-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tree-to-tree): Enable tree-to-tree drag-and-drop
Also makes implementation of external nodes more lightweight BREAKING CHANGE: `dropCancelled` and `addNewItem` callbacks on external nodes wrapped with `dndWrapExternalSource` are now ignored. Drag-and-drop now works without them.
- Loading branch information
Showing
10 changed files
with
821 additions
and
139 deletions.
There are no files selected for viewing
420 changes: 420 additions & 0 deletions
420
examples/storybooks/__snapshots__/storyshots.test.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { Component } from 'react'; | ||
// import { DragDropContext } from 'react-dnd'; | ||
// import HTML5Backend from 'react-dnd-html5-backend'; | ||
import SortableTree from '../../src'; | ||
// SortableTreeWithoutDndContext as SortableTree, | ||
// insertNode, | ||
// dndWrapExternalSource, | ||
|
||
const externalNodeType = 'yourNodeType'; | ||
|
||
class App extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
treeData1: [ | ||
{ title: 'node1', children: [{ title: 'Child node' }] }, | ||
{ title: 'node2' }, | ||
], | ||
treeData2: [{ title: 'node3' }, { title: 'node4' }], | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<div | ||
style={{ | ||
height: 350, | ||
width: 350, | ||
float: 'left', | ||
border: 'solid black 1px', | ||
}} | ||
> | ||
<SortableTree | ||
treeData={this.state.treeData1} | ||
onChange={treeData1 => this.setState({ treeData1 })} | ||
dndType={externalNodeType} | ||
/> | ||
</div> | ||
|
||
<div | ||
style={{ | ||
height: 350, | ||
width: 350, | ||
float: 'left', | ||
border: 'solid black 1px', | ||
}} | ||
> | ||
<SortableTree | ||
treeData={this.state.treeData2} | ||
onChange={treeData2 => this.setState({ treeData2 })} | ||
dndType={externalNodeType} | ||
/> | ||
</div> | ||
|
||
<div style={{ clear: 'both' }} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; |
Oops, something went wrong.