@omicronenergy/oscd-ui 0.0.16 → 0.0.18
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 +14 -0
- package/custom-elements.json +2521 -1540
- package/dist/search-field/OscdOutlinedSearchField.d.ts +36 -0
- package/dist/search-field/OscdOutlinedSearchField.js +35 -0
- package/dist/search-field/OscdOutlinedSearchField.js.map +1 -0
- package/dist/search-field/internal/OutlinedSearchField.d.ts +15 -0
- package/dist/search-field/internal/OutlinedSearchField.js +95 -0
- package/dist/search-field/internal/OutlinedSearchField.js.map +1 -0
- package/dist/search-field/oscd-outlined-search-field.d.ts +3 -0
- package/dist/search-field/oscd-outlined-search-field.js +6 -0
- package/dist/search-field/oscd-outlined-search-field.js.map +1 -0
- package/dist/search-field/oscd-outlined-search-field.spec.d.ts +1 -0
- package/dist/search-field/oscd-outlined-search-field.spec.js +62 -0
- package/dist/search-field/oscd-outlined-search-field.spec.js.map +1 -0
- package/dist/search-field/oscd-outlined-search-field.stories.d.ts +34 -0
- package/dist/search-field/oscd-outlined-search-field.stories.js +85 -0
- package/dist/search-field/oscd-outlined-search-field.stories.js.map +1 -0
- package/dist/tree/OscdTree.d.ts +0 -1
- package/dist/tree/OscdTree.js +0 -1
- package/dist/tree/OscdTree.js.map +1 -1
- package/dist/tree/OscdTree.stories.d.ts +1 -0
- package/dist/tree/OscdTree.stories.js +60 -0
- package/dist/tree/OscdTree.stories.js.map +1 -1
- package/dist/tree/internal/Tree.d.ts +17 -1
- package/dist/tree/internal/Tree.js +117 -26
- package/dist/tree/internal/Tree.js.map +1 -1
- package/dist/tree/oscd-tree.spec.js +137 -0
- package/dist/tree/oscd-tree.spec.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { OscdIcon } from '../icon/OscdIcon.js';
|
|
2
|
+
import { OscdIconButton } from '../iconbutton/OscdIconButton.js';
|
|
3
|
+
import { OutlinedSearchField } from './internal/OutlinedSearchField.js';
|
|
4
|
+
import { OscdOutlinedField } from '../field/OscdOutlinedField.js';
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
'oscd-outlined-search-field': OscdOutlinedSearchField;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const OscdOutlinedSearchField_base: typeof OutlinedSearchField & import("@open-wc/scoped-elements/lit-element.js").ScopedElementsHostConstructor;
|
|
11
|
+
/**
|
|
12
|
+
* @tag oscd-outlined-search-field
|
|
13
|
+
* @summary An `oscd-outlined-text-field` specialized for search input.
|
|
14
|
+
*
|
|
15
|
+
* Behaves like a standard outlined text field, but comes by default with a
|
|
16
|
+
* leading search icon and a trailing "clear" button (shown once
|
|
17
|
+
* [[`value`]] is non-empty), a placeholder rendered at 50% opacity (relative
|
|
18
|
+
* to the input text color) that is hidden while the field has focus.
|
|
19
|
+
*
|
|
20
|
+
* The default leading/trailing icons can be overridden by slotting content
|
|
21
|
+
* into the `leading-icon`/`trailing-icon` slots, exactly as with
|
|
22
|
+
* `oscd-outlined-text-field`. The placeholder color can be overridden via
|
|
23
|
+
* `--oscd-search-field-placeholder-color`.
|
|
24
|
+
*
|
|
25
|
+
* Like the outlined text field it wraps, the container has no background by
|
|
26
|
+
* default; consumers can set one via `--oscd-search-field-container-color`.
|
|
27
|
+
* */
|
|
28
|
+
export declare class OscdOutlinedSearchField extends OscdOutlinedSearchField_base {
|
|
29
|
+
static scopedElements: {
|
|
30
|
+
'oscd-outlined-field': typeof OscdOutlinedField;
|
|
31
|
+
'oscd-icon': typeof OscdIcon;
|
|
32
|
+
'oscd-icon-button': typeof OscdIconButton;
|
|
33
|
+
};
|
|
34
|
+
protected readonly fieldTag: import("lit-html/static.js").StaticValue;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
|
|
2
|
+
import { OscdIcon } from '../icon/OscdIcon.js';
|
|
3
|
+
import { OscdIconButton } from '../iconbutton/OscdIconButton.js';
|
|
4
|
+
import { OutlinedSearchField } from './internal/OutlinedSearchField.js';
|
|
5
|
+
import { OscdOutlinedField } from '../field/OscdOutlinedField.js';
|
|
6
|
+
import { literal } from 'lit/static-html.js';
|
|
7
|
+
/**
|
|
8
|
+
* @tag oscd-outlined-search-field
|
|
9
|
+
* @summary An `oscd-outlined-text-field` specialized for search input.
|
|
10
|
+
*
|
|
11
|
+
* Behaves like a standard outlined text field, but comes by default with a
|
|
12
|
+
* leading search icon and a trailing "clear" button (shown once
|
|
13
|
+
* [[`value`]] is non-empty), a placeholder rendered at 50% opacity (relative
|
|
14
|
+
* to the input text color) that is hidden while the field has focus.
|
|
15
|
+
*
|
|
16
|
+
* The default leading/trailing icons can be overridden by slotting content
|
|
17
|
+
* into the `leading-icon`/`trailing-icon` slots, exactly as with
|
|
18
|
+
* `oscd-outlined-text-field`. The placeholder color can be overridden via
|
|
19
|
+
* `--oscd-search-field-placeholder-color`.
|
|
20
|
+
*
|
|
21
|
+
* Like the outlined text field it wraps, the container has no background by
|
|
22
|
+
* default; consumers can set one via `--oscd-search-field-container-color`.
|
|
23
|
+
* */
|
|
24
|
+
export class OscdOutlinedSearchField extends ScopedElementsMixin(OutlinedSearchField) {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.fieldTag = literal `oscd-outlined-field`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
OscdOutlinedSearchField.scopedElements = {
|
|
31
|
+
'oscd-outlined-field': OscdOutlinedField,
|
|
32
|
+
'oscd-icon': OscdIcon,
|
|
33
|
+
'oscd-icon-button': OscdIconButton,
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=OscdOutlinedSearchField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OscdOutlinedSearchField.js","sourceRoot":"","sources":["../../search-field/OscdOutlinedSearchField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAQ7C;;;;;;;;;;;;;;;;KAgBK;AACL,MAAM,OAAO,uBAAwB,SAAQ,mBAAmB,CAC9D,mBAAmB,CACpB;IAFD;;QAS8B,aAAQ,GAAG,OAAO,CAAA,qBAAqB,CAAC;IACtE,CAAC;;AAPQ,sCAAc,GAAG;IACtB,qBAAqB,EAAE,iBAAiB;IACxC,WAAW,EAAE,QAAQ;IACrB,kBAAkB,EAAE,cAAc;CACnC,AAJoB,CAInB","sourcesContent":["import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\n\nimport { OscdIcon } from '../icon/OscdIcon.js';\nimport { OscdIconButton } from '../iconbutton/OscdIconButton.js';\nimport { OutlinedSearchField } from './internal/OutlinedSearchField.js';\nimport { OscdOutlinedField } from '../field/OscdOutlinedField.js';\nimport { literal } from 'lit/static-html.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'oscd-outlined-search-field': OscdOutlinedSearchField;\n }\n}\n\n/**\n * @tag oscd-outlined-search-field\n * @summary An `oscd-outlined-text-field` specialized for search input.\n *\n * Behaves like a standard outlined text field, but comes by default with a\n * leading search icon and a trailing \"clear\" button (shown once\n * [[`value`]] is non-empty), a placeholder rendered at 50% opacity (relative\n * to the input text color) that is hidden while the field has focus.\n *\n * The default leading/trailing icons can be overridden by slotting content\n * into the `leading-icon`/`trailing-icon` slots, exactly as with\n * `oscd-outlined-text-field`. The placeholder color can be overridden via\n * `--oscd-search-field-placeholder-color`.\n *\n * Like the outlined text field it wraps, the container has no background by\n * default; consumers can set one via `--oscd-search-field-container-color`.\n * */\nexport class OscdOutlinedSearchField extends ScopedElementsMixin(\n OutlinedSearchField,\n) {\n static scopedElements = {\n 'oscd-outlined-field': OscdOutlinedField,\n 'oscd-icon': OscdIcon,\n 'oscd-icon-button': OscdIconButton,\n };\n\n protected override readonly fieldTag = literal`oscd-outlined-field`;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OutlinedTextField } from '@omicronenergy/oscd-material-web-base/textfield/internal/outlined-text-field.js';
|
|
2
|
+
import { CSSResultOrNative, PropertyValues, TemplateResult } from 'lit';
|
|
3
|
+
export declare class OutlinedSearchField extends OutlinedTextField {
|
|
4
|
+
clearLabel: string;
|
|
5
|
+
constructor();
|
|
6
|
+
private handleFocus;
|
|
7
|
+
private handleBlur;
|
|
8
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
9
|
+
private clear;
|
|
10
|
+
private renderDefaultClearFieldIconButton;
|
|
11
|
+
protected renderTrailingIcon(): TemplateResult<1>;
|
|
12
|
+
protected renderLeadingIcon(): TemplateResult<1>;
|
|
13
|
+
private hasCustomSlot;
|
|
14
|
+
static styles: CSSResultOrNative[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { OutlinedTextField } from '@omicronenergy/oscd-material-web-base/textfield/internal/outlined-text-field.js';
|
|
3
|
+
import { css, html, nothing, } from 'lit';
|
|
4
|
+
import { property } from 'lit/decorators.js';
|
|
5
|
+
import { styles as outlinedStyles } from '@omicronenergy/oscd-material-web-base/textfield/internal/outlined-styles.js';
|
|
6
|
+
import { styles as sharedStyles } from '@omicronenergy/oscd-material-web-base/textfield/internal/shared-styles.js';
|
|
7
|
+
function renderDefaultLeadingIcon() {
|
|
8
|
+
return html `<oscd-icon slot="leading-icon">search</oscd-icon>`;
|
|
9
|
+
}
|
|
10
|
+
export class OutlinedSearchField extends OutlinedTextField {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.clearLabel = 'Clear search';
|
|
14
|
+
this.addEventListener('focus', this.handleFocus.bind(this));
|
|
15
|
+
this.addEventListener('blur', this.handleBlur.bind(this));
|
|
16
|
+
}
|
|
17
|
+
handleFocus() {
|
|
18
|
+
this.placeholder = '';
|
|
19
|
+
}
|
|
20
|
+
handleBlur() {
|
|
21
|
+
this.placeholder = 'Search';
|
|
22
|
+
}
|
|
23
|
+
willUpdate(changedProperties) {
|
|
24
|
+
super.willUpdate(changedProperties);
|
|
25
|
+
// The search icon is always present, either as consumer content or as the
|
|
26
|
+
// default rendered by renderLeadingIcon().
|
|
27
|
+
this.hasLeadingIcon = true;
|
|
28
|
+
this.hasTrailingIcon =
|
|
29
|
+
this.hasCustomSlot('trailing-icon') || Boolean(this.value);
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.value = '';
|
|
33
|
+
this.dispatchEvent(new InputEvent('input', { bubbles: true, composed: true }));
|
|
34
|
+
this.focus();
|
|
35
|
+
}
|
|
36
|
+
renderDefaultClearFieldIconButton() {
|
|
37
|
+
if (!this.value) {
|
|
38
|
+
return html ``;
|
|
39
|
+
}
|
|
40
|
+
return html `<oscd-icon-button
|
|
41
|
+
class="default-clear-button"
|
|
42
|
+
slot="trailing-icon"
|
|
43
|
+
aria-label=${this.clearLabel}
|
|
44
|
+
@click=${() => this.clear()}
|
|
45
|
+
><oscd-icon>close</oscd-icon></oscd-icon-button
|
|
46
|
+
>`;
|
|
47
|
+
}
|
|
48
|
+
renderTrailingIcon() {
|
|
49
|
+
return html `
|
|
50
|
+
<span class="icon trailing" slot="end">
|
|
51
|
+
<slot name="trailing-icon"></slot>
|
|
52
|
+
${this.hasCustomSlot('trailing-icon')
|
|
53
|
+
? nothing
|
|
54
|
+
: this.renderDefaultClearFieldIconButton()}
|
|
55
|
+
</span>
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
renderLeadingIcon() {
|
|
59
|
+
return html `
|
|
60
|
+
<span class="icon leading" slot="start">
|
|
61
|
+
<slot name="leading-icon"></slot>
|
|
62
|
+
${this.hasCustomSlot('leading-icon')
|
|
63
|
+
? nothing
|
|
64
|
+
: renderDefaultLeadingIcon()}
|
|
65
|
+
</span>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
hasCustomSlot(slotName) {
|
|
69
|
+
return this.querySelector(`[slot="${slotName}"]`) !== null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
OutlinedSearchField.styles = [
|
|
73
|
+
sharedStyles,
|
|
74
|
+
outlinedStyles,
|
|
75
|
+
css `
|
|
76
|
+
:host {
|
|
77
|
+
--md-outlined-text-field-input-text-placeholder-color: var(
|
|
78
|
+
--oscd-search-field-placeholder-color,
|
|
79
|
+
color-mix(
|
|
80
|
+
in srgb,
|
|
81
|
+
var(
|
|
82
|
+
--md-outlined-text-field-input-text-color,
|
|
83
|
+
var(--md-sys-color-on-surface, #1d1b20)
|
|
84
|
+
)
|
|
85
|
+
50%,
|
|
86
|
+
transparent
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
`,
|
|
91
|
+
];
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: String })
|
|
94
|
+
], OutlinedSearchField.prototype, "clearLabel", void 0);
|
|
95
|
+
//# sourceMappingURL=OutlinedSearchField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutlinedSearchField.js","sourceRoot":"","sources":["../../../search-field/internal/OutlinedSearchField.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iFAAiF,CAAC;AACpH,OAAO,EAEL,GAAG,EACH,IAAI,EACJ,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,MAAM,IAAI,cAAc,E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AC;QAChB,CAAC;QAED,OAAO,IAAI,CAAA;;;mBAGI,IAAI,CAAC,UAAU;eACnB,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;;MAE3B,CAAC;IACL,CAAC;IAEkB,kBAAkB;QACnC,OAAO,IAAI,CAAA;;;UAGL,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;YACnC,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,IAAI,CAAC,iCAAiC,EAAE;;KAE/C,CAAC;IACJ,CAAC;IAEkB,iBAAiB;QAClC,OAAO,IAAI,CAAA;;;UAGL,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAClC,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,wBAAwB,EAAE;;KAEjC,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,QAA0C;QAC9D,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;IAC7D,CAAC;;AAEe,0BAAM,GAAwB;IAC5C,YAAY;IACZ,cAAc;IACd,GAAG,CAAA;;;;;;;;;;;;;;;KAeF;CACF,AAnBqB,CAmBpB;AA9FF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDACC","sourcesContent":["import { OutlinedTextField } from '@omicronenergy/oscd-material-web-base/textfield/internal/outlined-text-field.js';\nimport {\n CSSResultOrNative,\n css,\n html,\n nothing,\n PropertyValues,\n TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { styles as outlinedStyles } from '@omicronenergy/oscd-material-web-base/textfield/internal/outlined-styles.js';\nimport { styles as sharedStyles } from '@omicronenergy/oscd-material-web-base/textfield/internal/shared-styles.js';\n\nfunction renderDefaultLeadingIcon(): TemplateResult {\n return html`<oscd-icon slot=\"leading-icon\">search</oscd-icon>`;\n}\n\nexport class OutlinedSearchField extends OutlinedTextField {\n @property({ type: String })\n clearLabel = 'Clear search';\n\n constructor() {\n super();\n\n this.addEventListener('focus', this.handleFocus.bind(this));\n this.addEventListener('blur', this.handleBlur.bind(this));\n }\n\n private handleFocus() {\n this.placeholder = '';\n }\n\n private handleBlur() {\n this.placeholder = 'Search';\n }\n\n override willUpdate(changedProperties: PropertyValues<this>): void {\n super.willUpdate(changedProperties);\n\n // The search icon is always present, either as consumer content or as the\n // default rendered by renderLeadingIcon().\n this.hasLeadingIcon = true;\n this.hasTrailingIcon =\n this.hasCustomSlot('trailing-icon') || Boolean(this.value);\n }\n\n private clear(): void {\n this.value = '';\n this.dispatchEvent(\n new InputEvent('input', { bubbles: true, composed: true }),\n );\n this.focus();\n }\n\n private renderDefaultClearFieldIconButton() {\n if (!this.value) {\n return html``;\n }\n\n return html`<oscd-icon-button\n class=\"default-clear-button\"\n slot=\"trailing-icon\"\n aria-label=${this.clearLabel}\n @click=${() => this.clear()}\n ><oscd-icon>close</oscd-icon></oscd-icon-button\n >`;\n }\n\n protected override renderTrailingIcon() {\n return html`\n <span class=\"icon trailing\" slot=\"end\">\n <slot name=\"trailing-icon\"></slot>\n ${this.hasCustomSlot('trailing-icon')\n ? nothing\n : this.renderDefaultClearFieldIconButton()}\n </span>\n `;\n }\n\n protected override renderLeadingIcon() {\n return html`\n <span class=\"icon leading\" slot=\"start\">\n <slot name=\"leading-icon\"></slot>\n ${this.hasCustomSlot('leading-icon')\n ? nothing\n : renderDefaultLeadingIcon()}\n </span>\n `;\n }\n\n private hasCustomSlot(slotName: 'leading-icon' | 'trailing-icon'): boolean {\n return this.querySelector(`[slot=\"${slotName}\"]`) !== null;\n }\n\n static override styles: CSSResultOrNative[] = [\n sharedStyles,\n outlinedStyles,\n css`\n :host {\n --md-outlined-text-field-input-text-placeholder-color: var(\n --oscd-search-field-placeholder-color,\n color-mix(\n in srgb,\n var(\n --md-outlined-text-field-input-text-color,\n var(--md-sys-color-on-surface, #1d1b20)\n )\n 50%,\n transparent\n )\n );\n }\n `,\n ];\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OscdOutlinedSearchField } from './OscdOutlinedSearchField.js';
|
|
2
|
+
import '../textfield/oscd-outlined-text-field.js';
|
|
3
|
+
import '../icon/oscd-icon.js';
|
|
4
|
+
import '../iconbutton/oscd-icon-button.js';
|
|
5
|
+
window.customElements.define('oscd-outlined-search-field', OscdOutlinedSearchField);
|
|
6
|
+
//# sourceMappingURL=oscd-outlined-search-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oscd-outlined-search-field.js","sourceRoot":"","sources":["../../search-field/oscd-outlined-search-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,0CAA0C,CAAC;AAClD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mCAAmC,CAAC;AAE3C,MAAM,CAAC,cAAc,CAAC,MAAM,CAC1B,4BAA4B,EAC5B,uBAAuB,CACxB,CAAC","sourcesContent":["import { OscdOutlinedSearchField } from './OscdOutlinedSearchField.js';\nimport '../textfield/oscd-outlined-text-field.js';\nimport '../icon/oscd-icon.js';\nimport '../iconbutton/oscd-icon-button.js';\n\nwindow.customElements.define(\n 'oscd-outlined-search-field',\n OscdOutlinedSearchField,\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './oscd-outlined-search-field.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import { sendKeys } from '@web/test-runner-commands';
|
|
3
|
+
import { spy } from 'sinon';
|
|
4
|
+
import './oscd-outlined-search-field.js';
|
|
5
|
+
describe('OscdOutlinedSearchField', () => {
|
|
6
|
+
let searchField;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
searchField = await fixture(html `<oscd-outlined-search-field
|
|
9
|
+
placeholder="Search"
|
|
10
|
+
clearLabel="Clear search"
|
|
11
|
+
></oscd-outlined-search-field>`);
|
|
12
|
+
});
|
|
13
|
+
it('renders a default leading search icon', async () => {
|
|
14
|
+
const icon = searchField.shadowRoot.querySelector('oscd-icon[slot="leading-icon"]');
|
|
15
|
+
expect(icon).to.exist;
|
|
16
|
+
expect(icon.textContent).to.equal('search');
|
|
17
|
+
});
|
|
18
|
+
it('does not render a clear button while empty', () => {
|
|
19
|
+
expect(searchField.shadowRoot.querySelector('oscd-icon-button')).to.be
|
|
20
|
+
.null;
|
|
21
|
+
});
|
|
22
|
+
it('renders a clear button once a value is set', async () => {
|
|
23
|
+
searchField.value = 'abc';
|
|
24
|
+
await searchField.updateComplete;
|
|
25
|
+
const clearButton = searchField.shadowRoot.querySelector('oscd-icon-button[slot="trailing-icon"]');
|
|
26
|
+
expect(clearButton).to.exist;
|
|
27
|
+
expect(clearButton.getAttribute('aria-label')).to.equal('Clear search');
|
|
28
|
+
});
|
|
29
|
+
it('clears the value and emits input when the clear button is clicked', async () => {
|
|
30
|
+
const inputSpy = spy();
|
|
31
|
+
searchField.addEventListener('input', inputSpy);
|
|
32
|
+
searchField.value = 'abc';
|
|
33
|
+
await searchField.updateComplete;
|
|
34
|
+
const clearButton = searchField.shadowRoot.querySelector('oscd-icon-button[slot="trailing-icon"]');
|
|
35
|
+
clearButton.click();
|
|
36
|
+
await searchField.updateComplete;
|
|
37
|
+
expect(searchField.value).to.equal('');
|
|
38
|
+
expect(inputSpy).to.have.been.calledOnce;
|
|
39
|
+
});
|
|
40
|
+
it('forwards typed input to value and dispatches input events', async () => {
|
|
41
|
+
searchField.focus();
|
|
42
|
+
await sendKeys({ type: 'abc' });
|
|
43
|
+
await searchField.updateComplete;
|
|
44
|
+
expect(searchField.value).to.equal('abc');
|
|
45
|
+
});
|
|
46
|
+
it('hides the placeholder while focused', async () => {
|
|
47
|
+
const innerField = searchField.shadowRoot.querySelector('oscd-outlined-text-field');
|
|
48
|
+
expect(innerField.getAttribute('placeholder')).to.equal('Search');
|
|
49
|
+
searchField.focus();
|
|
50
|
+
await searchField.updateComplete;
|
|
51
|
+
expect(innerField.getAttribute('placeholder')).to.equal('');
|
|
52
|
+
});
|
|
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
|
+
searchField.focus();
|
|
56
|
+
await searchField.updateComplete;
|
|
57
|
+
innerField.dispatchEvent(new Event('blur'));
|
|
58
|
+
await searchField.updateComplete;
|
|
59
|
+
expect(innerField.getAttribute('placeholder')).to.equal('Search');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=oscd-outlined-search-field.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oscd-outlined-search-field.spec.js","sourceRoot":"","sources":["../../search-field/oscd-outlined-search-field.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAY,GAAG,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,iCAAiC,CAAC;AAGzC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,WAAoC,CAAC;IAEzC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,WAAW,GAAG,MAAM,OAAO,CACzB,IAAI,CAAA;;;qCAG2B,CAChC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,IAAI,GAAG,WAAW,CAAC,UAAW,CAAC,aAAa,CAChD,gCAAgC,CACjC,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACtB,MAAM,CAAC,IAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA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{ 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 const innerField = searchField.shadowRoot!.querySelector(\n 'oscd-outlined-text-field',\n )!;\n\n expect(innerField.getAttribute('placeholder')).to.equal('Search');\n\n searchField.focus();\n await searchField.updateComplete;\n\n expect(innerField.getAttribute('placeholder')).to.equal('');\n });\n\n it('restores the placeholder once focus leaves and the value is empty', async () => {\n const innerField = searchField.shadowRoot!.querySelector(\n 'oscd-outlined-text-field',\n )!;\n\n searchField.focus();\n await searchField.updateComplete;\n innerField.dispatchEvent(new Event('blur'));\n await searchField.updateComplete;\n\n expect(innerField.getAttribute('placeholder')).to.equal('Search');\n });\n});\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/web-components-vite';
|
|
2
|
+
import '../icon/oscd-icon.js';
|
|
3
|
+
import '../iconbutton/oscd-icon-button.js';
|
|
4
|
+
import './oscd-outlined-search-field.js';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
title: import("storybook/internal/csf").ComponentTitle;
|
|
7
|
+
id?: import("storybook/internal/csf").ComponentId;
|
|
8
|
+
includeStories?: RegExp | string[];
|
|
9
|
+
excludeStories?: RegExp | string[];
|
|
10
|
+
component?: string | undefined;
|
|
11
|
+
subcomponents?: Record<string, string> | undefined;
|
|
12
|
+
play?: import("storybook/internal/csf").PlayFunction<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | undefined;
|
|
13
|
+
globals?: Partial<import("storybook/internal/csf").Globals> | undefined;
|
|
14
|
+
decorators?: import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components").WebComponentsRenderer, {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
}> | import("storybook/internal/csf").DecoratorFunction<import("@storybook/web-components").WebComponentsRenderer, {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
}>[] | undefined;
|
|
19
|
+
parameters?: import("@storybook/web-components-vite").Parameters | undefined;
|
|
20
|
+
args?: Partial<import("@storybook/web-components-vite").Args> | undefined;
|
|
21
|
+
argTypes?: Partial<import("@storybook/web-components-vite").ArgTypes<import("@storybook/web-components-vite").Args>> | undefined;
|
|
22
|
+
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;
|
|
23
|
+
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;
|
|
24
|
+
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;
|
|
25
|
+
render?: import("storybook/internal/csf").ArgsStoryFn<import("@storybook/web-components").WebComponentsRenderer, import("@storybook/web-components-vite").Args> | undefined;
|
|
26
|
+
tags: import("storybook/internal/csf").Tag[];
|
|
27
|
+
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;
|
|
28
|
+
};
|
|
29
|
+
export default _default;
|
|
30
|
+
export declare const Empty: StoryObj;
|
|
31
|
+
export declare const WithValue: StoryObj;
|
|
32
|
+
export declare const Disabled: StoryObj;
|
|
33
|
+
export declare const CustomLeadingSlot: StoryObj;
|
|
34
|
+
export declare const CustomLeadingAndTrailingSlots: StoryObj;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
|
+
import '../icon/oscd-icon.js';
|
|
4
|
+
import '../iconbutton/oscd-icon-button.js';
|
|
5
|
+
import './oscd-outlined-search-field.js';
|
|
6
|
+
import { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';
|
|
7
|
+
const { args, argTypes, meta } = getStorybookMeta({
|
|
8
|
+
tagName: 'oscd-outlined-search-field',
|
|
9
|
+
options: { omitTextContent: true },
|
|
10
|
+
});
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Inputs / Outlined Search Field',
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
...meta,
|
|
15
|
+
};
|
|
16
|
+
export const Empty = {
|
|
17
|
+
argTypes,
|
|
18
|
+
args: {
|
|
19
|
+
...args,
|
|
20
|
+
placeholder: 'Search',
|
|
21
|
+
clearLabel: 'Clear search',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const WithValue = {
|
|
25
|
+
argTypes,
|
|
26
|
+
args: {
|
|
27
|
+
...args,
|
|
28
|
+
placeholder: 'Search',
|
|
29
|
+
clearLabel: 'Clear search',
|
|
30
|
+
value: 'Some text',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const Disabled = {
|
|
34
|
+
argTypes,
|
|
35
|
+
args: {
|
|
36
|
+
...args,
|
|
37
|
+
placeholder: 'Search',
|
|
38
|
+
clearLabel: 'Clear search',
|
|
39
|
+
disabled: true,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const CustomLeadingSlot = {
|
|
43
|
+
argTypes,
|
|
44
|
+
args: {
|
|
45
|
+
...args,
|
|
46
|
+
placeholder: 'Search files',
|
|
47
|
+
},
|
|
48
|
+
render: ({ placeholder }) => html `
|
|
49
|
+
<oscd-outlined-search-field .placeholder=${placeholder}>
|
|
50
|
+
<oscd-icon-button
|
|
51
|
+
slot="leading-icon"
|
|
52
|
+
aria-label="Search files"
|
|
53
|
+
@click=${() => action('leading search button')('clicked')}
|
|
54
|
+
>
|
|
55
|
+
<oscd-icon>folder</oscd-icon>
|
|
56
|
+
</oscd-icon-button>
|
|
57
|
+
</oscd-outlined-search-field>
|
|
58
|
+
`,
|
|
59
|
+
};
|
|
60
|
+
export const CustomLeadingAndTrailingSlots = {
|
|
61
|
+
argTypes,
|
|
62
|
+
args: {
|
|
63
|
+
...args,
|
|
64
|
+
placeholder: 'Search',
|
|
65
|
+
},
|
|
66
|
+
render: ({ placeholder }) => html `
|
|
67
|
+
<oscd-outlined-search-field .placeholder=${placeholder} value="Some text">
|
|
68
|
+
<oscd-icon-button
|
|
69
|
+
slot="leading-icon"
|
|
70
|
+
aria-label="Search files"
|
|
71
|
+
@click=${() => action('leading search button')('clicked')}
|
|
72
|
+
>
|
|
73
|
+
<oscd-icon>folder</oscd-icon>
|
|
74
|
+
</oscd-icon-button>
|
|
75
|
+
<oscd-icon-button
|
|
76
|
+
slot="trailing-icon"
|
|
77
|
+
aria-label="Search"
|
|
78
|
+
@click=${() => action('trailing search button')('clicked')}
|
|
79
|
+
>
|
|
80
|
+
<oscd-icon>search</oscd-icon>
|
|
81
|
+
</oscd-icon-button>
|
|
82
|
+
</oscd-outlined-search-field>
|
|
83
|
+
`,
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=oscd-outlined-search-field.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oscd-outlined-search-field.stories.js","sourceRoot":"","sources":["../../search-field/oscd-outlined-search-field.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAA0B;IACzE,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;CACnC,CAAC,CAAC;AAEH,eAAe;IACb,KAAK,EAAE,gCAAgC;IACvC,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,GAAG,IAAI;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAa;IAC7B,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,cAAc;KAC3B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAa;IACjC,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,cAAc;QAC1B,KAAK,EAAE,WAAW;KACnB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,cAAc;QAC1B,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAa;IACzC,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,WAAW,EAAE,cAAc;KAC5B;IACD,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,IAAI,CAAA;+CACY,WAAW;;;;iBAIzC,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,SAAS,CAAC;;;;;GAK9D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAa;IACrD,QAAQ;IACR,IAAI,EAAE;QACJ,GAAG,IAAI;QACP,WAAW,EAAE,QAAQ;KACtB;IACD,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,IAAI,CAAA;+CACY,WAAW;;;;iBAIzC,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,SAAS,CAAC;;;;;;;iBAOhD,GAAG,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC;;;;;GAK/D;CACF,CAAC","sourcesContent":["import type { StoryObj } from '@storybook/web-components-vite';\nimport { html } from 'lit';\nimport { action } from 'storybook/actions';\n\nimport '../icon/oscd-icon.js';\nimport '../iconbutton/oscd-icon-button.js';\nimport './oscd-outlined-search-field.js';\nimport { OscdOutlinedSearchField } from './OscdOutlinedSearchField.js';\nimport { getStorybookMeta } from '@/utils/storybook/getStorybookMeta.js';\n\nconst { args, argTypes, meta } = getStorybookMeta<OscdOutlinedSearchField>({\n tagName: 'oscd-outlined-search-field',\n options: { omitTextContent: true },\n});\n\nexport default {\n title: 'Inputs / Outlined Search Field',\n tags: ['autodocs'],\n ...meta,\n};\n\nexport const Empty: StoryObj = {\n argTypes,\n args: {\n ...args,\n placeholder: 'Search',\n clearLabel: 'Clear search',\n },\n};\n\nexport const WithValue: StoryObj = {\n argTypes,\n args: {\n ...args,\n placeholder: 'Search',\n clearLabel: 'Clear search',\n value: 'Some text',\n },\n};\n\nexport const Disabled: StoryObj = {\n argTypes,\n args: {\n ...args,\n placeholder: 'Search',\n clearLabel: 'Clear search',\n disabled: true,\n },\n};\n\nexport const CustomLeadingSlot: StoryObj = {\n argTypes,\n args: {\n ...args,\n placeholder: 'Search files',\n },\n render: ({ placeholder }) => html`\n <oscd-outlined-search-field .placeholder=${placeholder}>\n <oscd-icon-button\n slot=\"leading-icon\"\n aria-label=\"Search files\"\n @click=${() => action('leading search button')('clicked')}\n >\n <oscd-icon>folder</oscd-icon>\n </oscd-icon-button>\n </oscd-outlined-search-field>\n `,\n};\n\nexport const CustomLeadingAndTrailingSlots: StoryObj = {\n argTypes,\n args: {\n ...args,\n placeholder: 'Search',\n },\n render: ({ placeholder }) => html`\n <oscd-outlined-search-field .placeholder=${placeholder} value=\"Some text\">\n <oscd-icon-button\n slot=\"leading-icon\"\n aria-label=\"Search files\"\n @click=${() => action('leading search button')('clicked')}\n >\n <oscd-icon>folder</oscd-icon>\n </oscd-icon-button>\n <oscd-icon-button\n slot=\"trailing-icon\"\n aria-label=\"Search\"\n @click=${() => action('trailing search button')('clicked')}\n >\n <oscd-icon>search</oscd-icon>\n </oscd-icon-button>\n </oscd-outlined-search-field>\n `,\n};\n"]}
|
package/dist/tree/OscdTree.d.ts
CHANGED
|
@@ -91,7 +91,6 @@ declare global {
|
|
|
91
91
|
* @fires selected-ids-changed - Fired when user interaction changes selected IDs.
|
|
92
92
|
* @fires expanded-ids-changed - Fired when expansion state changes.
|
|
93
93
|
* @fires node-click - Fired when a row is clicked.
|
|
94
|
-
* @fires node-activate - Fired when a row is activated with the keyboard.
|
|
95
94
|
* @fires node-expand - Cancelable event fired before a row expands.
|
|
96
95
|
* @fires node-collapse - Fired after a row collapses.
|
|
97
96
|
* @fires node-toggle - Fired after a row expansion state toggles.
|
package/dist/tree/OscdTree.js
CHANGED
|
@@ -85,7 +85,6 @@ import { Tree } from './internal/Tree.js';
|
|
|
85
85
|
* @fires selected-ids-changed - Fired when user interaction changes selected IDs.
|
|
86
86
|
* @fires expanded-ids-changed - Fired when expansion state changes.
|
|
87
87
|
* @fires node-click - Fired when a row is clicked.
|
|
88
|
-
* @fires node-activate - Fired when a row is activated with the keyboard.
|
|
89
88
|
* @fires node-expand - Cancelable event fired before a row expands.
|
|
90
89
|
* @fires node-collapse - Fired after a row collapses.
|
|
91
90
|
* @fires node-toggle - Fired after a row expansion state toggles.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OscdTree.js","sourceRoot":"","sources":["../../tree/OscdTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAiB1C
|
|
1
|
+
{"version":3,"file":"OscdTree.js","sourceRoot":"","sources":["../../tree/OscdTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAiB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI;CAAG","sourcesContent":["import { Tree } from './internal/Tree.js';\nexport type {\n TreeChildrenState,\n TreeNode,\n TreeNodeEventDetail,\n TreeRenderContext,\n TreeSelectionChangeEventDetail,\n TreeSelectionMode,\n TreeTogglePosition,\n} from './internal/Tree.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'oscd-tree': OscdTree;\n }\n}\n\n/**\n * Displays hierarchical data as an accessible, keyboard-navigable tree.\n *\n * `oscd-tree` is data-driven: callers provide nested node data through `data`,\n * and the tree manages expansion, selection, active-row navigation, row\n * indentation, and ARIA attributes. Row content stays flexible through the\n * `renderItem` callback.\n *\n * The tree owns the row frame. This includes indentation, expand/collapse\n * affordances, selection affordances, keyboard handling, focus handling, and\n * accessibility attributes. `renderItem` only supplies the content rendered\n * inside each row frame.\n *\n * The expand/collapse toggle is customizable: `collapseIcon` and `expandIcon`\n * override the icon names (defaults `chevron_right` / `expand_more`), and\n * `togglePosition` places the toggle either `'leading'` (default) or\n * `'trailing'`, in which case toggles line up on the row's trailing edge\n * regardless of nesting depth. Keyboard expansion is unaffected by the toggle\n * position.\n *\n * Leaf rows have no toggle. `renderLeafAccessory` can render an interactive\n * accessory (such as a pin/unpin button) into a leaf row's toggle column so it\n * aligns with the chevrons of expandable rows. The tree isolates pointer and\n * `Enter`/`Space` interaction on the accessory so activating it does not select\n * the row; a returned focusable element adds one tab stop per row.\n *\n * A leading icon (the `start` slot of `oscd-tree-item`) occupies exactly one\n * indent step, so when only some rows have icons (e.g. iconed parents with\n * icon-less children) the children's text aligns automatically under the\n * parent's text at any depth. The single `--oscd-tree-indent-step` property\n * (default `24px`) drives both indentation and the leading icon column; set it\n * large enough to hold your icon (e.g. `40px`) when using leading icons. See\n * {@link OscdTreeItem} for details.\n *\n * Every node may provide a stable `id`. If no ID is supplied, the tree uses\n * `getNodeId` when provided, then falls back to an index-path ID such as\n * `0/1/2`. Index-path IDs are convenient for static demos but are not stable\n * when nodes are inserted, removed, sorted, filtered, or lazily loaded, and\n * should not be persisted.\n *\n * `selectedIds` and `expandedIds` are controlled state. They can be persisted\n * by the caller, but persisted IDs must be scoped to the data set/context that\n * produced them. Reset or re-key those arrays when `data` changes to a\n * different logical tree, otherwise unrelated nodes with matching IDs may\n * appear selected or expanded.\n *\n * `children` has three meanings:\n *\n * - `children === undefined`: children are unknown or not loaded yet.\n * - `children === []`: children are known and the node is a leaf.\n * - `children.length > 0`: children are known and the node is a branch.\n *\n * Expansion of nodes with unknown children can be intercepted with the\n * cancelable `node-expand` event.\n *\n * @example\n * ```ts\n * type Node = TreeNode & {\n * label: string;\n * children?: Node[];\n * };\n *\n * const data: Node[] = [\n * {\n * id: 'ied:PUB_A',\n * label: 'PUB_A',\n * children: [{ id: 'ln:TCTR1', label: 'TCTR1', children: [] }],\n * },\n * ];\n *\n * html`\n * <oscd-tree\n * .data=${data}\n * .expandedIds=${['ied:PUB_A']}\n * .renderItem=${({ node }) => html`\n * <oscd-tree-item>\n * <span slot=\"headline\">${node.label}</span>\n * </oscd-tree-item>\n * `}\n * ></oscd-tree>\n * `;\n * ```\n *\n * @fires selected-ids-changed - Fired when user interaction changes selected IDs.\n * @fires expanded-ids-changed - Fired when expansion state changes.\n * @fires node-click - Fired when a row is clicked.\n * @fires node-expand - Cancelable event fired before a row expands.\n * @fires node-collapse - Fired after a row collapses.\n * @fires node-toggle - Fired after a row expansion state toggles.\n *\n * @tagname oscd-tree\n */\nexport class OscdTree extends Tree {}\n"]}
|
|
@@ -485,4 +485,64 @@ export const Filtered = {
|
|
|
485
485
|
</div>`;
|
|
486
486
|
},
|
|
487
487
|
};
|
|
488
|
+
export const StackedKeyboardNavigation = {
|
|
489
|
+
render: () => {
|
|
490
|
+
const focusFirstTree = (event) => {
|
|
491
|
+
const button = event.currentTarget;
|
|
492
|
+
const tree = button.parentElement?.querySelector('oscd-tree');
|
|
493
|
+
if (!tree) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
tree.activeId = tree.getFirstNodeId();
|
|
497
|
+
tree.focus();
|
|
498
|
+
};
|
|
499
|
+
const handleBoundary = (event) => {
|
|
500
|
+
const currentTree = event.currentTarget;
|
|
501
|
+
const direction = event
|
|
502
|
+
.detail.direction;
|
|
503
|
+
const trees = Array.from(currentTree.parentElement?.querySelectorAll('oscd-tree') ??
|
|
504
|
+
[]);
|
|
505
|
+
const currentIndex = trees.indexOf(currentTree);
|
|
506
|
+
const targetTree = trees[currentIndex + (direction === 'last' ? 1 : -1)];
|
|
507
|
+
if (!targetTree) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
targetTree.activeId =
|
|
511
|
+
direction === 'last'
|
|
512
|
+
? targetTree.getFirstNodeId()
|
|
513
|
+
: targetTree.getLastNodeId();
|
|
514
|
+
targetTree.focus();
|
|
515
|
+
};
|
|
516
|
+
const renderStackedTree = (prefix) => html `<oscd-tree
|
|
517
|
+
.data=${[
|
|
518
|
+
{ id: `${prefix}:one`, label: `${prefix} / One`, children: [] },
|
|
519
|
+
{ id: `${prefix}:two`, label: `${prefix} / Two`, children: [] },
|
|
520
|
+
]}
|
|
521
|
+
selectionMode="none"
|
|
522
|
+
.renderItem=${renderCompactItem}
|
|
523
|
+
@navigation-boundary=${handleBoundary}
|
|
524
|
+
@selected-ids-changed=${handleSelection}
|
|
525
|
+
></oscd-tree>`;
|
|
526
|
+
return html `<div
|
|
527
|
+
class="stacked-tree-story"
|
|
528
|
+
style="display: flex; flex-direction: column; justify-self:center; gap: 8px; width: min(520px, 100%);"
|
|
529
|
+
>
|
|
530
|
+
<style>
|
|
531
|
+
.stacked-tree-story oscd-tree:focus-within {
|
|
532
|
+
outline: 2px solid var(--md-sys-color-secondary, #6750a4);
|
|
533
|
+
outline-offset: 2px;
|
|
534
|
+
border-radius: 6px;
|
|
535
|
+
}
|
|
536
|
+
</style>
|
|
537
|
+
<p>
|
|
538
|
+
Demo shows 3 Trees, with a border around the focused tree and a border
|
|
539
|
+
around the active node to show how you can use keyboard navigation
|
|
540
|
+
accross multiple trees.
|
|
541
|
+
</p>
|
|
542
|
+
<button type="button" @click=${focusFirstTree}>Focus first tree</button>
|
|
543
|
+
${renderStackedTree('Tree A')} ${renderStackedTree('Tree B')}
|
|
544
|
+
${renderStackedTree('Tree C')}
|
|
545
|
+
</div>`;
|
|
546
|
+
},
|
|
547
|
+
};
|
|
488
548
|
//# sourceMappingURL=OscdTree.stories.js.map
|