@styloviz/tree-view 0.1.4 → 0.1.5

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/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # @styloviz/tree-view
2
2
 
3
- > 8 premium variants: collapsible tree, file explorer, tri-state checkboxes, org chart, tree table, searchable, drag & drop reordering and lazy load.
3
+ > 8 premium variants: collapsible tree, file explorer, tri-state checkboxes, org chart, tree table, searchable, drag & drop reordering and lazy load. Lazy loading, the tree-table columns and drag & drop reordering are Pro (`sv-tree-view-pro`); the free component renders the nodes you give it.
4
4
 
5
5
  Part of the **Styloviz UI Kit** — a premium Angular 21 + Tailwind CSS 4 dashboard component library. Standalone, `OnPush`, strongly typed, dark-mode ready.
6
6
 
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install @styloviz/tree-view
10
+ npm install @styloviz/core @styloviz/tree-view
11
11
  ```
12
12
 
13
- Requires `@angular/core` and `@angular/common` >= 21. Self-contained — no other Styloviz packages required. Prefer everything at once? `@styloviz/all` installs the whole free tier in one command.
13
+ Requires `@angular/core` and `@angular/common` >= 21. Also needs `@styloviz/core` — listed above so no extra step is required on npm (on pnpm/yarn, list it yourself). Prefer everything at once? `@styloviz/all` installs the whole free tier in one command.
14
14
 
15
15
  ## Usage
16
16
 
@@ -34,6 +34,11 @@ export class DemoComponent {}
34
34
  | `nodes` | `TreeNode[]` | `[]` | Tree node data (nested children, optional icons). |
35
35
  | `selectable` | `boolean` | `true` | Enable single-row selection highlight. |
36
36
  | `showLines` | `boolean` | `true` | Show vertical connector guide lines. |
37
+ | `loading` | `boolean` | `false` | True while the tree is being fetched. Replaces it with a placeholder. |
38
+ | `error` | `SvDataError \| string \| null` | `null` | Load failure. Use `toSvDataError()` from ` |
39
+ | `emptyText` | `string` | `'No items to display'` | Copy for the empty state. |
40
+ | `expandedIds` | `Set<string> (two-way)` | `new Set()` | Expanded node ids. Two-way bindable, so an expansion state loaded from the server — or restored from a URL — survives a reload. |
41
+ | `selectedId` | `string \| null (two-way)` | `null` | The selected node id. Two-way bindable. |
37
42
 
38
43
  ## Outputs
39
44
 
@@ -43,6 +48,7 @@ export class DemoComponent {}
43
48
  | `nodeExpand` | `TreeNode` | — |
44
49
  | `nodeCollapse` | `TreeNode` | — |
45
50
  | `nodeSelect` | `TreeNode` | — |
51
+ | `retry` | `void` | The host should re-run the failed load. |
46
52
 
47
53
  ## Documentation
48
54
 
@@ -1,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, output, signal, inject, ElementRef, computed, ChangeDetectionStrategy, Component } 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';
3
4
 
4
5
  // ─── Component ────────────────────────────────────────────────────────────────
5
6
  /**
@@ -21,24 +22,55 @@ class SvTreeViewComponent {
21
22
  selectable = input(true, ...(ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []));
22
23
  /** Show vertical connector guide lines. @default true */
23
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 */ []));
24
38
  nodeClick = output();
25
39
  nodeExpand = output();
26
40
  nodeCollapse = output();
27
41
  nodeSelect = output();
28
- expandedIds = signal(new Set(), ...(ngDevMode ? [{ debugName: "expandedIds" }] : /* istanbul ignore next */ []));
29
- selectedId = signal(null, ...(ngDevMode ? [{ debugName: "selectedId" }] : /* istanbul ignore next */ []));
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 */ []));
30
51
  /** The treeitem currently in the tab order (roving tabindex). */
31
52
  activeId = signal(null, ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
32
53
  _nodes = signal([], ...(ngDevMode ? [{ debugName: "_nodes" }] : /* istanbul ignore next */ []));
33
54
  host = inject(ElementRef);
34
55
  visibleNodes = computed(() => this._flatten(this._nodes(), 0, this.expandedIds()), ...(ngDevMode ? [{ debugName: "visibleNodes" }] : /* istanbul ignore next */ []));
35
- ngOnInit() {
36
- this._nodes.set(this.nodes());
37
- const ids = new Set();
38
- this._collectExpanded(this.nodes(), ids);
39
- this.expandedIds.set(ids);
40
- // Seed the roving tabindex on the first node so the tree is tab-reachable.
41
- this.activeId.set(this.visibleNodes()[0]?.node.id ?? null);
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
+ });
42
74
  }
43
75
  toggle(node) {
44
76
  if (node.disabled)
@@ -178,8 +210,21 @@ class SvTreeViewComponent {
178
210
  this._collectExpanded(n.children, ids);
179
211
  }
180
212
  }
