-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
197 lines (168 loc) · 4.19 KB
/
index.d.ts
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
/*
* GPLv3 https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Author: eidng8
*/
import { Vue } from 'vue-property-decorator';
/**
* Tree item data
*/
declare interface G8TreeItem {
/**
* Just to allow accessing data via index syntax and arbitrary data to fit in.
*/
[key: string]: unknown;
/**
* Item name, serves as label, will be rendered as node label.
*/
name?: string;
/**
* Whether current node is checked.
*/
checked?: boolean;
/**
* Intermediate check box state. Active while some of the children were
* checked, but not all.
*/
intermediate?: boolean;
/**
* Whether the sub-tree of this node has been rendered.
*/
rendered?: boolean;
/**
* List of tags.
*/
tags?: G8TreeItemTag[];
/**
* List of child nodes.
*/
children?: G8TreeItem[];
}
/**
* Node tag data
*/
declare interface G8TreeItemTag {
/**
* Just to allow accessing data via index syntax and arbitrary data to fit in.
*/
[key: string]: unknown;
/**
* Tag label.
*/
label: string;
/**
* Tag tooltip. Visible when mouse hovers on the tag.
*/
hint?: string;
}
/**
* Fired when a node is clicked.
*/
declare class G8ClickEvent extends MouseEvent {
/**
* Data about the clicked node
*/
data: {
/**
* Whether the node has been expanded after the click.
*/
expanded: boolean;
/**
* The data item associated with the clicked node.
*/
item: G8TreeItem;
};
}
/**
* A tree view component with stable DOM structure. Stable means its structure
* will not change once rendered. This component uses CSS to toggle sub-tree.
* To improve performance, sub-trees are not rendered until they are first
* expanded. Once expanded, further collapse/expand action won't cause the
* sub-tree to be rendered again. Currently there is an
* [issue](https://github.com/eidng8/vue-tree/issues/24) about performance
* problem of large tree data set.
*/
declare class G8VueTree extends Vue {
/**
* Key of the field in `item` to be used as element's `id` attribute.
*/
itemId: string;
/**
* Key of the field in `item` that holds node label.
*/
itemLabel: string;
/**
* Key of the field in `item` that holds tags array.
*/
tagsKey: string;
/**
* Key of the field in `item` that holds child nodes array.
*/
childrenKey: string;
/**
* Key of the field in tags list of `item` to be used as tag element's `id`
* attribute.
*/
tagId: string;
/**
* Key of the field in tags list of `item` that holds tag label.
*/
tagLabel: string;
/**
* Key of the field in tags list of `item` that holds tag tooltip.
*/
tagHint: string;
/**
* Whether to add a checkbox before each item, allowing multiple nodes to
* be checked.
*/
checker: boolean;
/**
* The tree data to be rendered. Please note that data passed ***may*** be
* mutated by this component to reflect various states of tree nodes. Mutated
* fields include:
*
* - checked
* - intermediate
* - rendered
*/
item: G8TreeItem;
/**
* Whether the node is expanded.
*/
expanded: boolean;
/**
* Whether the node is checked. This must be a member field in order for
* binding to work.
*/
checked: boolean;
/**
* Intermediate check box state. Active while some of the children were
* checked, but not all were checked. This must be a member field in order for
* binding to work.
*/
intermediate: boolean;
/**
* Whether the current node has any child.
*/
get hasChild(): boolean;
/**
* Handles the click event of checkboxes. Sets whether the current node is
* checked. Also set propagates the state to all immediate children.
* This method emits the `state-changed` event.
* @param state
*/
setState(state: boolean): void;
/**
* Handles click event of nodes, expanding/collapsing sub-tree if
* applicable. This method emits the `click` event.
*/
clicked(event: G8ClickEvent): void;
/**
* Handles `state-changed` events emitted by children, updating the check
* state of current node according. This method also bubbles up the
* `state-changed` event.
* @param node
*/
childrenStateChanged(node: G8TreeItem): void;
}