@omicronenergy/oscd-ui 0.0.13 → 0.0.14
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/CHANGELOG.md +9 -0
- package/custom-elements.json +8243 -5766
- package/dist/decorators/localstorage.d.ts +8 -0
- package/dist/decorators/localstorage.js +136 -0
- package/dist/decorators/localstorage.js.map +1 -0
- package/dist/decorators/localstorage.spec.d.ts +1 -0
- package/dist/decorators/localstorage.spec.js +138 -0
- package/dist/decorators/localstorage.spec.js.map +1 -0
- package/dist/snackbar/OscdSnackbar.d.ts +133 -0
- package/dist/snackbar/OscdSnackbar.js +505 -0
- package/dist/snackbar/OscdSnackbar.js.map +1 -0
- package/dist/snackbar/OscdSnackbar.spec.d.ts +1 -0
- package/dist/snackbar/OscdSnackbar.spec.js +287 -0
- package/dist/snackbar/OscdSnackbar.spec.js.map +1 -0
- package/dist/snackbar/OscdSnackbar.stories.d.ts +22 -0
- package/dist/snackbar/OscdSnackbar.stories.js +214 -0
- package/dist/snackbar/OscdSnackbar.stories.js.map +1 -0
- package/dist/snackbar/oscd-snackbar.d.ts +2 -0
- package/dist/snackbar/oscd-snackbar.js +4 -0
- package/dist/snackbar/oscd-snackbar.js.map +1 -0
- package/dist/tree/OscdTree.d.ts +81 -0
- package/dist/tree/OscdTree.js +76 -0
- package/dist/tree/OscdTree.js.map +1 -0
- package/dist/tree/OscdTree.stories.d.ts +59 -0
- package/dist/tree/OscdTree.stories.js +341 -0
- package/dist/tree/OscdTree.stories.js.map +1 -0
- package/dist/tree/OscdTreeItem.d.ts +43 -0
- package/dist/tree/OscdTreeItem.js +39 -0
- package/dist/tree/OscdTreeItem.js.map +1 -0
- package/dist/tree/internal/Tree.d.ts +186 -0
- package/dist/tree/internal/Tree.js +590 -0
- package/dist/tree/internal/Tree.js.map +1 -0
- package/dist/tree/internal/TreeItem.d.ts +25 -0
- package/dist/tree/internal/TreeItem.js +200 -0
- package/dist/tree/internal/TreeItem.js.map +1 -0
- package/dist/tree/oscd-tree-item.d.ts +2 -0
- package/dist/tree/oscd-tree-item.js +4 -0
- package/dist/tree/oscd-tree-item.js.map +1 -0
- package/dist/tree/oscd-tree.d.ts +3 -0
- package/dist/tree/oscd-tree.js +5 -0
- package/dist/tree/oscd-tree.js.map +1 -0
- package/package.json +8 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TreeItem } from './internal/TreeItem.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default content component for rows rendered inside `oscd-tree`.
|
|
4
|
+
*
|
|
5
|
+
* `oscd-tree-item` is intended to be returned from an `oscd-tree` `renderItem`
|
|
6
|
+
* callback. It renders the caller-visible row content only. The parent
|
|
7
|
+
* `oscd-tree` owns the tree row frame, indentation, expand/collapse affordance,
|
|
8
|
+
* selection affordance, keyboard handling, and ARIA attributes.
|
|
9
|
+
*
|
|
10
|
+
* Use the `headline` slot for the primary label, `supporting-text` for
|
|
11
|
+
* secondary/path text, `start` for an optional leading icon, and `end` for
|
|
12
|
+
* optional trailing status or actions.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const renderItem = ({ node, selected, active, disabled }) => html`
|
|
17
|
+
* <oscd-tree-item
|
|
18
|
+
* ?selected=${selected}
|
|
19
|
+
* ?active=${active}
|
|
20
|
+
* ?disabled=${disabled}
|
|
21
|
+
* >
|
|
22
|
+
* <oscd-icon slot="start">lan</oscd-icon>
|
|
23
|
+
* <span slot="headline">${node.label}</span>
|
|
24
|
+
* <span slot="supporting-text">${node.path}</span>
|
|
25
|
+
* ${selected ? html`<oscd-icon slot="end">check</oscd-icon>` : ''}
|
|
26
|
+
* </oscd-tree-item>
|
|
27
|
+
* `;
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @slot start - Optional leading content such as an icon.
|
|
31
|
+
* @slot headline - Primary row text.
|
|
32
|
+
* @slot supporting-text - Secondary row text.
|
|
33
|
+
* @slot end - Optional trailing content such as status or actions.
|
|
34
|
+
*
|
|
35
|
+
* @tagname oscd-tree-item
|
|
36
|
+
*/
|
|
37
|
+
export class OscdTreeItem extends TreeItem {
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=OscdTreeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OscdTreeItem.js","sourceRoot":"","sources":["../../tree/OscdTreeItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAQlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,YAAa,SAAQ,QAAQ;CAAG","sourcesContent":["import { TreeItem } from './internal/TreeItem.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'oscd-tree-item': OscdTreeItem;\n }\n}\n\n/**\n * Default content component for rows rendered inside `oscd-tree`.\n *\n * `oscd-tree-item` is intended to be returned from an `oscd-tree` `renderItem`\n * callback. It renders the caller-visible row content only. The parent\n * `oscd-tree` owns the tree row frame, indentation, expand/collapse affordance,\n * selection affordance, keyboard handling, and ARIA attributes.\n *\n * Use the `headline` slot for the primary label, `supporting-text` for\n * secondary/path text, `start` for an optional leading icon, and `end` for\n * optional trailing status or actions.\n *\n * @example\n * ```ts\n * const renderItem = ({ node, selected, active, disabled }) => html`\n * <oscd-tree-item\n * ?selected=${selected}\n * ?active=${active}\n * ?disabled=${disabled}\n * >\n * <oscd-icon slot=\"start\">lan</oscd-icon>\n * <span slot=\"headline\">${node.label}</span>\n * <span slot=\"supporting-text\">${node.path}</span>\n * ${selected ? html`<oscd-icon slot=\"end\">check</oscd-icon>` : ''}\n * </oscd-tree-item>\n * `;\n * ```\n *\n * @slot start - Optional leading content such as an icon.\n * @slot headline - Primary row text.\n * @slot supporting-text - Secondary row text.\n * @slot end - Optional trailing content such as status or actions.\n *\n * @tagname oscd-tree-item\n */\nexport class OscdTreeItem extends TreeItem {}\n"]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import { OscdCheckbox } from '../../checkbox/OscdCheckbox.js';
|
|
3
|
+
import { OscdFocusRing } from '../../focus/OscdFocusRing.js';
|
|
4
|
+
import { OscdIcon } from '../../icon/OscdIcon.js';
|
|
5
|
+
import { OscdRipple } from '../../ripple/OscdRipple.js';
|
|
6
|
+
import { OscdTreeItem } from '../OscdTreeItem.js';
|
|
7
|
+
/**
|
|
8
|
+
* Selection behavior for `oscd-tree`.
|
|
9
|
+
*/
|
|
10
|
+
export type TreeSelectionMode = 'none' | 'single' | 'multiple';
|
|
11
|
+
/**
|
|
12
|
+
* Loaded state of a tree node's children.
|
|
13
|
+
*/
|
|
14
|
+
export type TreeChildrenState = 'unknown' | 'leaf' | 'branch';
|
|
15
|
+
/**
|
|
16
|
+
* Minimal data contract for nodes rendered by `oscd-tree`.
|
|
17
|
+
*
|
|
18
|
+
* `children === undefined` means that children are unknown or not loaded yet.
|
|
19
|
+
* `children === []` means that the node is known to be a leaf.
|
|
20
|
+
* A non-empty `children` array means that the node is a branch.
|
|
21
|
+
*/
|
|
22
|
+
export type TreeNode = {
|
|
23
|
+
/**
|
|
24
|
+
* Stable node identifier. If omitted, `oscd-tree` falls back to
|
|
25
|
+
* `getNodeId` and then to the node's index path.
|
|
26
|
+
*/
|
|
27
|
+
id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Child nodes when known.
|
|
30
|
+
*/
|
|
31
|
+
children?: TreeNode[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Context passed to `renderItem` for each visible tree row.
|
|
35
|
+
*/
|
|
36
|
+
export type TreeRenderContext<T extends TreeNode = TreeNode> = {
|
|
37
|
+
/** The original caller-provided node. */
|
|
38
|
+
node: T;
|
|
39
|
+
/** Resolved node identifier used by selection, expansion, and events. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** One-based nesting level computed by the tree. */
|
|
42
|
+
level: number;
|
|
43
|
+
/** Whether this node is currently expanded. */
|
|
44
|
+
expanded: boolean;
|
|
45
|
+
/** Whether this node is currently selected. */
|
|
46
|
+
selected: boolean;
|
|
47
|
+
/** Whether this row is the active keyboard row. */
|
|
48
|
+
active: boolean;
|
|
49
|
+
/** Current child loading/branch state. */
|
|
50
|
+
childrenState: TreeChildrenState;
|
|
51
|
+
/** Whether this row can be selected. */
|
|
52
|
+
selectable: boolean;
|
|
53
|
+
/** Whether this row is disabled. */
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Detail for node-level tree events.
|
|
58
|
+
*/
|
|
59
|
+
export type TreeNodeEventDetail<T extends TreeNode = TreeNode> = {
|
|
60
|
+
/** The original caller-provided node. */
|
|
61
|
+
node: T;
|
|
62
|
+
/** Resolved node identifier. */
|
|
63
|
+
id: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Detail for `selected-ids-changed`.
|
|
67
|
+
*/
|
|
68
|
+
export type TreeSelectionChangeEventDetail<T extends TreeNode = TreeNode> = {
|
|
69
|
+
/** Current selected node identifiers. */
|
|
70
|
+
selectedIds: string[];
|
|
71
|
+
/** Previous selected node identifiers. */
|
|
72
|
+
previousSelectedIds: string[];
|
|
73
|
+
/** Node that triggered the selection change. */
|
|
74
|
+
targetNode: T;
|
|
75
|
+
};
|
|
76
|
+
declare const Tree_base: typeof LitElement & import("@open-wc/scoped-elements/lit-element.js").ScopedElementsHostConstructor;
|
|
77
|
+
/**
|
|
78
|
+
* Internal base class for `oscd-tree`.
|
|
79
|
+
*/
|
|
80
|
+
export declare class Tree<T extends TreeNode = TreeNode> extends Tree_base {
|
|
81
|
+
static scopedElements: {
|
|
82
|
+
'oscd-checkbox': typeof OscdCheckbox;
|
|
83
|
+
'oscd-focus-ring': typeof OscdFocusRing;
|
|
84
|
+
'oscd-icon': typeof OscdIcon;
|
|
85
|
+
'oscd-ripple': typeof OscdRipple;
|
|
86
|
+
'oscd-tree-item': typeof OscdTreeItem;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Structured tree data to render.
|
|
90
|
+
*/
|
|
91
|
+
data: T[];
|
|
92
|
+
/**
|
|
93
|
+
* Selected node identifiers.
|
|
94
|
+
*
|
|
95
|
+
* This state is controlled by the caller and may be persisted outside the
|
|
96
|
+
* tree, but it must be scoped to the data set/context that produced the IDs.
|
|
97
|
+
* Reset or re-key persisted selected IDs when `data` changes to a different
|
|
98
|
+
* logical tree, otherwise unrelated nodes with matching IDs may appear
|
|
99
|
+
* selected.
|
|
100
|
+
*/
|
|
101
|
+
selectedIds: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Expanded node identifiers.
|
|
104
|
+
*
|
|
105
|
+
* This state is controlled by the caller and may be persisted outside the
|
|
106
|
+
* tree, but it must be scoped to the data set/context that produced the IDs.
|
|
107
|
+
* Reset or re-key persisted expanded IDs when `data` changes to a different
|
|
108
|
+
* logical tree, otherwise unrelated nodes with matching IDs may appear
|
|
109
|
+
* expanded.
|
|
110
|
+
*/
|
|
111
|
+
expandedIds: string[];
|
|
112
|
+
/**
|
|
113
|
+
* Renders caller-provided content for a tree row.
|
|
114
|
+
*
|
|
115
|
+
* The tree owns the row frame, indentation, toggle affordance, selection
|
|
116
|
+
* affordance, keyboard handling, and ARIA attributes. This callback renders
|
|
117
|
+
* the content inside that frame.
|
|
118
|
+
*/
|
|
119
|
+
renderItem?: (context: TreeRenderContext<T>) => TemplateResult;
|
|
120
|
+
/**
|
|
121
|
+
* Resolves a stable node identifier when `node.id` is not provided.
|
|
122
|
+
*
|
|
123
|
+
* If neither `node.id` nor this callback is available, the tree falls back to
|
|
124
|
+
* an index-path ID. Index-path IDs are convenient for static examples but are
|
|
125
|
+
* not stable when rows are inserted, removed, sorted, filtered, or lazily
|
|
126
|
+
* loaded, and should not be persisted.
|
|
127
|
+
*/
|
|
128
|
+
getNodeId?: (node: T, indexPath: number[]) => string;
|
|
129
|
+
/**
|
|
130
|
+
* Resolves the accessible label for a node row.
|
|
131
|
+
*
|
|
132
|
+
* If omitted, the tree uses `node.label` when present, then the resolved node
|
|
133
|
+
* ID. This label is applied to the row frame that owns `role="treeitem"`.
|
|
134
|
+
*/
|
|
135
|
+
getNodeLabel?: (node: T, id: string) => string;
|
|
136
|
+
/**
|
|
137
|
+
* Returns whether a node can be selected.
|
|
138
|
+
*/
|
|
139
|
+
isSelectable?: (node: T) => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Returns whether a node is disabled.
|
|
142
|
+
*/
|
|
143
|
+
isDisabled?: (node: T) => boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Selection behavior.
|
|
146
|
+
*/
|
|
147
|
+
selectionMode: TreeSelectionMode;
|
|
148
|
+
private activeId?;
|
|
149
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
150
|
+
/**
|
|
151
|
+
* Expands a node by ID.
|
|
152
|
+
*/
|
|
153
|
+
expand(id: string): void;
|
|
154
|
+
/**
|
|
155
|
+
* Collapses a node by ID.
|
|
156
|
+
*/
|
|
157
|
+
collapse(id: string): void;
|
|
158
|
+
/**
|
|
159
|
+
* Toggles a node expansion state by ID.
|
|
160
|
+
*/
|
|
161
|
+
toggle(id: string): void;
|
|
162
|
+
private rowId;
|
|
163
|
+
private visibleRows;
|
|
164
|
+
private renderContext;
|
|
165
|
+
private accessibleLabel;
|
|
166
|
+
private isRowSelectable;
|
|
167
|
+
private isRowDisabled;
|
|
168
|
+
private setExpandedIds;
|
|
169
|
+
private setSelectedIds;
|
|
170
|
+
private fireNodeEvent;
|
|
171
|
+
private toggleExpansion;
|
|
172
|
+
private toggleSelection;
|
|
173
|
+
private activateRow;
|
|
174
|
+
private handleRowClick;
|
|
175
|
+
private handleToggleClick;
|
|
176
|
+
private handleKeyDown;
|
|
177
|
+
private stepIn;
|
|
178
|
+
private stepOut;
|
|
179
|
+
private renderSelection;
|
|
180
|
+
private renderToggle;
|
|
181
|
+
private renderRow;
|
|
182
|
+
updated(): void;
|
|
183
|
+
render(): TemplateResult;
|
|
184
|
+
static styles: import("lit").CSSResult;
|
|
185
|
+
}
|
|
186
|
+
export {};
|