@@ -32,12 +32,7 @@ import {
3232 defaultGetNodeKey ,
3333 defaultSearchMethod ,
3434} from './utils/default-handlers' ;
35- import {
36- dndWrapRoot ,
37- dndWrapSource ,
38- dndWrapTarget ,
39- dndWrapPlaceholder ,
40- } from './utils/drag-and-drop-utils' ;
35+ import DndManager from './utils/dnd-manager' ;
4136import styles from './react-sortable-tree.scss' ;
4237
4338let treeIdCounter = 1 ;
@@ -54,16 +49,17 @@ class ReactSortableTree extends Component {
5449 treeData,
5550 } = props ;
5651
52+ this . dndManager = new DndManager ( this ) ;
53+
5754 // Wrapping classes for use with react-dnd
5855 this . treeId = `rst__${ treeIdCounter } ` ;
5956 treeIdCounter += 1 ;
6057 this . dndType = dndType || this . treeId ;
61- this . nodeContentRenderer = dndWrapSource ( nodeContentRenderer , this . dndType ) ;
62- this . treePlaceholderRenderer = dndWrapPlaceholder (
63- TreePlaceholder ,
64- this . dndType
58+ this . nodeContentRenderer = this . dndManager . wrapSource ( nodeContentRenderer ) ;
59+ this . treePlaceholderRenderer = this . dndManager . wrapPlaceholder (
60+ TreePlaceholder
6561 ) ;
66- this . treeNodeRenderer = dndWrapTarget ( TreeNode , this . dndType ) ;
62+ this . treeNodeRenderer = this . dndManager . wrapTarget ( TreeNode ) ;
6763
6864 // Prepare scroll-on-drag options for this list
6965 if ( isVirtualized ) {
@@ -401,10 +397,7 @@ class ReactSortableTree extends Component {
401397 ) {
402398 const {
403399 canDrag,
404- canDrop,
405400 generateNodeProps,
406- getNodeKey,
407- maxDepth,
408401 scaffoldBlockPxWidth,
409402 searchFocusOffset,
410403 } = this . props ;
@@ -434,7 +427,6 @@ class ReactSortableTree extends Component {
434427 scaffoldBlockPxWidth,
435428 node,
436429 path,
437- treeId : this . treeId ,
438430 } ;
439431
440432 return (
@@ -443,24 +435,16 @@ class ReactSortableTree extends Component {
443435 key = { nodeKey }
444436 listIndex = { listIndex }
445437 getPrevRow = { getPrevRow }
446- treeData = { this . state . draggingTreeData || this . state . treeData }
447- getNodeKey = { getNodeKey }
448- customCanDrop = { canDrop }
449438 lowerSiblingCounts = { lowerSiblingCounts }
450439 swapFrom = { this . state . swapFrom }
451440 swapLength = { this . state . swapLength }
452441 swapDepth = { this . state . swapDepth }
453- maxDepth = { maxDepth }
454- dragHover = { this . dragHover }
455- drop = { this . drop }
456442 { ...sharedProps }
457443 >
458444 < NodeContentRenderer
459445 parentNode = { parentNode }
460446 isSearchMatch = { isSearchMatch }
461447 isSearchFocus = { isSearchFocus }
462- startDrag = { this . startDrag }
463- endDrag = { this . endDrag }
464448 canDrag = { rowCanDrag }
465449 toggleChildrenVisibility = { this . toggleChildrenVisibility }
466450 { ...sharedProps }
@@ -603,7 +587,7 @@ ReactSortableTree.propTypes = {
603587 scaffoldBlockPxWidth : PropTypes . number ,
604588
605589 // Maximum depth nodes can be inserted at. Defaults to infinite.
606- maxDepth : PropTypes . number ,
590+ maxDepth : PropTypes . number , // eslint-disable-line react/no-unused-prop-types
607591
608592 // The method used to search nodes.
609593 // Defaults to a function that uses the `searchQuery` string to search for nodes with
@@ -658,7 +642,7 @@ ReactSortableTree.propTypes = {
658642 canDrag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . bool ] ) ,
659643
660644 // Determine whether a node can be dropped based on its path and parents'.
661- canDrop : PropTypes . func ,
645+ canDrop : PropTypes . func , // eslint-disable-line react/no-unused-prop-types
662646
663647 // Called after children nodes collapsed or expanded.
664648 onVisibilityToggle : PropTypes . func ,
@@ -700,4 +684,4 @@ ReactSortableTree.contextTypes = {
700684// see: https://github.com/gaearon/react-dnd/issues/186
701685export { ReactSortableTree as SortableTreeWithoutDndContext } ;
702686
703- export default dndWrapRoot ( ReactSortableTree ) ;
687+ export default DndManager . wrapRoot ( ReactSortableTree ) ;
0 commit comments