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