@leavepulse/ui 0.15.0 → 0.15.2
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/{LpAppShell-BLKZDLh8.js → LpAppShell-CV194os6.js} +2 -2
- package/dist/chunks/{LpAutocomplete-B9uoCs4t.js → LpAutocomplete-DIgXmtCA.js} +13 -5
- package/dist/chunks/{LpConfirmDialog-BA45MvRL.js → LpConfirmDialog-D6Rhge21.js} +1 -1
- package/dist/chunks/{LpDrawer-6n5Hd-iF.js → LpDrawer-BHzCy-Aa.js} +1 -1
- package/dist/chunks/{LpFileTree-D0DEpKof.js → LpFileTree-BQz8Rfgz.js} +49 -32
- package/dist/chunks/{LpFileTreeNode-3e71ywJV.js → LpFileTreeNode-DFg4PhOK.js} +10 -7
- package/dist/chunks/{LpLogViewer-BBgaY38i.js → LpLogViewer-BvzRZPjs.js} +2 -1
- package/dist/chunks/LpModal-d6SZpfBH.js +131 -0
- package/dist/chunks/{LpNotificationBell-B9VHks_D.js → LpNotificationBell-BtfRoL2i.js} +1 -1
- package/dist/chunks/{LpScrollArea-BtnZCCBT.js → LpScrollArea-De9DLpa1.js} +2 -2
- package/dist/chunks/{LpSidebar-tZ2z-PnM.js → LpSidebar-B11IDRQi.js} +2 -2
- package/dist/chunks/{LpSidebarNav-D-YvtwsH.js → LpSidebarNav-TIUNHZX-.js} +1 -1
- package/dist/chunks/{LpTable-CzHVcr3v.js → LpTable-CKGaUbEM.js} +1 -1
- package/dist/components/LpAppShell.vue.js +1 -1
- package/dist/components/LpAutocomplete.vue.js +1 -1
- package/dist/components/LpCommandPalette.vue.js +1 -1
- package/dist/components/LpConfirmDialog.vue.js +1 -1
- package/dist/components/LpDrawer.vue.js +1 -1
- package/dist/components/LpFileTree.vue.js +1 -1
- package/dist/components/LpFileTreeNode.vue.d.ts +3 -1
- package/dist/components/LpFileTreeNode.vue.js +1 -1
- package/dist/components/LpLogViewer.vue.js +1 -1
- package/dist/components/LpModal.vue.js +1 -1
- package/dist/components/LpNotificationBell.vue.js +1 -1
- package/dist/components/LpScrollArea.vue.d.ts +4 -2
- package/dist/components/LpScrollArea.vue.js +1 -1
- package/dist/components/LpSidebar.vue.js +1 -1
- package/dist/components/LpSidebarNav.vue.js +1 -1
- package/dist/components/LpTable.vue.js +1 -1
- package/dist/components/fileTree.d.ts +16 -0
- package/dist/components/fileTree.js +49 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -12
- package/package.json +1 -1
- package/src/components/LpAutocomplete.vue +19 -2
- package/src/components/LpFileTree.vue +67 -35
- package/src/components/LpFileTreeNode.vue +16 -9
- package/src/components/LpLogViewer.vue +4 -0
- package/src/components/LpModal.vue +11 -1
- package/src/components/LpScrollArea.vue +16 -11
- package/src/components/fileTree.ts +75 -0
- package/src/index.ts +2 -1
- package/src/tokens/tokens.css +16 -0
- package/dist/chunks/LpModal-B9CVVC5U.js +0 -128
|
@@ -59,5 +59,21 @@ export declare function checkedCount(node: FileNode, checked: ReadonlySet<string
|
|
|
59
59
|
checked: number;
|
|
60
60
|
total: number;
|
|
61
61
|
};
|
|
62
|
+
/** Everything a row needs to render, precomputed once per node. */
|
|
63
|
+
export interface NodeStats {
|
|
64
|
+
state: CheckState;
|
|
65
|
+
/** Ticked files in the subtree, and how many there are in total. */
|
|
66
|
+
checked: number;
|
|
67
|
+
total: number;
|
|
68
|
+
/** Rolled-up subtree size, or undefined when nothing carries one. */
|
|
69
|
+
size?: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Derive every row's state in ONE post-order pass over the tree, keyed by node
|
|
73
|
+
* id. Calling `checkStateOf`/`subtreeSize`/`checkedCount` per row instead makes
|
|
74
|
+
* each row walk its own subtree, which is quadratic on a deep tree and shows up
|
|
75
|
+
* as a stutter the moment a directory holds a few thousand files.
|
|
76
|
+
*/
|
|
77
|
+
export declare function computeStats(nodes: FileNode[], checked: ReadonlySet<string>): Map<string, NodeStats>;
|
|
62
78
|
/** Ids of every ancestor directory of `id`, so callers can reveal a deep node. */
|
|
63
79
|
export declare function ancestorIds(nodes: FileNode[], id: string): string[];
|
|
@@ -144,6 +144,54 @@ function checkedCount(node, checked) {
|
|
|
144
144
|
walk(node.children ?? []);
|
|
145
145
|
return { checked: count, total };
|
|
146
146
|
}
|
|
147
|
+
function computeStats(nodes, checked) {
|
|
148
|
+
const stats = /* @__PURE__ */ new Map();
|
|
149
|
+
function visit(node) {
|
|
150
|
+
if (node.kind === "file" || !node.children?.length) {
|
|
151
|
+
const isChecked = checked.has(node.id);
|
|
152
|
+
const self2 = {
|
|
153
|
+
state: isChecked ? "checked" : "unchecked",
|
|
154
|
+
checked: node.kind === "file" && isChecked ? 1 : 0,
|
|
155
|
+
total: node.kind === "file" ? 1 : 0,
|
|
156
|
+
size: node.size
|
|
157
|
+
};
|
|
158
|
+
stats.set(node.id, self2);
|
|
159
|
+
return self2;
|
|
160
|
+
}
|
|
161
|
+
let all = true;
|
|
162
|
+
let any = false;
|
|
163
|
+
let count = 0;
|
|
164
|
+
let total = 0;
|
|
165
|
+
let bytes = 0;
|
|
166
|
+
let sized = node.size !== void 0;
|
|
167
|
+
for (const child of node.children) {
|
|
168
|
+
const childStats = visit(child);
|
|
169
|
+
if (childStats.state === "checked") any = true;
|
|
170
|
+
else if (childStats.state === "indeterminate") {
|
|
171
|
+
any = true;
|
|
172
|
+
all = false;
|
|
173
|
+
} else all = false;
|
|
174
|
+
count += childStats.checked;
|
|
175
|
+
total += childStats.total;
|
|
176
|
+
if (childStats.size !== void 0) {
|
|
177
|
+
bytes += childStats.size;
|
|
178
|
+
sized = true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const self = {
|
|
182
|
+
state: all ? "checked" : any ? "indeterminate" : "unchecked",
|
|
183
|
+
checked: count,
|
|
184
|
+
total,
|
|
185
|
+
// An explicit size on the directory wins: a server-side listing usually
|
|
186
|
+
// knows the real figure without the children being loaded.
|
|
187
|
+
size: node.size ?? (sized ? bytes : void 0)
|
|
188
|
+
};
|
|
189
|
+
stats.set(node.id, self);
|
|
190
|
+
return self;
|
|
191
|
+
}
|
|
192
|
+
for (const node of nodes) visit(node);
|
|
193
|
+
return stats;
|
|
194
|
+
}
|
|
147
195
|
function ancestorIds(nodes, id) {
|
|
148
196
|
const path = [];
|
|
149
197
|
function walk(list, trail) {
|
|
@@ -163,6 +211,7 @@ export {
|
|
|
163
211
|
ancestorIds,
|
|
164
212
|
checkStateOf,
|
|
165
213
|
checkedCount,
|
|
214
|
+
computeStats,
|
|
166
215
|
fileIcon,
|
|
167
216
|
formatModified,
|
|
168
217
|
formatSize,
|
package/dist/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export type { MenuItem } from './components/LpDropdownMenu.vue';
|
|
|
27
27
|
export { default as LpEmptyState } from './components/LpEmptyState.vue';
|
|
28
28
|
export { default as LpFileTree } from './components/LpFileTree.vue';
|
|
29
29
|
export type { FileTreeSummary } from './components/LpFileTree.vue';
|
|
30
|
-
export type { CheckState, FileNode } from './components/fileTree';
|
|
31
|
-
export { ancestorIds, checkedCount, checkStateOf, fileIcon, formatModified, formatSize, sortNodes, subtreeIds, subtreeSize, } from './components/fileTree';
|
|
30
|
+
export type { CheckState, FileNode, NodeStats } from './components/fileTree';
|
|
31
|
+
export { ancestorIds, checkedCount, checkStateOf, computeStats, fileIcon, formatModified, formatSize, sortNodes, subtreeIds, subtreeSize, } from './components/fileTree';
|
|
32
32
|
export { default as LpFormField } from './components/LpFormField.vue';
|
|
33
33
|
export { default as LpIcon } from './components/LpIcon.vue';
|
|
34
34
|
export { default as LpInfraNode } from './components/LpInfraNode.vue';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from "./chunks/LayoutCanvas-Dd20boUG.js";
|
|
2
2
|
import { _ as _2 } from "./chunks/LpAlert-BAYHDSS1.js";
|
|
3
|
-
import { _ as _3 } from "./chunks/LpAppShell-
|
|
4
|
-
import { _ as _4 } from "./chunks/LpAutocomplete-
|
|
3
|
+
import { _ as _3 } from "./chunks/LpAppShell-CV194os6.js";
|
|
4
|
+
import { _ as _4 } from "./chunks/LpAutocomplete-DIgXmtCA.js";
|
|
5
5
|
import { _ as _5 } from "./chunks/LpAvatar-B1Ez0ZAx.js";
|
|
6
6
|
import { _ as _6 } from "./chunks/LpBadge-CXzBPnwO.js";
|
|
7
7
|
import { _ as _7 } from "./chunks/LpBreadcrumbs-B7Aqatzw.js";
|
|
@@ -11,24 +11,24 @@ import { _ as _10 } from "./chunks/LpCard-BmrTvWOe.js";
|
|
|
11
11
|
import { _ as _11 } from "./chunks/LpCheckbox-BO0zuuPh.js";
|
|
12
12
|
import { _ as _12 } from "./chunks/LpCodeBlock-CSiOSPs8.js";
|
|
13
13
|
import { default as default2 } from "./components/LpCommandPalette.vue.js";
|
|
14
|
-
import { _ as _13 } from "./chunks/LpConfirmDialog-
|
|
14
|
+
import { _ as _13 } from "./chunks/LpConfirmDialog-D6Rhge21.js";
|
|
15
15
|
import { _ as _14 } from "./chunks/LpContextMenu-D0mzXqA7.js";
|
|
16
16
|
import { _ as _15 } from "./chunks/LpDatePicker-dY2q4dr4.js";
|
|
17
17
|
import { _ as _16 } from "./chunks/LpDisclosure-DP6yfgfM.js";
|
|
18
18
|
import { _ as _17 } from "./chunks/LpDivider-CUX46KR0.js";
|
|
19
|
-
import { _ as _18 } from "./chunks/LpDrawer-
|
|
19
|
+
import { _ as _18 } from "./chunks/LpDrawer-BHzCy-Aa.js";
|
|
20
20
|
import { _ as _19 } from "./chunks/LpDropdownMenu-DJpoqRCb.js";
|
|
21
21
|
import { _ as _20 } from "./chunks/LpEmptyState-CrfyRJUG.js";
|
|
22
|
-
import { _ as _21 } from "./chunks/LpFileTree-
|
|
23
|
-
import { ancestorIds, checkStateOf, checkedCount, fileIcon, formatModified, formatSize, sortNodes, subtreeIds, subtreeSize } from "./components/fileTree.js";
|
|
22
|
+
import { _ as _21 } from "./chunks/LpFileTree-BQz8Rfgz.js";
|
|
23
|
+
import { ancestorIds, checkStateOf, checkedCount, computeStats, fileIcon, formatModified, formatSize, sortNodes, subtreeIds, subtreeSize } from "./components/fileTree.js";
|
|
24
24
|
import { _ as _22 } from "./chunks/LpFormField-Bn-ZwC6z.js";
|
|
25
25
|
import { _ as _23 } from "./chunks/LpIcon-CCnX5_2j.js";
|
|
26
26
|
import { _ as _24 } from "./chunks/LpInfraNode-C_PHcthC.js";
|
|
27
27
|
import { _ as _25 } from "./chunks/LpInput-BauZRyzm.js";
|
|
28
28
|
import { _ as _26 } from "./chunks/LpLink-DHwOEp4e.js";
|
|
29
|
-
import { _ as _27 } from "./chunks/LpLogViewer-
|
|
30
|
-
import { _ as _28 } from "./chunks/LpModal-
|
|
31
|
-
import { _ as _29 } from "./chunks/LpNotificationBell-
|
|
29
|
+
import { _ as _27 } from "./chunks/LpLogViewer-BvzRZPjs.js";
|
|
30
|
+
import { _ as _28 } from "./chunks/LpModal-d6SZpfBH.js";
|
|
31
|
+
import { _ as _29 } from "./chunks/LpNotificationBell-BtfRoL2i.js";
|
|
32
32
|
import { _ as _30 } from "./chunks/LpNumberField-C5ar-OwE.js";
|
|
33
33
|
import { _ as _31 } from "./chunks/LpOtpInput-DqaT0Z75.js";
|
|
34
34
|
import { _ as _32 } from "./chunks/LpPagination-CeGuNe_q.js";
|
|
@@ -39,17 +39,17 @@ import { _ as _35 } from "./chunks/LpPopover-8268UmlC.js";
|
|
|
39
39
|
import { _ as _36 } from "./chunks/LpProgress-BhI0IbjC.js";
|
|
40
40
|
import { _ as _37 } from "./chunks/LpRadio-CL-pI0_O.js";
|
|
41
41
|
import { _ as _38 } from "./chunks/LpRadioGroup-B4yDTmi6.js";
|
|
42
|
-
import { _ as _39 } from "./chunks/LpScrollArea-
|
|
42
|
+
import { _ as _39 } from "./chunks/LpScrollArea-De9DLpa1.js";
|
|
43
43
|
import { _ as _40 } from "./chunks/LpSegmented-BmpanyAo.js";
|
|
44
44
|
import { _ as _41 } from "./chunks/LpSelect-DznhPEWX.js";
|
|
45
45
|
import { _ as _42 } from "./chunks/LpServiceNode-Dc-Ut5RS.js";
|
|
46
|
-
import { _ as _43 } from "./chunks/LpSidebar-
|
|
46
|
+
import { _ as _43 } from "./chunks/LpSidebar-B11IDRQi.js";
|
|
47
47
|
import { _ as _44 } from "./chunks/LpSkeleton-eSFIo4kD.js";
|
|
48
48
|
import { _ as _45 } from "./chunks/LpSlider-B1SF3pRV.js";
|
|
49
49
|
import { _ as _46 } from "./chunks/LpStat-CdbEFOvn.js";
|
|
50
50
|
import { _ as _47 } from "./chunks/LpStepper-5dFTrW21.js";
|
|
51
51
|
import { _ as _48 } from "./chunks/LpSwitch-v6fnccSM.js";
|
|
52
|
-
import { _ as _49 } from "./chunks/LpTable-
|
|
52
|
+
import { _ as _49 } from "./chunks/LpTable-CKGaUbEM.js";
|
|
53
53
|
import { _ as _50 } from "./chunks/LpTableOfContents-CjvxPMpU.js";
|
|
54
54
|
import { _ as _51 } from "./chunks/LpTabs-D7aTVPOb.js";
|
|
55
55
|
import { _ as _52 } from "./chunks/LpTextarea-CRAkhemZ.js";
|
|
@@ -169,6 +169,7 @@ export {
|
|
|
169
169
|
e as bootstrapTheme,
|
|
170
170
|
checkStateOf,
|
|
171
171
|
checkedCount,
|
|
172
|
+
computeStats,
|
|
172
173
|
countBlocks,
|
|
173
174
|
countLeaves,
|
|
174
175
|
f as dark,
|
package/package.json
CHANGED
|
@@ -97,9 +97,16 @@ const items = computed<AutocompleteOption[]>(() =>
|
|
|
97
97
|
),
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
+
// The field's text IS the value here, so a chosen option would otherwise filter
|
|
101
|
+
// the list down to itself: reopening the field showed a single row, and the
|
|
102
|
+
// other options only came back after erasing what was already selected. The
|
|
103
|
+
// filter therefore applies to what the user TYPES, and stops applying as soon
|
|
104
|
+
// as a value is picked (or the field is reopened untouched).
|
|
105
|
+
const typing = ref(false)
|
|
106
|
+
|
|
100
107
|
const filtered = computed(() => {
|
|
101
108
|
const q = text.value.trim().toLowerCase()
|
|
102
|
-
if (!props.filter || !q) return items.value
|
|
109
|
+
if (!props.filter || !typing.value || !q) return items.value
|
|
103
110
|
return items.value.filter((o) => {
|
|
104
111
|
const hay = `${o.label ?? o.value} ${o.description ?? ""}`.toLowerCase()
|
|
105
112
|
return hay.includes(q)
|
|
@@ -136,18 +143,28 @@ const anchorSize = {
|
|
|
136
143
|
lg: "h-(--size-control-lg) text-sm",
|
|
137
144
|
}
|
|
138
145
|
|
|
146
|
+
function onInput(event: Event) {
|
|
147
|
+
typing.value = true
|
|
148
|
+
text.value = (event.target as HTMLInputElement).value
|
|
149
|
+
}
|
|
150
|
+
|
|
139
151
|
function onFocus() {
|
|
152
|
+
// Arriving at a field that already holds a value shows every option, not just
|
|
153
|
+
// the one it currently holds.
|
|
154
|
+
typing.value = false
|
|
140
155
|
focused.value = true
|
|
141
156
|
if (canOpen.value) open.value = true
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
function choose(opt: AutocompleteOption) {
|
|
160
|
+
typing.value = false
|
|
145
161
|
emit("update:modelValue", opt.value)
|
|
146
162
|
emit("select", opt.value)
|
|
147
163
|
open.value = false
|
|
148
164
|
}
|
|
149
165
|
|
|
150
166
|
function clear() {
|
|
167
|
+
typing.value = false
|
|
151
168
|
emit("update:modelValue", "")
|
|
152
169
|
open.value = false
|
|
153
170
|
}
|
|
@@ -188,7 +205,7 @@ function clear() {
|
|
|
188
205
|
class="min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted"
|
|
189
206
|
@beforeinput="onBeforeInput"
|
|
190
207
|
@paste="onPaste"
|
|
191
|
-
@input="
|
|
208
|
+
@input="onInput"
|
|
192
209
|
@focus="onFocus"
|
|
193
210
|
@blur="focused = false"
|
|
194
211
|
/>
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
import { computed, ref, watch } from "vue"
|
|
22
22
|
import {
|
|
23
23
|
ancestorIds,
|
|
24
|
-
|
|
24
|
+
computeStats,
|
|
25
25
|
formatSize,
|
|
26
26
|
sortNodes,
|
|
27
27
|
subtreeIds,
|
|
28
|
-
subtreeSize,
|
|
29
28
|
type FileNode,
|
|
30
29
|
} from "./fileTree"
|
|
31
30
|
import LpEmptyState from "./LpEmptyState.vue"
|
|
@@ -135,19 +134,27 @@ watch(
|
|
|
135
134
|
},
|
|
136
135
|
)
|
|
137
136
|
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Index every node by id, plus each node's parent id, in one pass per data
|
|
139
|
+
* change. The parent map turns "reconcile my ancestors" into a walk up the
|
|
140
|
+
* chain instead of a search through the whole tree on every tick.
|
|
141
|
+
*/
|
|
142
|
+
const index = computed(() => {
|
|
143
|
+
const byId = new Map<string, FileNode>()
|
|
144
|
+
const parentOfId = new Map<string, string>()
|
|
145
|
+
function walk(list: FileNode[], parent?: string) {
|
|
142
146
|
for (const node of list) {
|
|
143
|
-
|
|
144
|
-
if (
|
|
147
|
+
byId.set(node.id, node)
|
|
148
|
+
if (parent !== undefined) parentOfId.set(node.id, parent)
|
|
149
|
+
if (node.children) walk(node.children, node.id)
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
walk(props.nodes)
|
|
148
|
-
return
|
|
153
|
+
return { byId, parentOfId }
|
|
149
154
|
})
|
|
150
155
|
|
|
156
|
+
const byId = computed(() => index.value.byId)
|
|
157
|
+
|
|
151
158
|
/**
|
|
152
159
|
* What the ticked set adds up to. Directories are counted but not sized — their
|
|
153
160
|
* bytes arrive through the files inside them, so summing both would double-count.
|
|
@@ -159,30 +166,47 @@ const summary = computed<FileTreeSummary>(() => {
|
|
|
159
166
|
let dirs = 0
|
|
160
167
|
let bytes = 0
|
|
161
168
|
let sized = false
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
if (size !== undefined) {
|
|
174
|
-
bytes += size
|
|
169
|
+
|
|
170
|
+
// Walk the tree, not the ticked set: a fully ticked directory can be counted
|
|
171
|
+
// whole and its subtree skipped, which keeps this linear in what's selected
|
|
172
|
+
// rather than in the size of the instance.
|
|
173
|
+
function walk(list: FileNode[]) {
|
|
174
|
+
for (const node of list) {
|
|
175
|
+
const stat = stats.value.get(node.id)
|
|
176
|
+
if (!stat || stat.state === "unchecked") continue
|
|
177
|
+
|
|
178
|
+
if (node.kind === "file") {
|
|
179
|
+
files++
|
|
180
|
+
if (node.size !== undefined) {
|
|
181
|
+
bytes += node.size
|
|
175
182
|
sized = true
|
|
176
183
|
}
|
|
184
|
+
continue
|
|
177
185
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
|
|
186
|
+
|
|
187
|
+
dirs++
|
|
188
|
+
if (stat.state === "checked" && stat.size !== undefined) {
|
|
189
|
+
// Whole directory: take its rolled-up size and don't descend.
|
|
190
|
+
bytes += stat.size
|
|
182
191
|
sized = true
|
|
192
|
+
files += stat.total
|
|
193
|
+
countDirs(node.children ?? [])
|
|
194
|
+
continue
|
|
183
195
|
}
|
|
196
|
+
walk(node.children ?? [])
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// A fully ticked directory still contributes its nested folders to the count.
|
|
201
|
+
function countDirs(list: FileNode[]) {
|
|
202
|
+
for (const node of list) {
|
|
203
|
+
if (node.kind !== "dir") continue
|
|
204
|
+
dirs++
|
|
205
|
+
countDirs(node.children ?? [])
|
|
184
206
|
}
|
|
185
207
|
}
|
|
208
|
+
|
|
209
|
+
walk(props.nodes)
|
|
186
210
|
return {
|
|
187
211
|
files,
|
|
188
212
|
dirs,
|
|
@@ -212,13 +236,17 @@ function onCheck(node: FileNode, value: boolean) {
|
|
|
212
236
|
if (value) next.add(id)
|
|
213
237
|
else next.delete(id)
|
|
214
238
|
}
|
|
215
|
-
// Walk
|
|
216
|
-
|
|
239
|
+
// Walk straight up the parent chain, re-deriving each ancestor from its
|
|
240
|
+
// children — nearest first, so each one sees the level below already settled.
|
|
241
|
+
let ancestorId = index.value.parentOfId.get(node.id)
|
|
242
|
+
while (ancestorId !== undefined) {
|
|
217
243
|
const ancestor = byId.value.get(ancestorId)
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
244
|
+
if (ancestor?.children?.length) {
|
|
245
|
+
const all = ancestor.children.every((c) => c.disabled || next.has(c.id))
|
|
246
|
+
if (all) next.add(ancestorId)
|
|
247
|
+
else next.delete(ancestorId)
|
|
248
|
+
}
|
|
249
|
+
ancestorId = index.value.parentOfId.get(ancestorId)
|
|
222
250
|
}
|
|
223
251
|
setChecked(next)
|
|
224
252
|
}
|
|
@@ -240,6 +268,10 @@ const requested = new Set<string>()
|
|
|
240
268
|
|
|
241
269
|
const roots = computed(() => (props.sort ? sortNodes(props.nodes) : props.nodes))
|
|
242
270
|
|
|
271
|
+
// One pass for the whole tree; every row reads its entry by id instead of
|
|
272
|
+
// walking its own subtree on each render.
|
|
273
|
+
const stats = computed(() => computeStats(props.nodes, checkedIds.value))
|
|
274
|
+
|
|
243
275
|
/** Rows currently visible, in render order — the axis the arrow keys walk. */
|
|
244
276
|
const visible = computed(() => {
|
|
245
277
|
const out: FileNode[] = []
|
|
@@ -334,8 +366,7 @@ function onSelect(node: FileNode) {
|
|
|
334
366
|
|
|
335
367
|
/** Nearest expanded ancestor of `id`, or undefined at the top level. */
|
|
336
368
|
function parentOf(id: string): FileNode | undefined {
|
|
337
|
-
const
|
|
338
|
-
const parentId = trail.at(-1)
|
|
369
|
+
const parentId = index.value.parentOfId.get(id)
|
|
339
370
|
return parentId ? visible.value.find((n) => n.id === parentId) : undefined
|
|
340
371
|
}
|
|
341
372
|
|
|
@@ -397,7 +428,7 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
397
428
|
// In checkable mode Space is the tick — the standard tree behaviour for a
|
|
398
429
|
// multi-select tree — and Enter stays "open/activate".
|
|
399
430
|
if (props.checkable) {
|
|
400
|
-
onCheck(node,
|
|
431
|
+
onCheck(node, stats.value.get(node.id)?.state !== "checked")
|
|
401
432
|
break
|
|
402
433
|
}
|
|
403
434
|
onSelect(node)
|
|
@@ -487,6 +518,7 @@ defineExpose({ reveal, expandAll, collapseAll, checkAll, clearChecked, summary }
|
|
|
487
518
|
:icon-size="iconSize"
|
|
488
519
|
:checkable="checkable"
|
|
489
520
|
:checked="checkedIds"
|
|
521
|
+
:stats="stats"
|
|
490
522
|
:show-size="showSize"
|
|
491
523
|
:show-modified="showModified"
|
|
492
524
|
@select="onSelect"
|
|
@@ -11,14 +11,12 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { computed } from "vue"
|
|
13
13
|
import {
|
|
14
|
-
checkedCount,
|
|
15
|
-
checkStateOf,
|
|
16
14
|
fileIcon,
|
|
17
15
|
formatModified,
|
|
18
16
|
formatSize,
|
|
19
17
|
sortNodes,
|
|
20
|
-
subtreeSize,
|
|
21
18
|
type FileNode,
|
|
19
|
+
type NodeStats,
|
|
22
20
|
} from "./fileTree"
|
|
23
21
|
import LpCheckbox from "./LpCheckbox.vue"
|
|
24
22
|
import LpContextMenu from "./LpContextMenu.vue"
|
|
@@ -38,6 +36,8 @@ const props = defineProps<{
|
|
|
38
36
|
/** Render a tri-state checkbox per row (multi-select mode). */
|
|
39
37
|
checkable: boolean
|
|
40
38
|
checked: Set<string>
|
|
39
|
+
/** Per-node state, derived once by the root for the whole tree. */
|
|
40
|
+
stats: Map<string, NodeStats>
|
|
41
41
|
showSize: boolean
|
|
42
42
|
showModified: boolean
|
|
43
43
|
}>()
|
|
@@ -71,15 +71,17 @@ const children = computed(() => {
|
|
|
71
71
|
return props.sort ? sortNodes(list) : list
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
+
const stat = computed(() => props.stats.get(props.node.id))
|
|
75
|
+
|
|
74
76
|
const checkState = computed(() =>
|
|
75
|
-
props.checkable ?
|
|
77
|
+
props.checkable ? (stat.value?.state ?? "unchecked") : "unchecked",
|
|
76
78
|
)
|
|
77
79
|
|
|
78
80
|
// A directory shows the rolled-up size of what's under it, so a backup picker
|
|
79
81
|
// can answer "how much is this folder" without expanding it.
|
|
80
82
|
const sizeLabel = computed(() => {
|
|
81
83
|
if (!props.showSize) return ""
|
|
82
|
-
const bytes =
|
|
84
|
+
const bytes = stat.value?.size
|
|
83
85
|
return bytes === undefined ? "" : formatSize(bytes)
|
|
84
86
|
})
|
|
85
87
|
|
|
@@ -90,7 +92,7 @@ const sizeLabel = computed(() => {
|
|
|
90
92
|
*/
|
|
91
93
|
const countLabel = computed(() => {
|
|
92
94
|
if (!props.checkable || !isDir.value) return ""
|
|
93
|
-
const { checked, total } =
|
|
95
|
+
const { checked = 0, total = 0 } = stat.value ?? {}
|
|
94
96
|
return total && checked && checked < total ? `${checked} / ${total}` : ""
|
|
95
97
|
})
|
|
96
98
|
|
|
@@ -213,7 +215,7 @@ function onActivate() {
|
|
|
213
215
|
:class="node.disabled ? '' : isDir ? 'text-brand' : 'text-muted'"
|
|
214
216
|
/>
|
|
215
217
|
|
|
216
|
-
<span class="min-w-0 flex-1 truncate">
|
|
218
|
+
<span class="min-w-0 flex-1 shrink-[2] truncate">
|
|
217
219
|
<slot name="row" :node="node" :depth="depth" :expanded="isOpen" :selected="isSelected">
|
|
218
220
|
{{ node.name }}
|
|
219
221
|
</slot>
|
|
@@ -228,8 +230,12 @@ function onActivate() {
|
|
|
228
230
|
{{ countLabel }}
|
|
229
231
|
</span>
|
|
230
232
|
|
|
231
|
-
<!-- Metadata columns: tabular figures so sizes line up down the tree.
|
|
232
|
-
|
|
233
|
+
<!-- Metadata columns: tabular figures so sizes line up down the tree.
|
|
234
|
+
`meta` is free text, so it truncates rather than pushing the size
|
|
235
|
+
column off the row. -->
|
|
236
|
+
<span v-if="node.meta" class="min-w-0 shrink truncate text-xs text-muted">
|
|
237
|
+
{{ node.meta }}
|
|
238
|
+
</span>
|
|
233
239
|
<span
|
|
234
240
|
v-if="modifiedLabel"
|
|
235
241
|
class="shrink-0 text-xs tabular-nums text-muted/80"
|
|
@@ -268,6 +274,7 @@ function onActivate() {
|
|
|
268
274
|
:icon-size="iconSize"
|
|
269
275
|
:checkable="checkable"
|
|
270
276
|
:checked="checked"
|
|
277
|
+
:stats="stats"
|
|
271
278
|
:show-size="showSize"
|
|
272
279
|
:show-modified="showModified"
|
|
273
280
|
@select="emit('select', $event)"
|
|
@@ -551,9 +551,13 @@ const transitionProps = {
|
|
|
551
551
|
<div
|
|
552
552
|
class="relative overflow-hidden rounded-card border border-line bg-surface font-mono text-xs leading-relaxed"
|
|
553
553
|
>
|
|
554
|
+
<!-- `instant`: this viewer decides for itself when a jump animates (see
|
|
555
|
+
rideToBottom) and restores scrollTop directly after prepending older
|
|
556
|
+
lines. A CSS smooth scroll would override both. -->
|
|
554
557
|
<LpScrollArea
|
|
555
558
|
ref="scrollRef"
|
|
556
559
|
fade
|
|
560
|
+
instant
|
|
557
561
|
:content-class="wrap ? '' : 'min-w-max'"
|
|
558
562
|
:style="{ height }"
|
|
559
563
|
@scroll="onScroll"
|
|
@@ -71,8 +71,17 @@ const bodyPad = computed(() =>
|
|
|
71
71
|
<DialogOverlay
|
|
72
72
|
class="fixed inset-0 z-(--z-overlay) bg-black/50 backdrop-blur-sm data-[state=open]:animate-[fade-in_var(--duration-medium)_var(--ease-emphasized)] data-[state=closed]:animate-[fade-out_120ms_ease]"
|
|
73
73
|
/>
|
|
74
|
+
<!-- Centred by a full-screen flex wrapper rather than by translating the
|
|
75
|
+
panel off its own centre. With `top:50% / -translate-y-1/2` the panel
|
|
76
|
+
is pinned by its MIDDLE, so every height change — content arriving,
|
|
77
|
+
an image loading, a list filling in — moved it up and down by half
|
|
78
|
+
the difference, and while the open animation was still running that
|
|
79
|
+
read as a stutter. Anchoring the wrapper instead means the panel only
|
|
80
|
+
grows downward and the animation has nothing to fight.
|
|
81
|
+
`pointer-events-none` lets clicks through to the overlay behind it. -->
|
|
82
|
+
<div class="fixed inset-0 z-(--z-modal) flex items-center justify-center p-4 pointer-events-none">
|
|
74
83
|
<DialogContent
|
|
75
|
-
class="
|
|
84
|
+
class="pointer-events-auto flex max-h-full flex-col rounded-card border border-line bg-surface-raised shadow-panel outline-none data-[state=open]:animate-[rise-in_var(--duration-medium)_var(--ease-emphasized)] data-[state=closed]:animate-[rise-out_120ms_cubic-bezier(0.4,0,1,1)]"
|
|
76
85
|
:class="widthClass"
|
|
77
86
|
:style="width ? { width } : undefined"
|
|
78
87
|
>
|
|
@@ -118,6 +127,7 @@ const bodyPad = computed(() =>
|
|
|
118
127
|
<slot name="footer" />
|
|
119
128
|
</footer>
|
|
120
129
|
</DialogContent>
|
|
130
|
+
</div>
|
|
121
131
|
</DialogPortal>
|
|
122
132
|
</DialogRoot>
|
|
123
133
|
</template>
|
|
@@ -20,16 +20,21 @@ import {
|
|
|
20
20
|
// component root, since items live inside reka's viewport.
|
|
21
21
|
// `barInsetTop` (any CSS length) pulls the vertical scrollbar down by that much,
|
|
22
22
|
// so it doesn't run under a sticky header pinned at the top of the viewport.
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
// Wheel and keyboard scrolling ease by default. `instant` opts back out, and
|
|
24
|
+
// any consumer that DRIVES the scroll itself needs it: CSS scroll-behaviour
|
|
25
|
+
// also governs programmatic scrolling, overriding `scrollTo({behavior:"auto"})`
|
|
26
|
+
// and animating even a plain `scrollTop = n`. A log tail pinning itself to the
|
|
27
|
+
// newest line, or restoring a position after prepending rows, has to land
|
|
28
|
+
// instantly — see LpLogViewer.
|
|
29
|
+
const props = withDefaults(
|
|
30
|
+
defineProps<{
|
|
31
|
+
fade?: boolean
|
|
32
|
+
instant?: boolean
|
|
33
|
+
contentClass?: string
|
|
34
|
+
barInsetTop?: string
|
|
35
|
+
}>(),
|
|
36
|
+
{ instant: false },
|
|
37
|
+
)
|
|
33
38
|
|
|
34
39
|
// Re-emit the native scroll event of the underlying viewport so consumers that
|
|
35
40
|
// drive scroll-following (e.g. log tails) can track position. The listener is
|
|
@@ -91,7 +96,7 @@ const barFade =
|
|
|
91
96
|
ref="viewportRef"
|
|
92
97
|
class="size-full min-w-0 [&>div]:!block [&>div]:!min-w-0"
|
|
93
98
|
:class="[
|
|
94
|
-
|
|
99
|
+
instant ? '' : 'scroll-smooth motion-reduce:scroll-auto',
|
|
95
100
|
fade ? '[mask-image:linear-gradient(to_bottom,transparent_0,black_14px,black_calc(100%-14px),transparent_100%)]' : '',
|
|
96
101
|
]"
|
|
97
102
|
@scroll.passive="$emit('scroll', $event)"
|