-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Tree component now has a dndRootElement prop that accepts null, undefined, or an HTML Node. If this prop exists, the drag and drop event handlers that are required by react-dnd will be scoped to that element. Any other native drag and drop listeners will work if they are not contained by the dndRootElement.
- Loading branch information
Showing
7 changed files
with
77 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
"./packages/*" | ||
], | ||
"scripts": { | ||
"bump": "yarn workspace react-arborist version" | ||
"bump": "yarn workspace react-arborist version", | ||
"dev": "yarn workspace demo start" | ||
}, | ||
"private": true, | ||
"packageManager": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
import React from "react"; | ||
import React, { useRef } from "react"; | ||
// @ts-ignore | ||
import AutoSize from "react-virtualized-auto-sizer"; | ||
import { Tree, TreeApi } from "react-arborist"; | ||
import { Node } from "./node"; | ||
import { useBackend } from "./backend"; | ||
import { MyData, useBackend } from "./backend"; | ||
|
||
export function GotLineage() { | ||
const backend = useBackend(); | ||
const rootElement = useRef<HTMLDivElement | null>(null); | ||
return ( | ||
<AutoSize> | ||
{(props: any) => ( | ||
<Tree | ||
ref={(tree: TreeApi) => { | ||
// @ts-ignore | ||
global.tree = tree; | ||
}} | ||
className="react-aborist" | ||
data={backend.data} | ||
getChildren="children" | ||
isOpen="isOpen" | ||
disableDrop={(d) => d.name === "House Arryn"} | ||
hideRoot | ||
indent={24} | ||
onMove={backend.onMove} | ||
onToggle={backend.onToggle} | ||
onEdit={backend.onEdit} | ||
rowHeight={22} | ||
width={props.width} | ||
height={props.height} | ||
onClick={() => console.log("clicked the tree")} | ||
onContextMenu={() => console.log("context menu the tree")} | ||
> | ||
{Node} | ||
</Tree> | ||
)} | ||
</AutoSize> | ||
<div ref={rootElement} style={{ height: "100%", width: "100%" }}> | ||
<AutoSize> | ||
{(props: any) => ( | ||
<Tree | ||
ref={(tree) => { | ||
// @ts-ignore | ||
global.tree = tree; | ||
}} | ||
className="react-aborist" | ||
data={backend.data} | ||
getChildren="children" | ||
isOpen="isOpen" | ||
disableDrop={(d: MyData) => d.name === "House Arryn"} | ||
hideRoot | ||
indent={24} | ||
onMove={backend.onMove} | ||
onToggle={backend.onToggle} | ||
onEdit={backend.onEdit} | ||
rowHeight={22} | ||
width={props.width} | ||
height={props.height} | ||
onClick={() => console.log("clicked the tree")} | ||
onContextMenu={() => console.log("context menu the tree")} | ||
dndRootElement={undefined} | ||
> | ||
{Node} | ||
</Tree> | ||
)} | ||
</AutoSize> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters