@leavepulse/ui 0.14.9 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/LpFileTree-D0DEpKof.js +375 -0
- package/dist/chunks/LpFileTreeNode-3e71ywJV.js +227 -0
- package/dist/component-names.d.ts +1 -1
- package/dist/components/LpFileTree.vue.d.ts +106 -0
- package/dist/components/LpFileTree.vue.js +4 -0
- package/dist/components/LpFileTreeNode.vue.d.ts +45 -0
- package/dist/components/LpFileTreeNode.vue.js +4 -0
- package/dist/components/LpLogViewer.vue.d.ts +1 -1
- package/dist/components/fileTree.d.ts +63 -0
- package/dist/components/fileTree.js +172 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +86 -74
- package/package.json +3 -2
- package/src/component-names.ts +2 -0
- package/src/components/LpFileTree.vue +518 -0
- package/src/components/LpFileTreeNode.vue +285 -0
- package/src/components/fileTree.ts +239 -0
- package/src/index.ts +14 -0
- package/src/tokens/tokens.css +22 -6
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, computed, openBlock, createElementBlock, Fragment, renderList, normalizeStyle, createBlock, createVNode, withCtx, createElementVNode, renderSlot, mergeProps, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
+
import { subtreeIds, subtreeSize, formatSize, sortNodes, ancestorIds, checkStateOf } from "../components/fileTree.js";
|
|
3
|
+
import { _ as _sfc_main$1 } from "./LpEmptyState-CrfyRJUG.js";
|
|
4
|
+
import { _ as _sfc_main$3 } from "./LpFileTreeNode-3e71ywJV.js";
|
|
5
|
+
import { _ as _sfc_main$2 } from "./LpScrollArea-BtnZCCBT.js";
|
|
6
|
+
const _hoisted_1 = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "flex flex-col gap-1"
|
|
9
|
+
};
|
|
10
|
+
const _hoisted_2 = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "flex h-full min-h-0 flex-col"
|
|
13
|
+
};
|
|
14
|
+
const _hoisted_3 = ["aria-multiselectable"];
|
|
15
|
+
const _hoisted_4 = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "shrink-0 border-t border-line px-2 py-1.5 text-xs text-muted"
|
|
18
|
+
};
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
20
|
+
__name: "LpFileTree",
|
|
21
|
+
props: {
|
|
22
|
+
nodes: {},
|
|
23
|
+
selected: {},
|
|
24
|
+
expanded: {},
|
|
25
|
+
loadingIds: {},
|
|
26
|
+
checkable: { type: Boolean, default: false },
|
|
27
|
+
checked: {},
|
|
28
|
+
showSize: { type: Boolean, default: false },
|
|
29
|
+
showModified: { type: Boolean, default: false },
|
|
30
|
+
sort: { type: Boolean, default: true },
|
|
31
|
+
iconSize: { default: 15 },
|
|
32
|
+
loading: { type: Boolean, default: false },
|
|
33
|
+
skeletonRows: { default: 8 },
|
|
34
|
+
emptyLabel: { default: "No files" },
|
|
35
|
+
emptyDescription: { default: "This folder is empty." }
|
|
36
|
+
},
|
|
37
|
+
emits: ["update:selected", "update:expanded", "select", "open", "expand", "collapse", "update:checked", "summary"],
|
|
38
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
39
|
+
const props = __props;
|
|
40
|
+
const emit = __emit;
|
|
41
|
+
const openIds = ref(new Set(props.expanded ?? []));
|
|
42
|
+
watch(
|
|
43
|
+
() => props.expanded,
|
|
44
|
+
(ids) => {
|
|
45
|
+
if (ids) openIds.value = new Set(ids);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
const loadingSet = computed(() => new Set(props.loadingIds ?? []));
|
|
49
|
+
const checkedIds = ref(new Set(props.checked ?? []));
|
|
50
|
+
watch(
|
|
51
|
+
() => props.checked,
|
|
52
|
+
(ids) => {
|
|
53
|
+
if (ids) checkedIds.value = new Set(ids);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
const byId = computed(() => {
|
|
57
|
+
const map = /* @__PURE__ */ new Map();
|
|
58
|
+
function walk(list) {
|
|
59
|
+
for (const node of list) {
|
|
60
|
+
map.set(node.id, node);
|
|
61
|
+
if (node.children) walk(node.children);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
walk(props.nodes);
|
|
65
|
+
return map;
|
|
66
|
+
});
|
|
67
|
+
const summary = computed(() => {
|
|
68
|
+
let files = 0;
|
|
69
|
+
let dirs = 0;
|
|
70
|
+
let bytes = 0;
|
|
71
|
+
let sized = false;
|
|
72
|
+
for (const id of checkedIds.value) {
|
|
73
|
+
const node = byId.value.get(id);
|
|
74
|
+
if (!node) continue;
|
|
75
|
+
if (node.kind === "dir") {
|
|
76
|
+
dirs++;
|
|
77
|
+
const inside = node.children?.length ? subtreeIds(node).some((child) => child !== id && checkedIds.value.has(child)) : false;
|
|
78
|
+
if (!inside) {
|
|
79
|
+
const size = subtreeSize(node);
|
|
80
|
+
if (size !== void 0) {
|
|
81
|
+
bytes += size;
|
|
82
|
+
sized = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
files++;
|
|
87
|
+
if (node.size !== void 0) {
|
|
88
|
+
bytes += node.size;
|
|
89
|
+
sized = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
files,
|
|
95
|
+
dirs,
|
|
96
|
+
bytes: sized ? bytes : void 0,
|
|
97
|
+
sizeLabel: sized ? formatSize(bytes) : "—"
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
watch(summary, (value) => emit("summary", value), { deep: false });
|
|
101
|
+
function setChecked(next) {
|
|
102
|
+
checkedIds.value = next;
|
|
103
|
+
emit("update:checked", [...next]);
|
|
104
|
+
}
|
|
105
|
+
function onCheck(node, value) {
|
|
106
|
+
if (node.disabled) return;
|
|
107
|
+
const next = new Set(checkedIds.value);
|
|
108
|
+
for (const id of subtreeIds(node)) {
|
|
109
|
+
const target = byId.value.get(id);
|
|
110
|
+
if (target?.disabled) continue;
|
|
111
|
+
if (value) next.add(id);
|
|
112
|
+
else next.delete(id);
|
|
113
|
+
}
|
|
114
|
+
for (const ancestorId of ancestorIds(props.nodes, node.id).reverse()) {
|
|
115
|
+
const ancestor = byId.value.get(ancestorId);
|
|
116
|
+
if (!ancestor?.children?.length) continue;
|
|
117
|
+
const all = ancestor.children.every((c) => c.disabled || next.has(c.id));
|
|
118
|
+
if (all) next.add(ancestorId);
|
|
119
|
+
else next.delete(ancestorId);
|
|
120
|
+
}
|
|
121
|
+
setChecked(next);
|
|
122
|
+
}
|
|
123
|
+
function checkAll() {
|
|
124
|
+
const next = /* @__PURE__ */ new Set();
|
|
125
|
+
for (const [id, node] of byId.value) if (!node.disabled) next.add(id);
|
|
126
|
+
setChecked(next);
|
|
127
|
+
}
|
|
128
|
+
function clearChecked() {
|
|
129
|
+
setChecked(/* @__PURE__ */ new Set());
|
|
130
|
+
}
|
|
131
|
+
const requested = /* @__PURE__ */ new Set();
|
|
132
|
+
const roots = computed(() => props.sort ? sortNodes(props.nodes) : props.nodes);
|
|
133
|
+
const visible = computed(() => {
|
|
134
|
+
const out = [];
|
|
135
|
+
function walk(list) {
|
|
136
|
+
for (const node of props.sort ? sortNodes(list) : list) {
|
|
137
|
+
out.push(node);
|
|
138
|
+
if (node.kind === "dir" && openIds.value.has(node.id) && node.children?.length) {
|
|
139
|
+
walk(node.children);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
walk(props.nodes);
|
|
144
|
+
return out;
|
|
145
|
+
});
|
|
146
|
+
const focusedId = ref(props.selected);
|
|
147
|
+
watch(
|
|
148
|
+
() => props.selected,
|
|
149
|
+
(id) => {
|
|
150
|
+
if (id) focusedId.value = id;
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
watch(
|
|
154
|
+
visible,
|
|
155
|
+
(rows) => {
|
|
156
|
+
if (!rows.length) {
|
|
157
|
+
focusedId.value = void 0;
|
|
158
|
+
} else if (!rows.some((n) => n.id === focusedId.value)) {
|
|
159
|
+
focusedId.value = rows[0].id;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{ immediate: true }
|
|
163
|
+
);
|
|
164
|
+
const root = ref(null);
|
|
165
|
+
function focusRow(id) {
|
|
166
|
+
focusedId.value = id;
|
|
167
|
+
const el = root.value?.querySelector(`[data-node-id="${CSS.escape(id)}"]`);
|
|
168
|
+
el?.focus();
|
|
169
|
+
el?.scrollIntoView({ block: "nearest" });
|
|
170
|
+
}
|
|
171
|
+
function setExpanded(next) {
|
|
172
|
+
openIds.value = next;
|
|
173
|
+
emit("update:expanded", [...next]);
|
|
174
|
+
}
|
|
175
|
+
function expand(node) {
|
|
176
|
+
if (node.kind !== "dir" || openIds.value.has(node.id)) return;
|
|
177
|
+
const next = new Set(openIds.value);
|
|
178
|
+
next.add(node.id);
|
|
179
|
+
setExpanded(next);
|
|
180
|
+
if (node.children === void 0 && !requested.has(node.id)) {
|
|
181
|
+
requested.add(node.id);
|
|
182
|
+
emit("expand", node);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function collapse(node) {
|
|
186
|
+
if (!openIds.value.has(node.id)) return;
|
|
187
|
+
const next = new Set(openIds.value);
|
|
188
|
+
next.delete(node.id);
|
|
189
|
+
setExpanded(next);
|
|
190
|
+
emit("collapse", node);
|
|
191
|
+
}
|
|
192
|
+
function onToggle(node) {
|
|
193
|
+
if (openIds.value.has(node.id)) collapse(node);
|
|
194
|
+
else expand(node);
|
|
195
|
+
}
|
|
196
|
+
function onSelect(node) {
|
|
197
|
+
if (node.disabled) return;
|
|
198
|
+
if (props.selected === node.id) {
|
|
199
|
+
emit("update:selected", "");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
emit("update:selected", node.id);
|
|
203
|
+
emit("select", node);
|
|
204
|
+
if (node.kind === "file") emit("open", node);
|
|
205
|
+
}
|
|
206
|
+
function parentOf(id) {
|
|
207
|
+
const trail = ancestorIds(props.nodes, id);
|
|
208
|
+
const parentId = trail.at(-1);
|
|
209
|
+
return parentId ? visible.value.find((n) => n.id === parentId) : void 0;
|
|
210
|
+
}
|
|
211
|
+
function move(delta) {
|
|
212
|
+
const rows = visible.value;
|
|
213
|
+
if (!rows.length) return;
|
|
214
|
+
const i = rows.findIndex((n) => n.id === focusedId.value);
|
|
215
|
+
const next = rows[Math.min(rows.length - 1, Math.max(0, (i < 0 ? 0 : i) + delta))];
|
|
216
|
+
if (next) focusRow(next.id);
|
|
217
|
+
}
|
|
218
|
+
function current() {
|
|
219
|
+
return visible.value.find((n) => n.id === focusedId.value);
|
|
220
|
+
}
|
|
221
|
+
function onKeydown(e) {
|
|
222
|
+
const node = current();
|
|
223
|
+
switch (e.key) {
|
|
224
|
+
case "ArrowDown":
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
move(1);
|
|
227
|
+
break;
|
|
228
|
+
case "ArrowUp":
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
move(-1);
|
|
231
|
+
break;
|
|
232
|
+
case "ArrowRight": {
|
|
233
|
+
if (!node) return;
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
if (node.kind === "dir" && !openIds.value.has(node.id)) expand(node);
|
|
236
|
+
else if (node.kind === "dir" && node.children?.length) move(1);
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case "ArrowLeft": {
|
|
240
|
+
if (!node) return;
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
if (node.kind === "dir" && openIds.value.has(node.id)) collapse(node);
|
|
243
|
+
else {
|
|
244
|
+
const parent = parentOf(node.id);
|
|
245
|
+
if (parent) focusRow(parent.id);
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case "Home":
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
if (visible.value[0]) focusRow(visible.value[0].id);
|
|
252
|
+
break;
|
|
253
|
+
case "End": {
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
const last = visible.value.at(-1);
|
|
256
|
+
if (last) focusRow(last.id);
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
case " ": {
|
|
260
|
+
if (!node) return;
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
if (props.checkable) {
|
|
263
|
+
onCheck(node, checkStateOf(node, checkedIds.value) !== "checked");
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
onSelect(node);
|
|
267
|
+
if (node.kind === "dir") onToggle(node);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "Enter": {
|
|
271
|
+
if (!node) return;
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
onSelect(node);
|
|
274
|
+
if (node.kind === "dir") onToggle(node);
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function reveal(id) {
|
|
280
|
+
const next = new Set(openIds.value);
|
|
281
|
+
for (const ancestor of ancestorIds(props.nodes, id)) next.add(ancestor);
|
|
282
|
+
setExpanded(next);
|
|
283
|
+
emit("update:selected", id);
|
|
284
|
+
requestAnimationFrame(() => focusRow(id));
|
|
285
|
+
}
|
|
286
|
+
function expandAll() {
|
|
287
|
+
const next = new Set(openIds.value);
|
|
288
|
+
function walk(list) {
|
|
289
|
+
for (const node of list) {
|
|
290
|
+
if (node.kind === "dir" && node.children?.length) {
|
|
291
|
+
next.add(node.id);
|
|
292
|
+
walk(node.children);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
walk(props.nodes);
|
|
297
|
+
setExpanded(next);
|
|
298
|
+
}
|
|
299
|
+
function collapseAll() {
|
|
300
|
+
setExpanded(/* @__PURE__ */ new Set());
|
|
301
|
+
}
|
|
302
|
+
__expose({ reveal, expandAll, collapseAll, checkAll, clearChecked, summary });
|
|
303
|
+
return (_ctx, _cache) => {
|
|
304
|
+
return __props.loading ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
305
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.skeletonRows, (n) => {
|
|
306
|
+
return openBlock(), createElementBlock("div", {
|
|
307
|
+
key: n,
|
|
308
|
+
class: "h-7 animate-pulse rounded-control bg-surface-soft",
|
|
309
|
+
style: normalizeStyle({ marginLeft: `${n % 3 * 14}px` })
|
|
310
|
+
}, null, 4);
|
|
311
|
+
}), 128))
|
|
312
|
+
])) : !roots.value.length ? (openBlock(), createBlock(_sfc_main$1, {
|
|
313
|
+
key: 1,
|
|
314
|
+
icon: "lucide:folder-search",
|
|
315
|
+
title: __props.emptyLabel,
|
|
316
|
+
description: __props.emptyDescription
|
|
317
|
+
}, null, 8, ["title", "description"])) : (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
318
|
+
createVNode(_sfc_main$2, { class: "min-h-0 flex-1" }, {
|
|
319
|
+
default: withCtx(() => [
|
|
320
|
+
createElementVNode("ul", {
|
|
321
|
+
ref_key: "root",
|
|
322
|
+
ref: root,
|
|
323
|
+
role: "tree",
|
|
324
|
+
"aria-multiselectable": __props.checkable,
|
|
325
|
+
class: "flex min-w-0 flex-col",
|
|
326
|
+
onKeydown
|
|
327
|
+
}, [
|
|
328
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(roots.value, (node) => {
|
|
329
|
+
return openBlock(), createBlock(_sfc_main$3, {
|
|
330
|
+
key: node.id,
|
|
331
|
+
node,
|
|
332
|
+
depth: 0,
|
|
333
|
+
expanded: openIds.value,
|
|
334
|
+
loading: loadingSet.value,
|
|
335
|
+
"selected-id": __props.selected,
|
|
336
|
+
"focused-id": focusedId.value,
|
|
337
|
+
sort: __props.sort,
|
|
338
|
+
"icon-size": __props.iconSize,
|
|
339
|
+
checkable: __props.checkable,
|
|
340
|
+
checked: checkedIds.value,
|
|
341
|
+
"show-size": __props.showSize,
|
|
342
|
+
"show-modified": __props.showModified,
|
|
343
|
+
onSelect,
|
|
344
|
+
onToggle,
|
|
345
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => focusedId.value = $event.id),
|
|
346
|
+
onCheck
|
|
347
|
+
}, {
|
|
348
|
+
row: withCtx((slotProps) => [
|
|
349
|
+
renderSlot(_ctx.$slots, "row", mergeProps({ ref_for: true }, slotProps))
|
|
350
|
+
]),
|
|
351
|
+
_: 3
|
|
352
|
+
}, 8, ["node", "expanded", "loading", "selected-id", "focused-id", "sort", "icon-size", "checkable", "checked", "show-size", "show-modified"]);
|
|
353
|
+
}), 128))
|
|
354
|
+
], 40, _hoisted_3)
|
|
355
|
+
]),
|
|
356
|
+
_: 3
|
|
357
|
+
}),
|
|
358
|
+
__props.checkable && (_ctx.$slots.summary || summary.value.files || summary.value.dirs) ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
359
|
+
renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps(summary.value)), () => [
|
|
360
|
+
createTextVNode(toDisplayString(summary.value.files) + " " + toDisplayString(summary.value.files === 1 ? "file" : "files"), 1),
|
|
361
|
+
summary.value.dirs ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
362
|
+
createTextVNode(", " + toDisplayString(summary.value.dirs) + " " + toDisplayString(summary.value.dirs === 1 ? "folder" : "folders"), 1)
|
|
363
|
+
], 64)) : createCommentVNode("", true),
|
|
364
|
+
summary.value.bytes !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
365
|
+
createTextVNode(" · " + toDisplayString(summary.value.sizeLabel), 1)
|
|
366
|
+
], 64)) : createCommentVNode("", true)
|
|
367
|
+
])
|
|
368
|
+
])) : createCommentVNode("", true)
|
|
369
|
+
]));
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
export {
|
|
374
|
+
_sfc_main as _
|
|
375
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { defineComponent, computed, resolveComponent, openBlock, createElementBlock, createVNode, withCtx, createElementVNode, withModifiers, normalizeStyle, normalizeClass, createBlock, createCommentVNode, unref, renderSlot, createTextVNode, toDisplayString, Transition, Fragment, renderList, mergeProps } from "vue";
|
|
2
|
+
import { sortNodes, checkStateOf, subtreeSize, formatSize, checkedCount, formatModified, fileIcon } from "../components/fileTree.js";
|
|
3
|
+
import { _ as _sfc_main$3 } from "./LpCheckbox-BO0zuuPh.js";
|
|
4
|
+
import { _ as _sfc_main$1 } from "./LpContextMenu-D0mzXqA7.js";
|
|
5
|
+
import { _ as _sfc_main$2 } from "./LpIcon-CCnX5_2j.js";
|
|
6
|
+
const _hoisted_1 = ["aria-level", "aria-selected", "aria-expanded", "aria-disabled"];
|
|
7
|
+
const _hoisted_2 = ["data-node-id", "tabindex"];
|
|
8
|
+
const _hoisted_3 = { class: "flex size-4 shrink-0 items-center justify-center" };
|
|
9
|
+
const _hoisted_4 = { class: "min-w-0 flex-1 truncate" };
|
|
10
|
+
const _hoisted_5 = {
|
|
11
|
+
key: 1,
|
|
12
|
+
class: "shrink-0 rounded-pill bg-brand-soft px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-brand"
|
|
13
|
+
};
|
|
14
|
+
const _hoisted_6 = {
|
|
15
|
+
key: 2,
|
|
16
|
+
class: "shrink-0 text-xs text-muted"
|
|
17
|
+
};
|
|
18
|
+
const _hoisted_7 = {
|
|
19
|
+
key: 3,
|
|
20
|
+
class: "shrink-0 text-xs tabular-nums text-muted/80"
|
|
21
|
+
};
|
|
22
|
+
const _hoisted_8 = {
|
|
23
|
+
key: 4,
|
|
24
|
+
class: "w-16 shrink-0 text-right text-xs tabular-nums text-muted"
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_9 = {
|
|
27
|
+
key: 0,
|
|
28
|
+
role: "group",
|
|
29
|
+
class: "flex min-w-0 flex-col overflow-hidden"
|
|
30
|
+
};
|
|
31
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
32
|
+
__name: "LpFileTreeNode",
|
|
33
|
+
props: {
|
|
34
|
+
node: {},
|
|
35
|
+
depth: {},
|
|
36
|
+
expanded: {},
|
|
37
|
+
loading: {},
|
|
38
|
+
selectedId: {},
|
|
39
|
+
focusedId: {},
|
|
40
|
+
sort: { type: Boolean },
|
|
41
|
+
iconSize: {},
|
|
42
|
+
checkable: { type: Boolean },
|
|
43
|
+
checked: {},
|
|
44
|
+
showSize: { type: Boolean },
|
|
45
|
+
showModified: { type: Boolean }
|
|
46
|
+
},
|
|
47
|
+
emits: ["select", "toggle", "focus", "check"],
|
|
48
|
+
setup(__props, { emit: __emit }) {
|
|
49
|
+
const props = __props;
|
|
50
|
+
const emit = __emit;
|
|
51
|
+
const isDir = computed(() => props.node.kind === "dir");
|
|
52
|
+
const isOpen = computed(() => isDir.value && props.expanded.has(props.node.id));
|
|
53
|
+
const isLoading = computed(() => props.loading.has(props.node.id));
|
|
54
|
+
const isSelected = computed(() => props.selectedId === props.node.id);
|
|
55
|
+
const isFocused = computed(() => props.focusedId === props.node.id);
|
|
56
|
+
const hasChildren = computed(() => isDir.value && (props.node.children?.length ?? 0) > 0);
|
|
57
|
+
const canExpand = computed(() => isDir.value && (props.node.children === void 0 || hasChildren.value));
|
|
58
|
+
const children = computed(() => {
|
|
59
|
+
const list = props.node.children ?? [];
|
|
60
|
+
return props.sort ? sortNodes(list) : list;
|
|
61
|
+
});
|
|
62
|
+
const checkState = computed(
|
|
63
|
+
() => props.checkable ? checkStateOf(props.node, props.checked) : "unchecked"
|
|
64
|
+
);
|
|
65
|
+
const sizeLabel = computed(() => {
|
|
66
|
+
if (!props.showSize) return "";
|
|
67
|
+
const bytes = subtreeSize(props.node);
|
|
68
|
+
return bytes === void 0 ? "" : formatSize(bytes);
|
|
69
|
+
});
|
|
70
|
+
const countLabel = computed(() => {
|
|
71
|
+
if (!props.checkable || !isDir.value) return "";
|
|
72
|
+
const { checked, total } = checkedCount(props.node, props.checked);
|
|
73
|
+
return total && checked && checked < total ? `${checked} / ${total}` : "";
|
|
74
|
+
});
|
|
75
|
+
const modifiedLabel = computed(
|
|
76
|
+
() => props.showModified && props.node.modified !== void 0 ? formatModified(props.node.modified) : ""
|
|
77
|
+
);
|
|
78
|
+
function rowDelay(index) {
|
|
79
|
+
return `${Math.min(index * 18, 180)}ms`;
|
|
80
|
+
}
|
|
81
|
+
function reducedMotion() {
|
|
82
|
+
return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
|
83
|
+
}
|
|
84
|
+
function onBranchEnter(el, done) {
|
|
85
|
+
if (reducedMotion()) return done();
|
|
86
|
+
const height = el.scrollHeight;
|
|
87
|
+
el.animate(
|
|
88
|
+
[
|
|
89
|
+
{ height: "0px", opacity: 0 },
|
|
90
|
+
{ height: `${height}px`, opacity: 1 }
|
|
91
|
+
],
|
|
92
|
+
{ duration: 220, easing: "cubic-bezier(0.2, 0, 0, 1)" }
|
|
93
|
+
).onfinish = () => done();
|
|
94
|
+
}
|
|
95
|
+
function onBranchLeave(el, done) {
|
|
96
|
+
if (reducedMotion()) return done();
|
|
97
|
+
const height = el.scrollHeight;
|
|
98
|
+
el.animate(
|
|
99
|
+
[
|
|
100
|
+
{ height: `${height}px`, opacity: 1 },
|
|
101
|
+
{ height: "0px", opacity: 0 }
|
|
102
|
+
],
|
|
103
|
+
{ duration: 180, easing: "cubic-bezier(0.2, 0, 0, 1)" }
|
|
104
|
+
).onfinish = () => done();
|
|
105
|
+
}
|
|
106
|
+
function onActivate() {
|
|
107
|
+
if (props.node.disabled) return;
|
|
108
|
+
emit("focus", props.node);
|
|
109
|
+
emit("select", props.node);
|
|
110
|
+
if (isDir.value) emit("toggle", props.node);
|
|
111
|
+
}
|
|
112
|
+
return (_ctx, _cache) => {
|
|
113
|
+
const _component_LpFileTreeNode = resolveComponent("LpFileTreeNode", true);
|
|
114
|
+
return openBlock(), createElementBlock("li", {
|
|
115
|
+
role: "treeitem",
|
|
116
|
+
class: "min-w-0",
|
|
117
|
+
"aria-level": __props.depth + 1,
|
|
118
|
+
"aria-selected": isSelected.value,
|
|
119
|
+
"aria-expanded": canExpand.value ? isOpen.value : void 0,
|
|
120
|
+
"aria-disabled": __props.node.disabled || void 0
|
|
121
|
+
}, [
|
|
122
|
+
createVNode(_sfc_main$1, {
|
|
123
|
+
items: __props.node.menu ?? []
|
|
124
|
+
}, {
|
|
125
|
+
default: withCtx(() => [
|
|
126
|
+
createElementVNode("div", {
|
|
127
|
+
"data-node-id": __props.node.id,
|
|
128
|
+
tabindex: isFocused.value ? 0 : -1,
|
|
129
|
+
class: normalizeClass(["group/row relative flex min-w-0 cursor-pointer select-none items-center gap-1.5 rounded-control py-1 pr-2 text-sm outline-none transition-colors duration-[var(--duration-fast)] focus-visible:ring-2 focus-visible:ring-ring", [
|
|
130
|
+
__props.node.disabled ? "cursor-not-allowed text-muted/50" : isSelected.value ? "bg-brand-soft text-ink" : "text-muted hover:bg-surface-soft hover:text-ink"
|
|
131
|
+
]]),
|
|
132
|
+
style: normalizeStyle({ paddingLeft: `${__props.depth * 14 + 6}px` }),
|
|
133
|
+
onClick: withModifiers(onActivate, ["stop"])
|
|
134
|
+
}, [
|
|
135
|
+
createElementVNode("span", _hoisted_3, [
|
|
136
|
+
isLoading.value ? (openBlock(), createBlock(_sfc_main$2, {
|
|
137
|
+
key: 0,
|
|
138
|
+
name: "lucide:loader-circle",
|
|
139
|
+
size: 13,
|
|
140
|
+
class: "animate-spin text-muted"
|
|
141
|
+
})) : canExpand.value ? (openBlock(), createBlock(_sfc_main$2, {
|
|
142
|
+
key: 1,
|
|
143
|
+
name: "lucide:chevron-right",
|
|
144
|
+
size: 14,
|
|
145
|
+
class: normalizeClass(["text-muted transition-transform duration-[var(--duration-fast)]", isOpen.value ? "rotate-90" : ""])
|
|
146
|
+
}, null, 8, ["class"])) : createCommentVNode("", true)
|
|
147
|
+
]),
|
|
148
|
+
__props.checkable ? (openBlock(), createBlock(_sfc_main$3, {
|
|
149
|
+
key: 0,
|
|
150
|
+
"model-value": checkState.value === "checked",
|
|
151
|
+
indeterminate: checkState.value === "indeterminate",
|
|
152
|
+
disabled: __props.node.disabled,
|
|
153
|
+
class: "shrink-0",
|
|
154
|
+
"aria-label": __props.node.name,
|
|
155
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
156
|
+
}, ["stop"])),
|
|
157
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => emit("check", __props.node, $event))
|
|
158
|
+
}, null, 8, ["model-value", "indeterminate", "disabled", "aria-label"])) : createCommentVNode("", true),
|
|
159
|
+
createVNode(_sfc_main$2, {
|
|
160
|
+
name: unref(fileIcon)(__props.node, isOpen.value),
|
|
161
|
+
size: __props.iconSize,
|
|
162
|
+
class: normalizeClass(["shrink-0", __props.node.disabled ? "" : isDir.value ? "text-brand" : "text-muted"])
|
|
163
|
+
}, null, 8, ["name", "size", "class"]),
|
|
164
|
+
createElementVNode("span", _hoisted_4, [
|
|
165
|
+
renderSlot(_ctx.$slots, "row", {
|
|
166
|
+
node: __props.node,
|
|
167
|
+
depth: __props.depth,
|
|
168
|
+
expanded: isOpen.value,
|
|
169
|
+
selected: isSelected.value
|
|
170
|
+
}, () => [
|
|
171
|
+
createTextVNode(toDisplayString(__props.node.name), 1)
|
|
172
|
+
])
|
|
173
|
+
]),
|
|
174
|
+
countLabel.value ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(countLabel.value), 1)) : createCommentVNode("", true),
|
|
175
|
+
__props.node.meta ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(__props.node.meta), 1)) : createCommentVNode("", true),
|
|
176
|
+
modifiedLabel.value ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(modifiedLabel.value), 1)) : createCommentVNode("", true),
|
|
177
|
+
sizeLabel.value ? (openBlock(), createElementBlock("span", _hoisted_8, toDisplayString(sizeLabel.value), 1)) : createCommentVNode("", true)
|
|
178
|
+
], 14, _hoisted_2)
|
|
179
|
+
]),
|
|
180
|
+
_: 3
|
|
181
|
+
}, 8, ["items"]),
|
|
182
|
+
createVNode(Transition, {
|
|
183
|
+
css: false,
|
|
184
|
+
onEnter: onBranchEnter,
|
|
185
|
+
onLeave: onBranchLeave
|
|
186
|
+
}, {
|
|
187
|
+
default: withCtx(() => [
|
|
188
|
+
isOpen.value && hasChildren.value ? (openBlock(), createElementBlock("ul", _hoisted_9, [
|
|
189
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(children.value, (child, i) => {
|
|
190
|
+
return openBlock(), createBlock(_component_LpFileTreeNode, {
|
|
191
|
+
key: child.id,
|
|
192
|
+
style: normalizeStyle({ "--row-delay": rowDelay(i) }),
|
|
193
|
+
class: "animate-[tree-row-in_var(--duration-medium)_var(--ease-emphasized)_both] [animation-delay:var(--row-delay)] motion-reduce:animate-none",
|
|
194
|
+
node: child,
|
|
195
|
+
depth: __props.depth + 1,
|
|
196
|
+
expanded: __props.expanded,
|
|
197
|
+
loading: __props.loading,
|
|
198
|
+
"selected-id": __props.selectedId,
|
|
199
|
+
"focused-id": __props.focusedId,
|
|
200
|
+
sort: __props.sort,
|
|
201
|
+
"icon-size": __props.iconSize,
|
|
202
|
+
checkable: __props.checkable,
|
|
203
|
+
checked: __props.checked,
|
|
204
|
+
"show-size": __props.showSize,
|
|
205
|
+
"show-modified": __props.showModified,
|
|
206
|
+
onSelect: _cache[2] || (_cache[2] = ($event) => emit("select", $event)),
|
|
207
|
+
onToggle: _cache[3] || (_cache[3] = ($event) => emit("toggle", $event)),
|
|
208
|
+
onFocus: _cache[4] || (_cache[4] = ($event) => emit("focus", $event)),
|
|
209
|
+
onCheck: _cache[5] || (_cache[5] = (n, v) => emit("check", n, v))
|
|
210
|
+
}, {
|
|
211
|
+
row: withCtx((slotProps) => [
|
|
212
|
+
renderSlot(_ctx.$slots, "row", mergeProps({ ref_for: true }, slotProps))
|
|
213
|
+
]),
|
|
214
|
+
_: 3
|
|
215
|
+
}, 8, ["style", "node", "depth", "expanded", "loading", "selected-id", "focused-id", "sort", "icon-size", "checkable", "checked", "show-size", "show-modified"]);
|
|
216
|
+
}), 128))
|
|
217
|
+
])) : createCommentVNode("", true)
|
|
218
|
+
]),
|
|
219
|
+
_: 3
|
|
220
|
+
})
|
|
221
|
+
], 8, _hoisted_1);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
export {
|
|
226
|
+
_sfc_main as _
|
|
227
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const COMPONENT_NAMES: readonly ["LayoutCanvas", "LayoutNode", "LpAlert", "LpAppShell", "LpAutocomplete", "LpAvatar", "LpBadge", "LpBreadcrumbs", "LpButton", "LpCalendar", "LpCard", "LpCheckbox", "LpCodeBlock", "LpCommandPalette", "LpConfirmDialog", "LpContextMenu", "LpDatePicker", "LpDisclosure", "LpDivider", "LpDrawer", "LpDropdownMenu", "LpEmptyState", "LpFormField", "LpIcon", "LpInfraNode", "LpInput", "LpLaneNode", "LpLink", "LpLogViewer", "LpModal", "LpNotificationBell", "LpNumberField", "LpOtpInput", "LpPagination", "LpPasswordInput", "LpPhoneInput", "LpPopover", "LpProgress", "LpRadio", "LpRadioGroup", "LpScrollArea", "LpSegmented", "LpSelect", "LpServiceNode", "LpSidebar", "LpSidebarNav", "LpSkeleton", "LpSlider", "LpStat", "LpStepper", "LpSwitch", "LpTable", "LpTableOfContents", "LpTabs", "LpTextarea", "LpThemeSwitcher", "LpTilt", "LpToaster", "LpTooltip", "LpTopologyCanvas", "LpUptimeBar"];
|
|
1
|
+
export declare const COMPONENT_NAMES: readonly ["LayoutCanvas", "LayoutNode", "LpAlert", "LpAppShell", "LpAutocomplete", "LpAvatar", "LpBadge", "LpBreadcrumbs", "LpButton", "LpCalendar", "LpCard", "LpCheckbox", "LpCodeBlock", "LpCommandPalette", "LpConfirmDialog", "LpContextMenu", "LpDatePicker", "LpDisclosure", "LpDivider", "LpDrawer", "LpDropdownMenu", "LpEmptyState", "LpFileTree", "LpFileTreeNode", "LpFormField", "LpIcon", "LpInfraNode", "LpInput", "LpLaneNode", "LpLink", "LpLogViewer", "LpModal", "LpNotificationBell", "LpNumberField", "LpOtpInput", "LpPagination", "LpPasswordInput", "LpPhoneInput", "LpPopover", "LpProgress", "LpRadio", "LpRadioGroup", "LpScrollArea", "LpSegmented", "LpSelect", "LpServiceNode", "LpSidebar", "LpSidebarNav", "LpSkeleton", "LpSlider", "LpStat", "LpStepper", "LpSwitch", "LpTable", "LpTableOfContents", "LpTabs", "LpTextarea", "LpThemeSwitcher", "LpTilt", "LpToaster", "LpTooltip", "LpTopologyCanvas", "LpUptimeBar"];
|