181
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: SvTreeViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
182
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.13", 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 } }, outputs: { nodeClick: "nodeClick", nodeExpand: "nodeExpand", nodeCollapse: "nodeCollapse", nodeSelect: "nodeSelect" }, ngImport: i0, template: `
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: `
215
+ @if (loading()) {
216
+ <div class="p-2" data-sv-state="loading">
217
+ <sv-skeleton-shell variant="list" [rows]="5" ariaLabel="Loading tree" />
218
+ </div>
219
+ } @else if (error()) {
220
+ <sv-error-shell
221
+ [error]="error()"
222
+ title="Could not load this tree"
223
+ (retry)="retry.emit()"
224
+ data-sv-state="error"
225
+ />
226
+ } @else {
227
+
183
228
  <div class="sv-tree-view select-none" role="tree">
184
229
  @for (fn of visibleNodes(); track fn.node.id) {
185
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"
@@ -238,20 +283,34 @@ class SvTreeViewComponent {
238
283
  }
239
284
 
240
285
  @if (!visibleNodes().length) {
241
- <p class="py-8 text-center text-sm text-gray-500 dark:text-gray-400">
242
- No items to display
243
- </p>
286
+ <sv-empty-shell reason="no-data" [title]="emptyText()" data-sv-state="empty" />
244
287
  }
245
288
  </div>
246
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
289
+ }
290
+
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 });
247
292
  }
248
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImport: i0, type: SvTreeViewComponent, decorators: [{
293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SvTreeViewComponent, decorators: [{
249
294
  type: Component,
250
295
  args: [{
296
+ imports: [SvSkeletonShellComponent, SvErrorShellComponent, SvEmptyShellComponent],
251
297
  selector: 'sv-tree-view',
252
298
  standalone: true,
253
299
  changeDetection: ChangeDetectionStrategy.OnPush,
254
300
  template: `
