@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/dist/index.js CHANGED
@@ -1,44 +1,49 @@
1
- import { defineComponent as oe, h as te, Transition as Re, inject as Ue, ref as b, computed as pe, watch as T, nextTick as he, onMounted as ge, resolveComponent as R, withDirectives as ne, openBlock as m, createElementBlock as O, withModifiers as L, normalizeClass as P, createElementVNode as A, normalizeStyle as Ve, createCommentVNode as $, createBlock as U, resolveDynamicComponent as We, createVNode as Ne, withCtx as ke, Fragment as Ce, renderList as ve, vShow as de, useSlots as Ye, getCurrentInstance as Ge, reactive as Je, provide as Qe, renderSlot as Xe, toDisplayString as Ze } from "vue";
2
- import _e from "@cw-devops-fe/virtual-list-vue3";
3
- const I = "$treeNodeId", ue = function(t, e) {
4
- !e || e[I] || Object.defineProperty(e, I, {
5
- value: t.id,
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
- }, re = function(t, e) {
11
- return t ? e[t] : e[I];
12
- }, H = (t) => {
13
- let e = !0, n = !0, d = !0;
14
- for (let r = 0, s = t.length; r < s; r++) {
15
- const l = t[r];
16
- (l.checked !== !0 || l.indeterminate) && (e = !1, l.disabled || (d = !1)), (l.checked !== !1 || l.indeterminate) && (n = !1);
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: e, none: n, allWithoutDisable: d, half: !e && !n };
19
- }, F = function(t) {
20
- if (t.childNodes.length === 0 || t.loading) return;
21
- const { all: e, half: n, none: d } = H(t.childNodes);
22
- e ? (t.checked = !0, t.indeterminate = !1) : n ? (t.checked = !1, t.indeterminate = !0) : d && (t.checked = !1, t.indeterminate = !1);
23
- const r = t.parent;
24
- !r || r.level === 0 || t.store.checkStrictly || F(r);
25
- }, q = function(t, e) {
26
- const n = t.store.props, d = t.data || {}, r = n[e];
27
- if (typeof r == "function")
28
- return r(d, t);
29
- if (typeof r == "string")
30
- return d[r];
31
- if (typeof r > "u") {
32
- const s = d[e];
33
- return s === void 0 ? "" : s;
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 et = 0;
37
- class M {
38
- constructor(e) {
39
- this.id = et++, 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;
40
- for (const l in e)
41
- Object.prototype.hasOwnProperty.call(e, l) && (this[l] = e[l]);
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 l = q(this, "isLeaf");
50
- typeof l == "boolean" && (this.isLeafByUser = l);
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) || ue(this, this.data), !this.data) return;
53
- const r = n.defaultExpandedKeys, s = n.key;
54
- s && r && r.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();
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(e) {
57
- Array.isArray(e) || ue(this, e), this.data = e, this.childNodes = [];
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 = q(this, "children") || [];
60
- for (let d = 0, r = n.length; d < r; d++)
61
- this.insertChild({ data: n[d] });
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 q(this, "label");
70
+ return J(this, "label");
65
71
  }
66
72
  get key() {
67
- const e = this.store.key;
68
- return this.data ? this.data[e] : null;
73
+ const t = this.store.key;
74
+ return this.data ? this.data[t] : null;
69
75
  }
70
76
  get disabled() {
71
- return q(this, "disabled");
77
+ return J(this, "disabled");
72
78
  }
73
79
  get nextSibling() {
74
- const e = this.parent;
75
- if (e) {
76
- const n = e.childNodes.indexOf(this);
80
+ const t = this.parent;
81
+ if (t) {
82
+ const n = t.childNodes.indexOf(this);
77
83
  if (n > -1)
78
- return e.childNodes[n + 1];
84
+ return t.childNodes[n + 1];
79
85
  }
80
86
  return null;
81
87
  }
82
88
  get previousSibling() {
83
- const e = this.parent;
84
- if (e) {
85
- const n = e.childNodes.indexOf(this);
89
+ const t = this.parent;
90
+ if (t) {
91
+ const n = t.childNodes.indexOf(this);
86
92
  if (n > -1)
87
- return n > 0 ? e.childNodes[n - 1] : null;
93
+ return n > 0 ? t.childNodes[n - 1] : null;
88
94
  }
89
95
  return null;
90
96
  }
91
- contains(e, n = !0) {
92
- const d = function(r) {
93
- const s = r.childNodes || [];
94
- let l = !1;
95
- for (let c = 0, y = s.length; c < y; c++) {
96
- const u = s[c];
97
- if (u === e || n && d(u)) {
98
- l = !0;
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 l;
108
+ return r;
103
109
  };
104
110
  return d(this);
105
111
  }
106
112
  remove() {
107
- const e = this.parent;
108
- e && e.removeChild(this);
113
+ const t = this.parent;
114
+ t && t.removeChild(this);
109
115
  }
110
- insertChild(e, n, d) {
111
- if (!e) throw new Error("insertChild error: child is required.");
112
- if (!(e instanceof M)) {
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 r = this.getChildren(!0) || [];
115
- r.indexOf(e.data) === -1 && (typeof n > "u" || n < 0 ? r.push(e.data) : r.splice(n, 0, e.data));
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(e, { parent: this, store: this.store }), e = new M(e);
123
+ Object.assign(t, { parent: this, store: this.store }), t = new P(t);
118
124
  }
119
- e.level = this.level + 1, typeof n > "u" || n < 0 ? this.childNodes.push(e) : this.childNodes.splice(n, 0, e), this.updateLeafState();
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(e, n) {
127
+ insertBefore(t, n) {
122
128
  let d;
123
- n && (d = this.childNodes.indexOf(n)), this.insertChild(e, d);
129
+ n && (d = this.childNodes.indexOf(n)), this.insertChild(t, d);
124
130
  }
125
- insertAfter(e, n) {
131
+ insertAfter(t, n) {
126
132
  let d;
127
- n && (d = this.childNodes.indexOf(n), d !== -1 && (d += 1)), this.insertChild(e, d);
133
+ n && (d = this.childNodes.indexOf(n), d !== -1 && (d += 1)), this.insertChild(t, d);
128
134
  }
129
- removeChild(e) {
130
- const n = this.getChildren() || [], d = n.indexOf(e.data);
135
+ removeChild(t) {
136
+ const n = this.getChildren() || [], d = n.indexOf(t.data);
131
137
  d > -1 && n.splice(d, 1);
132
- const r = this.childNodes.indexOf(e);
133
- r > -1 && (this.store && this.store.deregisterNode(e), e.parent = null, this.childNodes.splice(r, 1)), this.updateLeafState();
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(e) {
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 === e) {
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(e, n) {
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, e && e();
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 || F(this), d());
165
+ r instanceof Array && (this.checked ? this.setChecked(!0, !0) : this.store.checkStrictly || U(this), d());
155
166
  }) : d();
156
167
  }
157
- doCreateChildren(e, n = {}) {
158
- e.forEach((d) => {
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 e = this.childNodes;
204
+ const t = this.childNodes;
174
205
  if (!this.store.lazy || this.store.lazy === !0 && this.loaded === !0) {
175
- this.isLeaf = !e || e.length === 0;
206
+ this.isLeaf = !t || t.length === 0;
176
207
  return;
177
208
  }
178
209
  this.isLeaf = !1;
179
210
  }
180
- setChecked(e, n, d, r) {
181
- if (this.indeterminate = e === "half", this.checked = e === !0, this.store.checkStrictly) return;
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: l } = H(this.childNodes);
184
- !this.isLeaf && !H(this.childNodes).all && l && (this.checked = !1, e = !1);
185
- const c = () => {
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 y = this.childNodes;
188
- for (let g = 0, C = y.length; g < C; g++) {
189
- const E = y[g];
190
- r = r || e !== !1;
191
- const w = E.disabled ? E.checked : r;
192
- E.setChecked(w, n, !0, r);
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: u, all: k } = H(y);
195
- k || (this.checked = k, this.indeterminate = u);
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
- c(), F(this);
232
+ s(), U(this);
202
233
  },
203
- { checked: e !== !1 }
234
+ { checked: t !== !1 }
204
235
  );
205
236
  return;
206
237
  } else
207
- c();
238
+ s();
208
239
  }
209
- const s = this.parent;
210
- !s || s.level === 0 || d || F(s);
240
+ const a = this.parent;
241
+ !a || a.level === 0 || d || U(a);
211
242
  }
212
- getChildren(e = !1) {
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 r = "children";
218
- return d && (r = d.children || "children"), n[r] === void 0 && (n[r] = null), e && !n[r] && (n[r] = []), n[r];
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
- const e = this.getChildren() || [], n = this.childNodes.map((s) => s.data), d = {}, r = [];
222
- e.forEach((s, l) => {
223
- const c = s[I];
224
- !!c && n.findIndex((u) => u[I] === c) >= 0 ? d[c] = { index: l, data: s } : r.push({ index: l, data: s });
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[I]] || this.removeChildByData(s);
227
- }), r.forEach(({ index: s, data: l }) => {
228
- this.insertChild({ data: l }, s);
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
- loadData(e, n = {}) {
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 = (r) => {
235
- this.childNodes = [], this.doCreateChildren(r, n), this.loaded = !0, this.loading = !1, this.updateLeafState(), e && e.call(this, r);
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
- e && e.call(this);
289
+ t && t.call(this);
240
290
  }
241
291
  }
242
- class tt {
243
- constructor(e) {
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 n in e)
246
- Object.prototype.hasOwnProperty.call(e, n) && (this[n] = e[n]);
247
- if (this.nodesMap = {}, this.root = new M({
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.lazy && this.load) {
251
- const n = this.load;
252
- n(this.root, (d) => {
253
- this.root.doCreateChildren(d), this._initDefaultCheckedNodes();
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
- } else
256
- this._initDefaultCheckedNodes();
314
+ return;
315
+ }
316
+ this._initDefaultCheckedNodes();
257
317
  }
258
- filter(e) {
259
- const n = this.filterNodeMethod, d = this.lazy, r = function(s) {
260
- const l = s.root ? s.root.childNodes : s.childNodes;
261
- if (l.forEach((c) => {
262
- c.visible = n.call(c, e, c.data, c), r(c);
263
- }), !s.visible && l.length) {
264
- let c = !0;
265
- c = !l.some((y) => y.visible), s.root ? s.root.visible = c === !1 : s.visible = c === !1;
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
- e && s.visible && !s.isLeaf && !d && s.expand();
342
+ t && a.visible && !a.isLeaf && !d && a.expand();
268
343
  };
269
- r(this);
344
+ o(this);
270
345
  }
271
- setData(e) {
272
- e !== this.root.data ? (this.root.setData(e), this._initDefaultCheckedNodes()) : this.root.updateChildren();
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(e) {
275
- if (e instanceof M) return e;
276
- const n = typeof e != "object" ? e : re(this.key, e);
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(e, n) {
355
+ insertBefore(t, n) {
280
356
  const d = this.getNode(n);
281
- d.parent.insertBefore({ data: e }, d);
357
+ d.parent.insertBefore({ data: t }, d);
282
358
  }
283
- insertAfter(e, n) {
359
+ insertAfter(t, n) {
284
360
  const d = this.getNode(n);
285
- d.parent.insertAfter({ data: e }, d);
361
+ d.parent.insertAfter({ data: t }, d);
286
362
  }
287
- remove(e) {
288
- const n = this.getNode(e);
289
- n && n.parent && (n === this.currentNode && (this.currentNode = null), n.parent.removeChild(n));
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(e, n) {
371
+ append(t, n) {
292
372
  const d = n ? this.getNode(n) : this.root;
293
- d && d.insertChild({ data: e });
373
+ d && d.insertChild({ data: t });
294
374
  }
295
375
  _initDefaultCheckedNodes() {
296
- const e = this.defaultCheckedKeys || [], n = this.nodesMap;
297
- e.forEach((d) => {
298
- const r = n[d];
299
- r && r.setChecked(!0, !this.checkStrictly);
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(e) {
303
- (this.defaultCheckedKeys || []).indexOf(e.key) !== -1 && e.setChecked(!0, !this.checkStrictly);
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
- setDefaultCheckedKey(e) {
306
- e !== this.defaultCheckedKeys && (this.defaultCheckedKeys = e, this._initDefaultCheckedNodes());
388
+ registerNode(t) {
389
+ if (!this.key || !t || !t.data) return;
390
+ t.key !== void 0 && (this.nodesMap[t.key] = t);
307
391
  }
308
- registerNode(e) {
309
- if (!this.key || !e || !e.data) return;
310
- e.key !== void 0 && (this.nodesMap[e.key] = e);
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
- deregisterNode(e) {
313
- !this.key || !e || !e.data || (e.childNodes.forEach((d) => {
314
- this.deregisterNode(d);
315
- }), delete this.nodesMap[e.key]);
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(e = !1, n = !1) {
318
- const d = [], r = function(s) {
319
- (s.root ? s.root.childNodes : s.childNodes).forEach((c) => {
320
- (c.checked || n && c.indeterminate) && (!e || e && c.isLeaf) && d.push(c.data), r(c);
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 r(this), d;
413
+ return o(this), d;
324
414
  }
325
- getCheckedKeys(e = !1) {
326
- return this.getCheckedNodes(e).map((n) => (n || {})[this.key]);
415
+ getCheckedKeys(t = !1) {
416
+ return this.getCheckedNodes(t).map((n) => (n || {})[this.key]);
327
417
  }
328
418
  getHalfCheckedNodes() {
329
- const e = [], n = function(d) {
330
- (d.root ? d.root.childNodes : d.childNodes).forEach((s) => {
331
- s.indeterminate && e.push(s.data), n(s);
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), e;
424
+ return n(this), t;
335
425
  }
336
426
  getHalfCheckedKeys() {
337
- return this.getHalfCheckedNodes().map((e) => (e || {})[this.key]);
427
+ return this.getHalfCheckedNodes().map((t) => (t || {})[this.key]);
338
428
  }
339
429
  _getAllNodes() {
340
- const e = [], n = this.nodesMap;
430
+ const t = [], n = this.nodesMap;
341
431
  for (const d in n)
342
- Object.prototype.hasOwnProperty.call(n, d) && e.push(n[d]);
343
- return e;
432
+ Object.prototype.hasOwnProperty.call(n, d) && t.push(n[d]);
433
+ return t;
344
434
  }
345
- updateChildren(e, n) {
346
- const d = this.nodesMap[e];
435
+ updateChildren(t, n) {
436
+ const d = this.nodesMap[t];
347
437
  if (!d) return;
348
- const r = d.childNodes;
349
- for (let s = r.length - 1; s >= 0; s--) {
350
- const l = r[s];
351
- this.remove(l.data);
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 s = 0, l = n.length; s < l; s++) {
354
- const c = n[s];
355
- this.append(c, d.data);
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
- _setCheckedKeys(e, n = !1, d) {
359
- const r = this._getAllNodes().sort((c, y) => y.level - c.level), s = /* @__PURE__ */ Object.create(null), l = Object.keys(d);
360
- r.forEach((c) => c.setChecked(!1, !1));
361
- for (let c = 0, y = r.length; c < y; c++) {
362
- const u = r[c], k = u.data[e].toString();
363
- if (!(l.indexOf(k) > -1)) {
364
- u.checked && !s[k] && u.setChecked(!1, !1);
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 C = u.parent;
368
- for (; C && C.level > 0; )
369
- s[C.data[e]] = !0, C = C.parent;
370
- if (u.isLeaf || this.checkStrictly) {
371
- u.setChecked(!0, !1);
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 (u.setChecked(!0, !0), n) {
375
- u.setChecked(!1, !1);
376
- const E = function(w) {
377
- w.childNodes.forEach((S) => {
378
- S.isLeaf || S.setChecked(!1, !1), E(S);
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
- E(u);
495
+ K(g);
382
496
  }
383
497
  }
384
498
  }
385
- setCheckedNodes(e, n = !1) {
386
- const d = this.key, r = {};
387
- e.forEach((s) => {
388
- r[(s || {})[d]] = !0;
389
- }), this._setCheckedKeys(d, n, r);
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(e, n = !1) {
392
- this.defaultCheckedKeys = e;
393
- const d = this.key, r = {};
394
- e.forEach((s) => {
395
- r[s] = !0;
396
- }), this._setCheckedKeys(d, n, r);
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(e) {
399
- e = e || [], this.defaultExpandedKeys = e, e.forEach((n) => {
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(e, n, d) {
405
- const r = this.getNode(e);
406
- r && r.setChecked(!!n, d);
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(e) {
525
+ setCurrentNode(t) {
526
+ var d;
412
527
  const n = this.currentNode;
413
- n && (n.isCurrent = !1), this.currentNode = e, this.currentNode.isCurrent = !0;
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(e) {
416
- const n = e[this.key], d = this.nodesMap[n];
530
+ setUserCurrentNode(t) {
531
+ const n = t[this.key], d = this.nodesMap[n];
417
532
  this.setCurrentNode(d);
418
533
  }
419
- setCurrentNodeKey(e) {
420
- if (e == null) {
421
- this.currentNode && (this.currentNode.isCurrent = !1), this.currentNode = null;
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(e);
540
+ const n = this.getNode(t);
425
541
  n && this.setCurrentNode(n);
426
542
  }
427
543
  }
428
- const fe = (t, e) => t.classList.add(e), ye = (t, e) => t.classList.remove(e), nt = oe({
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(t, { slots: e }) {
431
- return () => te(
432
- Re,
588
+ setup(e, { slots: t }) {
589
+ return () => W(
590
+ dt,
433
591
  {
434
592
  onBeforeEnter(n) {
435
593
  const d = n;
436
- fe(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";
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
- ye(d, "collapse-transition"), d.style.height = "", d.style.overflow = d.dataset.oldOverflow || "";
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 && (fe(d, "collapse-transition"), d.style.height = "0", d.style.paddingTop = "0", d.style.paddingBottom = "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
- ye(d, "collapse-transition"), d.style.height = "", d.style.overflow = d.dataset.oldOverflow || "", d.style.paddingTop = d.dataset.oldPaddingTop || "", d.style.paddingBottom = d.dataset.oldPaddingBottom || "";
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
- e.default
617
+ t.default
460
618
  );
461
619
  }
462
- }), dt = oe({
620
+ }), yt = Y({
463
621
  name: "VueTreeNode",
464
622
  components: {
465
- TreeCollapseTransition: nt
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(t, { emit: e }) {
484
- const n = Ue("vueTree"), d = b(), r = b(!1), s = b(!1), l = b(null), c = b(null), y = pe(() => ({
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(h) {
644
+ setup(f) {
487
645
  return () => {
488
- var N;
489
- return t.renderContent ? t.renderContent(te, {
646
+ var B;
647
+ return e.renderContent ? e.renderContent(W, {
490
648
  _self: n,
491
- node: h.node,
492
- data: h.node.data,
493
- store: h.node.store
494
- }) : (N = n == null ? void 0 : n.slots) != null && N.default ? n.slots.default({
495
- node: h.node,
496
- data: h.node.data
497
- }) : te("span", { class: "vue-tree-node__label" }, h.node.label);
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
- T(
502
- () => t.node.indeterminate,
503
- (h) => {
504
- k(t.node.checked, h);
659
+ I(
660
+ () => e.node.indeterminate,
661
+ (f) => {
662
+ y(e.node.checked, f);
505
663
  }
506
- ), T(
507
- () => t.node.checked,
508
- (h) => {
509
- k(h, t.node.indeterminate);
664
+ ), I(
665
+ () => e.node.checked,
666
+ (f) => {
667
+ y(f, e.node.indeterminate);
510
668
  }
511
- ), T(
512
- () => t.node.expanded,
513
- (h) => {
514
- he(() => r.value = h), h && (s.value = !0);
669
+ ), I(
670
+ () => e.node.expanded,
671
+ (f) => {
672
+ X(() => o.value = f), f && (a.value = !0);
515
673
  }
516
674
  );
517
- function u(h) {
518
- return re(n.nodeKey, h.data);
675
+ function l(f) {
676
+ return he(n.nodeKey, f.data);
519
677
  }
520
- function k(h, N) {
521
- (l.value !== h || c.value !== N) && n.emitEvent("check-change", t.node.data, h, N), l.value = h, c.value = N;
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 h = n.store;
525
- h.setCurrentNode(t.node), n.emitEvent(
682
+ const f = n.store;
683
+ f.setCurrentNode(e.node), n.emitEvent(
526
684
  "current-change",
527
- h.currentNode ? h.currentNode.data : null,
528
- h.currentNode
529
- ), n.currentNode = d.value, n.expandOnClickNode && E(), n.checkOnClickNode && !t.node.disabled && w({
530
- target: { checked: !t.node.checked }
531
- }), n.emitEvent("node-click", t.node.data, t.node, { $el: d.value });
532
- }
533
- function C(h) {
534
- n.emitEvent("node-contextmenu", h, t.node.data, t.node, {
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 E() {
539
- t.node.isLeaf || (r.value ? (n.emitEvent("node-collapse", t.node.data, t.node, {
696
+ function p() {
697
+ e.node.isLeaf || (o.value ? (n.emitEvent("node-collapse", e.node.data, e.node, {
540
698
  $el: d.value
541
- }), t.node.collapse()) : (t.node.expand(), e("node-expand", t.node.data, t.node, { $el: d.value })));
542
- }
543
- function w(h) {
544
- const N = h.target;
545
- t.node.setChecked(N.checked, !n.checkStrictly), he(() => {
546
- const B = n.store;
547
- n.emitEvent("check", t.node.data, {
548
- checkedNodes: B.getCheckedNodes(),
549
- checkedKeys: B.getCheckedKeys(),
550
- halfCheckedNodes: B.getHalfCheckedNodes(),
551
- halfCheckedKeys: B.getHalfCheckedKeys()
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 j(h, N, B) {
556
- n.broadcastTreeNodeExpand(N), n.emitEvent("node-expand", h, N, B);
713
+ function K(f, B, M) {
714
+ n.broadcastTreeNodeExpand(B), n.emitEvent("node-expand", f, B, M);
557
715
  }
558
- function S(h) {
559
- n.draggable && n.handleTreeNodeDragStart(h, { node: t.node, $el: d.value });
716
+ function k(f) {
717
+ n.draggable && n.handleTreeNodeDragStart(f, { node: e.node, $el: d.value });
560
718
  }
561
- function V(h) {
562
- n.draggable && (n.handleTreeNodeDragOver(h, { node: t.node, $el: d.value }), h.preventDefault());
719
+ function E(f) {
720
+ n.draggable && (n.handleTreeNodeDragOver(f, { node: e.node, $el: d.value }), f.preventDefault());
563
721
  }
564
- function W(h) {
565
- h.preventDefault();
722
+ function L(f) {
723
+ f.preventDefault();
566
724
  }
567
- function Y(h) {
568
- n.draggable && n.handleTreeNodeDragEnd(h, { node: t.node, $el: d.value });
725
+ function Z(f) {
726
+ n.draggable && n.handleTreeNodeDragEnd(f, { node: e.node, $el: d.value });
569
727
  }
570
- const G = (h) => {
571
- t.node !== h && t.node.collapse();
728
+ const oe = (f) => {
729
+ e.node !== f && e.node.collapse();
572
730
  };
573
- ge(() => {
574
- n.accordion && n.onAccordionExpand(G);
731
+ Ee(() => {
732
+ n.accordion && n.onAccordionExpand(oe);
575
733
  });
576
- const z = (n.props || {}).children || "children";
577
- return T(
734
+ const ie = (n.props || {}).children || "children";
735
+ return I(
578
736
  () => {
579
- var h;
580
- return (h = t.node.data) == null ? void 0 : h[z];
737
+ var f;
738
+ return (f = e.node.data) == null ? void 0 : f[ie];
581
739
  },
582
740
  () => {
583
- t.node.updateChildren();
741
+ e.node.updateChildren();
584
742
  }
585
- ), t.node.expanded && (r.value = !0, s.value = !0), {
743
+ ), e.node.expanded && (o.value = !0, a.value = !0), {
586
744
  tree: n,
587
745
  nodeRef: d,
588
- expanded: r,
589
- childNodeRendered: s,
590
- nodeContentComponent: y,
591
- getNodeKey: u,
746
+ expanded: o,
747
+ childNodeRendered: a,
748
+ nodeContentComponent: u,
749
+ getNodeKey: l,
592
750
  handleClick: g,
593
751
  handleContextMenu: C,
594
- handleExpandIconClick: E,
595
- handleCheckChange: w,
596
- handleChildNodeExpand: j,
597
- handleDragStart: S,
598
- handleDragOver: V,
599
- handleDrop: W,
600
- handleDragEnd: Y
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
- }), me = (t, e) => {
604
- const n = t.__vccOpts || t;
605
- for (const [d, r] of e)
606
- n[d] = r;
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
- }, ot = ["aria-expanded", "aria-disabled", "aria-checked", "draggable"], rt = ["checked", "disabled"], st = {
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
- }, it = ["aria-expanded"];
612
- function at(t, e, n, d, r, s) {
613
- var y;
614
- const l = R("vue-tree-node", !0), c = R("tree-collapse-transition");
615
- return ne((m(), O("div", {
616
- class: P(["vue-tree-node", {
617
- "is-expanded": t.expanded,
618
- "is-current": t.node.isCurrent,
619
- "is-hidden": !t.node.visible,
620
- "is-focusable": !t.node.disabled,
621
- "is-checked": !t.node.disabled && t.node.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: e[3] || (e[3] = L((...u) => t.handleClick && t.handleClick(...u), ["stop"])),
624
- onContextmenu: e[4] || (e[4] = (...u) => t.handleContextMenu && t.handleContextMenu(...u)),
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": t.expanded,
628
- "aria-disabled": t.node.disabled,
629
- "aria-checked": t.node.checked,
630
- draggable: (y = t.tree) == null ? void 0 : y.draggable,
631
- onDragstart: e[5] || (e[5] = L((...u) => t.handleDragStart && t.handleDragStart(...u), ["stop"])),
632
- onDragover: e[6] || (e[6] = L((...u) => t.handleDragOver && t.handleDragOver(...u), ["stop"])),
633
- onDragend: e[7] || (e[7] = L((...u) => t.handleDragEnd && t.handleDragEnd(...u), ["stop"])),
634
- onDrop: e[8] || (e[8] = L((...u) => t.handleDrop && t.handleDrop(...u), ["stop"])),
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: Ve({ "padding-left": (t.node.level - 1) * t.tree.indent + "px" })
797
+ style: be({ "padding-left": (e.node.level - 1) * e.tree.indent + "px" })
640
798
  }, [
641
799
  A("span", {
642
- onClick: e[0] || (e[0] = L((...u) => t.handleExpandIconClick && t.handleExpandIconClick(...u), ["stop"])),
643
- class: P([
644
- { "is-leaf": t.node.isLeaf, expanded: !t.node.isLeaf && t.expanded },
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
- t.tree.iconClass ? t.tree.iconClass : "vue-icon-caret-right"
804
+ e.tree.iconClass ? e.tree.iconClass : "vue-icon-caret-right"
647
805
  ])
648
806
  }, null, 2),
649
- t.showCheckbox ? (m(), O("label", {
807
+ e.showCheckbox ? (b(), $("label", {
650
808
  key: 0,
651
- class: P(["vue-checkbox", {
652
- "is-checked": t.node.checked,
653
- "is-indeterminate": t.node.indeterminate,
654
- "is-disabled": !!t.node.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: e[2] || (e[2] = L(() => {
814
+ onClick: t[2] || (t[2] = x(() => {
657
815
  }, ["stop"]))
658
816
  }, [
659
817
  A("span", {
660
- class: P(["vue-checkbox__input", {
661
- "is-checked": t.node.checked,
662
- "is-indeterminate": t.node.indeterminate,
663
- "is-disabled": !!t.node.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
- e[9] || (e[9] = A("span", { class: "vue-checkbox__inner" }, null, -1)),
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: t.node.checked,
671
- disabled: !!t.node.disabled,
672
- onChange: e[1] || (e[1] = (...u) => t.handleCheckChange && t.handleCheckChange(...u))
673
- }, null, 40, rt)
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)) : $("", !0),
676
- t.node.loading ? (m(), O("span", st)) : $("", !0),
677
- (m(), U(We(t.nodeContentComponent), { node: t.node }, null, 8, ["node"]))
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
- Ne(c, null, {
680
- default: ke(() => [
681
- !t.renderAfterExpand || t.childNodeRendered ? ne((m(), O("div", {
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": t.expanded
843
+ "aria-expanded": e.expanded
686
844
  }, [
687
- (m(!0), O(Ce, null, ve(t.node.childNodes, (u) => (m(), U(l, {
688
- key: t.getNodeKey(u),
689
- "render-content": t.renderContent,
690
- "render-after-expand": t.renderAfterExpand,
691
- "show-checkbox": t.showCheckbox,
692
- node: u,
693
- onNodeExpand: t.handleChildNodeExpand
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, it)), [
696
- [de, t.expanded]
697
- ]) : $("", !0)
853
+ ], 8, Nt)), [
854
+ [ne, e.expanded]
855
+ ]) : q("", !0)
698
856
  ]),
699
857
  _: 1
700
858
  })
701
- ], 42, ot)), [
702
- [de, t.node.visible]
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 lt = /* @__PURE__ */ me(dt, [["render", at]]);
706
- function ct(t, e) {
707
- if (!t || !e) return;
708
- const n = e.split(" ");
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 && t.classList.add(d);
1130
+ d && e.classList.add(d);
711
1131
  }
712
- function ee(t, e) {
713
- if (!t || !e) return;
714
- const n = e.split(" ");
1132
+ function ce(e, t) {
1133
+ if (!e || !t) return;
1134
+ const n = t.split(" ");
715
1135
  for (const d of n)
716
- d && t.classList.remove(d);
1136
+ d && e.classList.remove(d);
717
1137
  }
718
- const ht = oe({
1138
+ const Ot = Y({
719
1139
  name: "VueTree",
720
- components: { VueTreeNode: lt, VirtualList: _e },
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
- /** 开启虚拟滚动(只虚拟化第一层节点)。默认 false,数据量大时传 true */
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(t, { emit: e, expose: n }) {
808
- const d = Ye(), r = Ge(), s = b(null), l = b(null), c = b(null), y = b(), u = b(), k = b(), g = Je({
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
- }), C = [];
815
- function E(o) {
816
- C.push(o);
1245
+ }), p = [];
1246
+ function v(i) {
1247
+ p.push(i);
817
1248
  }
818
- function w(o) {
819
- C.forEach((i) => i(o));
1249
+ function K(i) {
1250
+ p.forEach((c) => c(i));
820
1251
  }
821
- function j(o, ...i) {
822
- e(o, ...i);
1252
+ function k(i, ...c) {
1253
+ t(i, ...c);
823
1254
  }
824
- Qe("vueTree", {
1255
+ st("vueTree", {
825
1256
  get store() {
826
- return s.value;
1257
+ return r.value;
827
1258
  },
828
1259
  get nodeKey() {
829
- return t.nodeKey;
1260
+ return e.nodeKey;
830
1261
  },
831
1262
  get props() {
832
- return t.props;
1263
+ return e.props;
833
1264
  },
834
1265
  get expandOnClickNode() {
835
- return t.expandOnClickNode;
1266
+ return e.expandOnClickNode;
836
1267
  },
837
1268
  get checkOnClickNode() {
838
- return t.checkOnClickNode;
1269
+ return e.checkOnClickNode;
839
1270
  },
840
1271
  get checkStrictly() {
841
- return t.checkStrictly;
1272
+ return e.checkStrictly;
842
1273
  },
843
1274
  get draggable() {
844
- return t.draggable;
1275
+ return e.draggable;
845
1276
  },
846
1277
  get accordion() {
847
- return t.accordion;
1278
+ return e.accordion;
848
1279
  },
849
1280
  get indent() {
850
- return t.indent;
1281
+ return e.indent;
1282
+ },
1283
+ get loadingKey() {
1284
+ return e.loadingKey;
851
1285
  },
852
1286
  get iconClass() {
853
- return t.iconClass;
1287
+ return e.iconClass;
854
1288
  },
855
1289
  get currentNode() {
856
- return c.value;
1290
+ return u.value;
857
1291
  },
858
- set currentNode(o) {
859
- c.value = o;
1292
+ set currentNode(i) {
1293
+ u.value = i;
860
1294
  },
861
1295
  slots: d,
862
- emitEvent: j,
863
- broadcastTreeNodeExpand: w,
864
- onAccordionExpand: E,
865
- handleTreeNodeDragStart: Me,
866
- handleTreeNodeDragOver: je,
867
- handleTreeNodeDragEnd: ze
868
- }), s.value = new tt({
869
- key: t.nodeKey,
870
- data: t.data,
871
- lazy: t.lazy,
872
- props: t.props,
873
- load: t.load,
874
- currentNodeKey: t.currentNodeKey,
875
- checkStrictly: t.checkStrictly,
876
- checkDescendants: t.checkDescendants,
877
- defaultCheckedKeys: t.defaultCheckedKeys,
878
- defaultExpandedKeys: t.defaultExpandedKeys,
879
- autoExpandParent: t.autoExpandParent,
880
- defaultExpandAll: t.defaultExpandAll,
881
- filterNodeMethod: t.filterNodeMethod
882
- }), l.value = s.value.root;
883
- function S(o) {
884
- return re(t.nodeKey, o.data);
885
- }
886
- const V = pe(() => {
887
- const o = l.value.childNodes;
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
- T(
891
- () => t.defaultCheckedKeys,
892
- (o) => {
893
- s.value.setDefaultCheckedKey(o);
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
- ), T(
896
- () => t.defaultExpandedKeys,
897
- (o) => {
898
- s.value.defaultExpandedKeys = o, s.value.setDefaultExpandedKeys(o);
1335
+ ), I(
1336
+ () => e.defaultExpandedKeys,
1337
+ (i) => {
1338
+ r.value.defaultExpandedKeys = i, r.value.setDefaultExpandedKeys(i);
899
1339
  }
900
- ), T(
901
- () => t.data,
902
- (o) => {
903
- s.value.setData(o), t.currentNodeKey && s.value.setCurrentNodeKey(t.currentNodeKey);
1340
+ ), I(
1341
+ () => e.data,
1342
+ (i) => {
1343
+ r.value.setData(i), e.currentNodeKey && r.value.setCurrentNodeKey(e.currentNodeKey);
904
1344
  }
905
- ), T(
906
- () => t.currentNodeKey,
907
- (o) => {
908
- o && s.value.setCurrentNodeKey(o);
1345
+ ), I(
1346
+ () => e.currentNodeKey,
1347
+ (i) => {
1348
+ i && r.value.setCurrentNodeKey(i);
909
1349
  }
910
- ), T(
911
- () => t.checkStrictly,
912
- (o) => {
913
- s.value.checkStrictly = !!o;
1350
+ ), I(
1351
+ () => e.checkStrictly,
1352
+ (i) => {
1353
+ r.value.checkStrictly = !!i;
914
1354
  }
915
1355
  );
916
- function W(o) {
917
- if (!t.filterNodeMethod) throw new Error("[Tree] filterNodeMethod is required when filter");
918
- s.value.filter(o);
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 Y(o) {
921
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in getNodePath");
922
- const i = s.value.getNode(o);
923
- if (!i) return [];
924
- const a = [i.data];
925
- let f = i.parent;
926
- for (; f && f !== l.value; )
927
- a.push(f.data), f = f.parent;
928
- return a.reverse();
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 G(o, i) {
931
- return s.value.getCheckedNodes(o, i);
1370
+ function f(i, c) {
1371
+ return r.value.getCheckedNodes(i, c);
932
1372
  }
933
- function se(o) {
934
- return s.value.getCheckedKeys(o);
1373
+ function B(i) {
1374
+ return r.value.getCheckedKeys(i);
935
1375
  }
936
- function z() {
937
- const o = s.value.getCurrentNode();
938
- return o ? o.data : null;
1376
+ function M() {
1377
+ const i = r.value.getCurrentNode();
1378
+ return i ? i.data : null;
939
1379
  }
940
- function h() {
941
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in getCurrentKey");
942
- const o = z();
943
- return o ? o[t.nodeKey] : null;
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 N(o, i) {
946
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in setCheckedNodes");
947
- s.value.setCheckedNodes(o, i);
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 B(o, i) {
950
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in setCheckedKeys");
951
- s.value.setCheckedKeys(o, i);
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 Ee(o, i, a) {
954
- s.value.setChecked(o, i, a);
1393
+ function Le(i, c, h) {
1394
+ r.value.setChecked(i, c, h);
955
1395
  }
956
- function Ke() {
957
- return s.value.getHalfCheckedNodes();
1396
+ function Ie() {
1397
+ return r.value.getHalfCheckedNodes();
958
1398
  }
959
- function be() {
960
- return s.value.getHalfCheckedKeys();
1399
+ function Ve() {
1400
+ return r.value.getHalfCheckedKeys();
961
1401
  }
962
- function De(o) {
963
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in setCurrentNode");
964
- s.value.setUserCurrentNode(o);
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 xe(o) {
967
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in setCurrentKey");
968
- s.value.setCurrentNodeKey(o);
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 ie(o) {
971
- return !t.nodeKey || !t.virtual ? -1 : l.value.childNodes.findIndex((i) => String(S(i)) === String(o));
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 we(o) {
974
- var a, f;
975
- const i = ie(o);
976
- return i < 0 ? !1 : !!((f = (a = k.value) == null ? void 0 : a.isIndexVisible) != null && f.call(a, i));
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 Te(o) {
979
- var a, f;
980
- const i = ie(o);
981
- i < 0 || await ((f = (a = k.value) == null ? void 0 : a.scrollToIndex) == null ? void 0 : f.call(a, i));
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 Se(o) {
984
- return s.value.getNode(o);
1427
+ function je(i) {
1428
+ return r.value.getNode(i);
985
1429
  }
986
- function Be(o) {
987
- s.value.remove(o);
1430
+ function Fe(i) {
1431
+ r.value.remove(i);
988
1432
  }
989
- function Oe(o, i) {
990
- s.value.append(o, i);
1433
+ function Pe(i, c) {
1434
+ r.value.append(i, c);
991
1435
  }
992
- function Le(o, i) {
993
- s.value.insertBefore(o, i);
1436
+ function He(i, c) {
1437
+ r.value.insertBefore(i, c);
994
1438
  }
995
- function Ae(o, i) {
996
- s.value.insertAfter(o, i);
1439
+ function Ue(i, c) {
1440
+ r.value.insertAfter(i, c);
997
1441
  }
998
- function $e(o, i, a) {
999
- w(i), e("node-expand", o, i, a);
1442
+ function We(i, c, h) {
1443
+ K(c), t("node-expand", i, c, h);
1000
1444
  }
1001
- function Ie(o, i, a) {
1002
- e("node-collapse", o, i, a);
1445
+ function Ye(i, c, h) {
1446
+ e.accordion && r.value.collapseOtherBranches(c), t("node-expand", i, c, h);
1003
1447
  }
1004
- function Pe(o, i) {
1005
- if (!t.nodeKey) throw new Error("[Tree] nodeKey is required in updateKeyChild");
1006
- s.value.updateChildren(o, i);
1448
+ function Ze(i, c, h) {
1449
+ t("node-collapse", i, c, h);
1007
1450
  }
1008
- function Me(o, i) {
1009
- if (typeof t.allowDrag == "function" && !t.allowDrag(i.node))
1010
- return o.preventDefault(), !1;
1011
- o.dataTransfer.effectAllowed = "move";
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
- o.dataTransfer.setData("text/plain", "");
1460
+ i.dataTransfer.setData("text/plain", "");
1014
1461
  } catch {
1015
1462
  }
1016
- g.draggingNode = i, e("node-drag-start", i.node, o);
1017
- }
1018
- function je(o, i) {
1019
- var ce;
1020
- const a = i, f = g.dropNode;
1021
- f && f !== a && ee(f.$el, "is-drop-inner");
1022
- const p = g.draggingNode;
1023
- if (!p || !a) return;
1024
- let K = !0, v = !0, D = !0, ae = !0;
1025
- typeof t.allowDrop == "function" && (K = t.allowDrop(p.node, a.node, "prev"), ae = v = t.allowDrop(p.node, a.node, "inner"), D = t.allowDrop(p.node, a.node, "next")), o.dataTransfer.dropEffect = v ? "move" : "none", (K || v || D) && f !== a && (f && e("node-drag-leave", p.node, f.node, o), e("node-drag-enter", p.node, a.node, o)), (K || v || D) && (g.dropNode = a), a.node.nextSibling === p.node && (D = !1), a.node.previousSibling === p.node && (K = !1), a.node.contains(p.node, !1) && (v = !1), (p.node === a.node || p.node.contains(a.node)) && (K = !1, v = !1, D = !1);
1026
- const J = a.$el.getBoundingClientRect(), Q = ((ce = r == null ? void 0 : r.proxy) == null ? void 0 : ce.$el).getBoundingClientRect();
1027
- let x;
1028
- const He = K ? v ? 0.25 : D ? 0.45 : 1 : -1, Fe = D ? v ? 0.75 : K ? 0.55 : 0 : 1;
1029
- let X = -9999;
1030
- const le = o.clientY - J.top;
1031
- le < J.height * He ? x = "before" : le > J.height * Fe ? x = "after" : v ? x = "inner" : x = "none";
1032
- const Z = a.$el.querySelector(".vue-tree-node__expand-icon").getBoundingClientRect(), _ = y.value;
1033
- x === "before" ? X = Z.top - Q.top : x === "after" && (X = Z.bottom - Q.top), _ && (_.style.top = X + "px", _.style.left = Z.right - Q.left + "px"), x === "inner" ? ct(a.$el, "is-drop-inner") : ee(a.$el, "is-drop-inner"), g.showDropIndicator = x === "before" || x === "after", g.allowDrop = g.showDropIndicator || ae, g.dropType = x, e("node-drag-over", p.node, a.node, o);
1034
- }
1035
- function ze(o) {
1036
- const { draggingNode: i, dropType: a, dropNode: f } = g;
1037
- if (o.preventDefault(), o.dataTransfer.dropEffect = "move", i && f) {
1038
- const p = { data: i.node.data };
1039
- a !== "none" && i.node.remove(), a === "before" ? f.node.parent.insertBefore(p, f.node) : a === "after" ? f.node.parent.insertAfter(p, f.node) : a === "inner" && f.node.insertChild(p), a !== "none" && s.value.registerNode(p), ee(f.$el, "is-drop-inner"), e("node-drag-end", i.node, f.node, a, o), a !== "none" && e("node-drop", i.node, f.node, a, o);
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
- i && !f && e("node-drag-end", i.node, null, a, o), g.showDropIndicator = !1, g.draggingNode = null, g.dropNode = null, g.allowDrop = !0;
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 qe(o) {
1490
+ function _e(i) {
1044
1491
  var D;
1045
- const i = o.target;
1046
- if (i.className.indexOf("vue-tree-node") === -1) return;
1047
- const a = (D = r == null ? void 0 : r.proxy) == null ? void 0 : D.$el, f = Array.from(
1048
- a.querySelectorAll(".is-focusable[role=treeitem]")
1049
- ), p = f.indexOf(i);
1050
- let K;
1051
- [38, 40].indexOf(o.keyCode) > -1 && (o.preventDefault(), o.keyCode === 38 ? K = p !== 0 ? p - 1 : 0 : K = p < f.length - 1 ? p + 1 : 0, f[K].focus()), [37, 39].indexOf(o.keyCode) > -1 && (o.preventDefault(), i.click());
1052
- const v = i.querySelector('[type="checkbox"]');
1053
- [13, 32].indexOf(o.keyCode) > -1 && v && (o.preventDefault(), v.click());
1054
- }
1055
- return ge(() => {
1056
- var i;
1057
- ((i = r == null ? void 0 : r.proxy) == null ? void 0 : i.$el).addEventListener("keydown", qe);
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: W,
1060
- getNodePath: Y,
1061
- getCheckedNodes: G,
1062
- getCheckedKeys: se,
1063
- getCurrentNode: z,
1064
- getCurrentKey: h,
1065
- setCheckedNodes: N,
1066
- setCheckedKeys: B,
1067
- setChecked: Ee,
1068
- getHalfCheckedNodes: Ke,
1069
- getHalfCheckedKeys: be,
1070
- setCurrentNode: De,
1071
- setCurrentKey: xe,
1072
- isKeyVisible: we,
1073
- scrollToKey: Te,
1074
- getNode: Se,
1075
- remove: Be,
1076
- append: Oe,
1077
- insertBefore: Le,
1078
- insertAfter: Ae,
1079
- updateKeyChildren: Pe,
1080
- store: s
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: s,
1083
- root: l,
1084
- currentNode: c,
1085
- dragState: g,
1086
- dropIndicator: y,
1087
- treeContainerRef: u,
1088
- virtualListRef: k,
1089
- isEmpty: V,
1090
- getNodeKeyFn: S,
1091
- handleNodeExpand: $e,
1092
- handleNodeCollapse: Ie
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
- }), ut = {
1573
+ }), $t = {
1096
1574
  key: 2,
1097
1575
  class: "vue-tree__empty-block"
1098
- }, ft = { class: "vue-tree__empty-text" }, yt = {
1576
+ }, At = { class: "vue-tree__empty-text" }, Lt = {
1099
1577
  class: "vue-tree__drop-indicator",
1100
1578
  ref: "dropIndicator"
1101
1579
  };
1102
- function pt(t, e, n, d, r, s) {
1103
- const l = R("vue-tree-node"), c = R("virtual-list");
1104
- return m(), O("div", {
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: P(["vue-tree", {
1107
- "vue-tree--highlight-current": t.highlightCurrent,
1108
- "vue-tree--virtual": t.virtual,
1109
- "is-dragging": !!t.dragState.draggingNode,
1110
- "is-drop-not-allow": !t.dragState.allowDrop,
1111
- "is-drop-inner": t.dragState.dropType === "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
- t.virtual && !t.isEmpty ? (m(), U(c, {
1593
+ e.virtual && !e.isEmpty ? (b(), H(r, {
1116
1594
  key: 0,
1117
1595
  ref: "virtualListRef",
1118
- "list-data": t.root.childNodes,
1119
- "estimated-item-size": 28,
1120
- height: "100%"
1121
- }, {
1122
- default: ke(({ item: y }) => [
1123
- Ne(l, {
1124
- node: y.item,
1125
- props: t.props,
1126
- "render-after-expand": t.renderAfterExpand,
1127
- "show-checkbox": t.showCheckbox,
1128
- "render-content": t.renderContent,
1129
- onNodeExpand: t.handleNodeExpand,
1130
- onNodeCollapse: t.handleNodeCollapse
1131
- }, null, 8, ["node", "props", "render-after-expand", "show-checkbox", "render-content", "onNodeExpand", "onNodeCollapse"])
1132
- ]),
1133
- _: 1
1134
- }, 8, ["list-data"])) : $("", !0),
1135
- !t.virtual && !t.isEmpty ? (m(!0), O(Ce, { key: 1 }, ve(t.root.childNodes, (y) => (m(), U(l, {
1136
- key: t.getNodeKeyFn(y),
1137
- node: y,
1138
- props: t.props,
1139
- "render-after-expand": t.renderAfterExpand,
1140
- "show-checkbox": t.showCheckbox,
1141
- "render-content": t.renderContent,
1142
- onNodeExpand: t.handleNodeExpand,
1143
- onNodeCollapse: t.handleNodeCollapse
1144
- }, null, 8, ["node", "props", "render-after-expand", "show-checkbox", "render-content", "onNodeExpand", "onNodeCollapse"]))), 128)) : $("", !0),
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
- ])) : $("", !0),
1150
- ne(A("div", yt, null, 512), [
1151
- [de, t.dragState.showDropIndicator]
1624
+ ])) : q("", !0),
1625
+ ee(A("div", Lt, null, 512), [
1626
+ [ne, e.dragState.showDropIndicator]
1152
1627
  ])
1153
1628
  ], 2);
1154
1629
  }
1155
- const Ct = /* @__PURE__ */ me(ht, [["render", pt]]);
1630
+ const Rt = /* @__PURE__ */ ue(Ot, [["render", It]]);
1156
1631
  export {
1157
- Ct as VueTree,
1158
- Ct as default
1632
+ Rt as VueTree,
1633
+ Rt as default
1159
1634
  };