@@ -16,6 +16,9 @@ import {
1616 insertNode ,
1717 getDescendantCount ,
1818} from './utils/tree-data-utils' ;
19+ import {
20+ swapRows ,
21+ } from './utils/generic-utils' ;
1922import {
2023 defaultGetNodeKey ,
2124 defaultToggleChildrenVisibility ,
@@ -89,19 +92,6 @@ class ReactSortableTree extends Component {
8992 } ) ;
9093 }
9194
92- swapRows ( rows , fromIndex , toIndex , count = 1 ) {
93- const rowsWithoutMoved = [
94- ...rows . slice ( 0 , fromIndex ) ,
95- ...rows . slice ( fromIndex + count ) ,
96- ] ;
97-
98- return [
99- ...rowsWithoutMoved . slice ( 0 , toIndex ) ,
100- ...rows . slice ( fromIndex , fromIndex + count ) ,
101- ...rowsWithoutMoved . slice ( toIndex ) ,
102- ] ;
103- }
104-
10595 startDrag ( { path } ) {
10696 const draggingTreeData = removeNodeAtPath ( {
10797 treeData : this . props . treeData ,
@@ -126,7 +116,7 @@ class ReactSortableTree extends Component {
126116 const rows = this . getRows ( addedResult . treeData ) ;
127117 const expandedParentPath = rows [ addedResult . treeIndex ] . path ;
128118 this . setState ( {
129- rows : this . swapRows (
119+ rows : swapRows (
130120 rows ,
131121 addedResult . treeIndex ,
132122 minimumTreeIndex ,
@@ -254,7 +244,6 @@ class ReactSortableTree extends Component {
254244 < NodeContentRenderer
255245 node = { node }
256246 path = { path }
257- lowerSiblingCounts = { lowerSiblingCounts }
258247 treeIndex = { treeIndex }
259248 startDrag = { this . startDrag }
260249 endDrag = { this . endDrag }
@@ -268,8 +257,7 @@ class ReactSortableTree extends Component {
268257}
269258
270259ReactSortableTree . propTypes = {
271- treeData : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
272- changeData : PropTypes . func ,
260+ treeData : PropTypes . arrayOf ( PropTypes . object ) . isRequired ,
273261
274262 // Callback for move operation.
275263 // Called as moveNode({ node, path, parentPath, minimumTreeIndex })
@@ -295,7 +283,6 @@ ReactSortableTree.propTypes = {
295283 getNodeKey : PropTypes . func ,
296284 updateTreeData : PropTypes . func ,
297285 toggleChildrenVisibility : PropTypes . func ,
298- loadCollapsedLazyChildren : PropTypes . bool ,
299286} ;
300287
301288ReactSortableTree . defaultProps = {
0 commit comments