@@ -32,12 +32,7 @@ import {
32
32
defaultGetNodeKey ,
33
33
defaultSearchMethod ,
34
34
} 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' ;
41
36
import styles from './react-sortable-tree.scss' ;
42
37
43
38
let treeIdCounter = 1 ;
@@ -54,16 +49,17 @@ class ReactSortableTree extends Component {
54
49
treeData,
55
50
} = props ;
56
51
52
+ this . dndManager = new DndManager ( this ) ;
53
+
57
54
// Wrapping classes for use with react-dnd
58
55
this . treeId = `rst__${ treeIdCounter } ` ;
59
56
treeIdCounter += 1 ;
60
57
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
65
61
) ;
66
- this . treeNodeRenderer = dndWrapTarget ( TreeNode , this . dndType ) ;
62
+ this . treeNodeRenderer = this . dndManager . wrapTarget ( TreeNode ) ;
67
63
68
64
// Prepare scroll-on-drag options for this list
69
65
if ( isVirtualized ) {
@@ -401,10 +397,7 @@ class ReactSortableTree extends Component {
401
397
) {
402
398
const {
403
399
canDrag,
404
- canDrop,
405
400
generateNodeProps,
406
- getNodeKey,
407
- maxDepth,
408
401
scaffoldBlockPxWidth,
409
402
searchFocusOffset,
410
403
} = this . props ;
@@ -434,7 +427,6 @@ class ReactSortableTree extends Component {
434
427
scaffoldBlockPxWidth,
435
428
node,
436
429
path,
437
- treeId : this . treeId ,
438
430
} ;
439
431
440
432
return (
@@ -443,24 +435,16 @@ class ReactSortableTree extends Component {
443
435
key = { nodeKey }
444
436
listIndex = { listIndex }
445
437
getPrevRow = { getPrevRow }
446
- treeData = { this . state . draggingTreeData || this . state . treeData }
447
- getNodeKey = { getNodeKey }
448
- customCanDrop = { canDrop }
449
438
lowerSiblingCounts = { lowerSiblingCounts }
450
439
swapFrom = { this . state . swapFrom }
451
440
swapLength = { this . state . swapLength }
452
441
swapDepth = { this . state . swapDepth }
453
- maxDepth = { maxDepth }
454
- dragHover = { this . dragHover }
455
- drop = { this . drop }
456
442
{ ...sharedProps }
457
443
>
458
444
< NodeContentRenderer
459
445
parentNode = { parentNode }
460
446
isSearchMatch = { isSearchMatch }
461
447
isSearchFocus = { isSearchFocus }
462
- startDrag = { this . startDrag }
463
- endDrag = { this . endDrag }
464
448
canDrag = { rowCanDrag }
465
449
toggleChildrenVisibility = { this . toggleChildrenVisibility }
466
450
{ ...sharedProps }
@@ -603,7 +587,7 @@ ReactSortableTree.propTypes = {
603
587
scaffoldBlockPxWidth : PropTypes . number ,
604
588
605
589
// 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
607
591
608
592
// The method used to search nodes.
609
593
// Defaults to a function that uses the `searchQuery` string to search for nodes with
@@ -658,7 +642,7 @@ ReactSortableTree.propTypes = {
658
642
canDrag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . bool ] ) ,
659
643
660
644
// 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
662
646
663
647
// Called after children nodes collapsed or expanded.
664
648
onVisibilityToggle : PropTypes . func ,
@@ -700,4 +684,4 @@ ReactSortableTree.contextTypes = {
700
684
// see: https://github.com/gaearon/react-dnd/issues/186
701
685
export { ReactSortableTree as SortableTreeWithoutDndContext } ;
702
686
703
- export default dndWrapRoot ( ReactSortableTree ) ;
687
+ export default DndManager . wrapRoot ( ReactSortableTree ) ;
0 commit comments