vlite3 1.4.35 → 1.4.37
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/components/CategoryManager/CategoryManager.vue2.js +4 -4
- package/components/ColorPicker/ColorIro.vue3.js +2 -2
- package/components/ColorPicker/ColorPicker.vue.js +2 -2
- package/components/DataTable/DataTable.vue.d.ts +4 -1
- package/components/DataTable/DataTable.vue.js +322 -205
- package/components/DataTable/DataTableRow.vue.d.ts +21 -0
- package/components/DataTable/DataTableRow.vue.js +137 -73
- package/components/DataTable/types.d.ts +30 -0
- package/components/DataTable/useDataTableTree.d.ts +24 -0
- package/components/DataTable/useDataTableTree.js +137 -0
- package/components/FileTree/FileTree.vue.js +1 -1
- package/components/FileTree/FileTree.vue2.js +59 -57
- package/components/FileTree/FileTreeNode.vue.d.ts +6 -0
- package/components/FileTree/FileTreeNode.vue.js +112 -103
- package/components/Form/{AccordionView.vue.js → AccordionView.vue2.js} +1 -1
- package/components/Form/index.vue2.js +1 -1
- package/components/RichTextEditor/RichTextEditor.vue.js +4 -4
- package/components/RichTextEditor/RichTextLinkPopover.vue3.js +2 -2
- package/components/RichTextEditor/RichTextToolbar.vue3.js +2 -2
- package/components/Screen/ScreenFilter.vue.js +4 -4
- package/components/TreeConnectors/TreeConnectors.vue.d.ts +27 -0
- package/components/TreeConnectors/TreeConnectors.vue.js +44 -0
- package/components/TreeConnectors/TreeConnectors.vue2.js +4 -0
- package/components/TreeConnectors/geometry.d.ts +64 -0
- package/components/TreeConnectors/geometry.js +55 -0
- package/components/TreeConnectors/index.d.ts +3 -0
- package/components/index.d.ts +1 -0
- package/package.json +1 -1
- package/style.css +1 -1
- /package/components/ColorPicker/{ColorIro.vue.js → ColorIro.vue2.js} +0 -0
- /package/components/RichTextEditor/{RichTextLinkPopover.vue.js → RichTextLinkPopover.vue2.js} +0 -0
- /package/components/RichTextEditor/{RichTextToolbar.vue.js → RichTextToolbar.vue2.js} +0 -0
|
@@ -6,11 +6,21 @@ interface Props {
|
|
|
6
6
|
keyField: string;
|
|
7
7
|
selectable?: boolean;
|
|
8
8
|
isSelected?: boolean;
|
|
9
|
+
isIndeterminate?: boolean;
|
|
9
10
|
hoverable?: boolean;
|
|
10
11
|
striped?: boolean;
|
|
11
12
|
compact?: boolean;
|
|
12
13
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
13
14
|
cellBordered?: boolean;
|
|
15
|
+
/** Tree mode — when true, first data column shows expand/indent chrome. */
|
|
16
|
+
treeMode?: boolean;
|
|
17
|
+
depth?: number;
|
|
18
|
+
treeIndent?: number;
|
|
19
|
+
expandable?: boolean;
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
treeLoading?: boolean;
|
|
22
|
+
isLastSibling?: boolean;
|
|
23
|
+
ancestorLastFlags?: boolean[];
|
|
14
24
|
}
|
|
15
25
|
declare function __VLS_template(): {
|
|
16
26
|
attrs: Partial<{}>;
|
|
@@ -26,12 +36,14 @@ declare function __VLS_template(): {
|
|
|
26
36
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
27
37
|
declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
28
38
|
select: (id: any) => any;
|
|
39
|
+
toggleExpand: () => any;
|
|
29
40
|
rowClick: (payload: {
|
|
30
41
|
row: any;
|
|
31
42
|
index: number;
|
|
32
43
|
}) => any;
|
|
33
44
|
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
34
45
|
onSelect?: (id: any) => any;
|
|
46
|
+
onToggleExpand?: () => any;
|
|
35
47
|
onRowClick?: (payload: {
|
|
36
48
|
row: any;
|
|
37
49
|
index: number;
|
|
@@ -42,8 +54,17 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
|
|
|
42
54
|
striped: boolean;
|
|
43
55
|
selectable: boolean;
|
|
44
56
|
isSelected: boolean;
|
|
57
|
+
depth: number;
|
|
58
|
+
isLastSibling: boolean;
|
|
59
|
+
ancestorLastFlags: boolean[];
|
|
60
|
+
isIndeterminate: boolean;
|
|
45
61
|
keyField: string;
|
|
46
62
|
hoverable: boolean;
|
|
63
|
+
treeMode: boolean;
|
|
64
|
+
treeIndent: number;
|
|
65
|
+
expandable: boolean;
|
|
66
|
+
expanded: boolean;
|
|
67
|
+
treeLoading: boolean;
|
|
47
68
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLTableRowElement>;
|
|
48
69
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
49
70
|
export default _default;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { defineComponent as V, computed as f, openBlock as o, createElementBlock as d, normalizeClass as g, withModifiers as A, createElementVNode as b, createVNode as v, createCommentVNode as x, Fragment as p, renderList as D, normalizeStyle as w, unref as y, createBlock as c, renderSlot as I } from "vue";
|
|
2
|
+
import U from "../CheckBox.vue.js";
|
|
3
|
+
import k from "../Icon.vue.js";
|
|
4
|
+
import G from "../Price/Price.vue.js";
|
|
5
|
+
import P from "../DateTime/DateTime.vue.js";
|
|
6
|
+
import R from "../TreeConnectors/TreeConnectors.vue.js";
|
|
7
|
+
import { DEFAULT_TOGGLE_SIZE as O, DEFAULT_TREE_CONTENT_GAP as h, DEFAULT_TREE_LEADING as H } from "../TreeConnectors/geometry.js";
|
|
8
|
+
const j = ["data-state"], Z = { class: "flex items-center justify-center" }, q = ["aria-expanded"], J = ["title", "innerHTML"], ne = /* @__PURE__ */ V({
|
|
6
9
|
__name: "DataTableRow",
|
|
7
10
|
props: {
|
|
8
11
|
row: {},
|
|
@@ -11,29 +14,38 @@ const E = ["data-state"], H = { class: "flex items-center justify-center" }, I =
|
|
|
11
14
|
keyField: { default: "_id" },
|
|
12
15
|
selectable: { type: Boolean, default: !1 },
|
|
13
16
|
isSelected: { type: Boolean, default: !1 },
|
|
17
|
+
isIndeterminate: { type: Boolean, default: !1 },
|
|
14
18
|
hoverable: { type: Boolean, default: !0 },
|
|
15
19
|
striped: { type: Boolean, default: !1 },
|
|
16
20
|
compact: { type: Boolean, default: !1 },
|
|
17
21
|
size: { default: "md" },
|
|
18
|
-
cellBordered: { type: Boolean }
|
|
22
|
+
cellBordered: { type: Boolean },
|
|
23
|
+
treeMode: { type: Boolean, default: !1 },
|
|
24
|
+
depth: { default: 0 },
|
|
25
|
+
treeIndent: { default: 20 },
|
|
26
|
+
expandable: { type: Boolean, default: !1 },
|
|
27
|
+
expanded: { type: Boolean, default: !1 },
|
|
28
|
+
treeLoading: { type: Boolean, default: !1 },
|
|
29
|
+
isLastSibling: { type: Boolean, default: !1 },
|
|
30
|
+
ancestorLastFlags: { default: () => [] }
|
|
19
31
|
},
|
|
20
|
-
emits: ["select", "rowClick"],
|
|
21
|
-
setup(
|
|
22
|
-
const
|
|
23
|
-
if (!(!
|
|
24
|
-
return l.includes(".") ? l.split(".").reduce((t,
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
32
|
+
emits: ["select", "rowClick", "toggleExpand"],
|
|
33
|
+
setup(e, { emit: C }) {
|
|
34
|
+
const s = e, u = C, a = (n, l) => {
|
|
35
|
+
if (!(!n || !l))
|
|
36
|
+
return l.includes(".") ? l.split(".").reduce((t, i) => t?.[i], n) : n[l];
|
|
37
|
+
}, S = (n, l, t) => n.format ? n.format(l, t) : l == null ? "-" : n.type === "number" ? new Intl.NumberFormat("en-US").format(Number(l)) : String(l), B = (n, l, t) => {
|
|
38
|
+
const i = [];
|
|
39
|
+
if (n.width && /(?:^|\s|:)w-/.test(n.width) && i.push(n.width), n.minWidth && /(?:^|\s|:)min-w-/.test(n.minWidth) && i.push(n.minWidth), n.capitalize && i.push("capitalize"), n.addStatusColor) {
|
|
40
|
+
const r = L(l);
|
|
41
|
+
r && i.push(r);
|
|
30
42
|
}
|
|
31
|
-
if (typeof
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
} else
|
|
35
|
-
return
|
|
36
|
-
},
|
|
43
|
+
if (typeof n.class == "function") {
|
|
44
|
+
const r = n.class(l, t);
|
|
45
|
+
r && i.push(r);
|
|
46
|
+
} else n.class && i.push(n.class);
|
|
47
|
+
return i.join(" ");
|
|
48
|
+
}, L = (n) => {
|
|
37
49
|
const l = {
|
|
38
50
|
active: "text-success font-medium",
|
|
39
51
|
inactive: "text-muted-foreground",
|
|
@@ -48,86 +60,138 @@ const E = ["data-state"], H = { class: "flex items-center justify-center" }, I =
|
|
|
48
60
|
high: "text-destructive font-medium",
|
|
49
61
|
medium: "text-warning font-medium",
|
|
50
62
|
low: "text-muted-foreground"
|
|
51
|
-
}, t = String(
|
|
63
|
+
}, t = String(n).toLowerCase().replace(/[-_\s]/g, "");
|
|
52
64
|
return l[t] || "";
|
|
53
|
-
},
|
|
65
|
+
}, E = (n) => ({
|
|
54
66
|
left: "text-left",
|
|
55
67
|
center: "text-center",
|
|
56
68
|
right: "text-right"
|
|
57
|
-
})[
|
|
58
|
-
const { size:
|
|
59
|
-
return
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
})[n.align || "left"], M = f(() => a(s.row, s.keyField)), T = () => {
|
|
70
|
+
const { size: n, compact: l, cellBordered: t } = s;
|
|
71
|
+
return n === "xs" || l ? `py-1.5! -text-fs-1.5! ${t ? "px-3!" : "pr-4 max-sm:pr-10!"}` : n === "sm" ? `py-2! -text-fs-1.5! ${t ? "px-3!" : "pr-5 max-sm:pr-10!"}` : n === "lg" ? `py-4! text-base ${t ? "px-4!" : "pr-7 max-sm:pr-12!"}` : `py-3! -text-fs-1.5! ${t ? "px-3.5!" : "pr-6! max-sm:pr-10!"}`;
|
|
72
|
+
}, m = H, z = f(
|
|
73
|
+
() => s.treeMode ? m + s.depth * s.treeIndent : 0
|
|
74
|
+
), $ = f(
|
|
75
|
+
() => m + s.depth * s.treeIndent + O + h
|
|
76
|
+
), F = () => {
|
|
77
|
+
u("rowClick", { row: s.row, index: s.index });
|
|
78
|
+
}, N = () => {
|
|
79
|
+
u("select", M.value);
|
|
80
|
+
}, W = (n) => {
|
|
81
|
+
n.stopPropagation(), u("toggleExpand");
|
|
64
82
|
};
|
|
65
|
-
return (
|
|
66
|
-
class:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
return (n, l) => (o(), d("tr", {
|
|
84
|
+
class: g(["border-b data-[state=selected]:bg-muted h-full", [
|
|
85
|
+
e.hoverable ? "hover:bg-muted/20" : "",
|
|
86
|
+
e.striped && e.index % 2 === 1 ? "bg-muted/20" : "bg-background",
|
|
87
|
+
e.isSelected ? "bg-muted! hover:bg-muted/30" : "",
|
|
70
88
|
"group"
|
|
71
89
|
]]),
|
|
72
|
-
"data-state":
|
|
73
|
-
onClick:
|
|
90
|
+
"data-state": e.isSelected ? "selected" : void 0,
|
|
91
|
+
onClick: F
|
|
74
92
|
}, [
|
|
75
|
-
|
|
93
|
+
e.selectable ? (o(), d("td", {
|
|
76
94
|
key: 0,
|
|
77
95
|
class: "px-0! py-1! align-middle text-center",
|
|
78
|
-
onClick: l[0] || (l[0] =
|
|
96
|
+
onClick: l[0] || (l[0] = A(() => {
|
|
79
97
|
}, ["stop"]))
|
|
80
98
|
}, [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"model-value":
|
|
99
|
+
b("div", Z, [
|
|
100
|
+
v(U, {
|
|
101
|
+
"model-value": e.isSelected,
|
|
102
|
+
indeterminate: e.isIndeterminate,
|
|
84
103
|
size: "xs",
|
|
85
|
-
"onUpdate:modelValue":
|
|
86
|
-
}, null, 8, ["model-value"])
|
|
104
|
+
"onUpdate:modelValue": N
|
|
105
|
+
}, null, 8, ["model-value", "indeterminate"])
|
|
87
106
|
])
|
|
88
|
-
])) :
|
|
89
|
-
(o(!0),
|
|
107
|
+
])) : x("", !0),
|
|
108
|
+
(o(!0), d(p, null, D(e.headers, (t, i) => (o(), d("td", {
|
|
90
109
|
key: t.field,
|
|
91
|
-
class:
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
class: g(["align-middle whitespace-normal wrap-break-word", [
|
|
111
|
+
T(),
|
|
112
|
+
E(t),
|
|
94
113
|
t.hideOnMobile ? "hidden md:table-cell" : "",
|
|
95
|
-
|
|
114
|
+
e.treeMode ? "max-w-none min-w-0" : "max-w-[400px]",
|
|
115
|
+
// Keep overflow clip on data cells; last column (actions) must stay visible
|
|
116
|
+
i === e.headers.length - 1 ? "overflow-visible" : "overflow-hidden",
|
|
117
|
+
// Tree chrome overlays the whole first cell (incl. padding) so branch
|
|
118
|
+
// lines join seamlessly across rows. overflow-visible lets the connector
|
|
119
|
+
// overlay bleed across the collapsed row border for continuous trunks.
|
|
120
|
+
e.treeMode && i === 0 ? "relative pl-0! overflow-visible!" : "",
|
|
121
|
+
B(t, a(e.row, t.field), e.row)
|
|
96
122
|
]]),
|
|
97
|
-
style:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
123
|
+
style: w(
|
|
124
|
+
e.treeMode ? void 0 : {
|
|
125
|
+
...t.width && !/(?:^|\s|:)w-/.test(t.width) ? { width: t.width } : {},
|
|
126
|
+
...t.minWidth && !/(?:^|\s|:)min-w-/.test(t.minWidth) ? { minWidth: t.minWidth } : {}
|
|
127
|
+
}
|
|
128
|
+
)
|
|
101
129
|
}, [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
e.treeMode && i === 0 ? (o(), d(p, { key: 0 }, [
|
|
131
|
+
v(y(R), {
|
|
132
|
+
depth: e.depth,
|
|
133
|
+
"is-last-sibling": e.isLastSibling,
|
|
134
|
+
"ancestor-last-flags": e.ancestorLastFlags,
|
|
135
|
+
"has-toggle": e.expandable,
|
|
136
|
+
indent: e.treeIndent,
|
|
137
|
+
"base-inset": y(m),
|
|
138
|
+
"content-gap": y(h),
|
|
139
|
+
"bleed-y": ""
|
|
140
|
+
}, null, 8, ["depth", "is-last-sibling", "ancestor-last-flags", "has-toggle", "indent", "base-inset", "content-gap"]),
|
|
141
|
+
e.expandable ? (o(), d("button", {
|
|
142
|
+
key: 0,
|
|
143
|
+
type: "button",
|
|
144
|
+
class: "absolute z-10 top-1/2 -translate-y-1/2 flex h-6 w-6 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground transition-colors focus:outline-none",
|
|
145
|
+
style: w({ left: z.value + "px" }),
|
|
146
|
+
"aria-expanded": e.expanded,
|
|
147
|
+
onClick: W
|
|
148
|
+
}, [
|
|
149
|
+
e.treeLoading ? (o(), c(k, {
|
|
150
|
+
key: 0,
|
|
151
|
+
icon: "lucide:loader-2",
|
|
152
|
+
class: "h-4 w-4 animate-spin"
|
|
153
|
+
})) : (o(), c(k, {
|
|
154
|
+
key: 1,
|
|
155
|
+
icon: e.expanded ? "lucide:chevron-down" : "lucide:chevron-right",
|
|
156
|
+
class: "h-4 w-4"
|
|
157
|
+
}, null, 8, ["icon"]))
|
|
158
|
+
], 12, q)) : x("", !0)
|
|
159
|
+
], 64)) : x("", !0),
|
|
160
|
+
b("div", {
|
|
161
|
+
class: g([
|
|
162
|
+
"w-full min-w-0",
|
|
163
|
+
e.treeMode && i === 0 ? "relative flex items-center min-h-[28px] max-h-[80px] overflow-y-auto" : i === e.headers.length - 1 ? "overflow-visible" : "max-h-[80px] overflow-y-auto"
|
|
164
|
+
]),
|
|
165
|
+
style: w(e.treeMode && i === 0 ? { paddingLeft: $.value + "px" } : void 0)
|
|
166
|
+
}, [
|
|
167
|
+
I(n.$slots, t.field, {
|
|
168
|
+
value: a(e.row, t.field),
|
|
169
|
+
row: e.row,
|
|
170
|
+
index: e.index,
|
|
107
171
|
field: t.field
|
|
108
172
|
}, () => [
|
|
109
|
-
t.type === "price" ? (o(),
|
|
173
|
+
t.type === "price" ? (o(), c(G, {
|
|
110
174
|
key: 0,
|
|
111
|
-
value:
|
|
175
|
+
value: a(e.row, t.field),
|
|
112
176
|
class: "block",
|
|
113
|
-
title: String(
|
|
114
|
-
}, null, 8, ["value", "title"])) : t.type === "date" ? (o(),
|
|
177
|
+
title: String(a(e.row, t.field))
|
|
178
|
+
}, null, 8, ["value", "title"])) : t.type === "date" ? (o(), c(P, {
|
|
115
179
|
key: 1,
|
|
116
|
-
value:
|
|
180
|
+
value: a(e.row, t.field),
|
|
117
181
|
class: "block",
|
|
118
|
-
title: String(
|
|
119
|
-
}, null, 8, ["value", "title"])) : (o(),
|
|
182
|
+
title: String(a(e.row, t.field))
|
|
183
|
+
}, null, 8, ["value", "title"])) : (o(), d("span", {
|
|
120
184
|
key: 2,
|
|
121
185
|
class: "block",
|
|
122
|
-
title: String(
|
|
123
|
-
innerHTML:
|
|
124
|
-
}, null, 8,
|
|
186
|
+
title: String(a(e.row, t.field)),
|
|
187
|
+
innerHTML: S(t, a(e.row, t.field), e.row)
|
|
188
|
+
}, null, 8, J))
|
|
125
189
|
])
|
|
126
|
-
])
|
|
190
|
+
], 6)
|
|
127
191
|
], 6))), 128))
|
|
128
|
-
], 10,
|
|
192
|
+
], 10, j));
|
|
129
193
|
}
|
|
130
194
|
});
|
|
131
195
|
export {
|
|
132
|
-
|
|
196
|
+
ne as default
|
|
133
197
|
};
|
|
@@ -73,6 +73,16 @@ export interface DataTableProps {
|
|
|
73
73
|
variant?: 'default' | 'raised';
|
|
74
74
|
headerVariant?: 'default' | 'minimal';
|
|
75
75
|
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
76
|
+
/**
|
|
77
|
+
* Async loader for nested rows. Called when a row with `hasChildren: true`
|
|
78
|
+
* (and no cached/static `children`) is expanded. Return value is cached internally.
|
|
79
|
+
*/
|
|
80
|
+
loadChildren?: (row: any) => Promise<any[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Horizontal indent per tree depth level in px. Applied by DataTable to the first column.
|
|
83
|
+
* @default 20
|
|
84
|
+
*/
|
|
85
|
+
treeIndent?: number;
|
|
76
86
|
}
|
|
77
87
|
export interface SelectionState {
|
|
78
88
|
selected: any[];
|
|
@@ -83,6 +93,26 @@ export interface RowClickPayload {
|
|
|
83
93
|
row: any;
|
|
84
94
|
index: number;
|
|
85
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Emitted when a tree row is expanded or collapsed.
|
|
98
|
+
* Row conventions: `children?: any[]` (static) and/or `hasChildren?: boolean` (async marker).
|
|
99
|
+
*/
|
|
100
|
+
export interface ExpandPayload {
|
|
101
|
+
row: any;
|
|
102
|
+
expanded: boolean;
|
|
103
|
+
children?: any[];
|
|
104
|
+
depth: number;
|
|
105
|
+
}
|
|
106
|
+
/** Flattened visible tree row metadata used internally by DataTable. */
|
|
107
|
+
export interface DataTableFlatRow {
|
|
108
|
+
row: any;
|
|
109
|
+
id: any;
|
|
110
|
+
depth: number;
|
|
111
|
+
parentId: any | null;
|
|
112
|
+
isLastSibling: boolean;
|
|
113
|
+
ancestorLastFlags: boolean[];
|
|
114
|
+
index: number;
|
|
115
|
+
}
|
|
86
116
|
/**
|
|
87
117
|
* Shape provided by Screen to all deeply nested components via provide/inject.
|
|
88
118
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { DataTableFlatRow, ExpandPayload } from './types';
|
|
3
|
+
export interface UseDataTableTreeOptions {
|
|
4
|
+
rows: Ref<any[]> | ComputedRef<any[]>;
|
|
5
|
+
keyField: Ref<string> | ComputedRef<string>;
|
|
6
|
+
loadChildren?: Ref<((row: any) => Promise<any[]>) | undefined> | ComputedRef<((row: any) => Promise<any[]>) | undefined>;
|
|
7
|
+
getRowId: (row: any, keyField: string) => any;
|
|
8
|
+
onExpand: (payload: ExpandPayload) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function useDataTableTree({ rows, keyField, loadChildren, getRowId, onExpand, }: UseDataTableTreeOptions): {
|
|
11
|
+
isTreeMode: ComputedRef<boolean>;
|
|
12
|
+
expandedKeys: Ref<Set<any> & Omit<Set<any>, keyof Set<any>>, Set<any> | (Set<any> & Omit<Set<any>, keyof Set<any>>)>;
|
|
13
|
+
loadingKeys: Ref<Set<any> & Omit<Set<any>, keyof Set<any>>, Set<any> | (Set<any> & Omit<Set<any>, keyof Set<any>>)>;
|
|
14
|
+
childrenCache: Ref<Map<any, any[]> & Omit<Map<any, any[]>, keyof Map<any, any>>, Map<any, any[]> | (Map<any, any[]> & Omit<Map<any, any[]>, keyof Map<any, any>>)>;
|
|
15
|
+
flattenVisibleRows: ComputedRef<DataTableFlatRow[]>;
|
|
16
|
+
allLoadedRows: ComputedRef<Map<any, any>>;
|
|
17
|
+
getChildren: (row: any) => any[];
|
|
18
|
+
isExpandable: (row: any) => boolean;
|
|
19
|
+
isExpanded: (id: any) => boolean;
|
|
20
|
+
isLoading: (id: any) => boolean;
|
|
21
|
+
collectDescendantIds: (row: any) => any[];
|
|
22
|
+
toggleExpand: (row: any, depth: number) => Promise<void>;
|
|
23
|
+
pruneStaleTreeState: () => void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ref as x, computed as E } from "vue";
|
|
2
|
+
const y = "children", Y = "hasChildren";
|
|
3
|
+
function H(o) {
|
|
4
|
+
const l = o?.[y];
|
|
5
|
+
return Array.isArray(l) && l.length > 0;
|
|
6
|
+
}
|
|
7
|
+
function L(o) {
|
|
8
|
+
return o?.[Y] === !0;
|
|
9
|
+
}
|
|
10
|
+
function k({
|
|
11
|
+
rows: o,
|
|
12
|
+
keyField: l,
|
|
13
|
+
loadChildren: p,
|
|
14
|
+
getRowId: f,
|
|
15
|
+
onExpand: A
|
|
16
|
+
}) {
|
|
17
|
+
const u = x(/* @__PURE__ */ new Set()), v = x(/* @__PURE__ */ new Set()), r = x(/* @__PURE__ */ new Map()), C = E(() => {
|
|
18
|
+
if (p?.value) return !0;
|
|
19
|
+
const e = (t) => {
|
|
20
|
+
for (const n of t) {
|
|
21
|
+
if (H(n) || L(n)) return !0;
|
|
22
|
+
const a = n?.[y];
|
|
23
|
+
if (Array.isArray(a) && e(a)) return !0;
|
|
24
|
+
}
|
|
25
|
+
return !1;
|
|
26
|
+
};
|
|
27
|
+
return e(o.value || []);
|
|
28
|
+
}), h = (e) => {
|
|
29
|
+
const t = f(e, l.value);
|
|
30
|
+
if (r.value.has(t))
|
|
31
|
+
return r.value.get(t) || [];
|
|
32
|
+
const n = e?.[y];
|
|
33
|
+
return Array.isArray(n) ? n : [];
|
|
34
|
+
}, b = (e) => {
|
|
35
|
+
const t = f(e, l.value);
|
|
36
|
+
return r.value.has(t) ? (r.value.get(t) || []).length > 0 : H(e) ? !0 : L(e);
|
|
37
|
+
}, K = (e) => u.value.has(e), _ = (e) => v.value.has(e), m = (e) => {
|
|
38
|
+
const t = [], n = (a) => {
|
|
39
|
+
for (const s of h(a))
|
|
40
|
+
t.push(f(s, l.value)), n(s);
|
|
41
|
+
};
|
|
42
|
+
return n(e), t;
|
|
43
|
+
}, N = E(() => {
|
|
44
|
+
if (!C.value)
|
|
45
|
+
return (o.value || []).map((a, s) => ({
|
|
46
|
+
row: a,
|
|
47
|
+
id: f(a, l.value),
|
|
48
|
+
depth: 0,
|
|
49
|
+
parentId: null,
|
|
50
|
+
isLastSibling: s === (o.value || []).length - 1,
|
|
51
|
+
ancestorLastFlags: [],
|
|
52
|
+
index: s
|
|
53
|
+
}));
|
|
54
|
+
const e = [];
|
|
55
|
+
let t = 0;
|
|
56
|
+
const n = (a, s, d, S) => {
|
|
57
|
+
a.forEach((c, i) => {
|
|
58
|
+
const g = f(c, l.value), T = i === a.length - 1;
|
|
59
|
+
if (e.push({
|
|
60
|
+
row: c,
|
|
61
|
+
id: g,
|
|
62
|
+
depth: s,
|
|
63
|
+
parentId: d,
|
|
64
|
+
isLastSibling: T,
|
|
65
|
+
ancestorLastFlags: [...S],
|
|
66
|
+
index: t++
|
|
67
|
+
}), u.value.has(g)) {
|
|
68
|
+
const D = h(c);
|
|
69
|
+
D.length > 0 && n(D, s + 1, g, [...S, T]);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return n(o.value || [], 0, null, []), e;
|
|
74
|
+
}), M = E(() => {
|
|
75
|
+
const e = /* @__PURE__ */ new Map(), t = (n) => {
|
|
76
|
+
for (const a of n) {
|
|
77
|
+
const s = f(a, l.value);
|
|
78
|
+
e.set(s, a);
|
|
79
|
+
for (const d of h(a))
|
|
80
|
+
t([d]);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return t(o.value || []), e;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
isTreeMode: C,
|
|
87
|
+
expandedKeys: u,
|
|
88
|
+
loadingKeys: v,
|
|
89
|
+
childrenCache: r,
|
|
90
|
+
flattenVisibleRows: N,
|
|
91
|
+
allLoadedRows: M,
|
|
92
|
+
getChildren: h,
|
|
93
|
+
isExpandable: b,
|
|
94
|
+
isExpanded: K,
|
|
95
|
+
isLoading: _,
|
|
96
|
+
collectDescendantIds: m,
|
|
97
|
+
toggleExpand: async (e, t) => {
|
|
98
|
+
if (!b(e)) return;
|
|
99
|
+
const n = f(e, l.value);
|
|
100
|
+
if (u.value.has(n)) {
|
|
101
|
+
const c = new Set(u.value);
|
|
102
|
+
c.delete(n);
|
|
103
|
+
for (const i of m(e))
|
|
104
|
+
c.delete(i);
|
|
105
|
+
u.value = c, A({ row: e, expanded: !1, children: h(e), depth: t });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const s = new Set(u.value);
|
|
109
|
+
s.add(n), u.value = s;
|
|
110
|
+
let d = h(e);
|
|
111
|
+
if (!!p?.value && d.length === 0 && L(e) && !r.value.has(n) && p?.value) {
|
|
112
|
+
const c = new Set(v.value);
|
|
113
|
+
c.add(n), v.value = c;
|
|
114
|
+
try {
|
|
115
|
+
d = await p.value(e) || [];
|
|
116
|
+
const i = new Map(r.value);
|
|
117
|
+
i.set(n, d), r.value = i;
|
|
118
|
+
} finally {
|
|
119
|
+
const i = new Set(v.value);
|
|
120
|
+
i.delete(n), v.value = i;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
A({ row: e, expanded: !0, children: d, depth: t });
|
|
124
|
+
},
|
|
125
|
+
pruneStaleTreeState: () => {
|
|
126
|
+
const e = new Set(M.value.keys());
|
|
127
|
+
u.value = new Set([...u.value].filter((n) => e.has(n))), v.value = new Set([...v.value].filter((n) => e.has(n)));
|
|
128
|
+
const t = /* @__PURE__ */ new Map();
|
|
129
|
+
r.value.forEach((n, a) => {
|
|
130
|
+
e.has(a) && t.set(a, n);
|
|
131
|
+
}), r.value = t;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
k as useDataTableTree
|
|
137
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./FileTree.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-
|
|
4
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-773b0a78"]]);
|
|
5
5
|
export {
|
|
6
6
|
m as default
|
|
7
7
|
};
|