@styloviz/tree-view 0.4.0 → 1.0.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.
- package/README.md +37 -8
- package/fesm2022/styloviz-tree-view.mjs +537 -258
- package/fesm2022/styloviz-tree-view.mjs.map +1 -1
- package/package.json +11 -8
- package/types/styloviz-tree-view.d.ts +215 -87
- package/types/styloviz-tree-view.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
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
|
-
Part of the **Styloviz UI Kit** — a premium Angular 21 + Tailwind CSS 4 dashboard component library. Standalone, `OnPush`, strongly typed, dark-mode ready.
|
|
5
|
+
Part of the **Styloviz UI Kit** — a premium Angular 21 & 22 + Tailwind CSS 4 dashboard component library. Standalone, `OnPush`, strongly typed, dark-mode ready.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -10,7 +10,33 @@ Part of the **Styloviz UI Kit** — a premium Angular 21 + Tailwind CSS 4 dashbo
|
|
|
10
10
|
npm install @styloviz/core @styloviz/icons @styloviz/tree-view
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Requires `@angular/core` and `@angular/common`
|
|
13
|
+
Requires `@angular/core` and `@angular/common` 21 or 22 (peer range `>=21.0.0 <23.0.0`). Also needs `@styloviz/core`, `@styloviz/icons` — listed above so no extra step is required on npm (on pnpm/yarn, list them yourself). Prefer everything at once? `@styloviz/all` installs the whole free tier in one command.
|
|
14
|
+
|
|
15
|
+
## Styles (required)
|
|
16
|
+
|
|
17
|
+
Styloviz components are Tailwind CSS 4 utilities. If the project does not use
|
|
18
|
+
Tailwind yet, add it and its PostCSS plugin (the Angular CLI reads
|
|
19
|
+
`.postcssrc.json` from the project root):
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm i -D tailwindcss @tailwindcss/postcss postcss
|
|
23
|
+
echo '{ "plugins": { "@tailwindcss/postcss": {} } }' > .postcssrc.json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then, in your global stylesheet (usually `src/styles.css`), import the kit's
|
|
27
|
+
tokens and let Tailwind scan the installed packages — it skips `node_modules`
|
|
28
|
+
otherwise:
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@import "tailwindcss";
|
|
32
|
+
@import "@styloviz/core/styles/styloviz.css";
|
|
33
|
+
@source "../node_modules/@styloviz";
|
|
34
|
+
@source "../node_modules/@styloviz-pro"; /* Pro only */
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The stylesheet ships in `@styloviz/core` — add it to your install if it is not
|
|
38
|
+
there already. Dark mode is class-based (`class="dark"` on `<html>`). Rebrand by
|
|
39
|
+
redeclaring a token after the import: `@theme { --color-primary-600: #0f766e; }`.
|
|
14
40
|
|
|
15
41
|
## Usage
|
|
16
42
|
|
|
@@ -21,7 +47,7 @@ import { SvTreeViewComponent } from '@styloviz/tree-view';
|
|
|
21
47
|
standalone: true,
|
|
22
48
|
imports: [SvTreeViewComponent],
|
|
23
49
|
template: `
|
|
24
|
-
<sv-tree-view [nodes]="nodes" />
|
|
50
|
+
<sv-tree-view ariaLabel="Project files" [nodes]="nodes" />
|
|
25
51
|
`,
|
|
26
52
|
})
|
|
27
53
|
export class DemoComponent {}
|
|
@@ -34,8 +60,9 @@ export class DemoComponent {}
|
|
|
34
60
|
| `nodes` | `TreeNode[]` | `[]` | Tree node data (nested children, optional icons). |
|
|
35
61
|
| `selectable` | `boolean` | `true` | Enable single-row selection highlight. |
|
|
36
62
|
| `showLines` | `boolean` | `true` | Show vertical connector guide lines. |
|
|
63
|
+
| `ariaLabel` | `string` | `''` | What this tree is, e.g. `'Project files'` — names the `role="tree"` region. Two trees side by side both announce as an unnamed "tree" without this. Left unset, no name is invented: an `aria-label` of "Tree" only repeats the role. Matches `sv-tree-view-pro`'s input of the same name. |
|
|
37
64
|
| `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 ` |
|
|
65
|
+
| `error` | `SvDataError \| string \| null` | `null` | Load failure. Use `toSvDataError()` from `@styloviz/core` to normalize an `HttpErrorResponse`. |
|
|
39
66
|
| `emptyText` | `string` | `'No items to display'` | Copy for the empty state. |
|
|
40
67
|
| `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
68
|
| `selectedId` | `string \| null (two-way)` | `null` | The selected node id. Two-way bindable. |
|
|
@@ -44,11 +71,13 @@ export class DemoComponent {}
|
|
|
44
71
|
|
|
45
72
|
| Output | Type | Description |
|
|
46
73
|
| --- | --- | --- |
|
|
47
|
-
| `nodeClick` | `TreeNodeClickEvent` |
|
|
48
|
-
| `nodeExpand` | `TreeNode` |
|
|
49
|
-
| `nodeCollapse` | `TreeNode` |
|
|
50
|
-
| `nodeSelect` | `TreeNode` |
|
|
74
|
+
| `nodeClick` | `TreeNodeClickEvent` | Fires when an enabled node is clicked or activated with Enter/Space while `selectable`; payload is the node and its depth (0 for roots). |
|
|
75
|
+
| `nodeExpand` | `TreeNode` | Fires with the node when an enabled parent is expanded, by its chevron or ArrowRight. |
|
|
76
|
+
| `nodeCollapse` | `TreeNode` | Fires with the node when an expanded parent is collapsed, by its chevron or ArrowLeft. |
|
|
77
|
+
| `nodeSelect` | `TreeNode` | Fires with the node when it becomes selected by click or Enter/Space; never fires while `selectable` is false. |
|
|
51
78
|
| `retry` | `void` | The host should re-run the failed load. |
|
|
79
|
+
| `expandedIdsChange` | `Set<string>` | Emits the new `expandedIds` whenever it changes — the output half of `[(expandedIds)]`. |
|
|
80
|
+
| `selectedIdChange` | `string \| null` | Emits the new `selectedId` whenever it changes — the output half of `[(selectedId)]`. |
|
|
52
81
|
|
|
53
82
|
## Documentation
|
|
54
83
|
|