@digital-realty/ix-select 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/IxSelect.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Select } from '@material/web/select/internal/select.js';
|
|
1
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
3
2
|
import '@material/web/select/filled-select.js';
|
|
3
|
+
import { Select } from '@material/web/select/internal/select.js';
|
|
4
4
|
import '@material/web/select/outlined-select.js';
|
|
5
|
-
import '
|
|
5
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
6
6
|
import './selectoption/ix-select-option.js';
|
|
7
7
|
declare const VALUE: unique symbol;
|
|
8
8
|
export declare class IxSelect extends LitElement {
|
|
@@ -107,7 +107,7 @@ export declare class IxSelect extends LitElement {
|
|
|
107
107
|
private handleSelection;
|
|
108
108
|
private handleOpening;
|
|
109
109
|
getUpdateComplete(): Promise<boolean>;
|
|
110
|
-
protected updated(changed: PropertyValues<Select>): void
|
|
110
|
+
protected updated(changed: PropertyValues<Select>): Promise<void>;
|
|
111
111
|
private getErrorText;
|
|
112
112
|
private syncValidity;
|
|
113
113
|
private getRequiredValidationMessage;
|
|
@@ -126,6 +126,6 @@ export declare class IxSelect extends LitElement {
|
|
|
126
126
|
formStateRestoreCallback(newState: string): void;
|
|
127
127
|
connectedCallback(): void;
|
|
128
128
|
disconnectedCallback(): void;
|
|
129
|
-
render(): import("lit
|
|
129
|
+
render(): import("lit").TemplateResult<1 | 2>;
|
|
130
130
|
}
|
|
131
131
|
export {};
|
package/dist/IxSelect.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
|
-
import
|
|
4
|
-
import { html as staticHtml, literal } from 'lit/static-html.js';
|
|
5
|
-
import { property, query, state } from 'lit/decorators.js';
|
|
6
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
3
|
+
import '@digital-realty/ix-icon/ix-icon.js';
|
|
7
4
|
import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
|
|
8
5
|
import { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '@material/web/menu/internal/menu.js';
|
|
9
6
|
import '@material/web/select/filled-select.js';
|
|
10
7
|
import '@material/web/select/outlined-select.js';
|
|
11
|
-
import '
|
|
8
|
+
import { LitElement, html, isServer, nothing } from 'lit';
|
|
9
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { literal, html as staticHtml } from 'lit/static-html.js';
|
|
12
12
|
import './selectoption/ix-select-option.js';
|
|
13
13
|
const VALUE = Symbol('value');
|
|
14
14
|
export class IxSelect extends LitElement {
|
|
@@ -151,10 +151,11 @@ export class IxSelect extends LitElement {
|
|
|
151
151
|
this.internals.setFormValue(this.component.value);
|
|
152
152
|
return true;
|
|
153
153
|
}
|
|
154
|
-
updated(changed) {
|
|
154
|
+
async updated(changed) {
|
|
155
155
|
if (changed.has('required')) {
|
|
156
156
|
this.syncValidity();
|
|
157
157
|
}
|
|
158
|
+
await this.getUpdateComplete();
|
|
158
159
|
}
|
|
159
160
|
getErrorText() {
|
|
160
161
|
return this.error ? this.errorText : this.nativeErrorText;
|
|
@@ -194,6 +195,7 @@ export class IxSelect extends LitElement {
|
|
|
194
195
|
*/
|
|
195
196
|
reset() {
|
|
196
197
|
this.component.reset();
|
|
198
|
+
this.internals.setFormValue(this.component.value);
|
|
197
199
|
}
|
|
198
200
|
/** @private */
|
|
199
201
|
formResetCallback() {
|
package/dist/IxSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxSelect.js","sourceRoot":"","sources":["../src/IxSelect.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,QAAQ,EAAE,MA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,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAkB;AAMxE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACtC;AAMjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACtC;AAUlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;iDACO;AAOnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;gDACV;AAU/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;+CACrC;AAEV;IAAR,KAAK,EAAE;6CAA6B;AAE5B;IAAR,KAAK,EAAE;iDAA8B","sourcesContent":["import { html, LitElement, nothing, PropertyValues, isServer } from 'lit';\nimport { html as staticHtml, StaticValue, literal } from 'lit/static-html.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport { Select } from '@material/web/select/internal/select.js';\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '@material/web/menu/internal/menu.js';\nimport '@material/web/select/filled-select.js';\nimport '@material/web/select/outlined-select.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport './selectoption/ix-select-option.js';\n\nconst VALUE = Symbol('value');\n\nexport class IxSelect extends LitElement {\n static {\n requestUpdateOnAriaChange(IxSelect);\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n @query('.select') component!: Select;\n\n @property({ type: Number }) minWidth = 0;\n\n /**\n * Whether or not the drop-down menu should be at least the width of the select element.\n */\n @property({ type: Boolean, reflect: true, attribute: 'wide-menu' }) wideMenu =\n false;\n\n /**\n * The switch between filled and outlined.\n */\n @property({ type: Boolean, reflect: true }) filled = false;\n\n /**\n * The floating label for the field.\n */\n @property() label: string = '';\n\n /**\n * Opens the menu synchronously with no animation.\n */\n @property({ type: Boolean }) quick = false;\n\n /**\n * Whether or not the select is required.\n */\n @property({ type: Boolean }) required = false;\n\n /**\n * Disables the select.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * This error message overrides the error message displayed by\n * `reportValidity()`.\n */\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n /**\n * Conveys additional information below the select, such as how it should\n * be used.\n */\n @property({ type: String, attribute: 'supporting-text' }) supportingText = '';\n\n /**\n * Gets or sets whether or not the select is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n /**\n * Text to display in the field. Only set for SSR.\n */\n @property({ type: String, attribute: 'display-text' }) displayText = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'leading-icon', reflect: true })\n leadingIcon = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'trailing-icon', reflect: true })\n trailingIcon = '';\n\n /**\n * Whether or not the underlying md-menu should be position: fixed to display\n * in a top-level manner, or position: absolute.\n *\n * position:fixed is useful for cases where select is inside of another\n * element with stacking context and hidden overflows such as `md-dialog`.\n */\n @property({ attribute: 'menu-positioning' })\n menuPositioning: 'absolute' | 'fixed' = 'absolute';\n\n /**\n * The max time between the keystrokes of the typeahead select / menu behavior\n * before it clears the typeahead buffer.\n */\n @property({ type: Number, attribute: 'typeahead-delay' })\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n\n /**\n * The index of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `selectedIndex` setting `selectedIndex` will incur a\n * DOM query.\n */\n @property({ type: Number, attribute: 'selected-index' })\n selectedIndex = -1;\n\n @state() private nativeError = false;\n\n @state() private nativeErrorText = '';\n\n private get hasError() {\n return this.error || this.nativeError;\n }\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n private customValidationMessage = '';\n\n get form() {\n return this.internals.form;\n }\n\n get labels() {\n return this.internals.labels;\n }\n\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n get validity() {\n this.syncValidity();\n return this.internals.validity;\n }\n\n get value() {\n this[VALUE] = this.component.value;\n return this[VALUE];\n }\n\n set value(value: string) {\n if (isServer) return;\n this.component.value = value;\n }\n\n [VALUE] = '';\n\n get validationMessage() {\n this.syncValidity();\n return this.internals.validationMessage;\n }\n\n private handleSelection() {\n this.internals.setFormValue(this.component.value);\n this.syncValidity();\n }\n\n private handleOpening() {\n if (this.wideMenu) {\n this.minWidth = this.component.offsetWidth;\n }\n }\n\n async getUpdateComplete(): Promise<boolean> {\n await super.getUpdateComplete();\n await this.component.updateComplete;\n this.internals.setFormValue(this.component.value);\n return true;\n }\n\n protected override updated(changed: PropertyValues<Select>) {\n if (changed.has('required')) {\n this.syncValidity();\n }\n }\n\n private getErrorText() {\n return this.error ? this.errorText : this.nativeErrorText;\n }\n\n private async syncValidity() {\n const valueMissing = this.required && !this.component.value;\n const customError = !!this.customValidationMessage;\n const validationMessage =\n this.customValidationMessage ||\n (valueMissing && this.getRequiredValidationMessage()) ||\n '';\n\n this.internals.setValidity(\n { valueMissing, customError },\n validationMessage,\n this.component\n );\n }\n\n // Returns the platform `<select>` validation message for i18n.\n // eslint-disable-next-line class-methods-use-this\n private getRequiredValidationMessage() {\n const select = document.createElement('select');\n select.required = true;\n return select.validationMessage;\n }\n\n private handleResize = () => {\n this.minWidth = 0;\n };\n\n checkValidity() {\n this.syncValidity();\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.component.reportValidity();\n }\n\n setCustomValidity(error: string) {\n this.customValidationMessage = error;\n this.syncValidity();\n }\n\n focus() {\n (\n this.component.shadowRoot?.querySelector('.field') as HTMLFormElement\n )?.focus();\n }\n\n /**\n * Reset the select to its default value.\n */\n reset() {\n this.component.reset();\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /** @private */\n formStateRestoreCallback(newState: string) {\n this.value = newState;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n if (!isServer && this.wideMenu) {\n window.addEventListener('resize', this.handleResize);\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (!isServer && this.wideMenu) {\n window.removeEventListener('resize', this.handleResize);\n }\n }\n\n override render() {\n const tag: StaticValue = this.filled\n ? literal`md-filled-select`\n : literal`md-outlined-select`;\n\n const ariaLabel = this.label || (this as ARIAMixinStrict).ariaLabel;\n\n return staticHtml`<${tag}\n ?disabled=${this.disabled}\n ?quick=${this.quick}\n ?error=${this.hasError}\n ?required=${this.required}\n ?has-leading-icon=${this.leadingIcon.length > 0}\n aria-label=${ariaLabel || nothing}\n tabindex=${ifDefined(this.disabled ? undefined : '0')}\n menu-positioning=${this.menuPositioning}\n typeahead-delay=${this.typeaheadDelay}\n supporting-text=${this.supportingText}\n error-text=${this.getErrorText()}\n selected-index=${ifDefined(\n this.selectedIndex === -1 ? undefined : this.selectedIndex\n )}\n display-text=${this.displayText}\n label=${this.label}\n name=${this.name}\n @request-selection=${this.handleSelection}\n @opening=${this.handleOpening}\n class=\"select\"\n style=\"min-width:${this.minWidth}px\"\n @focus=${this.focus}\n >\n <slot></slot>\n ${\n this.leadingIcon\n ? html`<ix-icon slot=\"leading-icon\">${this.leadingIcon}</ix-icon>`\n : nothing\n }\n ${\n this.trailingIcon\n ? html`<ix-icon slot=\"trailing-icon\"\n >${this.trailingIcon}</ix-icon\n >`\n : nothing\n }\n <slot slot=\"aria-describedby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E,CAAC;0CAAkB;AAUR;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;2CAAgB;AAMV;IAAzD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;gDAAqB;AAQlC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAAe;AAKH;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAkB;AAMxE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CACtC;AAMjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACtC;AAUlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;iDACO;AAOnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;gDACV;AAU/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;+CACrC;AAEV;IAAR,KAAK,EAAE;6CAA6B;AAE5B;IAAR,KAAK,EAAE;iDAA8B","sourcesContent":["import '@digital-realty/ix-icon/ix-icon.js';\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '@material/web/menu/internal/menu.js';\nimport '@material/web/select/filled-select.js';\nimport { Select } from '@material/web/select/internal/select.js';\nimport '@material/web/select/outlined-select.js';\nimport { LitElement, PropertyValues, html, isServer, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { StaticValue, literal, html as staticHtml } from 'lit/static-html.js';\nimport './selectoption/ix-select-option.js';\n\nconst VALUE = Symbol('value');\n\nexport class IxSelect extends LitElement {\n static {\n requestUpdateOnAriaChange(IxSelect);\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n @query('.select') component!: Select;\n\n @property({ type: Number }) minWidth = 0;\n\n /**\n * Whether or not the drop-down menu should be at least the width of the select element.\n */\n @property({ type: Boolean, reflect: true, attribute: 'wide-menu' }) wideMenu =\n false;\n\n /**\n * The switch between filled and outlined.\n */\n @property({ type: Boolean, reflect: true }) filled = false;\n\n /**\n * The floating label for the field.\n */\n @property() label: string = '';\n\n /**\n * Opens the menu synchronously with no animation.\n */\n @property({ type: Boolean }) quick = false;\n\n /**\n * Whether or not the select is required.\n */\n @property({ type: Boolean }) required = false;\n\n /**\n * Disables the select.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * This error message overrides the error message displayed by\n * `reportValidity()`.\n */\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n /**\n * Conveys additional information below the select, such as how it should\n * be used.\n */\n @property({ type: String, attribute: 'supporting-text' }) supportingText = '';\n\n /**\n * Gets or sets whether or not the select is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n /**\n * Text to display in the field. Only set for SSR.\n */\n @property({ type: String, attribute: 'display-text' }) displayText = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'leading-icon', reflect: true })\n leadingIcon = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'trailing-icon', reflect: true })\n trailingIcon = '';\n\n /**\n * Whether or not the underlying md-menu should be position: fixed to display\n * in a top-level manner, or position: absolute.\n *\n * position:fixed is useful for cases where select is inside of another\n * element with stacking context and hidden overflows such as `md-dialog`.\n */\n @property({ attribute: 'menu-positioning' })\n menuPositioning: 'absolute' | 'fixed' = 'absolute';\n\n /**\n * The max time between the keystrokes of the typeahead select / menu behavior\n * before it clears the typeahead buffer.\n */\n @property({ type: Number, attribute: 'typeahead-delay' })\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n\n /**\n * The index of the currently selected option.\n *\n * Note: For SSR, set `[selected]` on the requested option and `displayText`\n * rather than setting `selectedIndex` setting `selectedIndex` will incur a\n * DOM query.\n */\n @property({ type: Number, attribute: 'selected-index' })\n selectedIndex = -1;\n\n @state() private nativeError = false;\n\n @state() private nativeErrorText = '';\n\n private get hasError() {\n return this.error || this.nativeError;\n }\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n private customValidationMessage = '';\n\n get form() {\n return this.internals.form;\n }\n\n get labels() {\n return this.internals.labels;\n }\n\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n get validity() {\n this.syncValidity();\n return this.internals.validity;\n }\n\n get value() {\n this[VALUE] = this.component.value;\n return this[VALUE];\n }\n\n set value(value: string) {\n if (isServer) return;\n this.component.value = value;\n }\n\n [VALUE] = '';\n\n get validationMessage() {\n this.syncValidity();\n return this.internals.validationMessage;\n }\n\n private handleSelection() {\n this.internals.setFormValue(this.component.value);\n this.syncValidity();\n }\n\n private handleOpening() {\n if (this.wideMenu) {\n this.minWidth = this.component.offsetWidth;\n }\n }\n\n async getUpdateComplete(): Promise<boolean> {\n await super.getUpdateComplete();\n await this.component.updateComplete;\n this.internals.setFormValue(this.component.value);\n return true;\n }\n\n protected override async updated(changed: PropertyValues<Select>) {\n if (changed.has('required')) {\n this.syncValidity();\n }\n\n await this.getUpdateComplete();\n }\n\n private getErrorText() {\n return this.error ? this.errorText : this.nativeErrorText;\n }\n\n private async syncValidity() {\n const valueMissing = this.required && !this.component.value;\n const customError = !!this.customValidationMessage;\n const validationMessage =\n this.customValidationMessage ||\n (valueMissing && this.getRequiredValidationMessage()) ||\n '';\n\n this.internals.setValidity(\n { valueMissing, customError },\n validationMessage,\n this.component\n );\n }\n\n // Returns the platform `<select>` validation message for i18n.\n // eslint-disable-next-line class-methods-use-this\n private getRequiredValidationMessage() {\n const select = document.createElement('select');\n select.required = true;\n return select.validationMessage;\n }\n\n private handleResize = () => {\n this.minWidth = 0;\n };\n\n checkValidity() {\n this.syncValidity();\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.component.reportValidity();\n }\n\n setCustomValidity(error: string) {\n this.customValidationMessage = error;\n this.syncValidity();\n }\n\n focus() {\n (\n this.component.shadowRoot?.querySelector('.field') as HTMLFormElement\n )?.focus();\n }\n\n /**\n * Reset the select to its default value.\n */\n reset() {\n this.component.reset();\n this.internals.setFormValue(this.component.value);\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /** @private */\n formStateRestoreCallback(newState: string) {\n this.value = newState;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n if (!isServer && this.wideMenu) {\n window.addEventListener('resize', this.handleResize);\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (!isServer && this.wideMenu) {\n window.removeEventListener('resize', this.handleResize);\n }\n }\n\n override render() {\n const tag: StaticValue = this.filled\n ? literal`md-filled-select`\n : literal`md-outlined-select`;\n\n const ariaLabel = this.label || (this as ARIAMixinStrict).ariaLabel;\n\n return staticHtml`<${tag}\n ?disabled=${this.disabled}\n ?quick=${this.quick}\n ?error=${this.hasError}\n ?required=${this.required}\n ?has-leading-icon=${this.leadingIcon.length > 0}\n aria-label=${ariaLabel || nothing}\n tabindex=${ifDefined(this.disabled ? undefined : '0')}\n menu-positioning=${this.menuPositioning}\n typeahead-delay=${this.typeaheadDelay}\n supporting-text=${this.supportingText}\n error-text=${this.getErrorText()}\n selected-index=${ifDefined(\n this.selectedIndex === -1 ? undefined : this.selectedIndex\n )}\n display-text=${this.displayText}\n label=${this.label}\n name=${this.name}\n @request-selection=${this.handleSelection}\n @opening=${this.handleOpening}\n class=\"select\"\n style=\"min-width:${this.minWidth}px\"\n @focus=${this.focus}\n >\n <slot></slot>\n ${\n this.leadingIcon\n ? html`<ix-icon slot=\"leading-icon\">${this.leadingIcon}</ix-icon>`\n : nothing\n }\n ${\n this.trailingIcon\n ? html`<ix-icon slot=\"trailing-icon\"\n >${this.trailingIcon}</ix-icon\n >`\n : nothing\n }\n <slot slot=\"aria-describedby\" name=\"aria-describedby\"></slot>\n </${tag}>`;\n }\n}\n"]}
|
|
@@ -57,21 +57,21 @@ export declare class IxSelectOption extends LitElement implements SelectOption {
|
|
|
57
57
|
get displayText(): string;
|
|
58
58
|
set displayText(text: string);
|
|
59
59
|
private readonly selectOptionController;
|
|
60
|
-
protected render(): import("lit
|
|
60
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
61
61
|
/**
|
|
62
62
|
* Renders the root list item.
|
|
63
63
|
*
|
|
64
64
|
* @param content the child content of the list item.
|
|
65
65
|
*/
|
|
66
|
-
protected renderListItem(content: unknown): import("lit
|
|
66
|
+
protected renderListItem(content: unknown): import("lit").TemplateResult<1>;
|
|
67
67
|
/**
|
|
68
68
|
* Handles rendering of the ripple element.
|
|
69
69
|
*/
|
|
70
|
-
protected renderRipple(): import("lit
|
|
70
|
+
protected renderRipple(): import("lit").TemplateResult<1>;
|
|
71
71
|
/**
|
|
72
72
|
* Handles rendering of the focus ring.
|
|
73
73
|
*/
|
|
74
|
-
protected renderFocusRing(): import("lit
|
|
74
|
+
protected renderFocusRing(): import("lit").TemplateResult<1>;
|
|
75
75
|
/**
|
|
76
76
|
* Classes applied to the list item root.
|
|
77
77
|
*/
|
|
@@ -79,6 +79,6 @@ export declare class IxSelectOption extends LitElement implements SelectOption {
|
|
|
79
79
|
/**
|
|
80
80
|
* Handles rendering the headline and supporting text.
|
|
81
81
|
*/
|
|
82
|
-
protected renderBody(): import("lit
|
|
82
|
+
protected renderBody(): import("lit").TemplateResult<1>;
|
|
83
83
|
focus(): void;
|
|
84
84
|
}
|
|
@@ -59,7 +59,7 @@ export declare class SelectOptionController implements ReactiveController {
|
|
|
59
59
|
/**
|
|
60
60
|
* The recommended role of the select option.
|
|
61
61
|
*/
|
|
62
|
-
get role(): "
|
|
62
|
+
get role(): "menuitem" | "option";
|
|
63
63
|
/**
|
|
64
64
|
* The text that is selectable via typeahead. If not set, defaults to the
|
|
65
65
|
* innerText of the item slotted into the `"headline"` slot.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-select following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "interxion",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.14",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"README.md",
|
|
105
105
|
"LICENSE"
|
|
106
106
|
],
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "3f03e0e887e1a3fdbeeba66e270abbb74ae7a95b"
|
|
108
108
|
}
|