@cw-devops-fe/vue-tree-vue3 1.0.1 → 1.1.0
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.
- package/README.md +104 -16
- package/dist/VirtualTreeRows.vue.d.ts +206 -0
- package/dist/VueTree.vue.d.ts +461 -61
- package/dist/VueTreeItem.vue.d.ts +59 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1148 -673
- package/dist/model/node.d.ts +19 -0
- package/dist/model/tree-store.d.ts +22 -0
- package/dist/model/virtual-tree.d.ts +30 -0
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
!
|
|
5
|
-
value:
|
|
1
|
+
import { reactive as ve, computed as z, watch as I, defineComponent as Y, h as W, Transition as dt, inject as me, ref as S, nextTick as X, onMounted as Ee, resolveComponent as _, withDirectives as ee, openBlock as b, createElementBlock as $, withModifiers as x, normalizeClass as R, createElementVNode as A, normalizeStyle as be, createCommentVNode as q, createBlock as H, resolveDynamicComponent as we, createVNode as De, withCtx as te, Fragment as Ke, renderList as xe, vShow as ne, renderSlot as de, toDisplayString as Te, onBeforeUnmount as ot, unref as it, createSlots as Se, useSlots as rt, getCurrentInstance as at, provide as st } from "vue";
|
|
2
|
+
import lt from "@cw-devops-fe/virtual-list-vue3";
|
|
3
|
+
const F = "$treeNodeId", Ce = function(e, t) {
|
|
4
|
+
!t || t[F] || Object.defineProperty(t, F, {
|
|
5
|
+
value: e.id,
|
|
6
6
|
enumerable: !1,
|
|
7
7
|
configurable: !1,
|
|
8
8
|
writable: !1
|
|
9
9
|
});
|
|
10
|
-
},
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
let
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
16
|
-
(
|
|
10
|
+
}, he = function(e, t) {
|
|
11
|
+
return e ? t[e] : t[F];
|
|
12
|
+
}, Q = (e) => {
|
|
13
|
+
let t = !0, n = !0, d = !0;
|
|
14
|
+
for (let o = 0, a = e.length; o < a; o++) {
|
|
15
|
+
const r = e[o];
|
|
16
|
+
(r.checked !== !0 || r.indeterminate) && (t = !1, r.disabled || (d = !1)), (r.checked !== !1 || r.indeterminate) && (n = !1);
|
|
17
17
|
}
|
|
18
|
-
return { all:
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { all:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (typeof
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
return { all: t, none: n, allWithoutDisable: d, half: !t && !n };
|
|
19
|
+
};
|
|
20
|
+
function Be(e) {
|
|
21
|
+
const { all: t, half: n, none: d } = Q(e.childNodes);
|
|
22
|
+
t ? (e.checked = !0, e.indeterminate = !1) : n ? (e.checked = !1, e.indeterminate = !0) : d && (e.checked = !1, e.indeterminate = !1);
|
|
23
|
+
}
|
|
24
|
+
const U = function(e) {
|
|
25
|
+
if (e.childNodes.length === 0 || e.loading) return;
|
|
26
|
+
Be(e);
|
|
27
|
+
const t = e.parent;
|
|
28
|
+
!t || t.level === 0 || e.store.checkStrictly || U(t);
|
|
29
|
+
}, J = function(e, t) {
|
|
30
|
+
const n = e.store.props, d = e.data || {}, o = n[t];
|
|
31
|
+
if (typeof o == "function")
|
|
32
|
+
return o(d, e);
|
|
33
|
+
if (typeof o == "string")
|
|
34
|
+
return d[o];
|
|
35
|
+
if (typeof o > "u") {
|
|
36
|
+
const a = d[t];
|
|
37
|
+
return a === void 0 ? "" : a;
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
|
-
let
|
|
37
|
-
class
|
|
38
|
-
constructor(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
let ct = 0;
|
|
41
|
+
class P {
|
|
42
|
+
constructor(t) {
|
|
43
|
+
var r;
|
|
44
|
+
this.id = ct++, 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;
|
|
45
|
+
for (const s in t)
|
|
46
|
+
Object.prototype.hasOwnProperty.call(t, s) && (this[s] = t[s]);
|
|
42
47
|
this.level = 0, this.loaded = !1, this.childNodes = [], this.loading = !1, this.parent && (this.level = this.parent.level + 1);
|
|
43
48
|
const n = this.store;
|
|
44
49
|
if (!n)
|
|
@@ -46,116 +51,142 @@ class M {
|
|
|
46
51
|
n.registerNode(this);
|
|
47
52
|
const d = n.props;
|
|
48
53
|
if (d && typeof d.isLeaf < "u") {
|
|
49
|
-
const
|
|
50
|
-
typeof
|
|
54
|
+
const s = J(this, "isLeaf");
|
|
55
|
+
typeof s == "boolean" && (this.isLeafByUser = s);
|
|
51
56
|
}
|
|
52
|
-
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) ||
|
|
53
|
-
const
|
|
54
|
-
|
|
57
|
+
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) || Ce(this, this.data), !this.data) return;
|
|
58
|
+
const o = n.defaultExpandedKeys, a = n.key;
|
|
59
|
+
a && o && o.indexOf(this.key) !== -1 && this.expand(null, n.autoExpandParent), (r = n.isVirtual) != null && r.call(n) ? a && n.currentNodeKey != null && this.key === n.currentNodeKey && n.setCurrentNode(this) : a && n.currentNodeKey !== void 0 && this.key === n.currentNodeKey && (n.currentNode = this, n.currentNode.isCurrent = !0), n.lazy && n._initDefaultCheckedNode(this), this.updateLeafState();
|
|
55
60
|
}
|
|
56
|
-
setData(
|
|
57
|
-
|
|
61
|
+
setData(t) {
|
|
62
|
+
var d, o;
|
|
63
|
+
Array.isArray(t) || Ce(this, t), this.data = t, this.childNodes = [];
|
|
58
64
|
let n;
|
|
59
|
-
this.level === 0 && this.data instanceof Array ? n = this.data : n =
|
|
60
|
-
for (let
|
|
61
|
-
this.insertChild({ data: n[
|
|
65
|
+
this.level === 0 && ((o = (d = this.store).isVirtual) != null && o.call(d) ? Array.isArray(this.data) : this.data instanceof Array) ? n = this.data : n = J(this, "children") || [];
|
|
66
|
+
for (let a = 0, r = n.length; a < r; a++)
|
|
67
|
+
this.insertChild({ data: n[a] });
|
|
62
68
|
}
|
|
63
69
|
get label() {
|
|
64
|
-
return
|
|
70
|
+
return J(this, "label");
|
|
65
71
|
}
|
|
66
72
|
get key() {
|
|
67
|
-
const
|
|
68
|
-
return this.data ? this.data[
|
|
73
|
+
const t = this.store.key;
|
|
74
|
+
return this.data ? this.data[t] : null;
|
|
69
75
|
}
|
|
70
76
|
get disabled() {
|
|
71
|
-
return
|
|
77
|
+
return J(this, "disabled");
|
|
72
78
|
}
|
|
73
79
|
get nextSibling() {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const n =
|
|
80
|
+
const t = this.parent;
|
|
81
|
+
if (t) {
|
|
82
|
+
const n = t.childNodes.indexOf(this);
|
|
77
83
|
if (n > -1)
|
|
78
|
-
return
|
|
84
|
+
return t.childNodes[n + 1];
|
|
79
85
|
}
|
|
80
86
|
return null;
|
|
81
87
|
}
|
|
82
88
|
get previousSibling() {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const n =
|
|
89
|
+
const t = this.parent;
|
|
90
|
+
if (t) {
|
|
91
|
+
const n = t.childNodes.indexOf(this);
|
|
86
92
|
if (n > -1)
|
|
87
|
-
return n > 0 ?
|
|
93
|
+
return n > 0 ? t.childNodes[n - 1] : null;
|
|
88
94
|
}
|
|
89
95
|
return null;
|
|
90
96
|
}
|
|
91
|
-
contains(
|
|
92
|
-
const d = function(
|
|
93
|
-
const
|
|
94
|
-
let
|
|
95
|
-
for (let
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
|
|
97
|
+
contains(t, n = !0) {
|
|
98
|
+
const d = function(o) {
|
|
99
|
+
const a = o.childNodes || [];
|
|
100
|
+
let r = !1;
|
|
101
|
+
for (let s = 0, u = a.length; s < u; s++) {
|
|
102
|
+
const l = a[s];
|
|
103
|
+
if (l === t || n && d(l)) {
|
|
104
|
+
r = !0;
|
|
99
105
|
break;
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
|
-
return
|
|
108
|
+
return r;
|
|
103
109
|
};
|
|
104
110
|
return d(this);
|
|
105
111
|
}
|
|
106
112
|
remove() {
|
|
107
|
-
const
|
|
108
|
-
|
|
113
|
+
const t = this.parent;
|
|
114
|
+
t && t.removeChild(this);
|
|
109
115
|
}
|
|
110
|
-
insertChild(
|
|
111
|
-
if (!
|
|
112
|
-
if (!(
|
|
116
|
+
insertChild(t, n, d) {
|
|
117
|
+
if (!t) throw new Error("insertChild error: child is required.");
|
|
118
|
+
if (!(t instanceof P)) {
|
|
113
119
|
if (!d) {
|
|
114
|
-
const
|
|
115
|
-
|
|
120
|
+
const o = this.getChildren(!0) || [];
|
|
121
|
+
o.indexOf(t.data) === -1 && (typeof n > "u" || n < 0 ? o.push(t.data) : o.splice(n, 0, t.data));
|
|
116
122
|
}
|
|
117
|
-
Object.assign(
|
|
123
|
+
Object.assign(t, { parent: this, store: this.store }), t = new P(t);
|
|
118
124
|
}
|
|
119
|
-
|
|
125
|
+
t.level = this.level + 1, typeof n > "u" || n < 0 ? this.childNodes.push(t) : this.childNodes.splice(n, 0, t), this.updateLeafState();
|
|
120
126
|
}
|
|
121
|
-
insertBefore(
|
|
127
|
+
insertBefore(t, n) {
|
|
122
128
|
let d;
|
|
123
|
-
n && (d = this.childNodes.indexOf(n)), this.insertChild(
|
|
129
|
+
n && (d = this.childNodes.indexOf(n)), this.insertChild(t, d);
|
|
124
130
|
}
|
|
125
|
-
insertAfter(
|
|
131
|
+
insertAfter(t, n) {
|
|
126
132
|
let d;
|
|
127
|
-
n && (d = this.childNodes.indexOf(n), d !== -1 && (d += 1)), this.insertChild(
|
|
133
|
+
n && (d = this.childNodes.indexOf(n), d !== -1 && (d += 1)), this.insertChild(t, d);
|
|
128
134
|
}
|
|
129
|
-
removeChild(
|
|
130
|
-
const n = this.getChildren() || [], d = n.indexOf(
|
|
135
|
+
removeChild(t) {
|
|
136
|
+
const n = this.getChildren() || [], d = n.indexOf(t.data);
|
|
131
137
|
d > -1 && n.splice(d, 1);
|
|
132
|
-
const
|
|
133
|
-
|
|
138
|
+
const o = this.childNodes.indexOf(t);
|
|
139
|
+
o > -1 && (this.store && this.store.deregisterNode(t), t.parent = null, this.childNodes.splice(o, 1)), this.updateLeafState();
|
|
134
140
|
}
|
|
135
|
-
removeChildByData(
|
|
141
|
+
removeChildByData(t) {
|
|
136
142
|
let n = null;
|
|
137
143
|
for (let d = 0; d < this.childNodes.length; d++)
|
|
138
|
-
if (this.childNodes[d].data ===
|
|
144
|
+
if (this.childNodes[d].data === t) {
|
|
139
145
|
n = this.childNodes[d];
|
|
140
146
|
break;
|
|
141
147
|
}
|
|
142
148
|
n && this.removeChild(n);
|
|
143
149
|
}
|
|
144
|
-
expand(
|
|
150
|
+
expand(t, n) {
|
|
151
|
+
var o, a;
|
|
152
|
+
if ((a = (o = this.store).isVirtual) != null && a.call(o)) {
|
|
153
|
+
this.expandVirtual(t, n);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
145
156
|
const d = () => {
|
|
146
157
|
if (n) {
|
|
147
158
|
let r = this.parent;
|
|
148
159
|
for (; r.level > 0; )
|
|
149
160
|
r.expanded = !0, r = r.parent;
|
|
150
161
|
}
|
|
151
|
-
this.expanded = !0,
|
|
162
|
+
this.expanded = !0, t && t();
|
|
152
163
|
};
|
|
153
164
|
this.shouldLoadData() ? this.loadData((r) => {
|
|
154
|
-
r instanceof Array && (this.checked ? this.setChecked(!0, !0) : this.store.checkStrictly ||
|
|
165
|
+
r instanceof Array && (this.checked ? this.setChecked(!0, !0) : this.store.checkStrictly || U(this), d());
|
|
155
166
|
}) : d();
|
|
156
167
|
}
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
/**
|
|
169
|
+
* 把当前节点标为展开,让平铺列表读取它的子项。
|
|
170
|
+
* 例如 A > B > C,展开 C 时传入 expandParent=true,也会把已存在的 A、B 标为展开。
|
|
171
|
+
* 这里只修改祖先的状态,尚未创建的路径需要调用方先按层加载。
|
|
172
|
+
* 无需加载时立即回调。需要加载时,收到子项数组并同步勾选状态后回调。
|
|
173
|
+
*/
|
|
174
|
+
expandVirtual(t, n) {
|
|
175
|
+
if (n) {
|
|
176
|
+
let d = this.parent;
|
|
177
|
+
for (; d && d.level > 0; )
|
|
178
|
+
d.expanded = !0, d = d.parent;
|
|
179
|
+
}
|
|
180
|
+
if (this.expanded = !0, this.shouldLoadData()) {
|
|
181
|
+
const d = ve(this);
|
|
182
|
+
d.loadData((o) => {
|
|
183
|
+
Array.isArray(o) && (d.checked ? d.setChecked(!0, !0) : d.store.checkStrictly || U(d), t == null || t());
|
|
184
|
+
});
|
|
185
|
+
} else
|
|
186
|
+
t == null || t();
|
|
187
|
+
}
|
|
188
|
+
doCreateChildren(t, n = {}) {
|
|
189
|
+
t.forEach((d) => {
|
|
159
190
|
this.insertChild(Object.assign({ data: d }, n), void 0, !0);
|
|
160
191
|
});
|
|
161
192
|
}
|
|
@@ -170,270 +201,397 @@ class M {
|
|
|
170
201
|
this.isLeaf = this.isLeafByUser;
|
|
171
202
|
return;
|
|
172
203
|
}
|
|
173
|
-
const
|
|
204
|
+
const t = this.childNodes;
|
|
174
205
|
if (!this.store.lazy || this.store.lazy === !0 && this.loaded === !0) {
|
|
175
|
-
this.isLeaf = !
|
|
206
|
+
this.isLeaf = !t || t.length === 0;
|
|
176
207
|
return;
|
|
177
208
|
}
|
|
178
209
|
this.isLeaf = !1;
|
|
179
210
|
}
|
|
180
|
-
setChecked(
|
|
181
|
-
if (this.indeterminate =
|
|
211
|
+
setChecked(t, n, d, o) {
|
|
212
|
+
if (this.indeterminate = t === "half", this.checked = t === !0, this.store.checkStrictly) return;
|
|
182
213
|
if (!(this.shouldLoadData() && !this.store.checkDescendants)) {
|
|
183
|
-
const { allWithoutDisable:
|
|
184
|
-
!this.isLeaf && !
|
|
185
|
-
const
|
|
214
|
+
const { allWithoutDisable: r } = Q(this.childNodes);
|
|
215
|
+
!this.isLeaf && !Q(this.childNodes).all && r && (this.checked = !1, t = !1);
|
|
216
|
+
const s = () => {
|
|
186
217
|
if (n) {
|
|
187
|
-
const
|
|
188
|
-
for (let g = 0, C =
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
218
|
+
const u = this.childNodes;
|
|
219
|
+
for (let g = 0, C = u.length; g < C; g++) {
|
|
220
|
+
const p = u[g];
|
|
221
|
+
o = o || t !== !1;
|
|
222
|
+
const v = p.disabled ? p.checked : o;
|
|
223
|
+
p.setChecked(v, n, !0, o);
|
|
193
224
|
}
|
|
194
|
-
const { half:
|
|
195
|
-
|
|
225
|
+
const { half: l, all: y } = Q(u);
|
|
226
|
+
y || (this.checked = y, this.indeterminate = l);
|
|
196
227
|
}
|
|
197
228
|
};
|
|
198
229
|
if (this.shouldLoadData()) {
|
|
199
230
|
this.loadData(
|
|
200
231
|
() => {
|
|
201
|
-
|
|
232
|
+
s(), U(this);
|
|
202
233
|
},
|
|
203
|
-
{ checked:
|
|
234
|
+
{ checked: t !== !1 }
|
|
204
235
|
);
|
|
205
236
|
return;
|
|
206
237
|
} else
|
|
207
|
-
|
|
238
|
+
s();
|
|
208
239
|
}
|
|
209
|
-
const
|
|
210
|
-
!
|
|
240
|
+
const a = this.parent;
|
|
241
|
+
!a || a.level === 0 || d || U(a);
|
|
211
242
|
}
|
|
212
|
-
getChildren(
|
|
243
|
+
getChildren(t = !1) {
|
|
244
|
+
var a, r;
|
|
213
245
|
if (this.level === 0) return this.data;
|
|
214
246
|
const n = this.data;
|
|
215
247
|
if (!n) return null;
|
|
216
248
|
const d = this.store.props;
|
|
217
|
-
let
|
|
218
|
-
return d && (
|
|
249
|
+
let o = "children";
|
|
250
|
+
return d && (o = d.children || "children"), !((r = (a = this.store).isVirtual) != null && r.call(a)) && n[o] === void 0 && (n[o] = null), t && !n[o] && (n[o] = []), n[o];
|
|
219
251
|
}
|
|
220
252
|
updateChildren() {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
253
|
+
var a, r;
|
|
254
|
+
if ((r = (a = this.store).isVirtual) != null && r.call(a) && !this.store.lazy) {
|
|
255
|
+
this.updateVirtualChildren();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const t = this.getChildren() || [], n = this.childNodes.map((s) => s.data), d = {}, o = [];
|
|
259
|
+
t.forEach((s, u) => {
|
|
260
|
+
const l = s[F];
|
|
261
|
+
!!l && n.findIndex((g) => g[F] === l) >= 0 ? d[l] = { index: u, data: s } : o.push({ index: u, data: s });
|
|
225
262
|
}), this.store.lazy || n.forEach((s) => {
|
|
226
|
-
d[s[
|
|
227
|
-
}),
|
|
228
|
-
this.insertChild({ data:
|
|
263
|
+
d[s[F]] || this.removeChildByData(s);
|
|
264
|
+
}), o.forEach(({ index: s, data: u }) => {
|
|
265
|
+
this.insertChild({ data: u }, s);
|
|
229
266
|
}), this.updateLeafState();
|
|
230
267
|
}
|
|
231
|
-
|
|
268
|
+
/**
|
|
269
|
+
* 把外部 children 的增删和顺序变化同步到内部 childNodes。
|
|
270
|
+
* 例如 [B, C, D] 变成 [C, B, E],就复用 C、B,创建 E,并移除 D。
|
|
271
|
+
*/
|
|
272
|
+
updateVirtualChildren() {
|
|
273
|
+
const t = this.getChildren() || [], n = new Map(this.childNodes.map((o) => [o.data, o])), d = [];
|
|
274
|
+
t.forEach((o) => {
|
|
275
|
+
const a = n.get(o);
|
|
276
|
+
a ? (d.push(a), n.delete(o)) : d.push(new P({ data: o, parent: this, store: this.store }));
|
|
277
|
+
}), n.forEach((o) => {
|
|
278
|
+
this.store.deregisterNode(o), o.parent = null;
|
|
279
|
+
}), this.childNodes = d, this.updateLeafState();
|
|
280
|
+
}
|
|
281
|
+
loadData(t, n = {}) {
|
|
232
282
|
if (this.store.lazy === !0 && this.store.load && !this.loaded && (!this.loading || Object.keys(n).length)) {
|
|
233
283
|
this.loading = !0;
|
|
234
|
-
const d = (
|
|
235
|
-
this.childNodes = [], this.doCreateChildren(
|
|
284
|
+
const d = (o) => {
|
|
285
|
+
this.childNodes = [], this.doCreateChildren(o, n), this.loaded = !0, this.loading = !1, this.updateLeafState(), t && t.call(this, o);
|
|
236
286
|
};
|
|
237
287
|
this.store.load(this, d);
|
|
238
288
|
} else
|
|
239
|
-
|
|
289
|
+
t && t.call(this);
|
|
240
290
|
}
|
|
241
291
|
}
|
|
242
|
-
class
|
|
243
|
-
constructor(
|
|
292
|
+
class ht {
|
|
293
|
+
constructor(t) {
|
|
294
|
+
var n;
|
|
244
295
|
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;
|
|
245
|
-
for (const
|
|
246
|
-
Object.prototype.hasOwnProperty.call(
|
|
247
|
-
|
|
296
|
+
for (const d in t)
|
|
297
|
+
Object.prototype.hasOwnProperty.call(t, d) && (this[d] = t[d]);
|
|
298
|
+
this.nodesMap = {}, this.root = new P({
|
|
248
299
|
data: this.data,
|
|
249
300
|
store: this
|
|
250
|
-
}), this.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
301
|
+
}), !((n = this.isVirtual) != null && n.call(this)) && this.initializeRoot();
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* 普通树在构造时调用,虚拟树在 store 进入响应式状态后调用。
|
|
305
|
+
* 例如首次打开懒加载虚拟树时,列表可能为空。等根节点的 load 回调返回,
|
|
306
|
+
* 通过响应式 root 写入顶层子项,平铺列表就会更新。子项登记到索引后,再按默认勾选键查找节点。
|
|
307
|
+
*/
|
|
308
|
+
initializeRoot() {
|
|
309
|
+
const t = this.load;
|
|
310
|
+
if (this.lazy && t) {
|
|
311
|
+
t(this.root, (n) => {
|
|
312
|
+
this.root.doCreateChildren(n), this._initDefaultCheckedNodes();
|
|
254
313
|
});
|
|
255
|
-
|
|
256
|
-
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this._initDefaultCheckedNodes();
|
|
257
317
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
318
|
+
/**
|
|
319
|
+
* 手风琴保留目标和它的祖先链。遍历已加载的对象树,收起路径外的节点,
|
|
320
|
+
* 包括暂时未挂载的后代,避免它们下次滚入或重新展开时带回旧状态。
|
|
321
|
+
*/
|
|
322
|
+
collapseOtherBranches(t) {
|
|
323
|
+
const n = /* @__PURE__ */ new Set();
|
|
324
|
+
for (let o = t; o !== this.root; o = o.parent)
|
|
325
|
+
n.add(o);
|
|
326
|
+
const d = (o) => {
|
|
327
|
+
o.childNodes.forEach((a) => {
|
|
328
|
+
n.has(a) || a.collapse(), d(a);
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
d(this.root);
|
|
332
|
+
}
|
|
333
|
+
filter(t) {
|
|
334
|
+
const n = this.filterNodeMethod, d = this.lazy, o = function(a) {
|
|
335
|
+
const r = a.root ? a.root.childNodes : a.childNodes;
|
|
336
|
+
if (r.forEach((s) => {
|
|
337
|
+
s.visible = n.call(s, t, s.data, s), o(s);
|
|
338
|
+
}), !a.visible && r.length) {
|
|
339
|
+
let s = !0;
|
|
340
|
+
s = !r.some((u) => u.visible), a.root ? a.root.visible = s === !1 : a.visible = s === !1;
|
|
266
341
|
}
|
|
267
|
-
|
|
342
|
+
t && a.visible && !a.isLeaf && !d && a.expand();
|
|
268
343
|
};
|
|
269
|
-
|
|
344
|
+
o(this);
|
|
270
345
|
}
|
|
271
|
-
setData(
|
|
272
|
-
|
|
346
|
+
setData(t) {
|
|
347
|
+
var d;
|
|
348
|
+
t !== this.root.data ? ((d = this.isVirtual) != null && d.call(this) && (this.root.childNodes.forEach((o) => this.deregisterVirtualNode(o)), this.data = t), this.root.setData(t), this._initDefaultCheckedNodes()) : this.root.updateChildren();
|
|
273
349
|
}
|
|
274
|
-
getNode(
|
|
275
|
-
if (
|
|
276
|
-
const n = typeof
|
|
350
|
+
getNode(t) {
|
|
351
|
+
if (t instanceof P) return t;
|
|
352
|
+
const n = typeof t != "object" ? t : he(this.key, t);
|
|
277
353
|
return this.nodesMap[n] || null;
|
|
278
354
|
}
|
|
279
|
-
insertBefore(
|
|
355
|
+
insertBefore(t, n) {
|
|
280
356
|
const d = this.getNode(n);
|
|
281
|
-
d.parent.insertBefore({ data:
|
|
357
|
+
d.parent.insertBefore({ data: t }, d);
|
|
282
358
|
}
|
|
283
|
-
insertAfter(
|
|
359
|
+
insertAfter(t, n) {
|
|
284
360
|
const d = this.getNode(n);
|
|
285
|
-
d.parent.insertAfter({ data:
|
|
361
|
+
d.parent.insertAfter({ data: t }, d);
|
|
286
362
|
}
|
|
287
|
-
remove(
|
|
288
|
-
|
|
289
|
-
|
|
363
|
+
remove(t) {
|
|
364
|
+
var d;
|
|
365
|
+
const n = this.getNode(t);
|
|
366
|
+
if (n && n.parent) {
|
|
367
|
+
const o = (d = this.isVirtual) == null ? void 0 : d.call(this);
|
|
368
|
+
!o && n === this.currentNode && (this.currentNode = null), n.parent.removeChild(n), o && !this.currentNode && (this.currentNodeKey = null);
|
|
369
|
+
}
|
|
290
370
|
}
|
|
291
|
-
append(
|
|
371
|
+
append(t, n) {
|
|
292
372
|
const d = n ? this.getNode(n) : this.root;
|
|
293
|
-
d && d.insertChild({ data:
|
|
373
|
+
d && d.insertChild({ data: t });
|
|
294
374
|
}
|
|
295
375
|
_initDefaultCheckedNodes() {
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
const
|
|
299
|
-
|
|
376
|
+
const t = this.defaultCheckedKeys || [], n = this.nodesMap;
|
|
377
|
+
t.forEach((d) => {
|
|
378
|
+
const o = n[d];
|
|
379
|
+
o && o.setChecked(!0, !this.checkStrictly);
|
|
300
380
|
});
|
|
301
381
|
}
|
|
302
|
-
_initDefaultCheckedNode(
|
|
303
|
-
(this.defaultCheckedKeys || []).indexOf(
|
|
382
|
+
_initDefaultCheckedNode(t) {
|
|
383
|
+
(this.defaultCheckedKeys || []).indexOf(t.key) !== -1 && t.setChecked(!0, !this.checkStrictly);
|
|
384
|
+
}
|
|
385
|
+
setDefaultCheckedKey(t) {
|
|
386
|
+
t !== this.defaultCheckedKeys && (this.defaultCheckedKeys = t, this._initDefaultCheckedNodes());
|
|
304
387
|
}
|
|
305
|
-
|
|
306
|
-
|
|
388
|
+
registerNode(t) {
|
|
389
|
+
if (!this.key || !t || !t.data) return;
|
|
390
|
+
t.key !== void 0 && (this.nodesMap[t.key] = t);
|
|
307
391
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
392
|
+
deregisterNode(t) {
|
|
393
|
+
var d;
|
|
394
|
+
if ((d = this.isVirtual) != null && d.call(this)) {
|
|
395
|
+
this.deregisterVirtualNode(t);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
!this.key || !t || !t.data || (t.childNodes.forEach((o) => {
|
|
399
|
+
this.deregisterNode(o);
|
|
400
|
+
}), delete this.nodesMap[t.key]);
|
|
311
401
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
402
|
+
// 解绑整个分支的索引和当前节点引用。保留键的策略由调用方决定,
|
|
403
|
+
// 整树替换可凭原键恢复高亮,显式删除由 remove 清空键。
|
|
404
|
+
deregisterVirtualNode(t) {
|
|
405
|
+
t.childNodes.forEach((n) => this.deregisterVirtualNode(n)), this.currentNode === t && (this.currentNode = null, t.isCurrent = !1), this.key && this.nodesMap[t.key] === t && delete this.nodesMap[t.key];
|
|
316
406
|
}
|
|
317
|
-
getCheckedNodes(
|
|
318
|
-
const d = [],
|
|
319
|
-
(
|
|
320
|
-
(
|
|
407
|
+
getCheckedNodes(t = !1, n = !1) {
|
|
408
|
+
const d = [], o = function(a) {
|
|
409
|
+
(a.root ? a.root.childNodes : a.childNodes).forEach((s) => {
|
|
410
|
+
(s.checked || n && s.indeterminate) && (!t || t && s.isLeaf) && d.push(s.data), o(s);
|
|
321
411
|
});
|
|
322
412
|
};
|
|
323
|
-
return
|
|
413
|
+
return o(this), d;
|
|
324
414
|
}
|
|
325
|
-
getCheckedKeys(
|
|
326
|
-
return this.getCheckedNodes(
|
|
415
|
+
getCheckedKeys(t = !1) {
|
|
416
|
+
return this.getCheckedNodes(t).map((n) => (n || {})[this.key]);
|
|
327
417
|
}
|
|
328
418
|
getHalfCheckedNodes() {
|
|
329
|
-
const
|
|
330
|
-
(d.root ? d.root.childNodes : d.childNodes).forEach((
|
|
331
|
-
|
|
419
|
+
const t = [], n = function(d) {
|
|
420
|
+
(d.root ? d.root.childNodes : d.childNodes).forEach((a) => {
|
|
421
|
+
a.indeterminate && t.push(a.data), n(a);
|
|
332
422
|
});
|
|
333
423
|
};
|
|
334
|
-
return n(this),
|
|
424
|
+
return n(this), t;
|
|
335
425
|
}
|
|
336
426
|
getHalfCheckedKeys() {
|
|
337
|
-
return this.getHalfCheckedNodes().map((
|
|
427
|
+
return this.getHalfCheckedNodes().map((t) => (t || {})[this.key]);
|
|
338
428
|
}
|
|
339
429
|
_getAllNodes() {
|
|
340
|
-
const
|
|
430
|
+
const t = [], n = this.nodesMap;
|
|
341
431
|
for (const d in n)
|
|
342
|
-
Object.prototype.hasOwnProperty.call(n, d) &&
|
|
343
|
-
return
|
|
432
|
+
Object.prototype.hasOwnProperty.call(n, d) && t.push(n[d]);
|
|
433
|
+
return t;
|
|
344
434
|
}
|
|
345
|
-
updateChildren(
|
|
346
|
-
const d = this.nodesMap[
|
|
435
|
+
updateChildren(t, n) {
|
|
436
|
+
const d = this.nodesMap[t];
|
|
347
437
|
if (!d) return;
|
|
348
|
-
const
|
|
349
|
-
for (let
|
|
350
|
-
const
|
|
351
|
-
this.remove(
|
|
438
|
+
const o = d.childNodes;
|
|
439
|
+
for (let a = o.length - 1; a >= 0; a--) {
|
|
440
|
+
const r = o[a];
|
|
441
|
+
this.remove(r.data);
|
|
352
442
|
}
|
|
353
|
-
for (let
|
|
354
|
-
const
|
|
355
|
-
this.append(
|
|
443
|
+
for (let a = 0, r = n.length; a < r; a++) {
|
|
444
|
+
const s = n[a];
|
|
445
|
+
this.append(s, d.data);
|
|
356
446
|
}
|
|
357
447
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
448
|
+
/**
|
|
449
|
+
* 按给定键更新已加载节点的勾选状态。虚拟且非懒加载时,可以批量重置并直接处理叶子键。
|
|
450
|
+
* 例如一个目录下有 1000 个文件,逐个调用 setChecked 会让同一个父目录反复扫描这 1000 项。
|
|
451
|
+
* 批量路径先更新深层节点,轮到父目录时再用已经写好的子项状态汇总一次。
|
|
452
|
+
*
|
|
453
|
+
* @param key 节点数据中的业务键字段,用于把记录中的键对应到模型节点。
|
|
454
|
+
* @param leafOnly 选中目录并向下联动后,是否按既有规则只保留叶子节点勾选。
|
|
455
|
+
* @param checkedKeys 本次要勾选的键集合,由 setCheckedKeys 或 setCheckedNodes 整理。
|
|
456
|
+
*/
|
|
457
|
+
_setCheckedKeys(t, n = !1, d) {
|
|
458
|
+
var u;
|
|
459
|
+
const o = Object.keys(d), a = (u = this.isVirtual) != null && u.call(this) && !this.lazy ? new Set(o) : void 0, r = this._getAllNodes();
|
|
460
|
+
if (a && (!o.length || this.checkStrictly || o.every((l) => {
|
|
461
|
+
var y;
|
|
462
|
+
return ((y = this.nodesMap[l]) == null ? void 0 : y.isLeaf) ?? !0;
|
|
463
|
+
}))) {
|
|
464
|
+
const l = o.length > 0 && !this.checkStrictly;
|
|
465
|
+
l && r.sort((y, g) => g.level - y.level), r.forEach((y) => {
|
|
466
|
+
l && !y.isLeaf ? Be(y) : (y.checked = a.has(String(y.key)), y.indeterminate = !1);
|
|
467
|
+
});
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
r.sort((l, y) => y.level - l.level);
|
|
471
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
472
|
+
r.forEach((l) => {
|
|
473
|
+
a ? (l.checked = !1, l.indeterminate = !1) : l.setChecked(!1, !1);
|
|
474
|
+
});
|
|
475
|
+
for (let l = 0, y = r.length; l < y; l++) {
|
|
476
|
+
const g = r[l], C = g.data[t].toString();
|
|
477
|
+
if (!(a ? a.has(C) : o.indexOf(C) > -1)) {
|
|
478
|
+
g.checked && !s[C] && g.setChecked(!1, !1);
|
|
365
479
|
continue;
|
|
366
480
|
}
|
|
367
|
-
let
|
|
368
|
-
for (;
|
|
369
|
-
s[
|
|
370
|
-
if (
|
|
371
|
-
|
|
481
|
+
let v = g.parent;
|
|
482
|
+
for (; v && v.level > 0; )
|
|
483
|
+
s[v.data[t]] = !0, v = v.parent;
|
|
484
|
+
if (g.isLeaf || this.checkStrictly) {
|
|
485
|
+
g.setChecked(!0, !1);
|
|
372
486
|
continue;
|
|
373
487
|
}
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
488
|
+
if (g.setChecked(!0, !0), n) {
|
|
489
|
+
g.setChecked(!1, !1);
|
|
490
|
+
const K = function(k) {
|
|
491
|
+
k.childNodes.forEach((L) => {
|
|
492
|
+
L.isLeaf || L.setChecked(!1, !1), K(L);
|
|
379
493
|
});
|
|
380
494
|
};
|
|
381
|
-
|
|
495
|
+
K(g);
|
|
382
496
|
}
|
|
383
497
|
}
|
|
384
498
|
}
|
|
385
|
-
setCheckedNodes(
|
|
386
|
-
const d = this.key,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}), this._setCheckedKeys(d, n,
|
|
499
|
+
setCheckedNodes(t, n = !1) {
|
|
500
|
+
const d = this.key, o = {};
|
|
501
|
+
t.forEach((a) => {
|
|
502
|
+
o[(a || {})[d]] = !0;
|
|
503
|
+
}), this._setCheckedKeys(d, n, o);
|
|
390
504
|
}
|
|
391
|
-
setCheckedKeys(
|
|
392
|
-
this.defaultCheckedKeys =
|
|
393
|
-
const d = this.key,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}), this._setCheckedKeys(d, n,
|
|
505
|
+
setCheckedKeys(t, n = !1) {
|
|
506
|
+
this.defaultCheckedKeys = t;
|
|
507
|
+
const d = this.key, o = {};
|
|
508
|
+
t.forEach((a) => {
|
|
509
|
+
o[a] = !0;
|
|
510
|
+
}), this._setCheckedKeys(d, n, o);
|
|
397
511
|
}
|
|
398
|
-
setDefaultExpandedKeys(
|
|
399
|
-
|
|
512
|
+
setDefaultExpandedKeys(t) {
|
|
513
|
+
t = t || [], this.defaultExpandedKeys = t, t.forEach((n) => {
|
|
400
514
|
const d = this.getNode(n);
|
|
401
515
|
d && d.expand(null, this.autoExpandParent);
|
|
402
516
|
});
|
|
403
517
|
}
|
|
404
|
-
setChecked(
|
|
405
|
-
const
|
|
406
|
-
|
|
518
|
+
setChecked(t, n, d) {
|
|
519
|
+
const o = this.getNode(t);
|
|
520
|
+
o && o.setChecked(!!n, d);
|
|
407
521
|
}
|
|
408
522
|
getCurrentNode() {
|
|
409
523
|
return this.currentNode;
|
|
410
524
|
}
|
|
411
|
-
setCurrentNode(
|
|
525
|
+
setCurrentNode(t) {
|
|
526
|
+
var d;
|
|
412
527
|
const n = this.currentNode;
|
|
413
|
-
n && (n.isCurrent = !1), this.currentNode =
|
|
528
|
+
n && (n.isCurrent = !1), this.currentNode = t, (d = this.isVirtual) != null && d.call(this) && (this.currentNodeKey = t.key), this.currentNode.isCurrent = !0;
|
|
414
529
|
}
|
|
415
|
-
setUserCurrentNode(
|
|
416
|
-
const n =
|
|
530
|
+
setUserCurrentNode(t) {
|
|
531
|
+
const n = t[this.key], d = this.nodesMap[n];
|
|
417
532
|
this.setCurrentNode(d);
|
|
418
533
|
}
|
|
419
|
-
setCurrentNodeKey(
|
|
420
|
-
|
|
421
|
-
|
|
534
|
+
setCurrentNodeKey(t) {
|
|
535
|
+
var d;
|
|
536
|
+
if (t == null) {
|
|
537
|
+
this.currentNode && (this.currentNode.isCurrent = !1), this.currentNode = null, (d = this.isVirtual) != null && d.call(this) && (this.currentNodeKey = null);
|
|
422
538
|
return;
|
|
423
539
|
}
|
|
424
|
-
const n = this.getNode(
|
|
540
|
+
const n = this.getNode(t);
|
|
425
541
|
n && this.setCurrentNode(n);
|
|
426
542
|
}
|
|
427
543
|
}
|
|
428
|
-
|
|
544
|
+
function ut(e) {
|
|
545
|
+
const t = [], n = (d) => {
|
|
546
|
+
d.visible && (t.push(d), d.expanded && d.childNodes.forEach(n));
|
|
547
|
+
};
|
|
548
|
+
return e.childNodes.forEach(n), t;
|
|
549
|
+
}
|
|
550
|
+
function ft(e, t, n, d) {
|
|
551
|
+
const o = z(() => {
|
|
552
|
+
if (!t()) return;
|
|
553
|
+
const r = /* @__PURE__ */ new Map(), s = n(), u = (l) => {
|
|
554
|
+
var g;
|
|
555
|
+
const y = s ? l === e ? void 0 : l.getChildren() : (g = l.getChildren()) == null ? void 0 : g.slice();
|
|
556
|
+
r.set(l, y), l.childNodes.forEach(u);
|
|
557
|
+
};
|
|
558
|
+
return u(e), r;
|
|
559
|
+
}), a = z(() => {
|
|
560
|
+
if (!t()) return;
|
|
561
|
+
const r = /* @__PURE__ */ new Map(), s = (u) => {
|
|
562
|
+
u !== e && r.set(u, { checked: u.checked, indeterminate: u.indeterminate }), u.childNodes.forEach(s);
|
|
563
|
+
};
|
|
564
|
+
return s(e), r;
|
|
565
|
+
});
|
|
566
|
+
I([o, a], ([r, s], [u, l]) => {
|
|
567
|
+
if (!r || !s) return;
|
|
568
|
+
const y = (p, v) => {
|
|
569
|
+
const K = l == null ? void 0 : l.get(p);
|
|
570
|
+
K && (K.checked !== v.checked || K.indeterminate !== v.indeterminate) && d(p);
|
|
571
|
+
};
|
|
572
|
+
if (r === u) {
|
|
573
|
+
s.forEach((p, v) => y(v, p));
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
const g = n(), C = (p) => {
|
|
577
|
+
if (!r.has(p)) return;
|
|
578
|
+
const v = r.get(p);
|
|
579
|
+
g ? p !== e && (u != null && u.has(p)) && v !== u.get(p) && p.updateChildren() : (((v == null ? void 0 : v.length) ?? 0) !== p.childNodes.length || v != null && v.some((E, L) => E !== p.childNodes[L].data)) && p.updateChildren();
|
|
580
|
+
const K = s.get(p);
|
|
581
|
+
K && y(p, K), p.childNodes.forEach(C);
|
|
582
|
+
};
|
|
583
|
+
C(e);
|
|
584
|
+
}, { immediate: !0 });
|
|
585
|
+
}
|
|
586
|
+
const pe = (e, t) => e.classList.add(t), Ne = (e, t) => e.classList.remove(t), gt = Y({
|
|
429
587
|
name: "TreeCollapseTransition",
|
|
430
|
-
setup(
|
|
431
|
-
return () =>
|
|
432
|
-
|
|
588
|
+
setup(e, { slots: t }) {
|
|
589
|
+
return () => W(
|
|
590
|
+
dt,
|
|
433
591
|
{
|
|
434
592
|
onBeforeEnter(n) {
|
|
435
593
|
const d = n;
|
|
436
|
-
|
|
594
|
+
pe(d, "collapse-transition"), d.dataset.oldPaddingTop = d.style.paddingTop, d.dataset.oldPaddingBottom = d.style.paddingBottom, d.style.height = "0", d.style.paddingTop = "0", d.style.paddingBottom = "0";
|
|
437
595
|
},
|
|
438
596
|
onEnter(n) {
|
|
439
597
|
const d = n;
|
|
@@ -441,7 +599,7 @@ const fe = (t, e) => t.classList.add(e), ye = (t, e) => t.classList.remove(e), n
|
|
|
441
599
|
},
|
|
442
600
|
onAfterEnter(n) {
|
|
443
601
|
const d = n;
|
|
444
|
-
|
|
602
|
+
Ne(d, "collapse-transition"), d.style.height = "", d.style.overflow = d.dataset.oldOverflow || "";
|
|
445
603
|
},
|
|
446
604
|
onBeforeLeave(n) {
|
|
447
605
|
const d = n;
|
|
@@ -449,20 +607,20 @@ const fe = (t, e) => t.classList.add(e), ye = (t, e) => t.classList.remove(e), n
|
|
|
449
607
|
},
|
|
450
608
|
onLeave(n) {
|
|
451
609
|
const d = n;
|
|
452
|
-
d.scrollHeight !== 0 && (
|
|
610
|
+
d.scrollHeight !== 0 && (pe(d, "collapse-transition"), d.style.height = "0", d.style.paddingTop = "0", d.style.paddingBottom = "0");
|
|
453
611
|
},
|
|
454
612
|
onAfterLeave(n) {
|
|
455
613
|
const d = n;
|
|
456
|
-
|
|
614
|
+
Ne(d, "collapse-transition"), d.style.height = "", d.style.overflow = d.dataset.oldOverflow || "", d.style.paddingTop = d.dataset.oldPaddingTop || "", d.style.paddingBottom = d.dataset.oldPaddingBottom || "";
|
|
457
615
|
}
|
|
458
616
|
},
|
|
459
|
-
|
|
617
|
+
t.default
|
|
460
618
|
);
|
|
461
619
|
}
|
|
462
|
-
}),
|
|
620
|
+
}), yt = Y({
|
|
463
621
|
name: "VueTreeNode",
|
|
464
622
|
components: {
|
|
465
|
-
TreeCollapseTransition:
|
|
623
|
+
TreeCollapseTransition: gt
|
|
466
624
|
},
|
|
467
625
|
props: {
|
|
468
626
|
node: {
|
|
@@ -480,244 +638,506 @@ const fe = (t, e) => t.classList.add(e), ye = (t, e) => t.classList.remove(e), n
|
|
|
480
638
|
}
|
|
481
639
|
},
|
|
482
640
|
emits: ["node-expand"],
|
|
483
|
-
setup(
|
|
484
|
-
const n =
|
|
641
|
+
setup(e, { emit: t }) {
|
|
642
|
+
const n = me("vueTree"), d = S(), o = S(!1), a = S(!1), r = S(null), s = S(null), u = z(() => ({
|
|
485
643
|
props: { node: { type: Object, required: !0 } },
|
|
486
|
-
setup(
|
|
644
|
+
setup(f) {
|
|
487
645
|
return () => {
|
|
488
|
-
var
|
|
489
|
-
return
|
|
646
|
+
var B;
|
|
647
|
+
return e.renderContent ? e.renderContent(W, {
|
|
490
648
|
_self: n,
|
|
491
|
-
node:
|
|
492
|
-
data:
|
|
493
|
-
store:
|
|
494
|
-
}) : (
|
|
495
|
-
node:
|
|
496
|
-
data:
|
|
497
|
-
}) :
|
|
649
|
+
node: f.node,
|
|
650
|
+
data: f.node.data,
|
|
651
|
+
store: f.node.store
|
|
652
|
+
}) : (B = n == null ? void 0 : n.slots) != null && B.default ? n.slots.default({
|
|
653
|
+
node: f.node,
|
|
654
|
+
data: f.node.data
|
|
655
|
+
}) : W("span", { class: "vue-tree-node__label" }, f.node.label);
|
|
498
656
|
};
|
|
499
657
|
}
|
|
500
658
|
}));
|
|
501
|
-
|
|
502
|
-
() =>
|
|
503
|
-
(
|
|
504
|
-
|
|
659
|
+
I(
|
|
660
|
+
() => e.node.indeterminate,
|
|
661
|
+
(f) => {
|
|
662
|
+
y(e.node.checked, f);
|
|
505
663
|
}
|
|
506
|
-
),
|
|
507
|
-
() =>
|
|
508
|
-
(
|
|
509
|
-
|
|
664
|
+
), I(
|
|
665
|
+
() => e.node.checked,
|
|
666
|
+
(f) => {
|
|
667
|
+
y(f, e.node.indeterminate);
|
|
510
668
|
}
|
|
511
|
-
),
|
|
512
|
-
() =>
|
|
513
|
-
(
|
|
514
|
-
|
|
669
|
+
), I(
|
|
670
|
+
() => e.node.expanded,
|
|
671
|
+
(f) => {
|
|
672
|
+
X(() => o.value = f), f && (a.value = !0);
|
|
515
673
|
}
|
|
516
674
|
);
|
|
517
|
-
function
|
|
518
|
-
return
|
|
675
|
+
function l(f) {
|
|
676
|
+
return he(n.nodeKey, f.data);
|
|
519
677
|
}
|
|
520
|
-
function
|
|
521
|
-
(
|
|
678
|
+
function y(f, B) {
|
|
679
|
+
(r.value !== f || s.value !== B) && n.emitEvent("check-change", e.node.data, f, B), r.value = f, s.value = B;
|
|
522
680
|
}
|
|
523
681
|
function g() {
|
|
524
|
-
const
|
|
525
|
-
|
|
682
|
+
const f = n.store;
|
|
683
|
+
f.setCurrentNode(e.node), n.emitEvent(
|
|
526
684
|
"current-change",
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
), n.currentNode = d.value, n.expandOnClickNode &&
|
|
530
|
-
target: { checked: !
|
|
531
|
-
}), n.emitEvent("node-click",
|
|
532
|
-
}
|
|
533
|
-
function C(
|
|
534
|
-
n.emitEvent("node-contextmenu",
|
|
685
|
+
f.currentNode ? f.currentNode.data : null,
|
|
686
|
+
f.currentNode
|
|
687
|
+
), n.currentNode = d.value, n.expandOnClickNode && p(), n.checkOnClickNode && !e.node.disabled && v({
|
|
688
|
+
target: { checked: !e.node.checked }
|
|
689
|
+
}), n.emitEvent("node-click", e.node.data, e.node, { $el: d.value });
|
|
690
|
+
}
|
|
691
|
+
function C(f) {
|
|
692
|
+
n.emitEvent("node-contextmenu", f, e.node.data, e.node, {
|
|
535
693
|
$el: d.value
|
|
536
694
|
});
|
|
537
695
|
}
|
|
538
|
-
function
|
|
539
|
-
|
|
696
|
+
function p() {
|
|
697
|
+
e.node.isLeaf || (o.value ? (n.emitEvent("node-collapse", e.node.data, e.node, {
|
|
540
698
|
$el: d.value
|
|
541
|
-
}),
|
|
542
|
-
}
|
|
543
|
-
function
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
const
|
|
547
|
-
n.emitEvent("check",
|
|
548
|
-
checkedNodes:
|
|
549
|
-
checkedKeys:
|
|
550
|
-
halfCheckedNodes:
|
|
551
|
-
halfCheckedKeys:
|
|
699
|
+
}), e.node.collapse()) : (e.node.expand(), t("node-expand", e.node.data, e.node, { $el: d.value })));
|
|
700
|
+
}
|
|
701
|
+
function v(f) {
|
|
702
|
+
const B = f.target;
|
|
703
|
+
e.node.setChecked(B.checked, !n.checkStrictly), X(() => {
|
|
704
|
+
const M = n.store;
|
|
705
|
+
n.emitEvent("check", e.node.data, {
|
|
706
|
+
checkedNodes: M.getCheckedNodes(),
|
|
707
|
+
checkedKeys: M.getCheckedKeys(),
|
|
708
|
+
halfCheckedNodes: M.getHalfCheckedNodes(),
|
|
709
|
+
halfCheckedKeys: M.getHalfCheckedKeys()
|
|
552
710
|
});
|
|
553
711
|
});
|
|
554
712
|
}
|
|
555
|
-
function
|
|
556
|
-
n.broadcastTreeNodeExpand(
|
|
713
|
+
function K(f, B, M) {
|
|
714
|
+
n.broadcastTreeNodeExpand(B), n.emitEvent("node-expand", f, B, M);
|
|
557
715
|
}
|
|
558
|
-
function
|
|
559
|
-
n.draggable && n.handleTreeNodeDragStart(
|
|
716
|
+
function k(f) {
|
|
717
|
+
n.draggable && n.handleTreeNodeDragStart(f, { node: e.node, $el: d.value });
|
|
560
718
|
}
|
|
561
|
-
function
|
|
562
|
-
n.draggable && (n.handleTreeNodeDragOver(
|
|
719
|
+
function E(f) {
|
|
720
|
+
n.draggable && (n.handleTreeNodeDragOver(f, { node: e.node, $el: d.value }), f.preventDefault());
|
|
563
721
|
}
|
|
564
|
-
function
|
|
565
|
-
|
|
722
|
+
function L(f) {
|
|
723
|
+
f.preventDefault();
|
|
566
724
|
}
|
|
567
|
-
function
|
|
568
|
-
n.draggable && n.handleTreeNodeDragEnd(
|
|
725
|
+
function Z(f) {
|
|
726
|
+
n.draggable && n.handleTreeNodeDragEnd(f, { node: e.node, $el: d.value });
|
|
569
727
|
}
|
|
570
|
-
const
|
|
571
|
-
|
|
728
|
+
const oe = (f) => {
|
|
729
|
+
e.node !== f && e.node.collapse();
|
|
572
730
|
};
|
|
573
|
-
|
|
574
|
-
n.accordion && n.onAccordionExpand(
|
|
731
|
+
Ee(() => {
|
|
732
|
+
n.accordion && n.onAccordionExpand(oe);
|
|
575
733
|
});
|
|
576
|
-
const
|
|
577
|
-
return
|
|
734
|
+
const ie = (n.props || {}).children || "children";
|
|
735
|
+
return I(
|
|
578
736
|
() => {
|
|
579
|
-
var
|
|
580
|
-
return (
|
|
737
|
+
var f;
|
|
738
|
+
return (f = e.node.data) == null ? void 0 : f[ie];
|
|
581
739
|
},
|
|
582
740
|
() => {
|
|
583
|
-
|
|
741
|
+
e.node.updateChildren();
|
|
584
742
|
}
|
|
585
|
-
),
|
|
743
|
+
), e.node.expanded && (o.value = !0, a.value = !0), {
|
|
586
744
|
tree: n,
|
|
587
745
|
nodeRef: d,
|
|
588
|
-
expanded:
|
|
589
|
-
childNodeRendered:
|
|
590
|
-
nodeContentComponent:
|
|
591
|
-
getNodeKey:
|
|
746
|
+
expanded: o,
|
|
747
|
+
childNodeRendered: a,
|
|
748
|
+
nodeContentComponent: u,
|
|
749
|
+
getNodeKey: l,
|
|
592
750
|
handleClick: g,
|
|
593
751
|
handleContextMenu: C,
|
|
594
|
-
handleExpandIconClick:
|
|
595
|
-
handleCheckChange:
|
|
596
|
-
handleChildNodeExpand:
|
|
597
|
-
handleDragStart:
|
|
598
|
-
handleDragOver:
|
|
599
|
-
handleDrop:
|
|
600
|
-
handleDragEnd:
|
|
752
|
+
handleExpandIconClick: p,
|
|
753
|
+
handleCheckChange: v,
|
|
754
|
+
handleChildNodeExpand: K,
|
|
755
|
+
handleDragStart: k,
|
|
756
|
+
handleDragOver: E,
|
|
757
|
+
handleDrop: L,
|
|
758
|
+
handleDragEnd: Z
|
|
601
759
|
};
|
|
602
760
|
}
|
|
603
|
-
}),
|
|
604
|
-
const n =
|
|
605
|
-
for (const [d,
|
|
606
|
-
n[d] =
|
|
761
|
+
}), ue = (e, t) => {
|
|
762
|
+
const n = e.__vccOpts || e;
|
|
763
|
+
for (const [d, o] of t)
|
|
764
|
+
n[d] = o;
|
|
607
765
|
return n;
|
|
608
|
-
},
|
|
766
|
+
}, kt = ["aria-expanded", "aria-disabled", "aria-checked", "draggable"], Ct = ["checked", "disabled"], pt = {
|
|
609
767
|
key: 1,
|
|
610
768
|
class: "vue-tree-node__loading-icon vue-icon-loading"
|
|
611
|
-
},
|
|
612
|
-
function
|
|
613
|
-
var
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
class:
|
|
617
|
-
"is-expanded":
|
|
618
|
-
"is-current":
|
|
619
|
-
"is-hidden": !
|
|
620
|
-
"is-focusable": !
|
|
621
|
-
"is-checked": !
|
|
769
|
+
}, Nt = ["aria-expanded"];
|
|
770
|
+
function vt(e, t, n, d, o, a) {
|
|
771
|
+
var u;
|
|
772
|
+
const r = _("vue-tree-node", !0), s = _("tree-collapse-transition");
|
|
773
|
+
return ee((b(), $("div", {
|
|
774
|
+
class: R(["vue-tree-node", {
|
|
775
|
+
"is-expanded": e.expanded,
|
|
776
|
+
"is-current": e.node.isCurrent,
|
|
777
|
+
"is-hidden": !e.node.visible,
|
|
778
|
+
"is-focusable": !e.node.disabled,
|
|
779
|
+
"is-checked": !e.node.disabled && e.node.checked
|
|
622
780
|
}]),
|
|
623
|
-
onClick:
|
|
624
|
-
onContextmenu:
|
|
781
|
+
onClick: t[3] || (t[3] = x((...l) => e.handleClick && e.handleClick(...l), ["stop"])),
|
|
782
|
+
onContextmenu: t[4] || (t[4] = (...l) => e.handleContextMenu && e.handleContextMenu(...l)),
|
|
625
783
|
role: "treeitem",
|
|
626
784
|
tabindex: "-1",
|
|
627
|
-
"aria-expanded":
|
|
628
|
-
"aria-disabled":
|
|
629
|
-
"aria-checked":
|
|
630
|
-
draggable: (
|
|
631
|
-
onDragstart:
|
|
632
|
-
onDragover:
|
|
633
|
-
onDragend:
|
|
634
|
-
onDrop:
|
|
785
|
+
"aria-expanded": e.expanded,
|
|
786
|
+
"aria-disabled": e.node.disabled,
|
|
787
|
+
"aria-checked": e.node.checked,
|
|
788
|
+
draggable: (u = e.tree) == null ? void 0 : u.draggable,
|
|
789
|
+
onDragstart: t[5] || (t[5] = x((...l) => e.handleDragStart && e.handleDragStart(...l), ["stop"])),
|
|
790
|
+
onDragover: t[6] || (t[6] = x((...l) => e.handleDragOver && e.handleDragOver(...l), ["stop"])),
|
|
791
|
+
onDragend: t[7] || (t[7] = x((...l) => e.handleDragEnd && e.handleDragEnd(...l), ["stop"])),
|
|
792
|
+
onDrop: t[8] || (t[8] = x((...l) => e.handleDrop && e.handleDrop(...l), ["stop"])),
|
|
635
793
|
ref: "nodeRef"
|
|
636
794
|
}, [
|
|
637
795
|
A("div", {
|
|
638
796
|
class: "vue-tree-node__content",
|
|
639
|
-
style:
|
|
797
|
+
style: be({ "padding-left": (e.node.level - 1) * e.tree.indent + "px" })
|
|
640
798
|
}, [
|
|
641
799
|
A("span", {
|
|
642
|
-
onClick:
|
|
643
|
-
class:
|
|
644
|
-
{ "is-leaf":
|
|
800
|
+
onClick: t[0] || (t[0] = x((...l) => e.handleExpandIconClick && e.handleExpandIconClick(...l), ["stop"])),
|
|
801
|
+
class: R([
|
|
802
|
+
{ "is-leaf": e.node.isLeaf, expanded: !e.node.isLeaf && e.expanded },
|
|
645
803
|
"vue-tree-node__expand-icon",
|
|
646
|
-
|
|
804
|
+
e.tree.iconClass ? e.tree.iconClass : "vue-icon-caret-right"
|
|
647
805
|
])
|
|
648
806
|
}, null, 2),
|
|
649
|
-
|
|
807
|
+
e.showCheckbox ? (b(), $("label", {
|
|
650
808
|
key: 0,
|
|
651
|
-
class:
|
|
652
|
-
"is-checked":
|
|
653
|
-
"is-indeterminate":
|
|
654
|
-
"is-disabled": !!
|
|
809
|
+
class: R(["vue-checkbox", {
|
|
810
|
+
"is-checked": e.node.checked,
|
|
811
|
+
"is-indeterminate": e.node.indeterminate,
|
|
812
|
+
"is-disabled": !!e.node.disabled
|
|
655
813
|
}]),
|
|
656
|
-
onClick:
|
|
814
|
+
onClick: t[2] || (t[2] = x(() => {
|
|
657
815
|
}, ["stop"]))
|
|
658
816
|
}, [
|
|
659
817
|
A("span", {
|
|
660
|
-
class:
|
|
661
|
-
"is-checked":
|
|
662
|
-
"is-indeterminate":
|
|
663
|
-
"is-disabled": !!
|
|
818
|
+
class: R(["vue-checkbox__input", {
|
|
819
|
+
"is-checked": e.node.checked,
|
|
820
|
+
"is-indeterminate": e.node.indeterminate,
|
|
821
|
+
"is-disabled": !!e.node.disabled
|
|
664
822
|
}])
|
|
665
823
|
}, [
|
|
666
|
-
|
|
824
|
+
t[9] || (t[9] = A("span", { class: "vue-checkbox__inner" }, null, -1)),
|
|
667
825
|
A("input", {
|
|
668
826
|
type: "checkbox",
|
|
669
827
|
class: "vue-checkbox__original",
|
|
670
|
-
checked:
|
|
671
|
-
disabled: !!
|
|
672
|
-
onChange:
|
|
673
|
-
}, null, 40,
|
|
828
|
+
checked: e.node.checked,
|
|
829
|
+
disabled: !!e.node.disabled,
|
|
830
|
+
onChange: t[1] || (t[1] = (...l) => e.handleCheckChange && e.handleCheckChange(...l))
|
|
831
|
+
}, null, 40, Ct)
|
|
674
832
|
], 2)
|
|
675
|
-
], 2)) :
|
|
676
|
-
|
|
677
|
-
(
|
|
833
|
+
], 2)) : q("", !0),
|
|
834
|
+
e.node.loading ? (b(), $("span", pt)) : q("", !0),
|
|
835
|
+
(b(), H(we(e.nodeContentComponent), { node: e.node }, null, 8, ["node"]))
|
|
678
836
|
], 4),
|
|
679
|
-
|
|
680
|
-
default:
|
|
681
|
-
!
|
|
837
|
+
De(s, null, {
|
|
838
|
+
default: te(() => [
|
|
839
|
+
!e.renderAfterExpand || e.childNodeRendered ? ee((b(), $("div", {
|
|
682
840
|
key: 0,
|
|
683
841
|
class: "vue-tree-node__children",
|
|
684
842
|
role: "group",
|
|
685
|
-
"aria-expanded":
|
|
843
|
+
"aria-expanded": e.expanded
|
|
686
844
|
}, [
|
|
687
|
-
(
|
|
688
|
-
key:
|
|
689
|
-
"render-content":
|
|
690
|
-
"render-after-expand":
|
|
691
|
-
"show-checkbox":
|
|
692
|
-
node:
|
|
693
|
-
onNodeExpand:
|
|
845
|
+
(b(!0), $(Ke, null, xe(e.node.childNodes, (l) => (b(), H(r, {
|
|
846
|
+
key: e.getNodeKey(l),
|
|
847
|
+
"render-content": e.renderContent,
|
|
848
|
+
"render-after-expand": e.renderAfterExpand,
|
|
849
|
+
"show-checkbox": e.showCheckbox,
|
|
850
|
+
node: l,
|
|
851
|
+
onNodeExpand: e.handleChildNodeExpand
|
|
694
852
|
}, null, 8, ["render-content", "render-after-expand", "show-checkbox", "node", "onNodeExpand"]))), 128))
|
|
695
|
-
], 8,
|
|
696
|
-
[
|
|
697
|
-
]) :
|
|
853
|
+
], 8, Nt)), [
|
|
854
|
+
[ne, e.expanded]
|
|
855
|
+
]) : q("", !0)
|
|
698
856
|
]),
|
|
699
857
|
_: 1
|
|
700
858
|
})
|
|
701
|
-
], 42,
|
|
702
|
-
[
|
|
859
|
+
], 42, kt)), [
|
|
860
|
+
[ne, e.node.visible]
|
|
861
|
+
]);
|
|
862
|
+
}
|
|
863
|
+
const mt = /* @__PURE__ */ ue(yt, [["render", vt]]), Et = Y({
|
|
864
|
+
// VirtualTreeRows 为每个挂载的列表项传入一个 Node,子节点由列表作为另外的行渲染。
|
|
865
|
+
name: "VueTreeItem",
|
|
866
|
+
props: {
|
|
867
|
+
node: {
|
|
868
|
+
type: Object,
|
|
869
|
+
required: !0
|
|
870
|
+
},
|
|
871
|
+
// 平铺列表里的当前索引。父组件按这个索引判断本行是否在屏幕内。
|
|
872
|
+
index: { type: Number, required: !0 },
|
|
873
|
+
scheduleContent: Function,
|
|
874
|
+
renderContent: Function,
|
|
875
|
+
showCheckbox: {
|
|
876
|
+
type: Boolean,
|
|
877
|
+
default: !1
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
setup(e) {
|
|
881
|
+
const t = me("vueTree"), n = S(), d = z(() => e.node.expanded), o = z(() => {
|
|
882
|
+
var E;
|
|
883
|
+
const k = t.loadingKey;
|
|
884
|
+
return e.node.loading || !!(k && ((E = e.node.data) != null && E[k]));
|
|
885
|
+
}), a = S(!1);
|
|
886
|
+
I(() => e.scheduleContent, (k, E, L) => {
|
|
887
|
+
a.value || (k ? L(k(() => {
|
|
888
|
+
a.value = !0;
|
|
889
|
+
}, () => e.index)) : a.value = !0);
|
|
890
|
+
}, { immediate: !0 });
|
|
891
|
+
const r = z(() => ({
|
|
892
|
+
props: { node: { type: Object, required: !0 } },
|
|
893
|
+
setup(k) {
|
|
894
|
+
return () => {
|
|
895
|
+
var E;
|
|
896
|
+
return e.renderContent ? e.renderContent(W, {
|
|
897
|
+
_self: t,
|
|
898
|
+
node: k.node,
|
|
899
|
+
data: k.node.data,
|
|
900
|
+
store: k.node.store
|
|
901
|
+
}) : (E = t == null ? void 0 : t.slots) != null && E.default ? t.slots.default({
|
|
902
|
+
node: k.node,
|
|
903
|
+
data: k.node.data
|
|
904
|
+
}) : W("span", { class: "vue-tree-node__label" }, k.node.label);
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}));
|
|
908
|
+
function s() {
|
|
909
|
+
const k = t.store;
|
|
910
|
+
k.setCurrentNode(e.node), t.emitEvent(
|
|
911
|
+
"current-change",
|
|
912
|
+
k.currentNode ? k.currentNode.data : null,
|
|
913
|
+
k.currentNode
|
|
914
|
+
), t.expandOnClickNode && l(), t.checkOnClickNode && !e.node.disabled && g(!e.node.checked), t.emitEvent("node-click", e.node.data, e.node, { $el: n.value });
|
|
915
|
+
}
|
|
916
|
+
function u(k) {
|
|
917
|
+
t.emitEvent("node-contextmenu", k, e.node.data, e.node, {
|
|
918
|
+
$el: n.value
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
function l() {
|
|
922
|
+
e.node.isLeaf || (d.value ? (t.emitEvent("node-collapse", e.node.data, e.node, {
|
|
923
|
+
$el: n.value
|
|
924
|
+
}), e.node.collapse()) : (e.node.expand(), t.handleVirtualNodeExpand(e.node.data, e.node, { $el: n.value })));
|
|
925
|
+
}
|
|
926
|
+
function y(k) {
|
|
927
|
+
g(k.target.checked);
|
|
928
|
+
}
|
|
929
|
+
function g(k) {
|
|
930
|
+
e.node.setChecked(k, !t.checkStrictly), X(() => {
|
|
931
|
+
const E = t.store;
|
|
932
|
+
t.emitEvent("check", e.node.data, {
|
|
933
|
+
checkedNodes: E.getCheckedNodes(),
|
|
934
|
+
checkedKeys: E.getCheckedKeys(),
|
|
935
|
+
halfCheckedNodes: E.getHalfCheckedNodes(),
|
|
936
|
+
halfCheckedKeys: E.getHalfCheckedKeys()
|
|
937
|
+
});
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
function C(k) {
|
|
941
|
+
t.draggable && t.handleTreeNodeDragStart(k, { node: e.node, $el: n.value });
|
|
942
|
+
}
|
|
943
|
+
function p(k) {
|
|
944
|
+
t.draggable && (t.handleTreeNodeDragOver(k, { node: e.node, $el: n.value }), k.preventDefault());
|
|
945
|
+
}
|
|
946
|
+
function v(k) {
|
|
947
|
+
k.preventDefault();
|
|
948
|
+
}
|
|
949
|
+
function K(k) {
|
|
950
|
+
t.draggable && t.handleTreeNodeDragEnd(k, { node: e.node, $el: n.value });
|
|
951
|
+
}
|
|
952
|
+
return {
|
|
953
|
+
tree: t,
|
|
954
|
+
nodeRef: n,
|
|
955
|
+
expanded: d,
|
|
956
|
+
loading: o,
|
|
957
|
+
contentReady: a,
|
|
958
|
+
nodeContentComponent: r,
|
|
959
|
+
handleClick: s,
|
|
960
|
+
handleContextMenu: u,
|
|
961
|
+
handleExpandIconClick: l,
|
|
962
|
+
handleCheckChange: y,
|
|
963
|
+
handleDragStart: C,
|
|
964
|
+
handleDragOver: p,
|
|
965
|
+
handleDrop: v,
|
|
966
|
+
handleDragEnd: K
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
}), bt = ["aria-level", "data-tree-node-id", "aria-expanded", "aria-disabled", "aria-checked", "aria-busy", "draggable"], wt = ["checked", "disabled"], Dt = {
|
|
970
|
+
key: 4,
|
|
971
|
+
class: "vue-tree-node__label"
|
|
972
|
+
};
|
|
973
|
+
function Kt(e, t, n, d, o, a) {
|
|
974
|
+
var r;
|
|
975
|
+
return ee((b(), $("div", {
|
|
976
|
+
class: R(["vue-tree-node", {
|
|
977
|
+
"is-expanded": e.expanded,
|
|
978
|
+
"is-current": e.node.isCurrent,
|
|
979
|
+
"is-hidden": !e.node.visible,
|
|
980
|
+
"is-focusable": !e.node.disabled,
|
|
981
|
+
"is-checked": !e.node.disabled && e.node.checked
|
|
982
|
+
}]),
|
|
983
|
+
onClick: t[4] || (t[4] = x((...s) => e.handleClick && e.handleClick(...s), ["stop"])),
|
|
984
|
+
onContextmenu: t[5] || (t[5] = (...s) => e.handleContextMenu && e.handleContextMenu(...s)),
|
|
985
|
+
role: "treeitem",
|
|
986
|
+
"aria-level": e.node.level,
|
|
987
|
+
"data-tree-node-id": e.node.id,
|
|
988
|
+
tabindex: "-1",
|
|
989
|
+
"aria-expanded": e.expanded,
|
|
990
|
+
"aria-disabled": e.node.disabled,
|
|
991
|
+
"aria-checked": e.node.checked,
|
|
992
|
+
"aria-busy": e.loading || void 0,
|
|
993
|
+
draggable: (r = e.tree) == null ? void 0 : r.draggable,
|
|
994
|
+
onDragstart: t[6] || (t[6] = x((...s) => e.handleDragStart && e.handleDragStart(...s), ["stop"])),
|
|
995
|
+
onDragover: t[7] || (t[7] = x((...s) => e.handleDragOver && e.handleDragOver(...s), ["stop"])),
|
|
996
|
+
onDragend: t[8] || (t[8] = x((...s) => e.handleDragEnd && e.handleDragEnd(...s), ["stop"])),
|
|
997
|
+
onDrop: t[9] || (t[9] = x((...s) => e.handleDrop && e.handleDrop(...s), ["stop"])),
|
|
998
|
+
ref: "nodeRef"
|
|
999
|
+
}, [
|
|
1000
|
+
A("div", {
|
|
1001
|
+
class: "vue-tree-node__content",
|
|
1002
|
+
style: be({ "padding-left": (e.node.level - 1) * e.tree.indent + "px" })
|
|
1003
|
+
}, [
|
|
1004
|
+
e.loading ? (b(), $("div", {
|
|
1005
|
+
key: 0,
|
|
1006
|
+
class: "vue-tree-node__expand-icon is-loading",
|
|
1007
|
+
onClick: t[0] || (t[0] = x((...s) => e.handleExpandIconClick && e.handleExpandIconClick(...s), ["stop"]))
|
|
1008
|
+
}, [
|
|
1009
|
+
de(e.$slots, "node-loading", {}, () => [
|
|
1010
|
+
t[10] || (t[10] = A("span", {
|
|
1011
|
+
class: "vue-tree-node__loading-icon vue-icon-loading",
|
|
1012
|
+
"aria-hidden": "true"
|
|
1013
|
+
}, null, -1))
|
|
1014
|
+
])
|
|
1015
|
+
])) : (b(), $("span", {
|
|
1016
|
+
key: 1,
|
|
1017
|
+
onClick: t[1] || (t[1] = x((...s) => e.handleExpandIconClick && e.handleExpandIconClick(...s), ["stop"])),
|
|
1018
|
+
class: R([
|
|
1019
|
+
{ "is-leaf": e.node.isLeaf, expanded: !e.node.isLeaf && e.expanded },
|
|
1020
|
+
"vue-tree-node__expand-icon",
|
|
1021
|
+
e.tree.iconClass ? e.tree.iconClass : "vue-icon-caret-right"
|
|
1022
|
+
])
|
|
1023
|
+
}, null, 2)),
|
|
1024
|
+
e.showCheckbox ? (b(), $("label", {
|
|
1025
|
+
key: 2,
|
|
1026
|
+
class: R(["vue-checkbox", {
|
|
1027
|
+
"is-checked": e.node.checked,
|
|
1028
|
+
"is-indeterminate": e.node.indeterminate,
|
|
1029
|
+
"is-disabled": !!e.node.disabled
|
|
1030
|
+
}]),
|
|
1031
|
+
onClick: t[3] || (t[3] = x(() => {
|
|
1032
|
+
}, ["stop"]))
|
|
1033
|
+
}, [
|
|
1034
|
+
A("span", {
|
|
1035
|
+
class: R(["vue-checkbox__input", {
|
|
1036
|
+
"is-checked": e.node.checked,
|
|
1037
|
+
"is-indeterminate": e.node.indeterminate,
|
|
1038
|
+
"is-disabled": !!e.node.disabled
|
|
1039
|
+
}])
|
|
1040
|
+
}, [
|
|
1041
|
+
t[11] || (t[11] = A("span", { class: "vue-checkbox__inner" }, null, -1)),
|
|
1042
|
+
A("input", {
|
|
1043
|
+
type: "checkbox",
|
|
1044
|
+
class: "vue-checkbox__original",
|
|
1045
|
+
checked: e.node.checked,
|
|
1046
|
+
disabled: !!e.node.disabled,
|
|
1047
|
+
onChange: t[2] || (t[2] = (...s) => e.handleCheckChange && e.handleCheckChange(...s))
|
|
1048
|
+
}, null, 40, wt)
|
|
1049
|
+
], 2)
|
|
1050
|
+
], 2)) : q("", !0),
|
|
1051
|
+
e.contentReady ? (b(), H(we(e.nodeContentComponent), {
|
|
1052
|
+
key: 3,
|
|
1053
|
+
node: e.node
|
|
1054
|
+
}, null, 8, ["node"])) : (b(), $("span", Dt, Te(e.node.label), 1))
|
|
1055
|
+
], 4)
|
|
1056
|
+
], 42, bt)), [
|
|
1057
|
+
[ne, e.node.visible]
|
|
703
1058
|
]);
|
|
704
1059
|
}
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
1060
|
+
const xt = /* @__PURE__ */ ue(Et, [["render", Kt]]), Tt = 8, St = /* @__PURE__ */ Y({
|
|
1061
|
+
__name: "VirtualTreeRows",
|
|
1062
|
+
props: {
|
|
1063
|
+
rows: {},
|
|
1064
|
+
getRowKey: { type: Function },
|
|
1065
|
+
showCheckbox: { type: Boolean },
|
|
1066
|
+
renderContent: { type: Function },
|
|
1067
|
+
deferContent: { type: Boolean }
|
|
1068
|
+
},
|
|
1069
|
+
setup(e, { expose: t }) {
|
|
1070
|
+
const n = e, d = S(), o = (l) => n.getRowKey(l), a = /* @__PURE__ */ new Map();
|
|
1071
|
+
let r = null;
|
|
1072
|
+
function s(l, y) {
|
|
1073
|
+
return a.set(l, y), r === null && (r = requestAnimationFrame(u)), () => a.delete(l);
|
|
1074
|
+
}
|
|
1075
|
+
function u() {
|
|
1076
|
+
r = null;
|
|
1077
|
+
const l = (g) => {
|
|
1078
|
+
var C;
|
|
1079
|
+
return Number(((C = d.value) == null ? void 0 : C.isIndexVisible(g)) ?? !1);
|
|
1080
|
+
}, y = [...a].map(([g, C]) => ({ mount: g, index: C() })).sort((g, C) => l(C.index) - l(g.index) || g.index - C.index).slice(0, Tt);
|
|
1081
|
+
for (const { mount: g } of y)
|
|
1082
|
+
a.delete(g), g();
|
|
1083
|
+
a.size && (r = requestAnimationFrame(u));
|
|
1084
|
+
}
|
|
1085
|
+
return ot(() => {
|
|
1086
|
+
r !== null && cancelAnimationFrame(r), a.clear();
|
|
1087
|
+
}), t({
|
|
1088
|
+
isIndexVisible: (l) => {
|
|
1089
|
+
var y;
|
|
1090
|
+
return ((y = d.value) == null ? void 0 : y.isIndexVisible(l)) ?? !1;
|
|
1091
|
+
},
|
|
1092
|
+
scrollToIndex: (l) => {
|
|
1093
|
+
var y;
|
|
1094
|
+
return (y = d.value) == null ? void 0 : y.scrollToIndex(l);
|
|
1095
|
+
}
|
|
1096
|
+
}), (l, y) => (b(), H(it(lt), {
|
|
1097
|
+
ref_key: "list",
|
|
1098
|
+
ref: d,
|
|
1099
|
+
"list-data": e.rows,
|
|
1100
|
+
"item-key": o,
|
|
1101
|
+
"immediate-scroll-update": "",
|
|
1102
|
+
"estimated-item-size": 28,
|
|
1103
|
+
height: "100%"
|
|
1104
|
+
}, {
|
|
1105
|
+
default: te(({ item: { item: g, index: C } }) => [
|
|
1106
|
+
De(xt, {
|
|
1107
|
+
node: g,
|
|
1108
|
+
index: Number(C.slice(1)),
|
|
1109
|
+
"show-checkbox": e.showCheckbox,
|
|
1110
|
+
"render-content": e.renderContent,
|
|
1111
|
+
"schedule-content": e.deferContent ? s : void 0
|
|
1112
|
+
}, Se({ _: 2 }, [
|
|
1113
|
+
l.$slots["node-loading"] ? {
|
|
1114
|
+
name: "node-loading",
|
|
1115
|
+
fn: te(() => [
|
|
1116
|
+
de(l.$slots, "node-loading")
|
|
1117
|
+
]),
|
|
1118
|
+
key: "0"
|
|
1119
|
+
} : void 0
|
|
1120
|
+
]), 1032, ["node", "index", "show-checkbox", "render-content", "schedule-content"])
|
|
1121
|
+
]),
|
|
1122
|
+
_: 3
|
|
1123
|
+
}, 8, ["list-data"]));
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
function Bt(e, t) {
|
|
1127
|
+
if (!e || !t) return;
|
|
1128
|
+
const n = t.split(" ");
|
|
709
1129
|
for (const d of n)
|
|
710
|
-
d &&
|
|
1130
|
+
d && e.classList.add(d);
|
|
711
1131
|
}
|
|
712
|
-
function
|
|
713
|
-
if (!
|
|
714
|
-
const n =
|
|
1132
|
+
function ce(e, t) {
|
|
1133
|
+
if (!e || !t) return;
|
|
1134
|
+
const n = t.split(" ");
|
|
715
1135
|
for (const d of n)
|
|
716
|
-
d &&
|
|
1136
|
+
d && e.classList.remove(d);
|
|
717
1137
|
}
|
|
718
|
-
const
|
|
1138
|
+
const Ot = Y({
|
|
719
1139
|
name: "VueTree",
|
|
720
|
-
components: { VueTreeNode:
|
|
1140
|
+
components: { VueTreeNode: mt, VirtualTreeRows: St },
|
|
721
1141
|
props: {
|
|
722
1142
|
data: {
|
|
723
1143
|
type: Array,
|
|
@@ -783,11 +1203,18 @@ const ht = oe({
|
|
|
783
1203
|
default: 18
|
|
784
1204
|
},
|
|
785
1205
|
iconClass: String,
|
|
786
|
-
/**
|
|
1206
|
+
/** 已展开且未被过滤的各层节点共用一个虚拟窗口,隐藏或收起的子树仍由模型保存。 */
|
|
787
1207
|
virtual: {
|
|
788
1208
|
type: Boolean,
|
|
789
1209
|
default: !1
|
|
790
|
-
}
|
|
1210
|
+
},
|
|
1211
|
+
/**
|
|
1212
|
+
* 仅用于有 renderContent 或默认插槽的虚拟树。行、文件名和复选框先显示,
|
|
1213
|
+
* 图标、菜单等自定义内容由 VirtualTreeRows 分帧安排,轮到本行时再挂载。
|
|
1214
|
+
*/
|
|
1215
|
+
deferContent: Boolean,
|
|
1216
|
+
/** 虚拟行可读取调用方的数据字段。例如 loadingKey="pending" 对应 data.pending。 */
|
|
1217
|
+
loadingKey: String
|
|
791
1218
|
},
|
|
792
1219
|
emits: [
|
|
793
1220
|
"node-expand",
|
|
@@ -804,356 +1231,404 @@ const ht = oe({
|
|
|
804
1231
|
"node-drag-end",
|
|
805
1232
|
"node-drop"
|
|
806
1233
|
],
|
|
807
|
-
setup(
|
|
808
|
-
const d =
|
|
1234
|
+
setup(e, { emit: t, expose: n }) {
|
|
1235
|
+
const d = rt(), o = at();
|
|
1236
|
+
function a() {
|
|
1237
|
+
return e.deferContent && !!(e.renderContent || d.default);
|
|
1238
|
+
}
|
|
1239
|
+
const r = S(null), s = S(null), u = S(null), l = S(), y = S(), g = S(), C = ve({
|
|
809
1240
|
showDropIndicator: !1,
|
|
810
1241
|
draggingNode: null,
|
|
811
1242
|
dropNode: null,
|
|
812
1243
|
allowDrop: !0,
|
|
813
1244
|
dropType: ""
|
|
814
|
-
}),
|
|
815
|
-
function
|
|
816
|
-
|
|
1245
|
+
}), p = [];
|
|
1246
|
+
function v(i) {
|
|
1247
|
+
p.push(i);
|
|
817
1248
|
}
|
|
818
|
-
function
|
|
819
|
-
|
|
1249
|
+
function K(i) {
|
|
1250
|
+
p.forEach((c) => c(i));
|
|
820
1251
|
}
|
|
821
|
-
function
|
|
822
|
-
|
|
1252
|
+
function k(i, ...c) {
|
|
1253
|
+
t(i, ...c);
|
|
823
1254
|
}
|
|
824
|
-
|
|
1255
|
+
st("vueTree", {
|
|
825
1256
|
get store() {
|
|
826
|
-
return
|
|
1257
|
+
return r.value;
|
|
827
1258
|
},
|
|
828
1259
|
get nodeKey() {
|
|
829
|
-
return
|
|
1260
|
+
return e.nodeKey;
|
|
830
1261
|
},
|
|
831
1262
|
get props() {
|
|
832
|
-
return
|
|
1263
|
+
return e.props;
|
|
833
1264
|
},
|
|
834
1265
|
get expandOnClickNode() {
|
|
835
|
-
return
|
|
1266
|
+
return e.expandOnClickNode;
|
|
836
1267
|
},
|
|
837
1268
|
get checkOnClickNode() {
|
|
838
|
-
return
|
|
1269
|
+
return e.checkOnClickNode;
|
|
839
1270
|
},
|
|
840
1271
|
get checkStrictly() {
|
|
841
|
-
return
|
|
1272
|
+
return e.checkStrictly;
|
|
842
1273
|
},
|
|
843
1274
|
get draggable() {
|
|
844
|
-
return
|
|
1275
|
+
return e.draggable;
|
|
845
1276
|
},
|
|
846
1277
|
get accordion() {
|
|
847
|
-
return
|
|
1278
|
+
return e.accordion;
|
|
848
1279
|
},
|
|
849
1280
|
get indent() {
|
|
850
|
-
return
|
|
1281
|
+
return e.indent;
|
|
1282
|
+
},
|
|
1283
|
+
get loadingKey() {
|
|
1284
|
+
return e.loadingKey;
|
|
851
1285
|
},
|
|
852
1286
|
get iconClass() {
|
|
853
|
-
return
|
|
1287
|
+
return e.iconClass;
|
|
854
1288
|
},
|
|
855
1289
|
get currentNode() {
|
|
856
|
-
return
|
|
1290
|
+
return u.value;
|
|
857
1291
|
},
|
|
858
|
-
set currentNode(
|
|
859
|
-
|
|
1292
|
+
set currentNode(i) {
|
|
1293
|
+
u.value = i;
|
|
860
1294
|
},
|
|
861
1295
|
slots: d,
|
|
862
|
-
emitEvent:
|
|
863
|
-
broadcastTreeNodeExpand:
|
|
864
|
-
onAccordionExpand:
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
return !o || o.length === 0 || o.every(({ visible: i }) => !i);
|
|
1296
|
+
emitEvent: k,
|
|
1297
|
+
broadcastTreeNodeExpand: K,
|
|
1298
|
+
onAccordionExpand: v,
|
|
1299
|
+
handleVirtualNodeExpand: Ye,
|
|
1300
|
+
handleTreeNodeDragStart: Je,
|
|
1301
|
+
handleTreeNodeDragOver: Qe,
|
|
1302
|
+
handleTreeNodeDragEnd: Xe
|
|
1303
|
+
}), r.value = new ht({
|
|
1304
|
+
key: e.nodeKey,
|
|
1305
|
+
isVirtual: () => e.virtual,
|
|
1306
|
+
data: e.data,
|
|
1307
|
+
lazy: e.lazy,
|
|
1308
|
+
props: e.props,
|
|
1309
|
+
load: e.load,
|
|
1310
|
+
currentNodeKey: e.currentNodeKey,
|
|
1311
|
+
checkStrictly: e.checkStrictly,
|
|
1312
|
+
checkDescendants: e.checkDescendants,
|
|
1313
|
+
defaultCheckedKeys: e.defaultCheckedKeys,
|
|
1314
|
+
defaultExpandedKeys: e.defaultExpandedKeys,
|
|
1315
|
+
autoExpandParent: e.autoExpandParent,
|
|
1316
|
+
defaultExpandAll: e.defaultExpandAll,
|
|
1317
|
+
filterNodeMethod: e.filterNodeMethod
|
|
1318
|
+
}), s.value = r.value.root, e.virtual && r.value.initializeRoot();
|
|
1319
|
+
const E = z(() => e.virtual ? ut(s.value) : []), L = (i) => Z(i) ?? i.id;
|
|
1320
|
+
ft(s.value, () => e.virtual, () => e.lazy, (i) => {
|
|
1321
|
+
t("check-change", i.data, i.checked, i.indeterminate);
|
|
889
1322
|
});
|
|
890
|
-
|
|
891
|
-
(
|
|
892
|
-
|
|
893
|
-
|
|
1323
|
+
function Z(i) {
|
|
1324
|
+
return he(e.nodeKey, i.data);
|
|
1325
|
+
}
|
|
1326
|
+
const oe = z(() => {
|
|
1327
|
+
const i = s.value.childNodes;
|
|
1328
|
+
return !i || i.length === 0 || i.every(({ visible: c }) => !c);
|
|
1329
|
+
});
|
|
1330
|
+
I(
|
|
1331
|
+
() => e.defaultCheckedKeys,
|
|
1332
|
+
(i) => {
|
|
1333
|
+
r.value.setDefaultCheckedKey(i);
|
|
894
1334
|
}
|
|
895
|
-
),
|
|
896
|
-
() =>
|
|
897
|
-
(
|
|
898
|
-
|
|
1335
|
+
), I(
|
|
1336
|
+
() => e.defaultExpandedKeys,
|
|
1337
|
+
(i) => {
|
|
1338
|
+
r.value.defaultExpandedKeys = i, r.value.setDefaultExpandedKeys(i);
|
|
899
1339
|
}
|
|
900
|
-
),
|
|
901
|
-
() =>
|
|
902
|
-
(
|
|
903
|
-
|
|
1340
|
+
), I(
|
|
1341
|
+
() => e.data,
|
|
1342
|
+
(i) => {
|
|
1343
|
+
r.value.setData(i), e.currentNodeKey && r.value.setCurrentNodeKey(e.currentNodeKey);
|
|
904
1344
|
}
|
|
905
|
-
),
|
|
906
|
-
() =>
|
|
907
|
-
(
|
|
908
|
-
|
|
1345
|
+
), I(
|
|
1346
|
+
() => e.currentNodeKey,
|
|
1347
|
+
(i) => {
|
|
1348
|
+
i && r.value.setCurrentNodeKey(i);
|
|
909
1349
|
}
|
|
910
|
-
),
|
|
911
|
-
() =>
|
|
912
|
-
(
|
|
913
|
-
|
|
1350
|
+
), I(
|
|
1351
|
+
() => e.checkStrictly,
|
|
1352
|
+
(i) => {
|
|
1353
|
+
r.value.checkStrictly = !!i;
|
|
914
1354
|
}
|
|
915
1355
|
);
|
|
916
|
-
function
|
|
917
|
-
if (!
|
|
918
|
-
|
|
1356
|
+
function fe(i) {
|
|
1357
|
+
if (!e.filterNodeMethod) throw new Error("[Tree] filterNodeMethod is required when filter");
|
|
1358
|
+
r.value.filter(i);
|
|
919
1359
|
}
|
|
920
|
-
function
|
|
921
|
-
if (!
|
|
922
|
-
const
|
|
923
|
-
if (!
|
|
924
|
-
const
|
|
925
|
-
let
|
|
926
|
-
for (;
|
|
927
|
-
|
|
928
|
-
return
|
|
1360
|
+
function ie(i) {
|
|
1361
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in getNodePath");
|
|
1362
|
+
const c = r.value.getNode(i);
|
|
1363
|
+
if (!c) return [];
|
|
1364
|
+
const h = [c.data];
|
|
1365
|
+
let N = c.parent;
|
|
1366
|
+
for (; N && N !== s.value; )
|
|
1367
|
+
h.push(N.data), N = N.parent;
|
|
1368
|
+
return h.reverse();
|
|
929
1369
|
}
|
|
930
|
-
function
|
|
931
|
-
return
|
|
1370
|
+
function f(i, c) {
|
|
1371
|
+
return r.value.getCheckedNodes(i, c);
|
|
932
1372
|
}
|
|
933
|
-
function
|
|
934
|
-
return
|
|
1373
|
+
function B(i) {
|
|
1374
|
+
return r.value.getCheckedKeys(i);
|
|
935
1375
|
}
|
|
936
|
-
function
|
|
937
|
-
const
|
|
938
|
-
return
|
|
1376
|
+
function M() {
|
|
1377
|
+
const i = r.value.getCurrentNode();
|
|
1378
|
+
return i ? i.data : null;
|
|
939
1379
|
}
|
|
940
|
-
function
|
|
941
|
-
if (!
|
|
942
|
-
const
|
|
943
|
-
return
|
|
1380
|
+
function Oe() {
|
|
1381
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in getCurrentKey");
|
|
1382
|
+
const i = M();
|
|
1383
|
+
return i ? i[e.nodeKey] : null;
|
|
944
1384
|
}
|
|
945
|
-
function
|
|
946
|
-
if (!
|
|
947
|
-
|
|
1385
|
+
function $e(i, c) {
|
|
1386
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in setCheckedNodes");
|
|
1387
|
+
r.value.setCheckedNodes(i, c);
|
|
948
1388
|
}
|
|
949
|
-
function
|
|
950
|
-
if (!
|
|
951
|
-
|
|
1389
|
+
function Ae(i, c) {
|
|
1390
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in setCheckedKeys");
|
|
1391
|
+
r.value.setCheckedKeys(i, c);
|
|
952
1392
|
}
|
|
953
|
-
function
|
|
954
|
-
|
|
1393
|
+
function Le(i, c, h) {
|
|
1394
|
+
r.value.setChecked(i, c, h);
|
|
955
1395
|
}
|
|
956
|
-
function
|
|
957
|
-
return
|
|
1396
|
+
function Ie() {
|
|
1397
|
+
return r.value.getHalfCheckedNodes();
|
|
958
1398
|
}
|
|
959
|
-
function
|
|
960
|
-
return
|
|
1399
|
+
function Ve() {
|
|
1400
|
+
return r.value.getHalfCheckedKeys();
|
|
961
1401
|
}
|
|
962
|
-
function
|
|
963
|
-
if (!
|
|
964
|
-
|
|
1402
|
+
function Me(i) {
|
|
1403
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in setCurrentNode");
|
|
1404
|
+
r.value.setUserCurrentNode(i);
|
|
965
1405
|
}
|
|
966
|
-
function
|
|
967
|
-
if (!
|
|
968
|
-
|
|
1406
|
+
function Re(i) {
|
|
1407
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in setCurrentKey");
|
|
1408
|
+
r.value.setCurrentNodeKey(i);
|
|
969
1409
|
}
|
|
970
|
-
function
|
|
971
|
-
|
|
1410
|
+
function ge(i) {
|
|
1411
|
+
if (!e.virtual || !e.nodeKey) return -1;
|
|
1412
|
+
const c = r.value.getNode(i);
|
|
1413
|
+
return c ? E.value.indexOf(c) : -1;
|
|
972
1414
|
}
|
|
973
|
-
function
|
|
974
|
-
var
|
|
975
|
-
const
|
|
976
|
-
return
|
|
1415
|
+
function ze(i) {
|
|
1416
|
+
var h;
|
|
1417
|
+
const c = ge(i);
|
|
1418
|
+
return c >= 0 && !!((h = g.value) != null && h.isIndexVisible(c));
|
|
977
1419
|
}
|
|
978
|
-
async function
|
|
979
|
-
var
|
|
980
|
-
|
|
981
|
-
|
|
1420
|
+
async function qe(i) {
|
|
1421
|
+
var h;
|
|
1422
|
+
if (!e.virtual) return;
|
|
1423
|
+
await X();
|
|
1424
|
+
const c = ge(i);
|
|
1425
|
+
c >= 0 && await ((h = g.value) == null ? void 0 : h.scrollToIndex(c));
|
|
982
1426
|
}
|
|
983
|
-
function
|
|
984
|
-
return
|
|
1427
|
+
function je(i) {
|
|
1428
|
+
return r.value.getNode(i);
|
|
985
1429
|
}
|
|
986
|
-
function
|
|
987
|
-
|
|
1430
|
+
function Fe(i) {
|
|
1431
|
+
r.value.remove(i);
|
|
988
1432
|
}
|
|
989
|
-
function
|
|
990
|
-
|
|
1433
|
+
function Pe(i, c) {
|
|
1434
|
+
r.value.append(i, c);
|
|
991
1435
|
}
|
|
992
|
-
function
|
|
993
|
-
|
|
1436
|
+
function He(i, c) {
|
|
1437
|
+
r.value.insertBefore(i, c);
|
|
994
1438
|
}
|
|
995
|
-
function
|
|
996
|
-
|
|
1439
|
+
function Ue(i, c) {
|
|
1440
|
+
r.value.insertAfter(i, c);
|
|
997
1441
|
}
|
|
998
|
-
function
|
|
999
|
-
|
|
1442
|
+
function We(i, c, h) {
|
|
1443
|
+
K(c), t("node-expand", i, c, h);
|
|
1000
1444
|
}
|
|
1001
|
-
function
|
|
1002
|
-
e("node-
|
|
1445
|
+
function Ye(i, c, h) {
|
|
1446
|
+
e.accordion && r.value.collapseOtherBranches(c), t("node-expand", i, c, h);
|
|
1003
1447
|
}
|
|
1004
|
-
function
|
|
1005
|
-
|
|
1006
|
-
s.value.updateChildren(o, i);
|
|
1448
|
+
function Ze(i, c, h) {
|
|
1449
|
+
t("node-collapse", i, c, h);
|
|
1007
1450
|
}
|
|
1008
|
-
function
|
|
1009
|
-
if (
|
|
1010
|
-
|
|
1011
|
-
|
|
1451
|
+
function Ge(i, c) {
|
|
1452
|
+
if (!e.nodeKey) throw new Error("[Tree] nodeKey is required in updateKeyChild");
|
|
1453
|
+
r.value.updateChildren(i, c);
|
|
1454
|
+
}
|
|
1455
|
+
function Je(i, c) {
|
|
1456
|
+
if (typeof e.allowDrag == "function" && !e.allowDrag(c.node))
|
|
1457
|
+
return i.preventDefault(), !1;
|
|
1458
|
+
i.dataTransfer.effectAllowed = "move";
|
|
1012
1459
|
try {
|
|
1013
|
-
|
|
1460
|
+
i.dataTransfer.setData("text/plain", "");
|
|
1014
1461
|
} catch {
|
|
1015
1462
|
}
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
function
|
|
1019
|
-
var
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
const
|
|
1023
|
-
if (!
|
|
1024
|
-
let
|
|
1025
|
-
typeof
|
|
1026
|
-
const
|
|
1027
|
-
let
|
|
1028
|
-
const
|
|
1029
|
-
let
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
function
|
|
1036
|
-
const { draggingNode:
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1463
|
+
C.draggingNode = c, t("node-drag-start", c.node, i);
|
|
1464
|
+
}
|
|
1465
|
+
function Qe(i, c) {
|
|
1466
|
+
var ke;
|
|
1467
|
+
const h = c, N = C.dropNode;
|
|
1468
|
+
N && N !== h && ce(N.$el, "is-drop-inner");
|
|
1469
|
+
const m = C.draggingNode;
|
|
1470
|
+
if (!m || !h) return;
|
|
1471
|
+
let T = !0, w = !0, D = !0, O = !0;
|
|
1472
|
+
typeof e.allowDrop == "function" && (T = e.allowDrop(m.node, h.node, "prev"), O = w = e.allowDrop(m.node, h.node, "inner"), D = e.allowDrop(m.node, h.node, "next")), i.dataTransfer.dropEffect = w ? "move" : "none", (T || w || D) && N !== h && (N && t("node-drag-leave", m.node, N.node, i), t("node-drag-enter", m.node, h.node, i)), (T || w || D) && (C.dropNode = h), h.node.nextSibling === m.node && (D = !1), h.node.previousSibling === m.node && (T = !1), h.node.contains(m.node, !1) && (w = !1), (m.node === h.node || m.node.contains(h.node)) && (T = !1, w = !1, D = !1);
|
|
1473
|
+
const j = h.$el.getBoundingClientRect(), re = ((ke = o == null ? void 0 : o.proxy) == null ? void 0 : ke.$el).getBoundingClientRect();
|
|
1474
|
+
let V;
|
|
1475
|
+
const tt = T ? w ? 0.25 : D ? 0.45 : 1 : -1, nt = D ? w ? 0.75 : T ? 0.55 : 0 : 1;
|
|
1476
|
+
let ae = -9999;
|
|
1477
|
+
const ye = i.clientY - j.top;
|
|
1478
|
+
ye < j.height * tt ? V = "before" : ye > j.height * nt ? V = "after" : w ? V = "inner" : V = "none";
|
|
1479
|
+
const se = h.$el.querySelector(".vue-tree-node__expand-icon").getBoundingClientRect(), le = l.value;
|
|
1480
|
+
V === "before" ? ae = se.top - re.top : V === "after" && (ae = se.bottom - re.top), le && (le.style.top = ae + "px", le.style.left = se.right - re.left + "px"), V === "inner" ? Bt(h.$el, "is-drop-inner") : ce(h.$el, "is-drop-inner"), C.showDropIndicator = V === "before" || V === "after", C.allowDrop = C.showDropIndicator || O, C.dropType = V, t("node-drag-over", m.node, h.node, i);
|
|
1481
|
+
}
|
|
1482
|
+
function Xe(i) {
|
|
1483
|
+
const { draggingNode: c, dropType: h, dropNode: N } = C;
|
|
1484
|
+
if (i.preventDefault(), i.dataTransfer.dropEffect = "move", c && N) {
|
|
1485
|
+
const m = { data: c.node.data };
|
|
1486
|
+
h !== "none" && c.node.remove(), h === "before" ? N.node.parent.insertBefore(m, N.node) : h === "after" ? N.node.parent.insertAfter(m, N.node) : h === "inner" && N.node.insertChild(m), h !== "none" && r.value.registerNode(m), ce(N.$el, "is-drop-inner"), t("node-drag-end", c.node, N.node, h, i), h !== "none" && t("node-drop", c.node, N.node, h, i);
|
|
1040
1487
|
}
|
|
1041
|
-
|
|
1488
|
+
c && !N && t("node-drag-end", c.node, null, h, i), C.showDropIndicator = !1, C.draggingNode = null, C.dropNode = null, C.allowDrop = !0;
|
|
1042
1489
|
}
|
|
1043
|
-
function
|
|
1490
|
+
function _e(i) {
|
|
1044
1491
|
var D;
|
|
1045
|
-
const
|
|
1046
|
-
if (
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
),
|
|
1050
|
-
let
|
|
1051
|
-
[38, 40].indexOf(
|
|
1052
|
-
const
|
|
1053
|
-
[13, 32].indexOf(
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
var
|
|
1057
|
-
|
|
1492
|
+
const c = i.target;
|
|
1493
|
+
if (c.className.indexOf("vue-tree-node") === -1) return;
|
|
1494
|
+
const h = (D = o == null ? void 0 : o.proxy) == null ? void 0 : D.$el, N = Array.from(
|
|
1495
|
+
h.querySelectorAll(".is-focusable[role=treeitem]")
|
|
1496
|
+
), m = N.indexOf(c);
|
|
1497
|
+
let T;
|
|
1498
|
+
[38, 40].indexOf(i.keyCode) > -1 && (i.preventDefault(), i.keyCode === 38 ? T = m !== 0 ? m - 1 : 0 : T = m < N.length - 1 ? m + 1 : 0, N[T].focus()), [37, 39].indexOf(i.keyCode) > -1 && (i.preventDefault(), c.click());
|
|
1499
|
+
const w = c.querySelector('[type="checkbox"]');
|
|
1500
|
+
[13, 32].indexOf(i.keyCode) > -1 && w && (i.preventDefault(), w.click());
|
|
1501
|
+
}
|
|
1502
|
+
async function et(i) {
|
|
1503
|
+
var h, N, m, T;
|
|
1504
|
+
const c = i.target;
|
|
1505
|
+
if (c.matches('.vue-tree-node[role="treeitem"]')) {
|
|
1506
|
+
if (i.key === "ArrowUp" || i.key === "ArrowDown") {
|
|
1507
|
+
i.preventDefault();
|
|
1508
|
+
const w = i.key === "ArrowDown" ? 1 : -1, D = E.value;
|
|
1509
|
+
let O = D.findIndex((G) => String(G.id) === c.dataset.treeNodeId);
|
|
1510
|
+
if (O < 0) return;
|
|
1511
|
+
do
|
|
1512
|
+
O += w;
|
|
1513
|
+
while (O >= 0 && O < D.length && D[O].disabled);
|
|
1514
|
+
w === 1 && O === D.length && (O = D.findIndex((G) => !G.disabled));
|
|
1515
|
+
const j = D[O];
|
|
1516
|
+
if (!j) return;
|
|
1517
|
+
(h = g.value) != null && h.isIndexVisible(O) || await ((N = g.value) == null ? void 0 : N.scrollToIndex(O)), (T = (m = y.value) == null ? void 0 : m.querySelector(
|
|
1518
|
+
`[data-tree-node-id="${j.id}"]`
|
|
1519
|
+
)) == null || T.focus();
|
|
1520
|
+
} else if (i.key === "ArrowLeft" || i.key === "ArrowRight")
|
|
1521
|
+
i.preventDefault(), c.click();
|
|
1522
|
+
else if (i.key === "Enter" || i.key === " ") {
|
|
1523
|
+
const w = c.querySelector('[type="checkbox"]');
|
|
1524
|
+
w && (i.preventDefault(), w.click());
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
return Ee(() => {
|
|
1529
|
+
var c;
|
|
1530
|
+
((c = o == null ? void 0 : o.proxy) == null ? void 0 : c.$el).addEventListener("keydown", (h) => {
|
|
1531
|
+
e.virtual ? et(h) : _e(h);
|
|
1532
|
+
});
|
|
1058
1533
|
}), n({
|
|
1059
|
-
filter:
|
|
1060
|
-
getNodePath:
|
|
1061
|
-
getCheckedNodes:
|
|
1062
|
-
getCheckedKeys:
|
|
1063
|
-
getCurrentNode:
|
|
1064
|
-
getCurrentKey:
|
|
1065
|
-
setCheckedNodes:
|
|
1066
|
-
setCheckedKeys:
|
|
1067
|
-
setChecked:
|
|
1068
|
-
getHalfCheckedNodes:
|
|
1069
|
-
getHalfCheckedKeys:
|
|
1070
|
-
setCurrentNode:
|
|
1071
|
-
setCurrentKey:
|
|
1072
|
-
isKeyVisible:
|
|
1073
|
-
scrollToKey:
|
|
1074
|
-
getNode:
|
|
1075
|
-
remove:
|
|
1076
|
-
append:
|
|
1077
|
-
insertBefore:
|
|
1078
|
-
insertAfter:
|
|
1079
|
-
updateKeyChildren:
|
|
1080
|
-
store:
|
|
1534
|
+
filter: fe,
|
|
1535
|
+
getNodePath: ie,
|
|
1536
|
+
getCheckedNodes: f,
|
|
1537
|
+
getCheckedKeys: B,
|
|
1538
|
+
getCurrentNode: M,
|
|
1539
|
+
getCurrentKey: Oe,
|
|
1540
|
+
setCheckedNodes: $e,
|
|
1541
|
+
setCheckedKeys: Ae,
|
|
1542
|
+
setChecked: Le,
|
|
1543
|
+
getHalfCheckedNodes: Ie,
|
|
1544
|
+
getHalfCheckedKeys: Ve,
|
|
1545
|
+
setCurrentNode: Me,
|
|
1546
|
+
setCurrentKey: Re,
|
|
1547
|
+
isKeyVisible: ze,
|
|
1548
|
+
scrollToKey: qe,
|
|
1549
|
+
getNode: je,
|
|
1550
|
+
remove: Fe,
|
|
1551
|
+
append: Pe,
|
|
1552
|
+
insertBefore: He,
|
|
1553
|
+
insertAfter: Ue,
|
|
1554
|
+
updateKeyChildren: Ge,
|
|
1555
|
+
store: r
|
|
1081
1556
|
}), {
|
|
1082
|
-
store:
|
|
1083
|
-
root:
|
|
1084
|
-
currentNode:
|
|
1085
|
-
dragState:
|
|
1086
|
-
dropIndicator:
|
|
1087
|
-
treeContainerRef:
|
|
1088
|
-
virtualListRef:
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1557
|
+
store: r,
|
|
1558
|
+
root: s,
|
|
1559
|
+
currentNode: u,
|
|
1560
|
+
dragState: C,
|
|
1561
|
+
dropIndicator: l,
|
|
1562
|
+
treeContainerRef: y,
|
|
1563
|
+
virtualListRef: g,
|
|
1564
|
+
expandedRows: E,
|
|
1565
|
+
shouldDeferContent: a,
|
|
1566
|
+
getRowKey: L,
|
|
1567
|
+
isEmpty: oe,
|
|
1568
|
+
getNodeKeyFn: Z,
|
|
1569
|
+
handleNodeExpand: We,
|
|
1570
|
+
handleNodeCollapse: Ze
|
|
1093
1571
|
};
|
|
1094
1572
|
}
|
|
1095
|
-
}),
|
|
1573
|
+
}), $t = {
|
|
1096
1574
|
key: 2,
|
|
1097
1575
|
class: "vue-tree__empty-block"
|
|
1098
|
-
},
|
|
1576
|
+
}, At = { class: "vue-tree__empty-text" }, Lt = {
|
|
1099
1577
|
class: "vue-tree__drop-indicator",
|
|
1100
1578
|
ref: "dropIndicator"
|
|
1101
1579
|
};
|
|
1102
|
-
function
|
|
1103
|
-
const
|
|
1104
|
-
return
|
|
1580
|
+
function It(e, t, n, d, o, a) {
|
|
1581
|
+
const r = _("VirtualTreeRows"), s = _("vue-tree-node");
|
|
1582
|
+
return b(), $("div", {
|
|
1105
1583
|
ref: "treeContainerRef",
|
|
1106
|
-
class:
|
|
1107
|
-
"vue-tree--highlight-current":
|
|
1108
|
-
"vue-tree--virtual":
|
|
1109
|
-
"is-dragging": !!
|
|
1110
|
-
"is-drop-not-allow": !
|
|
1111
|
-
"is-drop-inner":
|
|
1584
|
+
class: R(["vue-tree", {
|
|
1585
|
+
"vue-tree--highlight-current": e.highlightCurrent,
|
|
1586
|
+
"vue-tree--virtual": e.virtual,
|
|
1587
|
+
"is-dragging": !!e.dragState.draggingNode,
|
|
1588
|
+
"is-drop-not-allow": !e.dragState.allowDrop,
|
|
1589
|
+
"is-drop-inner": e.dragState.dropType === "inner"
|
|
1112
1590
|
}]),
|
|
1113
1591
|
role: "tree"
|
|
1114
1592
|
}, [
|
|
1115
|
-
|
|
1593
|
+
e.virtual && !e.isEmpty ? (b(), H(r, {
|
|
1116
1594
|
key: 0,
|
|
1117
1595
|
ref: "virtualListRef",
|
|
1118
|
-
|
|
1119
|
-
"
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
"
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
t.isEmpty ? (m(), O("div", ut, [
|
|
1146
|
-
Xe(t.$slots, "empty", {}, () => [
|
|
1147
|
-
A("span", ft, Ze(t.emptyText), 1)
|
|
1596
|
+
rows: e.expandedRows,
|
|
1597
|
+
"get-row-key": e.getRowKey,
|
|
1598
|
+
"show-checkbox": e.showCheckbox,
|
|
1599
|
+
"render-content": e.renderContent,
|
|
1600
|
+
"defer-content": e.shouldDeferContent()
|
|
1601
|
+
}, Se({ _: 2 }, [
|
|
1602
|
+
e.$slots["node-loading"] ? {
|
|
1603
|
+
name: "node-loading",
|
|
1604
|
+
fn: te(() => [
|
|
1605
|
+
de(e.$slots, "node-loading")
|
|
1606
|
+
]),
|
|
1607
|
+
key: "0"
|
|
1608
|
+
} : void 0
|
|
1609
|
+
]), 1032, ["rows", "get-row-key", "show-checkbox", "render-content", "defer-content"])) : q("", !0),
|
|
1610
|
+
!e.virtual && !e.isEmpty ? (b(!0), $(Ke, { key: 1 }, xe(e.root.childNodes, (u) => (b(), H(s, {
|
|
1611
|
+
key: e.getNodeKeyFn(u),
|
|
1612
|
+
node: u,
|
|
1613
|
+
props: e.props,
|
|
1614
|
+
"render-after-expand": e.renderAfterExpand,
|
|
1615
|
+
"show-checkbox": e.showCheckbox,
|
|
1616
|
+
"render-content": e.renderContent,
|
|
1617
|
+
onNodeExpand: e.handleNodeExpand,
|
|
1618
|
+
onNodeCollapse: e.handleNodeCollapse
|
|
1619
|
+
}, null, 8, ["node", "props", "render-after-expand", "show-checkbox", "render-content", "onNodeExpand", "onNodeCollapse"]))), 128)) : q("", !0),
|
|
1620
|
+
e.isEmpty ? (b(), $("div", $t, [
|
|
1621
|
+
de(e.$slots, "empty", {}, () => [
|
|
1622
|
+
A("span", At, Te(e.emptyText), 1)
|
|
1148
1623
|
])
|
|
1149
|
-
])) :
|
|
1150
|
-
|
|
1151
|
-
[
|
|
1624
|
+
])) : q("", !0),
|
|
1625
|
+
ee(A("div", Lt, null, 512), [
|
|
1626
|
+
[ne, e.dragState.showDropIndicator]
|
|
1152
1627
|
])
|
|
1153
1628
|
], 2);
|
|
1154
1629
|
}
|
|
1155
|
-
const
|
|
1630
|
+
const Rt = /* @__PURE__ */ ue(Ot, [["render", It]]);
|
|
1156
1631
|
export {
|
|
1157
|
-
|
|
1158
|
-
|
|
1632
|
+
Rt as VueTree,
|
|
1633
|
+
Rt as default
|
|
1159
1634
|
};
|