@cw-devops-fe/vue-tree-vue3 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,487 @@
1
+ import { default as TreeStore } from './model/tree-store';
2
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
+ data: {
4
+ type: ArrayConstructor;
5
+ default: () => never[];
6
+ };
7
+ emptyText: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
11
+ renderAfterExpand: {
12
+ type: BooleanConstructor;
13
+ default: boolean;
14
+ };
15
+ nodeKey: StringConstructor;
16
+ checkStrictly: BooleanConstructor;
17
+ defaultExpandAll: BooleanConstructor;
18
+ expandOnClickNode: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
22
+ checkOnClickNode: BooleanConstructor;
23
+ checkDescendants: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ autoExpandParent: {
28
+ type: BooleanConstructor;
29
+ default: boolean;
30
+ };
31
+ defaultCheckedKeys: ArrayConstructor;
32
+ defaultExpandedKeys: ArrayConstructor;
33
+ currentNodeKey: (StringConstructor | NumberConstructor)[];
34
+ renderContent: FunctionConstructor;
35
+ showCheckbox: {
36
+ type: BooleanConstructor;
37
+ default: boolean;
38
+ };
39
+ draggable: {
40
+ type: BooleanConstructor;
41
+ default: boolean;
42
+ };
43
+ allowDrag: FunctionConstructor;
44
+ allowDrop: FunctionConstructor;
45
+ props: {
46
+ default(): {
47
+ children: string;
48
+ label: string;
49
+ disabled: string;
50
+ };
51
+ };
52
+ lazy: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ highlightCurrent: BooleanConstructor;
57
+ load: FunctionConstructor;
58
+ filterNodeMethod: FunctionConstructor;
59
+ accordion: BooleanConstructor;
60
+ indent: {
61
+ type: NumberConstructor;
62
+ default: number;
63
+ };
64
+ iconClass: StringConstructor;
65
+ /** 开启虚拟滚动(只虚拟化第一层节点)。默认 false,数据量大时传 true */
66
+ virtual: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ }>, {
71
+ store: import('vue').Ref<{
72
+ currentNode: any;
73
+ currentNodeKey: any;
74
+ nodesMap: Record<string, any>;
75
+ root: {
76
+ id: number;
77
+ text: string | null;
78
+ checked: boolean;
79
+ indeterminate: boolean;
80
+ data: any;
81
+ expanded: boolean;
82
+ parent: any;
83
+ visible: boolean;
84
+ isCurrent: boolean;
85
+ level: number;
86
+ loaded: boolean;
87
+ childNodes: /*elided*/ any[];
88
+ loading: boolean;
89
+ store: any;
90
+ isLeaf: boolean;
91
+ isLeafByUser?: boolean | undefined;
92
+ setData: (data: any) => void;
93
+ readonly label: any;
94
+ readonly key: any;
95
+ readonly disabled: any;
96
+ readonly nextSibling: any;
97
+ readonly previousSibling: any;
98
+ contains: (target: import('./model/node').default, deep?: boolean) => boolean;
99
+ remove: () => void;
100
+ insertChild: (child: any, index?: number, batch?: boolean) => void;
101
+ insertBefore: (child: any, ref: import('./model/node').default) => void;
102
+ insertAfter: (child: any, ref: import('./model/node').default) => void;
103
+ removeChild: (child: import('./model/node').default) => void;
104
+ removeChildByData: (data: any) => void;
105
+ expand: (callback?: Function | null, expandParent?: boolean) => void;
106
+ doCreateChildren: (array: any[], defaultProps?: {}) => void;
107
+ collapse: () => void;
108
+ shouldLoadData: () => any;
109
+ updateLeafState: () => void;
110
+ setChecked: (value: any, deep?: boolean, recursion?: boolean, passValue?: any) => void;
111
+ getChildren: (forceInit?: boolean) => any;
112
+ updateChildren: () => void;
113
+ loadData: (callback?: Function, defaultProps?: {}) => void;
114
+ };
115
+ key: string;
116
+ data: any;
117
+ lazy: boolean;
118
+ load: Function | null;
119
+ props: any;
120
+ checkStrictly: boolean;
121
+ checkDescendants: boolean;
122
+ defaultCheckedKeys: any[];
123
+ defaultExpandedKeys: any[];
124
+ autoExpandParent: boolean;
125
+ defaultExpandAll: boolean;
126
+ filterNodeMethod: Function | null;
127
+ filter: (value: any) => void;
128
+ setData: (newVal: any) => void;
129
+ getNode: (data: any) => any;
130
+ insertBefore: (data: any, refData: any) => void;
131
+ insertAfter: (data: any, refData: any) => void;
132
+ remove: (data: any) => void;
133
+ append: (data: any, parentData?: any) => void;
134
+ _initDefaultCheckedNodes: () => void;
135
+ _initDefaultCheckedNode: (node: any) => void;
136
+ setDefaultCheckedKey: (newVal: any[]) => void;
137
+ registerNode: (node: any) => void;
138
+ deregisterNode: (node: any) => void;
139
+ getCheckedNodes: (leafOnly?: boolean, includeHalfChecked?: boolean) => any[];
140
+ getCheckedKeys: (leafOnly?: boolean) => any[];
141
+ getHalfCheckedNodes: () => any[];
142
+ getHalfCheckedKeys: () => any[];
143
+ _getAllNodes: () => any[];
144
+ updateChildren: (key: string, data: any[]) => void;
145
+ _setCheckedKeys: (key: string, leafOnly: boolean | undefined, checkedKeys: Record<string, boolean>) => void;
146
+ setCheckedNodes: (array: any[], leafOnly?: boolean) => void;
147
+ setCheckedKeys: (keys: any[], leafOnly?: boolean) => void;
148
+ setDefaultExpandedKeys: (keys: any[]) => void;
149
+ setChecked: (data: any, checked: boolean, deep?: boolean) => void;
150
+ getCurrentNode: () => any;
151
+ setCurrentNode: (currentNode: any) => void;
152
+ setUserCurrentNode: (node: any) => void;
153
+ setCurrentNodeKey: (key: any) => void;
154
+ } | null, TreeStore | {
155
+ currentNode: any;
156
+ currentNodeKey: any;
157
+ nodesMap: Record<string, any>;
158
+ root: {
159
+ id: number;
160
+ text: string | null;
161
+ checked: boolean;
162
+ indeterminate: boolean;
163
+ data: any;
164
+ expanded: boolean;
165
+ parent: any;
166
+ visible: boolean;
167
+ isCurrent: boolean;
168
+ level: number;
169
+ loaded: boolean;
170
+ childNodes: /*elided*/ any[];
171
+ loading: boolean;
172
+ store: any;
173
+ isLeaf: boolean;
174
+ isLeafByUser?: boolean | undefined;
175
+ setData: (data: any) => void;
176
+ readonly label: any;
177
+ readonly key: any;
178
+ readonly disabled: any;
179
+ readonly nextSibling: any;
180
+ readonly previousSibling: any;
181
+ contains: (target: import('./model/node').default, deep?: boolean) => boolean;
182
+ remove: () => void;
183
+ insertChild: (child: any, index?: number, batch?: boolean) => void;
184
+ insertBefore: (child: any, ref: import('./model/node').default) => void;
185
+ insertAfter: (child: any, ref: import('./model/node').default) => void;
186
+ removeChild: (child: import('./model/node').default) => void;
187
+ removeChildByData: (data: any) => void;
188
+ expand: (callback?: Function | null, expandParent?: boolean) => void;
189
+ doCreateChildren: (array: any[], defaultProps?: {}) => void;
190
+ collapse: () => void;
191
+ shouldLoadData: () => any;
192
+ updateLeafState: () => void;
193
+ setChecked: (value: any, deep?: boolean, recursion?: boolean, passValue?: any) => void;
194
+ getChildren: (forceInit?: boolean) => any;
195
+ updateChildren: () => void;
196
+ loadData: (callback?: Function, defaultProps?: {}) => void;
197
+ };
198
+ key: string;
199
+ data: any;
200
+ lazy: boolean;
201
+ load: Function | null;
202
+ props: any;
203
+ checkStrictly: boolean;
204
+ checkDescendants: boolean;
205
+ defaultCheckedKeys: any[];
206
+ defaultExpandedKeys: any[];
207
+ autoExpandParent: boolean;
208
+ defaultExpandAll: boolean;
209
+ filterNodeMethod: Function | null;
210
+ filter: (value: any) => void;
211
+ setData: (newVal: any) => void;
212
+ getNode: (data: any) => any;
213
+ insertBefore: (data: any, refData: any) => void;
214
+ insertAfter: (data: any, refData: any) => void;
215
+ remove: (data: any) => void;
216
+ append: (data: any, parentData?: any) => void;
217
+ _initDefaultCheckedNodes: () => void;
218
+ _initDefaultCheckedNode: (node: any) => void;
219
+ setDefaultCheckedKey: (newVal: any[]) => void;
220
+ registerNode: (node: any) => void;
221
+ deregisterNode: (node: any) => void;
222
+ getCheckedNodes: (leafOnly?: boolean, includeHalfChecked?: boolean) => any[];
223
+ getCheckedKeys: (leafOnly?: boolean) => any[];
224
+ getHalfCheckedNodes: () => any[];
225
+ getHalfCheckedKeys: () => any[];
226
+ _getAllNodes: () => any[];
227
+ updateChildren: (key: string, data: any[]) => void;
228
+ _setCheckedKeys: (key: string, leafOnly: boolean | undefined, checkedKeys: Record<string, boolean>) => void;
229
+ setCheckedNodes: (array: any[], leafOnly?: boolean) => void;
230
+ setCheckedKeys: (keys: any[], leafOnly?: boolean) => void;
231
+ setDefaultExpandedKeys: (keys: any[]) => void;
232
+ setChecked: (data: any, checked: boolean, deep?: boolean) => void;
233
+ getCurrentNode: () => any;
234
+ setCurrentNode: (currentNode: any) => void;
235
+ setUserCurrentNode: (node: any) => void;
236
+ setCurrentNodeKey: (key: any) => void;
237
+ } | null>;
238
+ root: import('vue').Ref<any, any>;
239
+ currentNode: import('vue').Ref<any, any>;
240
+ dragState: {
241
+ showDropIndicator: boolean;
242
+ draggingNode: any;
243
+ dropNode: any;
244
+ allowDrop: boolean;
245
+ dropType: string;
246
+ };
247
+ dropIndicator: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
248
+ treeContainerRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
249
+ virtualListRef: import('vue').Ref<any, any>;
250
+ isEmpty: import('vue').ComputedRef<any>;
251
+ getNodeKeyFn: (node: any) => any;
252
+ handleNodeExpand: (nodeData: any, node: any, nodeInstance: any) => void;
253
+ handleNodeCollapse: (nodeData: any, node: any, nodeInstance: any) => void;
254
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("node-expand" | "check-change" | "current-change" | "node-click" | "node-contextmenu" | "node-collapse" | "check" | "node-drag-start" | "node-drag-enter" | "node-drag-leave" | "node-drag-over" | "node-drag-end" | "node-drop")[], "node-expand" | "check-change" | "current-change" | "node-click" | "node-contextmenu" | "node-collapse" | "check" | "node-drag-start" | "node-drag-enter" | "node-drag-leave" | "node-drag-over" | "node-drag-end" | "node-drop", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
255
+ data: {
256
+ type: ArrayConstructor;
257
+ default: () => never[];
258
+ };
259
+ emptyText: {
260
+ type: StringConstructor;
261
+ default: string;
262
+ };
263
+ renderAfterExpand: {
264
+ type: BooleanConstructor;
265
+ default: boolean;
266
+ };
267
+ nodeKey: StringConstructor;
268
+ checkStrictly: BooleanConstructor;
269
+ defaultExpandAll: BooleanConstructor;
270
+ expandOnClickNode: {
271
+ type: BooleanConstructor;
272
+ default: boolean;
273
+ };
274
+ checkOnClickNode: BooleanConstructor;
275
+ checkDescendants: {
276
+ type: BooleanConstructor;
277
+ default: boolean;
278
+ };
279
+ autoExpandParent: {
280
+ type: BooleanConstructor;
281
+ default: boolean;
282
+ };
283
+ defaultCheckedKeys: ArrayConstructor;
284
+ defaultExpandedKeys: ArrayConstructor;
285
+ currentNodeKey: (StringConstructor | NumberConstructor)[];
286
+ renderContent: FunctionConstructor;
287
+ showCheckbox: {
288
+ type: BooleanConstructor;
289
+ default: boolean;
290
+ };
291
+ draggable: {
292
+ type: BooleanConstructor;
293
+ default: boolean;
294
+ };
295
+ allowDrag: FunctionConstructor;
296
+ allowDrop: FunctionConstructor;
297
+ props: {
298
+ default(): {
299
+ children: string;
300
+ label: string;
301
+ disabled: string;
302
+ };
303
+ };
304
+ lazy: {
305
+ type: BooleanConstructor;
306
+ default: boolean;
307
+ };
308
+ highlightCurrent: BooleanConstructor;
309
+ load: FunctionConstructor;
310
+ filterNodeMethod: FunctionConstructor;
311
+ accordion: BooleanConstructor;
312
+ indent: {
313
+ type: NumberConstructor;
314
+ default: number;
315
+ };
316
+ iconClass: StringConstructor;
317
+ /** 开启虚拟滚动(只虚拟化第一层节点)。默认 false,数据量大时传 true */
318
+ virtual: {
319
+ type: BooleanConstructor;
320
+ default: boolean;
321
+ };
322
+ }>> & Readonly<{
323
+ "onNode-expand"?: ((...args: any[]) => any) | undefined;
324
+ "onCheck-change"?: ((...args: any[]) => any) | undefined;
325
+ "onCurrent-change"?: ((...args: any[]) => any) | undefined;
326
+ "onNode-click"?: ((...args: any[]) => any) | undefined;
327
+ "onNode-contextmenu"?: ((...args: any[]) => any) | undefined;
328
+ "onNode-collapse"?: ((...args: any[]) => any) | undefined;
329
+ onCheck?: ((...args: any[]) => any) | undefined;
330
+ "onNode-drag-start"?: ((...args: any[]) => any) | undefined;
331
+ "onNode-drag-enter"?: ((...args: any[]) => any) | undefined;
332
+ "onNode-drag-leave"?: ((...args: any[]) => any) | undefined;
333
+ "onNode-drag-over"?: ((...args: any[]) => any) | undefined;
334
+ "onNode-drag-end"?: ((...args: any[]) => any) | undefined;
335
+ "onNode-drop"?: ((...args: any[]) => any) | undefined;
336
+ }>, {
337
+ data: unknown[];
338
+ props: {
339
+ children: string;
340
+ label: string;
341
+ disabled: string;
342
+ };
343
+ renderAfterExpand: boolean;
344
+ showCheckbox: boolean;
345
+ draggable: boolean;
346
+ checkStrictly: boolean;
347
+ defaultExpandAll: boolean;
348
+ checkOnClickNode: boolean;
349
+ highlightCurrent: boolean;
350
+ accordion: boolean;
351
+ emptyText: string;
352
+ expandOnClickNode: boolean;
353
+ checkDescendants: boolean;
354
+ autoExpandParent: boolean;
355
+ lazy: boolean;
356
+ indent: number;
357
+ virtual: boolean;
358
+ }, {}, {
359
+ VueTreeNode: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
360
+ node: {
361
+ type: ObjectConstructor;
362
+ required: true;
363
+ };
364
+ renderContent: FunctionConstructor;
365
+ renderAfterExpand: {
366
+ type: BooleanConstructor;
367
+ default: boolean;
368
+ };
369
+ showCheckbox: {
370
+ type: BooleanConstructor;
371
+ default: boolean;
372
+ };
373
+ }>, {
374
+ tree: any;
375
+ nodeRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
376
+ expanded: import('vue').Ref<boolean, boolean>;
377
+ childNodeRendered: import('vue').Ref<boolean, boolean>;
378
+ nodeContentComponent: import('vue').ComputedRef<{
379
+ props: {
380
+ node: {
381
+ type: ObjectConstructor;
382
+ required: boolean;
383
+ };
384
+ };
385
+ setup(innerProps: any): () => any;
386
+ }>;
387
+ getNodeKey: (node: any) => any;
388
+ handleClick: () => void;
389
+ handleContextMenu: (event: MouseEvent) => void;
390
+ handleExpandIconClick: () => void;
391
+ handleCheckChange: (ev: Event) => void;
392
+ handleChildNodeExpand: (nodeData: any, node: any, instance: any) => void;
393
+ handleDragStart: (event: DragEvent) => void;
394
+ handleDragOver: (event: DragEvent) => void;
395
+ handleDrop: (event: DragEvent) => void;
396
+ handleDragEnd: (event: DragEvent) => void;
397
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "node-expand"[], "node-expand", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
398
+ node: {
399
+ type: ObjectConstructor;
400
+ required: true;
401
+ };
402
+ renderContent: FunctionConstructor;
403
+ renderAfterExpand: {
404
+ type: BooleanConstructor;
405
+ default: boolean;
406
+ };
407
+ showCheckbox: {
408
+ type: BooleanConstructor;
409
+ default: boolean;
410
+ };
411
+ }>> & Readonly<{
412
+ "onNode-expand"?: ((...args: any[]) => any) | undefined;
413
+ }>, {
414
+ renderAfterExpand: boolean;
415
+ showCheckbox: boolean;
416
+ }, {}, {
417
+ TreeCollapseTransition: import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
418
+ [key: string]: any;
419
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
420
+ }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
421
+ VirtualList: {
422
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('@cw-devops-fe/virtual-list-vue3').VirtualListProps> & Readonly<{
423
+ "onLoading-change"?: ((value: boolean) => any) | undefined;
424
+ }>, {
425
+ isIndexVisible: (index: number) => boolean;
426
+ scrollToIndex: (index?: number) => Promise<void>;
427
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
428
+ "loading-change": (value: boolean) => any;
429
+ }, import('vue').PublicProps, {
430
+ listData: unknown[];
431
+ estimatedItemSizes: number[];
432
+ bufferScale: number;
433
+ height: string;
434
+ showLoading: boolean;
435
+ }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
436
+ listRef: HTMLDivElement;
437
+ phantomRef: HTMLDivElement;
438
+ contentRef: HTMLDivElement;
439
+ }, HTMLDivElement, import('vue').ComponentProvideOptions, {
440
+ P: {};
441
+ B: {};
442
+ D: {};
443
+ C: {};
444
+ M: {};
445
+ Defaults: {};
446
+ }, Readonly<import('@cw-devops-fe/virtual-list-vue3').VirtualListProps> & Readonly<{
447
+ "onLoading-change"?: ((value: boolean) => any) | undefined;
448
+ }>, {
449
+ isIndexVisible: (index: number) => boolean;
450
+ scrollToIndex: (index?: number) => Promise<void>;
451
+ }, {}, {}, {}, {
452
+ listData: unknown[];
453
+ estimatedItemSizes: number[];
454
+ bufferScale: number;
455
+ height: string;
456
+ showLoading: boolean;
457
+ }>;
458
+ __isFragment?: never;
459
+ __isTeleport?: never;
460
+ __isSuspense?: never;
461
+ } & import('vue').ComponentOptionsBase<Readonly<import('@cw-devops-fe/virtual-list-vue3').VirtualListProps> & Readonly<{
462
+ "onLoading-change"?: ((value: boolean) => any) | undefined;
463
+ }>, {
464
+ isIndexVisible: (index: number) => boolean;
465
+ scrollToIndex: (index?: number) => Promise<void>;
466
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
467
+ "loading-change": (value: boolean) => any;
468
+ }, string, {
469
+ listData: unknown[];
470
+ estimatedItemSizes: number[];
471
+ bufferScale: number;
472
+ height: string;
473
+ showLoading: boolean;
474
+ }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
475
+ $slots: {
476
+ loading?(_: {}): any;
477
+ default?(_: {
478
+ item: {
479
+ item: Record<string, unknown>;
480
+ index: string;
481
+ top: number;
482
+ };
483
+ }): any;
484
+ };
485
+ });
486
+ }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
487
+ export default _default;
@@ -0,0 +1,63 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
+ node: {
3
+ type: ObjectConstructor;
4
+ required: true;
5
+ };
6
+ renderContent: FunctionConstructor;
7
+ renderAfterExpand: {
8
+ type: BooleanConstructor;
9
+ default: boolean;
10
+ };
11
+ showCheckbox: {
12
+ type: BooleanConstructor;
13
+ default: boolean;
14
+ };
15
+ }>, {
16
+ tree: any;
17
+ nodeRef: import('vue').Ref<HTMLElement | undefined, HTMLElement | undefined>;
18
+ expanded: import('vue').Ref<boolean, boolean>;
19
+ childNodeRendered: import('vue').Ref<boolean, boolean>;
20
+ nodeContentComponent: import('vue').ComputedRef<{
21
+ props: {
22
+ node: {
23
+ type: ObjectConstructor;
24
+ required: boolean;
25
+ };
26
+ };
27
+ setup(innerProps: any): () => any;
28
+ }>;
29
+ getNodeKey: (node: any) => any;
30
+ handleClick: () => void;
31
+ handleContextMenu: (event: MouseEvent) => void;
32
+ handleExpandIconClick: () => void;
33
+ handleCheckChange: (ev: Event) => void;
34
+ handleChildNodeExpand: (nodeData: any, node: any, instance: any) => void;
35
+ handleDragStart: (event: DragEvent) => void;
36
+ handleDragOver: (event: DragEvent) => void;
37
+ handleDrop: (event: DragEvent) => void;
38
+ handleDragEnd: (event: DragEvent) => void;
39
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "node-expand"[], "node-expand", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
40
+ node: {
41
+ type: ObjectConstructor;
42
+ required: true;
43
+ };
44
+ renderContent: FunctionConstructor;
45
+ renderAfterExpand: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ showCheckbox: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
53
+ }>> & Readonly<{
54
+ "onNode-expand"?: ((...args: any[]) => any) | undefined;
55
+ }>, {
56
+ renderAfterExpand: boolean;
57
+ showCheckbox: boolean;
58
+ }, {}, {
59
+ TreeCollapseTransition: import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
60
+ [key: string]: any;
61
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
62
+ }, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
63
+ export default _default;
@@ -0,0 +1,4 @@
1
+ export declare function objectAssign(target: Record<string, unknown>, ...sources: Record<string, unknown>[]): Record<string, unknown>;
2
+ export declare function arrayFindIndex<T>(arr: T[], pred: (item: T) => boolean): number;
3
+ export declare function addClass(el: HTMLElement, cls: string): void;
4
+ export declare function removeClass(el: HTMLElement, cls: string): void;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("vue"),we=require("@cw-devops-fe/virtual-list-vue3"),T="$treeNodeId",Z=function(t,e){!e||e[T]||Object.defineProperty(e,T,{value:t.id,enumerable:!1,configurable:!1,writable:!1})},W=function(t,e){return t?e[t]:e[T]},$=t=>{let e=!0,n=!0,o=!0;for(let i=0,s=t.length;i<s;i++){const c=t[i];(c.checked!==!0||c.indeterminate)&&(e=!1,c.disabled||(o=!1)),(c.checked!==!1||c.indeterminate)&&(n=!1)}return{all:e,none:n,allWithoutDisable:o,half:!e&&!n}},M=function(t){if(t.childNodes.length===0||t.loading)return;const{all:e,half:n,none:o}=$(t.childNodes);e?(t.checked=!0,t.indeterminate=!1):n?(t.checked=!1,t.indeterminate=!0):o&&(t.checked=!1,t.indeterminate=!1);const i=t.parent;!i||i.level===0||t.store.checkStrictly||M(i)},A=function(t,e){const n=t.store.props,o=t.data||{},i=n[e];if(typeof i=="function")return i(o,t);if(typeof i=="string")return o[i];if(typeof i>"u"){const s=o[e];return s===void 0?"":s}};let be=0;class S{constructor(e){this.id=be++,this.text=null,this.checked=!1,this.indeterminate=!1,this.data=null,this.expanded=!1,this.parent=null,this.visible=!0,this.isCurrent=!1,this.isLeaf=!1;for(const c in e)Object.prototype.hasOwnProperty.call(e,c)&&(this[c]=e[c]);this.level=0,this.loaded=!1,this.childNodes=[],this.loading=!1,this.parent&&(this.level=this.parent.level+1);const n=this.store;if(!n)throw new Error("[Node]store is required!");n.registerNode(this);const o=n.props;if(o&&typeof o.isLeaf<"u"){const c=A(this,"isLeaf");typeof c=="boolean"&&(this.isLeafByUser=c)}if(n.lazy!==!0&&this.data?(this.setData(this.data),n.defaultExpandAll&&(this.expanded=!0)):this.level>0&&n.lazy&&n.defaultExpandAll&&this.expand(),Array.isArray(this.data)||Z(this,this.data),!this.data)return;const i=n.defaultExpandedKeys,s=n.key;s&&i&&i.indexOf(this.key)!==-1&&this.expand(null,n.autoExpandParent),s&&n.currentNodeKey!==void 0&&this.key===n.currentNodeKey&&(n.currentNode=this,n.currentNode.isCurrent=!0),n.lazy&&n._initDefaultCheckedNode(this),this.updateLeafState()}setData(e){Array.isArray(e)||Z(this,e),this.data=e,this.childNodes=[];let n;this.level===0&&this.data instanceof Array?n=this.data:n=A(this,"children")||[];for(let o=0,i=n.length;o<i;o++)this.insertChild({data:n[o]})}get label(){return A(this,"label")}get key(){const e=this.store.key;return this.data?this.data[e]:null}get disabled(){return A(this,"disabled")}get nextSibling(){const e=this.parent;if(e){const n=e.childNodes.indexOf(this);if(n>-1)return e.childNodes[n+1]}return null}get previousSibling(){const e=this.parent;if(e){const n=e.childNodes.indexOf(this);if(n>-1)return n>0?e.childNodes[n-1]:null}return null}contains(e,n=!0){const o=function(i){const s=i.childNodes||[];let c=!1;for(let h=0,y=s.length;h<y;h++){const f=s[h];if(f===e||n&&o(f)){c=!0;break}}return c};return o(this)}remove(){const e=this.parent;e&&e.removeChild(this)}insertChild(e,n,o){if(!e)throw new Error("insertChild error: child is required.");if(!(e instanceof S)){if(!o){const i=this.getChildren(!0)||[];i.indexOf(e.data)===-1&&(typeof n>"u"||n<0?i.push(e.data):i.splice(n,0,e.data))}Object.assign(e,{parent:this,store:this.store}),e=new S(e)}e.level=this.level+1,typeof n>"u"||n<0?this.childNodes.push(e):this.childNodes.splice(n,0,e),this.updateLeafState()}insertBefore(e,n){let o;n&&(o=this.childNodes.indexOf(n)),this.insertChild(e,o)}insertAfter(e,n){let o;n&&(o=this.childNodes.indexOf(n),o!==-1&&(o+=1)),this.insertChild(e,o)}removeChild(e){const n=this.getChildren()||[],o=n.indexOf(e.data);o>-1&&n.splice(o,1);const i=this.childNodes.indexOf(e);i>-1&&(this.store&&this.store.deregisterNode(e),e.parent=null,this.childNodes.splice(i,1)),this.updateLeafState()}removeChildByData(e){let n=null;for(let o=0;o<this.childNodes.length;o++)if(this.childNodes[o].data===e){n=this.childNodes[o];break}n&&this.removeChild(n)}expand(e,n){const o=()=>{if(n){let i=this.parent;for(;i.level>0;)i.expanded=!0,i=i.parent}this.expanded=!0,e&&e()};this.shouldLoadData()?this.loadData(i=>{i instanceof Array&&(this.checked?this.setChecked(!0,!0):this.store.checkStrictly||M(this),o())}):o()}doCreateChildren(e,n={}){e.forEach(o=>{this.insertChild(Object.assign({data:o},n),void 0,!0)})}collapse(){this.expanded=!1}shouldLoadData(){return this.store.lazy===!0&&this.store.load&&!this.loaded}updateLeafState(){if(this.store.lazy===!0&&this.loaded!==!0&&typeof this.isLeafByUser<"u"){this.isLeaf=this.isLeafByUser;return}const e=this.childNodes;if(!this.store.lazy||this.store.lazy===!0&&this.loaded===!0){this.isLeaf=!e||e.length===0;return}this.isLeaf=!1}setChecked(e,n,o,i){if(this.indeterminate=e==="half",this.checked=e===!0,this.store.checkStrictly)return;if(!(this.shouldLoadData()&&!this.store.checkDescendants)){const{allWithoutDisable:c}=$(this.childNodes);!this.isLeaf&&!$(this.childNodes).all&&c&&(this.checked=!1,e=!1);const h=()=>{if(n){const y=this.childNodes;for(let k=0,v=y.length;k<v;k++){const E=y[k];i=i||e!==!1;const D=E.disabled?E.checked:i;E.setChecked(D,n,!0,i)}const{half:f,all:C}=$(y);C||(this.checked=C,this.indeterminate=f)}};if(this.shouldLoadData()){this.loadData(()=>{h(),M(this)},{checked:e!==!1});return}else h()}const s=this.parent;!s||s.level===0||o||M(s)}getChildren(e=!1){if(this.level===0)return this.data;const n=this.data;if(!n)return null;const o=this.store.props;let i="children";return o&&(i=o.children||"children"),n[i]===void 0&&(n[i]=null),e&&!n[i]&&(n[i]=[]),n[i]}updateChildren(){const e=this.getChildren()||[],n=this.childNodes.map(s=>s.data),o={},i=[];e.forEach((s,c)=>{const h=s[T];!!h&&n.findIndex(f=>f[T]===h)>=0?o[h]={index:c,data:s}:i.push({index:c,data:s})}),this.store.lazy||n.forEach(s=>{o[s[T]]||this.removeChildByData(s)}),i.forEach(({index:s,data:c})=>{this.insertChild({data:c},s)}),this.updateLeafState()}loadData(e,n={}){if(this.store.lazy===!0&&this.store.load&&!this.loaded&&(!this.loading||Object.keys(n).length)){this.loading=!0;const o=i=>{this.childNodes=[],this.doCreateChildren(i,n),this.loaded=!0,this.loading=!1,this.updateLeafState(),e&&e.call(this,i)};this.store.load(this,o)}else e&&e.call(this)}}class De{constructor(e){this.currentNode=null,this.currentNodeKey=null,this.key="",this.data=null,this.lazy=!1,this.load=null,this.props={},this.checkStrictly=!1,this.checkDescendants=!1,this.defaultCheckedKeys=[],this.defaultExpandedKeys=[],this.autoExpandParent=!0,this.defaultExpandAll=!1,this.filterNodeMethod=null;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this[n]=e[n]);if(this.nodesMap={},this.root=new S({data:this.data,store:this}),this.lazy&&this.load){const n=this.load;n(this.root,o=>{this.root.doCreateChildren(o),this._initDefaultCheckedNodes()})}else this._initDefaultCheckedNodes()}filter(e){const n=this.filterNodeMethod,o=this.lazy,i=function(s){const c=s.root?s.root.childNodes:s.childNodes;if(c.forEach(h=>{h.visible=n.call(h,e,h.data,h),i(h)}),!s.visible&&c.length){let h=!0;h=!c.some(y=>y.visible),s.root?s.root.visible=h===!1:s.visible=h===!1}e&&s.visible&&!s.isLeaf&&!o&&s.expand()};i(this)}setData(e){e!==this.root.data?(this.root.setData(e),this._initDefaultCheckedNodes()):this.root.updateChildren()}getNode(e){if(e instanceof S)return e;const n=typeof e!="object"?e:W(this.key,e);return this.nodesMap[n]||null}insertBefore(e,n){const o=this.getNode(n);o.parent.insertBefore({data:e},o)}insertAfter(e,n){const o=this.getNode(n);o.parent.insertAfter({data:e},o)}remove(e){const n=this.getNode(e);n&&n.parent&&(n===this.currentNode&&(this.currentNode=null),n.parent.removeChild(n))}append(e,n){const o=n?this.getNode(n):this.root;o&&o.insertChild({data:e})}_initDefaultCheckedNodes(){const e=this.defaultCheckedKeys||[],n=this.nodesMap;e.forEach(o=>{const i=n[o];i&&i.setChecked(!0,!this.checkStrictly)})}_initDefaultCheckedNode(e){(this.defaultCheckedKeys||[]).indexOf(e.key)!==-1&&e.setChecked(!0,!this.checkStrictly)}setDefaultCheckedKey(e){e!==this.defaultCheckedKeys&&(this.defaultCheckedKeys=e,this._initDefaultCheckedNodes())}registerNode(e){if(!this.key||!e||!e.data)return;e.key!==void 0&&(this.nodesMap[e.key]=e)}deregisterNode(e){!this.key||!e||!e.data||(e.childNodes.forEach(o=>{this.deregisterNode(o)}),delete this.nodesMap[e.key])}getCheckedNodes(e=!1,n=!1){const o=[],i=function(s){(s.root?s.root.childNodes:s.childNodes).forEach(h=>{(h.checked||n&&h.indeterminate)&&(!e||e&&h.isLeaf)&&o.push(h.data),i(h)})};return i(this),o}getCheckedKeys(e=!1){return this.getCheckedNodes(e).map(n=>(n||{})[this.key])}getHalfCheckedNodes(){const e=[],n=function(o){(o.root?o.root.childNodes:o.childNodes).forEach(s=>{s.indeterminate&&e.push(s.data),n(s)})};return n(this),e}getHalfCheckedKeys(){return this.getHalfCheckedNodes().map(e=>(e||{})[this.key])}_getAllNodes(){const e=[],n=this.nodesMap;for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&e.push(n[o]);return e}updateChildren(e,n){const o=this.nodesMap[e];if(!o)return;const i=o.childNodes;for(let s=i.length-1;s>=0;s--){const c=i[s];this.remove(c.data)}for(let s=0,c=n.length;s<c;s++){const h=n[s];this.append(h,o.data)}}_setCheckedKeys(e,n=!1,o){const i=this._getAllNodes().sort((h,y)=>y.level-h.level),s=Object.create(null),c=Object.keys(o);i.forEach(h=>h.setChecked(!1,!1));for(let h=0,y=i.length;h<y;h++){const f=i[h],C=f.data[e].toString();if(!(c.indexOf(C)>-1)){f.checked&&!s[C]&&f.setChecked(!1,!1);continue}let v=f.parent;for(;v&&v.level>0;)s[v.data[e]]=!0,v=v.parent;if(f.isLeaf||this.checkStrictly){f.setChecked(!0,!1);continue}if(f.setChecked(!0,!0),n){f.setChecked(!1,!1);const E=function(D){D.childNodes.forEach(x=>{x.isLeaf||x.setChecked(!1,!1),E(x)})};E(f)}}}setCheckedNodes(e,n=!1){const o=this.key,i={};e.forEach(s=>{i[(s||{})[o]]=!0}),this._setCheckedKeys(o,n,i)}setCheckedKeys(e,n=!1){this.defaultCheckedKeys=e;const o=this.key,i={};e.forEach(s=>{i[s]=!0}),this._setCheckedKeys(o,n,i)}setDefaultExpandedKeys(e){e=e||[],this.defaultExpandedKeys=e,e.forEach(n=>{const o=this.getNode(n);o&&o.expand(null,this.autoExpandParent)})}setChecked(e,n,o){const i=this.getNode(e);i&&i.setChecked(!!n,o)}getCurrentNode(){return this.currentNode}setCurrentNode(e){const n=this.currentNode;n&&(n.isCurrent=!1),this.currentNode=e,this.currentNode.isCurrent=!0}setUserCurrentNode(e){const n=e[this.key],o=this.nodesMap[n];this.setCurrentNode(o)}setCurrentNodeKey(e){if(e==null){this.currentNode&&(this.currentNode.isCurrent=!1),this.currentNode=null;return}const n=this.getNode(e);n&&this.setCurrentNode(n)}}const _=(t,e)=>t.classList.add(e),ee=(t,e)=>t.classList.remove(e),xe=d.defineComponent({name:"TreeCollapseTransition",setup(t,{slots:e}){return()=>d.h(d.Transition,{onBeforeEnter(n){const o=n;_(o,"collapse-transition"),o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0"},onEnter(n){const o=n;o.dataset.oldOverflow=o.style.overflow,o.scrollHeight!==0?(o.style.height=o.scrollHeight+"px",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""):(o.style.height="",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""),o.style.overflow="hidden"},onAfterEnter(n){const o=n;ee(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||""},onBeforeLeave(n){const o=n;o.dataset.oldPaddingTop=o.style.paddingTop,o.dataset.oldPaddingBottom=o.style.paddingBottom,o.dataset.oldOverflow=o.style.overflow,o.style.height=o.scrollHeight+"px",o.style.overflow="hidden"},onLeave(n){const o=n;o.scrollHeight!==0&&(_(o,"collapse-transition"),o.style.height="0",o.style.paddingTop="0",o.style.paddingBottom="0")},onAfterLeave(n){const o=n;ee(o,"collapse-transition"),o.style.height="",o.style.overflow=o.dataset.oldOverflow||"",o.style.paddingTop=o.dataset.oldPaddingTop||"",o.style.paddingBottom=o.dataset.oldPaddingBottom||""}},e.default)}}),Be=d.defineComponent({name:"VueTreeNode",components:{TreeCollapseTransition:xe},props:{node:{type:Object,required:!0},renderContent:Function,renderAfterExpand:{type:Boolean,default:!0},showCheckbox:{type:Boolean,default:!1}},emits:["node-expand"],setup(t,{emit:e}){const n=d.inject("vueTree"),o=d.ref(),i=d.ref(!1),s=d.ref(!1),c=d.ref(null),h=d.ref(null),y=d.computed(()=>({props:{node:{type:Object,required:!0}},setup(u){return()=>{var N;return t.renderContent?t.renderContent(d.h,{_self:n,node:u.node,data:u.node.data,store:u.node.store}):(N=n==null?void 0:n.slots)!=null&&N.default?n.slots.default({node:u.node,data:u.node.data}):d.h("span",{class:"vue-tree-node__label"},u.node.label)}}}));d.watch(()=>t.node.indeterminate,u=>{C(t.node.checked,u)}),d.watch(()=>t.node.checked,u=>{C(u,t.node.indeterminate)}),d.watch(()=>t.node.expanded,u=>{d.nextTick(()=>i.value=u),u&&(s.value=!0)});function f(u){return W(n.nodeKey,u.data)}function C(u,N){(c.value!==u||h.value!==N)&&n.emitEvent("check-change",t.node.data,u,N),c.value=u,h.value=N}function k(){const u=n.store;u.setCurrentNode(t.node),n.emitEvent("current-change",u.currentNode?u.currentNode.data:null,u.currentNode),n.currentNode=o.value,n.expandOnClickNode&&E(),n.checkOnClickNode&&!t.node.disabled&&D({target:{checked:!t.node.checked}}),n.emitEvent("node-click",t.node.data,t.node,{$el:o.value})}function v(u){n.emitEvent("node-contextmenu",u,t.node.data,t.node,{$el:o.value})}function E(){t.node.isLeaf||(i.value?(n.emitEvent("node-collapse",t.node.data,t.node,{$el:o.value}),t.node.collapse()):(t.node.expand(),e("node-expand",t.node.data,t.node,{$el:o.value})))}function D(u){const N=u.target;t.node.setChecked(N.checked,!n.checkStrictly),d.nextTick(()=>{const B=n.store;n.emitEvent("check",t.node.data,{checkedNodes:B.getCheckedNodes(),checkedKeys:B.getCheckedKeys(),halfCheckedNodes:B.getHalfCheckedNodes(),halfCheckedKeys:B.getHalfCheckedKeys()})})}function O(u,N,B){n.broadcastTreeNodeExpand(N),n.emitEvent("node-expand",u,N,B)}function x(u){n.draggable&&n.handleTreeNodeDragStart(u,{node:t.node,$el:o.value})}function I(u){n.draggable&&(n.handleTreeNodeDragOver(u,{node:t.node,$el:o.value}),u.preventDefault())}function P(u){u.preventDefault()}function z(u){n.draggable&&n.handleTreeNodeDragEnd(u,{node:t.node,$el:o.value})}const j=u=>{t.node!==u&&t.node.collapse()};d.onMounted(()=>{n.accordion&&n.onAccordionExpand(j)});const L=(n.props||{}).children||"children";return d.watch(()=>{var u;return(u=t.node.data)==null?void 0:u[L]},()=>{t.node.updateChildren()}),t.node.expanded&&(i.value=!0,s.value=!0),{tree:n,nodeRef:o,expanded:i,childNodeRendered:s,nodeContentComponent:y,getNodeKey:f,handleClick:k,handleContextMenu:v,handleExpandIconClick:E,handleCheckChange:D,handleChildNodeExpand:O,handleDragStart:x,handleDragOver:I,handleDrop:P,handleDragEnd:z}}}),te=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n},Te=["aria-expanded","aria-disabled","aria-checked","draggable"],Se=["checked","disabled"],Oe={key:1,class:"vue-tree-node__loading-icon vue-icon-loading"},Le=["aria-expanded"];function Ae(t,e,n,o,i,s){var y;const c=d.resolveComponent("vue-tree-node",!0),h=d.resolveComponent("tree-collapse-transition");return d.withDirectives((d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["vue-tree-node",{"is-expanded":t.expanded,"is-current":t.node.isCurrent,"is-hidden":!t.node.visible,"is-focusable":!t.node.disabled,"is-checked":!t.node.disabled&&t.node.checked}]),onClick:e[3]||(e[3]=d.withModifiers((...f)=>t.handleClick&&t.handleClick(...f),["stop"])),onContextmenu:e[4]||(e[4]=(...f)=>t.handleContextMenu&&t.handleContextMenu(...f)),role:"treeitem",tabindex:"-1","aria-expanded":t.expanded,"aria-disabled":t.node.disabled,"aria-checked":t.node.checked,draggable:(y=t.tree)==null?void 0:y.draggable,onDragstart:e[5]||(e[5]=d.withModifiers((...f)=>t.handleDragStart&&t.handleDragStart(...f),["stop"])),onDragover:e[6]||(e[6]=d.withModifiers((...f)=>t.handleDragOver&&t.handleDragOver(...f),["stop"])),onDragend:e[7]||(e[7]=d.withModifiers((...f)=>t.handleDragEnd&&t.handleDragEnd(...f),["stop"])),onDrop:e[8]||(e[8]=d.withModifiers((...f)=>t.handleDrop&&t.handleDrop(...f),["stop"])),ref:"nodeRef"},[d.createElementVNode("div",{class:"vue-tree-node__content",style:d.normalizeStyle({"padding-left":(t.node.level-1)*t.tree.indent+"px"})},[d.createElementVNode("span",{onClick:e[0]||(e[0]=d.withModifiers((...f)=>t.handleExpandIconClick&&t.handleExpandIconClick(...f),["stop"])),class:d.normalizeClass([{"is-leaf":t.node.isLeaf,expanded:!t.node.isLeaf&&t.expanded},"vue-tree-node__expand-icon",t.tree.iconClass?t.tree.iconClass:"vue-icon-caret-right"])},null,2),t.showCheckbox?(d.openBlock(),d.createElementBlock("label",{key:0,class:d.normalizeClass(["vue-checkbox",{"is-checked":t.node.checked,"is-indeterminate":t.node.indeterminate,"is-disabled":!!t.node.disabled}]),onClick:e[2]||(e[2]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("span",{class:d.normalizeClass(["vue-checkbox__input",{"is-checked":t.node.checked,"is-indeterminate":t.node.indeterminate,"is-disabled":!!t.node.disabled}])},[e[9]||(e[9]=d.createElementVNode("span",{class:"vue-checkbox__inner"},null,-1)),d.createElementVNode("input",{type:"checkbox",class:"vue-checkbox__original",checked:t.node.checked,disabled:!!t.node.disabled,onChange:e[1]||(e[1]=(...f)=>t.handleCheckChange&&t.handleCheckChange(...f))},null,40,Se)],2)],2)):d.createCommentVNode("",!0),t.node.loading?(d.openBlock(),d.createElementBlock("span",Oe)):d.createCommentVNode("",!0),(d.openBlock(),d.createBlock(d.resolveDynamicComponent(t.nodeContentComponent),{node:t.node},null,8,["node"]))],4),d.createVNode(h,null,{default:d.withCtx(()=>[!t.renderAfterExpand||t.childNodeRendered?d.withDirectives((d.openBlock(),d.createElementBlock("div",{key:0,class:"vue-tree-node__children",role:"group","aria-expanded":t.expanded},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(t.node.childNodes,f=>(d.openBlock(),d.createBlock(c,{key:t.getNodeKey(f),"render-content":t.renderContent,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,node:f,onNodeExpand:t.handleChildNodeExpand},null,8,["render-content","render-after-expand","show-checkbox","node","onNodeExpand"]))),128))],8,Le)),[[d.vShow,t.expanded]]):d.createCommentVNode("",!0)]),_:1})],42,Te)),[[d.vShow,t.node.visible]])}const $e=te(Be,[["render",Ae]]);function Me(t,e){if(!t||!e)return;const n=e.split(" ");for(const o of n)o&&t.classList.add(o)}function U(t,e){if(!t||!e)return;const n=e.split(" ");for(const o of n)o&&t.classList.remove(o)}const Ie=d.defineComponent({name:"VueTree",components:{VueTreeNode:$e,VirtualList:we},props:{data:{type:Array,default:()=>[]},emptyText:{type:String,default:"暂无数据"},renderAfterExpand:{type:Boolean,default:!0},nodeKey:String,checkStrictly:Boolean,defaultExpandAll:Boolean,expandOnClickNode:{type:Boolean,default:!0},checkOnClickNode:Boolean,checkDescendants:{type:Boolean,default:!1},autoExpandParent:{type:Boolean,default:!0},defaultCheckedKeys:Array,defaultExpandedKeys:Array,currentNodeKey:[String,Number],renderContent:Function,showCheckbox:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},allowDrag:Function,allowDrop:Function,props:{default(){return{children:"children",label:"label",disabled:"disabled"}}},lazy:{type:Boolean,default:!1},highlightCurrent:Boolean,load:Function,filterNodeMethod:Function,accordion:Boolean,indent:{type:Number,default:18},iconClass:String,virtual:{type:Boolean,default:!1}},emits:["node-expand","current-change","check-change","check","node-click","node-contextmenu","node-collapse","node-drag-start","node-drag-enter","node-drag-leave","node-drag-over","node-drag-end","node-drop"],setup(t,{emit:e,expose:n}){const o=d.useSlots(),i=d.getCurrentInstance(),s=d.ref(null),c=d.ref(null),h=d.ref(null),y=d.ref(),f=d.ref(),C=d.ref(),k=d.reactive({showDropIndicator:!1,draggingNode:null,dropNode:null,allowDrop:!0,dropType:""}),v=[];function E(r){v.push(r)}function D(r){v.forEach(a=>a(r))}function O(r,...a){e(r,...a)}d.provide("vueTree",{get store(){return s.value},get nodeKey(){return t.nodeKey},get props(){return t.props},get expandOnClickNode(){return t.expandOnClickNode},get checkOnClickNode(){return t.checkOnClickNode},get checkStrictly(){return t.checkStrictly},get draggable(){return t.draggable},get accordion(){return t.accordion},get indent(){return t.indent},get iconClass(){return t.iconClass},get currentNode(){return h.value},set currentNode(r){h.value=r},slots:o,emitEvent:O,broadcastTreeNodeExpand:D,onAccordionExpand:E,handleTreeNodeDragStart:Ne,handleTreeNodeDragOver:Ce,handleTreeNodeDragEnd:ve}),s.value=new De({key:t.nodeKey,data:t.data,lazy:t.lazy,props:t.props,load:t.load,currentNodeKey:t.currentNodeKey,checkStrictly:t.checkStrictly,checkDescendants:t.checkDescendants,defaultCheckedKeys:t.defaultCheckedKeys,defaultExpandedKeys:t.defaultExpandedKeys,autoExpandParent:t.autoExpandParent,defaultExpandAll:t.defaultExpandAll,filterNodeMethod:t.filterNodeMethod}),c.value=s.value.root;function x(r){return W(t.nodeKey,r.data)}const I=d.computed(()=>{const r=c.value.childNodes;return!r||r.length===0||r.every(({visible:a})=>!a)});d.watch(()=>t.defaultCheckedKeys,r=>{s.value.setDefaultCheckedKey(r)}),d.watch(()=>t.defaultExpandedKeys,r=>{s.value.defaultExpandedKeys=r,s.value.setDefaultExpandedKeys(r)}),d.watch(()=>t.data,r=>{s.value.setData(r),t.currentNodeKey&&s.value.setCurrentNodeKey(t.currentNodeKey)}),d.watch(()=>t.currentNodeKey,r=>{r&&s.value.setCurrentNodeKey(r)}),d.watch(()=>t.checkStrictly,r=>{s.value.checkStrictly=!!r});function P(r){if(!t.filterNodeMethod)throw new Error("[Tree] filterNodeMethod is required when filter");s.value.filter(r)}function z(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in getNodePath");const a=s.value.getNode(r);if(!a)return[];const l=[a.data];let p=a.parent;for(;p&&p!==c.value;)l.push(p.data),p=p.parent;return l.reverse()}function j(r,a){return s.value.getCheckedNodes(r,a)}function Y(r){return s.value.getCheckedKeys(r)}function L(){const r=s.value.getCurrentNode();return r?r.data:null}function u(){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in getCurrentKey");const r=L();return r?r[t.nodeKey]:null}function N(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedNodes");s.value.setCheckedNodes(r,a)}function B(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCheckedKeys");s.value.setCheckedKeys(r,a)}function oe(r,a,l){s.value.setChecked(r,a,l)}function de(){return s.value.getHalfCheckedNodes()}function re(){return s.value.getHalfCheckedKeys()}function ie(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentNode");s.value.setUserCurrentNode(r)}function se(r){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in setCurrentKey");s.value.setCurrentNodeKey(r)}function G(r){return!t.nodeKey||!t.virtual?-1:c.value.childNodes.findIndex(a=>String(x(a))===String(r))}function ae(r){var l,p;const a=G(r);return a<0?!1:!!((p=(l=C.value)==null?void 0:l.isIndexVisible)!=null&&p.call(l,a))}async function le(r){var l,p;const a=G(r);a<0||await((p=(l=C.value)==null?void 0:l.scrollToIndex)==null?void 0:p.call(l,a))}function ce(r){return s.value.getNode(r)}function he(r){s.value.remove(r)}function ue(r,a){s.value.append(r,a)}function fe(r,a){s.value.insertBefore(r,a)}function pe(r,a){s.value.insertAfter(r,a)}function ye(r,a,l){D(a),e("node-expand",r,a,l)}function ge(r,a,l){e("node-collapse",r,a,l)}function ke(r,a){if(!t.nodeKey)throw new Error("[Tree] nodeKey is required in updateKeyChild");s.value.updateChildren(r,a)}function Ne(r,a){if(typeof t.allowDrag=="function"&&!t.allowDrag(a.node))return r.preventDefault(),!1;r.dataTransfer.effectAllowed="move";try{r.dataTransfer.setData("text/plain","")}catch{}k.draggingNode=a,e("node-drag-start",a.node,r)}function Ce(r,a){var X;const l=a,p=k.dropNode;p&&p!==l&&U(p.$el,"is-drop-inner");const g=k.draggingNode;if(!g||!l)return;let K=!0,m=!0,w=!0,J=!0;typeof t.allowDrop=="function"&&(K=t.allowDrop(g.node,l.node,"prev"),J=m=t.allowDrop(g.node,l.node,"inner"),w=t.allowDrop(g.node,l.node,"next")),r.dataTransfer.dropEffect=m?"move":"none",(K||m||w)&&p!==l&&(p&&e("node-drag-leave",g.node,p.node,r),e("node-drag-enter",g.node,l.node,r)),(K||m||w)&&(k.dropNode=l),l.node.nextSibling===g.node&&(w=!1),l.node.previousSibling===g.node&&(K=!1),l.node.contains(g.node,!1)&&(m=!1),(g.node===l.node||g.node.contains(l.node))&&(K=!1,m=!1,w=!1);const q=l.$el.getBoundingClientRect(),V=((X=i==null?void 0:i.proxy)==null?void 0:X.$el).getBoundingClientRect();let b;const Ee=K?m?.25:w?.45:1:-1,Ke=w?m?.75:K?.55:0:1;let F=-9999;const Q=r.clientY-q.top;Q<q.height*Ee?b="before":Q>q.height*Ke?b="after":m?b="inner":b="none";const H=l.$el.querySelector(".vue-tree-node__expand-icon").getBoundingClientRect(),R=y.value;b==="before"?F=H.top-V.top:b==="after"&&(F=H.bottom-V.top),R&&(R.style.top=F+"px",R.style.left=H.right-V.left+"px"),b==="inner"?Me(l.$el,"is-drop-inner"):U(l.$el,"is-drop-inner"),k.showDropIndicator=b==="before"||b==="after",k.allowDrop=k.showDropIndicator||J,k.dropType=b,e("node-drag-over",g.node,l.node,r)}function ve(r){const{draggingNode:a,dropType:l,dropNode:p}=k;if(r.preventDefault(),r.dataTransfer.dropEffect="move",a&&p){const g={data:a.node.data};l!=="none"&&a.node.remove(),l==="before"?p.node.parent.insertBefore(g,p.node):l==="after"?p.node.parent.insertAfter(g,p.node):l==="inner"&&p.node.insertChild(g),l!=="none"&&s.value.registerNode(g),U(p.$el,"is-drop-inner"),e("node-drag-end",a.node,p.node,l,r),l!=="none"&&e("node-drop",a.node,p.node,l,r)}a&&!p&&e("node-drag-end",a.node,null,l,r),k.showDropIndicator=!1,k.draggingNode=null,k.dropNode=null,k.allowDrop=!0}function me(r){var w;const a=r.target;if(a.className.indexOf("vue-tree-node")===-1)return;const l=(w=i==null?void 0:i.proxy)==null?void 0:w.$el,p=Array.from(l.querySelectorAll(".is-focusable[role=treeitem]")),g=p.indexOf(a);let K;[38,40].indexOf(r.keyCode)>-1&&(r.preventDefault(),r.keyCode===38?K=g!==0?g-1:0:K=g<p.length-1?g+1:0,p[K].focus()),[37,39].indexOf(r.keyCode)>-1&&(r.preventDefault(),a.click());const m=a.querySelector('[type="checkbox"]');[13,32].indexOf(r.keyCode)>-1&&m&&(r.preventDefault(),m.click())}return d.onMounted(()=>{var a;((a=i==null?void 0:i.proxy)==null?void 0:a.$el).addEventListener("keydown",me)}),n({filter:P,getNodePath:z,getCheckedNodes:j,getCheckedKeys:Y,getCurrentNode:L,getCurrentKey:u,setCheckedNodes:N,setCheckedKeys:B,setChecked:oe,getHalfCheckedNodes:de,getHalfCheckedKeys:re,setCurrentNode:ie,setCurrentKey:se,isKeyVisible:ae,scrollToKey:le,getNode:ce,remove:he,append:ue,insertBefore:fe,insertAfter:pe,updateKeyChildren:ke,store:s}),{store:s,root:c,currentNode:h,dragState:k,dropIndicator:y,treeContainerRef:f,virtualListRef:C,isEmpty:I,getNodeKeyFn:x,handleNodeExpand:ye,handleNodeCollapse:ge}}}),Pe={key:2,class:"vue-tree__empty-block"},ze={class:"vue-tree__empty-text"},je={class:"vue-tree__drop-indicator",ref:"dropIndicator"};function qe(t,e,n,o,i,s){const c=d.resolveComponent("vue-tree-node"),h=d.resolveComponent("virtual-list");return d.openBlock(),d.createElementBlock("div",{ref:"treeContainerRef",class:d.normalizeClass(["vue-tree",{"vue-tree--highlight-current":t.highlightCurrent,"vue-tree--virtual":t.virtual,"is-dragging":!!t.dragState.draggingNode,"is-drop-not-allow":!t.dragState.allowDrop,"is-drop-inner":t.dragState.dropType==="inner"}]),role:"tree"},[t.virtual&&!t.isEmpty?(d.openBlock(),d.createBlock(h,{key:0,ref:"virtualListRef","list-data":t.root.childNodes,"estimated-item-size":28,height:"100%"},{default:d.withCtx(({item:y})=>[d.createVNode(c,{node:y.item,props:t.props,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,"render-content":t.renderContent,onNodeExpand:t.handleNodeExpand,onNodeCollapse:t.handleNodeCollapse},null,8,["node","props","render-after-expand","show-checkbox","render-content","onNodeExpand","onNodeCollapse"])]),_:1},8,["list-data"])):d.createCommentVNode("",!0),!t.virtual&&!t.isEmpty?(d.openBlock(!0),d.createElementBlock(d.Fragment,{key:1},d.renderList(t.root.childNodes,y=>(d.openBlock(),d.createBlock(c,{key:t.getNodeKeyFn(y),node:y,props:t.props,"render-after-expand":t.renderAfterExpand,"show-checkbox":t.showCheckbox,"render-content":t.renderContent,onNodeExpand:t.handleNodeExpand,onNodeCollapse:t.handleNodeCollapse},null,8,["node","props","render-after-expand","show-checkbox","render-content","onNodeExpand","onNodeCollapse"]))),128)):d.createCommentVNode("",!0),t.isEmpty?(d.openBlock(),d.createElementBlock("div",Pe,[d.renderSlot(t.$slots,"empty",{},()=>[d.createElementVNode("span",ze,d.toDisplayString(t.emptyText),1)])])):d.createCommentVNode("",!0),d.withDirectives(d.createElementVNode("div",je,null,512),[[d.vShow,t.dragState.showDropIndicator]])],2)}const ne=te(Ie,[["render",qe]]);exports.VueTree=ne;exports.default=ne;
@@ -0,0 +1,3 @@
1
+ import { default as VueTree } from './VueTree.vue';
2
+ export { VueTree };
3
+ export default VueTree;