@pantograph/vue 0.30.7 → 0.30.8

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.
@@ -1,740 +0,0 @@
1
- import { defineComponent as ke, useAttrs as Xe, useSlots as Re, computed as m, createBlock as Ve, openBlock as Ie, h as R, unref as ae, createElementBlock as Ye, Fragment as Ze, createVNode as et, createElementVNode as tt, normalizeClass as rt, ref as ne, watch as pe, nextTick as at, onMounted as lt, onBeforeUnmount as nt, shallowRef as ot, render as st } from "vue";
2
- import { getComponentOptions as Ae, generateVariantClassList as J, getBemElement as M, normCls as Le, sortPlaceholderVariantsClass as it, getBemBlock as ct, createOptionGetterFunc as D, getBemModifier as dt, usePCId as ut, sortPlaceholderCls as gt, getComponentName as Ee } from "@pantograph/utils";
3
- import { createContext as pt, RovingFocusItem as ft, RovingFocusGroup as ht } from "reka-ui";
4
- import { cva as Oe } from "class-variance-authority";
5
- import { isString as yt, uniq as _e, flattenDeep as mt, last as fe, cloneDeep as $e, isEqual as Ke, omit as vt, isFunction as Ne } from "es-toolkit";
6
- import bt from "@pantograph/sortable";
7
- import { isEmptyElement as Fe, useFormInput as _t, useVirtualScroll as kt, installComponent as De } from "@pantograph/utils-vue";
8
- import { _ as Me } from "./IndentLevel.vue_vue_type_style_index_0_lang-CkvTqlkt.js";
9
- import { _ as It } from "./Icon.vue_vue_type_style_index_0_lang-CD9EvvB5.js";
10
- import { _ as St } from "./Checkbox.vue_vue_type_style_index_0_lang-D-7D_c_A.js";
11
- import { useConfig as xt } from "./ConfigProvider/index.js";
12
- import { _ as Ct } from "./ScrollContainer.vue_vue_type_style_index_0_lang-CRjnv1ii.js";
13
- import { i as Bt } from "./isArray-QlWcxgml.js";
14
- import "./IndentLevel/index.js";
15
- import { a as Pe } from "./index-D2tZoezA.js";
16
- const wt = ["sm", "md", "lg"], ze = { none: "gap-none", sm: "gap-sm", md: "gap-md", lg: "gap-lg" }, [Tt, Kt] = pt("Tree"), Ge = /* @__PURE__ */ ke({
17
- ...Ae("TreeNode"),
18
- __name: "TreeNode",
19
- props: {
20
- node: {}
21
- },
22
- setup(V) {
23
- const i = V, G = Xe(), e = Re(), r = Tt(), P = Oe(r.prefixes.node, {
24
- variants: {
25
- disabled: J("disabled", r.prefixes.node),
26
- active: J("active", r.prefixes.node)
27
- }
28
- }), v = (n) => r.getNodeChildren(n, !0, !1), T = m(() => v(i.node)), j = m(() => r.props.draggable ? i.node._draggable ?? !0 : !1), f = m(() => !!(r.disabled.value || i.node._disabled)), x = m(() => i.node._dragging ?? !1), k = m(
29
- () => !x.value && r.expandedKeys.value.includes(i.node._key)
30
- ), C = m(() => !x.value && !r.dragging.value && r.props.showLine ? U.value ? "all" : "before" : !1), Q = m(() => r.getIsSelected(i.node)), L = m(() => r.getIsChecked(i.node)), B = (n) => r.onCheck(i.node, !!n), I = m(() => r.getLevel(i.node)), U = m(
31
- () => {
32
- var n, d;
33
- return !!((n = T.value) != null && n.length || (d = r.props) != null && d.lazyLoad && !i.node._leaf);
34
- }
35
- ), X = m(() => ({
36
- ...i.node,
37
- selected: Q.value,
38
- checked: L.value,
39
- disabled: f.value,
40
- expanded: k.value,
41
- unFocusable: !0
42
- })), a = () => {
43
- f.value || r.onSelect(i.node, !Q.value);
44
- }, c = () => {
45
- const n = () => {
46
- var K, y, Y, A, E, N, q, S;
47
- const d = [];
48
- if ((K = r.props) != null && K.draggable) {
49
- let b = null;
50
- r.dragging.value || (b = R(It, {
51
- icon: "tabler:grip-vertical",
52
- size: r.iconSize.value,
53
- class: r.prefixes.draggableIcon
54
- })), d.push(R("span", { class: r.prefixes.draggable }, b));
55
- }
56
- d.push(
57
- R(
58
- Me,
59
- {
60
- level: I.value,
61
- children: U.value,
62
- size: r.indentSize.value,
63
- expanded: k.value,
64
- showLine: C.value,
65
- dir: r.props.dir,
66
- class: M(r.prefixes.node, "indent"),
67
- loading: i.node._loading,
68
- "branch-icon": i.node._switcherIcon ?? ((y = r.props) == null ? void 0 : y.switcherIcon),
69
- "no-rotate-branch": i.node._noRotateSwitcherIcon ?? ((Y = r.props) == null ? void 0 : Y.noRotateSwitcherIcon),
70
- onToggleExpand: (b) => {
71
- b.stopPropagation(), r.onExpandKey(i.node);
72
- }
73
- },
74
- () => {
75
- var b;
76
- return [(b = e.switcherIcon) == null ? void 0 : b.call(e, X.value)];
77
- }
78
- )
79
- ), (A = r.props) != null && A.checkable && d.push(
80
- R(St, {
81
- unExtendParent: !0,
82
- size: r.iconSize.value,
83
- modelValue: L.value,
84
- "onUpdate:modelValue": B,
85
- disabled: f.value,
86
- onClick: (b) => b.stopPropagation()
87
- })
88
- );
89
- const h = (E = e.default) == null ? void 0 : E.call(e, X.value);
90
- return Fe(h) ? d.push(
91
- R("div", { class: M(r.prefixes.node, "title") }, i.node._title)
92
- ) : d.push(h), R(
93
- "div",
94
- {
95
- ...G,
96
- "data-key": (N = r.props) != null && N.draggable ? i.node._key : void 0,
97
- "data-level": (q = r.props) != null && q.draggable ? I.value : void 0,
98
- "data-draggable": (S = r.props) != null && S.draggable ? !f.value && j.value : void 0,
99
- class: Le(
100
- P({
101
- disabled: f.value,
102
- active: Q.value
103
- }),
104
- i.node.class ?? ""
105
- ),
106
- onClick: a
107
- },
108
- d
109
- );
110
- };
111
- return r.props.focusable ? R(
112
- ft,
113
- {
114
- asChild: !0,
115
- tabStopId: i.node._key
116
- },
117
- n
118
- ) : n();
119
- };
120
- return (n, d) => (Ie(), Ve(c));
121
- }
122
- }), oe = (V) => yt(V);
123
- function Nt({
124
- getValue: V,
125
- getDisabled: i,
126
- arr: G,
127
- getChildren: e,
128
- getExtra: r,
129
- allowNoValidKey: P
130
- }) {
131
- const v = [], T = (j, f) => {
132
- j.forEach((x) => {
133
- const k = e(x, f), C = V(x, f, k);
134
- if (oe(C) || P != null && P(x, f, k))
135
- v.push({
136
- ...typeof x == "object" ? x : { _item: x },
137
- _parentKeys: f,
138
- _key: C,
139
- _disabled: !!i(x),
140
- _hasChildren: !!(k != null && k.length),
141
- ...(r == null ? void 0 : r(x)) ?? {}
142
- }), k != null && k.length && T(k, [...f ?? [], C]);
143
- else
144
- throw "every node must provide a valid key";
145
- });
146
- };
147
- return T(G), v;
148
- }
149
- const Pt = ({
150
- getData: V,
151
- getExpandedKeys: i,
152
- getValue: G,
153
- getDisabled: e,
154
- getChildren: r,
155
- isFlatten: P,
156
- getExtra: v
157
- }) => {
158
- const T = m(
159
- () => P ? ae(V()) : Nt({
160
- arr: ae(V()),
161
- getChildren: r,
162
- getValue: G,
163
- getDisabled: e,
164
- getExtra: v
165
- })
166
- ), j = m(() => {
167
- const a = ae(i());
168
- return T.value.filter(
169
- (c) => {
170
- var n, d;
171
- return !c._parentKeys || ((d = (n = c._parentKeys) == null ? void 0 : n.every) == null ? void 0 : d.call(n, (h) => a.includes(h)));
172
- }
173
- );
174
- }), f = (a, c = !1, n = !0) => {
175
- const d = a == null ? void 0 : a._key;
176
- return !oe(d) || !a ? [] : T.value.filter((h) => {
177
- var K;
178
- if (c) {
179
- const y = fe(h._parentKeys ?? []);
180
- return y && y === d;
181
- }
182
- return (K = h._parentKeys) == null ? void 0 : K.includes(d);
183
- }).filter((h) => h && (!n || !(h != null && h._disabled)));
184
- }, x = () => T.value.filter((a) => !a._parentKeys), k = (a) => a ? f(a, !0, !1) : x(), C = (a) => oe(a) ? T.value.find((c) => c._key === a) : void 0, Q = (a) => {
185
- const c = C(fe(a._parentKeys ?? []));
186
- return k(c).findIndex((n) => n._key === a._key);
187
- }, L = (a) => {
188
- const c = ae(a);
189
- return c && Bt(c) ? $e(c) : [];
190
- }, B = (a, c) => {
191
- const n = f(a);
192
- if (n != null && n.length)
193
- return n.some((d) => U(d, c, !1) === !0);
194
- }, I = (a, c) => {
195
- const n = f(a);
196
- return n != null && n.length ? n.every((d) => U(d, c, !1) === !0) : !1;
197
- }, U = (a, c, n = !1) => {
198
- const d = L(c), h = a == null ? void 0 : a._key;
199
- if (!n && !a._disabled && !d.includes(h)) {
200
- const K = f(a);
201
- if (K != null && K.length)
202
- return I(a, c) ? !0 : B(a, c) ? "indeterminate" : !1;
203
- }
204
- return d.includes(h);
205
- };
206
- return {
207
- flattenData: T,
208
- visibleFlattenData: j,
209
- getNodeChildren: f,
210
- getNodeByValue: C,
211
- getNodeIndexInScope: Q,
212
- getChildrenOrRootNodes: k,
213
- isSomeChildrenSelected: B,
214
- isAllChildrenSelected: I,
215
- isSelected: U,
216
- getRootNodes: x,
217
- selectValue: (a, c, n, d, h, K) => {
218
- let y = L(n);
219
- if (oe(a._key) && !a._disabled)
220
- if (h) {
221
- if (c ? y.push(a._key) : y = y.filter((Y) => a._key !== Y), !d) {
222
- const A = f(a).map((g) => g._key), E = y.map(C).filter((g) => g && g._parentKeys);
223
- c || E.push(a);
224
- const q = _e(
225
- mt(E.map((g) => g._parentKeys))
226
- ).filter((g) => oe(g) && g !== a._key).filter(oe).map(C).filter(Boolean), S = [], b = [];
227
- q.forEach((g) => {
228
- const ce = g == null ? void 0 : g._key;
229
- I(g, y) ? S.push(ce) : b.push(ce);
230
- }), c ? S.push(...A) : b.push(...A), y.push(...S), y = y.filter((g) => !b.includes(g));
231
- }
232
- } else K === "replace" ? c && (y = [a._key]) : c ? y = [a._key] : y = [];
233
- return _e(y);
234
- }
235
- };
236
- }, zt = /* @__PURE__ */ ke({
237
- __name: "TreePlaceholder",
238
- props: {
239
- level: {},
240
- size: {},
241
- indentSize: {},
242
- branchIcon: {},
243
- children: { type: Boolean }
244
- },
245
- setup(V) {
246
- return (i, G) => (Ie(), Ye(Ze, null, [
247
- et(ae(Me), {
248
- level: i.level,
249
- expanded: !1,
250
- branchIcon: i.branchIcon,
251
- children: i.children,
252
- size: i.indentSize
253
- }, null, 8, ["level", "branchIcon", "children", "size"]),
254
- tt("div", {
255
- class: rt(ae(it)({ size: i.size }))
256
- }, null, 2)
257
- ], 64));
258
- }
259
- }), Rt = /* @__PURE__ */ ke({
260
- ...Ae("Tree"),
261
- __name: "Tree",
262
- props: {
263
- selectionBehavior: { default: "toggle" },
264
- class: {},
265
- size: {},
266
- gap: {},
267
- dir: {},
268
- data: {},
269
- flattenData: { type: Boolean },
270
- modelValue: {},
271
- checkedKeys: {},
272
- expandedKeys: {},
273
- multiple: { type: Boolean },
274
- checkable: { type: Boolean },
275
- selectable: { type: Boolean },
276
- defaultExpandAll: { type: Boolean },
277
- showLine: { type: Boolean },
278
- inlineNode: { type: Boolean },
279
- lazyLoad: { type: Boolean },
280
- getLoading: {},
281
- getNoRotateSwitcherIcon: {},
282
- getTitle: {},
283
- getLeaf: {},
284
- getDraggable: {},
285
- getKey: {},
286
- getSwitcherIcon: {},
287
- getDisabled: {},
288
- getChildren: {},
289
- groupName: {},
290
- sortableProps: {},
291
- focusable: { type: Boolean, default: !0 },
292
- checkStrictly: { type: Boolean, default: void 0 },
293
- syncCheckboxAndSelect: { type: Boolean },
294
- virtual: { type: [Boolean, Object] },
295
- scrollContainerProps: {},
296
- outerVirtualScroll: { type: Boolean },
297
- switcherIcon: {},
298
- noRotateSwitcherIcon: { type: Boolean },
299
- draggable: { type: Boolean },
300
- disabled: { type: Boolean, default: void 0 }
301
- },
302
- emits: ["update:modelValue", "update:expandedKeys", "update:checkedKeys", "change", "expand", "select", "check", "dragStart", "dragEnd", "choose", "unchoose"],
303
- setup(V, { expose: i, emit: G }) {
304
- const e = V, r = G, P = Re(), v = ct("tree"), T = M(v, "node"), j = M(T, "group"), f = M(T, "draggable"), x = M(f, "icon"), k = M(j, "list"), C = {
305
- node: T,
306
- group: j,
307
- draggable: f,
308
- draggableIcon: x,
309
- groupList: k
310
- }, Q = Oe(v, {
311
- variants: {
312
- size: J(wt, v),
313
- gap: J(ze, v),
314
- selectable: J("selectable", v),
315
- disabled: J("disabled", v),
316
- inlineNode: J("inline-node", v),
317
- dragging: J("dragging", v)
318
- }
319
- }), L = {
320
- getLoading: D({
321
- key: "loading",
322
- getter: e.getLoading,
323
- noReturnOption: !0
324
- }),
325
- getNoRotateSwitcherIcon: D({
326
- key: "noRotateSwitcherIcon",
327
- getter: e.getNoRotateSwitcherIcon,
328
- noReturnOption: !0
329
- }),
330
- getTitle: D({
331
- key: "title",
332
- getter: e.getTitle,
333
- noReturnOption: !0
334
- }),
335
- getLeaf: D({
336
- key: "leaf",
337
- getter: e.getLeaf,
338
- noReturnOption: !0
339
- }),
340
- getDraggable: D({
341
- key: "draggable",
342
- getter: e.getDraggable,
343
- noReturnOption: !0
344
- }),
345
- getKey: D({
346
- key: "key",
347
- getter: e.getKey,
348
- noReturnOption: !0
349
- }),
350
- getSwitcherIcon: D({
351
- key: "switcherIcon",
352
- getter: e.getSwitcherIcon,
353
- noReturnOption: !0
354
- }),
355
- getDisabled: D({
356
- key: "disabled",
357
- getter: e.getDisabled,
358
- noReturnOption: !0
359
- }),
360
- getChildren: D({
361
- key: "children",
362
- getter: e.getChildren,
363
- noReturnOption: !0
364
- })
365
- }, B = (t, o) => {
366
- var O;
367
- const s = `get${o[0].toUpperCase() + o.slice(1)}`;
368
- return (O = L[s]) == null ? void 0 : O.call(L, t);
369
- }, I = ne(e.expandedKeys ?? []), {
370
- flattenData: U,
371
- visibleFlattenData: X,
372
- getNodeByValue: a,
373
- getChildrenOrRootNodes: c,
374
- getNodeIndexInScope: n,
375
- isSelected: d,
376
- getNodeChildren: h,
377
- selectValue: K,
378
- getRootNodes: y
379
- } = Pt({
380
- isFlatten: e.flattenData,
381
- getData: () => e.data,
382
- getExpandedKeys: () => I,
383
- getValue: (t) => B(t, "key"),
384
- getDisabled: (t) => B(t, "disabled"),
385
- getChildren: (t) => B(t, "children"),
386
- getExtra: (t) => ({
387
- _switcherIcon: B(t, "switcherIcon"),
388
- _title: B(t, "title"),
389
- _draggable: B(t, "draggable"),
390
- _leaf: B(t, "leaf"),
391
- _loading: B(t, "loading"),
392
- _noRotateSwitcherIcon: B(t, "noRotateSwitcherIcon")
393
- })
394
- }), Y = () => U.value.filter((t) => t == null ? void 0 : t._hasChildren).map((t) => t._key);
395
- let A = !1;
396
- pe(
397
- () => [e.defaultExpandAll, e.expandedKeys],
398
- ([t, o], s) => {
399
- A || (A = !0, o !== (s == null ? void 0 : s[1]) ? I.value = e.expandedKeys ?? [] : t && !(s != null && s[0]) && (I.value = Y()), at(() => A = !1));
400
- },
401
- { deep: !0, immediate: !0 }
402
- ), pe(
403
- I,
404
- (t) => {
405
- !A && t !== e.expandedKeys && r("update:expandedKeys", t);
406
- },
407
- { deep: !0 }
408
- );
409
- const E = ne(e.modelValue ?? []);
410
- pe(
411
- () => e.modelValue,
412
- () => {
413
- E.value = e.modelValue ?? [], e.syncCheckboxAndSelect && (S.value = e.modelValue ?? []);
414
- },
415
- { deep: !0 }
416
- );
417
- const N = m({
418
- get() {
419
- return E.value;
420
- },
421
- set(t) {
422
- t && (e.modelValue || (E.value = t), r("update:modelValue", t));
423
- }
424
- }), q = ne(e.checkedKeys ?? []);
425
- pe(
426
- () => e.checkedKeys,
427
- () => {
428
- q.value = e.checkedKeys ?? [], e.syncCheckboxAndSelect && (N.value = e.checkedKeys ?? []);
429
- },
430
- { deep: !0 }
431
- );
432
- const S = m({
433
- get() {
434
- return q.value;
435
- },
436
- set(t) {
437
- e.checkedKeys || (q.value = t), r("update:checkedKeys", t);
438
- }
439
- }), { getDisabled: b, getSize: g } = _t({
440
- defaults: { size: "md" },
441
- exports: ["getDisabled", "getSize"]
442
- }), ce = (t) => !!d(t, N, !0), je = (t) => d(t, S, e.checkStrictly), Se = (t, o) => {
443
- if (e.selectable && !b.value) {
444
- const s = K(
445
- t,
446
- o,
447
- N,
448
- !!(e.syncCheckboxAndSelect ? e.checkStrictly : e.checkStrictly !== !1),
449
- e.multiple,
450
- e.selectionBehavior
451
- );
452
- Ke(s, N.value) || (N.value = s, r("select", t, o, s), r("change", { modelValue: N.value, checkedKeys: S.value }), e.syncCheckboxAndSelect && (S.value = s, r("check", t, o, s)));
453
- }
454
- }, Ue = (t, o) => {
455
- if (e.checkable && !b.value) {
456
- const s = K(t, o, S, !!e.checkStrictly, !0);
457
- Ke(s, S.value) || (S.value = s, r("check", t, o, S.value), r("change", { modelValue: N.value, checkedKeys: S.value }), e.syncCheckboxAndSelect && (N.value = s, r("select", t, o, s)));
458
- }
459
- }, se = (t) => {
460
- let o = !0, s = $e(I.value);
461
- s.includes(t._key) ? (s = s.filter((O) => O !== t._key), o = !1) : (s = _e([...s, t._key]), o = !0), I.value = s, r("expand", t, o);
462
- }, he = m(() => {
463
- if (e.gap) {
464
- if (typeof e.gap == "number") return `${e.gap}px`;
465
- if (!Object.keys(ze).includes(e.gap)) return e.gap;
466
- }
467
- }), de = ne(!1), { getDir: qe } = xt(), Z = qe(), xe = m(() => {
468
- switch (g.value) {
469
- case "sm":
470
- return "2xsm";
471
- case "lg":
472
- return "sm";
473
- default:
474
- return "xsm";
475
- }
476
- }), We = m(() => g.value === "sm" ? "2xsm" : "xsm"), Ce = (t) => {
477
- var o;
478
- return (((o = t == null ? void 0 : t._parentKeys) == null ? void 0 : o.length) ?? 0) + 1;
479
- }, ye = ne(), Be = {
480
- iconSize: We,
481
- disabled: b,
482
- props: e,
483
- expandedKeys: I,
484
- model: N,
485
- dir: Z,
486
- checked: S,
487
- onExpandKey: se,
488
- onSelect: Se,
489
- onCheck: Ue,
490
- scrollContainerRef: ye,
491
- getNodeChildren: h,
492
- getNodeField: B,
493
- getIsSelected: ce,
494
- getIsChecked: je,
495
- getLevel: Ce,
496
- dragging: de,
497
- indentSize: xe,
498
- prefixes: C
499
- };
500
- Kt(Be);
501
- const me = ne();
502
- if (e.draggable) {
503
- let t, o;
504
- const s = (p) => {
505
- const u = p.getAttribute("data-key");
506
- if (u) return a(u);
507
- }, O = dt(M(v, "dragging_item"), g.value), w = () => {
508
- var p;
509
- (p = t == null ? void 0 : t.destroy) == null || p.call(t), t = void 0;
510
- };
511
- lt(async () => {
512
- let p, u, W, H, $;
513
- const be = (l) => ({
514
- ...l,
515
- node: u,
516
- oldParents: W,
517
- newParents: H,
518
- oldIndex: p,
519
- oldDraggableIndex: p,
520
- newIndex: $,
521
- newDraggableIndex: $
522
- }), Te = (l, te) => {
523
- if (l) {
524
- const z = () => {
525
- const ge = Ce(u), _ = !!(u != null && u._hasChildren);
526
- return {
527
- size: g.value,
528
- level: ge,
529
- children: _,
530
- indentSize: xe.value,
531
- branchIcon: (u ? u._switcherIcon ?? (e == null ? void 0 : e.switcherIcon) : e == null ? void 0 : e.switcherIcon) ?? "tabler:chevron-left"
532
- };
533
- }, F = document.createElement("div"), re = l.getBoundingClientRect();
534
- F.style.width = re.width ? `${re.width}px` : "100%", F.style.height = re.height ? `${re.height}px` : "100%", F.classList.add(M(v, gt));
535
- const ie = z();
536
- return te && (ie.level = te), st(R(zt, ie), F), F;
537
- }
538
- };
539
- t ? w() : me.value && (t = new bt(me.value, {
540
- ...vt(e.sortableProps || {}, ["onMove"]),
541
- group: Ne(e.groupName) ? e.groupName() : e.groupName ?? ut(v),
542
- filter: "[data-draggable=false]",
543
- tree: !0,
544
- draggable: `.${C.node}`,
545
- handle: `.${C.node} .${C.draggable} .${C.draggableIcon}`,
546
- dataIdAttr: "data-key",
547
- dragClass: O,
548
- onChoose(l) {
549
- var te;
550
- if (u = s(l == null ? void 0 : l.item), W = (te = u == null ? void 0 : u._parentKeys) == null ? void 0 : te.map(a).filter(Boolean), u) {
551
- if (W != null && W.length) {
552
- const z = fe(W);
553
- z && (p = h(z, !0, !1).findIndex(
554
- (F) => F._key === u._key
555
- ));
556
- } else
557
- p = y().findIndex((z) => z._key === u._key);
558
- u._dragging = !0;
559
- }
560
- r("choose", l);
561
- },
562
- onUnchoose(l) {
563
- u && (u._dragging = !1), r("unchoose", l);
564
- },
565
- onStart(l) {
566
- u != null && u._key && I.value.includes(u._key) && (o = u, se(o)), de.value = !0, r("dragStart", be(l));
567
- },
568
- onEnd(l) {
569
- de.value = !1, o && (se(o), o = void 0), r("dragEnd", be(l)), p = W = $ = H = u = void 0;
570
- },
571
- onMove(l, te) {
572
- var re, ie, ge;
573
- if ($ = H = void 0, l.draggedTreeItemParent) {
574
- const _ = s(l == null ? void 0 : l.draggedTreeItemParent);
575
- _ && (H = [
576
- ...((re = _ == null ? void 0 : _._parentKeys) == null ? void 0 : re.map(a).filter(Boolean)) ?? [],
577
- _
578
- ], (ie = h(_, !0, !1)) != null && ie.length && !I.value.includes(_._key) && se(_));
579
- }
580
- const z = l.draggedTreeItemLevel ?? 1;
581
- if (!l.draggedTreeItemBefore) $ = 0;
582
- else if (l.draggedTreeItemBefore) {
583
- if (l.draggedTreeItemBefore.level === z) {
584
- const _ = s(l.draggedTreeItemBefore);
585
- _ && ($ = n(_) + 1);
586
- } else if (l.draggedTreeItemBefore.level < z)
587
- $ = 0;
588
- else if (l.draggedTreeItemBefore.level > z) {
589
- if (!l.draggedTreeItemAfter || l.draggedTreeItemAfter.level < z) {
590
- const _ = fe(H ?? []);
591
- $ = c(_).length;
592
- } else if (l.draggedTreeItemAfter.level === z) {
593
- const _ = s(l.draggedTreeItemAfter);
594
- _ && ($ = n(_));
595
- }
596
- }
597
- }
598
- const F = be(l);
599
- Ne((ge = e.sortableProps) == null ? void 0 : ge.onMove) && e.sortableProps.onMove(F, te);
600
- },
601
- getPlaceholder(l) {
602
- return Te(l == null ? void 0 : l.item);
603
- },
604
- getPlaceholderOnMove(l) {
605
- return Te(l == null ? void 0 : l.dragged, l.draggedTreeItemLevel || 1);
606
- }
607
- }));
608
- }), nt(w);
609
- }
610
- const He = {
611
- none: 0,
612
- sm: 4,
613
- md: 6,
614
- lg: 8
615
- }, Je = m(() => ({
616
- get count() {
617
- return X.value.length ?? 0;
618
- },
619
- getScrollElement: () => {
620
- var t;
621
- return (t = ye.value) == null ? void 0 : t.container.viewportElement;
622
- },
623
- estimateSize: () => Pe[e.size] ?? Pe.md,
624
- overscan: 5,
625
- get gap() {
626
- return He[he.value ?? g.value] ?? he.value ?? g.value ?? 0;
627
- }
628
- }));
629
- let ve, ee;
630
- if (e.virtual)
631
- if (typeof e.virtual == "object")
632
- ve = e.virtual;
633
- else {
634
- const { virtualizer: t, ...o } = kt(Je);
635
- ve = t, ee = o;
636
- }
637
- const we = m(
638
- () => {
639
- var t;
640
- return e.virtual ? (((t = ae(ve)) == null ? void 0 : t.getVirtualItems()) ?? []).map(
641
- (o) => X.value[o.index]
642
- ) : X.value;
643
- }
644
- ), ue = ot(), Qe = () => {
645
- var o;
646
- const t = () => {
647
- const s = () => {
648
- var le;
649
- const w = (le = P.default) == null ? void 0 : le.call(P, {
650
- items: we.value
651
- });
652
- return Fe(w) ? we.value.map(
653
- (p) => R(
654
- Ge,
655
- { key: p._key, node: p },
656
- {
657
- default: P.node,
658
- switcherIcon: P.switcherIcon
659
- }
660
- )
661
- ) : w;
662
- }, O = () => R(
663
- "div",
664
- {
665
- dir: Z.value,
666
- role: "tree",
667
- class: Le(
668
- Q({
669
- size: g.value,
670
- gap: e.gap ?? g.value,
671
- selectable: e.selectable,
672
- disabled: b.value,
673
- inlineNode: e.inlineNode,
674
- dragging: de.value
675
- }),
676
- e.class
677
- ),
678
- style: {
679
- "--ptc-tree-gap": he.value,
680
- ...e.virtual ? (ee == null ? void 0 : ee.containerStyles.value) ?? {} : {}
681
- },
682
- ref: me
683
- },
684
- s()
685
- );
686
- return e.focusable ? R(
687
- ht,
688
- {
689
- orientation: "vertical",
690
- asChild: !0,
691
- currentTabStopId: ue.value,
692
- "onUpdate:currentTabStopId": (w) => {
693
- ue.value = w;
694
- },
695
- onKeyup: (w) => {
696
- var le;
697
- if (ue.value !== void 0) {
698
- const p = a(ue.value);
699
- if (p) {
700
- const u = !!(p._hasChildren || e != null && e.lazyLoad && !p._leaf);
701
- if ((w.key === "ArrowRight" || w.key === "ArrowLeft") && u) {
702
- const H = !(p._dragging ?? !1) && I.value.includes(p._key);
703
- (H && (Z.value === "rtl" && w.key === "ArrowRight" || Z.value === "ltr" && w.key === "ArrowLeft") || !H && (Z.value === "ltr" && w.key === "ArrowRight" || Z.value === "rtl" && w.key === "ArrowLeft")) && se(p);
704
- }
705
- w.key === "Enter" && Se(p, !((le = N.value) != null && le.includes(p._key)));
706
- }
707
- }
708
- }
709
- },
710
- O
711
- ) : O();
712
- };
713
- return e.virtual && !e.outerVirtualScroll ? R(
714
- Ct,
715
- {
716
- ...e.scrollContainerProps,
717
- ref: ye,
718
- dir: Z.value,
719
- wrapProps: {
720
- ...((o = e.scrollContainerProps) == null ? void 0 : o.wrapProps) ?? {},
721
- style: (ee == null ? void 0 : ee.scrollWrapperStyles.value) ?? {}
722
- }
723
- },
724
- t
725
- ) : t();
726
- };
727
- return i(Be), (t, o) => (Ie(), Ve(Qe));
728
- }
729
- }), Jt = De(Rt, Ee("Tree")), Qt = De(Ge, Ee("TreeNode"));
730
- export {
731
- ze as T,
732
- Rt as _,
733
- Ge as a,
734
- Qt as b,
735
- Jt as c,
736
- wt as d,
737
- Nt as f,
738
- Tt as i,
739
- Kt as p
740
- };