@digital-realty/ix-select 1.2.4 → 1.2.6
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
|
@@ -5,7 +5,7 @@ import '@material/web/select/outlined-select.js';
|
|
|
5
5
|
import { LitElement, PropertyValues } from 'lit';
|
|
6
6
|
import './selectoption/ix-select-option.js';
|
|
7
7
|
declare const VALUE: unique symbol;
|
|
8
|
-
declare const ixSelectBaseClass: import("@material/web/labs/behaviors/
|
|
8
|
+
declare const ixSelectBaseClass: (abstract new (...args: any[]) => import("@material/web/labs/behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("@digital-realty/ix-shared-fns/aria-forward-mixin.js").Constructor<import("@digital-realty/ix-shared-fns/aria-forward-mixin.js").AriaForwardMixinInterface>;
|
|
9
9
|
export declare class IxSelect extends ixSelectBaseClass {
|
|
10
10
|
/** @nocollapse */
|
|
11
11
|
static shadowRootOptions: ShadowRootInit;
|
package/dist/IxSelect.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
3
|
import '@digital-realty/ix-icon/ix-icon.js';
|
|
4
|
-
import { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';
|
|
5
4
|
import { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';
|
|
6
5
|
import { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '@material/web/menu/internal/menu.js';
|
|
7
6
|
import '@material/web/select/filled-select.js';
|
|
@@ -11,8 +10,10 @@ import { property, query, state } from 'lit/decorators.js';
|
|
|
11
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
11
|
import { literal, html as staticHtml } from 'lit/static-html.js';
|
|
13
12
|
import './selectoption/ix-select-option.js';
|
|
13
|
+
import { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';
|
|
14
|
+
import { spread } from '@open-wc/lit-helpers';
|
|
14
15
|
const VALUE = Symbol('value');
|
|
15
|
-
const ixSelectBaseClass =
|
|
16
|
+
const ixSelectBaseClass = AriaForwardMixin(mixinElementInternals(LitElement));
|
|
16
17
|
export class IxSelect extends ixSelectBaseClass {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments);
|
|
@@ -309,6 +310,7 @@ export class IxSelect extends ixSelectBaseClass {
|
|
|
309
310
|
style="min-width:${this.minWidth}px"
|
|
310
311
|
@focus=${this.focus}
|
|
311
312
|
@blur=${this.onBlur}
|
|
313
|
+
${spread(this.ariaAttributes)}
|
|
312
314
|
>
|
|
313
315
|
<slot></slot>
|
|
314
316
|
${this.leadingIcon
|
package/dist/IxSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxSelect.js","sourceRoot":"","sources":["../src/IxSelect.ts"],"names":[],"mappings":";;AAAA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,uCAAuC,CAAC;AAE/C,OAAO,yCAAyC,CAAC;AACjD,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAe,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,oCAAoC,CAAC;AAE5C,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAE9B,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,qBAAqB,CAAC,UAAU,C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CACtC;AAUlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;iDACmB;AAO/D;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 { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.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\nconst ixSelectBaseClass = mixinDelegatesAria(mixinElementInternals(LitElement));\n\nexport class IxSelect extends ixSelectBaseClass {\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 @property({ type: Number }) truncateLabelBy = 70;\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 * Forces the menu to be below the select element.\n */\n @property({ type: Boolean, attribute: 'menu-below' }) menuBelow = 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' | 'popover' = '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 truncateLabel() {\n const label = this.component.shadowRoot?.getElementById('label');\n if (!label) return;\n const labelContainerWidth =\n label.parentElement?.getBoundingClientRect().width;\n if (!labelContainerWidth) return;\n // Avoid truncating if the value is too short to be visable\n if (labelContainerWidth < this.truncateLabelBy * 2) return;\n label.style.setProperty(\n 'max-width',\n `${labelContainerWidth - this.truncateLabelBy}px`\n );\n label.style.setProperty('overflow', 'hidden');\n label.style.setProperty('text-overflow', 'ellipsis');\n label.style.setProperty('white-space', 'nowrap');\n }\n\n private handleSelection() {\n this.internals.setFormValue(this.component.value);\n this.syncValidity();\n this.truncateLabel();\n }\n\n private setMenuSize() {\n const select = this.shadowRoot?.querySelector('.select') as HTMLElement;\n const menu = select?.shadowRoot\n ?.querySelector('#listbox')\n ?.shadowRoot?.querySelector('.menu') as HTMLElement;\n\n if (menu.style) {\n menu.style.zIndex = '102';\n if (this.menuBelow) {\n const selectPosition = select?.getBoundingClientRect();\n const spaceBelow =\n window.innerHeight - (selectPosition.top + selectPosition.height);\n menu.style.maxHeight = `${spaceBelow * 0.8}px`;\n menu.style.insetBlockEnd = 'initial';\n menu.style.maxWidth = `${this.component.offsetWidth}px`;\n } else {\n // Set max-height to 70vh to prevent menus with many options from overflowing the viewport which\n // can cause some options to become inaccessible: https://telxapp.atlassian.net/browse/IXUAT-9459\n menu.style.maxHeight = '70vh';\n }\n }\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.setMenuSize();\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 // eslint-disable-next-line class-methods-use-this\n onBlur(e: FocusEvent) {\n // Prevent blur event from bubbling on focus in (when focus switches to options menu)\n const el = e.relatedTarget as HTMLElement;\n if (el?.tagName === 'IX-SELECT-OPTION') {\n e.stopPropagation();\n }\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=${() => {\n this.setMenuSize();\n this.dispatchEvent(\n new CustomEvent('selectMenu', {\n bubbles: true,\n composed: true,\n detail: { value: 'open' },\n })\n );\n }}\n @closing=${() => {\n this.dispatchEvent(\n new CustomEvent('selectMenu', {\n bubbles: true,\n composed: true,\n detail: { value: 'close' },\n })\n );\n }}\n class=\"select\"\n style=\"min-width:${this.minWidth}px\"\n @focus=${this.focus}\n @blur=${this.onBlur}\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"]}
|
|
1
|
+
{"version":3,"file":"IxSelect.js","sourceRoot":"","sources":["../src/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material/web/labs/behaviors/element-internals.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';\nimport { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';\nimport { spread } from '@open-wc/lit-helpers';\n\nconst VALUE = Symbol('value');\n\nconst ixSelectBaseClass = AriaForwardMixin(mixinElementInternals(LitElement));\n\nexport class IxSelect extends ixSelectBaseClass {\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 @property({ type: Number }) truncateLabelBy = 70;\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 * Forces the menu to be below the select element.\n */\n @property({ type: Boolean, attribute: 'menu-below' }) menuBelow = 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' | 'popover' = '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 truncateLabel() {\n const label = this.component.shadowRoot?.getElementById('label');\n if (!label) return;\n const labelContainerWidth =\n label.parentElement?.getBoundingClientRect().width;\n if (!labelContainerWidth) return;\n // Avoid truncating if the value is too short to be visable\n if (labelContainerWidth < this.truncateLabelBy * 2) return;\n label.style.setProperty(\n 'max-width',\n `${labelContainerWidth - this.truncateLabelBy}px`\n );\n label.style.setProperty('overflow', 'hidden');\n label.style.setProperty('text-overflow', 'ellipsis');\n label.style.setProperty('white-space', 'nowrap');\n }\n\n private handleSelection() {\n this.internals.setFormValue(this.component.value);\n this.syncValidity();\n this.truncateLabel();\n }\n\n private setMenuSize() {\n const select = this.shadowRoot?.querySelector('.select') as HTMLElement;\n const menu = select?.shadowRoot\n ?.querySelector('#listbox')\n ?.shadowRoot?.querySelector('.menu') as HTMLElement;\n\n if (menu.style) {\n menu.style.zIndex = '102';\n if (this.menuBelow) {\n const selectPosition = select?.getBoundingClientRect();\n const spaceBelow =\n window.innerHeight - (selectPosition.top + selectPosition.height);\n menu.style.maxHeight = `${spaceBelow * 0.8}px`;\n menu.style.insetBlockEnd = 'initial';\n menu.style.maxWidth = `${this.component.offsetWidth}px`;\n } else {\n // Set max-height to 70vh to prevent menus with many options from overflowing the viewport which\n // can cause some options to become inaccessible: https://telxapp.atlassian.net/browse/IXUAT-9459\n menu.style.maxHeight = '70vh';\n }\n }\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.setMenuSize();\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 // eslint-disable-next-line class-methods-use-this\n onBlur(e: FocusEvent) {\n // Prevent blur event from bubbling on focus in (when focus switches to options menu)\n const el = e.relatedTarget as HTMLElement;\n if (el?.tagName === 'IX-SELECT-OPTION') {\n e.stopPropagation();\n }\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=${() => {\n this.setMenuSize();\n this.dispatchEvent(\n new CustomEvent('selectMenu', {\n bubbles: true,\n composed: true,\n detail: { value: 'open' },\n })\n );\n }}\n @closing=${() => {\n this.dispatchEvent(\n new CustomEvent('selectMenu', {\n bubbles: true,\n composed: true,\n detail: { value: 'close' },\n })\n );\n }}\n class=\"select\"\n style=\"min-width:${this.minWidth}px\"\n @focus=${this.focus}\n @blur=${this.onBlur}\n ${spread(this.ariaAttributes)}\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"]}
|
package/dist/ix-select.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LitElement,html,nothing,css,isServer}from"lit";import{__decorate}from"tslib";import"@digital-realty/ix-icon/ix-icon.js";import{
|
|
1
|
+
import{LitElement,html,nothing,css,isServer}from"lit";import{__decorate}from"tslib";import"@digital-realty/ix-icon/ix-icon.js";import{mixinElementInternals}from"@material/web/labs/behaviors/element-internals.js";import{DEFAULT_TYPEAHEAD_BUFFER_TIME}from"@material/web/menu/internal/menu.js";import"@material/web/select/filled-select.js";import"@material/web/select/outlined-select.js";import{property,query,queryAssignedElements,queryAssignedNodes,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{literal,html as html$1}from"lit/static-html.js";import{styles}from"@material/web/menu/internal/menuitem/menu-item-styles.js";import"@material/web/ripple/ripple.js";import"@material/web/focus/md-focus-ring.js";import"@material/web/labs/item/item.js";import{classMap}from"lit/directives/class-map.js";import{mixinDelegatesAria}from"@material/web/internal/aria/delegate.js";import{MenuItemController}from"@material/web/menu/internal/controllers/menuItemController.js";import{AriaForwardMixin}from"@digital-realty/ix-shared-fns/aria-forward-mixin.js";import{spread}from"@open-wc/lit-helpers";function createRequestSelectionEvent(){return new Event("request-selection",{bubbles:!0,composed:!0})}function createRequestDeselectionEvent(){return new Event("request-deselection",{bubbles:!0,composed:!0})}class SelectOptionController{get role(){return this.menuItemController.role}get typeaheadText(){return this.menuItemController.typeaheadText}setTypeaheadText(e){this.menuItemController.setTypeaheadText(e)}get displayText(){if(null!==this.internalDisplayText)return this.internalDisplayText;var e=this.getHeadlineElements();let t=[];return e.forEach(e=>{e.textContent&&e.textContent.trim()&&t.push(e.textContent.trim())}),t.join(" ")}setDisplayText(e){this.internalDisplayText=e}constructor(e,t){this.host=e,this.internalDisplayText=null,this.lastSelected=this.host.selected,this.firstUpdate=!0,this.onClick=()=>{this.menuItemController.onClick()},this.onKeydown=e=>{this.menuItemController.onKeydown(e)},this.menuItemController=new MenuItemController(e,t),this.getHeadlineElements=t.getHeadlineElements,e.addController(this)}hostUpdate(){this.lastSelected!==this.host.selected&&(this.host.ariaSelected=this.host.selected?"true":"false")}hostUpdated(){this.lastSelected===this.host.selected||this.firstUpdate||(this.host.selected?this.host.dispatchEvent(createRequestSelectionEvent()):this.host.dispatchEvent(createRequestDeselectionEvent())),this.lastSelected=this.host.selected,this.firstUpdate=!1}}let selectOptionBaseClass=mixinDelegatesAria(LitElement);class IxSelectOption extends selectOptionBaseClass{constructor(){super(...arguments),this.disabled=!1,this.isMenuItem=!0,this.selected=!1,this.value="",this.type="option",this.selectOptionController=new SelectOptionController(this,{getHeadlineElements:()=>this.headlineElements,getSupportingTextElements:()=>this.supportingTextElements,getDefaultElements:()=>this.defaultElements,getInteractiveElement:()=>this.listItemRoot})}get typeaheadText(){return this.selectOptionController.typeaheadText}set typeaheadText(e){this.selectOptionController.setTypeaheadText(e)}get displayText(){return this.selectOptionController.displayText}set displayText(e){this.selectOptionController.setDisplayText(e)}render(){return this.renderListItem(html`<md-item><div slot="container">${this.renderRipple()} ${this.renderFocusRing()}</div><slot name="start" slot="start"></slot><slot name="end" slot="end"></slot>${this.renderBody()}</md-item>`)}renderListItem(e){return html`<li id="item" tabindex="${this.disabled?-1:0}" role="${this.selectOptionController.role}" aria-label="${this.ariaLabel||nothing}" aria-selected="${this.ariaSelected||nothing}" aria-checked="${this.ariaChecked||nothing}" aria-expanded="${this.ariaExpanded||nothing}" aria-haspopup="${this.ariaHasPopup||nothing}" class="list-item ${classMap(this.getRenderClasses())}" @click="${this.selectOptionController.onClick}" @keydown="${this.selectOptionController.onKeydown}">${e}</li>`}renderRipple(){return html`<md-ripple part="ripple" for="item" ?disabled="${this.disabled}"></md-ripple>`}renderFocusRing(){return html`<md-focus-ring part="focus-ring" for="item" inward></md-focus-ring>`}getRenderClasses(){return{disabled:this.disabled,selected:this.selected}}renderBody(){return html`<slot></slot><slot name="overline" slot="overline"></slot><slot name="headline" slot="headline"></slot><slot name="supporting-text" slot="supporting-text"></slot><slot name="trailing-supporting-text" slot="trailing-supporting-text"></slot>`}focus(){var e;null!=(e=this.listItemRoot)&&e.focus()}}IxSelectOption.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},__decorate([property({type:Boolean,reflect:!0})],IxSelectOption.prototype,"disabled",void 0),__decorate([property({type:Boolean,attribute:"md-menu-item",reflect:!0})],IxSelectOption.prototype,"isMenuItem",void 0),__decorate([property({type:Boolean})],IxSelectOption.prototype,"selected",void 0),__decorate([property()],IxSelectOption.prototype,"value",void 0),__decorate([query(".list-item")],IxSelectOption.prototype,"listItemRoot",void 0),__decorate([queryAssignedElements({slot:"headline"})],IxSelectOption.prototype,"headlineElements",void 0),__decorate([queryAssignedElements({slot:"supporting-text"})],IxSelectOption.prototype,"supportingTextElements",void 0),__decorate([queryAssignedNodes({slot:""})],IxSelectOption.prototype,"defaultElements",void 0),__decorate([property({attribute:"typeahead-text"})],IxSelectOption.prototype,"typeaheadText",null),__decorate([property({attribute:"display-text"})],IxSelectOption.prototype,"displayText",null);class IxSelectOptionStyled extends IxSelectOption{}var _a;IxSelectOptionStyled.styles=[styles,css`ix-icon{font-size:1.5rem;display:block}[slot=end]{margin-right:2rem}[slot=start]{margin-right:-.4rem}`],window.customElements.define("ix-select-option",IxSelectOptionStyled);let VALUE=Symbol("value"),ixSelectBaseClass=AriaForwardMixin(mixinElementInternals(LitElement));class IxSelect extends ixSelectBaseClass{constructor(){super(...arguments),this.minWidth=0,this.wideMenu=!1,this.truncateLabelBy=70,this.filled=!1,this.label="",this.quick=!1,this.required=!1,this.disabled=!1,this.errorText="",this.supportingText="",this.error=!1,this.menuBelow=!1,this.displayText="",this.leadingIcon="",this.trailingIcon="",this.menuPositioning="absolute",this.typeaheadDelay=DEFAULT_TYPEAHEAD_BUFFER_TIME,this.selectedIndex=-1,this.nativeError=!1,this.nativeErrorText="",this.internals=this.attachInternals(),this.customValidationMessage="",this[_a]="",this.handleResize=()=>{this.minWidth=0}}get hasError(){return this.error||this.nativeError}get form(){return this.internals.form}get labels(){return this.internals.labels}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}set name(e){this.setAttribute("name",e)}get validity(){return this.syncValidity(),this.internals.validity}get value(){return this[VALUE]=this.component.value,this[VALUE]}set value(e){isServer||(this.component.value=e)}get validationMessage(){return this.syncValidity(),this.internals.validationMessage}truncateLabel(){var e,t=null==(t=this.component.shadowRoot)?void 0:t.getElementById("label");!t||!(e=null==(e=t.parentElement)?void 0:e.getBoundingClientRect().width)||e<2*this.truncateLabelBy||(t.style.setProperty("max-width",e-this.truncateLabelBy+"px"),t.style.setProperty("overflow","hidden"),t.style.setProperty("text-overflow","ellipsis"),t.style.setProperty("white-space","nowrap"))}handleSelection(){this.internals.setFormValue(this.component.value),this.syncValidity(),this.truncateLabel()}setMenuSize(){var e=null==(e=this.shadowRoot)?void 0:e.querySelector(".select"),t=null==(t=null==(t=null==(t=null==e?void 0:e.shadowRoot)?void 0:t.querySelector("#listbox"))?void 0:t.shadowRoot)?void 0:t.querySelector(".menu");t.style&&(t.style.zIndex="102",this.menuBelow?(e=null==e?void 0:e.getBoundingClientRect(),e=window.innerHeight-(e.top+e.height),t.style.maxHeight=.8*e+"px",t.style.insetBlockEnd="initial",t.style.maxWidth=this.component.offsetWidth+"px"):t.style.maxHeight="70vh"),this.wideMenu&&(this.minWidth=this.component.offsetWidth)}async getUpdateComplete(){return await super.getUpdateComplete(),await this.component.updateComplete,this.setMenuSize(),this.internals.setFormValue(this.component.value),!0}async updated(e){e.has("required")&&this.syncValidity(),await this.getUpdateComplete()}getErrorText(){return this.error?this.errorText:this.nativeErrorText}async syncValidity(){var e=this.required&&!this.component.value,t=!!this.customValidationMessage,i=this.customValidationMessage||e&&this.getRequiredValidationMessage()||"";this.internals.setValidity({valueMissing:e,customError:t},i,this.component)}getRequiredValidationMessage(){var e=document.createElement("select");return e.required=!0,e.validationMessage}checkValidity(){return this.syncValidity(),this.internals.checkValidity()}reportValidity(){return this.component.reportValidity()}setCustomValidity(e){this.customValidationMessage=e,this.syncValidity()}focus(){var e;null!=(e=null==(e=this.component.shadowRoot)?void 0:e.querySelector(".field"))&&e.focus()}onBlur(e){var t=e.relatedTarget;"IX-SELECT-OPTION"===(null==t?void 0:t.tagName)&&e.stopPropagation()}reset(){this.component.reset(),this.internals.setFormValue(this.component.value)}formResetCallback(){this.reset()}formStateRestoreCallback(e){this.value=e}connectedCallback(){super.connectedCallback(),!isServer&&this.wideMenu&&window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),!isServer&&this.wideMenu&&window.removeEventListener("resize",this.handleResize)}render(){var e=this.filled?literal`md-filled-select`:literal`md-outlined-select`,t=this.label||this.ariaLabel;return html$1`<${e}
|
|
2
2
|
?disabled=${this.disabled}
|
|
3
3
|
?quick=${this.quick}
|
|
4
4
|
?error=${this.hasError}
|
|
@@ -21,6 +21,7 @@ import{LitElement,html,nothing,css,isServer}from"lit";import{__decorate}from"tsl
|
|
|
21
21
|
style="min-width:${this.minWidth}px"
|
|
22
22
|
@focus=${this.focus}
|
|
23
23
|
@blur=${this.onBlur}
|
|
24
|
+
${spread(this.ariaAttributes)}
|
|
24
25
|
>
|
|
25
26
|
<slot></slot>
|
|
26
27
|
${this.leadingIcon?html`<ix-icon slot="leading-icon">${this.leadingIcon}</ix-icon>`:nothing}
|
|
@@ -49,8 +49,6 @@ export declare class IxSelectOption extends selectOptionBaseClass implements Sel
|
|
|
49
49
|
delegatesFocus: boolean;
|
|
50
50
|
mode: ShadowRootMode;
|
|
51
51
|
slotAssignment?: SlotAssignmentMode | undefined;
|
|
52
|
-
customElements?: CustomElementRegistry | undefined;
|
|
53
|
-
registry?: CustomElementRegistry | undefined;
|
|
54
52
|
};
|
|
55
53
|
/**
|
|
56
54
|
* Disables the item and makes it non-selectable and non-interactive.
|
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.2.
|
|
6
|
+
"version": "1.2.6",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
"storybook:build": "tsc && npm run analyze -- --exclude dist && build-storybook"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@digital-realty/ix-icon": "^1.2.
|
|
34
|
+
"@digital-realty/ix-icon": "^1.2.4",
|
|
35
|
+
"@digital-realty/ix-shared-fns": "1.0.1",
|
|
35
36
|
"@lit/react": "^1.0.2",
|
|
36
37
|
"@material/web": "2.4.0",
|
|
38
|
+
"@open-wc/lit-helpers": "^0.7.0",
|
|
37
39
|
"lit": "^3.2.1",
|
|
38
40
|
"react": "^18.2.0"
|
|
39
41
|
},
|
|
@@ -109,5 +111,5 @@
|
|
|
109
111
|
"README.md",
|
|
110
112
|
"LICENSE"
|
|
111
113
|
],
|
|
112
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "ab315b433acc9b12065e1a2038a2bc3a7c07487f"
|
|
113
115
|
}
|