@styloviz/tree-view 0.3.0 → 1.0.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.
@@ -1,217 +1,331 @@
1
- import * as i0 from '@angular/core';
2
- import { input, output, model, signal, inject, ElementRef, computed, effect, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { SvSkeletonShellComponent, SvErrorShellComponent, SvEmptyShellComponent } from '@styloviz/core';
4
-
5
- // ─── Component ────────────────────────────────────────────────────────────────
6
- /**
7
- * SvTreeViewComponent (Free) — Collapsible single-select tree.
8
- *
9
- * For the full 8-variant suite (file explorer, checkbox tri-state,
10
- * org chart, tree table, searchable, draggable, lazy-load) upgrade to
11
- * `@styloviz-pro/tree-view`.
12
- *
13
- * @example
14
- * ```html
15
- * <sv-tree-view [nodes]="nodes" (nodeClick)="onNodeClick($event)" />
16
- * ```
17
- */
18
- class SvTreeViewComponent {
19
- /** Tree node data (nested children, optional icons). */
20
- nodes = input([], ...(ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []));
21
- /** Enable single-row selection highlight. @default true */
22
- selectable = input(true, ...(ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []));
23
- /** Show vertical connector guide lines. @default true */
24
- showLines = input(true, ...(ngDevMode ? [{ debugName: "showLines" }] : /* istanbul ignore next */ []));
25
- /**
26
- * True while the tree is being fetched. Replaces it with a placeholder.
27
- * @default false
28
- */
29
- loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
30
- /**
31
- * Load failure. Use `toSvDataError()` from `@styloviz/core` to normalize an
32
- * `HttpErrorResponse`.
33
- * @default null
34
- */
35
- error = input(null, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
36
- /** Copy for the empty state. @default 'No items to display' */
37
- emptyText = input('No items to display', ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
38
- nodeClick = output();
39
- nodeExpand = output();
40
- nodeCollapse = output();
41
- nodeSelect = output();
42
- /** The host should re-run the failed load. */
43
- retry = output();
44
- /**
45
- * Expanded node ids. Two-way bindable, so an expansion state loaded from the
46
- * server — or restored from a URL — survives a reload.
47
- */
48
- expandedIds = model(new Set(), ...(ngDevMode ? [{ debugName: "expandedIds" }] : /* istanbul ignore next */ []));
49
- /** The selected node id. Two-way bindable. */
50
- selectedId = model(null, ...(ngDevMode ? [{ debugName: "selectedId" }] : /* istanbul ignore next */ []));
51
- /** The treeitem currently in the tab order (roving tabindex). */
52
- activeId = signal(null, ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
53
- _nodes = signal([], ...(ngDevMode ? [{ debugName: "_nodes" }] : /* istanbul ignore next */ []));
54
- host = inject(ElementRef);
55
- visibleNodes = computed(() => this._flatten(this._nodes(), 0, this.expandedIds()), ...(ngDevMode ? [{ debugName: "visibleNodes" }] : /* istanbul ignore next */ []));
56
- /** Applied only on the first non-empty node set — after that the user owns it. */
57
- _seededFromNodes = false;
58
- constructor() {
59
- // `nodes` used to be read once in ngOnInit, so a host that fetched the tree
60
- // asynchronously and bound the result saw an empty component forever.
61
- effect(() => {
62
- const incoming = this.nodes();
63
- this._nodes.set(incoming);
64
- if (this._seededFromNodes || incoming.length === 0)
65
- return;
66
- this._seededFromNodes = true;
67
- const ids = new Set();
68
- this._collectExpanded(incoming, ids);
69
- if (ids.size)
70
- this.expandedIds.set(ids);
71
- // Seed the roving tabindex on the first node so the tree is tab-reachable.
72
- this.activeId.set(this.visibleNodes()[0]?.node.id ?? null);
73
- });
74
- }
75
- toggle(node) {
76
- if (node.disabled)
77
- return;
78
- const ids = new Set(this.expandedIds());
79
- if (ids.has(node.id)) {
80
- ids.delete(node.id);
81
- this.nodeCollapse.emit(node);
82
- }
83
- else {
84
- ids.add(node.id);
85
- this.nodeExpand.emit(node);
86
- }
87
- this.expandedIds.set(ids);
88
- }
89
- select(node, depth) {
90
- if (node.disabled || !this.selectable())
91
- return;
92
- this.selectedId.set(node.id);
93
- this.nodeSelect.emit(node);
94
- this.nodeClick.emit({ node, depth });
95
- }
96
- isSelected(id) { return this.selectedId() === id; }
97
- // ── Keyboard navigation (WAI-ARIA tree) ─────────────────────────────────────
98
- /** Roving tabindex: only the active treeitem is in the tab order. */
99
- treeTabIndex(id) {
100
- const active = this.activeId() ?? this.visibleNodes()[0]?.node.id ?? null;
101
- return id === active ? 0 : -1;
102
- }
103
- setActive(id) { this.activeId.set(id); }
104
- /**
105
- * Arrow / Home / End / Enter / Space handling per the WAI-ARIA tree pattern.
106
- * Arrow Up/Down move between visible rows; Right expands or steps into a
107
- * child; Left collapses or steps to the parent; Enter/Space selects.
108
- */
109
- onKeydown(event, fn, index) {
110
- const list = this.visibleNodes();
111
- switch (event.key) {
112
- case 'ArrowDown':
113
- event.preventDefault();
114
- this._focusStep(list, index, +1);
115
- break;
116
- case 'ArrowUp':
117
- event.preventDefault();
118
- this._focusStep(list, index, -1);
119
- break;
120
- case 'Home':
121
- event.preventDefault();
122
- this._focusFrom(list, 0, +1);
123
- break;
124
- case 'End':
125
- event.preventDefault();
126
- this._focusFrom(list, list.length - 1, -1);
127
- break;
128
- case 'ArrowRight':
129
- event.preventDefault();
130
- if (fn.hasChildren && !fn.isExpanded) {
131
- this.toggle(fn.node);
132
- }
133
- else if (fn.hasChildren && fn.isExpanded) {
134
- this._focusStep(list, index, +1);
135
- }
136
- break;
137
- case 'ArrowLeft':
138
- event.preventDefault();
139
- if (fn.hasChildren && fn.isExpanded) {
140
- this.toggle(fn.node);
141
- }
142
- else {
143
- this._focusParent(list, index, fn.depth);
144
- }
145
- break;
146
- case 'Enter':
147
- case ' ':
148
- event.preventDefault();
149
- this.select(fn.node, fn.depth);
150
- this.setActive(fn.node.id);
151
- break;
152
- default:
153
- return;
154
- }
155
- }
156
- /** Move focus by `dir` steps from `from`, skipping disabled rows. */
157
- _focusStep(list, from, dir) {
158
- for (let i = from + dir; i >= 0 && i < list.length; i += dir) {
159
- if (!list[i].node.disabled) {
160
- this._focus(list[i].node.id);
161
- return;
162
- }
163
- }
164
- }
165
- /** From `start`, find the first enabled row in direction `dir` and focus it. */
166
- _focusFrom(list, start, dir) {
167
- for (let i = start; i >= 0 && i < list.length; i += dir) {
168
- if (!list[i].node.disabled) {
169
- this._focus(list[i].node.id);
170
- return;
171
- }
172
- }
173
- }
174
- /** Focus the parent row (nearest previous row with a smaller depth). */
175
- _focusParent(list, index, depth) {
176
- for (let i = index - 1; i >= 0; i--) {
177
- if (list[i].depth < depth) {
178
- this._focus(list[i].node.id);
179
- return;
180
- }
181
- }
182
- }
183
- /** Set the active id and move DOM focus to that row (after any re-render). */
184
- _focus(id) {
185
- this.setActive(id);
186
- queueMicrotask(() => {
187
- const rows = this.host.nativeElement.querySelectorAll('[data-tree-id]');
188
- rows.forEach(el => { if (el.dataset['treeId'] === id)
189
- el.focus(); });
190
- });
191
- }
192
- _flatten(nodes, depth, expanded) {
193
- const result = [];
194
- for (let i = 0; i < nodes.length; i++) {
195
- const node = nodes[i];
196
- const hasChildren = !!node.children?.length;
197
- const isExp = expanded.has(node.id);
198
- result.push({ node, depth, isLast: i === nodes.length - 1, hasChildren, isExpanded: isExp });
199
- if (isExp && node.children?.length) {
200
- result.push(...this._flatten(node.children, depth + 1, expanded));
201
- }
202
- }
203
- return result;
204
- }
205
- _collectExpanded(nodes, ids) {
206
- for (const n of nodes) {
207
- if (n.expanded)
208
- ids.add(n.id);
209
- if (n.children)
210
- this._collectExpanded(n.children, ids);
211
- }
212
- }
213
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SvTreeViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
214
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.18", type: SvTreeViewComponent, isStandalone: true, selector: "sv-tree-view", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, showLines: { classPropertyName: "showLines", publicName: "showLines", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, expandedIds: { classPropertyName: "expandedIds", publicName: "expandedIds", isSignal: true, isRequired: false, transformFunction: null }, selectedId: { classPropertyName: "selectedId", publicName: "selectedId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodeClick: "nodeClick", nodeExpand: "nodeExpand", nodeCollapse: "nodeCollapse", nodeSelect: "nodeSelect", retry: "retry", expandedIds: "expandedIdsChange", selectedId: "selectedIdChange" }, ngImport: i0, template: `
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, ElementRef, computed, effect, inject, input, model, output, signal, untracked } from "@angular/core";
3
+ import { DOCUMENT } from "@angular/common";
4
+ import { SvIconComponent } from "@styloviz/icons";
5
+ import { SvEmptyShellComponent, SvErrorShellComponent, SvSkeletonShellComponent, createTypeahead, svAttrSelector, svCollectionTarget, svCutHierarchyCycles, svIsTypeaheadKey, svRecoverFocus, svSuccessorIndex, svWarnUnvirtualizedCeiling, warnOnDuplicateItemKeys } from "@styloviz/core";
6
+ var SvTreeViewComponent = class SvTreeViewComponent {
7
+ nodes = input([], ...ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []);
8
+ selectable = input(true, ...ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []);
9
+ showLines = input(true, ...ngDevMode ? [{ debugName: "showLines" }] : /* istanbul ignore next */ []);
10
+ ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
11
+ loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
12
+ error = input(null, ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
13
+ emptyText = input("No items to display", ...ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []);
14
+ nodeClick = output();
15
+ nodeExpand = output();
16
+ nodeCollapse = output();
17
+ nodeSelect = output();
18
+ retry = output();
19
+ expandedIds = model(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "expandedIds" }] : /* istanbul ignore next */ []);
20
+ selectedId = model(null, ...ngDevMode ? [{ debugName: "selectedId" }] : /* istanbul ignore next */ []);
21
+ activeId = signal(null, ...ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []);
22
+ _nodes = signal([], ...ngDevMode ? [{ debugName: "_nodes" }] : /* istanbul ignore next */ []);
23
+ _warnedBindings = /* @__PURE__ */ new Set();
24
+ host = inject(ElementRef);
25
+ _doc = inject(DOCUMENT);
26
+ visibleNodes = computed(() => {
27
+ const rows = this._flatten(this._nodes(), 0, this.expandedIds());
28
+ warnOnDuplicateItemKeys(rows, (n) => n.node.id, "sv-tree-view [nodes]");
29
+ return rows;
30
+ }, ...ngDevMode ? [{ debugName: "visibleNodes" }] : /* istanbul ignore next */ []);
31
+ _seededFromNodes = false;
32
+ constructor() {
33
+ effect(() => {
34
+ const incoming = svCutHierarchyCycles(this.nodes(), "sv-tree-view").nodes;
35
+ const focusedRow = untracked(() => this._focusedRowSnapshot());
36
+ this._nodes.set(incoming);
37
+ if (focusedRow) this._recoverAfterNodesChange(focusedRow);
38
+ if (this._seededFromNodes || incoming.length === 0) return;
39
+ this._seededFromNodes = true;
40
+ const ids = /* @__PURE__ */ new Set();
41
+ this._collectExpanded(incoming, ids);
42
+ if (ids.size && untracked(this.expandedIds).size === 0) this.expandedIds.set(ids);
43
+ this.activeId.set(this.visibleNodes()[0]?.node.id ?? null);
44
+ });
45
+ effect(() => svWarnUnvirtualizedCeiling("sv-tree-view", this.visibleNodes().length, false));
46
+ effect(() => this._warnIgnoredBindings());
47
+ }
48
+ _warnIgnoredBindings() {
49
+ if (typeof ngDevMode === "undefined" || !ngDevMode) return;
50
+ if (!this.ariaLabel().trim() && !this.host.nativeElement.hasAttribute("aria-labelledby") && !this._warnedBindings.has("no-name")) {
51
+ this._warnedBindings.add("no-name");
52
+ console.warn("[styloviz] sv-tree-view: the tree has no accessible name — [ariaLabel] is empty and the host has no aria-labelledby, so a screen reader announces only \"tree\". Pass [ariaLabel]=\"'Project files'\" (or similar).");
53
+ }
54
+ }
55
+ _focusedRowSnapshot() {
56
+ const active = this._doc.activeElement;
57
+ if (!active || !this.host.nativeElement.contains(active)) return null;
58
+ const id = active.closest("[data-tree-id]")?.dataset["treeId"];
59
+ if (id === void 0) return null;
60
+ return {
61
+ id,
62
+ index: this.visibleNodes().findIndex((fn) => fn.node.id === id)
63
+ };
64
+ }
65
+ _recoverAfterNodesChange(was) {
66
+ setTimeout(() => {
67
+ const list = this.visibleNodes();
68
+ if (list.some((fn) => fn.node.id === was.id)) return;
69
+ const next = list[svSuccessorIndex(was.index, list.length)];
70
+ if (next) this.setActive(next.node.id);
71
+ const root = this.host.nativeElement;
72
+ const successor = next ? root.querySelector(svAttrSelector("data-tree-id", next.node.id)) : null;
73
+ if (successor && !next?.node.disabled) successor.tabIndex = 0;
74
+ svRecoverFocus({
75
+ to: [successor],
76
+ fallback: root.querySelector("[role=\"tree\"]")
77
+ });
78
+ }, 0);
79
+ }
80
+ toggle(node) {
81
+ if (node.disabled) return;
82
+ const ids = new Set(this.expandedIds());
83
+ const collapsing = ids.has(node.id);
84
+ if (collapsing) ids.delete(node.id);
85
+ else ids.add(node.id);
86
+ this.expandedIds.set(ids);
87
+ if (collapsing) this._repairFocus(node.id);
88
+ if (collapsing) this.nodeCollapse.emit(node);
89
+ else this.nodeExpand.emit(node);
90
+ }
91
+ _repairFocus(preferredId) {
92
+ const active = this._doc.activeElement;
93
+ if (!active || !this.host.nativeElement.contains(active)) return;
94
+ const activeRowId = active.closest("[data-tree-id]")?.dataset["treeId"] ?? null;
95
+ if (activeRowId === null) return;
96
+ const list = this.visibleNodes();
97
+ if (list.some((fn) => fn.node.id === activeRowId)) return;
98
+ const target = list.some((fn) => fn.node.id === preferredId) ? preferredId : this._tabStopId();
99
+ if (target) this._focus(target);
100
+ }
101
+ depthArray(depth) {
102
+ return Array.from({ length: depth }, (_, i) => i);
103
+ }
104
+ select(node, depth) {
105
+ if (node.disabled || !this.selectable()) return;
106
+ this.selectedId.set(node.id);
107
+ this.nodeSelect.emit(node);
108
+ this.nodeClick.emit({
109
+ node,
110
+ depth
111
+ });
112
+ }
113
+ isSelected(id) {
114
+ return this.selectedId() === id;
115
+ }
116
+ _tabStopId = computed(() => {
117
+ const list = this.visibleNodes();
118
+ const active = this.activeId();
119
+ if (active !== null && list.some((fn) => fn.node.id === active)) return active;
120
+ return list[0]?.node.id ?? null;
121
+ }, ...ngDevMode ? [{ debugName: "_tabStopId" }] : /* istanbul ignore next */ []);
122
+ treeTabIndex(id) {
123
+ return id === this._tabStopId() ? 0 : -1;
124
+ }
125
+ setActive(id) {
126
+ this.activeId.set(id);
127
+ }
128
+ onKeydown(event, fn, index) {
129
+ const list = this.visibleNodes();
130
+ switch (event.key) {
131
+ case "ArrowDown":
132
+ event.preventDefault();
133
+ this._focusStep(list, index, 1);
134
+ break;
135
+ case "ArrowUp":
136
+ event.preventDefault();
137
+ this._focusStep(list, index, -1);
138
+ break;
139
+ case "Home":
140
+ event.preventDefault();
141
+ this._focusFrom(list, 0, 1);
142
+ break;
143
+ case "End":
144
+ event.preventDefault();
145
+ this._focusFrom(list, list.length - 1, -1);
146
+ break;
147
+ case "PageDown":
148
+ case "PageUp": {
149
+ event.preventDefault();
150
+ const next = svCollectionTarget(event.key, list.length, index, { pageSize: 10 }) ?? index;
151
+ const dir = event.key === "PageDown" ? 1 : -1;
152
+ if (list[next]?.node.disabled) this._focusFrom(list, next, dir);
153
+ else if (list[next]) this._focus(list[next].node.id);
154
+ break;
155
+ }
156
+ case "ArrowRight":
157
+ event.preventDefault();
158
+ if (fn.hasChildren && !fn.isExpanded) this.toggle(fn.node);
159
+ else if (fn.hasChildren && fn.isExpanded) this._focusStep(list, index, 1);
160
+ break;
161
+ case "ArrowLeft":
162
+ event.preventDefault();
163
+ if (fn.hasChildren && fn.isExpanded) this.toggle(fn.node);
164
+ else this._focusParent(list, index, fn.depth);
165
+ break;
166
+ case "Enter":
167
+ case " ":
168
+ event.preventDefault();
169
+ this.select(fn.node, fn.depth);
170
+ this.setActive(fn.node.id);
171
+ break;
172
+ default:
173
+ this._typeahead(event, list, index);
174
+ return;
175
+ }
176
+ }
177
+ _typeaheadBuffer = createTypeahead({ labelOf: (fn) => fn.node.label });
178
+ _typeahead(event, list, index) {
179
+ if (!svIsTypeaheadKey(event)) return;
180
+ const enabled = list.filter((fn) => !fn.node.disabled);
181
+ const current = enabled.findIndex((fn) => fn.node.id === list[index]?.node.id);
182
+ const next = this._typeaheadBuffer.handle(event.key, enabled, current);
183
+ if (next === null) return;
184
+ event.preventDefault();
185
+ this._focus(enabled[next].node.id);
186
+ }
187
+ _focusStep(list, from, dir) {
188
+ for (let i = from + dir; i >= 0 && i < list.length; i += dir) if (!list[i].node.disabled) {
189
+ this._focus(list[i].node.id);
190
+ return;
191
+ }
192
+ }
193
+ _focusFrom(list, start, dir) {
194
+ for (let i = start; i >= 0 && i < list.length; i += dir) if (!list[i].node.disabled) {
195
+ this._focus(list[i].node.id);
196
+ return;
197
+ }
198
+ }
199
+ _focusParent(list, index, depth) {
200
+ for (let i = index - 1; i >= 0; i--) if (list[i].depth < depth) {
201
+ this._focus(list[i].node.id);
202
+ return;
203
+ }
204
+ }
205
+ _focus(id) {
206
+ this.setActive(id);
207
+ setTimeout(() => {
208
+ this.host.nativeElement.querySelectorAll("[data-tree-id]").forEach((el) => {
209
+ if (el.dataset["treeId"] === id) el.focus();
210
+ });
211
+ }, 0);
212
+ }
213
+ _flatten(nodes, depth, expanded) {
214
+ const out = [];
215
+ this._flattenInto(out, nodes, depth, expanded);
216
+ return out;
217
+ }
218
+ _flattenInto(out, nodes, depth, expanded) {
219
+ for (let i = 0; i < nodes.length; i++) {
220
+ const node = nodes[i];
221
+ const hasChildren = !!node.children?.length;
222
+ const isExp = expanded.has(node.id);
223
+ out.push({
224
+ node,
225
+ depth,
226
+ isLast: i === nodes.length - 1,
227
+ hasChildren,
228
+ isExpanded: isExp
229
+ });
230
+ if (isExp && node.children?.length) this._flattenInto(out, node.children, depth + 1, expanded);
231
+ }
232
+ }
233
+ _collectExpanded(nodes, ids) {
234
+ for (const n of nodes) {
235
+ if (n.expanded) ids.add(n.id);
236
+ if (n.children) this._collectExpanded(n.children, ids);
237
+ }
238
+ }
239
+ static ɵfac = i0.ɵɵngDeclareFactory({
240
+ minVersion: "12.0.0",
241
+ version: "22.2.0",
242
+ ngImport: i0,
243
+ type: SvTreeViewComponent,
244
+ deps: [],
245
+ target: i0.ɵɵFactoryTarget.Component
246
+ });
247
+ static ɵcmp = i0.ɵɵngDeclareComponent({
248
+ minVersion: "17.0.0",
249
+ version: "22.2.0",
250
+ type: SvTreeViewComponent,
251
+ isStandalone: true,
252
+ selector: "sv-tree-view",
253
+ inputs: {
254
+ nodes: {
255
+ classPropertyName: "nodes",
256
+ publicName: "nodes",
257
+ isSignal: true,
258
+ isRequired: false,
259
+ transformFunction: null
260
+ },
261
+ selectable: {
262
+ classPropertyName: "selectable",
263
+ publicName: "selectable",
264
+ isSignal: true,
265
+ isRequired: false,
266
+ transformFunction: null
267
+ },
268
+ showLines: {
269
+ classPropertyName: "showLines",
270
+ publicName: "showLines",
271
+ isSignal: true,
272
+ isRequired: false,
273
+ transformFunction: null
274
+ },
275
+ ariaLabel: {
276
+ classPropertyName: "ariaLabel",
277
+ publicName: "ariaLabel",
278
+ isSignal: true,
279
+ isRequired: false,
280
+ transformFunction: null
281
+ },
282
+ loading: {
283
+ classPropertyName: "loading",
284
+ publicName: "loading",
285
+ isSignal: true,
286
+ isRequired: false,
287
+ transformFunction: null
288
+ },
289
+ error: {
290
+ classPropertyName: "error",
291
+ publicName: "error",
292
+ isSignal: true,
293
+ isRequired: false,
294
+ transformFunction: null
295
+ },
296
+ emptyText: {
297
+ classPropertyName: "emptyText",
298
+ publicName: "emptyText",
299
+ isSignal: true,
300
+ isRequired: false,
301
+ transformFunction: null
302
+ },
303
+ expandedIds: {
304
+ classPropertyName: "expandedIds",
305
+ publicName: "expandedIds",
306
+ isSignal: true,
307
+ isRequired: false,
308
+ transformFunction: null
309
+ },
310
+ selectedId: {
311
+ classPropertyName: "selectedId",
312
+ publicName: "selectedId",
313
+ isSignal: true,
314
+ isRequired: false,
315
+ transformFunction: null
316
+ }
317
+ },
318
+ outputs: {
319
+ nodeClick: "nodeClick",
320
+ nodeExpand: "nodeExpand",
321
+ nodeCollapse: "nodeCollapse",
322
+ nodeSelect: "nodeSelect",
323
+ retry: "retry",
324
+ expandedIds: "expandedIdsChange",
325
+ selectedId: "selectedIdChange"
326
+ },
327
+ ngImport: i0,
328
+ template: `
215
329
  @if (loading()) {
216
330
  <div class="p-2" data-sv-state="loading">
217
331
  <sv-skeleton-shell variant="list" [rows]="5" ariaLabel="Loading tree" />
@@ -225,15 +339,14 @@ class SvTreeViewComponent {
225
339
  />
226
340
  } @else {
227
341
 
228
- <div class="sv-tree-view select-none" role="tree">
342
+ <div class="sv-tree-view select-none" role="tree" [attr.aria-label]="ariaLabel().trim() || null">
229
343
  @for (fn of visibleNodes(); track fn.node.id) {
230
- <div class="group flex items-center gap-1 rounded-lg px-1 outline-none transition-colors duration-100 cursor-pointer focus-visible:ring-2 focus-visible:ring-indigo-400"
344
+ <div class="group flex items-center gap-1 rounded-lg px-1 outline-none transition-colors duration-100 cursor-pointer focus-visible:ring-2 focus-visible:ring-brandaccent-400"
231
345
  [class]="fn.node.disabled
232
346
  ? 'opacity-40 cursor-not-allowed py-1.5'
233
347
  : isSelected(fn.node.id)
234
- ? 'py-1.5 bg-indigo-50 dark:bg-indigo-900/25'
348
+ ? 'py-1.5 bg-brandaccent-50 dark:bg-brandaccent-900/25'
235
349
  : 'py-1.5 hover:bg-gray-100/70 dark:hover:bg-gray-800/50'"
236
- [style.paddingLeft.px]="fn.depth * 20 + 4"
237
350
  (click)="select(fn.node, fn.depth); setActive(fn.node.id)"
238
351
  (keydown)="onKeydown($event, fn, $index)"
239
352
  role="treeitem"
@@ -241,21 +354,39 @@ class SvTreeViewComponent {
241
354
  [attr.tabindex]="treeTabIndex(fn.node.id)"
242
355
  [attr.aria-level]="fn.depth + 1"
243
356
  [attr.aria-expanded]="fn.hasChildren ? fn.isExpanded : null"
244
- [attr.aria-selected]="isSelected(fn.node.id)">
357
+ [attr.aria-selected]="selectable() ? isSelected(fn.node.id) : null">
358
+
359
+ <!--
360
+ Depth spacers, one per level, carrying the optional connector guide.
361
+ Indentation used to be a paddingLeft on the row, which left
362
+ showLines - declared, documented, default true - with nothing to
363
+ hang a line on, so it did nothing at all. The Pro twin has rendered
364
+ these all along; this is the same 20px-per-level geometry.
365
+ (No backticks in here: this template is an inline JS literal.)
366
+ -->
367
+ @for (d of depthArray(fn.depth); track d) {
368
+ <span class="relative w-5 shrink-0 self-stretch" aria-hidden="true">
369
+ @if (showLines()) {
370
+ <span class="absolute inset-y-0 left-1/2 w-px -translate-x-1/2
371
+ bg-gray-200 dark:bg-gray-700/70"></span>
372
+ }
373
+ </span>
374
+ }
245
375
 
246
376
  <!-- Chevron toggle -->
377
+ <!-- Out of the tab order (X-10): ArrowRight/ArrowLeft on the row
378
+ expand and collapse, so a 1,500-row tree stays ONE tab stop. -->
247
379
  <button type="button"
380
+ tabindex="-1"
248
381
  class="flex h-5 w-5 shrink-0 items-center justify-center rounded
249
382
  text-gray-400 transition-all hover:text-gray-700 dark:hover:text-gray-200
250
- focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-indigo-400"
383
+ focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-brandaccent-400"
251
384
  [class.invisible]="!fn.hasChildren"
252
385
  (click)="toggle(fn.node); $event.stopPropagation()"
253
- [attr.aria-label]="fn.isExpanded ? 'Collapse' : 'Expand'">
254
- <svg class="h-3.5 w-3.5 transition-transform duration-150"
255
- [class.rotate-90]="fn.isExpanded"
256
- fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
257
- <path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5"/>
258
- </svg>
386
+ [attr.aria-label]="(fn.isExpanded ? 'Collapse ' : 'Expand ') + fn.node.label">
387
+ <sv-icon name="chevron-right"
388
+ [cssClass]="'h-3.5 w-3.5 transition-transform duration-150' + (fn.isExpanded ? ' rotate-90' : '')"
389
+ [strokeWidth]="2" />
259
390
  </button>
260
391
 
261
392
  <!-- Icon -->
@@ -266,7 +397,7 @@ class SvTreeViewComponent {
266
397
  <!-- Label -->
267
398
  <span class="flex-1 truncate text-[13px] font-medium"
268
399
  [class]="isSelected(fn.node.id)
269
- ? 'text-indigo-700 dark:text-indigo-300'
400
+ ? 'text-brandaccent-700 dark:text-brandaccent-300'
270
401
  : 'text-gray-800 dark:text-gray-100'">
271
402
  {{ fn.node.label }}
272
403
  </span>
@@ -288,16 +419,88 @@ class SvTreeViewComponent {
288
419
  </div>
289
420
  }
290
421
 
291
- `, isInline: true, dependencies: [{ kind: "component", type: SvSkeletonShellComponent, selector: "sv-skeleton-shell", inputs: ["variant", "rows", "columns", "chartHeight", "ariaLabel", "customClass"] }, { kind: "component", type: SvErrorShellComponent, selector: "sv-error-shell", inputs: ["error", "title", "retryLabel", "retryable", "compact", "showStatus", "customClass"], outputs: ["retry"] }, { kind: "component", type: SvEmptyShellComponent, selector: "sv-empty-shell", inputs: ["reason", "title", "message", "actionLabel", "compact", "customClass"], outputs: ["action"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
292
- }
293
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SvTreeViewComponent, decorators: [{
294
- type: Component,
295
- args: [{
296
- imports: [SvSkeletonShellComponent, SvErrorShellComponent, SvEmptyShellComponent],
297
- selector: 'sv-tree-view',
298
- standalone: true,
299
- changeDetection: ChangeDetectionStrategy.OnPush,
300
- template: `
422
+ `,
423
+ isInline: true,
424
+ dependencies: [
425
+ {
426
+ kind: "component",
427
+ type: SvIconComponent,
428
+ selector: "sv-icon",
429
+ inputs: [
430
+ "name",
431
+ "size",
432
+ "strokeWidth",
433
+ "weight",
434
+ "title",
435
+ "flip",
436
+ "rotate",
437
+ "cssClass"
438
+ ]
439
+ },
440
+ {
441
+ kind: "component",
442
+ type: SvSkeletonShellComponent,
443
+ selector: "sv-skeleton-shell",
444
+ inputs: [
445
+ "variant",
446
+ "rows",
447
+ "columns",
448
+ "chartHeight",
449
+ "ariaLabel",
450
+ "customClass"
451
+ ]
452
+ },
453
+ {
454
+ kind: "component",
455
+ type: SvErrorShellComponent,
456
+ selector: "sv-error-shell",
457
+ inputs: [
458
+ "error",
459
+ "title",
460
+ "retryLabel",
461
+ "retryable",
462
+ "compact",
463
+ "showStatus",
464
+ "customClass"
465
+ ],
466
+ outputs: ["retry"]
467
+ },
468
+ {
469
+ kind: "component",
470
+ type: SvEmptyShellComponent,
471
+ selector: "sv-empty-shell",
472
+ inputs: [
473
+ "reason",
474
+ "title",
475
+ "message",
476
+ "actionLabel",
477
+ "compact",
478
+ "customClass"
479
+ ],
480
+ outputs: ["action"]
481
+ }
482
+ ],
483
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
484
+ });
485
+ };
486
+ i0.ɵɵngDeclareClassMetadata({
487
+ minVersion: "12.0.0",
488
+ version: "22.2.0",
489
+ ngImport: i0,
490
+ type: SvTreeViewComponent,
491
+ decorators: [{
492
+ type: Component,
493
+ args: [{
494
+ imports: [
495
+ SvIconComponent,
496
+ SvSkeletonShellComponent,
497
+ SvErrorShellComponent,
498
+ SvEmptyShellComponent
499
+ ],
500
+ selector: "sv-tree-view",
501
+ standalone: true,
502
+ changeDetection: ChangeDetectionStrategy.OnPush,
503
+ template: `
301
504
  @if (loading()) {
302
505
  <div class="p-2" data-sv-state="loading">
303
506
  <sv-skeleton-shell variant="list" [rows]="5" ariaLabel="Loading tree" />
@@ -311,15 +514,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImpo
311
514
  />
312
515
  } @else {
313
516
 
314
- <div class="sv-tree-view select-none" role="tree">
517
+ <div class="sv-tree-view select-none" role="tree" [attr.aria-label]="ariaLabel().trim() || null">
315
518
  @for (fn of visibleNodes(); track fn.node.id) {
316
- <div class="group flex items-center gap-1 rounded-lg px-1 outline-none transition-colors duration-100 cursor-pointer focus-visible:ring-2 focus-visible:ring-indigo-400"
519
+ <div class="group flex items-center gap-1 rounded-lg px-1 outline-none transition-colors duration-100 cursor-pointer focus-visible:ring-2 focus-visible:ring-brandaccent-400"
317
520
  [class]="fn.node.disabled
318
521
  ? 'opacity-40 cursor-not-allowed py-1.5'
319
522
  : isSelected(fn.node.id)
320
- ? 'py-1.5 bg-indigo-50 dark:bg-indigo-900/25'
523
+ ? 'py-1.5 bg-brandaccent-50 dark:bg-brandaccent-900/25'
321
524
  : 'py-1.5 hover:bg-gray-100/70 dark:hover:bg-gray-800/50'"
322
- [style.paddingLeft.px]="fn.depth * 20 + 4"
323
525
  (click)="select(fn.node, fn.depth); setActive(fn.node.id)"
324
526
  (keydown)="onKeydown($event, fn, $index)"
325
527
  role="treeitem"
@@ -327,21 +529,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImpo
327
529
  [attr.tabindex]="treeTabIndex(fn.node.id)"
328
530
  [attr.aria-level]="fn.depth + 1"
329
531
  [attr.aria-expanded]="fn.hasChildren ? fn.isExpanded : null"
330
- [attr.aria-selected]="isSelected(fn.node.id)">
532
+ [attr.aria-selected]="selectable() ? isSelected(fn.node.id) : null">
533
+
534
+ <!--
535
+ Depth spacers, one per level, carrying the optional connector guide.
536
+ Indentation used to be a paddingLeft on the row, which left
537
+ showLines - declared, documented, default true - with nothing to
538
+ hang a line on, so it did nothing at all. The Pro twin has rendered
539
+ these all along; this is the same 20px-per-level geometry.
540
+ (No backticks in here: this template is an inline JS literal.)
541
+ -->
542
+ @for (d of depthArray(fn.depth); track d) {
543
+ <span class="relative w-5 shrink-0 self-stretch" aria-hidden="true">
544
+ @if (showLines()) {
545
+ <span class="absolute inset-y-0 left-1/2 w-px -translate-x-1/2
546
+ bg-gray-200 dark:bg-gray-700/70"></span>
547
+ }
548
+ </span>
549
+ }
331
550
 
332
551
  <!-- Chevron toggle -->
552
+ <!-- Out of the tab order (X-10): ArrowRight/ArrowLeft on the row
553
+ expand and collapse, so a 1,500-row tree stays ONE tab stop. -->
333
554
  <button type="button"
555
+ tabindex="-1"
334
556
  class="flex h-5 w-5 shrink-0 items-center justify-center rounded
335
557
  text-gray-400 transition-all hover:text-gray-700 dark:hover:text-gray-200
336
- focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-indigo-400"
558
+ focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-brandaccent-400"
337
559
  [class.invisible]="!fn.hasChildren"
338
560
  (click)="toggle(fn.node); $event.stopPropagation()"
339
- [attr.aria-label]="fn.isExpanded ? 'Collapse' : 'Expand'">
340
- <svg class="h-3.5 w-3.5 transition-transform duration-150"
341
- [class.rotate-90]="fn.isExpanded"
342
- fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
343
- <path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5"/>
344
- </svg>
561
+ [attr.aria-label]="(fn.isExpanded ? 'Collapse ' : 'Expand ') + fn.node.label">
562
+ <sv-icon name="chevron-right"
563
+ [cssClass]="'h-3.5 w-3.5 transition-transform duration-150' + (fn.isExpanded ? ' rotate-90' : '')"
564
+ [strokeWidth]="2" />
345
565
  </button>
346
566
 
347
567
  <!-- Icon -->
@@ -352,7 +572,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImpo
352
572
  <!-- Label -->
353
573
  <span class="flex-1 truncate text-[13px] font-medium"
354
574
  [class]="isSelected(fn.node.id)
355
- ? 'text-indigo-700 dark:text-indigo-300'
575
+ ? 'text-brandaccent-700 dark:text-brandaccent-300'
356
576
  : 'text-gray-800 dark:text-gray-100'">
357
577
  {{ fn.node.label }}
358
578
  </span>
@@ -374,13 +594,111 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImpo
374
594
  </div>
375
595
  }
376
596
 
377
- `,
378
- }]
379
- }], ctorParameters: () => [], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], selectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectable", required: false }] }], showLines: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLines", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], nodeClick: [{ type: i0.Output, args: ["nodeClick"] }], nodeExpand: [{ type: i0.Output, args: ["nodeExpand"] }], nodeCollapse: [{ type: i0.Output, args: ["nodeCollapse"] }], nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }], retry: [{ type: i0.Output, args: ["retry"] }], expandedIds: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedIds", required: false }] }, { type: i0.Output, args: ["expandedIdsChange"] }], selectedId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedId", required: false }] }, { type: i0.Output, args: ["selectedIdChange"] }] } });
380
-
381
- /**
382
- * Generated bundle index. Do not edit.
383
- */
384
-
597
+ `
598
+ }]
599
+ }],
600
+ ctorParameters: () => [],
601
+ propDecorators: {
602
+ nodes: [{
603
+ type: i0.Input,
604
+ args: [{
605
+ isSignal: true,
606
+ alias: "nodes",
607
+ required: false
608
+ }]
609
+ }],
610
+ selectable: [{
611
+ type: i0.Input,
612
+ args: [{
613
+ isSignal: true,
614
+ alias: "selectable",
615
+ required: false
616
+ }]
617
+ }],
618
+ showLines: [{
619
+ type: i0.Input,
620
+ args: [{
621
+ isSignal: true,
622
+ alias: "showLines",
623
+ required: false
624
+ }]
625
+ }],
626
+ ariaLabel: [{
627
+ type: i0.Input,
628
+ args: [{
629
+ isSignal: true,
630
+ alias: "ariaLabel",
631
+ required: false
632
+ }]
633
+ }],
634
+ loading: [{
635
+ type: i0.Input,
636
+ args: [{
637
+ isSignal: true,
638
+ alias: "loading",
639
+ required: false
640
+ }]
641
+ }],
642
+ error: [{
643
+ type: i0.Input,
644
+ args: [{
645
+ isSignal: true,
646
+ alias: "error",
647
+ required: false
648
+ }]
649
+ }],
650
+ emptyText: [{
651
+ type: i0.Input,
652
+ args: [{
653
+ isSignal: true,
654
+ alias: "emptyText",
655
+ required: false
656
+ }]
657
+ }],
658
+ nodeClick: [{
659
+ type: i0.Output,
660
+ args: ["nodeClick"]
661
+ }],
662
+ nodeExpand: [{
663
+ type: i0.Output,
664
+ args: ["nodeExpand"]
665
+ }],
666
+ nodeCollapse: [{
667
+ type: i0.Output,
668
+ args: ["nodeCollapse"]
669
+ }],
670
+ nodeSelect: [{
671
+ type: i0.Output,
672
+ args: ["nodeSelect"]
673
+ }],
674
+ retry: [{
675
+ type: i0.Output,
676
+ args: ["retry"]
677
+ }],
678
+ expandedIds: [{
679
+ type: i0.Input,
680
+ args: [{
681
+ isSignal: true,
682
+ alias: "expandedIds",
683
+ required: false
684
+ }]
685
+ }, {
686
+ type: i0.Output,
687
+ args: ["expandedIdsChange"]
688
+ }],
689
+ selectedId: [{
690
+ type: i0.Input,
691
+ args: [{
692
+ isSignal: true,
693
+ alias: "selectedId",
694
+ required: false
695
+ }]
696
+ }, {
697
+ type: i0.Output,
698
+ args: ["selectedIdChange"]
699
+ }]
700
+ }
701
+ });
385
702
  export { SvTreeViewComponent };
386
- //# sourceMappingURL=styloviz-tree-view.mjs.map
703
+
704
+ //# sourceMappingURL=styloviz-tree-view.mjs.map