@@ -19,13 +19,14 @@ TreeView.propTypes = {
19
19
template : PropTypes . func . isRequired ,
20
20
} ;
21
21
22
- function TreeNodes ( { childrenPath, depth, draggable, nodes, template } ) {
22
+ function TreeNodes ( { childrenPath, depth, draggable, nodes, parentNode , template } ) {
23
23
return (
24
24
< >
25
25
{ nodes . map ( ( node , index ) => (
26
26
< TreeNode
27
27
key = { index }
28
28
node = { node }
29
+ parentNode = { parentNode }
29
30
index = { index }
30
31
template = { template }
31
32
childrenPath = { childrenPath }
@@ -42,26 +43,34 @@ TreeNodes.propTypes = {
42
43
depth : PropTypes . number ,
43
44
draggable : PropTypes . bool ,
44
45
nodes : PropTypes . array ,
46
+ parentNode : PropTypes . object ,
45
47
template : PropTypes . func ,
46
48
} ;
47
49
48
- function TreeNode ( { node, index, template, childrenPath, depth, draggable } ) {
50
+ function TreeNode ( { node, parentNode , index, template, childrenPath, depth, draggable } ) {
49
51
const childrenNodes = getValueByPath ( node , childrenPath ) ;
50
52
51
53
return (
52
54
< div draggable = { draggable } >
53
55
< li className = "list-group-item" style = { { marginLeft : `${ depth * 20 } px` , borderTopWidth : '1px' } } >
54
- { template ( node , index ) }
56
+ { template ( node , index , parentNode ) }
55
57
</ li >
56
58
57
59
{ childrenNodes && (
58
- < TreeNodes nodes = { childrenNodes } template = { template } childrenPath = { childrenPath } depth = { depth + 1 } />
60
+ < TreeNodes
61
+ nodes = { childrenNodes }
62
+ parentNode = { node }
63
+ template = { template }
64
+ childrenPath = { childrenPath }
65
+ depth = { depth + 1 }
66
+ />
59
67
) }
60
68
</ div >
61
69
) ;
62
70
}
63
71
TreeNode . propTypes = {
64
72
node : PropTypes . object ,
73
+ parentNode : PropTypes . object ,
65
74
index : PropTypes . number ,
66
75
template : PropTypes . func ,
67
76
childrenPath : PropTypes . string ,
0 commit comments