1 | import type { BasicDataNode, TreeProps as RcTreeProps } from 'rc-tree';
|
2 | import RcTree from 'rc-tree';
|
3 | import type { DataNode, Key } from 'rc-tree/lib/interface';
|
4 | import * as React from 'react';
|
5 | export type SwitcherIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
|
6 | export type TreeLeafIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
|
7 | export interface AntdTreeNodeAttribute {
|
8 | eventKey: string;
|
9 | prefixCls: string;
|
10 | className: string;
|
11 | expanded: boolean;
|
12 | selected: boolean;
|
13 | checked: boolean;
|
14 | halfChecked: boolean;
|
15 | children: React.ReactNode;
|
16 | title: React.ReactNode;
|
17 | pos: string;
|
18 | dragOver: boolean;
|
19 | dragOverGapTop: boolean;
|
20 | dragOverGapBottom: boolean;
|
21 | isLeaf: boolean;
|
22 | selectable: boolean;
|
23 | disabled: boolean;
|
24 | disableCheckbox: boolean;
|
25 | }
|
26 | export interface AntTreeNodeProps {
|
27 | className?: string;
|
28 | checkable?: boolean;
|
29 | disabled?: boolean;
|
30 | disableCheckbox?: boolean;
|
31 | title?: string | React.ReactNode;
|
32 | key?: Key;
|
33 | eventKey?: string;
|
34 | isLeaf?: boolean;
|
35 | checked?: boolean;
|
36 | expanded?: boolean;
|
37 | loading?: boolean;
|
38 | selected?: boolean;
|
39 | selectable?: boolean;
|
40 | icon?: ((treeNode: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode;
|
41 | children?: React.ReactNode;
|
42 | [customProp: string]: any;
|
43 | }
|
44 | export interface AntTreeNode extends React.Component<AntTreeNodeProps, {}> {
|
45 | }
|
46 | export interface AntTreeNodeBaseEvent {
|
47 | node: AntTreeNode;
|
48 | nativeEvent: MouseEvent;
|
49 | }
|
50 | export interface AntTreeNodeCheckedEvent extends AntTreeNodeBaseEvent {
|
51 | event: 'check';
|
52 | checked?: boolean;
|
53 | checkedNodes?: AntTreeNode[];
|
54 | }
|
55 | export interface AntTreeNodeSelectedEvent extends AntTreeNodeBaseEvent {
|
56 | event: 'select';
|
57 | selected?: boolean;
|
58 | selectedNodes?: DataNode[];
|
59 | }
|
60 | export interface AntTreeNodeExpandedEvent extends AntTreeNodeBaseEvent {
|
61 | expanded?: boolean;
|
62 | }
|
63 | export interface AntTreeNodeMouseEvent {
|
64 | node: AntTreeNode;
|
65 | event: React.DragEvent<HTMLElement>;
|
66 | }
|
67 | export interface AntTreeNodeDragEnterEvent extends AntTreeNodeMouseEvent {
|
68 | expandedKeys: Key[];
|
69 | }
|
70 | export interface AntTreeNodeDropEvent {
|
71 | node: AntTreeNode;
|
72 | dragNode: AntTreeNode;
|
73 | dragNodesKeys: Key[];
|
74 | dropPosition: number;
|
75 | dropToGap?: boolean;
|
76 | event: React.MouseEvent<HTMLElement>;
|
77 | }
|
78 | export type TreeNodeNormal = DataNode;
|
79 | type DraggableFn = (node: DataNode) => boolean;
|
80 | interface DraggableConfig {
|
81 | icon?: React.ReactNode | false;
|
82 | nodeDraggable?: DraggableFn;
|
83 | }
|
84 | export interface TreeProps<T extends BasicDataNode = DataNode> extends Omit<RcTreeProps<T>, 'prefixCls' | 'showLine' | 'direction' | 'draggable' | 'icon' | 'switcherIcon'> {
|
85 | showLine?: boolean | {
|
86 | showLeafIcon: boolean | TreeLeafIcon;
|
87 | };
|
88 | className?: string;
|
89 |
|
90 | multiple?: boolean;
|
91 |
|
92 | autoExpandParent?: boolean;
|
93 |
|
94 | checkStrictly?: boolean;
|
95 |
|
96 | checkable?: boolean;
|
97 |
|
98 | disabled?: boolean;
|
99 |
|
100 | defaultExpandAll?: boolean;
|
101 |
|
102 | defaultExpandParent?: boolean;
|
103 |
|
104 | defaultExpandedKeys?: Key[];
|
105 |
|
106 | expandedKeys?: Key[];
|
107 |
|
108 | checkedKeys?: Key[] | {
|
109 | checked: Key[];
|
110 | halfChecked: Key[];
|
111 | };
|
112 |
|
113 | defaultCheckedKeys?: Key[];
|
114 |
|
115 | selectedKeys?: Key[];
|
116 |
|
117 | defaultSelectedKeys?: Key[];
|
118 | selectable?: boolean;
|
119 |
|
120 | filterAntTreeNode?: (node: AntTreeNode) => boolean;
|
121 | loadedKeys?: Key[];
|
122 |
|
123 | draggable?: DraggableFn | boolean | DraggableConfig;
|
124 | style?: React.CSSProperties;
|
125 | showIcon?: boolean;
|
126 | icon?: ((nodeProps: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode | RcTreeProps<T>['icon'];
|
127 | switcherIcon?: SwitcherIcon | RcTreeProps<T>['switcherIcon'];
|
128 | prefixCls?: string;
|
129 | children?: React.ReactNode;
|
130 | blockNode?: boolean;
|
131 | }
|
132 | declare const Tree: React.ForwardRefExoticComponent<TreeProps<DataNode> & React.RefAttributes<RcTree<DataNode>>>;
|
133 | export default Tree;
|
134 |
|
\ | No newline at end of file |