@@ -2,8 +2,9 @@ import * as React from 'react';
2
2
import RcTree , { TreeNode as RcTreeNode , TreeProps } from 'rc-tree' ;
3
3
import { Icon } from 'mo/components/icon' ;
4
4
import { prefixClaName , classNames } from 'mo/common/className' ;
5
- import { DataNode } from 'rc-tree/lib/interface' ;
5
+ import type { DataNode } from 'rc-tree/lib/interface' ;
6
6
import { FileTypes } from 'mo/model' ;
7
+ import type { LoadEventData } from 'mo/controller' ;
7
8
8
9
export interface ITreeNodeItemProps {
9
10
disabled ?: boolean ;
@@ -26,6 +27,7 @@ export interface ITreeProps extends Partial<TreeProps> {
26
27
isLeaf : boolean
27
28
) => JSX . Element | string ;
28
29
onDropTree ?( treeNode : ITreeNodeItemProps [ ] ) : void ;
30
+ onLoadData ?: ( treeNode : LoadEventData ) => Promise < void > ;
29
31
}
30
32
31
33
const TreeView = ( {
@@ -36,6 +38,7 @@ const TreeView = ({
36
38
onRightClick,
37
39
renderTitle, // custom title
38
40
onSelectNode,
41
+ onLoadData,
39
42
...restProps
40
43
} : ITreeProps ) => {
41
44
const [ selectedKeys , setKeys ] = React . useState < React . Key [ ] > ( [ ] ) ;
@@ -220,6 +223,7 @@ const TreeView = ({
220
223
switcherIcon = { < Icon type = "chevron-right" /> }
221
224
onSelect = { handleSelect }
222
225
onRightClick = { handleRightClick }
226
+ loadData = { onLoadData }
223
227
{ ...restProps }
224
228
>
225
229
{ renderTreeNodes ( data , 0 ) }
0 commit comments