@leavepulse/ui 0.14.10 → 0.15.1

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.
Files changed (41) hide show
  1. package/dist/chunks/{LpAppShell-BLKZDLh8.js → LpAppShell-CV194os6.js} +2 -2
  2. package/dist/chunks/{LpAutocomplete-B9uoCs4t.js → LpAutocomplete-DIgXmtCA.js} +13 -5
  3. package/dist/chunks/{LpConfirmDialog-BA45MvRL.js → LpConfirmDialog-WHkymac5.js} +1 -1
  4. package/dist/chunks/{LpDrawer-6n5Hd-iF.js → LpDrawer-BHzCy-Aa.js} +1 -1
  5. package/dist/chunks/{LpFileTree-0Ko_uj8q.js → LpFileTree-BQz8Rfgz.js} +55 -34
  6. package/dist/chunks/{LpFileTreeNode-D3lNEP-1.js → LpFileTreeNode-DFg4PhOK.js} +28 -14
  7. package/dist/chunks/{LpLogViewer-BBgaY38i.js → LpLogViewer-BvzRZPjs.js} +2 -1
  8. package/dist/chunks/{LpModal-B9CVVC5U.js → LpModal-DpBHQpbU.js} +1 -1
  9. package/dist/chunks/{LpNotificationBell-B9VHks_D.js → LpNotificationBell-BtfRoL2i.js} +1 -1
  10. package/dist/chunks/{LpScrollArea-BtnZCCBT.js → LpScrollArea-De9DLpa1.js} +2 -2
  11. package/dist/chunks/{LpSidebar-tZ2z-PnM.js → LpSidebar-B11IDRQi.js} +2 -2
  12. package/dist/chunks/{LpSidebarNav-D-YvtwsH.js → LpSidebarNav-TIUNHZX-.js} +1 -1
  13. package/dist/chunks/{LpTable-CzHVcr3v.js → LpTable-CKGaUbEM.js} +1 -1
  14. package/dist/components/LpAppShell.vue.js +1 -1
  15. package/dist/components/LpAutocomplete.vue.js +1 -1
  16. package/dist/components/LpCommandPalette.vue.js +1 -1
  17. package/dist/components/LpConfirmDialog.vue.js +1 -1
  18. package/dist/components/LpDrawer.vue.js +1 -1
  19. package/dist/components/LpFileTree.vue.js +1 -1
  20. package/dist/components/LpFileTreeNode.vue.d.ts +3 -1
  21. package/dist/components/LpFileTreeNode.vue.js +1 -1
  22. package/dist/components/LpLogViewer.vue.js +1 -1
  23. package/dist/components/LpModal.vue.js +1 -1
  24. package/dist/components/LpNotificationBell.vue.js +1 -1
  25. package/dist/components/LpScrollArea.vue.d.ts +4 -2
  26. package/dist/components/LpScrollArea.vue.js +1 -1
  27. package/dist/components/LpSidebar.vue.js +1 -1
  28. package/dist/components/LpSidebarNav.vue.js +1 -1
  29. package/dist/components/LpTable.vue.js +1 -1
  30. package/dist/components/fileTree.d.ts +25 -0
  31. package/dist/components/fileTree.js +66 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +14 -12
  34. package/package.json +3 -2
  35. package/src/components/LpAutocomplete.vue +19 -2
  36. package/src/components/LpFileTree.vue +73 -35
  37. package/src/components/LpFileTreeNode.vue +35 -7
  38. package/src/components/LpLogViewer.vue +4 -0
  39. package/src/components/LpScrollArea.vue +16 -11
  40. package/src/components/fileTree.ts +100 -0
  41. package/src/index.ts +3 -1
@@ -50,5 +50,30 @@ export type CheckState = "checked" | "unchecked" | "indeterminate";
50
50
  * ticked as a whole — which is exactly what a backup picker needs.
51
51
  */
