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