@xto/data 0.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/es/index.mjs ADDED
@@ -0,0 +1,1317 @@
1
+ import { defineComponent as H, computed as I, openBlock as c, createElementBlock as y, normalizeStyle as R, normalizeClass as u, renderSlot as P, unref as d, createCommentVNode as $, createTextVNode as _, toDisplayString as B, createElementVNode as C, ref as G, watch as W, Fragment as Z, renderList as q, useSlots as re, withModifiers as te, reactive as ce, provide as ae, toRef as ue, inject as se, resolveComponent as he, withDirectives as fe, createBlock as le, withCtx as oe, vShow as ye, nextTick as ge, onMounted as ie, onUnmounted as de } from "vue";
2
+ import { useNamespace as Y } from "@xto/core";
3
+ const We = /* @__PURE__ */ H({
4
+ name: "XTag",
5
+ __name: "index",
6
+ props: {
7
+ type: { default: "" },
8
+ size: { default: "default" },
9
+ effect: { default: "light" },
10
+ closable: { type: Boolean, default: !1 },
11
+ hit: { type: Boolean, default: !1 },
12
+ color: {}
13
+ },
14
+ emits: ["close"],
15
+ setup(t, { emit: a }) {
16
+ const e = t, s = a, r = Y("tag"), o = I(() => [
17
+ r.b(),
18
+ r.m(e.type || "primary"),
19
+ e.size !== "default" ? r.m(e.size) : "",
20
+ r.m(e.effect),
21
+ r.is("hit", e.hit)
22
+ ]), i = I(() => e.color ? {
23
+ backgroundColor: e.effect === "dark" ? e.color : "",
24
+ borderColor: e.color,
25
+ color: e.effect === "dark" ? "#fff" : e.color
26
+ } : {}), k = (b) => {
27
+ s("close", b);
28
+ };
29
+ return (b, z) => (c(), y("span", {
30
+ class: u(o.value),
31
+ style: R(i.value)
32
+ }, [
33
+ P(b.$slots, "default"),
34
+ t.closable ? (c(), y("i", {
35
+ key: 0,
36
+ class: u(d(r).e("close")),
37
+ onClick: k
38
+ }, "✕", 2)) : $("", !0)
39
+ ], 6));
40
+ }
41
+ }), Ze = /* @__PURE__ */ H({
42
+ name: "XCard",
43
+ __name: "index",
44
+ props: {
45
+ header: {},
46
+ bodyStyle: { default: () => ({ padding: "20px" }) },
47
+ shadow: { default: "always" }
48
+ },
49
+ setup(t) {
50
+ const a = t, e = Y("card"), s = I(() => [
51
+ e.b(),
52
+ e.is(`shadow-${a.shadow}`)
53
+ ]);
54
+ return (r, o) => (c(), y("div", {
55
+ class: u(s.value)
56
+ }, [
57
+ t.header || r.$slots.header ? (c(), y("div", {
58
+ key: 0,
59
+ class: u(d(e).e("header"))
60
+ }, [
61
+ P(r.$slots, "header", {}, () => [
62
+ _(B(t.header), 1)
63
+ ])
64
+ ], 2)) : $("", !0),
65
+ C("div", {
66
+ class: u(d(e).e("body")),
67
+ style: R(t.bodyStyle)
68
+ }, [
69
+ P(r.$slots, "default")
70
+ ], 6)
71
+ ], 2));
72
+ }
73
+ }), ve = ["viewBox"], pe = ["cx", "cy", "r", "stroke-width"], ke = ["cx", "cy", "r", "stroke-width", "stroke-dasharray", "stroke"], Ue = /* @__PURE__ */ H({
74
+ name: "XProgress",
75
+ __name: "index",
76
+ props: {
77
+ percentage: { default: 0 },
78
+ type: { default: "line" },
79
+ status: { default: "" },
80
+ strokeWidth: { default: 6 },
81
+ color: { type: [String, Array, Function], default: "#409eff" },
82
+ width: { default: 126 },
83
+ showText: { type: Boolean, default: !0 }
84
+ },
85
+ setup(t) {
86
+ const a = t, e = Y("progress"), s = I(() => Math.min(100, Math.max(0, a.percentage))), r = I(() => ({
87
+ width: `${s.value}%`,
88
+ backgroundColor: typeof a.color == "function" ? a.color(s.value) : a.color
89
+ })), o = I(() => [
90
+ e.b(),
91
+ e.m(a.type),
92
+ e.is("show-text", a.showText),
93
+ e.is(`status-${a.status || ""}`, a.status)
94
+ ]);
95
+ return I(() => a.status === "success" ? "100%" : a.status === "warning" ? "Warning" : a.status === "exception" ? "Exception" : `${s.value}%`), (i, k) => (c(), y("div", {
96
+ class: u(o.value)
97
+ }, [
98
+ t.type === "line" ? (c(), y("div", {
99
+ key: 0,
100
+ class: u(d(e).e("line"))
101
+ }, [
102
+ C("div", {
103
+ class: u(d(e).e("outer"))
104
+ }, [
105
+ C("div", {
106
+ class: u(d(e).e("inner"))
107
+ }, [
108
+ C("div", {
109
+ class: u(d(e).e("bar")),
110
+ style: R(r.value)
111
+ }, null, 6)
112
+ ], 2)
113
+ ], 2),
114
+ t.showText ? (c(), y("div", {
115
+ key: 0,
116
+ class: u(d(e).e("text"))
117
+ }, B(s.value) + "% ", 3)) : $("", !0)
118
+ ], 2)) : (c(), y("div", {
119
+ key: 1,
120
+ class: u(d(e).e("circle"))
121
+ }, [
122
+ (c(), y("svg", {
123
+ viewBox: `0 0 ${t.width} ${t.width}`,
124
+ style: R({ width: `${t.width}px`, height: `${t.width}px` })
125
+ }, [
126
+ C("circle", {
127
+ cx: t.width / 2,
128
+ cy: t.width / 2,
129
+ r: (t.width - t.strokeWidth) / 2,
130
+ fill: "none",
131
+ "stroke-width": t.strokeWidth,
132
+ stroke: "#ebeef5"
133
+ }, null, 8, pe),
134
+ C("circle", {
135
+ cx: t.width / 2,
136
+ cy: t.width / 2,
137
+ r: (t.width - t.strokeWidth) / 2,
138
+ fill: "none",
139
+ "stroke-width": t.strokeWidth,
140
+ "stroke-dasharray": `${s.value / 100 * Math.PI * (t.width - t.strokeWidth)} ${Math.PI * (t.width - t.strokeWidth)}`,
141
+ stroke: typeof t.color == "function" ? t.color(s.value) : t.color,
142
+ "stroke-linecap": "round",
143
+ style: { transform: "rotate(-90deg)", "transform-origin": "center" }
144
+ }, null, 8, ke)
145
+ ], 12, ve)),
146
+ t.showText ? (c(), y("div", {
147
+ key: 0,
148
+ class: u(d(e).e("circle-text"))
149
+ }, B(s.value) + "% ", 3)) : $("", !0)
150
+ ], 2))
151
+ ], 2));
152
+ }
153
+ }), me = ["disabled"], xe = ["onClick"], Ce = ["disabled"], we = ["value"], Me = ["value"], Xe = /* @__PURE__ */ H({
154
+ name: "XPagination",
155
+ __name: "index",
156
+ props: {
157
+ total: { default: 0 },
158
+ pageSize: { default: 10 },
159
+ currentPage: { default: 1 },
160
+ pageSizes: { default: () => [10, 20, 50, 100] },
161
+ layout: { default: "total, sizes, prev, pager, next, jumper" }
162
+ },
163
+ emits: ["update:currentPage", "update:pageSize", "current-change", "size-change"],
164
+ setup(t, { emit: a }) {
165
+ const e = t, s = a, r = Y("pagination"), o = G(e.currentPage), i = G(e.pageSize);
166
+ W(() => e.currentPage, (x) => {
167
+ o.value = x;
168
+ }), W(() => e.pageSize, (x) => {
169
+ i.value = x;
170
+ });
171
+ const k = I(() => o.value), b = I(() => i.value), z = I(() => Math.max(1, Math.ceil(e.total / b.value))), M = I(() => {
172
+ const x = [], K = z.value, S = k.value;
173
+ if (K <= 7)
174
+ for (let L = 1; L <= K; L++) x.push(L);
175
+ else if (S <= 4) {
176
+ for (let L = 1; L <= 5; L++) x.push(L);
177
+ x.push(-1), x.push(K);
178
+ } else if (S >= K - 3) {
179
+ x.push(1), x.push(-1);
180
+ for (let L = K - 4; L <= K; L++) x.push(L);
181
+ } else {
182
+ x.push(1), x.push(-1);
183
+ for (let L = S - 1; L <= S + 1; L++) x.push(L);
184
+ x.push(-1), x.push(K);
185
+ }
186
+ return x;
187
+ }), T = (x) => {
188
+ x < 1 || x > z.value || x === k.value || (o.value = x, s("update:currentPage", x), s("current-change", x));
189
+ }, O = (x) => {
190
+ i.value = x, s("update:pageSize", x), s("size-change", x), o.value = 1, s("update:currentPage", 1), s("current-change", 1);
191
+ };
192
+ return (x, K) => (c(), y("div", {
193
+ class: u(d(r).b())
194
+ }, [
195
+ C("span", {
196
+ class: u(d(r).e("total"))
197
+ }, "共 " + B(t.total) + " 条", 3),
198
+ C("button", {
199
+ class: u(d(r).e("btn")),
200
+ disabled: k.value <= 1,
201
+ onClick: K[0] || (K[0] = (S) => T(k.value - 1))
202
+ }, " ‹ ", 10, me),
203
+ (c(!0), y(Z, null, q(M.value, (S) => (c(), y(Z, { key: S }, [
204
+ S === -1 ? (c(), y("span", {
205
+ key: 0,
206
+ class: u(d(r).e("ellipsis"))
207
+ }, "...", 2)) : (c(), y("button", {
208
+ key: 1,
209
+ class: u([d(r).e("btn"), d(r).is("active", S === k.value)]),
210
+ onClick: (L) => T(S)
211
+ }, B(S), 11, xe))
212
+ ], 64))), 128)),
213
+ C("button", {
214
+ class: u(d(r).e("btn")),
215
+ disabled: k.value >= z.value,
216
+ onClick: K[1] || (K[1] = (S) => T(k.value + 1))
217
+ }, " › ", 10, Ce),
218
+ C("select", {
219
+ class: u(d(r).e("sizes")),
220
+ value: b.value,
221
+ onChange: K[2] || (K[2] = (S) => O(Number(S.target.value)))
222
+ }, [
223
+ (c(!0), y(Z, null, q(t.pageSizes, (S) => (c(), y("option", {
224
+ key: S,
225
+ value: S
226
+ }, B(S) + " 条/页", 9, Me))), 128))
227
+ ], 42, we)
228
+ ], 2));
229
+ }
230
+ }), be = { key: 0 }, Ie = ["checked", "indeterminate"], Ke = ["onClick"], Ne = ["onClick"], Se = ["checked", "onChange"], De = ["onClick"], Le = ["onClick"], Ae = { key: 1 }, $e = ["colspan"], Ve = /* @__PURE__ */ H({
231
+ name: "XDynamicTable",
232
+ __name: "index",
233
+ props: {
234
+ data: { default: () => [] },
235
+ columns: { default: () => [] },
236
+ height: {},
237
+ maxHeight: {},
238
+ rowKey: {},
239
+ loading: { type: Boolean, default: !1 },
240
+ border: { type: Boolean, default: !1 },
241
+ stripe: { type: Boolean, default: !1 },
242
+ showHeader: { type: Boolean, default: !0 },
243
+ showIndex: { type: Boolean, default: !1 },
244
+ showOperation: { type: Boolean, default: !1 },
245
+ showAddButton: { type: Boolean, default: !1 },
246
+ operationWidth: { default: 120 },
247
+ operationLabel: { default: "操作" },
248
+ emptyText: { default: "暂无数据" },
249
+ defaultSort: {}
250
+ },
251
+ emits: ["sort-change", "row-click", "row-dblclick", "selection-change", "select-all", "cell-click", "add-row", "delete-row", "update:data"],
252
+ setup(t, { expose: a, emit: e }) {
253
+ var m, g;
254
+ const s = t, r = e, o = Y("dynamic-table");
255
+ re();
256
+ const i = I({
257
+ get: () => s.data,
258
+ set: (l) => r("update:data", l)
259
+ }), k = G({
260
+ prop: ((m = s.defaultSort) == null ? void 0 : m.prop) || "",
261
+ order: ((g = s.defaultSort) == null ? void 0 : g.order) || null
262
+ }), b = G([]), z = G(!1), M = G(!1), T = I(() => {
263
+ if (!k.value.prop || !k.value.order)
264
+ return i.value;
265
+ const { prop: l, order: f } = k.value;
266
+ return [...i.value].sort((p, w) => {
267
+ const E = p[l], ee = w[l];
268
+ if (E === ee) return 0;
269
+ const ne = E > ee ? 1 : -1;
270
+ return f === "ascending" ? ne : -ne;
271
+ });
272
+ }), O = I(() => {
273
+ const l = {};
274
+ return s.height && (l.height = typeof s.height == "number" ? `${s.height}px` : s.height), s.maxHeight && (l.maxHeight = typeof s.maxHeight == "number" ? `${s.maxHeight}px` : s.maxHeight), l;
275
+ }), x = I(() => {
276
+ const l = typeof s.operationWidth == "number" ? `${s.operationWidth}px` : s.operationWidth;
277
+ return { width: l, minWidth: l };
278
+ }), K = I(() => [
279
+ o.b(),
280
+ o.is("border", s.border),
281
+ o.is("stripe", s.stripe),
282
+ o.is("loading", s.loading)
283
+ ]), S = (l) => {
284
+ l.sortable && (k.value.prop === l.prop ? k.value.order === "ascending" ? k.value.order = "descending" : k.value.order === "descending" && (k.value.order = null, k.value.prop = "") : (k.value.prop = l.prop, k.value.order = "ascending"), r("sort-change", { ...k.value }));
285
+ }, L = (l) => l.sortable ? k.value.prop !== l.prop ? o.is("sortable") : [
286
+ o.is("sortable"),
287
+ o.is(`sort-${k.value.order}`)
288
+ ] : "", U = (l, f, p) => {
289
+ const w = l[f.prop];
290
+ return f.formatter ? f.formatter(l, f, w, p) : w ?? "";
291
+ }, X = (l, f, p) => {
292
+ r("row-click", l, f, p);
293
+ }, V = (l, f, p) => {
294
+ const w = p.target;
295
+ r("cell-click", l, f, w, p);
296
+ }, J = () => {
297
+ z.value || M.value ? (b.value = [], z.value = !1, M.value = !1) : (b.value = [...i.value], z.value = !0, M.value = !1), r("select-all", b.value), r("selection-change", b.value);
298
+ }, N = (l) => {
299
+ const f = b.value.findIndex((p) => typeof s.rowKey == "function" ? s.rowKey(p) === s.rowKey(l) : s.rowKey ? p[s.rowKey] === l[s.rowKey] : p === l);
300
+ f > -1 ? b.value.splice(f, 1) : b.value.push(l), z.value = b.value.length === i.value.length, M.value = b.value.length > 0 && b.value.length < i.value.length, r("selection-change", b.value);
301
+ }, j = (l) => b.value.some((f) => typeof s.rowKey == "function" ? s.rowKey(f) === s.rowKey(l) : s.rowKey ? f[s.rowKey] === l[s.rowKey] : f === l), v = (l) => {
302
+ const f = {};
303
+ return l.width && (f.width = typeof l.width == "number" ? `${l.width}px` : l.width), l.minWidth && (f.minWidth = typeof l.minWidth == "number" ? `${l.minWidth}px` : l.minWidth), l.align && (f.textAlign = l.align), f;
304
+ }, D = (l) => {
305
+ const f = l || {};
306
+ s.columns.forEach((p) => {
307
+ f[p.prop] === void 0 && (f[p.prop] = "");
308
+ }), i.value = [...i.value, f], r("add-row", f);
309
+ }, A = (l) => {
310
+ const f = i.value[l];
311
+ i.value = i.value.filter((p, w) => w !== l), r("delete-row", f, l);
312
+ };
313
+ return a({
314
+ clearSelection: () => {
315
+ b.value = [], z.value = !1, M.value = !1;
316
+ },
317
+ getSelection: () => [...b.value],
318
+ sortState: k,
319
+ addRow: D,
320
+ deleteRow: A,
321
+ getData: () => [...i.value]
322
+ }), (l, f) => (c(), y("div", {
323
+ class: u(K.value)
324
+ }, [
325
+ t.showAddButton ? (c(), y("div", {
326
+ key: 0,
327
+ class: u(d(o).e("toolbar"))
328
+ }, [
329
+ P(l.$slots, "toolbar", {}, () => [
330
+ C("button", {
331
+ class: u(d(o).e("add-btn")),
332
+ onClick: f[0] || (f[0] = (p) => D())
333
+ }, [...f[2] || (f[2] = [
334
+ C("span", { class: "add-icon" }, "+", -1),
335
+ _(" 新增一行 ", -1)
336
+ ])], 2)
337
+ ])
338
+ ], 2)) : $("", !0),
339
+ t.loading ? (c(), y("div", {
340
+ key: 1,
341
+ class: u(d(o).e("loading"))
342
+ }, [...f[3] || (f[3] = [
343
+ C("span", { class: "loading-spinner" }, null, -1),
344
+ C("span", { class: "loading-text" }, "加载中...", -1)
345
+ ])], 2)) : $("", !0),
346
+ C("div", {
347
+ class: u(d(o).e("wrapper")),
348
+ style: R(O.value)
349
+ }, [
350
+ C("table", null, [
351
+ t.showHeader ? (c(), y("thead", be, [
352
+ C("tr", null, [
353
+ t.rowKey ? (c(), y("th", {
354
+ key: 0,
355
+ class: u([d(o).e("header-cell"), d(o).e("selection-cell")])
356
+ }, [
357
+ C("input", {
358
+ type: "checkbox",
359
+ checked: z.value,
360
+ indeterminate: M.value,
361
+ onChange: J
362
+ }, null, 40, Ie)
363
+ ], 2)) : $("", !0),
364
+ t.showIndex ? (c(), y("th", {
365
+ key: 1,
366
+ class: u(d(o).e("header-cell")),
367
+ style: { width: "60px" }
368
+ }, " 序号 ", 2)) : $("", !0),
369
+ (c(!0), y(Z, null, q(t.columns, (p) => (c(), y("th", {
370
+ key: p.prop,
371
+ class: u([d(o).e("header-cell"), L(p)]),
372
+ style: R(v(p)),
373
+ onClick: (w) => S(p)
374
+ }, [
375
+ C("span", null, B(p.label), 1),
376
+ p.sortable ? (c(), y("span", {
377
+ key: 0,
378
+ class: u(d(o).e("sort-icon"))
379
+ }, [...f[4] || (f[4] = [
380
+ C("span", { class: "sort-arrow up" }, "▲", -1),
381
+ C("span", { class: "sort-arrow down" }, "▼", -1)
382
+ ])], 2)) : $("", !0)
383
+ ], 14, Ke))), 128)),
384
+ t.showOperation ? (c(), y("th", {
385
+ key: 2,
386
+ class: u(d(o).e("header-cell")),
387
+ style: R(x.value)
388
+ }, B(t.operationLabel), 7)) : $("", !0)
389
+ ])
390
+ ])) : $("", !0),
391
+ C("tbody", null, [
392
+ (c(!0), y(Z, null, q(T.value, (p, w) => (c(), y("tr", {
393
+ key: t.rowKey ? typeof t.rowKey == "function" ? t.rowKey(p) : p[t.rowKey] : w,
394
+ class: u([d(o).e("row"), d(o).is("selected", j(p))]),
395
+ onClick: (E) => X(p, t.columns[0], E)
396
+ }, [
397
+ t.rowKey ? (c(), y("td", {
398
+ key: 0,
399
+ class: u(d(o).e("cell"))
400
+ }, [
401
+ C("input", {
402
+ type: "checkbox",
403
+ checked: j(p),
404
+ onClick: f[1] || (f[1] = te(() => {
405
+ }, ["stop"])),
406
+ onChange: (E) => N(p)
407
+ }, null, 40, Se)
408
+ ], 2)) : $("", !0),
409
+ t.showIndex ? (c(), y("td", {
410
+ key: 1,
411
+ class: u(d(o).e("cell"))
412
+ }, B(w + 1), 3)) : $("", !0),
413
+ (c(!0), y(Z, null, q(t.columns, (E) => (c(), y("td", {
414
+ key: E.prop,
415
+ class: u(d(o).e("cell")),
416
+ style: R(v(E)),
417
+ onClick: (ee) => V(p, E, ee)
418
+ }, [
419
+ P(l.$slots, `column-${E.prop}`, {
420
+ row: p,
421
+ column: E,
422
+ $index: w
423
+ }, () => [
424
+ _(B(U(p, E, w)), 1)
425
+ ])
426
+ ], 14, De))), 128)),
427
+ t.showOperation ? (c(), y("td", {
428
+ key: 2,
429
+ class: u([d(o).e("cell"), d(o).e("operation-cell")])
430
+ }, [
431
+ P(l.$slots, "operation", {
432
+ row: p,
433
+ $index: w,
434
+ deleteRow: () => A(w)
435
+ }, () => [
436
+ C("button", {
437
+ class: u(d(o).e("operation-btn")),
438
+ onClick: te((E) => A(w), ["stop"])
439
+ }, " 删除 ", 10, Le)
440
+ ])
441
+ ], 2)) : $("", !0)
442
+ ], 10, Ne))), 128))
443
+ ]),
444
+ T.value.length === 0 && !t.loading ? (c(), y("tbody", Ae, [
445
+ C("tr", null, [
446
+ C("td", {
447
+ colspan: t.columns.length + (t.rowKey ? 1 : 0) + (t.showIndex ? 1 : 0) + (t.showOperation ? 1 : 0),
448
+ class: u(d(o).e("empty"))
449
+ }, [
450
+ P(l.$slots, "empty", {}, () => [
451
+ _(B(t.emptyText), 1)
452
+ ])
453
+ ], 10, $e)
454
+ ])
455
+ ])) : $("", !0)
456
+ ])
457
+ ], 6)
458
+ ], 2));
459
+ }
460
+ });
461
+ class F {
462
+ constructor(a, e, s = 0, r = null) {
463
+ this.data = a, this.store = e, this.level = s, this.parent = r, this.children = [], this.expanded = !1, this.selected = !1, this.checked = !1, this.indeterminate = !1, this.loading = !1, this.visible = !0, this.loaded = !1;
464
+ const o = e.props || {}, i = o.value || "value", k = o.label || "label", b = o.disabled || "disabled", z = o.isLeaf || "isLeaf";
465
+ this.key = a[i] ?? a.value ?? a.id ?? Math.random().toString(), this.label = a[k] ?? a.label ?? "", this.disabled = a[b] ?? a.disabled ?? !1, this.isLeaf = a[z] ?? a.isLeaf ?? !1;
466
+ const M = o.children || "children", T = a[M] ?? a.children ?? [];
467
+ T.length > 0 ? this.children = T.map(
468
+ (O) => new F(O, e, s + 1, this)
469
+ ) : this.isLeaf = !0;
470
+ }
471
+ /** 设置展开状态 */
472
+ setExpanded(a, e = !0) {
473
+ this.expanded = a, a ? this.store.expandedKeys.add(this.key) : this.store.expandedKeys.delete(this.key);
474
+ }
475
+ /** 设置选中状态 */
476
+ setSelected(a) {
477
+ this.selected = a, a ? this.store.selectedKeys.add(this.key) : this.store.selectedKeys.delete(this.key);
478
+ }
479
+ /** 设置勾选状态 */
480
+ setChecked(a, e = !0, s = !0) {
481
+ this.checked = a, this.indeterminate = !1, a ? (this.store.checkedKeys.add(this.key), this.store.indeterminateKeys.delete(this.key)) : (this.store.checkedKeys.delete(this.key), this.store.indeterminateKeys.delete(this.key)), e && (this.updateChildrenChecked(a), this.updateParentChecked());
482
+ }
483
+ /** 更新子节点勾选状态 */
484
+ updateChildrenChecked(a) {
485
+ const e = (s) => {
486
+ s.children.forEach((r) => {
487
+ r.disabled || (r.checked = a, r.indeterminate = !1, a ? (this.store.checkedKeys.add(r.key), this.store.indeterminateKeys.delete(r.key)) : (this.store.checkedKeys.delete(r.key), this.store.indeterminateKeys.delete(r.key)), e(r));
488
+ });
489
+ };
490
+ e(this);
491
+ }
492
+ /** 更新父节点勾选状态 */
493
+ updateParentChecked() {
494
+ let a = this.parent;
495
+ for (; a; ) {
496
+ const e = a.children.filter((o) => !o.disabled);
497
+ if (e.length === 0) {
498
+ a = a.parent;
499
+ continue;
500
+ }
501
+ const s = e.every((o) => o.checked), r = e.some((o) => o.checked || o.indeterminate);
502
+ s ? (a.checked = !0, a.indeterminate = !1, this.store.checkedKeys.add(a.key), this.store.indeterminateKeys.delete(a.key)) : r ? (a.checked = !1, a.indeterminate = !0, this.store.checkedKeys.delete(a.key), this.store.indeterminateKeys.add(a.key)) : (a.checked = !1, a.indeterminate = !1, this.store.checkedKeys.delete(a.key), this.store.indeterminateKeys.delete(a.key)), a = a.parent;
503
+ }
504
+ }
505
+ /** 展开/收起 */
506
+ toggleExpand() {
507
+ this.setExpanded(!this.expanded);
508
+ }
509
+ /** 勾选/取消勾选 */
510
+ toggleCheck() {
511
+ this.setChecked(!this.checked);
512
+ }
513
+ /** 判断是否应该显示 */
514
+ get shouldShow() {
515
+ return !(!this.visible || this.parent && !this.parent.expanded);
516
+ }
517
+ /** 获取所有父节点的 key */
518
+ getParentKeys() {
519
+ const a = [];
520
+ let e = this.parent;
521
+ for (; e; )
522
+ a.push(e.key), e = e.parent;
523
+ return a;
524
+ }
525
+ /** 获取所有子节点的 key */
526
+ getChildrenKeys() {
527
+ const a = [], e = (s) => {
528
+ s.forEach((r) => {
529
+ a.push(r.key), r.children.length && e(r.children);
530
+ });
531
+ };
532
+ return e(this.children), a;
533
+ }
534
+ }
535
+ function ze(t, a) {
536
+ const e = ce({
537
+ nodesMap: /* @__PURE__ */ new Map(),
538
+ rootNodes: [],
539
+ expandedKeys: /* @__PURE__ */ new Set(),
540
+ checkedKeys: /* @__PURE__ */ new Set(),
541
+ selectedKeys: /* @__PURE__ */ new Set(),
542
+ indeterminateKeys: /* @__PURE__ */ new Set(),
543
+ currentKey: null,
544
+ filterValue: ""
545
+ });
546
+ e.props = t;
547
+ const s = G(""), r = (n) => {
548
+ if (e.nodesMap.clear(), e.rootNodes = [], !n || !n.length) return;
549
+ const h = (m, g, l) => {
550
+ var E;
551
+ const f = new F(m, e, g, l);
552
+ e.nodesMap.set(f.key, f);
553
+ const p = ((E = t.props) == null ? void 0 : E.children) || "children", w = m[p] ?? m.children ?? [];
554
+ return w.length > 0 && (f.children = w.map(
555
+ (ee) => h(ee, g + 1, f)
556
+ ), f.isLeaf = !1), f;
557
+ };
558
+ e.rootNodes = n.map((m) => h(m, 0, null)), o();
559
+ }, o = () => {
560
+ var n, h, m;
561
+ t.defaultExpandAll ? k() : (n = t.defaultExpandedKeys) != null && n.length && t.defaultExpandedKeys.forEach((g) => {
562
+ const l = e.nodesMap.get(g);
563
+ l && (l.expanded = !0, e.expandedKeys.add(g), t.autoExpandParent && i(l));
564
+ }), (h = t.defaultSelectedKeys) != null && h.length && t.defaultSelectedKeys.forEach((g) => {
565
+ const l = e.nodesMap.get(g);
566
+ l && (l.selected = !0, e.selectedKeys.add(g));
567
+ }), (m = t.defaultCheckedKeys) != null && m.length && t.defaultCheckedKeys.forEach((g) => {
568
+ const l = e.nodesMap.get(g);
569
+ l && l.setChecked(!0, !t.checkStrictly);
570
+ }), t.currentKey !== void 0 && (e.currentKey = t.currentKey);
571
+ }, i = (n) => {
572
+ let h = n.parent;
573
+ for (; h; )
574
+ h.expanded || (h.expanded = !0, e.expandedKeys.add(h.key)), h = h.parent;
575
+ }, k = () => {
576
+ e.nodesMap.forEach((n) => {
577
+ (n.children.length > 0 || t.lazy && !n.isLeaf) && (n.expanded = !0, e.expandedKeys.add(n.key));
578
+ });
579
+ }, b = () => {
580
+ e.nodesMap.forEach((n) => {
581
+ n.expanded = !1;
582
+ }), e.expandedKeys.clear();
583
+ }, z = (n) => {
584
+ var m;
585
+ if (n.disabled) return;
586
+ const h = !n.expanded;
587
+ if (t.accordion && h && (((m = n.parent) == null ? void 0 : m.children) || e.rootNodes).forEach((l) => {
588
+ l.key !== n.key && l.expanded && (l.expanded = !1, e.expandedKeys.delete(l.key), a("node-collapse", l.data, l, null));
589
+ }), t.lazy && t.load && !n.loaded && !n.loading && !n.isLeaf) {
590
+ n.loading = !0, t.load(n, (g) => {
591
+ n.loading = !1, n.loaded = !0, n.children = g.map((l) => {
592
+ const f = new F(l, e, n.level + 1, n);
593
+ return e.nodesMap.set(f.key, f), f;
594
+ }), n.isLeaf = n.children.length === 0, n.expanded = !0, e.expandedKeys.add(n.key), a("node-expand", n.data, n, null);
595
+ });
596
+ return;
597
+ }
598
+ h ? (n.expanded = !0, e.expandedKeys.add(n.key), a("node-expand", n.data, n, null)) : (n.expanded = !1, e.expandedKeys.delete(n.key), a("node-collapse", n.data, n, null));
599
+ }, M = (n, h) => {
600
+ if (n.disabled) return;
601
+ const m = h ?? !n.checked;
602
+ n.setChecked(m, !t.checkStrictly), a("check-change", n.data, n.checked, n.indeterminate);
603
+ const g = [], l = [], f = [], p = [];
604
+ e.nodesMap.forEach((w) => {
605
+ w.checked && (g.push(w.data), l.push(w.key)), w.indeterminate && (f.push(w.data), p.push(w.key));
606
+ }), a("check", n.data, {
607
+ checkedNodes: g,
608
+ checkedKeys: l,
609
+ halfCheckedNodes: f,
610
+ halfCheckedKeys: p
611
+ });
612
+ }, T = (n, h) => {
613
+ n.disabled || (a("node-click", n.data, n, null), t.expandOnClickNode && (n.children.length > 0 || t.lazy && !n.isLeaf) && z(n), t.checkOnClickNode && t.showCheckbox && M(n), t.highlightCurrent && (e.currentKey = n.key, a("current-change", n.data, n)), t.selectable && n.setSelected(!n.selected));
614
+ }, O = (n, h) => {
615
+ a("node-contextmenu", h, n.data, n);
616
+ }, x = (n) => {
617
+ if (s.value = n, e.filterValue = n, !n) {
618
+ e.nodesMap.forEach((m) => {
619
+ m.visible = !0;
620
+ });
621
+ return;
622
+ }
623
+ const h = t.filterNodeMethod || K;
624
+ e.nodesMap.forEach((m) => {
625
+ m.visible = h(n, m.data, m);
626
+ }), e.nodesMap.forEach((m) => {
627
+ m.visible && m.parent && S(m.parent);
628
+ });
629
+ }, K = (n, h, m) => {
630
+ var l;
631
+ const g = h.label || h[(l = t.props) == null ? void 0 : l.label] || "";
632
+ return String(g).toLowerCase().includes(n.toLowerCase());
633
+ }, S = (n) => {
634
+ n.visible = !0, n.expanded = !0, e.expandedKeys.add(n.key), n.parent && S(n.parent);
635
+ }, L = (n) => e.nodesMap.get(n), U = (n) => {
636
+ if (e.currentKey = n, n && t.highlightCurrent) {
637
+ const h = e.nodesMap.get(n);
638
+ h && a("current-change", h.data, h);
639
+ }
640
+ }, X = () => {
641
+ if (e.currentKey)
642
+ return e.nodesMap.get(e.currentKey);
643
+ }, V = (n = !1) => {
644
+ const h = [];
645
+ return e.nodesMap.forEach((m) => {
646
+ m.checked && (!n || m.isLeaf) && h.push(m.data);
647
+ }), h;
648
+ }, J = (n = !1) => {
649
+ const h = [];
650
+ return e.nodesMap.forEach((m) => {
651
+ m.checked && (!n || m.isLeaf) && h.push(m.key);
652
+ }), h;
653
+ }, N = (n) => {
654
+ e.nodesMap.forEach((h) => {
655
+ h.checked = !1, h.indeterminate = !1;
656
+ }), e.checkedKeys.clear(), e.indeterminateKeys.clear(), n.forEach((h) => {
657
+ const m = e.nodesMap.get(h);
658
+ m && m.setChecked(!0, !t.checkStrictly);
659
+ });
660
+ }, j = () => {
661
+ const n = [];
662
+ return e.nodesMap.forEach((h) => {
663
+ h.indeterminate && n.push(h.data);
664
+ }), n;
665
+ }, v = () => {
666
+ const n = [];
667
+ return e.nodesMap.forEach((h) => {
668
+ h.indeterminate && n.push(h.key);
669
+ }), n;
670
+ }, D = (n, h, m = !0) => {
671
+ const g = e.nodesMap.get(n);
672
+ g && g.setChecked(h, m && !t.checkStrictly);
673
+ }, A = () => {
674
+ const n = [];
675
+ return e.nodesMap.forEach((h) => {
676
+ h.selected && n.push(h.data);
677
+ }), n;
678
+ }, Q = (n) => {
679
+ e.nodesMap.forEach((h) => {
680
+ h.selected = !1;
681
+ }), e.selectedKeys.clear(), n.forEach((h) => {
682
+ const m = e.nodesMap.get(h);
683
+ m && (m.selected = !0, e.selectedKeys.add(h));
684
+ });
685
+ };
686
+ return ae("tree", {
687
+ props: t,
688
+ store: e,
689
+ emit: a,
690
+ toggleExpand: z,
691
+ toggleCheck: M,
692
+ handleNodeClick: T,
693
+ handleNodeContextmenu: O,
694
+ filterValue: ue(s)
695
+ }), W(
696
+ () => t.data,
697
+ (n) => {
698
+ r(n || []);
699
+ },
700
+ { immediate: !0, deep: !0 }
701
+ ), W(
702
+ () => t.expandedKeys,
703
+ (n) => {
704
+ n && (e.expandedKeys = new Set(n), e.nodesMap.forEach((h) => {
705
+ h.expanded = e.expandedKeys.has(h.key);
706
+ }));
707
+ },
708
+ { immediate: !0 }
709
+ ), W(
710
+ () => t.checkedKeys,
711
+ (n) => {
712
+ n && N(n);
713
+ },
714
+ { immediate: !0 }
715
+ ), W(
716
+ () => t.selectedKeys,
717
+ (n) => {
718
+ n && Q(n);
719
+ },
720
+ { immediate: !0 }
721
+ ), W(
722
+ () => t.currentKey,
723
+ (n) => {
724
+ n !== void 0 && (e.currentKey = n);
725
+ },
726
+ { immediate: !0 }
727
+ ), {
728
+ store: e,
729
+ filter: x,
730
+ getNode: L,
731
+ setCurrentKey: U,
732
+ getCurrentNode: X,
733
+ getCheckedNodes: V,
734
+ getCheckedKeys: J,
735
+ setCheckedKeys: N,
736
+ getHalfCheckedNodes: j,
737
+ getHalfCheckedKeys: v,
738
+ setChecked: D,
739
+ getSelectedNodes: A,
740
+ setSelectedKeys: Q,
741
+ expandAll: k,
742
+ collapseAll: b
743
+ };
744
+ }
745
+ const je = ["draggable"], Ee = {
746
+ key: 0,
747
+ class: "x-tree-node__loading-icon"
748
+ }, Te = {
749
+ key: 0,
750
+ class: "x-tree-node__expand-arrow"
751
+ }, Pe = {
752
+ key: 0,
753
+ class: "x-tree-node__icon"
754
+ }, Be = { class: "x-tree-node__label" }, Oe = /* @__PURE__ */ H({
755
+ name: "XTreeNode",
756
+ __name: "tree-node",
757
+ props: {
758
+ node: {}
759
+ },
760
+ setup(t) {
761
+ const a = t, e = se("tree"), { props: s, store: r, toggleExpand: o, toggleCheck: i, handleNodeClick: k, handleNodeContextmenu: b } = e, z = G(), M = G(null), T = I(() => a.node.expanded), O = I(() => a.node.checked), x = I(() => a.node.indeterminate), K = I(() => a.node.disabled), S = I(() => a.node.loading), L = I(() => a.node.isLeaf), U = I(() => r.currentKey === a.node.key), X = I(() => a.node.selected), V = I(() => ({
762
+ paddingLeft: `${a.node.level * (s.indent || 16)}px`
763
+ })), J = (g) => {
764
+ k(a.node, g);
765
+ }, N = (g) => {
766
+ b(a.node, g);
767
+ }, j = (g) => {
768
+ g.stopPropagation(), K.value || o(a.node);
769
+ }, v = (g) => {
770
+ g.stopPropagation(), K.value || i(a.node);
771
+ }, D = (g) => {
772
+ var l;
773
+ if (!(!s.draggable || K.value)) {
774
+ if (s.allowDrag && !s.allowDrag(a.node)) {
775
+ g.preventDefault();
776
+ return;
777
+ }
778
+ g.dataTransfer.effectAllowed = "move", g.dataTransfer.setData("nodeKey", String(a.node.key)), (l = e.emit) == null || l.call(e, "node-drag-start", a.node, g);
779
+ }
780
+ }, A = (g) => {
781
+ var l;
782
+ g.preventDefault(), s.draggable && (M.value = "inner", (l = e.emit) == null || l.call(e, "node-drag-enter", a.node, g));
783
+ }, Q = (g) => {
784
+ var l;
785
+ M.value = null, (l = e.emit) == null || l.call(e, "node-drag-leave", a.node, g);
786
+ }, n = (g) => {
787
+ var w, E;
788
+ if (g.preventDefault(), !s.draggable || K.value) return;
789
+ const l = (w = z.value) == null ? void 0 : w.getBoundingClientRect();
790
+ if (!l) return;
791
+ const f = g.clientY - l.top, p = l.height;
792
+ f < p * 0.25 ? M.value = "prev" : f > p * 0.75 ? M.value = "next" : M.value = "inner", (E = e.emit) == null || E.call(e, "node-drag-over", a.node, g);
793
+ }, h = (g) => {
794
+ var f, p;
795
+ if (g.preventDefault(), !s.draggable) return;
796
+ const l = (f = g.dataTransfer) == null ? void 0 : f.getData("nodeKey");
797
+ if (l) {
798
+ const w = r.nodesMap.get(l);
799
+ if (w && M.value) {
800
+ if (s.allowDrop && !s.allowDrop(w, a.node, M.value)) {
801
+ M.value = null;
802
+ return;
803
+ }
804
+ (p = e.emit) == null || p.call(e, "node-drop", w, a.node, M.value, g);
805
+ }
806
+ }
807
+ M.value = null;
808
+ }, m = (g) => {
809
+ var l;
810
+ M.value = null, (l = e.emit) == null || l.call(e, "node-drag-end", a.node, g);
811
+ };
812
+ return (g, l) => {
813
+ var p;
814
+ const f = he("TreeNode", !0);
815
+ return fe((c(), y("div", {
816
+ ref_key: "nodeRef",
817
+ ref: z,
818
+ class: u(["x-tree-node", {
819
+ "is-expanded": T.value,
820
+ "is-current": U.value,
821
+ "is-selected": X.value,
822
+ "is-disabled": K.value,
823
+ "is-drop-inner": M.value === "inner",
824
+ "is-drop-prev": M.value === "prev",
825
+ "is-drop-next": M.value === "next"
826
+ }]),
827
+ draggable: d(s).draggable && !K.value,
828
+ onDragstart: D,
829
+ onDragenter: A,
830
+ onDragleave: Q,
831
+ onDragover: n,
832
+ onDrop: h,
833
+ onDragend: m
834
+ }, [
835
+ C("div", {
836
+ class: "x-tree-node__content",
837
+ style: R(V.value),
838
+ onClick: J,
839
+ onContextmenu: N
840
+ }, [
841
+ C("span", {
842
+ class: u(["x-tree-node__expand-icon", {
843
+ "is-expanded": T.value,
844
+ "is-leaf": L.value,
845
+ "is-loading": S.value
846
+ }]),
847
+ onClick: j
848
+ }, [
849
+ S.value ? (c(), y("span", Ee, "⏳")) : (c(), y(Z, { key: 1 }, [
850
+ L.value ? $("", !0) : (c(), y("span", Te, "▶"))
851
+ ], 64))
852
+ ], 2),
853
+ t.node.icon || d(s).icon ? (c(), y("span", Pe, B(t.node.icon || d(s).icon), 1)) : $("", !0),
854
+ d(s).showCheckbox ? (c(), y("span", {
855
+ key: 1,
856
+ class: u(["x-tree-node__checkbox", {
857
+ "is-checked": O.value,
858
+ "is-indeterminate": x.value,
859
+ "is-disabled": K.value
860
+ }]),
861
+ onClick: te(v, ["stop"])
862
+ }, [...l[0] || (l[0] = [
863
+ C("span", { class: "x-tree-node__checkbox-inner" }, null, -1)
864
+ ])], 2)) : $("", !0),
865
+ C("span", Be, [
866
+ P(g.$slots, "default", {
867
+ node: t.node,
868
+ data: t.node.data
869
+ }, () => [
870
+ _(B(t.node.label), 1)
871
+ ])
872
+ ])
873
+ ], 36),
874
+ !L.value && T.value ? (c(), y("div", {
875
+ key: 0,
876
+ class: u(["x-tree-node__children", { "x-tree-node__children--show-line": d(s).showLine }])
877
+ }, [
878
+ !d(s).renderAfterExpand || T.value ? (c(!0), y(Z, { key: 0 }, q(t.node.children, (w) => (c(), le(f, {
879
+ key: w.key,
880
+ node: w
881
+ }, {
882
+ default: oe((E) => [
883
+ P(g.$slots, "default", {
884
+ node: E.node,
885
+ data: E.data
886
+ })
887
+ ]),
888
+ _: 3
889
+ }, 8, ["node"]))), 128)) : $("", !0)
890
+ ], 2)) : $("", !0)
891
+ ], 42, je)), [
892
+ [ye, t.node.visible && (((p = t.node.parent) == null ? void 0 : p.expanded) ?? !0)]
893
+ ]);
894
+ };
895
+ }
896
+ }), Je = /* @__PURE__ */ H({
897
+ name: "XTree",
898
+ __name: "index",
899
+ props: {
900
+ data: { default: () => [] },
901
+ emptyText: { default: "暂无数据" },
902
+ nodeKey: { default: "value" },
903
+ props: { default: () => ({}) },
904
+ renderAfterExpand: { type: Boolean, default: !0 },
905
+ load: {},
906
+ renderContent: {},
907
+ highlightCurrent: { type: Boolean, default: !1 },
908
+ checkOnClickNode: { type: Boolean, default: !1 },
909
+ autoExpandParent: { type: Boolean, default: !0 },
910
+ defaultExpandedKeys: { default: () => [] },
911
+ defaultCheckedKeys: { default: () => [] },
912
+ defaultSelectedKeys: { default: () => [] },
913
+ expandedKeys: {},
914
+ checkedKeys: {},
915
+ selectedKeys: {},
916
+ checkStrictly: { type: Boolean, default: !1 },
917
+ lazy: { type: Boolean, default: !1 },
918
+ draggable: { type: Boolean, default: !1 },
919
+ allowDrag: {},
920
+ allowDrop: {},
921
+ accordion: { type: Boolean, default: !1 },
922
+ indent: { default: 16 },
923
+ icon: {},
924
+ expandOnClickNode: { type: Boolean, default: !0 },
925
+ checkDescendants: { type: Boolean, default: !1 },
926
+ currentKey: {},
927
+ showLine: { type: Boolean, default: !1 },
928
+ showCheckbox: { type: Boolean, default: !1 },
929
+ selectable: { type: Boolean, default: !1 },
930
+ size: { default: "default" }
931
+ },
932
+ emits: ["node-click", "node-contextmenu", "check-change", "check", "current-change", "node-expand", "node-collapse", "node-drag-start", "node-drag-enter", "node-drag-leave", "node-drag-over", "node-drag-end", "node-drop"],
933
+ setup(t, { expose: a, emit: e }) {
934
+ const s = t, r = e, o = Y("tree"), {
935
+ store: i,
936
+ filter: k,
937
+ getNode: b,
938
+ setCurrentKey: z,
939
+ getCurrentNode: M,
940
+ getCheckedNodes: T,
941
+ getCheckedKeys: O,
942
+ setCheckedKeys: x,
943
+ getHalfCheckedNodes: K,
944
+ getHalfCheckedKeys: S,
945
+ setChecked: L,
946
+ getSelectedNodes: U,
947
+ setSelectedKeys: X,
948
+ expandAll: V,
949
+ collapseAll: J
950
+ } = ze(s, r);
951
+ return a({
952
+ filter: k,
953
+ getNode: b,
954
+ setCurrentKey: z,
955
+ getCurrentKey: () => i.currentKey,
956
+ getCurrentNode: M,
957
+ getCheckedNodes: T,
958
+ getCheckedKeys: O,
959
+ setCheckedKeys: x,
960
+ getHalfCheckedNodes: K,
961
+ getHalfCheckedKeys: S,
962
+ setChecked: L,
963
+ getSelectedNodes: U,
964
+ setSelectedKeys: X,
965
+ expandAll: V,
966
+ collapseAll: J,
967
+ // 额外方法
968
+ updateKeyChildren: (N, j) => {
969
+ const v = i.nodesMap.get(N);
970
+ v && (v.children.forEach((D) => {
971
+ i.nodesMap.delete(D.key);
972
+ }), v.children = j.map((D) => {
973
+ const A = new F(D, i, v.level + 1, v);
974
+ return i.nodesMap.set(A.key, A), A;
975
+ }), v.isLeaf = v.children.length === 0);
976
+ },
977
+ remove: (N) => {
978
+ const j = i.nodesMap.get(N);
979
+ if (j) {
980
+ const v = j.parent;
981
+ if (v) {
982
+ const A = v.children.indexOf(j);
983
+ A > -1 && v.children.splice(A, 1), v.children.length === 0 && (v.isLeaf = !0);
984
+ } else {
985
+ const A = i.rootNodes.indexOf(j);
986
+ A > -1 && i.rootNodes.splice(A, 1);
987
+ }
988
+ const D = (A) => {
989
+ i.nodesMap.delete(A.key), A.children.forEach(D);
990
+ };
991
+ D(j);
992
+ }
993
+ },
994
+ append: (N, j) => {
995
+ if (j) {
996
+ const v = i.nodesMap.get(j);
997
+ if (v) {
998
+ const D = new F(N, i, v.level + 1, v);
999
+ i.nodesMap.set(D.key, D), v.children.push(D), v.isLeaf = !1;
1000
+ }
1001
+ } else {
1002
+ const v = new F(N, i, 0, null);
1003
+ i.nodesMap.set(v.key, v), i.rootNodes.push(v);
1004
+ }
1005
+ },
1006
+ insertBefore: (N, j) => {
1007
+ var D;
1008
+ const v = i.nodesMap.get(j);
1009
+ if (v) {
1010
+ const A = new F(N, i, v.level, v.parent);
1011
+ i.nodesMap.set(A.key, A);
1012
+ const Q = ((D = v.parent) == null ? void 0 : D.children) || i.rootNodes, n = Q.indexOf(v);
1013
+ Q.splice(n, 0, A);
1014
+ }
1015
+ },
1016
+ insertAfter: (N, j) => {
1017
+ var D;
1018
+ const v = i.nodesMap.get(j);
1019
+ if (v) {
1020
+ const A = new F(N, i, v.level, v.parent);
1021
+ i.nodesMap.set(A.key, A);
1022
+ const Q = ((D = v.parent) == null ? void 0 : D.children) || i.rootNodes, n = Q.indexOf(v);
1023
+ Q.splice(n + 1, 0, A);
1024
+ }
1025
+ }
1026
+ }), (N, j) => (c(), y("div", {
1027
+ class: u([d(o).b(), d(o).m(t.size)])
1028
+ }, [
1029
+ (c(!0), y(Z, null, q(d(i).rootNodes, (v) => (c(), le(Oe, {
1030
+ key: v.key,
1031
+ node: v
1032
+ }, {
1033
+ default: oe((D) => [
1034
+ P(N.$slots, "default", {
1035
+ node: D.node,
1036
+ data: D.data
1037
+ }, () => [
1038
+ _(B(D.node.label), 1)
1039
+ ])
1040
+ ]),
1041
+ _: 2
1042
+ }, 1032, ["node"]))), 128)),
1043
+ d(i).rootNodes.length ? $("", !0) : (c(), y("div", {
1044
+ key: 0,
1045
+ class: u(d(o).e("empty"))
1046
+ }, [
1047
+ P(N.$slots, "empty", {}, () => [
1048
+ _(B(t.emptyText), 1)
1049
+ ])
1050
+ ], 2))
1051
+ ], 2));
1052
+ }
1053
+ }), Re = ["src"], Ge = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTg0IiBoZWlnaHQ9IjE1MiIgdmlld0JveD0iMCAwIDE4NCAxNTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDI0IDMxLjY3KSI+CiAgICAgIDxlbGxpcHNlIGZpbGwtb3BhY2l0eT0iLjgiIGZpbGw9IiNGNUY1RjciIGN4PSI2Ny43OTciIGN5PSIxMDYuODkiIHJ4PSI2Ny43OTciIHJ5PSIxMi42NjgiLz4KICAgICAgPHBhdGggZD0iTTEyMi4wMzQgNjkuNjc0TDk5LjM5NCA0OC4xNjJsMCAyMS41MTYgMjIuNjQgMjIuNjQ0IDAtMjIuNjQ0em0tMjIuNjQgMjIuNjQ0TDc2Ljk5OCA3MC43OThsMCAyMS41MTYgMjIuMzk2IDIyLjM5NiAwLTIyLjM5NnoiIGZpbGw9IiNFRkVGRkYiLz4KICAgICAgPHBhdGggZD0iTTk5LjM5NCA0OC4xNjJsLTIyLjM5NiAyMi42MzYgMjIuMzk2IDIxLjUyIDAtNDQuMTU2eiIgZmlsbD0iI0YyRjZGQyIvPgogICAgICA8cGF0aCBkPSJNMTIxLjk3OCA2OS42NzRMOTkuMzk0IDkyLjI1OGwzLjE2OCAzLjE2OCAyMi41ODQtMjIuNTg0LTMuMTY4LTMuMTY4eiIgZmlsbD0iI0M3Q0NEQyIvPgogICAgICA8cGF0aCBkPSJNOTkuMzk0IDkyLjI1OEw3Ni44MSA2OS42NzRsMy4xNjgtMy4xNjggMjIuNTg0IDIyLjU4NC0zLjE2OCAzLjE2OHoiIGZpbGw9IiNDN0NEREMiLz4KICAgIDwvZz4KICAgIDxwYXRoIGQ9Ik0xNDcuODU3IDMxLjY3bC0zLjI5Mi0zLjI5MmEyLjUgMi41IDAgMCAwLTMuNTM2IDBsLTEzLjQ2IDEzLjQ2YTMuNSAzLjUgMCAwIDAgMCA0Ljk1bDMuMjkzIDMuMjkyYTMuNSAzLjUgMCAwIDAgNC45NSAwbDEzLjQ2LTEzLjQ2YTIuNSAyLjUgMCAwIDAgMC0zLjUzNnoiIGZpbGw9IiNENkRCRUMiLz4KICAgIDxwYXRoIGQ9Ik0zNi4xNDMgMzEuNjdsMy4yOTItMy4yOTJhMi41IDIuNSAwIDAgMSAzLjUzNiAwbDEzLjQ2IDEzLjQ2YTMuNSAzLjUgMCAwIDEgMCA0Ljk1bC0zLjI5MyAzLjI5MmEzLjUgMy41IDAgMCAxLTQuOTUgMEwzNi4xNDMgMzUuMmEyLjUgMi41IDAgMCAxIDAtMy41MzZ6IiBmaWxsPSIjRDZEQkVDIi8+CiAgICA8Y2lyY2xlIGZpbGw9IiNFQUVFRjQiIGN4PSI5MiIgY3k9IjgiIHI9IjgiLz4KICA8L2c+Cjwvc3ZnPg==", Fe = /* @__PURE__ */ H({
1054
+ name: "XEmpty",
1055
+ __name: "index",
1056
+ props: {
1057
+ image: { default: "" },
1058
+ imageSize: { default: 0 },
1059
+ description: { default: "" },
1060
+ size: { default: "default" }
1061
+ },
1062
+ setup(t) {
1063
+ const a = t, e = Y("empty"), s = I(() => {
1064
+ const o = {};
1065
+ return a.imageSize && (o.height = `${a.imageSize}px`, o.width = `${a.imageSize}px`), o;
1066
+ }), r = I(() => a.description || "暂无数据");
1067
+ return (o, i) => (c(), y("div", {
1068
+ class: u([d(e).b(), d(e).m(t.size)])
1069
+ }, [
1070
+ C("div", {
1071
+ class: u(d(e).e("image")),
1072
+ style: R(s.value)
1073
+ }, [
1074
+ P(o.$slots, "image", {}, () => [
1075
+ t.image ? (c(), y("img", {
1076
+ key: 0,
1077
+ src: t.image,
1078
+ style: R(s.value),
1079
+ draggable: "false"
1080
+ }, null, 12, Re)) : (c(), y("img", {
1081
+ key: 1,
1082
+ src: Ge,
1083
+ style: R(s.value),
1084
+ draggable: "false"
1085
+ }, null, 4))
1086
+ ])
1087
+ ], 6),
1088
+ C("div", {
1089
+ class: u(d(e).e("description"))
1090
+ }, [
1091
+ P(o.$slots, "description", {}, () => [
1092
+ C("p", null, B(r.value), 1)
1093
+ ])
1094
+ ], 2),
1095
+ o.$slots.default ? (c(), y("div", {
1096
+ key: 0,
1097
+ class: u(d(e).e("bottom"))
1098
+ }, [
1099
+ P(o.$slots, "default")
1100
+ ], 2)) : $("", !0)
1101
+ ], 2));
1102
+ }
1103
+ }), qe = /* @__PURE__ */ H({
1104
+ name: "XTimeline",
1105
+ __name: "index",
1106
+ props: {
1107
+ direction: { default: "vertical" }
1108
+ },
1109
+ setup(t) {
1110
+ const a = t, e = Y("timeline");
1111
+ ae("timeline", {
1112
+ props: a
1113
+ });
1114
+ const s = I(() => [
1115
+ e.b(),
1116
+ e.m(a.direction)
1117
+ ]);
1118
+ return (r, o) => (c(), y("ul", {
1119
+ class: u(s.value),
1120
+ role: "timeline"
1121
+ }, [
1122
+ P(r.$slots, "default")
1123
+ ], 2));
1124
+ }
1125
+ }), _e = /* @__PURE__ */ H({
1126
+ name: "XTimelineItem",
1127
+ __name: "TimelineItem",
1128
+ props: {
1129
+ timestamp: { default: "" },
1130
+ type: { default: "primary" },
1131
+ color: {},
1132
+ size: { default: "normal" },
1133
+ hideTimestamp: { type: Boolean, default: !1 },
1134
+ placement: { default: "bottom" }
1135
+ },
1136
+ setup(t) {
1137
+ const a = t, e = Y("timeline-item"), s = {
1138
+ primary: "#409eff",
1139
+ success: "#67c23a",
1140
+ warning: "#e6a23c",
1141
+ danger: "#f56c6c",
1142
+ info: "#909399"
1143
+ }, r = I(() => {
1144
+ const i = {};
1145
+ return a.color ? i.backgroundColor = a.color : a.type && s[a.type] && (i.backgroundColor = s[a.type]), i;
1146
+ }), o = I(() => [
1147
+ e.b(),
1148
+ e.m(a.size)
1149
+ ]);
1150
+ return (i, k) => (c(), y("li", {
1151
+ class: u(o.value)
1152
+ }, [
1153
+ C("div", {
1154
+ class: u(d(e).e("node")),
1155
+ style: R(r.value)
1156
+ }, [
1157
+ P(i.$slots, "dot")
1158
+ ], 6),
1159
+ C("div", {
1160
+ class: u(d(e).e("tail"))
1161
+ }, null, 2),
1162
+ C("div", {
1163
+ class: u(d(e).e("wrapper"))
1164
+ }, [
1165
+ !t.hideTimestamp && t.timestamp && t.placement === "top" ? (c(), y("div", {
1166
+ key: 0,
1167
+ class: u(d(e).e("timestamp"))
1168
+ }, B(t.timestamp), 3)) : $("", !0),
1169
+ C("div", {
1170
+ class: u(d(e).e("content"))
1171
+ }, [
1172
+ P(i.$slots, "default")
1173
+ ], 2),
1174
+ !t.hideTimestamp && t.timestamp && t.placement === "bottom" ? (c(), y("div", {
1175
+ key: 1,
1176
+ class: u(d(e).e("timestamp"))
1177
+ }, B(t.timestamp), 3)) : $("", !0)
1178
+ ], 2)
1179
+ ], 2));
1180
+ }
1181
+ }), He = ["onMouseenter", "onClick"], et = /* @__PURE__ */ H({
1182
+ name: "XCarousel",
1183
+ __name: "index",
1184
+ props: {
1185
+ activeIndex: { default: 0 },
1186
+ autoplay: { type: Boolean, default: !0 },
1187
+ interval: { default: 3e3 },
1188
+ indicatorPosition: { default: "inside" },
1189
+ trigger: { default: "hover" },
1190
+ arrow: { default: "hover" },
1191
+ loop: { type: Boolean, default: !0 },
1192
+ height: { default: 300 }
1193
+ },
1194
+ emits: ["update:activeIndex", "change"],
1195
+ setup(t, { expose: a, emit: e }) {
1196
+ const s = t, r = e, o = Y("carousel"), i = G(s.activeIndex), k = G(0), b = G(null), z = G(!1);
1197
+ ae("carousel", {
1198
+ currentIndex: i,
1199
+ itemCount: k
1200
+ });
1201
+ const M = (N) => {
1202
+ const j = i.value;
1203
+ s.loop ? i.value = (N + k.value) % k.value : i.value = Math.max(0, Math.min(N, k.value - 1)), r("update:activeIndex", i.value), r("change", i.value, j);
1204
+ }, T = () => {
1205
+ M(i.value - 1);
1206
+ }, O = () => {
1207
+ M(i.value + 1);
1208
+ }, x = () => {
1209
+ s.autoplay && k.value > 1 && (K(), b.value = setInterval(() => {
1210
+ z.value || O();
1211
+ }, s.interval));
1212
+ }, K = () => {
1213
+ b.value && (clearInterval(b.value), b.value = null);
1214
+ }, S = () => {
1215
+ z.value = !0, s.arrow;
1216
+ }, L = () => {
1217
+ z.value = !1;
1218
+ }, U = (N) => {
1219
+ s.trigger === "hover" && M(N);
1220
+ }, X = (N) => {
1221
+ s.trigger === "click" && M(N);
1222
+ }, V = I(() => ({
1223
+ height: typeof s.height == "number" ? `${s.height}px` : s.height
1224
+ })), J = I(() => [
1225
+ o.b(),
1226
+ o.m(`arrow-${s.arrow}`),
1227
+ o.m(`indicator-${s.indicatorPosition}`)
1228
+ ]);
1229
+ return W(() => s.activeIndex, (N) => {
1230
+ i.value = N;
1231
+ }), W(() => s.autoplay, () => {
1232
+ x();
1233
+ }), W(k, () => {
1234
+ ge(() => {
1235
+ x();
1236
+ });
1237
+ }), ie(() => {
1238
+ x();
1239
+ }), de(() => {
1240
+ K();
1241
+ }), a({
1242
+ prev: T,
1243
+ next: O,
1244
+ setActiveItem: M
1245
+ }), (N, j) => (c(), y("div", {
1246
+ class: u(J.value),
1247
+ style: R(V.value),
1248
+ onMouseenter: S,
1249
+ onMouseleave: L
1250
+ }, [
1251
+ C("div", {
1252
+ class: u(d(o).e("container"))
1253
+ }, [
1254
+ P(N.$slots, "default")
1255
+ ], 2),
1256
+ t.arrow !== "never" ? (c(), y("button", {
1257
+ key: 0,
1258
+ class: u([d(o).e("arrow"), d(o).e("arrow-left")]),
1259
+ onClick: T
1260
+ }, " ‹ ", 2)) : $("", !0),
1261
+ t.arrow !== "never" ? (c(), y("button", {
1262
+ key: 1,
1263
+ class: u([d(o).e("arrow"), d(o).e("arrow-right")]),
1264
+ onClick: O
1265
+ }, " › ", 2)) : $("", !0),
1266
+ t.indicatorPosition !== "none" ? (c(), y("ul", {
1267
+ key: 2,
1268
+ class: u(d(o).e("indicators"))
1269
+ }, [
1270
+ (c(!0), y(Z, null, q(k.value, (v) => (c(), y("li", {
1271
+ key: v,
1272
+ class: u([d(o).e("indicator"), d(o).is("active", v - 1 === i.value)]),
1273
+ onMouseenter: (D) => U(v - 1),
1274
+ onClick: (D) => X(v - 1)
1275
+ }, [
1276
+ C("button", {
1277
+ class: u(d(o).e("indicator-btn"))
1278
+ }, null, 2)
1279
+ ], 42, He))), 128))
1280
+ ], 2)) : $("", !0)
1281
+ ], 38));
1282
+ }
1283
+ }), tt = /* @__PURE__ */ H({
1284
+ name: "XCarouselItem",
1285
+ __name: "CarouselItem",
1286
+ setup(t) {
1287
+ const a = Y("carousel-item"), e = se("carousel"), s = G(-1);
1288
+ ie(() => {
1289
+ e && (s.value = e.itemCount.value, e.itemCount.value++);
1290
+ }), de(() => {
1291
+ e && e.itemCount.value--;
1292
+ });
1293
+ const r = I(() => e && s.value === e.currentIndex.value), o = I(() => [
1294
+ a.b(),
1295
+ a.is("active", r.value)
1296
+ ]);
1297
+ return (i, k) => (c(), y("div", {
1298
+ class: u(o.value)
1299
+ }, [
1300
+ P(i.$slots, "default")
1301
+ ], 2));
1302
+ }
1303
+ });
1304
+ export {
1305
+ Ze as Card,
1306
+ et as Carousel,
1307
+ tt as CarouselItem,
1308
+ Ve as DynamicTable,
1309
+ Fe as Empty,
1310
+ Xe as Pagination,
1311
+ Ue as Progress,
1312
+ We as Tag,
1313
+ qe as Timeline,
1314
+ _e as TimelineItem,
1315
+ Je as Tree,
1316
+ F as TreeNode
1317
+ };