@nyx-ds/treeview 0.1.0 → 0.1.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/dist/event.d.ts +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/treeview-a11y.d.ts +5 -0
- package/dist/treeview-lazy.d.ts +68 -0
- package/dist/treeview-search.d.ts +49 -0
- package/dist/treeview-sort.d.ts +10 -0
- package/dist/treeview.d.ts +347 -0
- package/dist/treeview.js +1258 -554
- package/dist/treeview.umd.cjs +128 -108
- package/package.json +20 -4
package/dist/event.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface EventOptions {
|
|
2
|
+
bubbles?: boolean;
|
|
3
|
+
cancelable?: boolean;
|
|
4
|
+
composed?: boolean;
|
|
5
|
+
native?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EventDispatcher<T> {
|
|
8
|
+
(value: T, options?: EventOptions): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function event(customName?: string): (protoOrDescriptor: {}, name: string) => void;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Accessible name builders for treeview row controls. */
|
|
2
|
+
export declare function buildTreeExpanderAriaLabel(nodeLabel: string, expanded: boolean): string;
|
|
3
|
+
export declare function buildTreeRowCheckboxAriaLabel(nodeLabel: string): string;
|
|
4
|
+
export declare function buildTreeColumnCheckboxAriaLabel(columnTitle: string, nodeLabel: string): string;
|
|
5
|
+
export declare function buildTreeSearchStatusMessage(matchCount: number): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ITreeNode } from "./treeview";
|
|
2
|
+
/** Default nodes loaded per lazy/virtual scroll page. */
|
|
3
|
+
export declare const TREE_LAZY_PAGE_SIZE = 50;
|
|
4
|
+
export declare const TREE_LAZY_INITIAL_MAX_DEPTH = 2;
|
|
5
|
+
export interface IndexedTreeNode {
|
|
6
|
+
id: string | number;
|
|
7
|
+
depth: number;
|
|
8
|
+
parentId: string | number | null;
|
|
9
|
+
hasChildrenInSource: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface FlatTreeRow {
|
|
12
|
+
node: ITreeNode;
|
|
13
|
+
level: number;
|
|
14
|
+
revealSubtree: boolean;
|
|
15
|
+
parentLabelMatched: boolean;
|
|
16
|
+
hasChildrenInSource: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function indexTreeNodes(roots: ITreeNode[]): IndexedTreeNode[];
|
|
19
|
+
/** First chunk: up to `pageSize` nodes, only while depth <= maxDepth (0…2). */
|
|
20
|
+
export declare function getInitialLoadedIds(index: IndexedTreeNode[], pageSize?: number, maxDepth?: number): Set<string | number>;
|
|
21
|
+
/** First page of root nodes only — keeps collapsed lists scrollable (e.g. 1000 folders). */
|
|
22
|
+
export declare function getInitialLoadedRootIds(index: IndexedTreeNode[], pageSize?: number): Set<string | number>;
|
|
23
|
+
export declare function getNextLoadRootIds(index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>, pageSize: number): (string | number)[];
|
|
24
|
+
export declare function hasMoreRootsToLoad(index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>): boolean;
|
|
25
|
+
export declare function hasMoreNodesToLoad(index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>): boolean;
|
|
26
|
+
export declare function hasUnloadedDescendants(nodeId: string | number, index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>): boolean;
|
|
27
|
+
/** Root id (depth 0) for a flat row — used to prioritize lazy loads on scroll. */
|
|
28
|
+
export declare function getRootIdForFlatRow(row: FlatTreeRow | undefined, indexById: Map<string | number, IndexedTreeNode>): string | number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Picks a root to prioritize when loading the next lazy page on scroll
|
|
31
|
+
* (search results or expanded folders with many descendants).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getNextLoadPriorityRootId(flatRows: FlatTreeRow[], lastVisibleIndex: number, expandedIds: ReadonlySet<string | number>, index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>, indexById: Map<string | number, IndexedTreeNode>): string | number | undefined;
|
|
34
|
+
export declare function getAncestorIds(id: string | number, indexById: Map<string | number, IndexedTreeNode>): (string | number)[];
|
|
35
|
+
/**
|
|
36
|
+
* Loads the next page of node ids (global BFS order), optionally prioritizing
|
|
37
|
+
* descendants of `priorityRootId` when a folder is expanded.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getNextLoadIds(index: IndexedTreeNode[], loadedIds: ReadonlySet<string | number>, pageSize: number, priorityRootId?: string | number): (string | number)[];
|
|
40
|
+
export declare function collectSubtreeIds(index: IndexedTreeNode[], rootId: string | number): (string | number)[];
|
|
41
|
+
/** All descendant ids under `rootId` that are not loaded yet (for expand). */
|
|
42
|
+
export declare function getUnloadedSubtreeIds(index: IndexedTreeNode[], rootId: string | number, loadedIds: ReadonlySet<string | number>): (string | number)[];
|
|
43
|
+
/** First page of an expanded subtree (remaining ids load on virtualizer scroll). */
|
|
44
|
+
export declare function getNextSubtreeLoadIds(index: IndexedTreeNode[], rootId: string | number, loadedIds: ReadonlySet<string | number>, pageSize?: number): (string | number)[];
|
|
45
|
+
/** Structural clone: copies tree fields and preserves `data` by reference. */
|
|
46
|
+
export declare function cloneTreeNode(node: ITreeNode): ITreeNode;
|
|
47
|
+
export declare function buildSourceMaps(roots: ITreeNode[]): Map<string | number, ITreeNode>;
|
|
48
|
+
/** Builds the materialized tree containing only loaded node ids. */
|
|
49
|
+
export declare function materializeLoadedTree(roots: ITreeNode[], loadedIds: ReadonlySet<string | number>, sourceById: Map<string | number, ITreeNode>): ITreeNode[];
|
|
50
|
+
export declare function buildFlatVisibleRows(options: {
|
|
51
|
+
items: ITreeNode[];
|
|
52
|
+
expandedIds: ReadonlySet<string | number>;
|
|
53
|
+
hasSearch: boolean;
|
|
54
|
+
searchTerm: string;
|
|
55
|
+
searchVisibleIds: ReadonlySet<string | number>;
|
|
56
|
+
sourceHasChildren: (id: string | number) => boolean;
|
|
57
|
+
getSourceChildren?: (id: string | number) => ITreeNode[] | undefined;
|
|
58
|
+
}): FlatTreeRow[];
|
|
59
|
+
export declare function ensureIdsLoaded(ids: Iterable<string | number>, loadedIds: Set<string | number>, indexById: Map<string | number, IndexedTreeNode>): boolean;
|
|
60
|
+
/** Whether search still has visible hits that are not materialized yet. */
|
|
61
|
+
export declare function hasMoreSearchVisibleToLoad(visibleIds: ReadonlySet<string | number>, loadedIds: ReadonlySet<string | number>): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Next lazy page for search: visible hits only (plus ancestors), preserving
|
|
64
|
+
* discovery order from `computeTreeSearch` so scroll can paginate homonymous folders.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getNextSearchVisibleLoadIds(visibleIds: ReadonlySet<string | number>, loadedIds: ReadonlySet<string | number>, indexById: Map<string | number, IndexedTreeNode>, pageSize?: number): (string | number)[];
|
|
67
|
+
/** Loads one search page into `loadedIds`. Returns whether anything was added. */
|
|
68
|
+
export declare function loadNextSearchVisiblePage(visibleIds: ReadonlySet<string | number>, loadedIds: Set<string | number>, indexById: Map<string | number, IndexedTreeNode>, pageSize?: number): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure search helpers for nyx-treeview (unit-testable, framework-agnostic).
|
|
3
|
+
*/
|
|
4
|
+
/** Debounce delay (ms) before applying search filter after typing. */
|
|
5
|
+
export declare const TREE_SEARCH_DEBOUNCE_MS = 200;
|
|
6
|
+
export interface TreeSearchNode {
|
|
7
|
+
id: string | number;
|
|
8
|
+
label: string;
|
|
9
|
+
children?: TreeSearchNode[];
|
|
10
|
+
}
|
|
11
|
+
export interface TreeSearchState {
|
|
12
|
+
visibleIds: Set<string | number>;
|
|
13
|
+
expandIds: Set<string | number>;
|
|
14
|
+
}
|
|
15
|
+
export interface TreeSearchIndexEntry {
|
|
16
|
+
id: string | number;
|
|
17
|
+
parentId: string | number | null;
|
|
18
|
+
normalizedLabel: string;
|
|
19
|
+
childIds: (string | number)[];
|
|
20
|
+
hasChildren: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Flat index for O(1) lookup and iterative search (no deep recursion). */
|
|
23
|
+
export interface TreeSearchIndex {
|
|
24
|
+
roots: (string | number)[];
|
|
25
|
+
byId: Map<string | number, TreeSearchIndexEntry>;
|
|
26
|
+
size: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function labelMatchesSearch(label: string, term: string): boolean;
|
|
29
|
+
/** Builds parent/child maps and pre-normalized labels in one iterative pass. */
|
|
30
|
+
export declare function buildTreeSearchIndex(items: TreeSearchNode[]): TreeSearchIndex;
|
|
31
|
+
/**
|
|
32
|
+
* Computes visible nodes and auto-expand targets for the current search term.
|
|
33
|
+
* Any depth: every label match is listed; ancestors on the path are included too.
|
|
34
|
+
*/
|
|
35
|
+
/** Counts nodes whose label matches the search term (excludes ancestor-only rows). */
|
|
36
|
+
export declare function countTreeSearchMatches(itemsOrIndex: TreeSearchNode[] | TreeSearchIndex, term: string): number;
|
|
37
|
+
export declare function computeTreeSearch(itemsOrIndex: TreeSearchNode[] | TreeSearchIndex, term: string, userCollapsedIds?: ReadonlySet<string | number>): TreeSearchState;
|
|
38
|
+
export declare function getChildNodesForSearch(parent: TreeSearchNode, visibleIds: ReadonlySet<string | number>, term?: string): TreeSearchNode[];
|
|
39
|
+
/** Whether any descendant label matches the search term. */
|
|
40
|
+
export declare function hasLabelMatchingDescendant(nodeId: string | number, term: string, getChildren: (id: string | number) => TreeSearchNode[] | undefined): boolean;
|
|
41
|
+
/** Whether any descendant in `getChildren` is included in search `visibleIds`. */
|
|
42
|
+
export declare function hasVisibleSearchDescendant(nodeId: string | number, visibleIds: ReadonlySet<string | number>, getChildren: (id: string | number) => TreeSearchNode[] | undefined): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* During search, show every child only for an exclusive folder hit (no deeper visible match).
|
|
45
|
+
* Partial terms like "1" keep children filtered by `visibleIds`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function shouldShowAllChildrenOnSearchExpand(label: string, term: string, parentLabelMatched: boolean, nodeId: string | number, visibleIds: ReadonlySet<string | number>, getChildren: (id: string | number) => TreeSearchNode[] | undefined): boolean;
|
|
48
|
+
export declare function isFolderSearchHit(label: string, term: string, parentLabelMatched: boolean): boolean;
|
|
49
|
+
export declare function shouldRevealSubtree(label: string, term: string, revealSubtree: boolean, parentLabelMatched: boolean): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ITreeNode } from "./treeview";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the node or any descendant has row/column selection state.
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasSelectionInSubtree(node: ITreeNode, usesSimpleRowSelection: boolean): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Sorts siblings so nodes with selection (direct or in subtree) appear first.
|
|
8
|
+
* Preserves relative order within selected and unselected groups.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sortTreeSelectedFirst(nodes: ITreeNode[], usesSimpleRowSelection: boolean): ITreeNode[];
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from "lit";
|
|
2
|
+
import { EventDispatcher } from "./event";
|
|
3
|
+
import "@lit-labs/virtualizer";
|
|
4
|
+
import "@nyx-ds/input";
|
|
5
|
+
import "@nyx-ds/checkbox";
|
|
6
|
+
import "@nyx-ds/icon";
|
|
7
|
+
import "@nyx-ds/button";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for rendering an icon within the tree or headers.
|
|
10
|
+
* Can be used to define FontAwesome icons, external images, or raw SVGs.
|
|
11
|
+
*/
|
|
12
|
+
export interface ITreeIconOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The name of the icon (e.g., 'folder', 'user', 'check').
|
|
15
|
+
* Used when integrating with icon libraries like FontAwesome.
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The style variant of the icon.
|
|
20
|
+
* Common values: 'solid', 'regular', 'light', 'duotone'.
|
|
21
|
+
* @default 'regular'
|
|
22
|
+
*/
|
|
23
|
+
variant?: string;
|
|
24
|
+
/**
|
|
25
|
+
* URL source for an external image or SVG file.
|
|
26
|
+
* If provided, renders an <img> tag or fetches the SVG.
|
|
27
|
+
*/
|
|
28
|
+
src?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Raw SVG string content.
|
|
31
|
+
* Useful for inline SVGs without external dependencies.
|
|
32
|
+
*/
|
|
33
|
+
svg?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Defines a column that appears on the right side of the treeview.
|
|
37
|
+
* Each column represents a specific permission or state (represented by a checkbox).
|
|
38
|
+
*/
|
|
39
|
+
export interface ITreeColumn {
|
|
40
|
+
/**
|
|
41
|
+
* Unique identifier for the column.
|
|
42
|
+
* This ID is used in `ITreeNode.selectedColumns` and `ITreeNode.disabledColumns` to map values.
|
|
43
|
+
*/
|
|
44
|
+
id: string | number;
|
|
45
|
+
/**
|
|
46
|
+
* Title text for the column header.
|
|
47
|
+
* Often used as a tooltip or accessible label.
|
|
48
|
+
*/
|
|
49
|
+
title?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Icon displayed in the column header.
|
|
52
|
+
* Can be a string (icon name) or a detailed `ITreeIconOptions` object.
|
|
53
|
+
*/
|
|
54
|
+
icon?: string | ITreeIconOptions;
|
|
55
|
+
/**
|
|
56
|
+
* IDs of columns that are prerequisites for this column.
|
|
57
|
+
* Checking this column also checks its prerequisites in the node and its
|
|
58
|
+
* subtree; unchecking a prerequisite unchecks every column that requires it
|
|
59
|
+
* (reverse cascade). Dependencies are resolved transitively.
|
|
60
|
+
* Leave undefined for independent columns.
|
|
61
|
+
*/
|
|
62
|
+
requires?: (string | number)[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Represents a single row (node) in the hierarchical tree structure.
|
|
66
|
+
*/
|
|
67
|
+
export interface ITreeNode {
|
|
68
|
+
/**
|
|
69
|
+
* Unique identifier for the node.
|
|
70
|
+
* Used for tracking expansion state and selection logic.
|
|
71
|
+
*/
|
|
72
|
+
id: string | number;
|
|
73
|
+
/**
|
|
74
|
+
* The main text label displayed for the node.
|
|
75
|
+
*/
|
|
76
|
+
label: string;
|
|
77
|
+
/**
|
|
78
|
+
* The icon displayed next to the label (e.g., folder or file icon).
|
|
79
|
+
*/
|
|
80
|
+
icon?: string | ITreeIconOptions;
|
|
81
|
+
/**
|
|
82
|
+
* Array containing the `id` of columns that are currently checked/selected for this node.
|
|
83
|
+
*/
|
|
84
|
+
selectedColumns?: (string | number)[];
|
|
85
|
+
/**
|
|
86
|
+
* Array containing the `id` of columns that should be disabled (read-only) for this node.
|
|
87
|
+
* The checkbox will appear visually disabled and cannot be toggled.
|
|
88
|
+
*/
|
|
89
|
+
disabledColumns?: (string | number)[];
|
|
90
|
+
/**
|
|
91
|
+
* Nested child nodes associated with this parent node.
|
|
92
|
+
*/
|
|
93
|
+
children?: ITreeNode[];
|
|
94
|
+
/**
|
|
95
|
+
* Row selected when `showRowSelection` is enabled without column permissions.
|
|
96
|
+
*/
|
|
97
|
+
selected?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Optional payload to store extra business logic or metadata.
|
|
100
|
+
* This is preserved but not used visually by the component.
|
|
101
|
+
*/
|
|
102
|
+
data?: any;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Main configuration object passed to the `<nyx-treeview>` component.
|
|
106
|
+
*/
|
|
107
|
+
export interface ITreeViewOptions {
|
|
108
|
+
/**
|
|
109
|
+
* The main title displayed at the top left of the component header.
|
|
110
|
+
*/
|
|
111
|
+
title: string;
|
|
112
|
+
/**
|
|
113
|
+
* The root array of data nodes to render.
|
|
114
|
+
*/
|
|
115
|
+
items: ITreeNode[];
|
|
116
|
+
/**
|
|
117
|
+
* The initial depth level to automatically expand nodes.
|
|
118
|
+
* 0 = Root only, 1 = First level children, etc.
|
|
119
|
+
* Works with `lazyLoad`: loads required nodes, then expands on init.
|
|
120
|
+
*/
|
|
121
|
+
defaultExpandedLevel?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Definitions for the checkbox columns displayed on the right side.
|
|
124
|
+
*/
|
|
125
|
+
columns?: ITreeColumn[];
|
|
126
|
+
/**
|
|
127
|
+
* If `true`, renders a master checkbox at the start of the row.
|
|
128
|
+
* With column permissions: toggles all columns for the row.
|
|
129
|
+
* Without columns: toggles `selected` on the row and its descendants.
|
|
130
|
+
*/
|
|
131
|
+
showRowSelection?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Shows header icons and per-row permission checkboxes on the right.
|
|
134
|
+
* Defaults to `true` when `columns` has at least one entry.
|
|
135
|
+
*/
|
|
136
|
+
showColumnPermissions?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Enables chunked data loading and virtual scroll.
|
|
139
|
+
* Initial view: first page of root folders (collapsed); children load on expand.
|
|
140
|
+
* Scroll loads more rows; only visible rows are mounted in the DOM.
|
|
141
|
+
*/
|
|
142
|
+
lazyLoad?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* How many folders/items to load per lazy/virtual scroll page when `lazyLoad` is enabled.
|
|
145
|
+
* @default 50
|
|
146
|
+
*/
|
|
147
|
+
lazyLoadPageSize?: number;
|
|
148
|
+
/**
|
|
149
|
+
* When `true`, siblings with row/column selection (or selected descendants)
|
|
150
|
+
* are sorted to the top. Useful when reopening an edit form so previously
|
|
151
|
+
* chosen folders are easier to find.
|
|
152
|
+
*/
|
|
153
|
+
sortSelectedFirst?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Shows the per-row type icon next to the expander.
|
|
156
|
+
* Defaults to `true`.
|
|
157
|
+
*/
|
|
158
|
+
showNodeIcons?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Nyx Treeview Component.
|
|
162
|
+
*
|
|
163
|
+
* A hierarchical list component that supports expandable nodes, multi-column checkbox selection,
|
|
164
|
+
* search filtering, keyboard navigation, and WAI-ARIA `tree` / `treeitem` semantics.
|
|
165
|
+
*
|
|
166
|
+
* @event nyx-change - Fired when any selection changes (checkbox toggle). Returns `{ items: ITreeNode[] }`.
|
|
167
|
+
* With `lazyLoad`, `items` is the full source tree (`_sourceItems`), including nodes not yet materialized in the viewport.
|
|
168
|
+
*
|
|
169
|
+
* @cssproperty [--treeview-radius=var(--nyx-radii-s)] - Border radius of the container.
|
|
170
|
+
* @cssproperty [--treeview-search-padding=var(--nyx-sizing-1-25) var(--nyx-sizing-1-75) 0 var(--nyx-sizing-1-75)] - Padding of the search container.
|
|
171
|
+
* @cssproperty [--treeview-header-padding=var(--nyx-sizing-2) var(--nyx-sizing-2) var(--nyx-sizing-1-75) var(--nyx-sizing-2)] - Padding of the header row.
|
|
172
|
+
* @cssproperty [--treeview-row-padding=var(--nyx-sizing-1-5, 12px) var(--nyx-sizing-2)] - Padding of data rows.
|
|
173
|
+
* @cssproperty [--treeview-row-gap=var(--nyx-sizing-2)] - Gap between elements in a row.
|
|
174
|
+
* @cssproperty [--treeview-col-gap=var(--nyx-sizing-1)] - Gap between column checkboxes.
|
|
175
|
+
* @cssproperty [--treeview-node-gap=var(--nyx-sizing-1)] - Gap between expander, icon, and text.
|
|
176
|
+
* @cssproperty [--treeview-row-min-height=48px] - Minimum height of rows (Figma default).
|
|
177
|
+
* @cssproperty [--treeview-indent-base=16px] - Left padding at tree level 0.
|
|
178
|
+
* @cssproperty [--treeview-indent-step=24px] - Additional left padding per nested level.
|
|
179
|
+
* @cssproperty [--treeview-expander-wrapper-size=var(--nyx-sizing-4)] - Size of the expander button area.
|
|
180
|
+
* @cssproperty [--treeview-expander-padding=var(--nyx-sizing-1-25)] - Padding inside the expander button.
|
|
181
|
+
*
|
|
182
|
+
* @cssproperty [--treeview-background=var(--nyx-color-neutral-background-primary)] - Component background color.
|
|
183
|
+
* @cssproperty [--treeview-border-color=var(--nyx-color-neutral-border-tertiary)] - Component border color.
|
|
184
|
+
* @cssproperty [--treeview-content-color=var(--nyx-color-neutral-content-primary)] - Default text and icon color.
|
|
185
|
+
* @cssproperty [--treeview-focus-border-color=var(--nyx-color-brand-border-default)] - Color of keyboard focus ring.
|
|
186
|
+
* @cssproperty [--treeview-row-selected-background=var(--nyx-color-brand-background-softer)] - Background of selected rows.
|
|
187
|
+
* @cssproperty [--treeview-row-selected-hover-background=var(--nyx-color-brand-background-softer-hover)] - Background of selected rows on hover.
|
|
188
|
+
* @cssproperty [--treeview-row-selected-color=var(--nyx-color-neutral-content-primary)] - Text color of selected rows.
|
|
189
|
+
*
|
|
190
|
+
* @cssproperty [--treeview-font-family=var(--nyx-font-family-font-family)] - Font family.
|
|
191
|
+
* @cssproperty [--treeview-title-font-size=var(--nyx-label-medium-font-size)] - Header title font size.
|
|
192
|
+
* @cssproperty [--treeview-title-line-height=var(--nyx-label-medium-line-height)] - Header title line height.
|
|
193
|
+
* @cssproperty [--treeview-text-font-size=var(--nyx-label-medium-font-size)] - Row text font size.
|
|
194
|
+
* @cssproperty [--treeview-text-line-height=var(--nyx-label-medium-line-height)] - Row text line height.
|
|
195
|
+
* @cssproperty [--treeview-header-icon-size=var(--nyx-label-large-font-size)] - Size of header icons.
|
|
196
|
+
* @cssproperty [--treeview-node-icon-size=var(--nyx-label-medium-font-size)] - Size of node icons.
|
|
197
|
+
* @cssproperty [--treeview-expander-icon-size=var(--nyx-label-large-font-size)] - Size of expander chevron.
|
|
198
|
+
*
|
|
199
|
+
* @cssproperty [--treeview-row-hover-background=var(--nyx-color-neutral-background-secondary)] - Background of rows on hover.
|
|
200
|
+
* @cssproperty [--treeview-row-hover-color=var(--nyx-color-brand-content-hover)] - Text color of rows on hover.
|
|
201
|
+
* @cssproperty [--treeview-expander-hover-background=var(--nyx-color-brand-background-softer-hover)] - Background of expander on hover.
|
|
202
|
+
*/
|
|
203
|
+
export declare class NyxTreeview extends LitElement {
|
|
204
|
+
/**
|
|
205
|
+
* Configuration object for the Treeview.
|
|
206
|
+
*
|
|
207
|
+
* Expects an object matching the `ITreeViewOptions` interface:
|
|
208
|
+
* - `title`: String header.
|
|
209
|
+
* - `items`: Array of `ITreeNode`.
|
|
210
|
+
* - `columns`: Array of `ITreeColumn`.
|
|
211
|
+
* - `showRowSelection`: Boolean.
|
|
212
|
+
*/
|
|
213
|
+
private _options?;
|
|
214
|
+
get options(): ITreeViewOptions | undefined;
|
|
215
|
+
set options(value: ITreeViewOptions | undefined);
|
|
216
|
+
private _items;
|
|
217
|
+
private _expandedIds;
|
|
218
|
+
private _searchTerm;
|
|
219
|
+
private _searchStatusMessage;
|
|
220
|
+
private _searchVisibleIds;
|
|
221
|
+
private _searchUserCollapsedIds;
|
|
222
|
+
private _searchManualExpandedIds;
|
|
223
|
+
private _expandedIdsBeforeSearch;
|
|
224
|
+
private _flatRows;
|
|
225
|
+
private _loadedIds;
|
|
226
|
+
private _activeRowId;
|
|
227
|
+
private _sourceItems;
|
|
228
|
+
private _lazyItemsSourceRef;
|
|
229
|
+
private _treeIndex;
|
|
230
|
+
private _indexById;
|
|
231
|
+
private _sourceById;
|
|
232
|
+
private _lazyScrollLoading;
|
|
233
|
+
private _searchIndex;
|
|
234
|
+
private _searchIndexSourceRef;
|
|
235
|
+
private _searchDebounceTimer;
|
|
236
|
+
onChange: EventDispatcher<{
|
|
237
|
+
items: ITreeNode[];
|
|
238
|
+
}>;
|
|
239
|
+
private _isLazyEnabled;
|
|
240
|
+
private _getLazyPageSize;
|
|
241
|
+
private _hasColumnPermissions;
|
|
242
|
+
private _showRowSelection;
|
|
243
|
+
private _showNodeIcons;
|
|
244
|
+
private _usesSimpleRowSelection;
|
|
245
|
+
private _applyItemsFromOptions;
|
|
246
|
+
private _applyOptionsChange;
|
|
247
|
+
private _initLazyState;
|
|
248
|
+
/**
|
|
249
|
+
* Expands only nodes already present in the materialized tree.
|
|
250
|
+
* Further rows appear as lazy load + scroll bring more ids into `_items`.
|
|
251
|
+
*/
|
|
252
|
+
private _applyLazyInitialExpansion;
|
|
253
|
+
private _rebuildMaterializedItems;
|
|
254
|
+
private _selectionRoots;
|
|
255
|
+
/** Full source node for selection UI/state (lazy materialized nodes may omit children). */
|
|
256
|
+
private _selectionNode;
|
|
257
|
+
private _invalidateSearchIndex;
|
|
258
|
+
/** Clears search-derived sets so a data source swap cannot reuse stale ids. */
|
|
259
|
+
private _resetSearchDerivedState;
|
|
260
|
+
private _ensureSearchIndex;
|
|
261
|
+
disconnectedCallback(): void;
|
|
262
|
+
private _findNodeById;
|
|
263
|
+
private _forEachInSubtree;
|
|
264
|
+
private _getSourceChildren;
|
|
265
|
+
private _loadMoreNodes;
|
|
266
|
+
private _loadSubtreeForExpand;
|
|
267
|
+
private _sourceHasChildren;
|
|
268
|
+
/** Refresh lazy flat rows after intentional lazy state mutations. */
|
|
269
|
+
private _commitLazyRows;
|
|
270
|
+
private _syncFlatRows;
|
|
271
|
+
private _setActiveRow;
|
|
272
|
+
private _syncActiveRowWithVisibleRows;
|
|
273
|
+
private _getRowTabIndex;
|
|
274
|
+
private _rowDomId;
|
|
275
|
+
private _rowSelector;
|
|
276
|
+
private _isSearchActive;
|
|
277
|
+
/** Index to scroll to after search — deepest hit, or first homonymous child. */
|
|
278
|
+
private _getSearchScrollTargetIndex;
|
|
279
|
+
private _loadUntilSearchTargetVisible;
|
|
280
|
+
private _scrollToSearchTarget;
|
|
281
|
+
private _hasExpandedUnloadedSubtree;
|
|
282
|
+
/** Expanded folder hit with no deeper visible match — may lazy-load all children. */
|
|
283
|
+
private _hasExclusiveSearchFolderWithUnloadedChildren;
|
|
284
|
+
private _shouldLoadMoreOnScroll;
|
|
285
|
+
private _getLazyLoadPriorityRootId;
|
|
286
|
+
private _getScrollPrefetchMargin;
|
|
287
|
+
private _onVirtualizerVisibilityChanged;
|
|
288
|
+
private _getTreeAriaLabel;
|
|
289
|
+
private _renderTreeRow;
|
|
290
|
+
private _renderExpanderCell;
|
|
291
|
+
private _renderNodeTypeIcon;
|
|
292
|
+
private _generateLightDomIcons;
|
|
293
|
+
private _createIconElement;
|
|
294
|
+
private _expandToLevel;
|
|
295
|
+
private _isColumnDisabled;
|
|
296
|
+
private _isNodeSelected;
|
|
297
|
+
private _isIndeterminate;
|
|
298
|
+
private _allDescendantsSelected;
|
|
299
|
+
private _getFlatDescendants;
|
|
300
|
+
/** Transitive set of prerequisite column ids for `columnId` (excludes itself). */
|
|
301
|
+
private _requiredClosure;
|
|
302
|
+
/** Transitive set of column ids that depend on `columnId` (excludes itself). */
|
|
303
|
+
private _dependentsClosure;
|
|
304
|
+
private _canEnableColumn;
|
|
305
|
+
private _handleCheck;
|
|
306
|
+
private _toggleNodeState;
|
|
307
|
+
private _updateParents;
|
|
308
|
+
private _isRowAllSelected;
|
|
309
|
+
private _isRowIndeterminate;
|
|
310
|
+
private _isSimpleRowAllSelected;
|
|
311
|
+
private _isSimpleRowIndeterminate;
|
|
312
|
+
private _setSimpleRowSelected;
|
|
313
|
+
private _updateSimpleRowParents;
|
|
314
|
+
private _isRowCheckboxChecked;
|
|
315
|
+
private _isRowCheckboxIndeterminate;
|
|
316
|
+
private _handleRowCheck;
|
|
317
|
+
private _applyRowColumnsToNode;
|
|
318
|
+
private _toggleRowRecursively;
|
|
319
|
+
private _triggerChange;
|
|
320
|
+
private _handleSearchInput;
|
|
321
|
+
private _applySearchTerm;
|
|
322
|
+
private _recomputeSearchFilter;
|
|
323
|
+
private _updateSearchStatusMessage;
|
|
324
|
+
private _toggleExpand;
|
|
325
|
+
private _nodeHasChildren;
|
|
326
|
+
private _getVisibleTreeRows;
|
|
327
|
+
private _getParentId;
|
|
328
|
+
private _focusRowById;
|
|
329
|
+
private _focusFirstVisibleChild;
|
|
330
|
+
private _handleRowKeyDown;
|
|
331
|
+
private _handleRowFocusOut;
|
|
332
|
+
private _enableChildren;
|
|
333
|
+
private _disableChildren;
|
|
334
|
+
private _clearAllFocus;
|
|
335
|
+
private _renderRowSelectionCheckbox;
|
|
336
|
+
private _renderNodeIconCell;
|
|
337
|
+
private _renderColumnCheckboxes;
|
|
338
|
+
render(): TemplateResult<1>;
|
|
339
|
+
private _renderFlatRow;
|
|
340
|
+
private _renderNodes;
|
|
341
|
+
static styles: import("lit").CSSResult;
|
|
342
|
+
}
|
|
343
|
+
declare global {
|
|
344
|
+
interface HTMLElementTagNameMap {
|
|
345
|
+
"nyx-treeview": NyxTreeview;
|
|
346
|
+
}
|
|
347
|
+
}
|