301
+ @if (loading()) {
302
+ <div class="p-2" data-sv-state="loading">
303
+ <sv-skeleton-shell variant="list" [rows]="5" ariaLabel="Loading tree" />
304
+ </div>
305
+ } @else if (error()) {
306
+ <sv-error-shell
307
+ [error]="error()"
308
+ title="Could not load this tree"
309
+ (retry)="retry.emit()"
310
+ data-sv-state="error"
311
+ />
312
+ } @else {
313
+
255
314
  <div class="sv-tree-view select-none" role="tree">
256
315
  @for (fn of visibleNodes(); track fn.node.id) {
257
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"
@@ -310,14 +369,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.13", ngImpo
310
369
  }
311
370
 
312
371
  @if (!visibleNodes().length) {
313
- <p class="py-8 text-center text-sm text-gray-500 dark:text-gray-400">
314
- No items to display
315
- </p>
372
+ <sv-empty-shell reason="no-data" [title]="emptyText()" data-sv-state="empty" />
316
373
  }
317
374
  </div>
375
+ }
376
+
318
377
  `,
319
378
  }]
320
- }], 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 }] }], nodeClick: [{ type: i0.Output, args: ["nodeClick"] }], nodeExpand: [{ type: i0.Output, args: ["nodeExpand"] }], nodeCollapse: [{ type: i0.Output, args: ["nodeCollapse"] }], nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }] } });
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"] }] } });
321
380
 
322
381
  /**
323
382
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"styloviz-tree-view.mjs","sources":["../../../../projects/tree-view-free/src/lib/tree-view.component.ts","../../../../projects/tree-view-free/src/styloviz-tree-view.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n ElementRef,\n inject,\n input,\n OnInit,\n output,\n signal,\n} from '@angular/core';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport interface TreeNode {\n readonly id: string;\n readonly label: string;\n readonly icon?: string;\n children?: TreeNode[];\n readonly expanded?: boolean;\n readonly disabled?: boolean;\n readonly badge?: string;\n}\n\nexport interface FlatNode {\n readonly node: TreeNode;\n readonly depth: number;\n readonly isLast: boolean;\n readonly hasChildren: boolean;\n readonly isExpanded: boolean;\n}\n\nexport interface TreeNodeClickEvent {\n readonly node: TreeNode;\n readonly depth: number;\n}\n\n// ─── Component ────────────────────────────────────────────────────────────────\n\n/**\n * SvTreeViewComponent (Free) — Collapsible single-select tree.\n *\n * For the full 8-variant suite (file explorer, checkbox tri-state,\n * org chart, tree table, searchable, draggable, lazy-load) upgrade to\n * `@styloviz-pro/tree-view`.\n *\n * @example\n * ```html\n * <sv-tree-view [nodes]=\"nodes\" (nodeClick)=\"onNodeClick($event)\" />\n * ```\n */\n@Component({\n selector: 'sv-tree-view',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"sv-tree-view select-none\" role=\"tree\">\n @for (fn of visibleNodes(); track fn.node.id) {\n <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\"\n [class]=\"fn.node.disabled\n ? 'opacity-40 cursor-not-allowed py-1.5'\n : isSelected(fn.node.id)\n ? 'py-1.5 bg-indigo-50 dark:bg-indigo-900/25'\n : 'py-1.5 hover:bg-gray-100/70 dark:hover:bg-gray-800/50'\"\n [style.paddingLeft.px]=\"fn.depth * 20 + 4\"\n (click)=\"select(fn.node, fn.depth); setActive(fn.node.id)\"\n (keydown)=\"onKeydown($event, fn, $index)\"\n role=\"treeitem\"\n [attr.data-tree-id]=\"fn.node.id\"\n [attr.tabindex]=\"treeTabIndex(fn.node.id)\"\n [attr.aria-level]=\"fn.depth + 1\"\n [attr.aria-expanded]=\"fn.hasChildren ? fn.isExpanded : null\"\n [attr.aria-selected]=\"isSelected(fn.node.id)\">\n\n <!-- Chevron toggle -->\n <button type=\"button\"\n class=\"flex h-5 w-5 shrink-0 items-center justify-center rounded\n text-gray-400 transition-all hover:text-gray-700 dark:hover:text-gray-200\n focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-indigo-400\"\n [class.invisible]=\"!fn.hasChildren\"\n (click)=\"toggle(fn.node); $event.stopPropagation()\"\n [attr.aria-label]=\"fn.isExpanded ? 'Collapse' : 'Expand'\">\n <svg class=\"h-3.5 w-3.5 transition-transform duration-150\"\n [class.rotate-90]=\"fn.isExpanded\"\n fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"/>\n </svg>\n </button>\n\n <!-- Icon -->\n @if (fn.node.icon) {\n <span class=\"shrink-0 text-sm\" aria-hidden=\"true\">{{ fn.node.icon }}</span>\n }\n\n <!-- Label -->\n <span class=\"flex-1 truncate text-[13px] font-medium\"\n [class]=\"isSelected(fn.node.id)\n ? 'text-indigo-700 dark:text-indigo-300'\n : 'text-gray-800 dark:text-gray-100'\">\n {{ fn.node.label }}\n </span>\n\n <!-- Badge -->\n @if (fn.node.badge) {\n <span class=\"ml-auto shrink-0 rounded-full bg-gray-100 px-1.5 py-px\n text-[10px] font-semibold text-gray-600\n dark:bg-gray-800 dark:text-gray-300\">\n {{ fn.node.badge }}\n </span>\n }\n </div>\n }\n\n @if (!visibleNodes().length) {\n <p class=\"py-8 text-center text-sm text-gray-500 dark:text-gray-400\">\n No items to display\n </p>\n }\n </div>\n `,\n})\nexport class SvTreeViewComponent implements OnInit {\n /** Tree node data (nested children, optional icons). */\n readonly nodes = input<TreeNode[]>([]);\n /** Enable single-row selection highlight. @default true */\n readonly selectable = input<boolean>(true);\n /** Show vertical connector guide lines. @default true */\n readonly showLines = input<boolean>(true);\n\n readonly nodeClick = output<TreeNodeClickEvent>();\n readonly nodeExpand = output<TreeNode>();\n readonly nodeCollapse = output<TreeNode>();\n readonly nodeSelect = output<TreeNode>();\n\n readonly expandedIds = signal<Set<string>>(new Set());\n readonly selectedId = signal<string | null>(null);\n /** The treeitem currently in the tab order (roving tabindex). */\n readonly activeId = signal<string | null>(null);\n\n private readonly _nodes = signal<TreeNode[]>([]);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n readonly visibleNodes = computed<FlatNode[]>(() =>\n this._flatten(this._nodes(), 0, this.expandedIds())\n );\n\n ngOnInit(): void {\n this._nodes.set(this.nodes());\n const ids = new Set<string>();\n this._collectExpanded(this.nodes(), ids);\n this.expandedIds.set(ids);\n // Seed the roving tabindex on the first node so the tree is tab-reachable.\n this.activeId.set(this.visibleNodes()[0]?.node.id ?? null);\n }\n\n toggle(node: TreeNode): void {\n if (node.disabled) return;\n const ids = new Set(this.expandedIds());\n if (ids.has(node.id)) {\n ids.delete(node.id);\n this.nodeCollapse.emit(node);\n } else {\n ids.add(node.id);\n this.nodeExpand.emit(node);\n }\n this.expandedIds.set(ids);\n }\n\n select(node: TreeNode, depth: number): void {\n if (node.disabled || !this.selectable()) return;\n this.selectedId.set(node.id);\n this.nodeSelect.emit(node);\n this.nodeClick.emit({ node, depth });\n }\n\n isSelected(id: string): boolean { return this.selectedId() === id; }\n\n // ── Keyboard navigation (WAI-ARIA tree) ─────────────────────────────────────\n\n /** Roving tabindex: only the active treeitem is in the tab order. */\n treeTabIndex(id: string): number {\n const active = this.activeId() ?? this.visibleNodes()[0]?.node.id ?? null;\n return id === active ? 0 : -1;\n }\n\n setActive(id: string): void { this.activeId.set(id); }\n\n /**\n * Arrow / Home / End / Enter / Space handling per the WAI-ARIA tree pattern.\n * Arrow Up/Down move between visible rows; Right expands or steps into a\n * child; Left collapses or steps to the parent; Enter/Space selects.\n */\n onKeydown(event: KeyboardEvent, fn: FlatNode, index: number): void {\n const list = this.visibleNodes();\n switch (event.key) {\n case 'ArrowDown': event.preventDefault(); this._focusStep(list, index, +1); break;\n case 'ArrowUp': event.preventDefault(); this._focusStep(list, index, -1); break;\n case 'Home': event.preventDefault(); this._focusFrom(list, 0, +1); break;\n case 'End': event.preventDefault(); this._focusFrom(list, list.length - 1, -1); break;\n case 'ArrowRight':\n event.preventDefault();\n if (fn.hasChildren && !fn.isExpanded) { this.toggle(fn.node); }\n else if (fn.hasChildren && fn.isExpanded) { this._focusStep(list, index, +1); }\n break;\n case 'ArrowLeft':\n event.preventDefault();\n if (fn.hasChildren && fn.isExpanded) { this.toggle(fn.node); }\n else { this._focusParent(list, index, fn.depth); }\n break;\n case 'Enter':\n case ' ':\n event.preventDefault();\n this.select(fn.node, fn.depth);\n this.setActive(fn.node.id);\n break;\n default:\n return;\n }\n }\n\n /** Move focus by `dir` steps from `from`, skipping disabled rows. */\n private _focusStep(list: readonly FlatNode[], from: number, dir: 1 | -1): void {\n for (let i = from + dir; i >= 0 && i < list.length; i += dir) {\n if (!list[i].node.disabled) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** From `start`, find the first enabled row in direction `dir` and focus it. */\n private _focusFrom(list: readonly FlatNode[], start: number, dir: 1 | -1): void {\n for (let i = start; i >= 0 && i < list.length; i += dir) {\n if (!list[i].node.disabled) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** Focus the parent row (nearest previous row with a smaller depth). */\n private _focusParent(list: readonly FlatNode[], index: number, depth: number): void {\n for (let i = index - 1; i >= 0; i--) {\n if (list[i].depth < depth) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** Set the active id and move DOM focus to that row (after any re-render). */\n private _focus(id: string): void {\n this.setActive(id);\n queueMicrotask(() => {\n const rows = this.host.nativeElement.querySelectorAll<HTMLElement>('[data-tree-id]');\n rows.forEach(el => { if (el.dataset['treeId'] === id) el.focus(); });\n });\n }\n\n private _flatten(nodes: TreeNode[], depth: number, expanded: Set<string>): FlatNode[] {\n const result: FlatNode[] = [];\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n const hasChildren = !!node.children?.length;\n const isExp = expanded.has(node.id);\n result.push({ node, depth, isLast: i === nodes.length - 1, hasChildren, isExpanded: isExp });\n if (isExp && node.children?.length) {\n result.push(...this._flatten(node.children, depth + 1, expanded));\n }\n }\n return result;\n }\n\n private _collectExpanded(nodes: TreeNode[], ids: Set<string>): void {\n for (const n of nodes) {\n if (n.expanded) ids.add(n.id);\n if (n.children) this._collectExpanded(n.children, ids);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAqCA;AAEA;;;;;;;;;;;AAWG;MAuEU,mBAAmB,CAAA;;AAErB,IAAA,KAAK,GAAQ,KAAK,CAAa,EAAE,4EAAC;;AAElC,IAAA,UAAU,GAAG,KAAK,CAAU,IAAI,iFAAC;;AAEjC,IAAA,SAAS,GAAI,KAAK,CAAU,IAAI,gFAAC;IAEjC,SAAS,GAAM,MAAM,EAAsB;IAC3C,UAAU,GAAK,MAAM,EAAY;IACjC,YAAY,GAAG,MAAM,EAAY;IACjC,UAAU,GAAK,MAAM,EAAY;AAEjC,IAAA,WAAW,GAAG,MAAM,CAAc,IAAI,GAAG,EAAE,kFAAC;AAC5C,IAAA,UAAU,GAAI,MAAM,CAAgB,IAAI,iFAAC;;AAEzC,IAAA,QAAQ,GAAM,MAAM,CAAgB,IAAI,+EAAC;AAEjC,IAAA,MAAM,GAAG,MAAM,CAAa,EAAE,6EAAC;AAC/B,IAAA,IAAI,GAAK,MAAM,CAA0B,UAAU,CAAC;IAE5D,YAAY,GAAG,QAAQ,CAAa,MAC3C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,cAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CACpD;IAED,QAAQ,GAAA;QACN,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AAC7B,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;QAC7B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,C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EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,iBAAA,EAAA,YAAA,EAAA,UAAA,EAAA,YAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,SAAA,EAAA,WAAA,EAAA,UAAA,EAAA,YAAA,EAAA,YAAA,EAAA,cAAA,EAAA,UAAA,EAAA,YAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAlEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgET,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAEU,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAtE/B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,UAAU,EAAE,IAAI;oBAChB,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgET,EAAA,CAAA;AACF,iBAAA;;;ACxHD;;AAEG;;;;"}
1
+ {"version":3,"file":"styloviz-tree-view.mjs","sources":["../../../../projects/tree-view-free/src/lib/tree-view.component.ts","../../../../projects/tree-view-free/src/styloviz-tree-view.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n inject,\n input,\n model,\n output,\n signal,\n} from '@angular/core';\nimport {\n SvEmptyShellComponent,\n SvErrorShellComponent,\n SvSkeletonShellComponent,\n type SvDataError,\n} from '@styloviz/core';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\nexport interface TreeNode {\n readonly id: string;\n readonly label: string;\n readonly icon?: string;\n children?: TreeNode[];\n readonly expanded?: boolean;\n readonly disabled?: boolean;\n readonly badge?: string;\n}\n\nexport interface FlatNode {\n readonly node: TreeNode;\n readonly depth: number;\n readonly isLast: boolean;\n readonly hasChildren: boolean;\n readonly isExpanded: boolean;\n}\n\nexport interface TreeNodeClickEvent {\n readonly node: TreeNode;\n readonly depth: number;\n}\n\n// ─── Component ────────────────────────────────────────────────────────────────\n\n/**\n * SvTreeViewComponent (Free) — Collapsible single-select tree.\n *\n * For the full 8-variant suite (file explorer, checkbox tri-state,\n * org chart, tree table, searchable, draggable, lazy-load) upgrade to\n * `@styloviz-pro/tree-view`.\n *\n * @example\n * ```html\n * <sv-tree-view [nodes]=\"nodes\" (nodeClick)=\"onNodeClick($event)\" />\n * ```\n */\n@Component({\n imports: [SvSkeletonShellComponent, SvErrorShellComponent, SvEmptyShellComponent],\n selector: 'sv-tree-view',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n @if (loading()) {\n <div class=\"p-2\" data-sv-state=\"loading\">\n <sv-skeleton-shell variant=\"list\" [rows]=\"5\" ariaLabel=\"Loading tree\" />\n </div>\n } @else if (error()) {\n <sv-error-shell\n [error]=\"error()\"\n title=\"Could not load this tree\"\n (retry)=\"retry.emit()\"\n data-sv-state=\"error\"\n />\n } @else {\n\n <div class=\"sv-tree-view select-none\" role=\"tree\">\n @for (fn of visibleNodes(); track fn.node.id) {\n <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\"\n [class]=\"fn.node.disabled\n ? 'opacity-40 cursor-not-allowed py-1.5'\n : isSelected(fn.node.id)\n ? 'py-1.5 bg-indigo-50 dark:bg-indigo-900/25'\n : 'py-1.5 hover:bg-gray-100/70 dark:hover:bg-gray-800/50'\"\n [style.paddingLeft.px]=\"fn.depth * 20 + 4\"\n (click)=\"select(fn.node, fn.depth); setActive(fn.node.id)\"\n (keydown)=\"onKeydown($event, fn, $index)\"\n role=\"treeitem\"\n [attr.data-tree-id]=\"fn.node.id\"\n [attr.tabindex]=\"treeTabIndex(fn.node.id)\"\n [attr.aria-level]=\"fn.depth + 1\"\n [attr.aria-expanded]=\"fn.hasChildren ? fn.isExpanded : null\"\n [attr.aria-selected]=\"isSelected(fn.node.id)\">\n\n <!-- Chevron toggle -->\n <button type=\"button\"\n class=\"flex h-5 w-5 shrink-0 items-center justify-center rounded\n text-gray-400 transition-all hover:text-gray-700 dark:hover:text-gray-200\n focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-indigo-400\"\n [class.invisible]=\"!fn.hasChildren\"\n (click)=\"toggle(fn.node); $event.stopPropagation()\"\n [attr.aria-label]=\"fn.isExpanded ? 'Collapse' : 'Expand'\">\n <svg class=\"h-3.5 w-3.5 transition-transform duration-150\"\n [class.rotate-90]=\"fn.isExpanded\"\n fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m8.25 4.5 7.5 7.5-7.5 7.5\"/>\n </svg>\n </button>\n\n <!-- Icon -->\n @if (fn.node.icon) {\n <span class=\"shrink-0 text-sm\" aria-hidden=\"true\">{{ fn.node.icon }}</span>\n }\n\n <!-- Label -->\n <span class=\"flex-1 truncate text-[13px] font-medium\"\n [class]=\"isSelected(fn.node.id)\n ? 'text-indigo-700 dark:text-indigo-300'\n : 'text-gray-800 dark:text-gray-100'\">\n {{ fn.node.label }}\n </span>\n\n <!-- Badge -->\n @if (fn.node.badge) {\n <span class=\"ml-auto shrink-0 rounded-full bg-gray-100 px-1.5 py-px\n text-[10px] font-semibold text-gray-600\n dark:bg-gray-800 dark:text-gray-300\">\n {{ fn.node.badge }}\n </span>\n }\n </div>\n }\n\n @if (!visibleNodes().length) {\n <sv-empty-shell reason=\"no-data\" [title]=\"emptyText()\" data-sv-state=\"empty\" />\n }\n </div>\n }\n\n `,\n})\nexport class SvTreeViewComponent {\n /** Tree node data (nested children, optional icons). */\n readonly nodes = input<TreeNode[]>([]);\n /** Enable single-row selection highlight. @default true */\n readonly selectable = input<boolean>(true);\n /** Show vertical connector guide lines. @default true */\n readonly showLines = input<boolean>(true);\n\n /**\n * True while the tree is being fetched. Replaces it with a placeholder.\n * @default false\n */\n readonly loading = input<boolean>(false);\n\n /**\n * Load failure. Use `toSvDataError()` from `@styloviz/core` to normalize an\n * `HttpErrorResponse`.\n * @default null\n */\n readonly error = input<SvDataError | string | null>(null);\n\n /** Copy for the empty state. @default 'No items to display' */\n readonly emptyText = input<string>('No items to display');\n\n readonly nodeClick = output<TreeNodeClickEvent>();\n readonly nodeExpand = output<TreeNode>();\n readonly nodeCollapse = output<TreeNode>();\n readonly nodeSelect = output<TreeNode>();\n /** The host should re-run the failed load. */\n readonly retry = output<void>();\n\n /**\n * Expanded node ids. Two-way bindable, so an expansion state loaded from the\n * server — or restored from a URL — survives a reload.\n */\n readonly expandedIds = model<Set<string>>(new Set());\n /** The selected node id. Two-way bindable. */\n readonly selectedId = model<string | null>(null);\n /** The treeitem currently in the tab order (roving tabindex). */\n readonly activeId = signal<string | null>(null);\n\n private readonly _nodes = signal<TreeNode[]>([]);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n readonly visibleNodes = computed<FlatNode[]>(() =>\n this._flatten(this._nodes(), 0, this.expandedIds())\n );\n\n /** Applied only on the first non-empty node set — after that the user owns it. */\n private _seededFromNodes = false;\n\n constructor() {\n // `nodes` used to be read once in ngOnInit, so a host that fetched the tree\n // asynchronously and bound the result saw an empty component forever.\n effect(() => {\n const incoming = this.nodes();\n this._nodes.set(incoming);\n if (this._seededFromNodes || incoming.length === 0) return;\n this._seededFromNodes = true;\n const ids = new Set<string>();\n this._collectExpanded(incoming, ids);\n if (ids.size) this.expandedIds.set(ids);\n // Seed the roving tabindex on the first node so the tree is tab-reachable.\n this.activeId.set(this.visibleNodes()[0]?.node.id ?? null);\n });\n }\n\n toggle(node: TreeNode): void {\n if (node.disabled) return;\n const ids = new Set(this.expandedIds());\n if (ids.has(node.id)) {\n ids.delete(node.id);\n this.nodeCollapse.emit(node);\n } else {\n ids.add(node.id);\n this.nodeExpand.emit(node);\n }\n this.expandedIds.set(ids);\n }\n\n select(node: TreeNode, depth: number): void {\n if (node.disabled || !this.selectable()) return;\n this.selectedId.set(node.id);\n this.nodeSelect.emit(node);\n this.nodeClick.emit({ node, depth });\n }\n\n isSelected(id: string): boolean { return this.selectedId() === id; }\n\n // ── Keyboard navigation (WAI-ARIA tree) ─────────────────────────────────────\n\n /** Roving tabindex: only the active treeitem is in the tab order. */\n treeTabIndex(id: string): number {\n const active = this.activeId() ?? this.visibleNodes()[0]?.node.id ?? null;\n return id === active ? 0 : -1;\n }\n\n setActive(id: string): void { this.activeId.set(id); }\n\n /**\n * Arrow / Home / End / Enter / Space handling per the WAI-ARIA tree pattern.\n * Arrow Up/Down move between visible rows; Right expands or steps into a\n * child; Left collapses or steps to the parent; Enter/Space selects.\n */\n onKeydown(event: KeyboardEvent, fn: FlatNode, index: number): void {\n const list = this.visibleNodes();\n switch (event.key) {\n case 'ArrowDown': event.preventDefault(); this._focusStep(list, index, +1); break;\n case 'ArrowUp': event.preventDefault(); this._focusStep(list, index, -1); break;\n case 'Home': event.preventDefault(); this._focusFrom(list, 0, +1); break;\n case 'End': event.preventDefault(); this._focusFrom(list, list.length - 1, -1); break;\n case 'ArrowRight':\n event.preventDefault();\n if (fn.hasChildren && !fn.isExpanded) { this.toggle(fn.node); }\n else if (fn.hasChildren && fn.isExpanded) { this._focusStep(list, index, +1); }\n break;\n case 'ArrowLeft':\n event.preventDefault();\n if (fn.hasChildren && fn.isExpanded) { this.toggle(fn.node); }\n else { this._focusParent(list, index, fn.depth); }\n break;\n case 'Enter':\n case ' ':\n event.preventDefault();\n this.select(fn.node, fn.depth);\n this.setActive(fn.node.id);\n break;\n default:\n return;\n }\n }\n\n /** Move focus by `dir` steps from `from`, skipping disabled rows. */\n private _focusStep(list: readonly FlatNode[], from: number, dir: 1 | -1): void {\n for (let i = from + dir; i >= 0 && i < list.length; i += dir) {\n if (!list[i].node.disabled) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** From `start`, find the first enabled row in direction `dir` and focus it. */\n private _focusFrom(list: readonly FlatNode[], start: number, dir: 1 | -1): void {\n for (let i = start; i >= 0 && i < list.length; i += dir) {\n if (!list[i].node.disabled) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** Focus the parent row (nearest previous row with a smaller depth). */\n private _focusParent(list: readonly FlatNode[], index: number, depth: number): void {\n for (let i = index - 1; i >= 0; i--) {\n if (list[i].depth < depth) { this._focus(list[i].node.id); return; }\n }\n }\n\n /** Set the active id and move DOM focus to that row (after any re-render). */\n private _focus(id: string): void {\n this.setActive(id);\n queueMicrotask(() => {\n const rows = this.host.nativeElement.querySelectorAll<HTMLElement>('[data-tree-id]');\n rows.forEach(el => { if (el.dataset['treeId'] === id) el.focus(); });\n });\n }\n\n private _flatten(nodes: TreeNode[], depth: number, expanded: Set<string>): FlatNode[] {\n const result: FlatNode[] = [];\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n const hasChildren = !!node.children?.length;\n const isExp = expanded.has(node.id);\n result.push({ node, depth, isLast: i === nodes.length - 1, hasChildren, isExpanded: isExp });\n if (isExp && node.children?.length) {\n result.push(...this._flatten(node.children, depth + 1, expanded));\n }\n }\n return result;\n }\n\n private _collectExpanded(nodes: TreeNode[], ids: Set<string>): void {\n for (const n of nodes) {\n if (n.expanded) ids.add(n.id);\n if (n.children) this._collectExpanded(n.children, ids);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"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EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FAmFrE,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBApF/B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,OAAO,EAAE,CAAC,wBAAwB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC;AACjF,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,UAAU,EAAE,IAAI;oBAChB,eAAe,EAAE,uBAAuB,CAAC,MAAM;AAC/C,oBAAA,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ET,EAAA,CAAA;AACF,iBAAA;;;AC7ID;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@styloviz/tree-view",
3
- "version": "0.1.4",
4
- "description": "8 premium variants: collapsible tree, file explorer, tri-state checkboxes, org chart, tree table, searchable, drag & drop reordering and lazy load.",
3
+ "version": "0.1.5",
4
+ "description": "8 premium variants: collapsible tree, file explorer, tri-state checkboxes, org chart, tree table, searchable, drag & drop reordering and lazy load. Lazy loading, the tree-table columns and drag & drop reordering are Pro (`sv-tree-view-pro`); the free component renders the nodes you give it.",
5
5
  "keywords": [
6
6
  "angular",
7
7
  "tailwind",
@@ -21,7 +21,8 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@angular/common": ">=21.0.0",
24
- "@angular/core": ">=21.0.0"
24
+ "@angular/core": ">=21.0.0",
25
+ "@styloviz/core": ">=0.1.0"
25
26
  },
26
27
  "publishConfig": {
27
28
  "access": "public"
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { OnInit } from '@angular/core';
2
+ import { SvDataError } from '@styloviz/core';
3
3
 
4
4
  interface TreeNode {
5
5
  readonly id: string;
@@ -33,25 +33,47 @@ interface TreeNodeClickEvent {
33
33
  * <sv-tree-view [nodes]="nodes" (nodeClick)="onNodeClick($event)" />
34
34
  * ```
35
35
  */
36
- declare class SvTreeViewComponent implements OnInit {
36
+ declare class SvTreeViewComponent {
37
37
  /** Tree node data (nested children, optional icons). */
38
38
  readonly nodes: _angular_core.InputSignal<TreeNode[]>;
39
39
  /** Enable single-row selection highlight. @default true */
40
40
  readonly selectable: _angular_core.InputSignal<boolean>;
41
41
  /** Show vertical connector guide lines. @default true */
42
42
  readonly showLines: _angular_core.InputSignal<boolean>;
43
+ /**
44
+ * True while the tree is being fetched. Replaces it with a placeholder.
45
+ * @default false
46
+ */
47
+ readonly loading: _angular_core.InputSignal<boolean>;
48
+ /**
49
+ * Load failure. Use `toSvDataError()` from `@styloviz/core` to normalize an
50
+ * `HttpErrorResponse`.
51
+ * @default null
52
+ */
53
+ readonly error: _angular_core.InputSignal<string | SvDataError | null>;
54
+ /** Copy for the empty state. @default 'No items to display' */
55
+ readonly emptyText: _angular_core.InputSignal<string>;
43
56
  readonly nodeClick: _angular_core.OutputEmitterRef<TreeNodeClickEvent>;
44
57
  readonly nodeExpand: _angular_core.OutputEmitterRef<TreeNode>;
45
58
  readonly nodeCollapse: _angular_core.OutputEmitterRef<TreeNode>;
46
59
  readonly nodeSelect: _angular_core.OutputEmitterRef<TreeNode>;
47
- readonly expandedIds: _angular_core.WritableSignal<Set<string>>;
48
- readonly selectedId: _angular_core.WritableSignal<string | null>;
60
+ /** The host should re-run the failed load. */
61
+ readonly retry: _angular_core.OutputEmitterRef<void>;
62
+ /**
63
+ * Expanded node ids. Two-way bindable, so an expansion state loaded from the
64
+ * server — or restored from a URL — survives a reload.
65
+ */
66
+ readonly expandedIds: _angular_core.ModelSignal<Set<string>>;
67
+ /** The selected node id. Two-way bindable. */
68
+ readonly selectedId: _angular_core.ModelSignal<string | null>;
49
69
  /** The treeitem currently in the tab order (roving tabindex). */
50
70
  readonly activeId: _angular_core.WritableSignal<string | null>;
51
71
  private readonly _nodes;
52
72
  private readonly host;
53
73
  readonly visibleNodes: _angular_core.Signal<FlatNode[]>;
54
- ngOnInit(): void;
74
+ /** Applied only on the first non-empty node set — after that the user owns it. */
75
+ private _seededFromNodes;
76
+ constructor();
55
77
  toggle(node: TreeNode): void;
56
78
  select(node: TreeNode, depth: number): void;
57
79
  isSelected(id: string): boolean;
@@ -75,7 +97,7 @@ declare class SvTreeViewComponent implements OnInit {
75
97
  private _flatten;
76
98
  private _collectExpanded;
77
99
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SvTreeViewComponent, never>;
78
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SvTreeViewComponent, "sv-tree-view", never, { "nodes": { "alias": "nodes"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "showLines": { "alias": "showLines"; "required": false; "isSignal": true; }; }, { "nodeClick": "nodeClick"; "nodeExpand": "nodeExpand"; "nodeCollapse": "nodeCollapse"; "nodeSelect": "nodeSelect"; }, never, never, true, never>;
100
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SvTreeViewComponent, "sv-tree-view", never, { "nodes": { "alias": "nodes"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "showLines": { "alias": "showLines"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "emptyText": { "alias": "emptyText"; "required": false; "isSignal": true; }; "expandedIds": { "alias": "expandedIds"; "required": false; "isSignal": true; }; "selectedId": { "alias": "selectedId"; "required": false; "isSignal": true; }; }, { "nodeClick": "nodeClick"; "nodeExpand": "nodeExpand"; "nodeCollapse": "nodeCollapse"; "nodeSelect": "nodeSelect"; "retry": "retry"; "expandedIds": "expandedIdsChange"; "selectedId": "selectedIdChange"; }, never, never, true, never>;
79
101
  }
80
102
 
81
103
  export { SvTreeViewComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"styloviz-tree-view.d.ts","sources":["../../../../projects/tree-view-free/src/lib/tree-view.component.ts"],"mappings":";;;UAciB,QAAQ;AACvB;AACA;AACA;AACA,eAAW,QAAQ;AACnB;AACA;AACA;AACD;UAEgB,QAAQ;AACvB,mBAAe,QAAQ;AACvB;AACA;AACA;AACA;AACD;UAEgB,kBAAkB;AACjC,mBAAe,QAAQ;AACvB;AACD;AAID;;;;;;;;;;;AAWG;AACH,cAsEa,mBAAoB,YAAW,MAAM;;oBAElC,aAAA,CAAA,WAAA,CAAA,QAAA;;yBAEK,aAAA,CAAA,WAAA;;wBAED,aAAA,CAAA,WAAA;wBAEA,aAAA,CAAA,gBAAA,CAAA,kBAAA;yBACC,aAAA,CAAA,gBAAA,CAAA,QAAA;2BACE,aAAA,CAAA,gBAAA,CAAA,QAAA;yBACF,aAAA,CAAA,gBAAA,CAAA,QAAA;0BAEC,aAAA,CAAA,cAAA,CAAA,GAAA;yBACD,aAAA,CAAA,cAAA;;uBAEF,aAAA,CAAA,cAAA;AAEjB;AACA;2BAEqB,aAAA,CAAA,MAAA,CAAA,QAAA;AAIrB;AASA,iBAAa,QAAQ;iBAaR,QAAQ;AAOrB;;AAKA;AAKA;AAEA;;;;AAIG;AACH,qBAAiB,aAAa,MAAM,QAAQ;;AA6B5C;;AAOA;;AAOA;;AAOA;AAQA;AAcA;oDA/IW,mBAAmB;sDAAnB,mBAAmB;AAqJ/B;;;;","names":[]}
1
+ {"version":3,"file":"styloviz-tree-view.d.ts","sources":["../../../../projects/tree-view-free/src/lib/tree-view.component.ts"],"mappings":";;;UAqBiB,QAAQ;AACvB;AACA;AACA;AACA,eAAW,QAAQ;AACnB;AACA;AACA;AACD;UAEgB,QAAQ;AACvB,mBAAe,QAAQ;AACvB;AACA;AACA;AACA;AACD;UAEgB,kBAAkB;AACjC,mBAAe,QAAQ;AACvB;AACD;AAID;;;;;;;;;;;AAWG;AACH,cAoFa,mBAAmB;;oBAEhB,aAAA,CAAA,WAAA,CAAA,QAAA;;yBAEK,aAAA,CAAA,WAAA;;wBAED,aAAA,CAAA,WAAA;AAElB;;;AAGG;sBACa,aAAA,CAAA,WAAA;AAEhB;;;;AAIG;oBACW,aAAA,CAAA,WAAA,UAAA,WAAA;;wBAGI,aAAA,CAAA,WAAA;wBAEA,aAAA,CAAA,gBAAA,CAAA,kBAAA;yBACC,aAAA,CAAA,gBAAA,CAAA,QAAA;2BACE,aAAA,CAAA,gBAAA,CAAA,QAAA;yBACF,aAAA,CAAA,gBAAA,CAAA,QAAA;;oBAEL,aAAA,CAAA,gBAAA;AAEd;;;AAGG;0BACiB,aAAA,CAAA,WAAA,CAAA,GAAA;;yBAED,aAAA,CAAA,WAAA;;uBAEF,aAAA,CAAA,cAAA;AAEjB;AACA;2BAEqB,aAAA,CAAA,MAAA,CAAA,QAAA;;;;AAuBrB,iBAAa,QAAQ;iBAaR,QAAQ;AAOrB;;AAKA;AAKA;AAEA;;;;AAIG;AACH,qBAAiB,aAAa,MAAM,QAAQ;;AA6B5C;;AAOA;;AAOA;;AAOA;AAQA;AAcA;oDAhLW,mBAAmB;sDAAnB,mBAAmB;AAsL/B;;;;","names":[]}