@septkit/ui 0.0.91 → 0.0.93

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.
@@ -18,7 +18,8 @@ function t(t, n) {
18
18
  if (!i.has(e.id)) continue;
19
19
  let t = {
20
20
  ...e,
21
- children: void 0
21
+ children: void 0,
22
+ hasChildren: void 0
22
23
  };
23
24
  o.set(e.id, t);
24
25
  let r = n === void 0 ? void 0 : o.get(n);
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./explorer.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region lib/explorer/explorer.vue
5
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-956831c2"]]);
5
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-3296f33f"]]);
6
6
  //#endregion
7
7
  export { n as default };
@@ -3,26 +3,26 @@ import t from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_
3
3
  import n from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/chevrons-up-down.js";
4
4
  import r from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/search.js";
5
5
  import i from "../external/.pnpm/@lucide_vue@1.23.0_vue@3.5.39_typescript@5.8.3_/node_modules/@lucide/vue/dist/esm/icons/x.js";
6
- import { expandedIdsOf as a, isAllExpanded as o, revealIds as s, toggleExpandedId as c } from "../tree/expansion.js";
7
- import l from "../tree/tree.js";
6
+ import { hasChildren as a } from "../tree/has-children.js";
7
+ import { expandedIdsOf as o, isAllExpanded as ee, revealIds as te, toggleExpandedId as s } from "../tree/expansion.js";
8
+ import c from "../tree/tree.js";
8
9
  import "../tree/index.js";
9
- import { buildTreeIndex as ee, findAncestorIds as u } from "../tree/tree-index.js";
10
+ import { buildTreeIndex as l, findAncestorIds as u } from "../tree/tree-index.js";
10
11
  import { filterExplorerTree as d, splitByMatch as f } from "./explorer-search.js";
11
- import { Fragment as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createSlots as y, createTextVNode as b, createVNode as x, defineComponent as S, normalizeClass as te, openBlock as C, ref as w, renderList as T, renderSlot as E, toDisplayString as D, unref as O, vModelText as ne, watch as k, withCtx as A, withDirectives as j, withKeys as M, withModifiers as N } from "vue";
12
+ import { Fragment as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createSlots as ne, createTextVNode as y, createVNode as b, defineComponent as x, mergeModels as S, normalizeClass as C, openBlock as w, ref as re, renderList as ie, renderSlot as T, toDisplayString as E, unref as D, useModel as O, vModelText as k, watch as A, withCtx as j, withDirectives as M, withKeys as N, withModifiers as P } from "vue";
12
13
  //#region lib/explorer/explorer.vue?vue&type=script&setup=true&lang.ts
13
- var P = { class: "explorer" }, F = { class: "explorer__controls flex items-center gap-1 bg-base-100" }, I = { class: "input input-sm flex-1" }, L = ["disabled", "aria-label"], R = {
14
- key: 0,
15
- class: "label",
14
+ var F = { class: "explorer" }, I = { class: "explorer__controls flex items-center gap-1 bg-base-100" }, L = { class: "input input-sm flex-1" }, R = ["disabled", "aria-label"], z = {
15
+ class: "label empty:hidden",
16
16
  role: "status"
17
- }, z = {
18
- key: 1,
17
+ }, B = {
18
+ key: 0,
19
19
  class: "explorer__viewport"
20
- }, B = { class: "pl-2 truncate" }, V = {
20
+ }, V = { class: "pl-2 truncate" }, H = {
21
21
  key: 0,
22
22
  class: "rounded-sm bg-warning/40 text-inherit"
23
- }, H = /*@__PURE__*/ S({
23
+ }, U = /*@__PURE__*/ x({
24
24
  __name: "explorer",
25
- props: {
25
+ props: /*@__PURE__*/ S({
26
26
  items: {},
27
27
  expanded: { default: () => ({
28
28
  scoped: [],
@@ -30,128 +30,139 @@ var P = { class: "explorer" }, F = { class: "explorer__controls flex items-cente
30
30
  }) },
31
31
  ariaLabel: { default: "SCL Tree" },
32
32
  selected: {},
33
- rowLabel: {}
34
- },
35
- emits: [
33
+ rowLabel: {},
34
+ searchLoading: {
35
+ type: Boolean,
36
+ default: !1
37
+ }
38
+ }, {
39
+ term: { default: "" },
40
+ termModifiers: {}
41
+ }),
42
+ emits: /*@__PURE__*/ S([
36
43
  "select",
37
44
  "contextmenu",
38
45
  "update:expanded"
39
- ],
40
- setup(S, { emit: H }) {
41
- let U = S, W = H, G = w(""), K = w(), q = m(() => ee(U.items)), J = m(() => G.value.trim().length > 0), Y = m(() => d(q.value, G.value)), X = m(() => J.value ? {
46
+ ], ["update:term"]),
47
+ setup(x, { emit: S }) {
48
+ let U = x, W = O(x, "term"), G = S, K = re(), q = m(() => l(U.items)), J = m(() => W.value.trim().length > 0), Y = m(() => d(q.value, W.value)), ae = m(() => J.value ? U.searchLoading ? "Searching..." : Y.value.items.length ? "" : "No results" : ""), oe = m(() => J.value ? {
42
49
  scoped: [],
43
50
  all: !0
44
- } : U.expanded), re = m(() => a(U.expanded, q.value.expandableIds)), Z = m(() => o(U.expanded, q.value.expandableIds));
45
- k(() => U.selected, (e) => {
46
- e === void 0 || !J.value || !q.value.byId.has(e) || Y.value.visibleIds?.has(e) || (G.value = "");
47
- }), k(G, (e, t) => {
51
+ } : U.expanded), se = m(() => o(U.expanded, q.value.expandableIds)), X = m(() => ee(U.expanded, q.value.expandableIds));
52
+ A(() => U.selected, (e) => {
53
+ e === void 0 || !J.value || !q.value.byId.has(e) || Y.value.visibleIds?.has(e) || (W.value = "");
54
+ }), A(W, (e, t) => {
48
55
  if (!t.trim() || e.trim()) return;
49
56
  let n = U.selected ?? K.value;
50
57
  if (n === void 0 || U.expanded.all) return;
51
58
  let r = u(q.value, n);
52
- r !== void 0 && W("update:expanded", s(U.expanded, r));
59
+ r !== void 0 && G("update:expanded", te(U.expanded, r));
53
60
  });
54
- function ie() {
55
- W("update:expanded", {
61
+ function ce() {
62
+ G("update:expanded", {
56
63
  scoped: [],
57
- all: !Z.value
64
+ all: !X.value
58
65
  });
59
66
  }
60
- function Q(e) {
61
- W("update:expanded", c(re.value, e));
67
+ function Z(e) {
68
+ G("update:expanded", s(se.value, e));
62
69
  }
63
- function ae(e) {
64
- e.selectable === !1 && e.children?.length && Q(e.id);
70
+ function le(e) {
71
+ e.selectable === !1 && a(e) && Z(e.id);
65
72
  }
66
- function oe(e) {
67
- K.value = e.id, W("select", e);
73
+ function ue(e) {
74
+ K.value = e.id, G("select", e);
68
75
  }
69
- function se(e) {
70
- J.value || W("update:expanded", e);
76
+ function Q(e) {
77
+ J.value || G("update:expanded", e);
71
78
  }
72
79
  function $() {
73
- G.value = "";
80
+ W.value = "";
74
81
  }
75
- return (a, o) => (C(), _("div", P, [v("div", F, [v("label", I, [
76
- x(O(r), {
77
- "aria-hidden": "true",
78
- size: 14,
79
- class: "opacity-50"
80
- }),
81
- j(v("input", {
82
- "onUpdate:modelValue": o[0] ||= (e) => G.value = e,
83
- type: "text",
84
- class: "grow",
85
- placeholder: "Search by name",
86
- "aria-label": "Search by name",
87
- "data-testid": "explorer-search",
88
- onKeydown: M($, ["esc"])
89
- }, null, 544), [[ne, G.value]]),
90
- G.value ? (C(), _("button", {
91
- key: 0,
82
+ return (a, o) => (w(), _("div", F, [
83
+ v("div", I, [v("label", L, [
84
+ b(D(r), {
85
+ "aria-hidden": "true",
86
+ size: 14,
87
+ class: "opacity-50"
88
+ }),
89
+ M(v("input", {
90
+ "onUpdate:modelValue": o[0] ||= (e) => W.value = e,
91
+ type: "text",
92
+ class: "grow",
93
+ placeholder: "Search by name",
94
+ "aria-label": "Search by name",
95
+ "data-testid": "explorer-search",
96
+ onKeydown: N($, ["esc"])
97
+ }, null, 544), [[k, W.value]]),
98
+ W.value ? (w(), _("button", {
99
+ key: 0,
100
+ type: "button",
101
+ class: "btn btn-ghost btn-circle btn-xs",
102
+ "aria-label": "Clear search",
103
+ onClick: $
104
+ }, [b(D(i), {
105
+ "aria-hidden": "true",
106
+ size: 14
107
+ })])) : g("", !0)
108
+ ]), v("button", {
92
109
  type: "button",
93
- class: "btn btn-ghost btn-circle btn-xs",
94
- "aria-label": "Clear search",
95
- onClick: $
96
- }, [x(O(i), {
110
+ class: "btn btn-ghost btn-square btn-sm",
111
+ disabled: J.value || !q.value.expandableIds.length,
112
+ "aria-label": X.value ? "Collapse all" : "Expand all",
113
+ onClick: ce
114
+ }, [X.value ? (w(), h(D(n), {
115
+ key: 0,
97
116
  "aria-hidden": "true",
98
- size: 14
99
- })])) : g("", !0)
100
- ]), v("button", {
101
- type: "button",
102
- class: "btn btn-ghost btn-square btn-sm",
103
- disabled: J.value || !q.value.expandableIds.length,
104
- "aria-label": Z.value ? "Collapse all" : "Expand all",
105
- onClick: ie
106
- }, [Z.value ? (C(), h(O(n), {
107
- key: 0,
108
- "aria-hidden": "true",
109
- size: 16
110
- })) : (C(), h(O(t), {
111
- key: 1,
112
- "aria-hidden": "true",
113
- size: 16
114
- }))], 8, L)]), J.value && !Y.value.items.length ? (C(), _("p", R, "No results")) : (C(), _("div", z, [x(O(l), {
115
- items: Y.value.items,
116
- expanded: X.value,
117
- selected: U.selected ?? K.value,
118
- "aria-label": U.ariaLabel,
119
- "row-label": U.rowLabel,
120
- onSelect: oe,
121
- onRowClick: ae,
122
- onContextmenu: o[1] ||= (e) => W("contextmenu", e),
123
- "onUpdate:expanded": se
124
- }, y({
125
- "node-toggle": A(({ node: t, hasChildren: n, expanded: r }) => [x(O(e), {
117
+ size: 16
118
+ })) : (w(), h(D(t), {
119
+ key: 1,
126
120
  "aria-hidden": "true",
127
- size: 16,
128
- class: te(["explorer__chevron shrink-0", {
129
- invisible: !n || J.value,
130
- "explorer__chevron--open": r
131
- }]),
132
- onClick: N((e) => Q(t.id), ["stop"])
133
- }, null, 8, ["class", "onClick"])]),
134
- "node-label": A(({ node: e }) => [E(a.$slots, "node-label", {
135
- node: e,
136
- term: G.value
137
- }, () => [v("span", B, [(C(!0), _(p, null, T(O(f)(e.name, G.value), (e, t) => (C(), _(p, { key: t }, [e.match ? (C(), _("mark", V, D(e.text), 1)) : (C(), _(p, { key: 1 }, [b(D(e.text), 1)], 64))], 64))), 128))])], !0)]),
138
- _: 2
139
- }, [a.$slots["node-prefix"] ? {
140
- name: "node-prefix",
141
- fn: A(({ node: e }) => [E(a.$slots, "node-prefix", { node: e }, void 0, !0)]),
142
- key: "0"
143
- } : void 0, a.$slots["node-suffix"] ? {
144
- name: "node-suffix",
145
- fn: A(({ node: e }) => [E(a.$slots, "node-suffix", { node: e }, void 0, !0)]),
146
- key: "1"
147
- } : void 0]), 1032, [
148
- "items",
149
- "expanded",
150
- "selected",
151
- "aria-label",
152
- "row-label"
153
- ])]))]));
121
+ size: 16
122
+ }))], 8, R)]),
123
+ v("p", z, E(ae.value), 1),
124
+ !J.value || Y.value.items.length ? (w(), _("div", B, [b(D(c), {
125
+ items: Y.value.items,
126
+ expanded: oe.value,
127
+ selected: U.selected ?? K.value,
128
+ "aria-label": U.ariaLabel,
129
+ "row-label": U.rowLabel,
130
+ onSelect: ue,
131
+ onRowClick: le,
132
+ onContextmenu: o[1] ||= (e) => G("contextmenu", e),
133
+ "onUpdate:expanded": Q
134
+ }, ne({
135
+ "node-toggle": j(({ node: t, hasChildren: n, expanded: r }) => [b(D(e), {
136
+ "aria-hidden": "true",
137
+ size: 16,
138
+ class: C(["explorer__chevron shrink-0", {
139
+ invisible: !n || J.value,
140
+ "explorer__chevron--open": r
141
+ }]),
142
+ onClick: P((e) => Z(t.id), ["stop"])
143
+ }, null, 8, ["class", "onClick"])]),
144
+ "node-label": j(({ node: e }) => [T(a.$slots, "node-label", {
145
+ node: e,
146
+ term: W.value
147
+ }, () => [v("span", V, [(w(!0), _(p, null, ie(D(f)(e.name, W.value), (e, t) => (w(), _(p, { key: t }, [e.match ? (w(), _("mark", H, E(e.text), 1)) : (w(), _(p, { key: 1 }, [y(E(e.text), 1)], 64))], 64))), 128))])], !0)]),
148
+ _: 2
149
+ }, [a.$slots["node-prefix"] ? {
150
+ name: "node-prefix",
151
+ fn: j(({ node: e }) => [T(a.$slots, "node-prefix", { node: e }, void 0, !0)]),
152
+ key: "0"
153
+ } : void 0, a.$slots["node-suffix"] ? {
154
+ name: "node-suffix",
155
+ fn: j(({ node: e }) => [T(a.$slots, "node-suffix", { node: e }, void 0, !0)]),
156
+ key: "1"
157
+ } : void 0]), 1032, [
158
+ "items",
159
+ "expanded",
160
+ "selected",
161
+ "aria-label",
162
+ "row-label"
163
+ ])])) : g("", !0)
164
+ ]));
154
165
  }
155
166
  });
156
167
  //#endregion
157
- export { H as default };
168
+ export { U as default };
package/dist/index.d.ts CHANGED
@@ -48,9 +48,9 @@ maxSize: number;
48
48
 
49
49
  declare const __VLS_component_11: DefineComponent<__VLS_Props_21, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_21> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLElement>;
50
50
 
51
- declare const __VLS_component_12: DefineComponent<__VLS_PublicProps_6, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
51
+ declare const __VLS_component_12: DefineComponent<__VLS_PublicProps_7, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
52
52
  "update:open": (value: boolean) => any;
53
- }, string, PublicProps, Readonly<__VLS_PublicProps_6> & Readonly<{
53
+ }, string, PublicProps, Readonly<__VLS_PublicProps_7> & Readonly<{
54
54
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
55
55
  }>, {
56
56
  hoverDelay: number;
@@ -59,11 +59,11 @@ hoverDelay: number;
59
59
  declare const __VLS_component_13: DefineComponent<__VLS_Props_26, {
60
60
  focus: () => void | undefined;
61
61
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
62
- toggle: (groupId: string) => any;
63
62
  keydown: (event: KeyboardEvent) => any;
63
+ toggle: (groupId: string) => any;
64
64
  }, string, PublicProps, Readonly<__VLS_Props_26> & Readonly<{
65
- onToggle?: ((groupId: string) => any) | undefined;
66
65
  onKeydown?: ((event: KeyboardEvent) => any) | undefined;
66
+ onToggle?: ((groupId: string) => any) | undefined;
67
67
  }>, {
68
68
  expanded: boolean;
69
69
  testId: string;
@@ -316,23 +316,26 @@ expanded: ExplorerExpandedState;
316
316
  root: {} | null;
317
317
  }, any>;
318
318
 
319
- declare const __VLS_component_7: DefineComponent<__VLS_Props_12, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
319
+ declare const __VLS_component_7: DefineComponent<__VLS_PublicProps_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
320
320
  select: (node: ExplorerNode) => any;
321
321
  contextmenu: (payload: {
322
322
  node: ExplorerNode;
323
323
  event: MouseEvent;
324
324
  }) => any;
325
325
  "update:expanded": (state: ExplorerExpandedState) => any;
326
- }, string, PublicProps, Readonly<__VLS_Props_12> & Readonly<{
326
+ "update:term": (value: string) => any;
327
+ }, string, PublicProps, Readonly<__VLS_PublicProps_4> & Readonly<{
327
328
  onSelect?: ((node: ExplorerNode) => any) | undefined;
328
329
  onContextmenu?: ((payload: {
329
330
  node: ExplorerNode;
330
331
  event: MouseEvent;
331
332
  }) => any) | undefined;
332
333
  "onUpdate:expanded"?: ((state: ExplorerExpandedState) => any) | undefined;
334
+ "onUpdate:term"?: ((value: string) => any) | undefined;
333
335
  }>, {
334
336
  ariaLabel: string;
335
337
  expanded: ExplorerExpandedState;
338
+ searchLoading: boolean;
336
339
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
337
340
 
338
341
  declare const __VLS_component_8: DefineComponent<__VLS_Props_13, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
@@ -355,10 +358,10 @@ path: string;
355
358
  }) => any) | undefined;
356
359
  }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
357
360
 
358
- declare const __VLS_component_9: DefineComponent<__VLS_PublicProps_5, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
361
+ declare const __VLS_component_9: DefineComponent<__VLS_PublicProps_6, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
359
362
  "update:modelValue": (value: string) => any;
360
363
  "update:invalid": (value: boolean) => any;
361
- }, string, PublicProps, Readonly<__VLS_PublicProps_5> & Readonly<{
364
+ }, string, PublicProps, Readonly<__VLS_PublicProps_6> & Readonly<{
362
365
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
363
366
  "onUpdate:invalid"?: ((value: boolean) => any) | undefined;
364
367
  }>, {
@@ -406,6 +409,8 @@ declare type __VLS_Props_12 = {
406
409
  selected?: string;
407
410
  /** What a row is called for assistive technology, when the text drawn in it says less or more. */
408
411
  rowLabel?: (node: ExplorerNode) => string | undefined;
412
+ /** The consumer is still loading the rows to search: the matches shown so far are not all of them. */
413
+ searchLoading?: boolean;
409
414
  };
410
415
 
411
416
  declare type __VLS_Props_13 = {
@@ -655,15 +660,19 @@ declare type __VLS_PublicProps_3 = {
655
660
  } & __VLS_Props_5;
656
661
 
657
662
  declare type __VLS_PublicProps_4 = {
663
+ 'term'?: string;
664
+ } & __VLS_Props_12;
665
+
666
+ declare type __VLS_PublicProps_5 = {
658
667
  modelValue: NoteCategory[];
659
668
  };
660
669
 
661
- declare type __VLS_PublicProps_5 = {
670
+ declare type __VLS_PublicProps_6 = {
662
671
  modelValue?: string;
663
672
  'invalid'?: boolean;
664
673
  } & __VLS_Props_19;
665
674
 
666
- declare type __VLS_PublicProps_6 = {
675
+ declare type __VLS_PublicProps_7 = {
667
676
  'open'?: boolean;
668
677
  } & __VLS_Props_22;
669
678
 
@@ -1561,6 +1570,8 @@ export declare type ExplorerNode = {
1561
1570
  name: string;
1562
1571
  selectable?: boolean;
1563
1572
  children?: ExplorerNode[];
1573
+ /** Has children not loaded yet: drawn as a branch the user can open. */
1574
+ hasChildren?: boolean;
1564
1575
  };
1565
1576
 
1566
1577
  /** Map of named extension modules. */
@@ -2044,9 +2055,9 @@ export declare const NOTE_STATUSES: readonly ["open", "resolved", "removed"];
2044
2055
 
2045
2056
  export declare type NoteCategory = (typeof NOTE_CATEGORIES)[number];
2046
2057
 
2047
- export declare const NoteCategoryPicker: DefineComponent<__VLS_PublicProps_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
2058
+ export declare const NoteCategoryPicker: DefineComponent<__VLS_PublicProps_5, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
2048
2059
  "update:modelValue": (value: ("feedback" | "instantiation" | "interlock")[]) => any;
2049
- }, string, PublicProps, Readonly<__VLS_PublicProps_4> & Readonly<{
2060
+ }, string, PublicProps, Readonly<__VLS_PublicProps_5> & Readonly<{
2050
2061
  "onUpdate:modelValue"?: ((value: ("feedback" | "instantiation" | "interlock")[]) => any) | undefined;
2051
2062
  }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLFieldSetElement>;
2052
2063
 
@@ -1,14 +1,12 @@
1
+ import { hasChildren as e } from "./has-children.js";
1
2
  //#region lib/tree/collect-expandable-node-ids.ts
2
- function e(e) {
3
- let t = [], n = [...e].reverse();
4
- for (; n.length;) {
5
- let e = n.pop();
6
- if (e.children?.length) {
7
- t.push(e.id);
8
- for (let t = e.children.length - 1; t >= 0; t--) n.push(e.children[t]);
9
- }
3
+ function t(t) {
4
+ let n = [], r = [...t].reverse();
5
+ for (; r.length;) {
6
+ let t = r.pop();
7
+ if (e(t) && (n.push(t.id), t.children)) for (let e = t.children.length - 1; e >= 0; e--) r.push(t.children[e]);
10
8
  }
11
- return t;
9
+ return n;
12
10
  }
13
11
  //#endregion
14
- export { e as collectExpandableNodeIds };
12
+ export { t as collectExpandableNodeIds };
@@ -1,36 +1,37 @@
1
+ import { hasChildren as e } from "./has-children.js";
1
2
  //#region lib/tree/flatten-tree.ts
2
- function e(e, t) {
3
- let n = [], r = [{
4
- nodes: e,
3
+ function t(t, n) {
4
+ let r = [], i = [{
5
+ nodes: t,
5
6
  index: 0,
6
7
  depth: 1,
7
8
  parentIndex: void 0
8
9
  }];
9
- for (; r.length;) {
10
- let e = r[r.length - 1];
11
- if (e.index >= e.nodes.length) {
12
- r.pop();
10
+ for (; i.length;) {
11
+ let t = i[i.length - 1];
12
+ if (t.index >= t.nodes.length) {
13
+ i.pop();
13
14
  continue;
14
15
  }
15
- let i = e.nodes[e.index++], a = n.length, o = !!i.children?.length, s = o && t.has(i.id);
16
- n.push({
17
- id: i.id,
18
- index: a,
19
- node: i,
20
- depth: e.depth,
21
- posInSet: e.index,
22
- setSize: e.nodes.length,
23
- parentIndex: e.parentIndex,
24
- hasChildren: o,
25
- expanded: s
26
- }), s && r.push({
27
- nodes: i.children,
16
+ let a = t.nodes[t.index++], o = r.length, s = e(a), c = s && n.has(a.id);
17
+ r.push({
18
+ id: a.id,
19
+ index: o,
20
+ node: a,
21
+ depth: t.depth,
22
+ posInSet: t.index,
23
+ setSize: t.nodes.length,
24
+ parentIndex: t.parentIndex,
25
+ hasChildren: s,
26
+ expanded: c
27
+ }), c && a.children?.length && i.push({
28
+ nodes: a.children,
28
29
  index: 0,
29
- depth: e.depth + 1,
30
- parentIndex: a
30
+ depth: t.depth + 1,
31
+ parentIndex: o
31
32
  });
32
33
  }
33
- return n;
34
+ return r;
34
35
  }
35
36
  //#endregion
36
- export { e as flattenTree };
37
+ export { t as flattenTree };
@@ -0,0 +1,6 @@
1
+ //#region lib/tree/has-children.ts
2
+ function e(e) {
3
+ return !!e.children?.length || e.hasChildren === !0;
4
+ }
5
+ //#endregion
6
+ export { e as hasChildren };
@@ -1,33 +1,31 @@
1
+ import { hasChildren as e } from "./has-children.js";
1
2
  //#region lib/tree/tree-index.ts
2
- function e(e) {
3
- let t = [], n = /* @__PURE__ */ new Map(), r = [], i = [];
4
- for (let t = e.length - 1; t >= 0; t--) i.push({
5
- node: e[t],
3
+ function t(t) {
4
+ let n = [], r = /* @__PURE__ */ new Map(), i = [], a = [];
5
+ for (let e = t.length - 1; e >= 0; e--) a.push({
6
+ node: t[e],
6
7
  parentId: void 0,
7
- lowerName: e[t].name.toLowerCase()
8
+ lowerName: t[e].name.toLowerCase()
8
9
  });
9
- for (; i.length;) {
10
- let e = i.pop(), { node: a } = e;
11
- if (t.push(e), n.set(a.id, e), a.children?.length) {
12
- r.push(a.id);
13
- for (let e = a.children.length - 1; e >= 0; e--) {
14
- let t = a.children[e];
15
- i.push({
16
- node: t,
17
- parentId: a.id,
18
- lowerName: t.name.toLowerCase()
19
- });
20
- }
10
+ for (; a.length;) {
11
+ let t = a.pop(), { node: o } = t;
12
+ if (n.push(t), r.set(o.id, t), e(o) && (i.push(o.id), o.children)) for (let e = o.children.length - 1; e >= 0; e--) {
13
+ let t = o.children[e];
14
+ a.push({
15
+ node: t,
16
+ parentId: o.id,
17
+ lowerName: t.name.toLowerCase()
18
+ });
21
19
  }
22
20
  }
23
21
  return {
24
- items: e,
25
- nodes: t,
26
- byId: n,
27
- expandableIds: r
22
+ items: t,
23
+ nodes: n,
24
+ byId: r,
25
+ expandableIds: i
28
26
  };
29
27
  }
30
- function t(e, t) {
28
+ function n(e, t) {
31
29
  let n = e.byId.get(t);
32
30
  if (!n) return;
33
31
  let r = [];
@@ -35,4 +33,4 @@ function t(e, t) {
35
33
  return r.reverse();
36
34
  }
37
35
  //#endregion
38
- export { e as buildTreeIndex, t as findAncestorIds };
36
+ export { t as buildTreeIndex, n as findAncestorIds };
package/dist/tree/tree.js CHANGED
@@ -2,6 +2,6 @@ import e from "./tree.vue_vue_type_script_setup_true_lang.js";
2
2
  /* empty css */
3
3
  import t from "../_virtual/_plugin-vue_export-helper.js";
4
4
  //#region lib/tree/tree.vue
5
- var n = /*#__PURE__*/ t(e, [["__scopeId", "data-v-ec248e32"]]);
5
+ var n = /*#__PURE__*/ t(e, [["__scopeId", "data-v-39de0682"]]);
6
6
  //#endregion
7
7
  export { n as default };