52
52
  export declare function checkStateOf(node: FileNode, checked: ReadonlySet<string>): CheckState;
53
+ /**
54
+ * How much of a directory's subtree is ticked, counting FILES only (folders are
55
+ * containers, not payload). Lets a row say "3 / 12" so a half-filled checkbox
56
+ * isn't the only clue that a folder is partially selected.
57
+ */
58
+ export declare function checkedCount(node: FileNode, checked: ReadonlySet<string>): {
59
+ checked: number;
60
+ total: number;
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>;
53
78
  /** Ids of every ancestor directory of `id`, so callers can reveal a deep node. */
54
79
  export declare function ancestorIds(nodes: FileNode[], id: string): string[];
@@ -128,6 +128,70 @@ function checkStateOf(node, checked) {
128
128
  if (all) return "checked";
129
129
  return any ? "indeterminate" : "unchecked";
130
130
  }
131
+ function checkedCount(node, checked) {
132
+ let count = 0;
133
+ let total = 0;
134
+ function walk(list) {
135
+ for (const child of list) {
136
+ if (child.kind === "file") {
137
+ total++;
138
+ if (checked.has(child.id)) count++;
139
+ } else if (child.children?.length) {
140
+ walk(child.children);
141
+ }
142
+ }
143
+ }
144
+ walk(node.children ?? []);
145
+ return { checked: count, total };
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
+ }
131
195
  function ancestorIds(nodes, id) {
132
196
  const path = [];
133
197
  function walk(list, trail) {
@@ -146,6 +210,8 @@ function ancestorIds(nodes, id) {
146
210
  export {
147
211
  ancestorIds,
148
212
  checkStateOf,
213
+ checkedCount,
214
+ computeStats,
149
215
  fileIcon,
150
216
  formatModified,
151
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, 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-BLKZDLh8.js";
4
- import { _ as _4 } from "./chunks/LpAutocomplete-B9uoCs4t.js";
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-BA45MvRL.js";
14
+ import { _ as _13 } from "./chunks/LpConfirmDialog-WHkymac5.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-6n5Hd-iF.js";
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-0Ko_uj8q.js";
23
- import { ancestorIds, checkStateOf, 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-BBgaY38i.js";
30
- import { _ as _28 } from "./chunks/LpModal-B9CVVC5U.js";
31
- import { _ as _29 } from "./chunks/LpNotificationBell-B9VHks_D.js";
29
+ import { _ as _27 } from "./chunks/LpLogViewer-BvzRZPjs.js";
30
+ import { _ as _28 } from "./chunks/LpModal-DpBHQpbU.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-BtnZCCBT.js";
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-tZ2z-PnM.js";
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-CzHVcr3v.js";
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";
@@ -168,6 +168,8 @@ export {
168
168
  blockTitle,
169
169
  e as bootstrapTheme,
170
170
  checkStateOf,
171
+ checkedCount,
172
+ computeStats,
171
173
  countBlocks,
172
174
  countLeaves,
173
175
  f as dark,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leavepulse/ui",
3
- "version": "0.14.10",
3
+ "version": "0.15.1",
4
4
  "type": "module",
5
5
  "description": "LeavePulse token-driven Vue component kit.",
6
6
  "repository": {
@@ -31,7 +31,8 @@
31
31
  "./dist/*": "./dist/*"
32
32
  },
33
33
  "publishConfig": {
34
- "registry": "https://registry.npmjs.org"
34
+ "registry": "https://registry.npmjs.org",
35
+ "access": "public"
35
36
  },
36
37
  "sideEffects": [
37
38
  "**/*.css",
@@ -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="text = ($event.target as HTMLInputElement).value"
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
- checkStateOf,
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
- /** Index every node by id once per data change — the tree walks it a lot. */
139
- const byId = computed(() => {
140
- const map = new Map<string, FileNode>()
141
- function walk(list: FileNode[]) {
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
- map.set(node.id, node)
144
- if (node.children) walk(node.children)
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 map
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
- for (const id of checkedIds.value) {
163
- const node = byId.value.get(id)
164
- if (!node) continue
165
- if (node.kind === "dir") {
166
- dirs++
167
- // Only when nothing inside it is ticked (unexpanded/lazy folder).
168
- const inside = node.children?.length
169
- ? subtreeIds(node).some((child) => child !== id && checkedIds.value.has(child))
170
- : false
171
- if (!inside) {
172
- const size = subtreeSize(node)
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
- } else {
179
- files++
180
- if (node.size !== undefined) {
181
- bytes += node.size
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 ?? [])
184
197
  }
185
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 ?? [])
206
+ }
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 ancestors outward, re-deriving each from its children.
216
- for (const ancestorId of ancestorIds(props.nodes, node.id).reverse()) {
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 (!ancestor?.children?.length) continue
219
- const all = ancestor.children.every((c) => c.disabled || next.has(c.id))
220
- if (all) next.add(ancestorId)
221
- else next.delete(ancestorId)
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[] = []
@@ -321,6 +353,12 @@ function onToggle(node: FileNode) {
321
353
 
322
354
  function onSelect(node: FileNode) {
323
355
  if (node.disabled) return
356
+ // Clicking the highlighted row again clears it — a selection you can't undo
357
+ // without picking something else is a trap.
358
+ if (props.selected === node.id) {
359
+ emit("update:selected", "")
360
+ return
361
+ }
324
362
  emit("update:selected", node.id)
325
363
  emit("select", node)
326
364
  if (node.kind === "file") emit("open", node)
@@ -328,8 +366,7 @@ function onSelect(node: FileNode) {
328
366
 
329
367
  /** Nearest expanded ancestor of `id`, or undefined at the top level. */
330
368
  function parentOf(id: string): FileNode | undefined {
331
- const trail = ancestorIds(props.nodes, id)
332
- const parentId = trail.at(-1)
369
+ const parentId = index.value.parentOfId.get(id)
333
370
  return parentId ? visible.value.find((n) => n.id === parentId) : undefined
334
371
  }
335
372
 
@@ -391,7 +428,7 @@ function onKeydown(e: KeyboardEvent) {
391
428
  // In checkable mode Space is the tick — the standard tree behaviour for a
392
429
  // multi-select tree — and Enter stays "open/activate".
393
430
  if (props.checkable) {
394
- onCheck(node, checkStateOf(node, checkedIds.value) !== "checked")
431
+ onCheck(node, stats.value.get(node.id)?.state !== "checked")
395
432
  break
396
433
  }
397
434
  onSelect(node)
@@ -481,6 +518,7 @@ defineExpose({ reveal, expandAll, collapseAll, checkAll, clearChecked, summary }
481
518
  :icon-size="iconSize"
482
519
  :checkable="checkable"
483
520
  :checked="checkedIds"
521
+ :stats="stats"
484
522
  :show-size="showSize"
485
523
  :show-modified="showModified"
486
524
  @select="onSelect"
@@ -11,13 +11,12 @@
11
11
  */
12
12
  import { computed } from "vue"
13
13
  import {
14
- checkStateOf,
15
14
  fileIcon,
16
15
  formatModified,
17
16
  formatSize,
18
17
  sortNodes,
19
- subtreeSize,
20
18
  type FileNode,
19
+ type NodeStats,
21
20
  } from "./fileTree"
22
21
  import LpCheckbox from "./LpCheckbox.vue"
23
22
  import LpContextMenu from "./LpContextMenu.vue"
@@ -37,6 +36,8 @@ const props = defineProps<{
37
36
  /** Render a tri-state checkbox per row (multi-select mode). */
38
37
  checkable: boolean
39
38
  checked: Set<string>
39
+ /** Per-node state, derived once by the root for the whole tree. */
40
+ stats: Map<string, NodeStats>
40
41
  showSize: boolean
41
42
  showModified: boolean
42
43
  }>()
@@ -70,18 +71,31 @@ const children = computed(() => {
70
71
  return props.sort ? sortNodes(list) : list
71
72
  })
72
73
 
74
+ const stat = computed(() => props.stats.get(props.node.id))
75
+
73
76
  const checkState = computed(() =>
74
- props.checkable ? checkStateOf(props.node, props.checked) : "unchecked",
77
+ props.checkable ? (stat.value?.state ?? "unchecked") : "unchecked",
75
78
  )
76
79
 
77
80
  // A directory shows the rolled-up size of what's under it, so a backup picker
78
81
  // can answer "how much is this folder" without expanding it.
79
82
  const sizeLabel = computed(() => {
80
83
  if (!props.showSize) return ""
81
- const bytes = subtreeSize(props.node)
84
+ const bytes = stat.value?.size
82
85
  return bytes === undefined ? "" : formatSize(bytes)
83
86
  })
84
87
 
88
+ /**
89
+ * "3 / 12" on a directory whose subtree is partly ticked. Only shown while it
90
+ * actually differs from the whole — a fully ticked or untouched folder reads
91
+ * fine from the checkbox alone, and a count on every row would be noise.
92
+ */
93
+ const countLabel = computed(() => {
94
+ if (!props.checkable || !isDir.value) return ""
95
+ const { checked = 0, total = 0 } = stat.value ?? {}
96
+ return total && checked && checked < total ? `${checked} / ${total}` : ""
97
+ })
98
+
85
99
  const modifiedLabel = computed(() =>
86
100
  props.showModified && props.node.modified !== undefined
87
101
  ? formatModified(props.node.modified)
@@ -201,14 +215,27 @@ function onActivate() {
201
215
  :class="node.disabled ? '' : isDir ? 'text-brand' : 'text-muted'"
202
216
  />
203
217
 
204
- <span class="min-w-0 flex-1 truncate">
218
+ <span class="min-w-0 flex-1 shrink-[2] truncate">
205
219
  <slot name="row" :node="node" :depth="depth" :expanded="isOpen" :selected="isSelected">
206
220
  {{ node.name }}
207
221
  </slot>
208
222
  </span>
209
223
 
210
- <!-- Metadata columns: tabular figures so sizes line up down the tree. -->
211
- <span v-if="node.meta" class="shrink-0 text-xs text-muted">{{ node.meta }}</span>
224
+ <!-- Partial-selection counter: says outright how much of the folder is
225
+ ticked, which a half-state checkbox alone doesn't convey. -->
226
+ <span
227
+ v-if="countLabel"
228
+ class="shrink-0 rounded-pill bg-brand-soft px-1.5 py-0.5 text-[11px] font-medium tabular-nums text-brand"
229
+ >
230
+ {{ countLabel }}
231
+ </span>
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>
212
239
  <span
213
240
  v-if="modifiedLabel"
214
241
  class="shrink-0 text-xs tabular-nums text-muted/80"
@@ -247,6 +274,7 @@ function onActivate() {
247
274
  :icon-size="iconSize"
248
275
  :checkable="checkable"
249
276
  :checked="checked"
277
+ :stats="stats"
250
278
  :show-size="showSize"
251
279
  :show-modified="showModified"
252
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"
@@ -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
- // `smooth` eases wheel and keyboard scrolling. Opt-in rather than default:
24
- // it also applies to `scrollTo({ behavior: "auto" })`, which consumers that
25
- // drive the scroll themselves (a log tail jumping to the newest line) rely on
26
- // being instant.
27
- const props = defineProps<{
28
- fade?: boolean
29
- smooth?: boolean
30
- contentClass?: string
31
- barInsetTop?: string
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
- smooth ? 'scroll-smooth motion-reduce:scroll-auto' : '',
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)"