@omicronenergy/oscd-ui 0.0.14 → 0.0.15
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 +7 -0
- package/dist/action-icon/oscd-action-icon.stories.d.ts +12 -69
- package/dist/action-list/oscd-action-list.stories.d.ts +12 -33
- package/dist/action-pane/oscd-action-pane.stories.d.ts +13 -36
- package/dist/action-tree/oscd-action-tree.stories.d.ts +13 -36
- package/dist/button/OscdElevatedButton.stories.d.ts +13 -36
- package/dist/button/OscdFilledButton.stories.d.ts +13 -36
- package/dist/button/OscdFilledTonalButton.stories.d.ts +13 -36
- package/dist/button/OscdOutlinedButton.stories.d.ts +13 -36
- package/dist/button/OscdTextButton.stories.d.ts +13 -36
- package/dist/checkbox/OscdCheckbox.stories.d.ts +13 -36
- package/dist/chips/OscdAssistChip.stories.d.ts +13 -36
- package/dist/chips/OscdChipSet.stories.d.ts +13 -36
- package/dist/chips/OscdFilterChip.stories.d.ts +13 -36
- package/dist/chips/OscdInputChip.stories.d.ts +13 -36
- package/dist/chips/OscdSuggestionChip.stories.d.ts +13 -36
- package/dist/dialog/OscdDialog.stories.d.ts +13 -36
- package/dist/divider/OscdDivider.stories.d.ts +13 -36
- package/dist/elevation/OscdElevation.stories.d.ts +13 -36
- package/dist/fab/OscdBrandedFab.stories.d.ts +13 -36
- package/dist/fab/OscdFab.stories.d.ts +13 -36
- package/dist/field/OscdFilledField.stories.d.ts +13 -36
- package/dist/field/OscdOutlinedField.stories.d.ts +13 -36
- package/dist/filter-button/oscd-filter-button.stories.d.ts +12 -32
- package/dist/focus/OscdFocusRing.stories.d.ts +13 -36
- package/dist/icon/OscdIcon.stories.d.ts +13 -36
- package/dist/iconbutton/OscdFilledIconButton.stories.d.ts +13 -36
- package/dist/iconbutton/OscdFilledTonalIconButton.stories.d.ts +13 -36
- package/dist/iconbutton/OscdIconButton.stories.d.ts +13 -36
- package/dist/iconbutton/OscdOutlinedIconButton.stories.d.ts +13 -36
- package/dist/labs/badge/OscdBadge.stories.d.ts +13 -36
- package/dist/labs/card/OscdElevatedCard.stories.d.ts +13 -36
- package/dist/labs/card/OscdFilledCard.stories.d.ts +13 -36
- package/dist/labs/card/OscdOutlinedCard.stories.d.ts +13 -36
- package/dist/labs/item/OscdItem.stories.d.ts +13 -36
- package/dist/labs/navigationbar/OscdNavigationBar.stories.d.ts +13 -36
- package/dist/labs/navigationtab/OscdNavigationTab.stories.d.ts +13 -36
- package/dist/labs/segmentedbutton/OscdOutlinedSegmentedButton.stories.d.ts +12 -32
- package/dist/labs/segmentedbuttonset/OscdOutlinedSegmentedButtonSet.stories.d.ts +12 -32
- package/dist/list/OscdList.stories.d.ts +13 -36
- package/dist/list/OscdListItem.stories.d.ts +13 -36
- package/dist/menu/OscdMenuItem.stories.d.ts +13 -36
- package/dist/menu/OscdSubMenu.stories.d.ts +23 -50
- package/dist/menu/OscdSubMenu.stories.js +188 -13
- package/dist/menu/OscdSubMenu.stories.js.map +1 -1
- package/dist/progress/OscdCircularProgress.stories.d.ts +13 -36
- package/dist/progress/OscdLinearProgress.stories.d.ts +13 -36
- package/dist/radio/OscdRadio.stories.d.ts +12 -32
- package/dist/ripple/OscdRipple.stories.d.ts +13 -36
- package/dist/scl-checkbox/oscd-scl-checkbox.stories.d.ts +13 -36
- package/dist/scl-icon/OscdSclIcon.stories.d.ts +13 -36
- package/dist/scl-select/oscd-scl-select.stories.d.ts +13 -36
- package/dist/scl-textfield/oscd-scl-text-field.stories.d.ts +13 -36
- package/dist/select/OscdFilledSelect.stories.d.ts +12 -32
- package/dist/select/OscdOutlinedSelect.stories.d.ts +12 -32
- package/dist/select/OscdSelectOption.stories.d.ts +12 -32
- package/dist/selection-list/oscd-selection-list.stories.d.ts +12 -32
- package/dist/selection-list/oscd-selection-list.stories.js +1 -1
- package/dist/selection-list/oscd-selection-list.stories.js.map +1 -1
- package/dist/slider/OscdSlider.stories.d.ts +13 -36
- package/dist/switch/OscdSwitch.stories.d.ts +13 -36
- package/dist/tabs/OscdPrimaryTab.stories.d.ts +12 -32
- package/dist/tabs/OscdSecondaryTab.stories.d.ts +12 -32
- package/dist/tabs/OscdTabs.stories.d.ts +13 -36
- package/dist/textfield/OscdFilledTextField.stories.d.ts +13 -36
- package/dist/textfield/OscdOutlinedTextField.stories.d.ts +13 -36
- package/dist/tree/OscdTree.d.ts +22 -1
- package/dist/tree/OscdTree.js +21 -0
- package/dist/tree/OscdTree.js.map +1 -1
- package/dist/tree/OscdTree.stories.d.ts +16 -36
- package/dist/tree/OscdTree.stories.js +148 -1
- package/dist/tree/OscdTree.stories.js.map +1 -1
- package/dist/tree/OscdTreeItem.d.ts +17 -0
- package/dist/tree/OscdTreeItem.js +17 -0
- package/dist/tree/OscdTreeItem.js.map +1 -1
- package/dist/tree/internal/Tree.d.ts +47 -0
- package/dist/tree/internal/Tree.js +150 -8
- package/dist/tree/internal/Tree.js.map +1 -1
- package/dist/tree/internal/TreeItem.d.ts +22 -0
- package/dist/tree/internal/TreeItem.js +61 -4
- package/dist/tree/internal/TreeItem.js.map +1 -1
- package/dist/tree/oscd-tree.spec.d.ts +3 -0
- package/dist/tree/oscd-tree.spec.js +144 -0
- package/dist/tree/oscd-tree.spec.js.map +1 -0
- package/dist/tree-grid/oscd-tree-grid.stories.d.ts +13 -36
- package/dist/utils/storybook/getStorybookMeta.d.ts +1 -3
- package/dist/utils/storybook/getStorybookMeta.js +10 -1
- package/dist/utils/storybook/getStorybookMeta.js.map +1 -1
- package/package.json +6 -6
- package/regenerating-library.md +4 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import './oscd-tree.js';
|
|
4
|
+
import './oscd-tree-item.js';
|
|
5
|
+
import '../icon/oscd-icon.js';
|
|
6
|
+
const data = [
|
|
7
|
+
{
|
|
8
|
+
id: 'a',
|
|
9
|
+
label: 'A',
|
|
10
|
+
children: [{ id: 'a/a', label: 'A/A', children: [] }],
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
const rowToggleIcon = (el) => {
|
|
14
|
+
const icon = el.renderRoot.querySelector('.row .toggle oscd-icon');
|
|
15
|
+
return icon?.textContent?.trim();
|
|
16
|
+
};
|
|
17
|
+
describe('oscd-tree toggle customization', () => {
|
|
18
|
+
it('uses the default expand/collapse icons', async () => {
|
|
19
|
+
const collapsed = await fixture(html `<oscd-tree .data=${data}></oscd-tree>`);
|
|
20
|
+
expect(rowToggleIcon(collapsed)).to.equal('chevron_right');
|
|
21
|
+
const expanded = await fixture(html `<oscd-tree .data=${data} .expandedIds=${['a']}></oscd-tree>`);
|
|
22
|
+
expect(rowToggleIcon(expanded)).to.equal('expand_more');
|
|
23
|
+
});
|
|
24
|
+
it('honors overridden expand/collapse icons', async () => {
|
|
25
|
+
const collapsed = await fixture(html `<oscd-tree
|
|
26
|
+
.data=${data}
|
|
27
|
+
collapse-icon="add"
|
|
28
|
+
expand-icon="remove"
|
|
29
|
+
></oscd-tree>`);
|
|
30
|
+
expect(rowToggleIcon(collapsed)).to.equal('add');
|
|
31
|
+
const expanded = await fixture(html `<oscd-tree
|
|
32
|
+
.data=${data}
|
|
33
|
+
.expandedIds=${['a']}
|
|
34
|
+
collapse-icon="add"
|
|
35
|
+
expand-icon="remove"
|
|
36
|
+
></oscd-tree>`);
|
|
37
|
+
expect(rowToggleIcon(expanded)).to.equal('remove');
|
|
38
|
+
});
|
|
39
|
+
it('renders the toggle before the content by default', async () => {
|
|
40
|
+
const el = await fixture(html `<oscd-tree .data=${data}></oscd-tree>`);
|
|
41
|
+
expect(el.togglePosition).to.equal('leading');
|
|
42
|
+
const row = el.renderRoot.querySelector('.row');
|
|
43
|
+
const children = Array.from(row.children);
|
|
44
|
+
const toggleIndex = children.findIndex(child => child.classList.contains('toggle'));
|
|
45
|
+
const contentIndex = children.findIndex(child => child.classList.contains('content'));
|
|
46
|
+
expect(toggleIndex).to.be.lessThan(contentIndex);
|
|
47
|
+
});
|
|
48
|
+
it('renders the toggle after the content when trailing', async () => {
|
|
49
|
+
const el = await fixture(html `<oscd-tree .data=${data} toggle-position="trailing"></oscd-tree>`);
|
|
50
|
+
expect(el.togglePosition).to.equal('trailing');
|
|
51
|
+
expect(el.getAttribute('toggle-position')).to.equal('trailing');
|
|
52
|
+
const row = el.renderRoot.querySelector('.row');
|
|
53
|
+
const children = Array.from(row.children);
|
|
54
|
+
const toggleIndex = children.findIndex(child => child.classList.contains('toggle'));
|
|
55
|
+
const contentIndex = children.findIndex(child => child.classList.contains('content'));
|
|
56
|
+
expect(toggleIndex).to.be.greaterThan(contentIndex);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('oscd-tree leaf accessory', () => {
|
|
60
|
+
it('renders no accessory by default on leaf rows', async () => {
|
|
61
|
+
const el = await fixture(html `<oscd-tree .data=${data} .expandedIds=${['a']}></oscd-tree>`);
|
|
62
|
+
const leafRow = el.renderRoot.querySelectorAll('.row')[1];
|
|
63
|
+
expect(leafRow.querySelector('.accessory')).to.be.null;
|
|
64
|
+
expect(leafRow.querySelector('.toggle')).to.not.be.null;
|
|
65
|
+
});
|
|
66
|
+
it('renders the accessory in the toggle column of leaf rows only', async () => {
|
|
67
|
+
const el = await fixture(html `<oscd-tree
|
|
68
|
+
.data=${data}
|
|
69
|
+
.expandedIds=${['a']}
|
|
70
|
+
.renderLeafAccessory=${() => html `<button class="pin"><oscd-icon>keep</oscd-icon></button>`}
|
|
71
|
+
></oscd-tree>`);
|
|
72
|
+
const rows = el.renderRoot.querySelectorAll('.row');
|
|
73
|
+
const branchRow = rows[0];
|
|
74
|
+
const leafRow = rows[1];
|
|
75
|
+
// Branch keeps its toggle, no accessory.
|
|
76
|
+
expect(branchRow.querySelector('.accessory')).to.be.null;
|
|
77
|
+
expect(branchRow.querySelector('.toggle')).to.not.be.null;
|
|
78
|
+
// Leaf renders the accessory instead of the empty toggle button.
|
|
79
|
+
const accessory = leafRow.querySelector('.accessory');
|
|
80
|
+
expect(accessory).to.not.be.null;
|
|
81
|
+
expect(leafRow.querySelector('.toggle')).to.be.null;
|
|
82
|
+
expect(accessory?.querySelector('button.pin')).to.not.be.null;
|
|
83
|
+
});
|
|
84
|
+
it('does not select the row when the accessory is clicked', async () => {
|
|
85
|
+
let selectionChanged = false;
|
|
86
|
+
const el = await fixture(html `<oscd-tree
|
|
87
|
+
.data=${data}
|
|
88
|
+
.expandedIds=${['a']}
|
|
89
|
+
selectionMode="single"
|
|
90
|
+
.renderLeafAccessory=${() => html `<button class="pin"><oscd-icon>keep</oscd-icon></button>`}
|
|
91
|
+
@selected-ids-changed=${() => {
|
|
92
|
+
selectionChanged = true;
|
|
93
|
+
}}
|
|
94
|
+
></oscd-tree>`);
|
|
95
|
+
const button = el.renderRoot.querySelector('.accessory button.pin');
|
|
96
|
+
button.click();
|
|
97
|
+
expect(selectionChanged).to.be.false;
|
|
98
|
+
expect(el.selectedIds).to.deep.equal([]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('oscd-tree-item leading alignment', () => {
|
|
102
|
+
const renderMixed = ({ node }) => html `<oscd-tree-item>
|
|
103
|
+
${node.id === 'a' ? html `<oscd-icon slot="start">dns</oscd-icon>` : ''}
|
|
104
|
+
<span slot="headline">${node.label}</span>
|
|
105
|
+
</oscd-tree-item>`;
|
|
106
|
+
const items = (el) => el.renderRoot.querySelectorAll('oscd-tree-item');
|
|
107
|
+
const textLeft = (item) => {
|
|
108
|
+
const root = item.shadowRoot;
|
|
109
|
+
const text = root.querySelector('.text');
|
|
110
|
+
return text.getBoundingClientRect().left;
|
|
111
|
+
};
|
|
112
|
+
const leadingWidth = (item) => {
|
|
113
|
+
const root = item.shadowRoot;
|
|
114
|
+
const leading = root.querySelector('.leading');
|
|
115
|
+
return leading.getBoundingClientRect().width;
|
|
116
|
+
};
|
|
117
|
+
it('collapses the leading column on icon-less rows and reserves one indent step on iconed rows', async () => {
|
|
118
|
+
const el = await fixture(html `<oscd-tree
|
|
119
|
+
style="--oscd-tree-indent-step: 40px;"
|
|
120
|
+
.data=${data}
|
|
121
|
+
.expandedIds=${['a']}
|
|
122
|
+
.renderItem=${renderMixed}
|
|
123
|
+
></oscd-tree>`);
|
|
124
|
+
const [parent, child] = items(el);
|
|
125
|
+
// Iconed parent reserves exactly one indent step; icon-less child collapses.
|
|
126
|
+
expect(leadingWidth(parent)).to.equal(40);
|
|
127
|
+
expect(leadingWidth(child)).to.equal(0);
|
|
128
|
+
});
|
|
129
|
+
it('aligns an icon-less child under its iconed parent at any indent step', async () => {
|
|
130
|
+
for (const step of ['24px', '40px', '56px']) {
|
|
131
|
+
const el = await fixture(html `<oscd-tree
|
|
132
|
+
style="--oscd-tree-indent-step: ${step};"
|
|
133
|
+
.data=${data}
|
|
134
|
+
.expandedIds=${['a']}
|
|
135
|
+
.renderItem=${renderMixed}
|
|
136
|
+
></oscd-tree>`);
|
|
137
|
+
const [parent, child] = items(el);
|
|
138
|
+
// A leading icon occupies one indent step, so the child (indented one
|
|
139
|
+
// step) lands its text exactly under the parent's text.
|
|
140
|
+
expect(Math.abs(textLeft(child) - textLeft(parent))).to.be.lessThan(1);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=oscd-tree.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oscd-tree.spec.js","sourceRoot":"","sources":["../../tree/oscd-tree.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sBAAsB,CAAC;AAM9B,MAAM,IAAI,GAAW;IACnB;QACE,EAAE,EAAE,GAAG;QACP,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,CAAC,EAAE,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,OAAO,CACtB,IAAI,CAAA;;gBAEM,IAAI;uBACG,CAAC,GAAG,CAAC;sBACN,WAAW;oBACb,CACf,CAAC;QACF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAClC,6EAA6E;QAC7E,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1C,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YAC5C,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA;4CACgC,IAAI;kBAC9B,IAAI;yBACG,CAAC,GAAG,CAAC;wBACN,WAAW;sBACb,CACf,CAAC;YACF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;YAClC,sEAAsE;YACtE,wDAAwD;YACxD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACzE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\n\nimport './oscd-tree.js';\nimport './oscd-tree-item.js';\nimport '../icon/oscd-icon.js';\nimport type { OscdTree } from './OscdTree.js';\nimport type { TreeNode, TreeRenderContext } from './OscdTree.js';\n\ntype Node = TreeNode & { label: string; children?: Node[] };\n\nconst data: Node[] = [\n {\n id: 'a',\n label: 'A',\n children: [{ id: 'a/a', label: 'A/A', children: [] }],\n },\n];\n\nconst rowToggleIcon = (el: OscdTree): string | undefined => {\n const icon = el.renderRoot.querySelector(\n '.row .toggle oscd-icon',\n ) as HTMLElement | null;\n return icon?.textContent?.trim();\n};\n\ndescribe('oscd-tree toggle customization', () => {\n it('uses the default expand/collapse icons', async () => {\n const collapsed = await fixture<OscdTree>(\n html`<oscd-tree .data=${data}></oscd-tree>`,\n );\n expect(rowToggleIcon(collapsed)).to.equal('chevron_right');\n\n const expanded = await fixture<OscdTree>(\n html`<oscd-tree .data=${data} .expandedIds=${['a']}></oscd-tree>`,\n );\n expect(rowToggleIcon(expanded)).to.equal('expand_more');\n });\n\n it('honors overridden expand/collapse icons', async () => {\n const collapsed = await fixture<OscdTree>(\n html`<oscd-tree\n .data=${data}\n collapse-icon=\"add\"\n expand-icon=\"remove\"\n ></oscd-tree>`,\n );\n expect(rowToggleIcon(collapsed)).to.equal('add');\n\n const expanded = await fixture<OscdTree>(\n html`<oscd-tree\n .data=${data}\n .expandedIds=${['a']}\n collapse-icon=\"add\"\n expand-icon=\"remove\"\n ></oscd-tree>`,\n );\n expect(rowToggleIcon(expanded)).to.equal('remove');\n });\n\n it('renders the toggle before the content by default', async () => {\n const el = await fixture<OscdTree>(\n html`<oscd-tree .data=${data}></oscd-tree>`,\n );\n expect(el.togglePosition).to.equal('leading');\n\n const row = el.renderRoot.querySelector('.row') as HTMLElement;\n const children = Array.from(row.children);\n const toggleIndex = children.findIndex(child =>\n child.classList.contains('toggle'),\n );\n const contentIndex = children.findIndex(child =>\n child.classList.contains('content'),\n );\n expect(toggleIndex).to.be.lessThan(contentIndex);\n });\n\n it('renders the toggle after the content when trailing', async () => {\n const el = await fixture<OscdTree>(\n html`<oscd-tree .data=${data} toggle-position=\"trailing\"></oscd-tree>`,\n );\n expect(el.togglePosition).to.equal('trailing');\n expect(el.getAttribute('toggle-position')).to.equal('trailing');\n\n const row = el.renderRoot.querySelector('.row') as HTMLElement;\n const children = Array.from(row.children);\n const toggleIndex = children.findIndex(child =>\n child.classList.contains('toggle'),\n );\n const contentIndex = children.findIndex(child =>\n child.classList.contains('content'),\n );\n expect(toggleIndex).to.be.greaterThan(contentIndex);\n });\n});\n\ndescribe('oscd-tree leaf accessory', () => {\n it('renders no accessory by default on leaf rows', async () => {\n const el = await fixture<OscdTree>(\n html`<oscd-tree .data=${data} .expandedIds=${['a']}></oscd-tree>`,\n );\n const leafRow = el.renderRoot.querySelectorAll('.row')[1] as HTMLElement;\n expect(leafRow.querySelector('.accessory')).to.be.null;\n expect(leafRow.querySelector('.toggle')).to.not.be.null;\n });\n\n it('renders the accessory in the toggle column of leaf rows only', async () => {\n const el = await fixture<OscdTree>(\n html`<oscd-tree\n .data=${data}\n .expandedIds=${['a']}\n .renderLeafAccessory=${() =>\n html`<button class=\"pin\"><oscd-icon>keep</oscd-icon></button>`}\n ></oscd-tree>`,\n );\n\n const rows = el.renderRoot.querySelectorAll('.row');\n const branchRow = rows[0] as HTMLElement;\n const leafRow = rows[1] as HTMLElement;\n\n // Branch keeps its toggle, no accessory.\n expect(branchRow.querySelector('.accessory')).to.be.null;\n expect(branchRow.querySelector('.toggle')).to.not.be.null;\n\n // Leaf renders the accessory instead of the empty toggle button.\n const accessory = leafRow.querySelector('.accessory');\n expect(accessory).to.not.be.null;\n expect(leafRow.querySelector('.toggle')).to.be.null;\n expect(accessory?.querySelector('button.pin')).to.not.be.null;\n });\n\n it('does not select the row when the accessory is clicked', async () => {\n let selectionChanged = false;\n const el = await fixture<OscdTree>(\n html`<oscd-tree\n .data=${data}\n .expandedIds=${['a']}\n selectionMode=\"single\"\n .renderLeafAccessory=${() =>\n html`<button class=\"pin\"><oscd-icon>keep</oscd-icon></button>`}\n @selected-ids-changed=${() => {\n selectionChanged = true;\n }}\n ></oscd-tree>`,\n );\n\n const button = el.renderRoot.querySelector(\n '.accessory button.pin',\n ) as HTMLButtonElement;\n button.click();\n\n expect(selectionChanged).to.be.false;\n expect(el.selectedIds).to.deep.equal([]);\n });\n});\n\ndescribe('oscd-tree-item leading alignment', () => {\n const renderMixed = ({ node }: TreeRenderContext<Node>) =>\n html`<oscd-tree-item>\n ${node.id === 'a' ? html`<oscd-icon slot=\"start\">dns</oscd-icon>` : ''}\n <span slot=\"headline\">${node.label}</span>\n </oscd-tree-item>`;\n\n const items = (el: OscdTree): NodeListOf<Element> =>\n el.renderRoot.querySelectorAll('oscd-tree-item');\n\n const textLeft = (item: Element): number => {\n const root = (item as HTMLElement & { shadowRoot: ShadowRoot }).shadowRoot;\n const text = root.querySelector('.text') as HTMLElement;\n return text.getBoundingClientRect().left;\n };\n\n const leadingWidth = (item: Element): number => {\n const root = (item as HTMLElement & { shadowRoot: ShadowRoot }).shadowRoot;\n const leading = root.querySelector('.leading') as HTMLElement;\n return leading.getBoundingClientRect().width;\n };\n\n it('collapses the leading column on icon-less rows and reserves one indent step on iconed rows', async () => {\n const el = await fixture<OscdTree>(\n html`<oscd-tree\n style=\"--oscd-tree-indent-step: 40px;\"\n .data=${data}\n .expandedIds=${['a']}\n .renderItem=${renderMixed}\n ></oscd-tree>`,\n );\n const [parent, child] = items(el);\n // Iconed parent reserves exactly one indent step; icon-less child collapses.\n expect(leadingWidth(parent)).to.equal(40);\n expect(leadingWidth(child)).to.equal(0);\n });\n\n it('aligns an icon-less child under its iconed parent at any indent step', async () => {\n for (const step of ['24px', '40px', '56px']) {\n const el = await fixture<OscdTree>(\n html`<oscd-tree\n style=\"--oscd-tree-indent-step: ${step};\"\n .data=${data}\n .expandedIds=${['a']}\n .renderItem=${renderMixed}\n ></oscd-tree>`,\n );\n const [parent, child] = items(el);\n // A leading icon occupies one indent step, so the child (indented one\n // step) lands its text exactly under the parent's text.\n expect(Math.abs(textLeft(child) - textLeft(parent))).to.be.lessThan(1);\n }\n });\n});\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/web-components-vite';
|
|
2
|
-
import { OscdTreeGrid } from './OscdTreeGrid.js';
|
|
3
2
|
import './oscd-tree-grid.js';
|
|
4
3
|
declare const _default: {
|
|
5
4
|
title: string;
|
|
@@ -9,43 +8,21 @@ declare const _default: {
|
|
|
9
8
|
excludeStories?: RegExp | string[];
|
|
10
9
|
component?: string | undefined;
|
|
11
10
|
subcomponents?: Record<string, string> | undefined;
|
|
12
|
-
play?: import("storybook/internal/csf").PlayFunction<import("@storybook/web-components
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}> | import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
19
|
-
textContent: string;
|
|
11
|
+
play?: import("storybook/internal/csf").PlayFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | undefined;
|
|
12
|
+
globals?: Partial<import("storybook/internal/csf").Globals> | undefined;
|
|
13
|
+
decorators?: import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components").WebComponentsRenderer, {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
}> | import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components").WebComponentsRenderer, {
|
|
16
|
+
[x: string]: any;
|
|
20
17
|
}>[] | undefined;
|
|
21
18
|
parameters?: import("@storybook/web-components-vite").Parameters | undefined;
|
|
22
|
-
args?: Partial<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
textContent: string;
|
|
30
|
-
}> | import("storybook/internal/csf").LoaderFunction<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
31
|
-
textContent: string;
|
|
32
|
-
}>[] | undefined;
|
|
33
|
-
beforeEach?: import("storybook/internal/csf").BeforeEach<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
34
|
-
textContent: string;
|
|
35
|
-
}> | import("storybook/internal/csf").BeforeEach<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
36
|
-
textContent: string;
|
|
37
|
-
}>[] | undefined;
|
|
38
|
-
afterEach?: import("storybook/internal/csf").AfterEach<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
39
|
-
textContent: string;
|
|
40
|
-
}> | import("storybook/internal/csf").AfterEach<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
41
|
-
textContent: string;
|
|
42
|
-
}>[] | undefined;
|
|
43
|
-
render?: import("storybook/internal/csf").ArgsStoryFn<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
44
|
-
textContent: string;
|
|
45
|
-
}> | undefined;
|
|
46
|
-
mount?: ((context: import("storybook/internal/csf").StoryContext<import("@storybook/web-components-vite").WebComponentsRenderer, OscdTreeGrid & {
|
|
47
|
-
textContent: string;
|
|
48
|
-
}>) => () => Promise<import("storybook/internal/csf").Canvas>) | undefined;
|
|
19
|
+
args?: Partial<import("@storybook/web-components-vite").Args> | undefined;
|
|
20
|
+
argTypes?: Partial<import("@storybook/web-components-vite").ArgTypes<import("@storybook/web-components-vite").Args>> | undefined;
|
|
21
|
+
loaders?: import("storybook/internal/csf").LoaderFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | import("storybook/internal/csf").LoaderFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args>[] | undefined;
|
|
22
|
+
beforeEach?: import("storybook/internal/csf").BeforeEach<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | import("storybook/internal/csf").BeforeEach<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args>[] | undefined;
|
|
23
|
+
afterEach?: import("storybook/internal/csf").AfterEach<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | import("storybook/internal/csf").AfterEach<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args>[] | undefined;
|
|
24
|
+
render?: import("storybook/internal/csf").ArgsStoryFn<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | undefined;
|
|
25
|
+
mount?: ((context: import("storybook/internal/csf").StoryContext<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args>) => () => Promise<import("storybook/internal/csf").Canvas>) | undefined;
|
|
49
26
|
};
|
|
50
27
|
export default _default;
|
|
51
28
|
export declare const Default: StoryObj;
|
|
@@ -12,9 +12,7 @@ export declare function getStorybookMeta<T extends {
|
|
|
12
12
|
[x: string]: any;
|
|
13
13
|
};
|
|
14
14
|
argTypes: {};
|
|
15
|
-
meta: Meta
|
|
16
|
-
textContent: string;
|
|
17
|
-
}>;
|
|
15
|
+
meta: Meta;
|
|
18
16
|
template: (args?: (Partial<T> & {
|
|
19
17
|
[key: string]: any;
|
|
20
18
|
}) | undefined, slot?: import("lit-html").TemplateResult) => import("lit-html").TemplateResult;
|
|
@@ -40,7 +40,16 @@ export function getStorybookMeta({ tagName, defaultArgs = {}, options = {}, }) {
|
|
|
40
40
|
return {
|
|
41
41
|
args,
|
|
42
42
|
argTypes,
|
|
43
|
-
|
|
43
|
+
/*
|
|
44
|
+
* Widened deliberately. Stories spread `...meta` into an untyped default
|
|
45
|
+
* export, so a generic `Meta<T>` inlines `Partial<T>` into the inferred
|
|
46
|
+
* type. T is the element class, which carries symbol-keyed members from the
|
|
47
|
+
* material-web mixins (internals, createValidator, getFormState, ...). Those
|
|
48
|
+
* unique symbols are not nameable from a story file, so declaration emit
|
|
49
|
+
* fails with TS4082. Remove this cast once args are typed as the component's
|
|
50
|
+
* public props rather than the element class itself.
|
|
51
|
+
*/
|
|
52
|
+
meta: meta,
|
|
44
53
|
template, // Expose template for custom stories
|
|
45
54
|
};
|
|
46
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorybookMeta.js","sourceRoot":"","sources":["../../../utils/storybook/getStorybookMeta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E;YACR,GAAG,CAAC,CAAC,OAAO,CAAC,eAAe;gBAC1B,CAAC,CAAC;oBACE,WAAW,EAAE;wBACX,IAAI,EAAE,cAAc;wBACpB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;wBACzB,WAAW,EAAE,2BAA2B;qBACzC;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,QAAQ;SACW;QAExB,MAAM,EAAE,IAAI,CAAC,EAAE,CACb,QAAQ,CACN,IAAI,EACJ,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,SAAS,CAC3D;QACH,8DAA8D;QAC9D,GAAI,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAS;KACpC,CAAC;IACF,OAAO;QACL,IAAI;QACJ,QAAQ;QACR;;;;;;;;WAQG;QACH,IAAI,EAAE,IAAY;QAClB,QAAQ,EAAE,qCAAqC;KAChD,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,gGAAgG","sourcesContent":["import type { Meta } from '@storybook/web-components-vite';\nimport { html } from 'lit';\n\nimport {\n getStorybookHelpers,\n storybookHelperDecorator,\n} from './getStorybookHelpers.js';\n\nimport { storybookOverrides } from './story-overrides/story-overrides.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getStorybookMeta<T extends { [key: string]: any }>({\n tagName,\n defaultArgs = {},\n options = {},\n}: {\n tagName: string;\n defaultArgs?: Partial<T>;\n options?: { omitTextContent?: boolean };\n}) {\n const { template, events, ...rest } = getStorybookHelpers<T>(tagName);\n const overrides = storybookOverrides[tagName] || {};\n\n const argTypes = {\n ...rest.argTypes,\n ...(overrides?.argTypes ?? {}),\n };\n\n const args = {\n ...rest.args,\n ...defaultArgs,\n ...(overrides?.args ?? {}),\n };\n\n const meta: Meta<T & { textContent: string }> = {\n component: tagName,\n tags: ['autodocs'],\n\n decorators: [storybookHelperDecorator],\n parameters: {\n layout: 'centered',\n },\n argTypes: {\n ...(!options.omitTextContent\n ? {\n textContent: {\n name: 'Text Content',\n control: { type: 'text' },\n description: 'Text content of Component',\n },\n }\n : {}),\n ...argTypes,\n } as Meta<T>['argTypes'],\n\n render: argz =>\n template(\n argz,\n argz.textContent ? html` ${argz.textContent} ` : undefined,\n ),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...((overrides?.meta ?? {}) as any),\n };\n return {\n args,\n argTypes,\n /*\n * Widened deliberately. Stories spread `...meta` into an untyped default\n * export, so a generic `Meta<T>` inlines `Partial<T>` into the inferred\n * type. T is the element class, which carries symbol-keyed members from the\n * material-web mixins (internals, createValidator, getFormState, ...). Those\n * unique symbols are not nameable from a story file, so declaration emit\n * fails with TS4082. Remove this cast once args are typed as the component's\n * public props rather than the element class itself.\n */\n meta: meta as Meta,\n template, // Expose template for custom stories\n };\n}\n\n// Example usage:\n// const { args, argTypes, meta } = getStorybookMeta<YourComponentType>( 'your-component-tag' );\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omicronenergy/oscd-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "UI Web Components set for OpenSCD",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -198,14 +198,14 @@
|
|
|
198
198
|
"@lit-labs/analyzer": "^0.12.1",
|
|
199
199
|
"@open-wc/eslint-config": "^13.0.0",
|
|
200
200
|
"@open-wc/testing": "^4.0.0",
|
|
201
|
-
"@storybook/addon-docs": "^
|
|
202
|
-
"@storybook/web-components-vite": "^
|
|
201
|
+
"@storybook/addon-docs": "^10.4.6",
|
|
202
|
+
"@storybook/web-components-vite": "^10.4.6",
|
|
203
203
|
"@types/mocha": "^10.0.10",
|
|
204
204
|
"@types/node": "^24.0.3",
|
|
205
205
|
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
206
206
|
"@typescript-eslint/parser": "^8.36.0",
|
|
207
207
|
"@wc-toolkit/cem-inheritance": "^1.2.2",
|
|
208
|
-
"@wc-toolkit/storybook-helpers": "^
|
|
208
|
+
"@wc-toolkit/storybook-helpers": "^10.7.3",
|
|
209
209
|
"@web/dev-server-polyfill": "^1.0.6",
|
|
210
210
|
"@web/test-runner": "0.20.2",
|
|
211
211
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"eslint-plugin-lit-a11y": "^5.1.0",
|
|
220
220
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
221
221
|
"eslint-plugin-prettier": "^5.5.1",
|
|
222
|
-
"eslint-plugin-storybook": "
|
|
222
|
+
"eslint-plugin-storybook": "10.4.6",
|
|
223
223
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
224
224
|
"eslint-plugin-wc": "^3.0.1",
|
|
225
225
|
"gh-pages": "^6.3.0",
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"prettier": "^3.6.0",
|
|
231
231
|
"rimraf": "^6.1.3",
|
|
232
232
|
"sinon": "^21.0.0",
|
|
233
|
-
"storybook": "^
|
|
233
|
+
"storybook": "^10.4.6",
|
|
234
234
|
"typescript": "^5.9.2",
|
|
235
235
|
"vite-tsconfig-paths": "^5.1.4",
|
|
236
236
|
"wireit": "^0.14.12"
|
package/regenerating-library.md
CHANGED
|
@@ -19,7 +19,7 @@ If we copy the material web code in its entirety, we will have a hard time keepi
|
|
|
19
19
|
|
|
20
20
|
### Steps
|
|
21
21
|
|
|
22
|
-
1. Currently the path to the local clone of the Material Web repository is hardcoded in the `./
|
|
22
|
+
1. Currently the path to the local clone of the Material Web repository is hardcoded in the `./scripts/generateOscdComponents.ts` script to `../oscd-material-web-base`. Change this path if needed.
|
|
23
23
|
2. Build this project (so scripts are transpiled): `npm run build`
|
|
24
24
|
3. Run `npm run generate-oscd` to generate the components.
|
|
25
25
|
|
|
@@ -33,4 +33,6 @@ As with anything generated, there will be exceptions were you need to do things
|
|
|
33
33
|
|
|
34
34
|
### Prevent generation of specific components
|
|
35
35
|
|
|
36
|
-
Each
|
|
36
|
+
Each generated file has a `GENERATED SOURCE FILE. DO NOT MODIFY` comment at the top. If you remove this comment, the generation script will skip this file and not overwrite it.
|
|
37
|
+
|
|
38
|
+
Note that this marker is also present on the generated `*.stories.ts` and `*.spec.ts` files, not just the component wrappers. Fixes that should apply to all components belong in the generator templates in `./scripts/generateOscdComponents.ts`, followed by a regeneration — otherwise they will be lost the next time the library is regenerated.
|