tree.d.ts
7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import { CreateElement, VNode } from 'vue';
import { ElementUIComponent } from './component';
export interface TreeData {
id?: any;
label?: string;
disabled?: boolean;
isLeaf?: boolean;
children?: TreeData[];
}
export interface TreeProps {
label: string;
disabled: string;
isLeaf: string;
children: string;
}
export interface TreeNode<K, D> {
checked: boolean;
childNodes: TreeNode<K, D>[];
data: D;
expanded: boolean;
id: number;
indeterminate: boolean;
isLeaf: boolean;
level: number;
loaded: boolean;
loading: boolean;
parent: TreeNode<K, D> | null;
store: any;
visible: boolean;
disabled: boolean;
icon: string;
key: K;
label: string;
nextSibling: TreeNode<K, D> | null;
previousSibling: TreeNode<K, D> | null;
}
/** incomplete, you can convert to any to use other properties */
export interface TreeStore<K, D> {
_getAllNodes: () => TreeNode<K, D>[];
}
/** Tree Component */
export declare class ElTree<K = any, D = TreeData> extends ElementUIComponent {
/** TreeStore */
store: TreeStore<K, D>;
/** Tree data */
data: D[];
/** Text displayed when data is void */
emptyText: string;
/** Unique identity key name for nodes, its value should be unique across the whole tree */
nodeKey: string;
/** Configuration options, see the following table */
props: TreeProps;
/** Method for loading subtree data */
load: (data: D, resolve: Function) => void;
/**
* Render function for a specific node
*
* @param h The render function
*/
renderContent: (h: CreateElement, context: { node: TreeNode<K, D>; data: D; store: TreeStore<K, D> }) => VNode;
/** Whether current node is highlighted */
highlightCurrent: boolean;
/** Whether to expand all nodes by default */
defaultExpandAll: boolean;
/** Whether to expand or collapse node when clicking on the node. If false, then expand or collapse node only when clicking on the arrow icon. */
expandOnClickNode: boolean;
/** Whether to check or uncheck node when clicking on the node, if false, the node can only be checked or unchecked by clicking on the checkbox. */
checkOnClickNode: boolean;
/** Whether to expand father node when a child node is expanded */
autoExpandParent: boolean;
/** Array of keys of initially expanded nodes */
defaultExpandedKeys: K[];
/** Whether node is selectable */
showCheckbox: boolean;
/** Whether checked state of a node not affects its father and child nodes when show-checkbox is true */
checkStrictly: boolean;
/** Array of keys of initially checked nodes */
defaultCheckedKeys: K[];
/**
* This function will be executed on each node when use filter method. If return false, tree node will be hidden.
*
* @param value The query string
* @param data The original data object
* @param node Tree node
*/
filterNodeMethod: (value: string, data: D, node: TreeNode<K, D>) => boolean;
/** Whether only one node among the same level can be expanded at one time */
accordion: boolean;
/** Horizontal indentation of nodes in adjacent levels in pixels */
indent: number;
/** Whether enable tree nodes drag and drop */
draggable: boolean;
/**
* Function to be executed before dragging a node
*
* @param node The node to be dragged
*/
allowDrag: (node: TreeNode<K, D>) => boolean;
/**
* Function to be executed before the dragging node is dropped
*
* @param draggingNode The dragging node
* @param dropNode The target node
* @param type Drop type
*/
allowDrop: (draggingNode: TreeNode<K, D>, dropNode: TreeNode<K, D>, type: 'prev' | 'inner' | 'next') => boolean;
/**
* Filter all tree nodes. Filtered nodes will be hidden
*
* @param value The value to be used as first parameter for `filter-node-method`
*/
filter(value: any): void;
/**
* Update the children of the node which specified by the key
*
* @param key the key of the node which children will be updated
* @param data the children data
*/
updateKeyChildren(key: K, data: D[]): void;
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes
*
* @param leafOnly If the `leafOnly` is `true`, it only returns the currently selected array of sub-nodes
* @param includeHalfChecked If the `includeHalfChecked` is `true`, the return value contains halfchecked nodes
*/
getCheckedNodes(leafOnly?: boolean, includeHalfChecked?: boolean): D[];
/**
* Set certain nodes to be checked. Only works when `node-key` is assigned
*
* @param nodes An array of nodes to be checked
* @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
*/
setCheckedNodes(data: D[], leafOnly?: boolean): void;
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of nodes' keys
*
* @param leafOnly If the `leafOnly` is `true`, it only returns the currently selected array of sub-nodes
*/
getCheckedKeys(leafOnly?: boolean): K[];
/**
* Set certain nodes to be checked. Only works when `node-key` is assigned
*
* @param keys An array of node's keys to be checked
* @param leafOnly If the parameter is true, it only returns the currently selected array of sub-nodes
*/
setCheckedKeys(keys: K[], leafOnly?: boolean): void;
/**
* Set node to be checked or not. Only works when `node-key` is assigned
*
* @param data Node's key or data to be checked
* @param checked Indicating the node checked or not
* @param deep Indicating whether to checked state deeply or not
*/
setChecked(data: D | K, checked: boolean, deep: boolean): void;
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently half selected array of nodes
*/
getHalfCheckedNodes(): D[];
/**
* If the node can be selected (`show-checkbox` is `true`), it returns the currently half selected array of nodes' keys
*/
getHalfCheckedKeys(): K[];
/**
* Return the highlight node's key (null if no node is highlighted)
*/
getCurrentKey(): K;
/**
* Set highlighted node by key, only works when node-key is assigned
*
* @param key The node's key to be highlighted
*/
setCurrentKey(key: K): void;
/**
* Return the highlight node data (null if no node is highlighted)
* @todo the name of methods should be getCurrentNodeData
*/
getCurrentNode(): D;
/**
* Set highlighted node, only works when node-key is assigned
*
* @param node The node to be highlighted
*/
setCurrentNode(data: D): void;
/**
* Get node by node key or node data
*
* @param by node key or node data
*/
getNode(by: D | K): TreeNode<K, D>;
/**
* Remove node by key or node data or node instance
*
* @param by key or node data or node instance
*/
remove(by: D | K): void;
/**
* Append a child node to specified node
*
* @param childData the data of appended node
* @param parent key or node data or node instance of the parent node
*/
append(childData: D, parent: D | K): void;
/**
* insert a node before specified node
*
* @param data the data of inserted node
* @param ref key or node data or node instance of the reference node
*/
insertBefore(data: D, ref: D | K): void;
/**
* insert a node after specified node
*
* @param data the data of inserted node
* @param ref key or node data or node instance of the reference node
*/
insertAfter(data: D, ref: D | K): void;
/** Custom tree node icon */
iconClass?: string;
}