@omicronenergy/oscd-ui 0.0.18 → 0.0.19
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/dist/action-tree/OscdActionTree.d.ts +2 -0
- package/dist/action-tree/OscdActionTree.js +12 -42
- package/dist/action-tree/OscdActionTree.js.map +1 -1
- package/dist/action-tree/oscd-action-tree.spec.js +2 -2
- package/dist/action-tree/oscd-action-tree.spec.js.map +1 -1
- package/dist/search-field/oscd-outlined-search-field.spec.js +5 -6
- package/dist/search-field/oscd-outlined-search-field.spec.js.map +1 -1
- package/dist/tree/OscdTree.stories.js +22 -4
- package/dist/tree/OscdTree.stories.js.map +1 -1
- package/dist/tree/internal/Tree.js +28 -4
- package/dist/tree/internal/Tree.js.map +1 -1
- package/dist/tree/internal/TreeItem.js +22 -8
- package/dist/tree/internal/TreeItem.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.19](https://github.com/OMICRONEnergyOSS/oscd-ui/compare/oscd-ui-v0.0.18...oscd-ui-v0.0.19) (2026-08-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* correct tree item styling for selected, active items ([314beb7](https://github.com/OMICRONEnergyOSS/oscd-ui/commit/314beb7d6adf03c76bf72c713405c05982ca72e8))
|
|
9
|
+
* corrected OscdActionTree font usage ([d00911a](https://github.com/OMICRONEnergyOSS/oscd-ui/commit/d00911a1ab1b49697614566a904f02e2f7c4678f))
|
|
10
|
+
* correction to failing tests after refactor ([2088e37](https://github.com/OMICRONEnergyOSS/oscd-ui/commit/2088e371038401bfb4e7a7a7e684361cf3587e23))
|
|
11
|
+
|
|
3
12
|
## [0.0.18](https://github.com/OMICRONEnergyOSS/oscd-ui/compare/oscd-ui-v0.0.17...oscd-ui-v0.0.18) (2026-08-21)
|
|
4
13
|
|
|
5
14
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { OscdIcon } from '../icon/OscdIcon.js';
|
|
2
3
|
import { OscdIconButton } from '../iconbutton/OscdIconButton.js';
|
|
3
4
|
type Value = {
|
|
4
5
|
edit?: () => void;
|
|
@@ -27,6 +28,7 @@ declare const OscdActionTree_base: typeof LitElement & import("@open-wc/scoped-e
|
|
|
27
28
|
*/
|
|
28
29
|
export declare class OscdActionTree extends OscdActionTree_base {
|
|
29
30
|
static scopedElements: {
|
|
31
|
+
'oscd-icon': typeof OscdIcon;
|
|
30
32
|
'oscd-icon-button': typeof OscdIconButton;
|
|
31
33
|
};
|
|
32
34
|
data: TreeNode | null;
|
|
@@ -2,6 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { property, state } from 'lit/decorators.js';
|
|
4
4
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
|
|
5
|
+
import { OscdIcon } from '../icon/OscdIcon.js';
|
|
5
6
|
import { OscdIconButton } from '../iconbutton/OscdIconButton.js';
|
|
6
7
|
// Compute the maximum number of values found in any leaf array
|
|
7
8
|
function getMaxLeafCount(node) {
|
|
@@ -113,7 +114,9 @@ export class OscdActionTree extends ScopedElementsMixin(LitElement) {
|
|
|
113
114
|
return html `<span class="leading-icon">${node.icon}</span>`;
|
|
114
115
|
}
|
|
115
116
|
if (typeof node.icon === 'string') {
|
|
116
|
-
return html `<span class="leading-icon
|
|
117
|
+
return html `<span class="leading-icon"
|
|
118
|
+
><oscd-icon>${node.icon}</oscd-icon></span
|
|
119
|
+
>`;
|
|
117
120
|
}
|
|
118
121
|
return html ``; // no icon
|
|
119
122
|
}
|
|
@@ -166,12 +169,12 @@ export class OscdActionTree extends ScopedElementsMixin(LitElement) {
|
|
|
166
169
|
<div class="val-inner">
|
|
167
170
|
${cell.edit
|
|
168
171
|
? html `
|
|
169
|
-
<icon-button
|
|
172
|
+
<oscd-icon-button
|
|
170
173
|
aria-label="Edit value ${i + 1}"
|
|
171
174
|
@click=${cell.edit}
|
|
172
175
|
>
|
|
173
|
-
<
|
|
174
|
-
</icon-button>
|
|
176
|
+
<oscd-icon>edit</oscd-icon>
|
|
177
|
+
</oscd-icon-button>
|
|
175
178
|
`
|
|
176
179
|
: ''}
|
|
177
180
|
<span class="val-text">${cell.val ?? ''}</span>
|
|
@@ -205,19 +208,12 @@ export class OscdActionTree extends ScopedElementsMixin(LitElement) {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
OscdActionTree.scopedElements = {
|
|
211
|
+
'oscd-icon': OscdIcon,
|
|
208
212
|
'oscd-icon-button': OscdIconButton,
|
|
209
213
|
};
|
|
210
214
|
OscdActionTree.styles = css `
|
|
211
|
-
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400&display=swap');
|
|
212
|
-
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,400,0,0');
|
|
213
215
|
:host {
|
|
214
|
-
font-family:
|
|
215
|
-
'Roboto',
|
|
216
|
-
system-ui,
|
|
217
|
-
-apple-system,
|
|
218
|
-
'Segoe UI',
|
|
219
|
-
Arial,
|
|
220
|
-
sans-serif;
|
|
216
|
+
font-family: var(--md-sys-typescale-body-large-font, Roboto);
|
|
221
217
|
font-weight: 400;
|
|
222
218
|
color: var(--action-tree-font-color, #000000);
|
|
223
219
|
--md-icon-button-icon-size: 20px;
|
|
@@ -276,7 +272,7 @@ OscdActionTree.styles = css `
|
|
|
276
272
|
color: inherit;
|
|
277
273
|
}
|
|
278
274
|
/* remove extra spacing on icon-button in value cells */
|
|
279
|
-
.val-cell icon-button {
|
|
275
|
+
.val-cell oscd-icon-button {
|
|
280
276
|
margin-right: 0;
|
|
281
277
|
width: 24px;
|
|
282
278
|
height: 24px;
|
|
@@ -360,27 +356,6 @@ OscdActionTree.styles = css `
|
|
|
360
356
|
text-align: center;
|
|
361
357
|
font-size: 12px;
|
|
362
358
|
}
|
|
363
|
-
/* Material Symbols icon style */
|
|
364
|
-
.ms {
|
|
365
|
-
font-family: 'Material Symbols Outlined';
|
|
366
|
-
font-weight: 400;
|
|
367
|
-
font-style: normal;
|
|
368
|
-
font-size: 18px;
|
|
369
|
-
line-height: 1;
|
|
370
|
-
letter-spacing: normal;
|
|
371
|
-
text-transform: none;
|
|
372
|
-
display: inline-block;
|
|
373
|
-
white-space: nowrap;
|
|
374
|
-
direction: ltr;
|
|
375
|
-
-webkit-font-feature-settings: 'liga';
|
|
376
|
-
-webkit-font-smoothing: antialiased;
|
|
377
|
-
font-variation-settings:
|
|
378
|
-
'FILL' 0,
|
|
379
|
-
'wght' 400,
|
|
380
|
-
'GRAD' 0,
|
|
381
|
-
'opsz' 20;
|
|
382
|
-
color: inherit;
|
|
383
|
-
}
|
|
384
359
|
.leading-icon {
|
|
385
360
|
color: inherit;
|
|
386
361
|
width: 18px;
|
|
@@ -388,6 +363,7 @@ OscdActionTree.styles = css `
|
|
|
388
363
|
display: inline-flex;
|
|
389
364
|
align-items: center;
|
|
390
365
|
justify-content: center;
|
|
366
|
+
--md-icon-size: 18px;
|
|
391
367
|
}
|
|
392
368
|
|
|
393
369
|
.icon-btn {
|
|
@@ -422,13 +398,7 @@ OscdActionTree.styles = css `
|
|
|
422
398
|
}
|
|
423
399
|
/* explicit styling for no data message */
|
|
424
400
|
.no-data {
|
|
425
|
-
font-family:
|
|
426
|
-
'Roboto',
|
|
427
|
-
system-ui,
|
|
428
|
-
-apple-system,
|
|
429
|
-
'Segoe UI',
|
|
430
|
-
Arial,
|
|
431
|
-
sans-serif;
|
|
401
|
+
font-family: var(--md-sys-typescale-body-large-font, Roboto);
|
|
432
402
|
font-weight: 400;
|
|
433
403
|
color: inherit;
|
|
434
404
|
padding: 8px 12px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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,CACzB,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,IAAI,CAAA,6CAA6C,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;;;KAGxC,CAAC;IACJ,CAAC;;AAtNM,6BAAc,GAAG;IACtB,kBAAkB,EAAE,cAAc;CACnC,AAFoB,CAEnB;AAsNc,qBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkO3B,AAlOqB,CAkOpB;AAtb0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAGjD;IADP,KAAK,EAAE;8CACgC;AAIhC;IADP,KAAK,EAAE;kDACoC;AAIpC;IADP,KAAK,EAAE;mDACgB","sourcesContent":["import { css, html, LitElement, TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { OscdIconButton } from '../iconbutton/OscdIconButton.js';\n\ntype Value = {\n edit?: () => void;\n val: string | number | boolean | null;\n};\n\ntype Leaf = Value[];\n\n// Compute the maximum number of values found in any leaf array\nfunction getMaxLeafCount(node: TreeNode | null): number {\n let max = 0;\n const walk = (n: TreeNode | null) => {\n if (!n) {\n return;\n }\n if (n.leaf && n.leaf.length) {\n max = Math.max(max, n.leaf.length);\n }\n n.children?.forEach(walk);\n };\n walk(node);\n return max;\n}\n\nexport type TreeNode = {\n name: string;\n icon?: SVGElement | string; // web-standard: SVGElement or Material Symbols name string\n info?: string;\n leaf?: Leaf;\n children?: TreeNode[];\n};\n\n/**\n * @tag oscd-action-tree\n *\n * A tree component to display hierarchical data with action capabilities.\n *\n * ## Details\n *\n * - Displays data in a tree structure with expandable/collapsible nodes.\n * - Each node can have an optional icon, info text, leaf values, and child nodes.\n * - Leaf values can have associated edit actions.\n * - Automatically folds new nodes when data is updated.\n */\nexport class OscdActionTree extends ScopedElementsMixin(LitElement) {\n static scopedElements = {\n 'oscd-icon-button': OscdIconButton,\n };\n\n @property({ type: Object }) data: TreeNode | null = null;\n\n @state()\n private folded: Set<string> = new Set();\n\n // Track known paths to detect when new nodes are added\n @state()\n private knownPaths: Set<string> = new Set();\n\n // Track how many leaf columns to render\n @state()\n private maxLeafCols = 0;\n\n // eslint-disable-next-line class-methods-use-this\n private pathKey(path: (string | number)[]) {\n return path.join('.') || 'root';\n }\n\n protected override willUpdate(_changed: Map<string, unknown>) {\n if (this.data) {\n // Collect all current paths in the tree\n const allCurrentPaths = new Set<string>();\n const collectPaths = (\n node: TreeNode | null,\n path: (string | number)[] = [],\n ) => {\n if (!node) {\n return;\n }\n if (path.length > 0 && node.children !== undefined) {\n const pathKey = this.pathKey(path);\n allCurrentPaths.add(pathKey);\n }\n node.children?.forEach((child, i) =>\n collectPaths(child, [...path, 'children', i]),\n );\n };\n collectPaths(this.data, []);\n\n // Find new paths that weren't known before\n const updatedFolded = new Set(this.folded);\n\n allCurrentPaths.forEach(pathKey => {\n if (!this.knownPaths.has(pathKey)) {\n // This is a new node, fold it\n updatedFolded.add(pathKey);\n }\n });\n\n // Remove fold state for paths that no longer exist\n const cleanedFolded = new Set<string>();\n updatedFolded.forEach(path => {\n if (allCurrentPaths.has(path)) {\n cleanedFolded.add(path);\n }\n });\n\n // Update our state\n this.folded = cleanedFolded;\n this.knownPaths = allCurrentPaths;\n\n // compute max number of leaf values across the tree\n this.maxLeafCols = getMaxLeafCount(this.data);\n }\n }\n\n private toggleFold(path: (string | number)[], node?: TreeNode) {\n const k = this.pathKey(path);\n const s = new Set(this.folded);\n const isUnfolding = s.has(k); // currently folded, will be unfolded\n if (s.has(k)) {\n s.delete(k);\n } else {\n s.add(k);\n }\n this.folded = s;\n\n // Trigger re-render and height update\n this.requestUpdate();\n\n // Fire 'unfold' only when leaf is not defined and children are defined but an empty array\n if (\n isUnfolding &&\n node &&\n node.leaf === undefined &&\n Array.isArray(node.children) &&\n node.children.length === 0\n ) {\n this.dispatchEvent(\n new CustomEvent('unfold', {\n detail: node,\n bubbles: true,\n composed: true,\n }),\n );\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private renderLeadingIcon(node: TreeNode): TemplateResult {\n if (node.icon instanceof SVGElement) {\n return html`<span class=\"leading-icon\">${node.icon}</span>`;\n }\n if (typeof node.icon === 'string') {\n return html`<span class=\"leading-icon ms\">${node.icon}</span>`;\n }\n return html``; // no icon\n }\n\n private renderRows(\n node: TreeNode | null,\n path: (string | number)[] = [],\n level = 0,\n parentFolded = false,\n ): ReturnType<typeof html>[] {\n if (!node) {\n return [];\n }\n const rows: ReturnType<typeof html>[] = [];\n\n // Show a fold toggle if the node declares a children property (even if empty)\n const hasToggle = node.children !== undefined;\n // Only render children rows when there are actual children\n const hasChildren = !!(node.children && node.children.length > 0);\n const key = this.pathKey(path);\n const isFolded = this.folded.has(key);\n\n const leaf = node.leaf ?? [];\n\n rows.push(html`\n <tr class=\"tree-row ${parentFolded ? 'child-hidden' : ''}\">\n <td class=\"guideline\" style=\"padding-left:${level * 1.5}em;\">\n <div class=\"row-inner\">\n <span class=\"row-left\">\n ${hasToggle\n ? html`\n <span\n class=\"tree-fold ${isFolded ? 'folded' : ''}\"\n @click=${() => this.toggleFold(path, node)}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.toggleFold(path, node);\n }\n }}\n tabindex=\"0\"\n role=\"button\"\n aria-label=\"Toggle fold\"\n >\n ⌃\n </span>\n `\n : html`<span class=\"tree-fold\"></span>`}\n ${this.renderLeadingIcon(node)}\n <span class=\"tree-key\">${node.name}</span>\n </span>\n </div>\n </td>\n ${Array.from({ length: this.maxLeafCols }, (_, i) => {\n const cell = leaf[i];\n return html`<td class=\"val-cell\">\n ${cell\n ? html`\n <div class=\"val-inner\">\n ${cell.edit\n ? html`\n <icon-button\n aria-label=\"Edit value ${i + 1}\"\n @click=${cell.edit}\n >\n <span class=\"ms\">edit</span>\n </icon-button>\n `\n : ''}\n <span class=\"val-text\">${cell.val ?? ''}</span>\n </div>\n `\n : ''}\n </td>`;\n })}\n </tr>\n `);\n\n // Always render children, but mark them as hidden if parent is folded\n if (hasChildren) {\n node.children!.forEach((child, i) => {\n const childRows = this.renderRows(\n child,\n [...path, 'children', i],\n level + 1,\n parentFolded || isFolded,\n );\n rows.push(...childRows);\n });\n }\n\n return rows;\n }\n\n override render() {\n if (!this.data) {\n return html`<div class=\"no-data\">No data provided</div>`;\n }\n return html`\n <table class=\"tree-grid\">\n <tbody>\n ${this.renderRows(this.data, [], 0)}\n </tbody>\n </table>\n `;\n }\n\n static override styles = css`\n @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400&display=swap');\n @import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,400,0,0');\n :host {\n font-family:\n 'Roboto',\n system-ui,\n -apple-system,\n 'Segoe UI',\n Arial,\n sans-serif;\n font-weight: 400;\n color: var(--action-tree-font-color, #000000);\n --md-icon-button-icon-size: 20px;\n --md-sys-color-on-surface-variant: var(--action-tree-font-color, #000000);\n }\n .tree-grid {\n width: auto; /* don't stretch to 100% */\n border-collapse: collapse;\n color: inherit;\n }\n .tree-grid th,\n .tree-grid td {\n border-bottom: 1px solid var(--action-tree-horizontal-grid-color, #eee);\n padding: 0.3em 0.5em;\n vertical-align: middle; /* center content vertically */\n font-weight: 400;\n color: inherit;\n }\n /* ensure some room between text and right-side icons */\n .tree-grid td:first-child,\n .tree-grid th:first-child {\n min-width: 360px;\n padding-right: 12px;\n border-right: 1px solid var(--action-tree-vertical-grid-color, #ddd); /* vertical separator */\n text-align: left;\n }\n .val-col,\n .val-cell {\n text-align: right;\n white-space: nowrap;\n color: inherit;\n }\n /* vertical separator after each value column */\n .val-cell {\n border-right: 1px solid var(--action-tree-vertical-grid-color, #ddd);\n }\n /* Remove border from last column */\n .val-cell:last-child {\n border-right: none;\n }\n /* Remove border from last row */\n .tree-row:last-child td {\n border-bottom: none;\n }\n /* layout inside value cell: icon on left, value aligned right */\n .val-inner {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n .val-text {\n margin-left: auto;\n text-align: right;\n display: inline-block;\n min-width: 0;\n color: inherit;\n }\n /* remove extra spacing on icon-button in value cells */\n .val-cell icon-button {\n margin-right: 0;\n width: 24px;\n height: 24px;\n }\n /* row height for easier icon buttons */\n .tree-row {\n min-height: 34px;\n transition: all 400ms ease-in-out;\n max-height: 50px; /* smaller max-height for better animation */\n opacity: 1;\n overflow: hidden;\n }\n .tree-row.child-hidden {\n max-height: 0px;\n min-height: 0px;\n opacity: 0;\n padding: 0;\n margin: 0;\n border: none;\n }\n /* Hide content inside cells when row is hidden */\n .tree-row.child-hidden td {\n padding: 0;\n border: none;\n height: 0;\n line-height: 0;\n }\n .tree-row.child-hidden .row-inner,\n .tree-row.child-hidden .val-inner {\n display: none;\n }\n\n /* Uniform background for all rows */\n .tree-row:not(.child-hidden) {\n background-color: var(--action-tree-background-color, transparent);\n }\n\n /* Smooth transition for fold icon */\n .tree-fold {\n transition: transform var(--action-tree-fold-duration, 200ms) ease-in-out;\n transform: rotate(180deg); /* Default: point down when expanded */\n }\n .tree-fold.folded {\n transform: rotate(90deg); /* Point right when folded */\n }\n\n .row-inner {\n display: flex;\n align-items: center;\n gap: 0.4em;\n color: inherit;\n }\n .row-left {\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n min-width: 0;\n color: inherit;\n }\n .row-right {\n margin-left: auto; /* push actions to the right side of the first column */\n display: inline-flex;\n gap: 0.6em; /* a bit more space between action icons */\n color: inherit;\n font-weight: 400;\n }\n .tree-key {\n font-weight: 400;\n color: inherit;\n user-select: none;\n white-space: pre;\n }\n .tree-fold {\n cursor: pointer;\n margin-right: 0.1em;\n color: inherit;\n font-weight: 400;\n user-select: none;\n display: inline-block;\n width: 0.8em;\n text-align: center;\n font-size: 12px;\n }\n /* Material Symbols icon style */\n .ms {\n font-family: 'Material Symbols Outlined';\n font-weight: 400;\n font-style: normal;\n font-size: 18px;\n line-height: 1;\n letter-spacing: normal;\n text-transform: none;\n display: inline-block;\n white-space: nowrap;\n direction: ltr;\n -webkit-font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n font-variation-settings:\n 'FILL' 0,\n 'wght' 400,\n 'GRAD' 0,\n 'opsz' 20;\n color: inherit;\n }\n .leading-icon {\n color: inherit;\n width: 18px;\n height: 18px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n .icon-btn {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border: 1px solid #999;\n border-radius: 50%;\n background: #fff;\n font-size: 12px;\n line-height: 1;\n padding: 0;\n font-weight: 400;\n }\n .guideline {\n position: relative;\n }\n .info-row td {\n background: transparent; /* no highlight */\n padding-top: 4px;\n padding-bottom: 6px;\n }\n .info-box {\n color: inherit;\n font-size: 0.9em;\n white-space: pre-wrap;\n font-weight: 300;\n margin-top: 4px;\n }\n /* explicit styling for no data message */\n .no-data {\n font-family:\n 'Roboto',\n system-ui,\n -apple-system,\n 'Segoe UI',\n Arial,\n sans-serif;\n font-weight: 400;\n color: inherit;\n padding: 8px 12px;\n }\n `;\n}\n"]}
|
|
1
|
+
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,CAAC,EACxB,KAAK,GAAG,CAAC,EACT,YAAY,IAAI,QAAQ,CACzB,CAAC;gBACF,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,IAAI,CAAA,6CAA6C,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;;;KAGxC,CAAC;IACJ,CAAC;;AAzNM,6BAAc,GAAG;IACtB,WAAW,EAAE,QAAQ;IACrB,kBAAkB,EAAE,cAAc;CACnC,AAHoB,CAGnB;AAwNc,qBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgM3B,AAhMqB,CAgMpB;AAtZ0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAGjD;IADP,KAAK,EAAE;8CACgC;AAIhC;IADP,KAAK,EAAE;kDACoC;AAIpC;IADP,KAAK,EAAE;mDACgB","sourcesContent":["import { css, html, LitElement, TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { OscdIcon } from '../icon/OscdIcon.js';\nimport { OscdIconButton } from '../iconbutton/OscdIconButton.js';\n\ntype Value = {\n edit?: () => void;\n val: string | number | boolean | null;\n};\n\ntype Leaf = Value[];\n\n// Compute the maximum number of values found in any leaf array\nfunction getMaxLeafCount(node: TreeNode | null): number {\n let max = 0;\n const walk = (n: TreeNode | null) => {\n if (!n) {\n return;\n }\n if (n.leaf && n.leaf.length) {\n max = Math.max(max, n.leaf.length);\n }\n n.children?.forEach(walk);\n };\n walk(node);\n return max;\n}\n\nexport type TreeNode = {\n name: string;\n icon?: SVGElement | string; // web-standard: SVGElement or Material Symbols name string\n info?: string;\n leaf?: Leaf;\n children?: TreeNode[];\n};\n\n/**\n * @tag oscd-action-tree\n *\n * A tree component to display hierarchical data with action capabilities.\n *\n * ## Details\n *\n * - Displays data in a tree structure with expandable/collapsible nodes.\n * - Each node can have an optional icon, info text, leaf values, and child nodes.\n * - Leaf values can have associated edit actions.\n * - Automatically folds new nodes when data is updated.\n */\nexport class OscdActionTree extends ScopedElementsMixin(LitElement) {\n static scopedElements = {\n 'oscd-icon': OscdIcon,\n 'oscd-icon-button': OscdIconButton,\n };\n\n @property({ type: Object }) data: TreeNode | null = null;\n\n @state()\n private folded: Set<string> = new Set();\n\n // Track known paths to detect when new nodes are added\n @state()\n private knownPaths: Set<string> = new Set();\n\n // Track how many leaf columns to render\n @state()\n private maxLeafCols = 0;\n\n // eslint-disable-next-line class-methods-use-this\n private pathKey(path: (string | number)[]) {\n return path.join('.') || 'root';\n }\n\n protected override willUpdate(_changed: Map<string, unknown>) {\n if (this.data) {\n // Collect all current paths in the tree\n const allCurrentPaths = new Set<string>();\n const collectPaths = (\n node: TreeNode | null,\n path: (string | number)[] = [],\n ) => {\n if (!node) {\n return;\n }\n if (path.length > 0 && node.children !== undefined) {\n const pathKey = this.pathKey(path);\n allCurrentPaths.add(pathKey);\n }\n node.children?.forEach((child, i) =>\n collectPaths(child, [...path, 'children', i]),\n );\n };\n collectPaths(this.data, []);\n\n // Find new paths that weren't known before\n const updatedFolded = new Set(this.folded);\n\n allCurrentPaths.forEach(pathKey => {\n if (!this.knownPaths.has(pathKey)) {\n // This is a new node, fold it\n updatedFolded.add(pathKey);\n }\n });\n\n // Remove fold state for paths that no longer exist\n const cleanedFolded = new Set<string>();\n updatedFolded.forEach(path => {\n if (allCurrentPaths.has(path)) {\n cleanedFolded.add(path);\n }\n });\n\n // Update our state\n this.folded = cleanedFolded;\n this.knownPaths = allCurrentPaths;\n\n // compute max number of leaf values across the tree\n this.maxLeafCols = getMaxLeafCount(this.data);\n }\n }\n\n private toggleFold(path: (string | number)[], node?: TreeNode) {\n const k = this.pathKey(path);\n const s = new Set(this.folded);\n const isUnfolding = s.has(k); // currently folded, will be unfolded\n if (s.has(k)) {\n s.delete(k);\n } else {\n s.add(k);\n }\n this.folded = s;\n\n // Trigger re-render and height update\n this.requestUpdate();\n\n // Fire 'unfold' only when leaf is not defined and children are defined but an empty array\n if (\n isUnfolding &&\n node &&\n node.leaf === undefined &&\n Array.isArray(node.children) &&\n node.children.length === 0\n ) {\n this.dispatchEvent(\n new CustomEvent('unfold', {\n detail: node,\n bubbles: true,\n composed: true,\n }),\n );\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private renderLeadingIcon(node: TreeNode): TemplateResult {\n if (node.icon instanceof SVGElement) {\n return html`<span class=\"leading-icon\">${node.icon}</span>`;\n }\n if (typeof node.icon === 'string') {\n return html`<span class=\"leading-icon\"\n ><oscd-icon>${node.icon}</oscd-icon></span\n >`;\n }\n return html``; // no icon\n }\n\n private renderRows(\n node: TreeNode | null,\n path: (string | number)[] = [],\n level = 0,\n parentFolded = false,\n ): ReturnType<typeof html>[] {\n if (!node) {\n return [];\n }\n const rows: ReturnType<typeof html>[] = [];\n\n // Show a fold toggle if the node declares a children property (even if empty)\n const hasToggle = node.children !== undefined;\n // Only render children rows when there are actual children\n const hasChildren = !!(node.children && node.children.length > 0);\n const key = this.pathKey(path);\n const isFolded = this.folded.has(key);\n\n const leaf = node.leaf ?? [];\n\n rows.push(html`\n <tr class=\"tree-row ${parentFolded ? 'child-hidden' : ''}\">\n <td class=\"guideline\" style=\"padding-left:${level * 1.5}em;\">\n <div class=\"row-inner\">\n <span class=\"row-left\">\n ${hasToggle\n ? html`\n <span\n class=\"tree-fold ${isFolded ? 'folded' : ''}\"\n @click=${() => this.toggleFold(path, node)}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.toggleFold(path, node);\n }\n }}\n tabindex=\"0\"\n role=\"button\"\n aria-label=\"Toggle fold\"\n >\n ⌃\n </span>\n `\n : html`<span class=\"tree-fold\"></span>`}\n ${this.renderLeadingIcon(node)}\n <span class=\"tree-key\">${node.name}</span>\n </span>\n </div>\n </td>\n ${Array.from({ length: this.maxLeafCols }, (_, i) => {\n const cell = leaf[i];\n return html`<td class=\"val-cell\">\n ${cell\n ? html`\n <div class=\"val-inner\">\n ${cell.edit\n ? html`\n <oscd-icon-button\n aria-label=\"Edit value ${i + 1}\"\n @click=${cell.edit}\n >\n <oscd-icon>edit</oscd-icon>\n </oscd-icon-button>\n `\n : ''}\n <span class=\"val-text\">${cell.val ?? ''}</span>\n </div>\n `\n : ''}\n </td>`;\n })}\n </tr>\n `);\n\n // Always render children, but mark them as hidden if parent is folded\n if (hasChildren) {\n node.children!.forEach((child, i) => {\n const childRows = this.renderRows(\n child,\n [...path, 'children', i],\n level + 1,\n parentFolded || isFolded,\n );\n rows.push(...childRows);\n });\n }\n\n return rows;\n }\n\n override render() {\n if (!this.data) {\n return html`<div class=\"no-data\">No data provided</div>`;\n }\n return html`\n <table class=\"tree-grid\">\n <tbody>\n ${this.renderRows(this.data, [], 0)}\n </tbody>\n </table>\n `;\n }\n\n static override styles = css`\n :host {\n font-family: var(--md-sys-typescale-body-large-font, Roboto);\n font-weight: 400;\n color: var(--action-tree-font-color, #000000);\n --md-icon-button-icon-size: 20px;\n --md-sys-color-on-surface-variant: var(--action-tree-font-color, #000000);\n }\n .tree-grid {\n width: auto; /* don't stretch to 100% */\n border-collapse: collapse;\n color: inherit;\n }\n .tree-grid th,\n .tree-grid td {\n border-bottom: 1px solid var(--action-tree-horizontal-grid-color, #eee);\n padding: 0.3em 0.5em;\n vertical-align: middle; /* center content vertically */\n font-weight: 400;\n color: inherit;\n }\n /* ensure some room between text and right-side icons */\n .tree-grid td:first-child,\n .tree-grid th:first-child {\n min-width: 360px;\n padding-right: 12px;\n border-right: 1px solid var(--action-tree-vertical-grid-color, #ddd); /* vertical separator */\n text-align: left;\n }\n .val-col,\n .val-cell {\n text-align: right;\n white-space: nowrap;\n color: inherit;\n }\n /* vertical separator after each value column */\n .val-cell {\n border-right: 1px solid var(--action-tree-vertical-grid-color, #ddd);\n }\n /* Remove border from last column */\n .val-cell:last-child {\n border-right: none;\n }\n /* Remove border from last row */\n .tree-row:last-child td {\n border-bottom: none;\n }\n /* layout inside value cell: icon on left, value aligned right */\n .val-inner {\n display: flex;\n align-items: center;\n gap: 6px;\n }\n .val-text {\n margin-left: auto;\n text-align: right;\n display: inline-block;\n min-width: 0;\n color: inherit;\n }\n /* remove extra spacing on icon-button in value cells */\n .val-cell oscd-icon-button {\n margin-right: 0;\n width: 24px;\n height: 24px;\n }\n /* row height for easier icon buttons */\n .tree-row {\n min-height: 34px;\n transition: all 400ms ease-in-out;\n max-height: 50px; /* smaller max-height for better animation */\n opacity: 1;\n overflow: hidden;\n }\n .tree-row.child-hidden {\n max-height: 0px;\n min-height: 0px;\n opacity: 0;\n padding: 0;\n margin: 0;\n border: none;\n }\n /* Hide content inside cells when row is hidden */\n .tree-row.child-hidden td {\n padding: 0;\n border: none;\n height: 0;\n line-height: 0;\n }\n .tree-row.child-hidden .row-inner,\n .tree-row.child-hidden .val-inner {\n display: none;\n }\n\n /* Uniform background for all rows */\n .tree-row:not(.child-hidden) {\n background-color: var(--action-tree-background-color, transparent);\n }\n\n /* Smooth transition for fold icon */\n .tree-fold {\n transition: transform var(--action-tree-fold-duration, 200ms) ease-in-out;\n transform: rotate(180deg); /* Default: point down when expanded */\n }\n .tree-fold.folded {\n transform: rotate(90deg); /* Point right when folded */\n }\n\n .row-inner {\n display: flex;\n align-items: center;\n gap: 0.4em;\n color: inherit;\n }\n .row-left {\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n min-width: 0;\n color: inherit;\n }\n .row-right {\n margin-left: auto; /* push actions to the right side of the first column */\n display: inline-flex;\n gap: 0.6em; /* a bit more space between action icons */\n color: inherit;\n font-weight: 400;\n }\n .tree-key {\n font-weight: 400;\n color: inherit;\n user-select: none;\n white-space: pre;\n }\n .tree-fold {\n cursor: pointer;\n margin-right: 0.1em;\n color: inherit;\n font-weight: 400;\n user-select: none;\n display: inline-block;\n width: 0.8em;\n text-align: center;\n font-size: 12px;\n }\n .leading-icon {\n color: inherit;\n width: 18px;\n height: 18px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n --md-icon-size: 18px;\n }\n\n .icon-btn {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n border: 1px solid #999;\n border-radius: 50%;\n background: #fff;\n font-size: 12px;\n line-height: 1;\n padding: 0;\n font-weight: 400;\n }\n .guideline {\n position: relative;\n }\n .info-row td {\n background: transparent; /* no highlight */\n padding-top: 4px;\n padding-bottom: 6px;\n }\n .info-box {\n color: inherit;\n font-size: 0.9em;\n white-space: pre-wrap;\n font-weight: 300;\n margin-top: 4px;\n }\n /* explicit styling for no data message */\n .no-data {\n font-family: var(--md-sys-typescale-body-large-font, Roboto);\n font-weight: 400;\n color: inherit;\n padding: 8px 12px;\n }\n `;\n}\n"]}
|
|
@@ -126,7 +126,7 @@ describe('ActionTree Component', () => {
|
|
|
126
126
|
lln0FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
127
127
|
await timeout(100);
|
|
128
128
|
// Find and click the edit button for Beh's second value
|
|
129
|
-
const editButton = tree.shadowRoot?.querySelector('icon-button');
|
|
129
|
+
const editButton = tree.shadowRoot?.querySelector('oscd-icon-button');
|
|
130
130
|
expect(editButton).to.exist;
|
|
131
131
|
editButton?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
132
132
|
await timeout(100);
|
|
@@ -148,7 +148,7 @@ describe('ActionTree Component', () => {
|
|
|
148
148
|
aFoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
149
149
|
await timeout(100);
|
|
150
150
|
// Find all edit buttons
|
|
151
|
-
const editButtons = tree.shadowRoot?.querySelectorAll('icon-button');
|
|
151
|
+
const editButtons = tree.shadowRoot?.querySelectorAll('oscd-icon-button');
|
|
152
152
|
expect(editButtons?.length).to.be.greaterThan(1);
|
|
153
153
|
// Click first edit button
|
|
154
154
|
editButtons?.[0]?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oscd-action-tree.spec.js","sourceRoot":"","sources":["../../action-tree/oscd-action-tree.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,uBAAuB,CAAC;AAG/B,SAAS,OAAO,CAAC,EAAU;IACzB,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;QACvB,UAAU,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AACD,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AAExB,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC;AAE9B,MAAM,QAAQ,GAAa;IACzB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE;wBACR;4BACE,IAAI,EAAE,KAAK;4BACX,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,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AAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\n\nimport { type SinonSpy, spy } from 'sinon';\n\nimport './oscd-action-tree.js';\nimport type { OscdActionTree, TreeNode } from './OscdActionTree.js';\n\nfunction timeout(ms: number) {\n return new Promise(res => {\n setTimeout(res, ms * 1);\n });\n}\nmocha.timeout(4000 * 1);\n\nconst editCallbackSpy = spy();\n\nconst testTree: TreeNode = {\n name: 'IED1',\n children: [\n {\n name: 'LD1',\n children: [\n {\n name: 'LLN0',\n children: [\n {\n name: 'Beh',\n leaf: [{ val: 0 }, { edit: editCallbackSpy, val: 1 }, { val: 4 }],\n },\n ],\n },\n {\n name: 'MMXU1',\n children: [\n {\n name: 'A',\n children: [\n {\n name: 'phsA',\n leaf: [\n { val: 33.44 },\n { edit: editCallbackSpy, val: 55.44 },\n { val: 66.44 },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n {\n name: 'LD2',\n children: [\n {\n name: 'LLN0',\n children: [\n {\n name: 'Beh',\n leaf: [{ val: 0 }],\n },\n {\n name: 'EmptyNode',\n children: [], // Node with NO leaf and empty children - should fire unfold event\n },\n ],\n },\n ],\n },\n {\n name: 'LD3',\n children: [], // Empty children - should fire unfold event\n },\n ],\n};\n\ndescribe('ActionTree Component', () => {\n describe('custom events', () => {\n let tree: OscdActionTree;\n let unfoldEventSpy: SinonSpy;\n\n beforeEach(async () => {\n tree = await fixture(\n html`<oscd-action-tree .data=${testTree}></oscd-action-tree>`,\n );\n\n unfoldEventSpy = spy();\n tree.addEventListener('unfold', unfoldEventSpy);\n editCallbackSpy.resetHistory();\n await timeout(200);\n });\n\n it('fires unfold event when expanding empty children array', async () => {\n // Find the fold icon for LD3 which has empty children array\n const ld3FoldIcon = tree.shadowRoot?.querySelector(\n '.tree-row:last-child .tree-fold',\n );\n\n expect(ld3FoldIcon).to.exist;\n\n // Click to unfold the empty children\n ld3FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n expect(unfoldEventSpy).to.have.been.calledOnce;\n expect(unfoldEventSpy.firstCall.args[0].detail.name).to.equal('LD3');\n });\n\n it('does not fire unfold event when expanding nodes with actual children', async () => {\n unfoldEventSpy.resetHistory();\n\n // Click on LD1 which has actual children (not empty array)\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1]; // LD1 fold icon\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Should not fire unfold event since LD1 has actual children\n\n expect(unfoldEventSpy).to.not.have.been.called;\n });\n\n it('event detail contains the correct node information', async () => {\n // Click on LD3 which has empty children\n const ld3FoldIcon = tree.shadowRoot?.querySelector(\n '.tree-row:last-child .tree-fold',\n );\n ld3FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const eventDetail = unfoldEventSpy.firstCall.args[0].detail;\n expect(eventDetail.name).to.equal('LD3');\n expect(eventDetail.children).to.deep.equal([]);\n\n expect(eventDetail.leaf).to.be.undefined;\n });\n });\n\n describe('edit callbacks', () => {\n let tree: OscdActionTree;\n\n beforeEach(async () => {\n tree = await fixture(\n html`<oscd-action-tree .data=${testTree}></oscd-action-tree>`,\n );\n\n editCallbackSpy.resetHistory();\n await timeout(200);\n });\n\n it('triggers edit callback when edit button is clicked', async () => {\n // First expand to make edit buttons visible\n // Expand LD1\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1];\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Expand LLN0 under LD1\n const lln0FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[2];\n lln0FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Find and click the edit button for Beh's second value\n const editButton = tree.shadowRoot?.querySelector('icon-button');\n\n expect(editButton).to.exist;\n\n editButton?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n expect(editCallbackSpy).to.have.been.calledOnce;\n });\n\n it('edit callbacks are called independently for different values', async () => {\n // Expand LD1 -> LLN0 to access Beh\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1];\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const lln0FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[2];\n lln0FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Expand MMXU1 -> A to access phsA\n const mmxu1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[4]; // MMXU1 under LD1\n mmxu1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const aFoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[5]; // A under MMXU1\n aFoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Find all edit buttons\n const editButtons = tree.shadowRoot?.querySelectorAll('icon-button');\n expect(editButtons?.length).to.be.greaterThan(1);\n\n // Click first edit button\n editButtons?.[0]?.dispatchEvent(\n new MouseEvent('click', { bubbles: true }),\n );\n await timeout(50);\n\n // Click second edit button\n editButtons?.[1]?.dispatchEvent(\n new MouseEvent('click', { bubbles: true }),\n );\n await timeout(50);\n\n // Both callbacks should have been called\n expect(editCallbackSpy.callCount).to.equal(2);\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"oscd-action-tree.spec.js","sourceRoot":"","sources":["../../action-tree/oscd-action-tree.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAiB,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,uBAAu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AE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;YAC1E,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAEjD,0BAA0B;YAC1B,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,CAC7B,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAC3C,CAAC;YACF,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC;YAElB,2BAA2B;YAC3B,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,CAC7B,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAC3C,CAAC;YACF,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC;YAElB,yCAAyC;YACzC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\n\nimport { type SinonSpy, spy } from 'sinon';\n\nimport './oscd-action-tree.js';\nimport type { OscdActionTree, TreeNode } from './OscdActionTree.js';\n\nfunction timeout(ms: number) {\n return new Promise(res => {\n setTimeout(res, ms * 1);\n });\n}\nmocha.timeout(4000 * 1);\n\nconst editCallbackSpy = spy();\n\nconst testTree: TreeNode = {\n name: 'IED1',\n children: [\n {\n name: 'LD1',\n children: [\n {\n name: 'LLN0',\n children: [\n {\n name: 'Beh',\n leaf: [{ val: 0 }, { edit: editCallbackSpy, val: 1 }, { val: 4 }],\n },\n ],\n },\n {\n name: 'MMXU1',\n children: [\n {\n name: 'A',\n children: [\n {\n name: 'phsA',\n leaf: [\n { val: 33.44 },\n { edit: editCallbackSpy, val: 55.44 },\n { val: 66.44 },\n ],\n },\n ],\n },\n ],\n },\n ],\n },\n {\n name: 'LD2',\n children: [\n {\n name: 'LLN0',\n children: [\n {\n name: 'Beh',\n leaf: [{ val: 0 }],\n },\n {\n name: 'EmptyNode',\n children: [], // Node with NO leaf and empty children - should fire unfold event\n },\n ],\n },\n ],\n },\n {\n name: 'LD3',\n children: [], // Empty children - should fire unfold event\n },\n ],\n};\n\ndescribe('ActionTree Component', () => {\n describe('custom events', () => {\n let tree: OscdActionTree;\n let unfoldEventSpy: SinonSpy;\n\n beforeEach(async () => {\n tree = await fixture(\n html`<oscd-action-tree .data=${testTree}></oscd-action-tree>`,\n );\n\n unfoldEventSpy = spy();\n tree.addEventListener('unfold', unfoldEventSpy);\n editCallbackSpy.resetHistory();\n await timeout(200);\n });\n\n it('fires unfold event when expanding empty children array', async () => {\n // Find the fold icon for LD3 which has empty children array\n const ld3FoldIcon = tree.shadowRoot?.querySelector(\n '.tree-row:last-child .tree-fold',\n );\n\n expect(ld3FoldIcon).to.exist;\n\n // Click to unfold the empty children\n ld3FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n expect(unfoldEventSpy).to.have.been.calledOnce;\n expect(unfoldEventSpy.firstCall.args[0].detail.name).to.equal('LD3');\n });\n\n it('does not fire unfold event when expanding nodes with actual children', async () => {\n unfoldEventSpy.resetHistory();\n\n // Click on LD1 which has actual children (not empty array)\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1]; // LD1 fold icon\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Should not fire unfold event since LD1 has actual children\n\n expect(unfoldEventSpy).to.not.have.been.called;\n });\n\n it('event detail contains the correct node information', async () => {\n // Click on LD3 which has empty children\n const ld3FoldIcon = tree.shadowRoot?.querySelector(\n '.tree-row:last-child .tree-fold',\n );\n ld3FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const eventDetail = unfoldEventSpy.firstCall.args[0].detail;\n expect(eventDetail.name).to.equal('LD3');\n expect(eventDetail.children).to.deep.equal([]);\n\n expect(eventDetail.leaf).to.be.undefined;\n });\n });\n\n describe('edit callbacks', () => {\n let tree: OscdActionTree;\n\n beforeEach(async () => {\n tree = await fixture(\n html`<oscd-action-tree .data=${testTree}></oscd-action-tree>`,\n );\n\n editCallbackSpy.resetHistory();\n await timeout(200);\n });\n\n it('triggers edit callback when edit button is clicked', async () => {\n // First expand to make edit buttons visible\n // Expand LD1\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1];\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Expand LLN0 under LD1\n const lln0FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[2];\n lln0FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Find and click the edit button for Beh's second value\n const editButton = tree.shadowRoot?.querySelector('oscd-icon-button');\n\n expect(editButton).to.exist;\n\n editButton?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n expect(editCallbackSpy).to.have.been.calledOnce;\n });\n\n it('edit callbacks are called independently for different values', async () => {\n // Expand LD1 -> LLN0 to access Beh\n const ld1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[1];\n ld1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const lln0FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[2];\n lln0FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Expand MMXU1 -> A to access phsA\n const mmxu1FoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[4]; // MMXU1 under LD1\n mmxu1FoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n const aFoldIcon = tree.shadowRoot?.querySelectorAll('.tree-fold')[5]; // A under MMXU1\n aFoldIcon?.dispatchEvent(new MouseEvent('click', { bubbles: true }));\n await timeout(100);\n\n // Find all edit buttons\n const editButtons = tree.shadowRoot?.querySelectorAll('oscd-icon-button');\n expect(editButtons?.length).to.be.greaterThan(1);\n\n // Click first edit button\n editButtons?.[0]?.dispatchEvent(\n new MouseEvent('click', { bubbles: true }),\n );\n await timeout(50);\n\n // Click second edit button\n editButtons?.[1]?.dispatchEvent(\n new MouseEvent('click', { bubbles: true }),\n );\n await timeout(50);\n\n // Both callbacks should have been called\n expect(editCallbackSpy.callCount).to.equal(2);\n });\n });\n});\n"]}
|
|
@@ -44,19 +44,18 @@ describe('OscdOutlinedSearchField', () => {
|
|
|
44
44
|
expect(searchField.value).to.equal('abc');
|
|
45
45
|
});
|
|
46
46
|
it('hides the placeholder while focused', async () => {
|
|
47
|
-
|
|
48
|
-
expect(innerField.getAttribute('placeholder')).to.equal('Search');
|
|
47
|
+
expect(searchField.getAttribute('placeholder')).to.equal('Search');
|
|
49
48
|
searchField.focus();
|
|
50
49
|
await searchField.updateComplete;
|
|
51
|
-
|
|
50
|
+
// An empty placeholder string is reflected by removing the attribute.
|
|
51
|
+
expect(searchField.getAttribute('placeholder')).to.be.null;
|
|
52
52
|
});
|
|
53
53
|
it('restores the placeholder once focus leaves and the value is empty', async () => {
|
|
54
|
-
const innerField = searchField.shadowRoot.querySelector('oscd-outlined-text-field');
|
|
55
54
|
searchField.focus();
|
|
56
55
|
await searchField.updateComplete;
|
|
57
|
-
|
|
56
|
+
searchField.dispatchEvent(new Event('blur'));
|
|
58
57
|
await searchField.updateComplete;
|
|
59
|
-
expect(
|
|
58
|
+
expect(searchField.getAttribute('placeholder')).to.equal('Search');
|
|
60
59
|
});
|
|
61
60
|
});
|
|
62
61
|
//# sourceMappingURL=oscd-outlined-search-field.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oscd-outlined-search-field.spec.js","sourceRoot":"","sources":["../../search-field/oscd-outlined-search-field.spec.ts"],"names":[],"mappings":"AAAA,OA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IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;QACjF,WAAW,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,WAAW,CAAC,cAAc,CAAC;QACjC,WAAW,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,MAAM,WAAW,CAAC,cAAc,CAAC;QAEjC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\n\nimport { SinonSpy, spy } from 'sinon';\n\nimport './oscd-outlined-search-field.js';\nimport type { OscdOutlinedSearchField } from './OscdOutlinedSearchField.js';\n\ndescribe('OscdOutlinedSearchField', () => {\n let searchField: OscdOutlinedSearchField;\n\n beforeEach(async () => {\n searchField = await fixture(\n html`<oscd-outlined-search-field\n placeholder=\"Search\"\n clearLabel=\"Clear search\"\n ></oscd-outlined-search-field>`,\n );\n });\n\n it('renders a default leading search icon', async () => {\n const icon = searchField.shadowRoot!.querySelector(\n 'oscd-icon[slot=\"leading-icon\"]',\n );\n\n expect(icon).to.exist;\n expect(icon!.textContent).to.equal('search');\n });\n\n it('does not render a clear button while empty', () => {\n expect(searchField.shadowRoot!.querySelector('oscd-icon-button')).to.be\n .null;\n });\n\n it('renders a clear button once a value is set', async () => {\n searchField.value = 'abc';\n await searchField.updateComplete;\n\n const clearButton = searchField.shadowRoot!.querySelector(\n 'oscd-icon-button[slot=\"trailing-icon\"]',\n );\n\n expect(clearButton).to.exist;\n expect(clearButton!.getAttribute('aria-label')).to.equal('Clear search');\n });\n\n it('clears the value and emits input when the clear button is clicked', async () => {\n const inputSpy: SinonSpy = spy();\n searchField.addEventListener('input', inputSpy);\n\n searchField.value = 'abc';\n await searchField.updateComplete;\n\n const clearButton = searchField.shadowRoot!.querySelector(\n 'oscd-icon-button[slot=\"trailing-icon\"]',\n ) as HTMLElement;\n clearButton.click();\n await searchField.updateComplete;\n\n expect(searchField.value).to.equal('');\n expect(inputSpy).to.have.been.calledOnce;\n });\n\n it('forwards typed input to value and dispatches input events', async () => {\n searchField.focus();\n await sendKeys({ type: 'abc' });\n await searchField.updateComplete;\n\n expect(searchField.value).to.equal('abc');\n });\n\n it('hides the placeholder while focused', async () => {\n expect(searchField.getAttribute('placeholder')).to.equal('Search');\n\n searchField.focus();\n await searchField.updateComplete;\n\n // An empty placeholder string is reflected by removing the attribute.\n expect(searchField.getAttribute('placeholder')).to.be.null;\n });\n\n it('restores the placeholder once focus leaves and the value is empty', async () => {\n searchField.focus();\n await searchField.updateComplete;\n searchField.dispatchEvent(new Event('blur'));\n await searchField.updateComplete;\n\n expect(searchField.getAttribute('placeholder')).to.equal('Search');\n });\n});\n"]}
|
|
@@ -486,7 +486,12 @@ export const Filtered = {
|
|
|
486
486
|
},
|
|
487
487
|
};
|
|
488
488
|
export const StackedKeyboardNavigation = {
|
|
489
|
-
|
|
489
|
+
args: {
|
|
490
|
+
['selectedIdsByTree']: {},
|
|
491
|
+
},
|
|
492
|
+
render: argz => {
|
|
493
|
+
const [_, updateArgs] = useArgs();
|
|
494
|
+
const selectedIdsByTree = argz['selectedIdsByTree'] ?? {};
|
|
490
495
|
const focusFirstTree = (event) => {
|
|
491
496
|
const button = event.currentTarget;
|
|
492
497
|
const tree = button.parentElement?.querySelector('oscd-tree');
|
|
@@ -513,15 +518,25 @@ export const StackedKeyboardNavigation = {
|
|
|
513
518
|
: targetTree.getLastNodeId();
|
|
514
519
|
targetTree.focus();
|
|
515
520
|
};
|
|
521
|
+
const handleStackedSelection = (prefix, event) => {
|
|
522
|
+
handleSelection(event);
|
|
523
|
+
updateArgs({
|
|
524
|
+
selectedIdsByTree: {
|
|
525
|
+
...selectedIdsByTree,
|
|
526
|
+
[prefix]: event.detail.selectedIds,
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
};
|
|
516
530
|
const renderStackedTree = (prefix) => html `<oscd-tree
|
|
517
531
|
.data=${[
|
|
518
532
|
{ id: `${prefix}:one`, label: `${prefix} / One`, children: [] },
|
|
519
533
|
{ id: `${prefix}:two`, label: `${prefix} / Two`, children: [] },
|
|
520
534
|
]}
|
|
521
|
-
selectionMode="
|
|
535
|
+
selectionMode="single"
|
|
536
|
+
.selectedIds=${selectedIdsByTree[prefix] ?? []}
|
|
522
537
|
.renderItem=${renderCompactItem}
|
|
523
538
|
@navigation-boundary=${handleBoundary}
|
|
524
|
-
@selected-ids-changed=${
|
|
539
|
+
@selected-ids-changed=${(event) => handleStackedSelection(prefix, event)}
|
|
525
540
|
></oscd-tree>`;
|
|
526
541
|
return html `<div
|
|
527
542
|
class="stacked-tree-story"
|
|
@@ -537,7 +552,10 @@ export const StackedKeyboardNavigation = {
|
|
|
537
552
|
<p>
|
|
538
553
|
Demo shows 3 Trees, with a border around the focused tree and a border
|
|
539
554
|
around the active node to show how you can use keyboard navigation
|
|
540
|
-
accross multiple trees.
|
|
555
|
+
accross multiple trees. Each tree uses single-selection, so clicking or
|
|
556
|
+
pressing Enter on a row also exercises the selected+active (focused)
|
|
557
|
+
state, showing selected-background/on-selected-foreground pairing
|
|
558
|
+
alongside the active outline.
|
|
541
559
|
</p>
|
|
542
560
|
<button type="button" @click=${focusFirstTree}>Focus first tree</button>
|
|
543
561
|
${renderStackedTree('Tree A')} ${renderStackedTree('Tree B')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OscdTree.stories.js","sourceRoot":"","sources":["../../tree/OscdTree.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;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;YACF,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAChD,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzE,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,OAAO;YACT,CAAC;YAED,UAAU,CAAC,QAAQ;gBACjB,SAAS,KAAK,MAAM;oBAClB,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE;oBAC7B,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACjC,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;QAEF,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE,CAC3C,IAAI,CAAA;gBACM;YACN,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC/D,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;SAChE;;sBAEa,iBAAiB;+BACR,cAAc;gCACb,eAAe;oBAC3B,CAAC;QAEjB,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;qCAgBsB,cAAc;QAC3C,iBAAiB,CAAC,QAAQ,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC;WACxB,CAAC;IACV,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit';\nimport type { StoryObj } from '@storybook/web-components-vite';\nimport { action } from 'storybook/actions';\nimport { useArgs } from 'storybook/preview-api';\n\nimport { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';\nimport type {\n TreeNode,\n TreeRenderContext,\n TreeSelectionChangeEventDetail,\n} from './OscdTree.js';\nimport { OscdTree } from './OscdTree.js';\n\nimport './oscd-tree.js';\nimport '../icon/oscd-icon.js';\nimport '../textfield/oscd-outlined-text-field.js';\n\ntype DemoTreeNode = TreeNode & {\n id?: string;\n label: string;\n description?: string;\n kind: 'ied' | 'access-point' | 'l-device' | 'logical-node';\n children?: DemoTreeNode[];\n};\n\nconst { args, argTypes, meta } = getStorybookMeta<OscdTree>({\n tagName: 'oscd-tree',\n});\n\nconst sampleTree: DemoTreeNode[] = [\n {\n id: 'ied:PUB_A',\n label: 'PUB_A',\n description: 'Publisher IED',\n kind: 'ied',\n children: [\n {\n id: 'ap:PUB_A/AP1',\n label: 'AP1',\n description: 'Access point',\n kind: 'access-point',\n children: [\n {\n id: 'ld:PUB_A/AP1/LD_A',\n label: 'LD_A',\n description: 'Logical device',\n kind: 'l-device',\n children: [\n {\n id: 'ln:PUB_A|AP1|LD_A||LLN0|',\n label: 'LLN0',\n description: 'Logical node zero',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_A|AP1|LD_A||TCTR|1',\n label: 'TCTR1',\n description: 'Current transformer',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_A|AP1|LD_A||XCBR|1',\n label: 'XCBR1',\n description: 'Circuit breaker',\n kind: 'logical-node',\n children: [],\n },\n ],\n },\n ],\n },\n ],\n },\n {\n id: 'ied:PUB_B',\n label: 'PUB_B',\n description: 'Publisher IED',\n kind: 'ied',\n children: [\n {\n id: 'ap:PUB_B/AP1',\n label: 'AP1',\n description: 'Access point',\n kind: 'access-point',\n children: [\n {\n id: 'ld:PUB_B/AP1/LD_B',\n label: 'LD_B',\n description: 'Logical device',\n kind: 'l-device',\n children: [\n {\n id: 'ln:PUB_B|AP1|LD_B||LLN0|',\n label: 'LLN0',\n description: 'Logical node zero',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_B|AP1|LD_B||TCTR|1',\n label: 'TCTR1',\n description: 'Current transformer',\n kind: 'logical-node',\n children: [],\n },\n ],\n },\n ],\n },\n ],\n },\n];\n\nconst treeWithUnknownChildren: DemoTreeNode[] = [\n ...sampleTree,\n {\n id: 'ied:REMOTE',\n label: 'REMOTE',\n description: 'Children are not loaded yet',\n kind: 'ied',\n },\n];\n\nconst kindIcon = (kind: DemoTreeNode['kind']): string => {\n switch (kind) {\n case 'ied':\n return 'reportIcon';\n case 'access-point':\n return 'lan';\n case 'l-device':\n return 'dns';\n case 'logical-node':\n return 'article';\n default:\n return 'circle';\n }\n};\n\nconst renderDemoItem = ({\n node,\n selected,\n active,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n <oscd-icon slot=\"start\">${kindIcon(node.kind)}</oscd-icon>\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.description}</span>\n </oscd-tree-item>`;\n\nconst renderCompactItem = ({\n node,\n childrenState,\n selected,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item ?selected=${selected} ?disabled=${disabled}>\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.kind} / ${childrenState}</span>\n </oscd-tree-item>`;\n\nconst renderMixedIconItem = ({\n node,\n selected,\n active,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n ${node.kind === 'ied'\n ? html`<oscd-icon slot=\"start\">${kindIcon(node.kind)}</oscd-icon>`\n : ''}\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.description}</span>\n </oscd-tree-item>`;\n\nconst matchesFilter = (node: DemoTreeNode, filter: string): boolean => {\n const needle = filter.trim().toLowerCase();\n if (!needle) {\n return true;\n }\n\n return [node.label, node.description, node.kind, node.id]\n .filter((term): term is string => !!term)\n .some(term => term.toLowerCase().includes(needle));\n};\n\nconst filterTree = (nodes: DemoTreeNode[], filter: string): DemoTreeNode[] => {\n const needle = filter.trim();\n if (!needle) {\n return nodes;\n }\n\n return nodes\n .map((node): DemoTreeNode | undefined => {\n const children = node.children\n ? filterTree(node.children, needle)\n : node.children;\n const matched = matchesFilter(node, needle);\n\n if (!matched && (!children || children.length === 0)) {\n return undefined;\n }\n\n const filteredNode: DemoTreeNode = {\n ...node,\n };\n\n if (node.children !== undefined) {\n filteredNode.children = children;\n }\n\n return filteredNode;\n })\n .filter((node): node is DemoTreeNode => !!node);\n};\n\nconst handleSelection = (\n event: CustomEvent<TreeSelectionChangeEventDetail<DemoTreeNode>>,\n) => {\n action('selected-ids-changed')(event.detail.selectedIds);\n};\n\nconst unpinnedIcon = html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n>\n <path\n d=\"M16.391 14.4188L16.8773 16.2406L16.2096 17.3947L13.3244 15.7253L11.3211 19.1876L10.4102 19.4307L10.1671 18.5198L12.1703 15.0576L9.28512 13.3882L9.95287 12.2341L11.7747 11.7478L14.1118 7.70854L13.5348 7.37467L14.2025 6.22059L19.9729 9.55934L19.3052 10.7134L18.7281 10.3795L16.391 14.4188ZM11.5974 13.1857L15.2328 15.2891L14.9531 14.2415L17.574 9.71179L15.2659 8.37629L12.645 12.906L11.5974 13.1857Z\"\n fill=\"currentColor\"\n />\n</svg>`;\n\nconst pinnedIcon = html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n>\n <path\n d=\"M16.4379 14.5274L16.9273 16.3484L16.2615 17.5036L13.3735 15.8391L11.3761 19.3047L10.4656 19.5494L10.2209 18.6389L12.2183 15.1733L9.33034 13.5088L9.99614 12.3536L11.8171 11.8642L14.1475 7.821L13.5699 7.4881L14.2357 6.3329L20.0117 9.66194L19.3459 10.8171L18.7683 10.4842L16.4379 14.5274Z\"\n fill=\"currentColor\"\n />\n</svg>`;\n\nconst handleExpansion = (event: CustomEvent<{ expandedIds: string[] }>) => {\n action('expanded-ids-changed')(event.detail.expandedIds);\n};\n\nexport default {\n ...meta,\n title: 'Tree / Tree',\n tags: ['autodocs'],\n};\n\nexport const Default: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1'],\n ['.renderItem']: renderDemoItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const MultipleSelection: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'multiple',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const SingleSelection: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'single',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const DisabledRows: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'multiple',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n .isDisabled=${(node: DemoTreeNode) =>\n node.kind === 'logical-node' &&\n node.id !== 'ln:PUB_A|AP1|LD_A||TCTR|1'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const UnknownChildren: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: treeWithUnknownChildren,\n ['.expandedIds']: ['ied:PUB_A'],\n ['.renderItem']: renderCompactItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @node-expand=${(event: Event) => {\n const customEvent = event as CustomEvent<{ id: string }>;\n if (customEvent.detail.id === 'ied:REMOTE') {\n customEvent.preventDefault();\n action('lazy node-expand prevented')(customEvent.detail.id);\n }\n }}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const DerivedIds: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree.map(({ id: _id, ...node }) => node),\n ['.expandedIds']: ['0', '0/0'],\n ['.renderItem']: renderDemoItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const ToggleCustomization: StoryObj = {\n argTypes: {\n ...argTypes,\n togglePosition: {\n name: 'toggle-position',\n control: { type: 'inline-radio' },\n options: ['leading', 'trailing'],\n description: 'Placement of the expand/collapse toggle within each row.',\n },\n collapseIcon: {\n name: 'collapse-icon',\n control: { type: 'text' },\n description: 'Icon shown on the toggle when a branch is collapsed.',\n },\n expandIcon: {\n name: 'expand-icon',\n control: { type: 'text' },\n description: 'Icon shown on the toggle when a branch is expanded.',\n },\n },\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1'],\n ['.renderItem']: renderDemoItem,\n togglePosition: 'trailing',\n collapseIcon: 'chevron_right',\n expandIcon: 'expand_more',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n toggle-position=${argz['togglePosition']}\n collapse-icon=${argz['collapseIcon']}\n expand-icon=${argz['expandIcon']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const PinnableLeaves: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.renderItem']: renderDemoItem,\n togglePosition: 'trailing',\n pinnedIds: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n },\n render: argz => {\n const [_, updateArgs] = useArgs();\n const pinnedIds = (argz['pinnedIds'] as string[]) ?? [];\n\n const togglePin = (id: string) => {\n const next = pinnedIds.includes(id)\n ? pinnedIds.filter(pinnedId => pinnedId !== id)\n : [...pinnedIds, id];\n action('pinned-ids-changed')(next);\n updateArgs({ pinnedIds: next });\n };\n\n return html`<div style=\"max-width: 520px;\">\n <oscd-tree\n toggle-position=${argz['togglePosition']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n .renderLeafAccessory=${({\n node,\n id,\n }: TreeRenderContext<DemoTreeNode>) => {\n const pinned = pinnedIds.includes(id);\n return html`<button\n aria-label=${pinned ? `Unpin ${node.label}` : `Pin ${node.label}`}\n aria-pressed=${pinned}\n @click=${() => togglePin(id)}\n >\n <oscd-icon style=\"--md-icon-size: 20px;\"\n >${pinned ? pinnedIcon : unpinnedIcon}</oscd-icon\n >\n </button>`;\n }}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`;\n },\n};\n\nexport const AlignedLeadingIcons: StoryObj = {\n argTypes: {\n ...argTypes,\n indentStep: {\n name: '--oscd-tree-indent-step',\n control: { type: 'text' },\n description:\n 'Drives both per-level indentation and the leading icon column width. Because a leading icon occupies exactly one indent step, icon-less children align their text under their iconed parent automatically. Set it large enough to hold the icon (e.g. 40px).',\n },\n },\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.renderItem']: renderMixedIconItem,\n togglePosition: 'trailing',\n indentStep: '40px',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n style=\"--oscd-tree-indent-step: ${argz['indentStep']};\"\n toggle-position=${argz['togglePosition']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const Filtered: StoryObj = {\n argTypes,\n args: {\n ...args,\n expandedIds: ['ied:PUB_A'],\n filter: 'TCTR',\n },\n render: argz => {\n const [_, updateArgs] = useArgs();\n const filter = String(argz['filter'] ?? '');\n const expandedIds = argz['expandedIds'] as string[];\n const filteredTree = filterTree(sampleTree, filter);\n\n return html`<div\n style=\"display: flex; flex-direction: column; gap: 12px; width: min(520px, 100%);\"\n >\n <oscd-outlined-text-field\n label=\"Filter tree\"\n .value=${filter}\n @input=${(event: Event) => {\n const input = event.target as HTMLInputElement;\n action('filter input')(input.value);\n updateArgs({ filter: input.value });\n }}\n ></oscd-outlined-text-field>\n <oscd-tree\n .data=${filteredTree}\n .expandedIds=${expandedIds}\n .renderItem=${renderDemoItem}\n @expanded-ids-changed=${(\n event: CustomEvent<{ expandedIds: string[] }>,\n ) => {\n handleExpansion(event);\n updateArgs({ expandedIds: event.detail.expandedIds });\n }}\n ></oscd-tree>\n </div>`;\n },\n};\n\nexport const StackedKeyboardNavigation: StoryObj = {\n render: () => {\n const focusFirstTree = (event: Event) => {\n const button = event.currentTarget as HTMLButtonElement;\n const tree = button.parentElement?.querySelector<OscdTree>('oscd-tree');\n if (!tree) {\n return;\n }\n\n tree.activeId = tree.getFirstNodeId();\n tree.focus();\n };\n\n const handleBoundary = (event: Event) => {\n const currentTree = event.currentTarget as OscdTree;\n const direction = (event as CustomEvent<{ direction: 'first' | 'last' }>)\n .detail.direction;\n const trees = Array.from(\n currentTree.parentElement?.querySelectorAll<OscdTree>('oscd-tree') ??\n [],\n );\n const currentIndex = trees.indexOf(currentTree);\n const targetTree = trees[currentIndex + (direction === 'last' ? 1 : -1)];\n if (!targetTree) {\n return;\n }\n\n targetTree.activeId =\n direction === 'last'\n ? targetTree.getFirstNodeId()\n : targetTree.getLastNodeId();\n targetTree.focus();\n };\n\n const renderStackedTree = (prefix: string) =>\n html`<oscd-tree\n .data=${[\n { id: `${prefix}:one`, label: `${prefix} / One`, children: [] },\n { id: `${prefix}:two`, label: `${prefix} / Two`, children: [] },\n ]}\n selectionMode=\"none\"\n .renderItem=${renderCompactItem}\n @navigation-boundary=${handleBoundary}\n @selected-ids-changed=${handleSelection}\n ></oscd-tree>`;\n\n return html`<div\n class=\"stacked-tree-story\"\n style=\"display: flex; flex-direction: column; justify-self:center; gap: 8px; width: min(520px, 100%);\"\n >\n <style>\n .stacked-tree-story oscd-tree:focus-within {\n outline: 2px solid var(--md-sys-color-secondary, #6750a4);\n outline-offset: 2px;\n border-radius: 6px;\n }\n </style>\n <p>\n Demo shows 3 Trees, with a border around the focused tree and a border\n around the active node to show how you can use keyboard navigation\n accross multiple trees.\n </p>\n <button type=\"button\" @click=${focusFirstTree}>Focus first tree</button>\n ${renderStackedTree('Tree A')} ${renderStackedTree('Tree B')}\n ${renderStackedTree('Tree C')}\n </div>`;\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"OscdTree.stories.js","sourceRoot":"","sources":["../../tree/OscdTree.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAQzE,OAAO,gBAAgB,CAAC;AACxB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0CAA0C,CAAC;AAUlD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAW;IAC1D,OAAO,EAAE,WAAW;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,GAAmB;IACjC;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE;YACR;gBACE,EAAE,EAAE,cAAc;gBAClB,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,cAAc;gBAC3B,IAAI,E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,QAAQ;gBACjB,SAAS,KAAK,MAAM;oBAClB,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE;oBAC7B,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACjC,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;QAEF,MAAM,sBAAsB,GAAG,CAC7B,MAAc,EACd,KAAgE,EAChE,EAAE;YACF,eAAe,CAAC,KAAK,CAAC,CAAC;YACvB,UAAU,CAAC;gBACT,iBAAiB,EAAE;oBACjB,GAAG,iBAAiB;oBACpB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;iBACnC;aACF,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE,CAC3C,IAAI,CAAA;gBACM;YACN,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC/D,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;SAChE;;uBAEc,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE;sBAChC,iBAAiB;+BACR,cAAc;gCACb,CACtB,KAAgE,EAChE,EAAE,CAAC,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC;oBAC9B,CAAC;QAEjB,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;qCAmBsB,cAAc;QAC3C,iBAAiB,CAAC,QAAQ,CAAC,IAAI,iBAAiB,CAAC,QAAQ,CAAC;QAC1D,iBAAiB,CAAC,QAAQ,CAAC;WACxB,CAAC;IACV,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit';\nimport type { StoryObj } from '@storybook/web-components-vite';\nimport { action } from 'storybook/actions';\nimport { useArgs } from 'storybook/preview-api';\n\nimport { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';\nimport type {\n TreeNode,\n TreeRenderContext,\n TreeSelectionChangeEventDetail,\n} from './OscdTree.js';\nimport { OscdTree } from './OscdTree.js';\n\nimport './oscd-tree.js';\nimport '../icon/oscd-icon.js';\nimport '../textfield/oscd-outlined-text-field.js';\n\ntype DemoTreeNode = TreeNode & {\n id?: string;\n label: string;\n description?: string;\n kind: 'ied' | 'access-point' | 'l-device' | 'logical-node';\n children?: DemoTreeNode[];\n};\n\nconst { args, argTypes, meta } = getStorybookMeta<OscdTree>({\n tagName: 'oscd-tree',\n});\n\nconst sampleTree: DemoTreeNode[] = [\n {\n id: 'ied:PUB_A',\n label: 'PUB_A',\n description: 'Publisher IED',\n kind: 'ied',\n children: [\n {\n id: 'ap:PUB_A/AP1',\n label: 'AP1',\n description: 'Access point',\n kind: 'access-point',\n children: [\n {\n id: 'ld:PUB_A/AP1/LD_A',\n label: 'LD_A',\n description: 'Logical device',\n kind: 'l-device',\n children: [\n {\n id: 'ln:PUB_A|AP1|LD_A||LLN0|',\n label: 'LLN0',\n description: 'Logical node zero',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_A|AP1|LD_A||TCTR|1',\n label: 'TCTR1',\n description: 'Current transformer',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_A|AP1|LD_A||XCBR|1',\n label: 'XCBR1',\n description: 'Circuit breaker',\n kind: 'logical-node',\n children: [],\n },\n ],\n },\n ],\n },\n ],\n },\n {\n id: 'ied:PUB_B',\n label: 'PUB_B',\n description: 'Publisher IED',\n kind: 'ied',\n children: [\n {\n id: 'ap:PUB_B/AP1',\n label: 'AP1',\n description: 'Access point',\n kind: 'access-point',\n children: [\n {\n id: 'ld:PUB_B/AP1/LD_B',\n label: 'LD_B',\n description: 'Logical device',\n kind: 'l-device',\n children: [\n {\n id: 'ln:PUB_B|AP1|LD_B||LLN0|',\n label: 'LLN0',\n description: 'Logical node zero',\n kind: 'logical-node',\n children: [],\n },\n {\n id: 'ln:PUB_B|AP1|LD_B||TCTR|1',\n label: 'TCTR1',\n description: 'Current transformer',\n kind: 'logical-node',\n children: [],\n },\n ],\n },\n ],\n },\n ],\n },\n];\n\nconst treeWithUnknownChildren: DemoTreeNode[] = [\n ...sampleTree,\n {\n id: 'ied:REMOTE',\n label: 'REMOTE',\n description: 'Children are not loaded yet',\n kind: 'ied',\n },\n];\n\nconst kindIcon = (kind: DemoTreeNode['kind']): string => {\n switch (kind) {\n case 'ied':\n return 'reportIcon';\n case 'access-point':\n return 'lan';\n case 'l-device':\n return 'dns';\n case 'logical-node':\n return 'article';\n default:\n return 'circle';\n }\n};\n\nconst renderDemoItem = ({\n node,\n selected,\n active,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n <oscd-icon slot=\"start\">${kindIcon(node.kind)}</oscd-icon>\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.description}</span>\n </oscd-tree-item>`;\n\nconst renderCompactItem = ({\n node,\n childrenState,\n selected,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item ?selected=${selected} ?disabled=${disabled}>\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.kind} / ${childrenState}</span>\n </oscd-tree-item>`;\n\nconst renderMixedIconItem = ({\n node,\n selected,\n active,\n disabled,\n}: TreeRenderContext<DemoTreeNode>) =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n ${node.kind === 'ied'\n ? html`<oscd-icon slot=\"start\">${kindIcon(node.kind)}</oscd-icon>`\n : ''}\n <span slot=\"headline\">${node.label}</span>\n <span slot=\"supporting-text\">${node.description}</span>\n </oscd-tree-item>`;\n\nconst matchesFilter = (node: DemoTreeNode, filter: string): boolean => {\n const needle = filter.trim().toLowerCase();\n if (!needle) {\n return true;\n }\n\n return [node.label, node.description, node.kind, node.id]\n .filter((term): term is string => !!term)\n .some(term => term.toLowerCase().includes(needle));\n};\n\nconst filterTree = (nodes: DemoTreeNode[], filter: string): DemoTreeNode[] => {\n const needle = filter.trim();\n if (!needle) {\n return nodes;\n }\n\n return nodes\n .map((node): DemoTreeNode | undefined => {\n const children = node.children\n ? filterTree(node.children, needle)\n : node.children;\n const matched = matchesFilter(node, needle);\n\n if (!matched && (!children || children.length === 0)) {\n return undefined;\n }\n\n const filteredNode: DemoTreeNode = {\n ...node,\n };\n\n if (node.children !== undefined) {\n filteredNode.children = children;\n }\n\n return filteredNode;\n })\n .filter((node): node is DemoTreeNode => !!node);\n};\n\nconst handleSelection = (\n event: CustomEvent<TreeSelectionChangeEventDetail<DemoTreeNode>>,\n) => {\n action('selected-ids-changed')(event.detail.selectedIds);\n};\n\nconst unpinnedIcon = html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n>\n <path\n d=\"M16.391 14.4188L16.8773 16.2406L16.2096 17.3947L13.3244 15.7253L11.3211 19.1876L10.4102 19.4307L10.1671 18.5198L12.1703 15.0576L9.28512 13.3882L9.95287 12.2341L11.7747 11.7478L14.1118 7.70854L13.5348 7.37467L14.2025 6.22059L19.9729 9.55934L19.3052 10.7134L18.7281 10.3795L16.391 14.4188ZM11.5974 13.1857L15.2328 15.2891L14.9531 14.2415L17.574 9.71179L15.2659 8.37629L12.645 12.906L11.5974 13.1857Z\"\n fill=\"currentColor\"\n />\n</svg>`;\n\nconst pinnedIcon = html`<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"28\"\n height=\"28\"\n viewBox=\"0 0 28 28\"\n fill=\"none\"\n>\n <path\n d=\"M16.4379 14.5274L16.9273 16.3484L16.2615 17.5036L13.3735 15.8391L11.3761 19.3047L10.4656 19.5494L10.2209 18.6389L12.2183 15.1733L9.33034 13.5088L9.99614 12.3536L11.8171 11.8642L14.1475 7.821L13.5699 7.4881L14.2357 6.3329L20.0117 9.66194L19.3459 10.8171L18.7683 10.4842L16.4379 14.5274Z\"\n fill=\"currentColor\"\n />\n</svg>`;\n\nconst handleExpansion = (event: CustomEvent<{ expandedIds: string[] }>) => {\n action('expanded-ids-changed')(event.detail.expandedIds);\n};\n\nexport default {\n ...meta,\n title: 'Tree / Tree',\n tags: ['autodocs'],\n};\n\nexport const Default: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1'],\n ['.renderItem']: renderDemoItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const MultipleSelection: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'multiple',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const SingleSelection: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'single',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const DisabledRows: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.selectedIds']: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n ['.renderItem']: renderDemoItem,\n selectionMode: 'multiple',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n selectionMode=${argz['selectionMode']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .selectedIds=${argz['.selectedIds']}\n .renderItem=${argz['.renderItem']}\n .isSelectable=${(node: DemoTreeNode) => node.kind === 'logical-node'}\n .isDisabled=${(node: DemoTreeNode) =>\n node.kind === 'logical-node' &&\n node.id !== 'ln:PUB_A|AP1|LD_A||TCTR|1'}\n @selected-ids-changed=${handleSelection}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const UnknownChildren: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: treeWithUnknownChildren,\n ['.expandedIds']: ['ied:PUB_A'],\n ['.renderItem']: renderCompactItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @node-expand=${(event: Event) => {\n const customEvent = event as CustomEvent<{ id: string }>;\n if (customEvent.detail.id === 'ied:REMOTE') {\n customEvent.preventDefault();\n action('lazy node-expand prevented')(customEvent.detail.id);\n }\n }}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const DerivedIds: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree.map(({ id: _id, ...node }) => node),\n ['.expandedIds']: ['0', '0/0'],\n ['.renderItem']: renderDemoItem,\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const ToggleCustomization: StoryObj = {\n argTypes: {\n ...argTypes,\n togglePosition: {\n name: 'toggle-position',\n control: { type: 'inline-radio' },\n options: ['leading', 'trailing'],\n description: 'Placement of the expand/collapse toggle within each row.',\n },\n collapseIcon: {\n name: 'collapse-icon',\n control: { type: 'text' },\n description: 'Icon shown on the toggle when a branch is collapsed.',\n },\n expandIcon: {\n name: 'expand-icon',\n control: { type: 'text' },\n description: 'Icon shown on the toggle when a branch is expanded.',\n },\n },\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1'],\n ['.renderItem']: renderDemoItem,\n togglePosition: 'trailing',\n collapseIcon: 'chevron_right',\n expandIcon: 'expand_more',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n toggle-position=${argz['togglePosition']}\n collapse-icon=${argz['collapseIcon']}\n expand-icon=${argz['expandIcon']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const PinnableLeaves: StoryObj = {\n argTypes,\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.renderItem']: renderDemoItem,\n togglePosition: 'trailing',\n pinnedIds: ['ln:PUB_A|AP1|LD_A||TCTR|1'],\n },\n render: argz => {\n const [_, updateArgs] = useArgs();\n const pinnedIds = (argz['pinnedIds'] as string[]) ?? [];\n\n const togglePin = (id: string) => {\n const next = pinnedIds.includes(id)\n ? pinnedIds.filter(pinnedId => pinnedId !== id)\n : [...pinnedIds, id];\n action('pinned-ids-changed')(next);\n updateArgs({ pinnedIds: next });\n };\n\n return html`<div style=\"max-width: 520px;\">\n <oscd-tree\n toggle-position=${argz['togglePosition']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n .renderLeafAccessory=${({\n node,\n id,\n }: TreeRenderContext<DemoTreeNode>) => {\n const pinned = pinnedIds.includes(id);\n return html`<button\n aria-label=${pinned ? `Unpin ${node.label}` : `Pin ${node.label}`}\n aria-pressed=${pinned}\n @click=${() => togglePin(id)}\n >\n <oscd-icon style=\"--md-icon-size: 20px;\"\n >${pinned ? pinnedIcon : unpinnedIcon}</oscd-icon\n >\n </button>`;\n }}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`;\n },\n};\n\nexport const AlignedLeadingIcons: StoryObj = {\n argTypes: {\n ...argTypes,\n indentStep: {\n name: '--oscd-tree-indent-step',\n control: { type: 'text' },\n description:\n 'Drives both per-level indentation and the leading icon column width. Because a leading icon occupies exactly one indent step, icon-less children align their text under their iconed parent automatically. Set it large enough to hold the icon (e.g. 40px).',\n },\n },\n args: {\n ...args,\n ['.data']: sampleTree,\n ['.expandedIds']: ['ied:PUB_A', 'ap:PUB_A/AP1', 'ld:PUB_A/AP1/LD_A'],\n ['.renderItem']: renderMixedIconItem,\n togglePosition: 'trailing',\n indentStep: '40px',\n },\n render: argz =>\n html`<div style=\"max-width: 520px;\">\n <oscd-tree\n style=\"--oscd-tree-indent-step: ${argz['indentStep']};\"\n toggle-position=${argz['togglePosition']}\n .data=${argz['.data']}\n .expandedIds=${argz['.expandedIds']}\n .renderItem=${argz['.renderItem']}\n @expanded-ids-changed=${handleExpansion}\n ></oscd-tree>\n </div>`,\n};\n\nexport const Filtered: StoryObj = {\n argTypes,\n args: {\n ...args,\n expandedIds: ['ied:PUB_A'],\n filter: 'TCTR',\n },\n render: argz => {\n const [_, updateArgs] = useArgs();\n const filter = String(argz['filter'] ?? '');\n const expandedIds = argz['expandedIds'] as string[];\n const filteredTree = filterTree(sampleTree, filter);\n\n return html`<div\n style=\"display: flex; flex-direction: column; gap: 12px; width: min(520px, 100%);\"\n >\n <oscd-outlined-text-field\n label=\"Filter tree\"\n .value=${filter}\n @input=${(event: Event) => {\n const input = event.target as HTMLInputElement;\n action('filter input')(input.value);\n updateArgs({ filter: input.value });\n }}\n ></oscd-outlined-text-field>\n <oscd-tree\n .data=${filteredTree}\n .expandedIds=${expandedIds}\n .renderItem=${renderDemoItem}\n @expanded-ids-changed=${(\n event: CustomEvent<{ expandedIds: string[] }>,\n ) => {\n handleExpansion(event);\n updateArgs({ expandedIds: event.detail.expandedIds });\n }}\n ></oscd-tree>\n </div>`;\n },\n};\n\nexport const StackedKeyboardNavigation: StoryObj = {\n args: {\n ['selectedIdsByTree']: {} as Record<string, string[]>,\n },\n render: argz => {\n const [_, updateArgs] = useArgs();\n const selectedIdsByTree =\n (argz['selectedIdsByTree'] as Record<string, string[]>) ?? {};\n\n const focusFirstTree = (event: Event) => {\n const button = event.currentTarget as HTMLButtonElement;\n const tree = button.parentElement?.querySelector<OscdTree>('oscd-tree');\n if (!tree) {\n return;\n }\n\n tree.activeId = tree.getFirstNodeId();\n tree.focus();\n };\n\n const handleBoundary = (event: Event) => {\n const currentTree = event.currentTarget as OscdTree;\n const direction = (event as CustomEvent<{ direction: 'first' | 'last' }>)\n .detail.direction;\n const trees = Array.from(\n currentTree.parentElement?.querySelectorAll<OscdTree>('oscd-tree') ??\n [],\n );\n const currentIndex = trees.indexOf(currentTree);\n const targetTree = trees[currentIndex + (direction === 'last' ? 1 : -1)];\n if (!targetTree) {\n return;\n }\n\n targetTree.activeId =\n direction === 'last'\n ? targetTree.getFirstNodeId()\n : targetTree.getLastNodeId();\n targetTree.focus();\n };\n\n const handleStackedSelection = (\n prefix: string,\n event: CustomEvent<TreeSelectionChangeEventDetail<DemoTreeNode>>,\n ) => {\n handleSelection(event);\n updateArgs({\n selectedIdsByTree: {\n ...selectedIdsByTree,\n [prefix]: event.detail.selectedIds,\n },\n });\n };\n\n const renderStackedTree = (prefix: string) =>\n html`<oscd-tree\n .data=${[\n { id: `${prefix}:one`, label: `${prefix} / One`, children: [] },\n { id: `${prefix}:two`, label: `${prefix} / Two`, children: [] },\n ]}\n selectionMode=\"single\"\n .selectedIds=${selectedIdsByTree[prefix] ?? []}\n .renderItem=${renderCompactItem}\n @navigation-boundary=${handleBoundary}\n @selected-ids-changed=${(\n event: CustomEvent<TreeSelectionChangeEventDetail<DemoTreeNode>>,\n ) => handleStackedSelection(prefix, event)}\n ></oscd-tree>`;\n\n return html`<div\n class=\"stacked-tree-story\"\n style=\"display: flex; flex-direction: column; justify-self:center; gap: 8px; width: min(520px, 100%);\"\n >\n <style>\n .stacked-tree-story oscd-tree:focus-within {\n outline: 2px solid var(--md-sys-color-secondary, #6750a4);\n outline-offset: 2px;\n border-radius: 6px;\n }\n </style>\n <p>\n Demo shows 3 Trees, with a border around the focused tree and a border\n around the active node to show how you can use keyboard navigation\n accross multiple trees. Each tree uses single-selection, so clicking or\n pressing Enter on a row also exercises the selected+active (focused)\n state, showing selected-background/on-selected-foreground pairing\n alongside the active outline.\n </p>\n <button type=\"button\" @click=${focusFirstTree}>Focus first tree</button>\n ${renderStackedTree('Tree A')} ${renderStackedTree('Tree B')}\n ${renderStackedTree('Tree C')}\n </div>`;\n },\n};\n"]}
|
|
@@ -559,7 +559,7 @@ Tree.styles = css `
|
|
|
559
559
|
color: var(--oscd-tree-color, var(--md-sys-color-on-surface, #1d1b20));
|
|
560
560
|
font-family: var(
|
|
561
561
|
--oscd-tree-font-family,
|
|
562
|
-
var(--
|
|
562
|
+
var(--md-sys-typescale-body-large-font, Roboto)
|
|
563
563
|
);
|
|
564
564
|
outline: none;
|
|
565
565
|
/*
|
|
@@ -643,10 +643,13 @@ Tree.styles = css `
|
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
.row[data-selection-mode='single'][data-selected='true'] {
|
|
646
|
-
color: var(
|
|
646
|
+
color: var(
|
|
647
|
+
--oscd-tree-row-selected-text-color,
|
|
648
|
+
var(--md-sys-color-on-primary, #fff)
|
|
649
|
+
);
|
|
647
650
|
background: var(
|
|
648
651
|
--oscd-tree-row-selected-color,
|
|
649
|
-
var(--
|
|
652
|
+
var(--md-sys-color-primary, #6750a4)
|
|
650
653
|
);
|
|
651
654
|
}
|
|
652
655
|
|
|
@@ -655,7 +658,28 @@ Tree.styles = css `
|
|
|
655
658
|
) {
|
|
656
659
|
background: var(
|
|
657
660
|
--oscd-tree-row-selected-hover-color,
|
|
658
|
-
var(
|
|
661
|
+
var(
|
|
662
|
+
--oscd-tree-row-selected-color,
|
|
663
|
+
var(--md-sys-color-primary, #6750a4)
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/*
|
|
669
|
+
* When a selected row is also the keyboard-active row while the tree has
|
|
670
|
+
* focus, the ":host(:focus-within) .row[data-active='true']" rule above
|
|
671
|
+
* has higher specificity than the selected-row rule and would otherwise
|
|
672
|
+
* win the cascade for "color", overriding the selected text color with
|
|
673
|
+
* "inherit" while leaving the selected background untouched. Restate the
|
|
674
|
+
* selected text color here, at higher specificity than both rules, so a
|
|
675
|
+
* focused+selected row keeps its selected-background/selected-foreground
|
|
676
|
+
* pairing while still showing the active outline.
|
|
677
|
+
*/
|
|
678
|
+
:host(:focus-within)
|
|
679
|
+
.row[data-selection-mode='single'][data-selected='true'][data-active='true'] {
|
|
680
|
+
color: var(
|
|
681
|
+
--oscd-tree-row-selected-text-color,
|
|
682
|
+
var(--md-sys-color-on-primary, #fff)
|
|
659
683
|
);
|
|
660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AAE,CAAC;wCACG;AAMlC;IADC,QAAQ,EAAE;2CAC+B;AAS1C;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;0CACV;AAS/B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;wCACZ;AAW3B;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;4CACX;AAI/C;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sCACA;AAO/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC;kDACtC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\n\nimport { OscdCheckbox } from '../../checkbox/OscdCheckbox.js';\nimport { OscdFocusRing } from '../../focus/OscdFocusRing.js';\nimport { OscdIcon } from '../../icon/OscdIcon.js';\nimport { OscdRipple } from '../../ripple/OscdRipple.js';\nimport { OscdTreeItem } from '../OscdTreeItem.js';\n\n/**\n * Selection behavior for `oscd-tree`.\n */\nexport type TreeSelectionMode = 'none' | 'single' | 'multiple';\n\n/**\n * Placement of the expand/collapse toggle within a tree row.\n *\n * - `'leading'` renders the toggle before the row content (default).\n * - `'trailing'` renders the toggle after the row content, right-aligned so\n * the toggles line up on the trailing edge regardless of nesting depth.\n */\nexport type TreeTogglePosition = 'leading' | 'trailing';\n\n/**\n * Loaded state of a tree node's children.\n */\nexport type TreeChildrenState = 'unknown' | 'leaf' | 'branch';\n\n/**\n * Minimal data contract for nodes rendered by `oscd-tree`.\n *\n * `children === undefined` means that children are unknown or not loaded yet.\n * `children === []` means that the node is known to be a leaf.\n * A non-empty `children` array means that the node is a branch.\n */\nexport type TreeNode = {\n /**\n * Stable node identifier. If omitted, `oscd-tree` falls back to\n * `getNodeId` and then to the node's index path.\n */\n id?: string;\n\n /**\n * Child nodes when known.\n */\n children?: TreeNode[];\n};\n\n/**\n * Context passed to `renderItem` for each visible tree row.\n */\nexport type TreeRenderContext<T extends TreeNode = TreeNode> = {\n /** The original caller-provided node. */\n node: T;\n\n /** Resolved node identifier used by selection, expansion, and events. */\n id: string;\n\n /** One-based nesting level computed by the tree. */\n level: number;\n\n /** Whether this node is currently expanded. */\n expanded: boolean;\n\n /** Whether this node is currently selected. */\n selected: boolean;\n\n /** Whether this row is the active keyboard row. */\n active: boolean;\n\n /** Current child loading/branch state. */\n childrenState: TreeChildrenState;\n\n /** Whether this row can be selected. */\n selectable: boolean;\n\n /** Whether this row is disabled. */\n disabled: boolean;\n};\n\n/**\n * Detail for node-level tree events.\n */\nexport type TreeNodeEventDetail<T extends TreeNode = TreeNode> = {\n /** The original caller-provided node. */\n node: T;\n\n /** Resolved node identifier. */\n id: string;\n};\n\n/**\n * Detail for `selected-ids-changed`.\n */\nexport type TreeSelectionChangeEventDetail<T extends TreeNode = TreeNode> = {\n /** Current selected node identifiers. */\n selectedIds: string[];\n\n /** Previous selected node identifiers. */\n previousSelectedIds: string[];\n\n /** Node that triggered the selection change. */\n targetNode: T;\n};\n\ntype VisibleTreeNode<T extends TreeNode = TreeNode> = {\n node: T;\n id: string;\n htmlId: string;\n level: number;\n parentIds: string[];\n ariaPositionInSet: number;\n ariaSetSize: number;\n};\n\nconst fallbackRenderItem = <T extends TreeNode>({\n node,\n id,\n selected,\n active,\n disabled,\n}: TreeRenderContext<T>): TemplateResult =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n <span slot=\"headline\">${'label' in node ? String(node.label) : id}</span>\n </oscd-tree-item>`;\n\nconst idSeparator = '/';\n\nfunction childState(node: TreeNode): TreeChildrenState {\n if (node.children === undefined) {\n return 'unknown';\n }\n\n return node.children.length > 0 ? 'branch' : 'leaf';\n}\n\n/**\n * Internal base class for `oscd-tree`.\n */\nexport class Tree<T extends TreeNode = TreeNode> extends ScopedElementsMixin(\n LitElement,\n) {\n static scopedElements = {\n 'oscd-checkbox': OscdCheckbox,\n 'oscd-focus-ring': OscdFocusRing,\n 'oscd-icon': OscdIcon,\n 'oscd-ripple': OscdRipple,\n 'oscd-tree-item': OscdTreeItem,\n };\n\n /**\n * Structured tree data to render.\n */\n @property({ attribute: false })\n data: T[] = [];\n\n /**\n * Selected node identifiers.\n *\n * This state is controlled by the caller and may be persisted outside the\n * tree, but it must be scoped to the data set/context that produced the IDs.\n * Reset or re-key persisted selected IDs when `data` changes to a different\n * logical tree, otherwise unrelated nodes with matching IDs may appear\n * selected.\n */\n @property({ attribute: false })\n selectedIds: string[] = [];\n\n /**\n * Expanded node identifiers.\n *\n * This state is controlled by the caller and may be persisted outside the\n * tree, but it must be scoped to the data set/context that produced the IDs.\n * Reset or re-key persisted expanded IDs when `data` changes to a different\n * logical tree, otherwise unrelated nodes with matching IDs may appear\n * expanded.\n */\n @property({ attribute: false })\n expandedIds: string[] = [];\n\n /**\n * Renders caller-provided content for a tree row.\n *\n * The tree owns the row frame, indentation, toggle affordance, selection\n * affordance, keyboard handling, and ARIA attributes. This callback renders\n * the content inside that frame.\n */\n @property({ attribute: false })\n renderItem?: (context: TreeRenderContext<T>) => TemplateResult;\n\n /**\n * Renders an interactive accessory into the toggle column of a **leaf** row.\n *\n * Leaf rows have no expand/collapse toggle, so this callback can supply\n * trailing content (for example a pin/unpin button) that lines up exactly\n * with the chevrons of expandable rows, following `togglePosition`.\n *\n * Return `nothing` (or a falsy value) to leave the leaf's toggle column\n * empty. The tree isolates pointer and `Enter`/`Space` interaction on the\n * accessory so activating it does not select or toggle the row; arrow-key\n * navigation still works. Any returned interactive element (such as a\n * `<button>`) is keyboard-focusable and therefore adds a tab stop per row.\n * Provide an accessible label and `aria-pressed` for toggle semantics.\n */\n @property({ attribute: false })\n renderLeafAccessory?: (context: TreeRenderContext<T>) => unknown;\n\n /**\n * Resolves a stable node identifier when `node.id` is not provided.\n *\n * If neither `node.id` nor this callback is available, the tree falls back to\n * an index-path ID. Index-path IDs are convenient for static examples but are\n * not stable when rows are inserted, removed, sorted, filtered, or lazily\n * loaded, and should not be persisted.\n */\n @property({ attribute: false })\n getNodeId?: (node: T, indexPath: number[]) => string;\n\n /**\n * Resolves the accessible label for a node row.\n *\n * If omitted, the tree uses `node.label` when present, then the resolved node\n * ID. This label is applied to the row frame that owns `role=\"treeitem\"`.\n */\n @property({ attribute: false })\n getNodeLabel?: (node: T, id: string) => string;\n\n /**\n * Returns whether a node can be selected.\n */\n @property({ attribute: false })\n isSelectable?: (node: T) => boolean;\n\n /**\n * Returns whether a node is disabled.\n */\n @property({ attribute: false })\n isDisabled?: (node: T) => boolean;\n\n /**\n * Selection behavior.\n */\n @property()\n selectionMode: TreeSelectionMode = 'none';\n\n /**\n * Icon shown on the expand/collapse toggle when a branch is collapsed.\n *\n * Any icon name understood by `oscd-icon` (a Material Symbol name or a\n * registered SCL icon) may be used. Defaults to `chevron_right`.\n */\n @property({ attribute: 'collapse-icon' })\n collapseIcon = 'chevron_right';\n\n /**\n * Icon shown on the expand/collapse toggle when a branch is expanded.\n *\n * Any icon name understood by `oscd-icon` (a Material Symbol name or a\n * registered SCL icon) may be used. Defaults to `expand_more`.\n */\n @property({ attribute: 'expand-icon' })\n expandIcon = 'expand_more';\n\n /**\n * Placement of the expand/collapse toggle within each row.\n *\n * `'leading'` (default) renders the toggle before the row content.\n * `'trailing'` renders it after the content, right-aligned so the toggles\n * line up on the trailing edge regardless of nesting depth. Keyboard\n * expansion (`ArrowRight`/`ArrowLeft`) is unaffected by this option.\n */\n @property({ reflect: true, attribute: 'toggle-position' })\n togglePosition: TreeTogglePosition = 'leading';\n\n /** Currently active keyboard row. Controlled by the caller when needed. */\n @property({ attribute: false })\n activeId: string | null = null;\n\n /**\n * Whether focusing the active row should scroll it into the nearest\n * scrollable ancestor when it is outside the visible area.\n */\n @property({ type: Boolean, attribute: 'scroll-active-into-view' })\n scrollActiveIntoView = true;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n this.addEventListener('keydown', this.handleTreeKeyDown);\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('keydown', this.handleTreeKeyDown);\n super.disconnectedCallback();\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n if (!changedProperties.has('activeId') || this.activeId === null) {\n return;\n }\n\n const isNavigable = this.navigableRows().some(\n row => row.id === this.activeId,\n );\n if (!isNavigable) {\n console.warn(`Ignoring invalid oscd-tree activeId: ${this.activeId}`);\n this.activeId = changedProperties.get('activeId') ?? null;\n }\n }\n\n /** Returns the first visible, enabled row ID, or null when none exists. */\n public getFirstNodeId(): string | null {\n return this.navigableRows()[0]?.id ?? null;\n }\n\n /** Returns the last visible, enabled row ID, or null when none exists. */\n public getLastNodeId(): string | null {\n const rows = this.navigableRows();\n return rows[rows.length - 1]?.id ?? null;\n }\n\n /**\n * Expands a node by ID.\n */\n public expand(id: string): void {\n if (!this.expandedIds.includes(id)) {\n this.setExpandedIds([...this.expandedIds, id]);\n }\n }\n\n /**\n * Collapses a node by ID.\n */\n public collapse(id: string): void {\n if (this.expandedIds.includes(id)) {\n this.setExpandedIds(\n this.expandedIds.filter(expandedId => expandedId !== id),\n );\n }\n }\n\n /**\n * Toggles a node expansion state by ID.\n */\n public toggle(id: string): void {\n const row = this.visibleRows().find(candidate => candidate.id === id);\n if (!row) {\n return;\n }\n\n this.toggleExpansion(row);\n }\n\n private rowId(node: T, indexPath: number[]): string {\n return (\n node.id ??\n this.getNodeId?.(node, indexPath) ??\n indexPath.join(idSeparator)\n );\n }\n\n private visibleRows(): VisibleTreeNode<T>[] {\n const expandedIds = new Set(this.expandedIds);\n const rows: VisibleTreeNode<T>[] = [];\n\n const walk = (\n nodes: T[] | undefined,\n level: number,\n parentIds: string[],\n indexPath: number[],\n ) => {\n if (!nodes) {\n return;\n }\n\n const ariaSetSize = nodes.length;\n nodes.forEach((node, index) => {\n const childIndexPath = [...indexPath, index];\n const id = this.rowId(node, childIndexPath);\n rows.push({\n node,\n id,\n htmlId: `tree-row-${rows.length}`,\n level,\n parentIds,\n ariaPositionInSet: index + 1,\n ariaSetSize,\n });\n\n if (expandedIds.has(id) && node.children) {\n walk(\n node.children as T[],\n level + 1,\n [...parentIds, id],\n childIndexPath,\n );\n }\n });\n };\n\n walk(this.data, 1, [], []);\n\n return rows;\n }\n\n private navigableRows(): VisibleTreeNode<T>[] {\n return this.visibleRows().filter(row => !this.isRowDisabled(row));\n }\n\n private renderContext(row: VisibleTreeNode<T>): TreeRenderContext<T> {\n const selected = this.selectedIds.includes(row.id);\n\n return {\n node: row.node,\n id: row.id,\n level: row.level,\n expanded: this.expandedIds.includes(row.id),\n selected,\n active: this.activeId === row.id,\n childrenState: childState(row.node),\n selectable: this.selectionMode !== 'none' && this.isRowSelectable(row),\n disabled: this.isRowDisabled(row),\n };\n }\n\n private accessibleLabel(row: VisibleTreeNode<T>): string {\n if (this.getNodeLabel) {\n return this.getNodeLabel(row.node, row.id);\n }\n\n if ('label' in row.node && row.node.label !== undefined) {\n return String(row.node.label);\n }\n\n return row.id;\n }\n\n private isRowSelectable(row: VisibleTreeNode<T>): boolean {\n return this.isSelectable ? this.isSelectable(row.node) : true;\n }\n\n private isRowDisabled(row: VisibleTreeNode<T>): boolean {\n return this.isDisabled ? this.isDisabled(row.node) : false;\n }\n\n private setExpandedIds(expandedIds: string[]): void {\n this.expandedIds = expandedIds;\n this.dispatchEvent(\n new CustomEvent('expanded-ids-changed', {\n detail: { expandedIds },\n }),\n );\n }\n\n private setSelectedIds(selectedIds: string[], targetNode: T): void {\n const previousSelectedIds = this.selectedIds;\n this.selectedIds = selectedIds;\n this.dispatchEvent(\n new CustomEvent<TreeSelectionChangeEventDetail<T>>(\n 'selected-ids-changed',\n {\n detail: {\n selectedIds,\n previousSelectedIds,\n targetNode,\n },\n },\n ),\n );\n }\n\n private fireNodeEvent(\n name: string,\n row: VisibleTreeNode<T>,\n options?: { cancelable?: boolean },\n ): boolean {\n const event = new CustomEvent<TreeNodeEventDetail<T>>(name, {\n bubbles: true,\n cancelable: options?.cancelable ?? false,\n detail: {\n node: row.node,\n id: row.id,\n },\n });\n\n return this.dispatchEvent(event);\n }\n\n private toggleExpansion(row: VisibleTreeNode<T>): void {\n if (this.isRowDisabled(row) || childState(row.node) === 'leaf') {\n return;\n }\n\n const expanded = this.expandedIds.includes(row.id);\n if (expanded) {\n this.setExpandedIds(\n this.expandedIds.filter(expandedId => expandedId !== row.id),\n );\n this.fireNodeEvent('node-collapse', row);\n this.fireNodeEvent('node-toggle', row);\n return;\n }\n\n if (!this.fireNodeEvent('node-expand', row, { cancelable: true })) {\n return;\n }\n\n this.setExpandedIds([...this.expandedIds, row.id]);\n this.fireNodeEvent('node-toggle', row);\n }\n\n private toggleSelection(row: VisibleTreeNode<T>): void {\n if (\n this.selectionMode === 'none' ||\n this.isRowDisabled(row) ||\n !this.isRowSelectable(row)\n ) {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.setSelectedIds([row.id], row.node);\n return;\n }\n\n const selected = this.selectedIds.includes(row.id);\n this.setSelectedIds(\n selected\n ? this.selectedIds.filter(selectedId => selectedId !== row.id)\n : [...this.selectedIds, row.id],\n row.node,\n );\n }\n\n private activateRow(row: VisibleTreeNode<T>): void {\n this.activeId = row.id;\n this.fireNodeEvent('node-click', row);\n }\n\n private handleRowClick(row: VisibleTreeNode<T>, event: MouseEvent): void {\n if (this.isRowDisabled(row)) {\n event.preventDefault();\n return;\n }\n\n this.activateRow(row);\n\n if (childState(row.node) !== 'leaf') {\n this.toggleExpansion(row);\n return;\n }\n\n this.toggleSelection(row);\n }\n\n private handleTreeKeyDown = (event: KeyboardEvent): void => {\n if (event.target !== this) {\n return;\n }\n\n const rows = this.navigableRows();\n const rowIndex = rows.findIndex(row => row.id === this.activeId);\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateNext(rows, rowIndex);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigatePrevious(rows, rowIndex);\n break;\n case 'Home':\n event.preventDefault();\n this.activeId = this.getFirstNodeId();\n break;\n case 'End':\n event.preventDefault();\n this.activeId = this.getLastNodeId();\n break;\n case 'Enter': {\n const activeRow = rows[rowIndex];\n if (activeRow) {\n event.preventDefault();\n this.toggleSelection(activeRow);\n }\n break;\n }\n default:\n break;\n }\n };\n\n private handleToggleClick(row: VisibleTreeNode<T>, event: MouseEvent): void {\n event.stopPropagation();\n this.activeId = row.id;\n this.toggleExpansion(row);\n }\n\n private handleKeyDown(row: VisibleTreeNode<T>, event: KeyboardEvent): void {\n event.stopPropagation();\n const rows = this.navigableRows();\n const rowIndex = rows.findIndex(candidate => candidate.id === row.id);\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateNext(rows, rowIndex);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigatePrevious(rows, rowIndex);\n break;\n case 'Home':\n event.preventDefault();\n this.activeId = this.getFirstNodeId();\n break;\n case 'End':\n event.preventDefault();\n this.activeId = this.getLastNodeId();\n break;\n case 'ArrowRight':\n event.preventDefault();\n this.stepIn(row, rows, rowIndex);\n break;\n case 'ArrowLeft':\n event.preventDefault();\n this.stepOut(row);\n break;\n case 'Enter':\n event.preventDefault();\n this.activeId = row.id;\n this.toggleSelection(row);\n break;\n case ' ':\n event.preventDefault();\n this.toggleSelection(row);\n break;\n default:\n break;\n }\n }\n\n private navigateNext(rows: VisibleTreeNode<T>[], rowIndex: number): void {\n const nextRow = rows[rowIndex < 0 ? 0 : rowIndex + 1];\n if (!nextRow) {\n this.dispatchEvent(\n new CustomEvent('navigation-boundary', {\n detail: { direction: 'last' },\n }),\n );\n return;\n }\n\n this.activeId = nextRow.id;\n this.dispatchEvent(\n new CustomEvent('active-changed', {\n detail: { activeId: nextRow.id },\n }),\n );\n }\n\n private navigatePrevious(rows: VisibleTreeNode<T>[], rowIndex: number): void {\n const previousRow = rows[rowIndex < 0 ? rows.length - 1 : rowIndex - 1];\n if (!previousRow) {\n this.dispatchEvent(\n new CustomEvent('navigation-boundary', {\n detail: { direction: 'first' },\n }),\n );\n return;\n }\n\n this.activeId = previousRow.id;\n this.dispatchEvent(\n new CustomEvent('active-changed', {\n detail: { activeId: previousRow.id },\n }),\n );\n }\n\n private stepIn(\n row: VisibleTreeNode<T>,\n rows: VisibleTreeNode<T>[],\n rowIndex: number,\n ): void {\n const state = childState(row.node);\n if (state === 'leaf') {\n return;\n }\n\n if (!this.expandedIds.includes(row.id)) {\n this.toggleExpansion(row);\n return;\n }\n\n const nextRow = rows[rowIndex + 1];\n if (nextRow?.parentIds[nextRow.parentIds.length - 1] === row.id) {\n this.activeId = nextRow.id;\n }\n }\n\n private stepOut(row: VisibleTreeNode<T>): void {\n if (this.expandedIds.includes(row.id)) {\n this.toggleExpansion(row);\n return;\n }\n\n const parentId = row.parentIds[row.parentIds.length - 1];\n if (parentId) {\n this.activeId = parentId;\n }\n }\n\n private renderSelection(\n row: VisibleTreeNode<T>,\n ): TemplateResult | typeof nothing {\n if (this.selectionMode !== 'multiple' || !this.isRowSelectable(row)) {\n return nothing;\n }\n\n const selected = this.selectedIds.includes(row.id);\n return html`<span\n part=\"selection\"\n class=\"selection\"\n aria-hidden=\"true\"\n data-selected=${selected ? 'true' : 'false'}\n ><oscd-checkbox\n tabindex=\"-1\"\n ?checked=${selected}\n ?disabled=${this.isRowDisabled(row)}\n ></oscd-checkbox\n ></span>`;\n }\n\n private renderToggle(\n row: VisibleTreeNode<T>,\n context: TreeRenderContext<T>,\n ): TemplateResult {\n const expandable = context.childrenState !== 'leaf';\n const expanded = context.expanded;\n\n if (!expandable && this.renderLeafAccessory) {\n const accessory = this.renderLeafAccessory(context);\n if (accessory !== nothing && accessory != null && accessory !== false) {\n return html`<div\n part=\"accessory\"\n class=\"accessory\"\n @click=${(event: Event) => event.stopPropagation()}\n @keydown=${(event: KeyboardEvent) =>\n this.handleAccessoryKeydown(event)}\n >\n ${accessory}\n </div>`;\n }\n }\n\n return html`<button\n part=\"toggle\"\n class=\"toggle ${expandable ? '' : 'leaf-toggle'}\"\n ?disabled=${!expandable || context.disabled}\n aria-label=${expanded ? 'Collapse' : 'Expand'}\n tabindex=\"-1\"\n @click=${(event: MouseEvent) => this.handleToggleClick(row, event)}\n >\n ${expandable\n ? html`<oscd-icon\n >${expanded ? this.expandIcon : this.collapseIcon}</oscd-icon\n >`\n : nothing}\n </button>`;\n }\n\n // Keep Enter/Space activations of a leaf accessory (e.g. a pin button) from\n // bubbling to the row's keyboard handler; arrow keys still bubble so tree\n // navigation continues to work while an accessory is focused.\n // eslint-disable-next-line class-methods-use-this\n private handleAccessoryKeydown(event: KeyboardEvent): void {\n if (\n event.key === 'Enter' ||\n event.key === ' ' ||\n event.key === 'Spacebar'\n ) {\n event.stopPropagation();\n }\n }\n\n private renderRow(row: VisibleTreeNode<T>): TemplateResult {\n const context = this.renderContext(row);\n const state = context.childrenState;\n const selected = context.selected;\n const disabled = context.disabled;\n const active = context.active;\n\n return html`<div\n id=${row.htmlId}\n part=\"row\"\n class=\"row\"\n role=\"treeitem\"\n tabindex=${active ? '0' : '-1'}\n aria-level=${row.level}\n aria-posinset=${row.ariaPositionInSet}\n aria-setsize=${row.ariaSetSize}\n aria-label=${this.accessibleLabel(row)}\n aria-expanded=${state === 'leaf' ? nothing : context.expanded}\n aria-selected=${context.selectable ? selected : nothing}\n aria-disabled=${disabled ? 'true' : nothing}\n data-active=${active ? 'true' : 'false'}\n data-selected=${selected ? 'true' : 'false'}\n data-selection-mode=${this.selectionMode}\n data-disabled=${disabled ? 'true' : 'false'}\n style=${`--oscd-tree-row-level: ${row.level};`}\n @click=${(event: MouseEvent) => this.handleRowClick(row, event)}\n @keydown=${(event: KeyboardEvent) => this.handleKeyDown(row, event)}\n >\n <oscd-ripple for=${row.htmlId} ?disabled=${disabled}></oscd-ripple>\n <oscd-focus-ring for=${row.htmlId} inward></oscd-focus-ring>\n <span part=\"indent\" class=\"indent\" aria-hidden=\"true\"></span>\n ${this.togglePosition === 'leading'\n ? this.renderToggle(row, context)\n : nothing}\n ${this.renderSelection(row)}\n <span part=\"content\" class=\"content\"\n >${(this.renderItem ?? fallbackRenderItem)(context)}</span\n >\n ${this.togglePosition === 'trailing'\n ? this.renderToggle(row, context)\n : nothing}\n </div>`;\n }\n\n override updated(): void {\n const focusedAccessory =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement?.closest('.accessory')\n : null;\n if (focusedAccessory) {\n return;\n }\n\n const activeRow = this.renderRoot.querySelector<HTMLElement>(\n '.row[data-active=\"true\"]',\n );\n if (activeRow && this.matches(':focus-within')) {\n activeRow.focus();\n if (this.scrollActiveIntoView) {\n activeRow.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n }\n }\n\n override render(): TemplateResult {\n const rows = this.visibleRows();\n\n return html`<div part=\"tree\" class=\"tree\" role=\"tree\">\n ${rows.map(row => this.renderRow(row))}\n </div>`;\n }\n\n static override styles = css`\n :host {\n display: block;\n /*\n * Allow the tree to shrink below its content's intrinsic (max-content)\n * width when placed in a flex or grid container. Without this, a single\n * long row label leaks its max-content width up the layout chain and\n * sizes every row to it, pushing trailing toggles/accessories out of a\n * width-constrained parent and defeating the per-row ellipsis. Keeping\n * this on the host makes the tree a well-behaved flex/grid child by\n * default for every consumer.\n */\n min-width: 0;\n color: var(--oscd-tree-color, var(--md-sys-color-on-surface, #1d1b20));\n font-family: var(\n --oscd-tree-font-family,\n var(--oscd-text-font, sans-serif)\n );\n outline: none;\n /*\n * Drives both the per-level indentation and the leading icon column width\n * of each row (see OscdTreeItem). Keeping these fused means a leading icon\n * occupies exactly one indent step, so icon-less descendants align their\n * text under an iconed ancestor's text automatically. Set it large enough\n * to hold your leading icon comfortably (e.g. 40px) when using icons.\n */\n --oscd-tree-indent-step: 24px;\n --oscd-tree-toggle-size: 32px;\n --oscd-tree-toggle-icon-size: 24px;\n --oscd-tree-row-height: 44px;\n --oscd-tree-row-shape: var(--md-sys-shape-corner-small, 4px);\n --md-ripple-hover-color: var(\n --oscd-tree-row-hover-state-layer-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n --md-ripple-hover-opacity: var(\n --oscd-tree-row-hover-state-layer-opacity,\n 0.08\n );\n --md-ripple-pressed-color: var(\n --oscd-tree-row-pressed-state-layer-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n --md-ripple-pressed-opacity: var(\n --oscd-tree-row-pressed-state-layer-opacity,\n 0.12\n );\n }\n\n .tree {\n display: flex;\n flex-direction: column;\n min-width: 0;\n gap: var(--oscd-tree-row-gap, 0);\n }\n\n .row {\n position: relative;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--oscd-tree-row-height);\n border-radius: var(--oscd-tree-row-shape);\n color: inherit;\n cursor: default;\n outline: none;\n padding-inline-start: var(--oscd-tree-row-padding-start, 16px);\n padding-inline-end: var(--oscd-tree-row-padding-end, 8px);\n user-select: none;\n }\n\n :host(:focus-within) .row[data-active='true'] {\n outline: var(--oscd-tree-row-active-border-width, 1px) solid\n var(--oscd-tree-row-active-border-color, currentColor);\n outline-offset: -1px;\n color: var(--oscd-tree-row-active-text-color, inherit);\n }\n\n oscd-ripple,\n oscd-focus-ring {\n border-radius: var(--oscd-tree-row-shape);\n }\n\n oscd-focus-ring {\n z-index: 1;\n --md-focus-ring-shape: var(--oscd-tree-row-shape);\n --md-focus-ring-color: var(\n --oscd-tree-row-focus-ring-color,\n var(--md-sys-color-primary, #6750a4)\n );\n --md-focus-ring-width: var(--oscd-tree-row-focus-ring-width, 2px);\n --md-focus-ring-duration: var(--oscd-tree-row-focus-ring-duration, 0ms);\n }\n\n .row[data-disabled='true'] {\n cursor: default;\n }\n\n .row[data-selection-mode='single'][data-selected='true'] {\n color: var(--oscd-tree-row-selected-text-color, var(--oscd-base3, #fff));\n background: var(\n --oscd-tree-row-selected-color,\n var(--oscd-primary, #0b335b)\n );\n }\n\n .row[data-selection-mode='single'][data-selected='true']:hover:not(\n [data-disabled='true']\n ) {\n background: var(\n --oscd-tree-row-selected-hover-color,\n var(--oscd-tree-row-selected-color, var(--oscd-primary, #0b335b))\n );\n }\n\n .indent {\n flex: 0 0\n calc(\n max(0, var(--oscd-tree-row-level) - 1) * var(--oscd-tree-indent-step)\n );\n inline-size: calc(\n max(0, var(--oscd-tree-row-level) - 1) * var(--oscd-tree-indent-step)\n );\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-toggle-size);\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n border: 0;\n border-radius: 50%;\n padding: 0;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n\n .leaf-toggle {\n flex-basis: var(\n --oscd-tree-leaf-toggle-size,\n var(--oscd-tree-toggle-size)\n );\n inline-size: var(\n --oscd-tree-leaf-toggle-size,\n var(--oscd-tree-toggle-size)\n );\n }\n\n .toggle:disabled {\n cursor: default;\n opacity: 0;\n }\n\n :host([toggle-position='trailing']) .toggle {\n margin-inline-start: var(--oscd-tree-trailing-toggle-gap, 4px);\n }\n\n :host([toggle-position='trailing']) .leaf-toggle {\n margin-inline-start: var(\n --oscd-tree-leaf-toggle-gap,\n var(--oscd-tree-trailing-toggle-gap, 4px)\n );\n }\n\n .toggle oscd-icon {\n --md-icon-size: var(--oscd-tree-toggle-icon-size, 24px);\n }\n\n .accessory {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-toggle-size);\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n /*\n * Accessory visibility at rest. Defaults to fully opaque so accessories\n * are always shown; consumers can set --oscd-tree-accessory-rest-opacity\n * to 0 for a reveal-on-interaction pattern. Row hover and keyboard focus\n * within the accessory always force it fully visible so it stays\n * discoverable and keyboard-accessible.\n */\n opacity: var(--oscd-tree-accessory-rest-opacity, 1);\n transition: opacity 0.1s ease-in-out;\n }\n\n .row:hover .accessory,\n .accessory:focus-within {\n opacity: 1;\n }\n\n :host([toggle-position='trailing']) .accessory {\n margin-inline-start: var(--oscd-tree-trailing-toggle-gap, 4px);\n }\n\n .accessory oscd-icon {\n --md-icon-size: var(\n --oscd-tree-accessory-icon-size,\n var(--oscd-tree-toggle-icon-size, 24px)\n );\n }\n\n .accessory button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n border: 0;\n border-radius: 50%;\n padding: 0;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n\n .selection {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-selection-size, 48px);\n inline-size: var(--oscd-tree-selection-size, 48px);\n pointer-events: none;\n }\n\n .selection oscd-checkbox {\n pointer-events: none;\n --md-focus-ring-width: 0;\n --md-ripple-hover-opacity: 0;\n --md-ripple-pressed-opacity: 0;\n --md-checkbox-container-size: var(\n --oscd-tree-selection-checkbox-size,\n 18px\n );\n --md-checkbox-icon-size: var(\n --oscd-tree-selection-checkbox-icon-size,\n 18px\n );\n }\n\n .content {\n display: block;\n flex: 1 1 auto;\n min-width: 0;\n }\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../tree/internal/Tree.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACl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tC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\n\nimport { OscdCheckbox } from '../../checkbox/OscdCheckbox.js';\nimport { OscdFocusRing } from '../../focus/OscdFocusRing.js';\nimport { OscdIcon } from '../../icon/OscdIcon.js';\nimport { OscdRipple } from '../../ripple/OscdRipple.js';\nimport { OscdTreeItem } from '../OscdTreeItem.js';\n\n/**\n * Selection behavior for `oscd-tree`.\n */\nexport type TreeSelectionMode = 'none' | 'single' | 'multiple';\n\n/**\n * Placement of the expand/collapse toggle within a tree row.\n *\n * - `'leading'` renders the toggle before the row content (default).\n * - `'trailing'` renders the toggle after the row content, right-aligned so\n * the toggles line up on the trailing edge regardless of nesting depth.\n */\nexport type TreeTogglePosition = 'leading' | 'trailing';\n\n/**\n * Loaded state of a tree node's children.\n */\nexport type TreeChildrenState = 'unknown' | 'leaf' | 'branch';\n\n/**\n * Minimal data contract for nodes rendered by `oscd-tree`.\n *\n * `children === undefined` means that children are unknown or not loaded yet.\n * `children === []` means that the node is known to be a leaf.\n * A non-empty `children` array means that the node is a branch.\n */\nexport type TreeNode = {\n /**\n * Stable node identifier. If omitted, `oscd-tree` falls back to\n * `getNodeId` and then to the node's index path.\n */\n id?: string;\n\n /**\n * Child nodes when known.\n */\n children?: TreeNode[];\n};\n\n/**\n * Context passed to `renderItem` for each visible tree row.\n */\nexport type TreeRenderContext<T extends TreeNode = TreeNode> = {\n /** The original caller-provided node. */\n node: T;\n\n /** Resolved node identifier used by selection, expansion, and events. */\n id: string;\n\n /** One-based nesting level computed by the tree. */\n level: number;\n\n /** Whether this node is currently expanded. */\n expanded: boolean;\n\n /** Whether this node is currently selected. */\n selected: boolean;\n\n /** Whether this row is the active keyboard row. */\n active: boolean;\n\n /** Current child loading/branch state. */\n childrenState: TreeChildrenState;\n\n /** Whether this row can be selected. */\n selectable: boolean;\n\n /** Whether this row is disabled. */\n disabled: boolean;\n};\n\n/**\n * Detail for node-level tree events.\n */\nexport type TreeNodeEventDetail<T extends TreeNode = TreeNode> = {\n /** The original caller-provided node. */\n node: T;\n\n /** Resolved node identifier. */\n id: string;\n};\n\n/**\n * Detail for `selected-ids-changed`.\n */\nexport type TreeSelectionChangeEventDetail<T extends TreeNode = TreeNode> = {\n /** Current selected node identifiers. */\n selectedIds: string[];\n\n /** Previous selected node identifiers. */\n previousSelectedIds: string[];\n\n /** Node that triggered the selection change. */\n targetNode: T;\n};\n\ntype VisibleTreeNode<T extends TreeNode = TreeNode> = {\n node: T;\n id: string;\n htmlId: string;\n level: number;\n parentIds: string[];\n ariaPositionInSet: number;\n ariaSetSize: number;\n};\n\nconst fallbackRenderItem = <T extends TreeNode>({\n node,\n id,\n selected,\n active,\n disabled,\n}: TreeRenderContext<T>): TemplateResult =>\n html`<oscd-tree-item\n ?selected=${selected}\n ?active=${active}\n ?disabled=${disabled}\n >\n <span slot=\"headline\">${'label' in node ? String(node.label) : id}</span>\n </oscd-tree-item>`;\n\nconst idSeparator = '/';\n\nfunction childState(node: TreeNode): TreeChildrenState {\n if (node.children === undefined) {\n return 'unknown';\n }\n\n return node.children.length > 0 ? 'branch' : 'leaf';\n}\n\n/**\n * Internal base class for `oscd-tree`.\n */\nexport class Tree<T extends TreeNode = TreeNode> extends ScopedElementsMixin(\n LitElement,\n) {\n static scopedElements = {\n 'oscd-checkbox': OscdCheckbox,\n 'oscd-focus-ring': OscdFocusRing,\n 'oscd-icon': OscdIcon,\n 'oscd-ripple': OscdRipple,\n 'oscd-tree-item': OscdTreeItem,\n };\n\n /**\n * Structured tree data to render.\n */\n @property({ attribute: false })\n data: T[] = [];\n\n /**\n * Selected node identifiers.\n *\n * This state is controlled by the caller and may be persisted outside the\n * tree, but it must be scoped to the data set/context that produced the IDs.\n * Reset or re-key persisted selected IDs when `data` changes to a different\n * logical tree, otherwise unrelated nodes with matching IDs may appear\n * selected.\n */\n @property({ attribute: false })\n selectedIds: string[] = [];\n\n /**\n * Expanded node identifiers.\n *\n * This state is controlled by the caller and may be persisted outside the\n * tree, but it must be scoped to the data set/context that produced the IDs.\n * Reset or re-key persisted expanded IDs when `data` changes to a different\n * logical tree, otherwise unrelated nodes with matching IDs may appear\n * expanded.\n */\n @property({ attribute: false })\n expandedIds: string[] = [];\n\n /**\n * Renders caller-provided content for a tree row.\n *\n * The tree owns the row frame, indentation, toggle affordance, selection\n * affordance, keyboard handling, and ARIA attributes. This callback renders\n * the content inside that frame.\n */\n @property({ attribute: false })\n renderItem?: (context: TreeRenderContext<T>) => TemplateResult;\n\n /**\n * Renders an interactive accessory into the toggle column of a **leaf** row.\n *\n * Leaf rows have no expand/collapse toggle, so this callback can supply\n * trailing content (for example a pin/unpin button) that lines up exactly\n * with the chevrons of expandable rows, following `togglePosition`.\n *\n * Return `nothing` (or a falsy value) to leave the leaf's toggle column\n * empty. The tree isolates pointer and `Enter`/`Space` interaction on the\n * accessory so activating it does not select or toggle the row; arrow-key\n * navigation still works. Any returned interactive element (such as a\n * `<button>`) is keyboard-focusable and therefore adds a tab stop per row.\n * Provide an accessible label and `aria-pressed` for toggle semantics.\n */\n @property({ attribute: false })\n renderLeafAccessory?: (context: TreeRenderContext<T>) => unknown;\n\n /**\n * Resolves a stable node identifier when `node.id` is not provided.\n *\n * If neither `node.id` nor this callback is available, the tree falls back to\n * an index-path ID. Index-path IDs are convenient for static examples but are\n * not stable when rows are inserted, removed, sorted, filtered, or lazily\n * loaded, and should not be persisted.\n */\n @property({ attribute: false })\n getNodeId?: (node: T, indexPath: number[]) => string;\n\n /**\n * Resolves the accessible label for a node row.\n *\n * If omitted, the tree uses `node.label` when present, then the resolved node\n * ID. This label is applied to the row frame that owns `role=\"treeitem\"`.\n */\n @property({ attribute: false })\n getNodeLabel?: (node: T, id: string) => string;\n\n /**\n * Returns whether a node can be selected.\n */\n @property({ attribute: false })\n isSelectable?: (node: T) => boolean;\n\n /**\n * Returns whether a node is disabled.\n */\n @property({ attribute: false })\n isDisabled?: (node: T) => boolean;\n\n /**\n * Selection behavior.\n */\n @property()\n selectionMode: TreeSelectionMode = 'none';\n\n /**\n * Icon shown on the expand/collapse toggle when a branch is collapsed.\n *\n * Any icon name understood by `oscd-icon` (a Material Symbol name or a\n * registered SCL icon) may be used. Defaults to `chevron_right`.\n */\n @property({ attribute: 'collapse-icon' })\n collapseIcon = 'chevron_right';\n\n /**\n * Icon shown on the expand/collapse toggle when a branch is expanded.\n *\n * Any icon name understood by `oscd-icon` (a Material Symbol name or a\n * registered SCL icon) may be used. Defaults to `expand_more`.\n */\n @property({ attribute: 'expand-icon' })\n expandIcon = 'expand_more';\n\n /**\n * Placement of the expand/collapse toggle within each row.\n *\n * `'leading'` (default) renders the toggle before the row content.\n * `'trailing'` renders it after the content, right-aligned so the toggles\n * line up on the trailing edge regardless of nesting depth. Keyboard\n * expansion (`ArrowRight`/`ArrowLeft`) is unaffected by this option.\n */\n @property({ reflect: true, attribute: 'toggle-position' })\n togglePosition: TreeTogglePosition = 'leading';\n\n /** Currently active keyboard row. Controlled by the caller when needed. */\n @property({ attribute: false })\n activeId: string | null = null;\n\n /**\n * Whether focusing the active row should scroll it into the nearest\n * scrollable ancestor when it is outside the visible area.\n */\n @property({ type: Boolean, attribute: 'scroll-active-into-view' })\n scrollActiveIntoView = true;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.tabIndex = 0;\n this.addEventListener('keydown', this.handleTreeKeyDown);\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('keydown', this.handleTreeKeyDown);\n super.disconnectedCallback();\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n if (!changedProperties.has('activeId') || this.activeId === null) {\n return;\n }\n\n const isNavigable = this.navigableRows().some(\n row => row.id === this.activeId,\n );\n if (!isNavigable) {\n console.warn(`Ignoring invalid oscd-tree activeId: ${this.activeId}`);\n this.activeId = changedProperties.get('activeId') ?? null;\n }\n }\n\n /** Returns the first visible, enabled row ID, or null when none exists. */\n public getFirstNodeId(): string | null {\n return this.navigableRows()[0]?.id ?? null;\n }\n\n /** Returns the last visible, enabled row ID, or null when none exists. */\n public getLastNodeId(): string | null {\n const rows = this.navigableRows();\n return rows[rows.length - 1]?.id ?? null;\n }\n\n /**\n * Expands a node by ID.\n */\n public expand(id: string): void {\n if (!this.expandedIds.includes(id)) {\n this.setExpandedIds([...this.expandedIds, id]);\n }\n }\n\n /**\n * Collapses a node by ID.\n */\n public collapse(id: string): void {\n if (this.expandedIds.includes(id)) {\n this.setExpandedIds(\n this.expandedIds.filter(expandedId => expandedId !== id),\n );\n }\n }\n\n /**\n * Toggles a node expansion state by ID.\n */\n public toggle(id: string): void {\n const row = this.visibleRows().find(candidate => candidate.id === id);\n if (!row) {\n return;\n }\n\n this.toggleExpansion(row);\n }\n\n private rowId(node: T, indexPath: number[]): string {\n return (\n node.id ??\n this.getNodeId?.(node, indexPath) ??\n indexPath.join(idSeparator)\n );\n }\n\n private visibleRows(): VisibleTreeNode<T>[] {\n const expandedIds = new Set(this.expandedIds);\n const rows: VisibleTreeNode<T>[] = [];\n\n const walk = (\n nodes: T[] | undefined,\n level: number,\n parentIds: string[],\n indexPath: number[],\n ) => {\n if (!nodes) {\n return;\n }\n\n const ariaSetSize = nodes.length;\n nodes.forEach((node, index) => {\n const childIndexPath = [...indexPath, index];\n const id = this.rowId(node, childIndexPath);\n rows.push({\n node,\n id,\n htmlId: `tree-row-${rows.length}`,\n level,\n parentIds,\n ariaPositionInSet: index + 1,\n ariaSetSize,\n });\n\n if (expandedIds.has(id) && node.children) {\n walk(\n node.children as T[],\n level + 1,\n [...parentIds, id],\n childIndexPath,\n );\n }\n });\n };\n\n walk(this.data, 1, [], []);\n\n return rows;\n }\n\n private navigableRows(): VisibleTreeNode<T>[] {\n return this.visibleRows().filter(row => !this.isRowDisabled(row));\n }\n\n private renderContext(row: VisibleTreeNode<T>): TreeRenderContext<T> {\n const selected = this.selectedIds.includes(row.id);\n\n return {\n node: row.node,\n id: row.id,\n level: row.level,\n expanded: this.expandedIds.includes(row.id),\n selected,\n active: this.activeId === row.id,\n childrenState: childState(row.node),\n selectable: this.selectionMode !== 'none' && this.isRowSelectable(row),\n disabled: this.isRowDisabled(row),\n };\n }\n\n private accessibleLabel(row: VisibleTreeNode<T>): string {\n if (this.getNodeLabel) {\n return this.getNodeLabel(row.node, row.id);\n }\n\n if ('label' in row.node && row.node.label !== undefined) {\n return String(row.node.label);\n }\n\n return row.id;\n }\n\n private isRowSelectable(row: VisibleTreeNode<T>): boolean {\n return this.isSelectable ? this.isSelectable(row.node) : true;\n }\n\n private isRowDisabled(row: VisibleTreeNode<T>): boolean {\n return this.isDisabled ? this.isDisabled(row.node) : false;\n }\n\n private setExpandedIds(expandedIds: string[]): void {\n this.expandedIds = expandedIds;\n this.dispatchEvent(\n new CustomEvent('expanded-ids-changed', {\n detail: { expandedIds },\n }),\n );\n }\n\n private setSelectedIds(selectedIds: string[], targetNode: T): void {\n const previousSelectedIds = this.selectedIds;\n this.selectedIds = selectedIds;\n this.dispatchEvent(\n new CustomEvent<TreeSelectionChangeEventDetail<T>>(\n 'selected-ids-changed',\n {\n detail: {\n selectedIds,\n previousSelectedIds,\n targetNode,\n },\n },\n ),\n );\n }\n\n private fireNodeEvent(\n name: string,\n row: VisibleTreeNode<T>,\n options?: { cancelable?: boolean },\n ): boolean {\n const event = new CustomEvent<TreeNodeEventDetail<T>>(name, {\n bubbles: true,\n cancelable: options?.cancelable ?? false,\n detail: {\n node: row.node,\n id: row.id,\n },\n });\n\n return this.dispatchEvent(event);\n }\n\n private toggleExpansion(row: VisibleTreeNode<T>): void {\n if (this.isRowDisabled(row) || childState(row.node) === 'leaf') {\n return;\n }\n\n const expanded = this.expandedIds.includes(row.id);\n if (expanded) {\n this.setExpandedIds(\n this.expandedIds.filter(expandedId => expandedId !== row.id),\n );\n this.fireNodeEvent('node-collapse', row);\n this.fireNodeEvent('node-toggle', row);\n return;\n }\n\n if (!this.fireNodeEvent('node-expand', row, { cancelable: true })) {\n return;\n }\n\n this.setExpandedIds([...this.expandedIds, row.id]);\n this.fireNodeEvent('node-toggle', row);\n }\n\n private toggleSelection(row: VisibleTreeNode<T>): void {\n if (\n this.selectionMode === 'none' ||\n this.isRowDisabled(row) ||\n !this.isRowSelectable(row)\n ) {\n return;\n }\n\n if (this.selectionMode === 'single') {\n this.setSelectedIds([row.id], row.node);\n return;\n }\n\n const selected = this.selectedIds.includes(row.id);\n this.setSelectedIds(\n selected\n ? this.selectedIds.filter(selectedId => selectedId !== row.id)\n : [...this.selectedIds, row.id],\n row.node,\n );\n }\n\n private activateRow(row: VisibleTreeNode<T>): void {\n this.activeId = row.id;\n this.fireNodeEvent('node-click', row);\n }\n\n private handleRowClick(row: VisibleTreeNode<T>, event: MouseEvent): void {\n if (this.isRowDisabled(row)) {\n event.preventDefault();\n return;\n }\n\n this.activateRow(row);\n\n if (childState(row.node) !== 'leaf') {\n this.toggleExpansion(row);\n return;\n }\n\n this.toggleSelection(row);\n }\n\n private handleTreeKeyDown = (event: KeyboardEvent): void => {\n if (event.target !== this) {\n return;\n }\n\n const rows = this.navigableRows();\n const rowIndex = rows.findIndex(row => row.id === this.activeId);\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateNext(rows, rowIndex);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigatePrevious(rows, rowIndex);\n break;\n case 'Home':\n event.preventDefault();\n this.activeId = this.getFirstNodeId();\n break;\n case 'End':\n event.preventDefault();\n this.activeId = this.getLastNodeId();\n break;\n case 'Enter': {\n const activeRow = rows[rowIndex];\n if (activeRow) {\n event.preventDefault();\n this.toggleSelection(activeRow);\n }\n break;\n }\n default:\n break;\n }\n };\n\n private handleToggleClick(row: VisibleTreeNode<T>, event: MouseEvent): void {\n event.stopPropagation();\n this.activeId = row.id;\n this.toggleExpansion(row);\n }\n\n private handleKeyDown(row: VisibleTreeNode<T>, event: KeyboardEvent): void {\n event.stopPropagation();\n const rows = this.navigableRows();\n const rowIndex = rows.findIndex(candidate => candidate.id === row.id);\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateNext(rows, rowIndex);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigatePrevious(rows, rowIndex);\n break;\n case 'Home':\n event.preventDefault();\n this.activeId = this.getFirstNodeId();\n break;\n case 'End':\n event.preventDefault();\n this.activeId = this.getLastNodeId();\n break;\n case 'ArrowRight':\n event.preventDefault();\n this.stepIn(row, rows, rowIndex);\n break;\n case 'ArrowLeft':\n event.preventDefault();\n this.stepOut(row);\n break;\n case 'Enter':\n event.preventDefault();\n this.activeId = row.id;\n this.toggleSelection(row);\n break;\n case ' ':\n event.preventDefault();\n this.toggleSelection(row);\n break;\n default:\n break;\n }\n }\n\n private navigateNext(rows: VisibleTreeNode<T>[], rowIndex: number): void {\n const nextRow = rows[rowIndex < 0 ? 0 : rowIndex + 1];\n if (!nextRow) {\n this.dispatchEvent(\n new CustomEvent('navigation-boundary', {\n detail: { direction: 'last' },\n }),\n );\n return;\n }\n\n this.activeId = nextRow.id;\n this.dispatchEvent(\n new CustomEvent('active-changed', {\n detail: { activeId: nextRow.id },\n }),\n );\n }\n\n private navigatePrevious(rows: VisibleTreeNode<T>[], rowIndex: number): void {\n const previousRow = rows[rowIndex < 0 ? rows.length - 1 : rowIndex - 1];\n if (!previousRow) {\n this.dispatchEvent(\n new CustomEvent('navigation-boundary', {\n detail: { direction: 'first' },\n }),\n );\n return;\n }\n\n this.activeId = previousRow.id;\n this.dispatchEvent(\n new CustomEvent('active-changed', {\n detail: { activeId: previousRow.id },\n }),\n );\n }\n\n private stepIn(\n row: VisibleTreeNode<T>,\n rows: VisibleTreeNode<T>[],\n rowIndex: number,\n ): void {\n const state = childState(row.node);\n if (state === 'leaf') {\n return;\n }\n\n if (!this.expandedIds.includes(row.id)) {\n this.toggleExpansion(row);\n return;\n }\n\n const nextRow = rows[rowIndex + 1];\n if (nextRow?.parentIds[nextRow.parentIds.length - 1] === row.id) {\n this.activeId = nextRow.id;\n }\n }\n\n private stepOut(row: VisibleTreeNode<T>): void {\n if (this.expandedIds.includes(row.id)) {\n this.toggleExpansion(row);\n return;\n }\n\n const parentId = row.parentIds[row.parentIds.length - 1];\n if (parentId) {\n this.activeId = parentId;\n }\n }\n\n private renderSelection(\n row: VisibleTreeNode<T>,\n ): TemplateResult | typeof nothing {\n if (this.selectionMode !== 'multiple' || !this.isRowSelectable(row)) {\n return nothing;\n }\n\n const selected = this.selectedIds.includes(row.id);\n return html`<span\n part=\"selection\"\n class=\"selection\"\n aria-hidden=\"true\"\n data-selected=${selected ? 'true' : 'false'}\n ><oscd-checkbox\n tabindex=\"-1\"\n ?checked=${selected}\n ?disabled=${this.isRowDisabled(row)}\n ></oscd-checkbox\n ></span>`;\n }\n\n private renderToggle(\n row: VisibleTreeNode<T>,\n context: TreeRenderContext<T>,\n ): TemplateResult {\n const expandable = context.childrenState !== 'leaf';\n const expanded = context.expanded;\n\n if (!expandable && this.renderLeafAccessory) {\n const accessory = this.renderLeafAccessory(context);\n if (accessory !== nothing && accessory != null && accessory !== false) {\n return html`<div\n part=\"accessory\"\n class=\"accessory\"\n @click=${(event: Event) => event.stopPropagation()}\n @keydown=${(event: KeyboardEvent) =>\n this.handleAccessoryKeydown(event)}\n >\n ${accessory}\n </div>`;\n }\n }\n\n return html`<button\n part=\"toggle\"\n class=\"toggle ${expandable ? '' : 'leaf-toggle'}\"\n ?disabled=${!expandable || context.disabled}\n aria-label=${expanded ? 'Collapse' : 'Expand'}\n tabindex=\"-1\"\n @click=${(event: MouseEvent) => this.handleToggleClick(row, event)}\n >\n ${expandable\n ? html`<oscd-icon\n >${expanded ? this.expandIcon : this.collapseIcon}</oscd-icon\n >`\n : nothing}\n </button>`;\n }\n\n // Keep Enter/Space activations of a leaf accessory (e.g. a pin button) from\n // bubbling to the row's keyboard handler; arrow keys still bubble so tree\n // navigation continues to work while an accessory is focused.\n // eslint-disable-next-line class-methods-use-this\n private handleAccessoryKeydown(event: KeyboardEvent): void {\n if (\n event.key === 'Enter' ||\n event.key === ' ' ||\n event.key === 'Spacebar'\n ) {\n event.stopPropagation();\n }\n }\n\n private renderRow(row: VisibleTreeNode<T>): TemplateResult {\n const context = this.renderContext(row);\n const state = context.childrenState;\n const selected = context.selected;\n const disabled = context.disabled;\n const active = context.active;\n\n return html`<div\n id=${row.htmlId}\n part=\"row\"\n class=\"row\"\n role=\"treeitem\"\n tabindex=${active ? '0' : '-1'}\n aria-level=${row.level}\n aria-posinset=${row.ariaPositionInSet}\n aria-setsize=${row.ariaSetSize}\n aria-label=${this.accessibleLabel(row)}\n aria-expanded=${state === 'leaf' ? nothing : context.expanded}\n aria-selected=${context.selectable ? selected : nothing}\n aria-disabled=${disabled ? 'true' : nothing}\n data-active=${active ? 'true' : 'false'}\n data-selected=${selected ? 'true' : 'false'}\n data-selection-mode=${this.selectionMode}\n data-disabled=${disabled ? 'true' : 'false'}\n style=${`--oscd-tree-row-level: ${row.level};`}\n @click=${(event: MouseEvent) => this.handleRowClick(row, event)}\n @keydown=${(event: KeyboardEvent) => this.handleKeyDown(row, event)}\n >\n <oscd-ripple for=${row.htmlId} ?disabled=${disabled}></oscd-ripple>\n <oscd-focus-ring for=${row.htmlId} inward></oscd-focus-ring>\n <span part=\"indent\" class=\"indent\" aria-hidden=\"true\"></span>\n ${this.togglePosition === 'leading'\n ? this.renderToggle(row, context)\n : nothing}\n ${this.renderSelection(row)}\n <span part=\"content\" class=\"content\"\n >${(this.renderItem ?? fallbackRenderItem)(context)}</span\n >\n ${this.togglePosition === 'trailing'\n ? this.renderToggle(row, context)\n : nothing}\n </div>`;\n }\n\n override updated(): void {\n const focusedAccessory =\n this.renderRoot instanceof ShadowRoot\n ? this.renderRoot.activeElement?.closest('.accessory')\n : null;\n if (focusedAccessory) {\n return;\n }\n\n const activeRow = this.renderRoot.querySelector<HTMLElement>(\n '.row[data-active=\"true\"]',\n );\n if (activeRow && this.matches(':focus-within')) {\n activeRow.focus();\n if (this.scrollActiveIntoView) {\n activeRow.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n }\n }\n\n override render(): TemplateResult {\n const rows = this.visibleRows();\n\n return html`<div part=\"tree\" class=\"tree\" role=\"tree\">\n ${rows.map(row => this.renderRow(row))}\n </div>`;\n }\n\n static override styles = css`\n :host {\n display: block;\n /*\n * Allow the tree to shrink below its content's intrinsic (max-content)\n * width when placed in a flex or grid container. Without this, a single\n * long row label leaks its max-content width up the layout chain and\n * sizes every row to it, pushing trailing toggles/accessories out of a\n * width-constrained parent and defeating the per-row ellipsis. Keeping\n * this on the host makes the tree a well-behaved flex/grid child by\n * default for every consumer.\n */\n min-width: 0;\n color: var(--oscd-tree-color, var(--md-sys-color-on-surface, #1d1b20));\n font-family: var(\n --oscd-tree-font-family,\n var(--md-sys-typescale-body-large-font, Roboto)\n );\n outline: none;\n /*\n * Drives both the per-level indentation and the leading icon column width\n * of each row (see OscdTreeItem). Keeping these fused means a leading icon\n * occupies exactly one indent step, so icon-less descendants align their\n * text under an iconed ancestor's text automatically. Set it large enough\n * to hold your leading icon comfortably (e.g. 40px) when using icons.\n */\n --oscd-tree-indent-step: 24px;\n --oscd-tree-toggle-size: 32px;\n --oscd-tree-toggle-icon-size: 24px;\n --oscd-tree-row-height: 44px;\n --oscd-tree-row-shape: var(--md-sys-shape-corner-small, 4px);\n --md-ripple-hover-color: var(\n --oscd-tree-row-hover-state-layer-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n --md-ripple-hover-opacity: var(\n --oscd-tree-row-hover-state-layer-opacity,\n 0.08\n );\n --md-ripple-pressed-color: var(\n --oscd-tree-row-pressed-state-layer-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n --md-ripple-pressed-opacity: var(\n --oscd-tree-row-pressed-state-layer-opacity,\n 0.12\n );\n }\n\n .tree {\n display: flex;\n flex-direction: column;\n min-width: 0;\n gap: var(--oscd-tree-row-gap, 0);\n }\n\n .row {\n position: relative;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-width: 0;\n min-height: var(--oscd-tree-row-height);\n border-radius: var(--oscd-tree-row-shape);\n color: inherit;\n cursor: default;\n outline: none;\n padding-inline-start: var(--oscd-tree-row-padding-start, 16px);\n padding-inline-end: var(--oscd-tree-row-padding-end, 8px);\n user-select: none;\n }\n\n :host(:focus-within) .row[data-active='true'] {\n outline: var(--oscd-tree-row-active-border-width, 1px) solid\n var(--oscd-tree-row-active-border-color, currentColor);\n outline-offset: -1px;\n color: var(--oscd-tree-row-active-text-color, inherit);\n }\n\n oscd-ripple,\n oscd-focus-ring {\n border-radius: var(--oscd-tree-row-shape);\n }\n\n oscd-focus-ring {\n z-index: 1;\n --md-focus-ring-shape: var(--oscd-tree-row-shape);\n --md-focus-ring-color: var(\n --oscd-tree-row-focus-ring-color,\n var(--md-sys-color-primary, #6750a4)\n );\n --md-focus-ring-width: var(--oscd-tree-row-focus-ring-width, 2px);\n --md-focus-ring-duration: var(--oscd-tree-row-focus-ring-duration, 0ms);\n }\n\n .row[data-disabled='true'] {\n cursor: default;\n }\n\n .row[data-selection-mode='single'][data-selected='true'] {\n color: var(\n --oscd-tree-row-selected-text-color,\n var(--md-sys-color-on-primary, #fff)\n );\n background: var(\n --oscd-tree-row-selected-color,\n var(--md-sys-color-primary, #6750a4)\n );\n }\n\n .row[data-selection-mode='single'][data-selected='true']:hover:not(\n [data-disabled='true']\n ) {\n background: var(\n --oscd-tree-row-selected-hover-color,\n var(\n --oscd-tree-row-selected-color,\n var(--md-sys-color-primary, #6750a4)\n )\n );\n }\n\n /*\n * When a selected row is also the keyboard-active row while the tree has\n * focus, the \":host(:focus-within) .row[data-active='true']\" rule above\n * has higher specificity than the selected-row rule and would otherwise\n * win the cascade for \"color\", overriding the selected text color with\n * \"inherit\" while leaving the selected background untouched. Restate the\n * selected text color here, at higher specificity than both rules, so a\n * focused+selected row keeps its selected-background/selected-foreground\n * pairing while still showing the active outline.\n */\n :host(:focus-within)\n .row[data-selection-mode='single'][data-selected='true'][data-active='true'] {\n color: var(\n --oscd-tree-row-selected-text-color,\n var(--md-sys-color-on-primary, #fff)\n );\n }\n\n .indent {\n flex: 0 0\n calc(\n max(0, var(--oscd-tree-row-level) - 1) * var(--oscd-tree-indent-step)\n );\n inline-size: calc(\n max(0, var(--oscd-tree-row-level) - 1) * var(--oscd-tree-indent-step)\n );\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-toggle-size);\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n border: 0;\n border-radius: 50%;\n padding: 0;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n\n .leaf-toggle {\n flex-basis: var(\n --oscd-tree-leaf-toggle-size,\n var(--oscd-tree-toggle-size)\n );\n inline-size: var(\n --oscd-tree-leaf-toggle-size,\n var(--oscd-tree-toggle-size)\n );\n }\n\n .toggle:disabled {\n cursor: default;\n opacity: 0;\n }\n\n :host([toggle-position='trailing']) .toggle {\n margin-inline-start: var(--oscd-tree-trailing-toggle-gap, 4px);\n }\n\n :host([toggle-position='trailing']) .leaf-toggle {\n margin-inline-start: var(\n --oscd-tree-leaf-toggle-gap,\n var(--oscd-tree-trailing-toggle-gap, 4px)\n );\n }\n\n .toggle oscd-icon {\n --md-icon-size: var(--oscd-tree-toggle-icon-size, 24px);\n }\n\n .accessory {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-toggle-size);\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n /*\n * Accessory visibility at rest. Defaults to fully opaque so accessories\n * are always shown; consumers can set --oscd-tree-accessory-rest-opacity\n * to 0 for a reveal-on-interaction pattern. Row hover and keyboard focus\n * within the accessory always force it fully visible so it stays\n * discoverable and keyboard-accessible.\n */\n opacity: var(--oscd-tree-accessory-rest-opacity, 1);\n transition: opacity 0.1s ease-in-out;\n }\n\n .row:hover .accessory,\n .accessory:focus-within {\n opacity: 1;\n }\n\n :host([toggle-position='trailing']) .accessory {\n margin-inline-start: var(--oscd-tree-trailing-toggle-gap, 4px);\n }\n\n .accessory oscd-icon {\n --md-icon-size: var(\n --oscd-tree-accessory-icon-size,\n var(--oscd-tree-toggle-icon-size, 24px)\n );\n }\n\n .accessory button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: var(--oscd-tree-toggle-size);\n block-size: var(--oscd-tree-toggle-size);\n border: 0;\n border-radius: 50%;\n padding: 0;\n color: inherit;\n background: transparent;\n cursor: pointer;\n }\n\n .selection {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--oscd-tree-selection-size, 48px);\n inline-size: var(--oscd-tree-selection-size, 48px);\n pointer-events: none;\n }\n\n .selection oscd-checkbox {\n pointer-events: none;\n --md-focus-ring-width: 0;\n --md-ripple-hover-opacity: 0;\n --md-ripple-pressed-opacity: 0;\n --md-checkbox-container-size: var(\n --oscd-tree-selection-checkbox-size,\n 18px\n );\n --md-checkbox-icon-size: var(\n --oscd-tree-selection-checkbox-icon-size,\n 18px\n );\n }\n\n .content {\n display: block;\n flex: 1 1 auto;\n min-width: 0;\n }\n `;\n}\n"]}
|
|
@@ -91,10 +91,7 @@ TreeItem.styles = css `
|
|
|
91
91
|
--oscd-tree-item-font-family,
|
|
92
92
|
var(
|
|
93
93
|
--md-list-item-label-text-font,
|
|
94
|
-
var(
|
|
95
|
-
--md-sys-typescale-body-large-font,
|
|
96
|
-
var(--oscd-text-font, sans-serif)
|
|
97
|
-
)
|
|
94
|
+
var(--md-sys-typescale-body-large-font, Roboto)
|
|
98
95
|
)
|
|
99
96
|
);
|
|
100
97
|
font-size: var(
|
|
@@ -111,12 +108,16 @@ TreeItem.styles = css `
|
|
|
111
108
|
}
|
|
112
109
|
|
|
113
110
|
:host([selected]) .headline {
|
|
111
|
+
/*
|
|
112
|
+
* Falls back to currentColor (like the resting ".headline" rule below)
|
|
113
|
+
* rather than a fixed on-surface ink, so the label tracks whatever
|
|
114
|
+
* "color" the containing row already resolved to for its selected
|
|
115
|
+
* state (e.g. Tree.js's selected/active row rules), instead of
|
|
116
|
+
* silently overriding it with an unrelated fixed color.
|
|
117
|
+
*/
|
|
114
118
|
color: var(
|
|
115
119
|
--oscd-tree-item-selected-headline-color,
|
|
116
|
-
var(
|
|
117
|
-
--md-list-item-label-text-color,
|
|
118
|
-
var(--md-sys-color-on-surface, #1d1b20)
|
|
119
|
-
)
|
|
120
|
+
var(--md-list-item-label-text-color, currentColor)
|
|
120
121
|
);
|
|
121
122
|
font-weight: var(
|
|
122
123
|
--oscd-tree-item-selected-headline-weight,
|
|
@@ -124,6 +125,19 @@ TreeItem.styles = css `
|
|
|
124
125
|
);
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
/*
|
|
129
|
+
* Like the selected headline rule above, falls back to currentColor so
|
|
130
|
+
* the supporting text also tracks the row's selected-state color instead
|
|
131
|
+
* of staying pinned to the resting on-surface-variant grey (which has
|
|
132
|
+
* poor contrast once the row's background switches to a selected color).
|
|
133
|
+
*/
|
|
134
|
+
:host([selected]) .supporting-text {
|
|
135
|
+
color: var(
|
|
136
|
+
--oscd-tree-item-selected-supporting-text-color,
|
|
137
|
+
var(--md-list-item-supporting-text-color, currentColor)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
127
141
|
.content {
|
|
128
142
|
display: flex;
|
|
129
143
|
align-items: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeItem.js","sourceRoot":"","sources":["../../../tree/internal/TreeItem.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QACE;;W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C5B;AAMf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC1B;AAOT;IADP,KAAK,EAAE;mDAC0B","sourcesContent":["import { css, html, LitElement, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\n/**\n * Internal base class for `oscd-tree-item`.\n *\n * ## Leading icon alignment\n *\n * A leading icon (the `start` slot) is rendered inside a fixed-width leading\n * column whose size defaults to the tree's `--oscd-tree-indent-step`. This is\n * deliberate: it makes a leading icon occupy **exactly one indent step**, so an\n * icon-less descendant — which the tree indents by one step per level — lands\n * its text precisely under its iconed ancestor's text, at any depth, with no\n * per-row tuning. Rows without a leading icon collapse the column to zero and\n * rely on the tree's indentation instead.\n *\n * Because the leading column and the indent step are fused, a single knob\n * (`--oscd-tree-indent-step`) controls both per-level indentation and the\n * leading icon column, and the two can never drift out of alignment. Set it\n * large enough to comfortably hold the icon (e.g. `40px`); the visual gap\n * between the icon and the text is the leftover space, `step - icon size`.\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 */\nexport class TreeItem extends LitElement {\n /**\n * Whether the row content should render selected styling.\n */\n @property({ type: Boolean, reflect: true })\n selected = false;\n\n /**\n * Whether the row content represents the active tree row.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * Whether the row content should render disabled styling.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Whether the `start` slot currently holds a leading icon. Drives the\n * fixed-width leading column so icon-less rows collapse it to zero.\n */\n @state()\n private hasLeadingContent = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Set the initial state synchronously from light-DOM children so the\n // first render already has the correct leading-column width — the\n // `slotchange` event only fires post-render and races the first paint,\n // letting an unclipped icon spill into `.text` for one frame.\n this.hasLeadingContent = this.querySelector('[slot=\"start\"]') !== null;\n }\n\n private handleStartSlotChange(event: Event): void {\n // Keeps state correct if `start`'s content changes after connect (e.g. a\n // reused row whose `renderItem` conditionally adds/removes an icon).\n this.hasLeadingContent =\n (event.target as HTMLSlotElement).assignedElements({ flatten: true })\n .length > 0;\n }\n\n override render(): TemplateResult {\n return html`<div part=\"content\" class=\"content\">\n <span\n part=\"leading\"\n class=\"leading ${this.hasLeadingContent ? 'has-leading' : ''}\"\n >\n <slot name=\"start\" @slotchange=${this.handleStartSlotChange}></slot>\n </span>\n <span part=\"text\" class=\"text\">\n <span part=\"headline\" class=\"headline\"\n ><slot name=\"headline\"></slot\n ></span>\n <span part=\"supporting-text\" class=\"supporting-text\"\n ><slot name=\"supporting-text\"></slot\n ></span>\n </span>\n <slot name=\"end\"></slot>\n </div>`;\n }\n\n static override styles = css`\n :host {\n box-sizing: border-box;\n display: block;\n min-width: 0;\n color: inherit;\n font-family: var(\n --oscd-tree-item-font-family,\n var(\n --md-list-item-label-text-font,\n var(\n --md-sys-typescale-body-large-font,\n var(--oscd-text-font, sans-serif)\n )\n )\n );\n font-size: var(\n --oscd-tree-item-font-size,\n var(--md-list-item-label-text-size, 1rem)\n );\n }\n\n :host([disabled]) {\n opacity: var(\n --oscd-tree-item-disabled-opacity,\n var(--md-list-item-disabled-opacity, 0.3)\n );\n }\n\n :host([selected]) .headline {\n color: var(\n --oscd-tree-item-selected-headline-color,\n var(\n --md-list-item-label-text-color,\n var(--md-sys-color-on-surface, #1d1b20)\n )\n );\n font-weight: var(\n --oscd-tree-item-selected-headline-weight,\n var(--md-sys-typescale-body-large-weight-prominent, 500)\n );\n }\n\n .content {\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-width: 0;\n min-height: var(\n --oscd-tree-item-min-height,\n var(--md-list-item-one-line-container-height, 56px)\n );\n width: 100%;\n }\n\n /*\n * Leading icon column. A leading icon occupies exactly one indent step so\n * that icon-less descendants (indented one step per level by the tree)\n * align their text under an iconed ancestor's text at any depth. Rows\n * without a leading icon collapse this column to zero and rely on the\n * tree's indentation instead. Override --oscd-tree-item-leading-size only\n * if you must decouple it from --oscd-tree-indent-step; keeping them equal\n * is what preserves the alignment.\n */\n .leading {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n flex: 0 0 auto;\n inline-size: 0;\n }\n\n .leading.has-leading {\n inline-size: var(\n --oscd-tree-item-leading-size,\n var(--oscd-tree-indent-step, 24px)\n );\n }\n\n .text {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n justify-content: center;\n min-width: 0;\n }\n\n .headline,\n .supporting-text {\n display: block;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .headline {\n color: var(\n --oscd-tree-item-headline-color,\n var(--md-list-item-label-text-color, currentColor)\n );\n font-family: var(\n --oscd-tree-item-headline-font,\n var(--md-list-item-label-text-font, inherit)\n );\n font-size: var(\n --oscd-tree-item-headline-size,\n var(--md-list-item-label-text-size, 1rem)\n );\n font-weight: var(\n --oscd-tree-item-headline-weight,\n var(--md-list-item-label-text-weight, 400)\n );\n line-height: var(\n --oscd-tree-item-headline-line-height,\n var(--md-list-item-label-text-line-height, 1.5rem)\n );\n }\n\n .supporting-text {\n color: var(\n --oscd-tree-item-supporting-text-color,\n var(\n --md-list-item-supporting-text-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n font-family: var(\n --oscd-tree-item-supporting-text-font,\n var(--md-list-item-supporting-text-font, inherit)\n );\n font-size: var(\n --oscd-tree-item-supporting-text-size,\n var(--md-list-item-supporting-text-size, 0.875rem)\n );\n font-weight: var(\n --oscd-tree-item-supporting-text-weight,\n var(--md-list-item-supporting-text-weight, 400)\n );\n line-height: var(\n --oscd-tree-item-supporting-text-line-height,\n var(--md-list-item-supporting-text-line-height, 1.25rem)\n );\n }\n\n ::slotted([slot='start']),\n ::slotted([slot='end']) {\n flex: 0 0 auto;\n }\n\n ::slotted([slot='start']) {\n color: var(\n --oscd-tree-item-leading-icon-color,\n var(\n --md-list-item-leading-icon-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n }\n\n ::slotted([slot='end']) {\n margin-inline-start: var(--oscd-tree-item-gap, 16px);\n color: var(\n --oscd-tree-item-trailing-icon-color,\n var(\n --md-list-item-trailing-icon-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n }\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeItem.js","sourceRoot":"","sources":["../../../tree/internal/TreeItem.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QACE;;WAEG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAEjB;;WAEG;QAEH,WAAM,GAAG,KAAK,CAAC;QAEf;;WAEG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAEjB;;;WAGG;QAEK,sBAAiB,GAAG,KAAK,CAAC;IAgOpC,CAAC;IA9NU,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,qEAAqE;QACrE,kEAAkE;QAClE,uEAAuE;QACvE,8DAA8D;QAC9D,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACzE,CAAC;IAEO,qBAAqB,CAAC,KAAY;QACxC,yEAAyE;QACzE,qEAAqE;QACrE,IAAI,CAAC,iBAAiB;YACnB,KAAK,CAAC,MAA0B,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBAClE,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;;;yBAGU,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;;yCAE3B,IAAI,CAAC,qBAAqB;;;;;;;;;;;WAWxD,CAAC;IACV,CAAC;;AAEe,eAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwL3B,AAxLqB,CAwLpB;AAlPF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC1B;AAMjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAC5B;AAMf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC1B;AAOT;IADP,KAAK,EAAE;mDAC0B","sourcesContent":["import { css, html, LitElement, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\n/**\n * Internal base class for `oscd-tree-item`.\n *\n * ## Leading icon alignment\n *\n * A leading icon (the `start` slot) is rendered inside a fixed-width leading\n * column whose size defaults to the tree's `--oscd-tree-indent-step`. This is\n * deliberate: it makes a leading icon occupy **exactly one indent step**, so an\n * icon-less descendant — which the tree indents by one step per level — lands\n * its text precisely under its iconed ancestor's text, at any depth, with no\n * per-row tuning. Rows without a leading icon collapse the column to zero and\n * rely on the tree's indentation instead.\n *\n * Because the leading column and the indent step are fused, a single knob\n * (`--oscd-tree-indent-step`) controls both per-level indentation and the\n * leading icon column, and the two can never drift out of alignment. Set it\n * large enough to comfortably hold the icon (e.g. `40px`); the visual gap\n * between the icon and the text is the leftover space, `step - icon size`.\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 */\nexport class TreeItem extends LitElement {\n /**\n * Whether the row content should render selected styling.\n */\n @property({ type: Boolean, reflect: true })\n selected = false;\n\n /**\n * Whether the row content represents the active tree row.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * Whether the row content should render disabled styling.\n */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Whether the `start` slot currently holds a leading icon. Drives the\n * fixed-width leading column so icon-less rows collapse it to zero.\n */\n @state()\n private hasLeadingContent = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Set the initial state synchronously from light-DOM children so the\n // first render already has the correct leading-column width — the\n // `slotchange` event only fires post-render and races the first paint,\n // letting an unclipped icon spill into `.text` for one frame.\n this.hasLeadingContent = this.querySelector('[slot=\"start\"]') !== null;\n }\n\n private handleStartSlotChange(event: Event): void {\n // Keeps state correct if `start`'s content changes after connect (e.g. a\n // reused row whose `renderItem` conditionally adds/removes an icon).\n this.hasLeadingContent =\n (event.target as HTMLSlotElement).assignedElements({ flatten: true })\n .length > 0;\n }\n\n override render(): TemplateResult {\n return html`<div part=\"content\" class=\"content\">\n <span\n part=\"leading\"\n class=\"leading ${this.hasLeadingContent ? 'has-leading' : ''}\"\n >\n <slot name=\"start\" @slotchange=${this.handleStartSlotChange}></slot>\n </span>\n <span part=\"text\" class=\"text\">\n <span part=\"headline\" class=\"headline\"\n ><slot name=\"headline\"></slot\n ></span>\n <span part=\"supporting-text\" class=\"supporting-text\"\n ><slot name=\"supporting-text\"></slot\n ></span>\n </span>\n <slot name=\"end\"></slot>\n </div>`;\n }\n\n static override styles = css`\n :host {\n box-sizing: border-box;\n display: block;\n min-width: 0;\n color: inherit;\n font-family: var(\n --oscd-tree-item-font-family,\n var(\n --md-list-item-label-text-font,\n var(--md-sys-typescale-body-large-font, Roboto)\n )\n );\n font-size: var(\n --oscd-tree-item-font-size,\n var(--md-list-item-label-text-size, 1rem)\n );\n }\n\n :host([disabled]) {\n opacity: var(\n --oscd-tree-item-disabled-opacity,\n var(--md-list-item-disabled-opacity, 0.3)\n );\n }\n\n :host([selected]) .headline {\n /*\n * Falls back to currentColor (like the resting \".headline\" rule below)\n * rather than a fixed on-surface ink, so the label tracks whatever\n * \"color\" the containing row already resolved to for its selected\n * state (e.g. Tree.js's selected/active row rules), instead of\n * silently overriding it with an unrelated fixed color.\n */\n color: var(\n --oscd-tree-item-selected-headline-color,\n var(--md-list-item-label-text-color, currentColor)\n );\n font-weight: var(\n --oscd-tree-item-selected-headline-weight,\n var(--md-sys-typescale-body-large-weight-prominent, 500)\n );\n }\n\n /*\n * Like the selected headline rule above, falls back to currentColor so\n * the supporting text also tracks the row's selected-state color instead\n * of staying pinned to the resting on-surface-variant grey (which has\n * poor contrast once the row's background switches to a selected color).\n */\n :host([selected]) .supporting-text {\n color: var(\n --oscd-tree-item-selected-supporting-text-color,\n var(--md-list-item-supporting-text-color, currentColor)\n );\n }\n\n .content {\n display: flex;\n align-items: center;\n box-sizing: border-box;\n min-width: 0;\n min-height: var(\n --oscd-tree-item-min-height,\n var(--md-list-item-one-line-container-height, 56px)\n );\n width: 100%;\n }\n\n /*\n * Leading icon column. A leading icon occupies exactly one indent step so\n * that icon-less descendants (indented one step per level by the tree)\n * align their text under an iconed ancestor's text at any depth. Rows\n * without a leading icon collapse this column to zero and rely on the\n * tree's indentation instead. Override --oscd-tree-item-leading-size only\n * if you must decouple it from --oscd-tree-indent-step; keeping them equal\n * is what preserves the alignment.\n */\n .leading {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n flex: 0 0 auto;\n inline-size: 0;\n }\n\n .leading.has-leading {\n inline-size: var(\n --oscd-tree-item-leading-size,\n var(--oscd-tree-indent-step, 24px)\n );\n }\n\n .text {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n justify-content: center;\n min-width: 0;\n }\n\n .headline,\n .supporting-text {\n display: block;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .headline {\n color: var(\n --oscd-tree-item-headline-color,\n var(--md-list-item-label-text-color, currentColor)\n );\n font-family: var(\n --oscd-tree-item-headline-font,\n var(--md-list-item-label-text-font, inherit)\n );\n font-size: var(\n --oscd-tree-item-headline-size,\n var(--md-list-item-label-text-size, 1rem)\n );\n font-weight: var(\n --oscd-tree-item-headline-weight,\n var(--md-list-item-label-text-weight, 400)\n );\n line-height: var(\n --oscd-tree-item-headline-line-height,\n var(--md-list-item-label-text-line-height, 1.5rem)\n );\n }\n\n .supporting-text {\n color: var(\n --oscd-tree-item-supporting-text-color,\n var(\n --md-list-item-supporting-text-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n font-family: var(\n --oscd-tree-item-supporting-text-font,\n var(--md-list-item-supporting-text-font, inherit)\n );\n font-size: var(\n --oscd-tree-item-supporting-text-size,\n var(--md-list-item-supporting-text-size, 0.875rem)\n );\n font-weight: var(\n --oscd-tree-item-supporting-text-weight,\n var(--md-list-item-supporting-text-weight, 400)\n );\n line-height: var(\n --oscd-tree-item-supporting-text-line-height,\n var(--md-list-item-supporting-text-line-height, 1.25rem)\n );\n }\n\n ::slotted([slot='start']),\n ::slotted([slot='end']) {\n flex: 0 0 auto;\n }\n\n ::slotted([slot='start']) {\n color: var(\n --oscd-tree-item-leading-icon-color,\n var(\n --md-list-item-leading-icon-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n }\n\n ::slotted([slot='end']) {\n margin-inline-start: var(--oscd-tree-item-gap, 16px);\n color: var(\n --oscd-tree-item-trailing-icon-color,\n var(\n --md-list-item-trailing-icon-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n )\n );\n }\n `;\n}\n"]}
|