@digital-realty/ix-select 1.2.3 → 1.2.5
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 +2 -1
- package/dist/IxSelect.js +4 -5
- package/dist/IxSelect.js.map +1 -1
- package/dist/ix-select.min.js +2 -2
- package/dist/selectoption/IxSelectOption.d.ts +35 -7
- package/dist/selectoption/IxSelectOption.js +12 -11
- package/dist/selectoption/IxSelectOption.js.map +1 -1
- package/dist/selectoption/ix-select-option.js +1 -1
- package/dist/selectoption/ix-select-option.js.map +1 -1
- package/package.json +4 -4
package/dist/IxSelect.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ 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
|
-
|
|
8
|
+
declare const ixSelectBaseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<typeof LitElement, import("@material/web/labs/behaviors/element-internals.js").WithElementInternals>, object>;
|
|
9
|
+
export declare class IxSelect extends ixSelectBaseClass {
|
|
9
10
|
/** @nocollapse */
|
|
10
11
|
static shadowRootOptions: ShadowRootInit;
|
|
11
12
|
/** @nocollapse */
|
package/dist/IxSelect.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
3
|
import '@digital-realty/ix-icon/ix-icon.js';
|
|
4
|
-
import {
|
|
4
|
+
import { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';
|
|
5
|
+
import { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';
|
|
5
6
|
import { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '@material/web/menu/internal/menu.js';
|
|
6
7
|
import '@material/web/select/filled-select.js';
|
|
7
8
|
import '@material/web/select/outlined-select.js';
|
|
@@ -11,7 +12,8 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
11
12
|
import { literal, html as staticHtml } from 'lit/static-html.js';
|
|
12
13
|
import './selectoption/ix-select-option.js';
|
|
13
14
|
const VALUE = Symbol('value');
|
|
14
|
-
|
|
15
|
+
const ixSelectBaseClass = mixinDelegatesAria(mixinElementInternals(LitElement));
|
|
16
|
+
export class IxSelect extends ixSelectBaseClass {
|
|
15
17
|
constructor() {
|
|
16
18
|
super(...arguments);
|
|
17
19
|
this.minWidth = 0;
|
|
@@ -322,9 +324,6 @@ export class IxSelect extends LitElement {
|
|
|
322
324
|
}
|
|
323
325
|
}
|
|
324
326
|
_a = VALUE;
|
|
325
|
-
(() => {
|
|
326
|
-
requestUpdateOnAriaChange(IxSelect);
|
|
327
|
-
})();
|
|
328
327
|
/** @nocollapse */
|
|
329
328
|
IxSelect.shadowRootOptions = {
|
|
330
329
|
...LitElement.shadowRootOptions,
|
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,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,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;AAE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,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;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 { 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 @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
|
+
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;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,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;AAKJ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;2CAAmB;AAKjB;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;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"]}
|
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{mixinDelegatesAria}from"@material/web/internal/aria/delegate.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{MenuItemController}from"@material/web/menu/internal/controllers/menuItemController.js";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=mixinDelegatesAria(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}
|
|
@@ -28,4 +28,4 @@ import{LitElement,html,nothing,css,isServer}from"lit";import{__decorate}from"tsl
|
|
|
28
28
|
>${this.trailingIcon}</ix-icon
|
|
29
29
|
>`:nothing}
|
|
30
30
|
<slot slot="aria-describedby" name="aria-describedby"></slot>
|
|
31
|
-
</${e}>`}}_a=VALUE,
|
|
31
|
+
</${e}>`}}_a=VALUE,IxSelect.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},IxSelect.formAssociated=!0,__decorate([query(".select")],IxSelect.prototype,"component",void 0),__decorate([property({type:Number})],IxSelect.prototype,"minWidth",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"wide-menu"})],IxSelect.prototype,"wideMenu",void 0),__decorate([property({type:Number})],IxSelect.prototype,"truncateLabelBy",void 0),__decorate([property({type:Boolean,reflect:!0})],IxSelect.prototype,"filled",void 0),__decorate([property()],IxSelect.prototype,"label",void 0),__decorate([property({type:Boolean})],IxSelect.prototype,"quick",void 0),__decorate([property({type:Boolean})],IxSelect.prototype,"required",void 0),__decorate([property({type:Boolean,reflect:!0})],IxSelect.prototype,"disabled",void 0),__decorate([property({type:String,attribute:"error-text"})],IxSelect.prototype,"errorText",void 0),__decorate([property({type:String,attribute:"supporting-text"})],IxSelect.prototype,"supportingText",void 0),__decorate([property({type:Boolean,reflect:!0})],IxSelect.prototype,"error",void 0),__decorate([property({type:Boolean,attribute:"menu-below"})],IxSelect.prototype,"menuBelow",void 0),__decorate([property({type:String,attribute:"display-text"})],IxSelect.prototype,"displayText",void 0),__decorate([property({attribute:"leading-icon",reflect:!0})],IxSelect.prototype,"leadingIcon",void 0),__decorate([property({attribute:"trailing-icon",reflect:!0})],IxSelect.prototype,"trailingIcon",void 0),__decorate([property({attribute:"menu-positioning"})],IxSelect.prototype,"menuPositioning",void 0),__decorate([property({type:Number,attribute:"typeahead-delay"})],IxSelect.prototype,"typeaheadDelay",void 0),__decorate([property({type:Number,attribute:"selected-index"})],IxSelect.prototype,"selectedIndex",void 0),__decorate([state()],IxSelect.prototype,"nativeError",void 0),__decorate([state()],IxSelect.prototype,"nativeErrorText",void 0);class IxSelectStyled extends IxSelect{}IxSelectStyled.styles=css`:host([disabled]){pointer-events:none}:host([error]){--md-outlined-select-text-field-outline-width:2px}.select{display:block}ix-icon{height:var(--ix-select-leading-icon-height,1.5rem);color:var(--ix-select-leading-icon-color,var(--clr-graphics-fill,#09224199));margin-inline-start:var(--ix-select-leading-icon-inset)}`,window.customElements.define("ix-select",IxSelectStyled);export{IxSelectStyled};
|
|
@@ -8,15 +8,42 @@ import '@material/web/focus/md-focus-ring.js';
|
|
|
8
8
|
import '@material/web/labs/item/item.js';
|
|
9
9
|
import { LitElement } from 'lit';
|
|
10
10
|
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
11
|
-
import {
|
|
11
|
+
import { MenuItem } from '@material/web/menu/internal/controllers/menuItemController.js';
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @fires request-selection Requests the parent md-select to select this element
|
|
15
|
-
* (and deselect others if single-selection) when `selected` changed to `true`.
|
|
16
|
-
* @fires request-deselection Requests the parent md-select to deselect this
|
|
17
|
-
* element when `selected` changed to `false`.
|
|
13
|
+
* The interface specific to a Select Option
|
|
18
14
|
*/
|
|
19
|
-
|
|
15
|
+
interface SelectOptionSelf {
|
|
16
|
+
/**
|
|
17
|
+
* The form value associated with the Select Option. (Note: the visual portion
|
|
18
|
+
* of the SelectOption is the headline defined in ListItem)
|
|
19
|
+
*/
|
|
20
|
+
value: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether or not the SelectOption is selected.
|
|
23
|
+
*/
|
|
24
|
+
selected: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The text to display in the select when selected. Defaults to the
|
|
27
|
+
* textContent of the Element slotted into the headline.
|
|
28
|
+
*/
|
|
29
|
+
displayText: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The interface to implement for a select option. Additionally, the element
|
|
33
|
+
* must have `md-list-item` and `md-menu-item` attributes on the host.
|
|
34
|
+
*/
|
|
35
|
+
export type SelectOption = SelectOptionSelf & MenuItem;
|
|
36
|
+
declare const selectOptionBaseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<typeof LitElement, object>;
|
|
37
|
+
/**
|
|
38
|
+
* @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}
|
|
39
|
+
* Closes the encapsulating menu on closable interaction. --bubbles --composed
|
|
40
|
+
* @fires request-selection {Event} Requests the parent md-select to select this
|
|
41
|
+
* element (and deselect others if single-selection) when `selected` changed to
|
|
42
|
+
* `true`. --bubbles --composed
|
|
43
|
+
* @fires request-deselection {Event} Requests the parent md-select to deselect
|
|
44
|
+
* this element when `selected` changed to `false`. --bubbles --composed
|
|
45
|
+
*/
|
|
46
|
+
export declare class IxSelectOption extends selectOptionBaseClass implements SelectOption {
|
|
20
47
|
/** @nocollapse */
|
|
21
48
|
static shadowRootOptions: {
|
|
22
49
|
delegatesFocus: boolean;
|
|
@@ -84,3 +111,4 @@ export declare class IxSelectOption extends LitElement implements SelectOption {
|
|
|
84
111
|
protected renderBody(): import("lit-html").TemplateResult<1>;
|
|
85
112
|
focus(): void;
|
|
86
113
|
}
|
|
114
|
+
export {};
|
|
@@ -10,16 +10,20 @@ import '@material/web/labs/item/item.js';
|
|
|
10
10
|
import { html, LitElement, nothing } from 'lit';
|
|
11
11
|
import { property, query, queryAssignedElements, queryAssignedNodes, } from 'lit/decorators.js';
|
|
12
12
|
import { classMap } from 'lit/directives/class-map.js';
|
|
13
|
-
import {
|
|
14
|
-
import { SelectOptionController
|
|
13
|
+
import { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';
|
|
14
|
+
import { SelectOptionController } from './selectOptionController.js';
|
|
15
|
+
// Separate variable needed for closure.
|
|
16
|
+
const selectOptionBaseClass = mixinDelegatesAria(LitElement);
|
|
15
17
|
/**
|
|
16
|
-
* @fires close-menu
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}
|
|
19
|
+
* Closes the encapsulating menu on closable interaction. --bubbles --composed
|
|
20
|
+
* @fires request-selection {Event} Requests the parent md-select to select this
|
|
21
|
+
* element (and deselect others if single-selection) when `selected` changed to
|
|
22
|
+
* `true`. --bubbles --composed
|
|
23
|
+
* @fires request-deselection {Event} Requests the parent md-select to deselect
|
|
24
|
+
* this element when `selected` changed to `false`. --bubbles --composed
|
|
21
25
|
*/
|
|
22
|
-
export class IxSelectOption extends
|
|
26
|
+
export class IxSelectOption extends selectOptionBaseClass {
|
|
23
27
|
constructor() {
|
|
24
28
|
super(...arguments);
|
|
25
29
|
/**
|
|
@@ -155,9 +159,6 @@ export class IxSelectOption extends LitElement {
|
|
|
155
159
|
(_a = this.listItemRoot) === null || _a === void 0 ? void 0 : _a.focus();
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
|
-
(() => {
|
|
159
|
-
requestUpdateOnAriaChange(IxSelectOption);
|
|
160
|
-
})();
|
|
161
162
|
/** @nocollapse */
|
|
162
163
|
IxSelectOption.shadowRootOptions = {
|
|
163
164
|
...LitElement.shadowRootOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxSelectOption.js","sourceRoot":"","sources":["../../src/selectoption/IxSelectOption.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAEL,sBAAsB,GACvB,MAAM,6BAA6B,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QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAkB;AAM7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDACpD;AAKW;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAkB;AAKlC;IAAX,QAAQ,EAAE;6CAAY;AAEF;IAApB,KAAK,CAAC,YAAY,CAAC;oDAAsD;AAG1E;IADC,qBAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;wDACQ;AAGpD;IADC,qBAAqB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;8DACO;AAG1D;IADC,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;uDACc;AAa/C;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;mDAGzC;AAWD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;iDAGvC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '@material/web/ripple/ripple.js';\nimport '@material/web/focus/md-focus-ring.js';\nimport '@material/web/labs/item/item.js';\n\nimport { html, LitElement, nothing } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n} from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\n\nimport {\n SelectOption,\n SelectOptionController,\n} from './selectOptionController.js';\n\n/**\n * @fires close-menu Closes the encapsulating menu on\n * @fires request-selection Requests the parent md-select to select this element\n * (and deselect others if single-selection) when `selected` changed to `true`.\n * @fires request-deselection Requests the parent md-select to deselect this\n * element when `selected` changed to `false`.\n */\nexport class IxSelectOption extends LitElement implements SelectOption {\n static {\n requestUpdateOnAriaChange(IxSelectOption);\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({ type: Boolean, attribute: 'md-menu-item', reflect: true })\n isMenuItem = true;\n\n /**\n * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({ type: Boolean }) selected = false;\n\n /**\n * Form value of the option.\n */\n @property() value = '';\n\n @query('.list-item') protected readonly listItemRoot!: HTMLElement | null;\n\n @queryAssignedElements({ slot: 'headline' })\n protected readonly headlineElements!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'supporting-text' })\n protected readonly supportingTextElements!: HTMLElement[];\n\n @queryAssignedNodes({ slot: '' })\n protected readonly defaultElements!: Element[];\n\n type = 'option' as const;\n\n /**\n * The text that is selectable via typeahead. If not set, defaults to the\n * innerText of the item slotted into the `\"headline\"` slot.\n */\n get typeaheadText() {\n return this.selectOptionController.typeaheadText;\n }\n\n @property({ attribute: 'typeahead-text' })\n set typeaheadText(text: string) {\n this.selectOptionController.setTypeaheadText(text);\n }\n\n /**\n * The text that is displayed in the select field when selected. If not set,\n * defaults to the textContent of the item slotted into the `\"headline\"` slot.\n */\n get displayText() {\n return this.selectOptionController.displayText;\n }\n\n @property({ attribute: 'display-text' })\n set displayText(text: string) {\n this.selectOptionController.setDisplayText(text);\n }\n\n private readonly selectOptionController = new SelectOptionController(this, {\n getHeadlineElements: () => this.headlineElements,\n getSupportingTextElements: () => this.supportingTextElements,\n getDefaultElements: () => this.defaultElements,\n getInteractiveElement: () => this.listItemRoot,\n });\n\n protected override render() {\n return this.renderListItem(html`\n <md-item>\n <div slot=\"container\">\n ${this.renderRipple()} ${this.renderFocusRing()}\n </div>\n <slot name=\"start\" slot=\"start\"></slot>\n <slot name=\"end\" slot=\"end\"></slot>\n ${this.renderBody()}\n </md-item>\n `);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n return html`\n <li\n id=\"item\"\n tabindex=${this.disabled ? -1 : 0}\n role=${this.selectOptionController.role}\n aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n aria-expanded=${(this as ARIAMixinStrict).ariaExpanded || nothing}\n aria-haspopup=${(this as ARIAMixinStrict).ariaHasPopup || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n @click=${this.selectOptionController.onClick}\n @keydown=${this.selectOptionController.onKeydown}\n >\n ${content}\n </li>\n `;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n protected renderRipple() {\n return html` <md-ripple\n part=\"ripple\"\n for=\"item\"\n ?disabled=${this.disabled}\n ></md-ripple>`;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n // eslint-disable-next-line class-methods-use-this\n protected renderFocusRing() {\n return html` <md-focus-ring\n part=\"focus-ring\"\n for=\"item\"\n inward\n ></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses(): ClassInfo {\n return {\n disabled: this.disabled,\n selected: this.selected,\n };\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n // eslint-disable-next-line class-methods-use-this\n protected renderBody() {\n return html`\n <slot></slot>\n <slot name=\"overline\" slot=\"overline\"></slot>\n <slot name=\"headline\" slot=\"headline\"></slot>\n <slot name=\"supporting-text\" slot=\"supporting-text\"></slot>\n <slot\n name=\"trailing-supporting-text\"\n slot=\"trailing-supporting-text\"\n ></slot>\n `;\n }\n\n override focus() {\n // TODO(b/300334509): needed for some cases where delegatesFocus doesn't\n // work programmatically like in FF and select-option\n this.listItemRoot?.focus();\n }\n}\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**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '@material/web/ripple/ripple.js';\nimport '@material/web/focus/md-focus-ring.js';\nimport '@material/web/labs/item/item.js';\n\nimport { html, LitElement, nothing } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n} from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { MenuItem } from '@material/web/menu/internal/controllers/menuItemController.js';\n\nimport { SelectOptionController } from './selectOptionController.js';\n\n/**\n * The interface specific to a Select Option\n */\ninterface SelectOptionSelf {\n /**\n * The form value associated with the Select Option. (Note: the visual portion\n * of the SelectOption is the headline defined in ListItem)\n */\n value: string;\n /**\n * Whether or not the SelectOption is selected.\n */\n selected: boolean;\n /**\n * The text to display in the select when selected. Defaults to the\n * textContent of the Element slotted into the headline.\n */\n displayText: string;\n}\n\n/**\n * The interface to implement for a select option. Additionally, the element\n * must have `md-list-item` and `md-menu-item` attributes on the host.\n */\nexport type SelectOption = SelectOptionSelf & MenuItem;\n\n// Separate variable needed for closure.\nconst selectOptionBaseClass = mixinDelegatesAria(LitElement);\n\n/**\n * @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}\n * Closes the encapsulating menu on closable interaction. --bubbles --composed\n * @fires request-selection {Event} Requests the parent md-select to select this\n * element (and deselect others if single-selection) when `selected` changed to\n * `true`. --bubbles --composed\n * @fires request-deselection {Event} Requests the parent md-select to deselect\n * this element when `selected` changed to `false`. --bubbles --composed\n */\nexport class IxSelectOption\n extends selectOptionBaseClass\n implements SelectOption\n{\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({ type: Boolean, attribute: 'md-menu-item', reflect: true })\n isMenuItem = true;\n\n /**\n * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({ type: Boolean }) selected = false;\n\n /**\n * Form value of the option.\n */\n @property() value = '';\n\n @query('.list-item') protected readonly listItemRoot!: HTMLElement | null;\n\n @queryAssignedElements({ slot: 'headline' })\n protected readonly headlineElements!: HTMLElement[];\n\n @queryAssignedElements({ slot: 'supporting-text' })\n protected readonly supportingTextElements!: HTMLElement[];\n\n @queryAssignedNodes({ slot: '' })\n protected readonly defaultElements!: Element[];\n\n type = 'option' as const;\n\n /**\n * The text that is selectable via typeahead. If not set, defaults to the\n * innerText of the item slotted into the `\"headline\"` slot.\n */\n get typeaheadText() {\n return this.selectOptionController.typeaheadText;\n }\n\n @property({ attribute: 'typeahead-text' })\n set typeaheadText(text: string) {\n this.selectOptionController.setTypeaheadText(text);\n }\n\n /**\n * The text that is displayed in the select field when selected. If not set,\n * defaults to the textContent of the item slotted into the `\"headline\"` slot.\n */\n get displayText() {\n return this.selectOptionController.displayText;\n }\n\n @property({ attribute: 'display-text' })\n set displayText(text: string) {\n this.selectOptionController.setDisplayText(text);\n }\n\n private readonly selectOptionController = new SelectOptionController(this, {\n getHeadlineElements: () => this.headlineElements,\n getSupportingTextElements: () => this.supportingTextElements,\n getDefaultElements: () => this.defaultElements,\n getInteractiveElement: () => this.listItemRoot,\n });\n\n protected override render() {\n return this.renderListItem(html`\n <md-item>\n <div slot=\"container\">\n ${this.renderRipple()} ${this.renderFocusRing()}\n </div>\n <slot name=\"start\" slot=\"start\"></slot>\n <slot name=\"end\" slot=\"end\"></slot>\n ${this.renderBody()}\n </md-item>\n `);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n return html`\n <li\n id=\"item\"\n tabindex=${this.disabled ? -1 : 0}\n role=${this.selectOptionController.role}\n aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n aria-expanded=${(this as ARIAMixinStrict).ariaExpanded || nothing}\n aria-haspopup=${(this as ARIAMixinStrict).ariaHasPopup || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n @click=${this.selectOptionController.onClick}\n @keydown=${this.selectOptionController.onKeydown}\n >\n ${content}\n </li>\n `;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n protected renderRipple() {\n return html` <md-ripple\n part=\"ripple\"\n for=\"item\"\n ?disabled=${this.disabled}\n ></md-ripple>`;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n // eslint-disable-next-line class-methods-use-this\n protected renderFocusRing() {\n return html` <md-focus-ring\n part=\"focus-ring\"\n for=\"item\"\n inward\n ></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses(): ClassInfo {\n return {\n disabled: this.disabled,\n selected: this.selected,\n };\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n // eslint-disable-next-line class-methods-use-this\n protected renderBody() {\n return html`\n <slot></slot>\n <slot name=\"overline\" slot=\"overline\"></slot>\n <slot name=\"headline\" slot=\"headline\"></slot>\n <slot name=\"supporting-text\" slot=\"supporting-text\"></slot>\n <slot\n name=\"trailing-supporting-text\"\n slot=\"trailing-supporting-text\"\n ></slot>\n `;\n }\n\n override focus() {\n // TODO(b/300334509): needed for some cases where delegatesFocus doesn't\n // work programmatically like in FF and select-option\n this.listItemRoot?.focus();\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
import { styles } from '@material/web/menu/internal/menuitem/menu-item-styles.
|
|
2
|
+
import { styles } from '@material/web/menu/internal/menuitem/menu-item-styles.js';
|
|
3
3
|
import { IxSelectOption } from './IxSelectOption.js';
|
|
4
4
|
export class IxSelectOptionStyled extends IxSelectOption {
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ix-select-option.js","sourceRoot":"","sources":["../../src/selectoption/ix-select-option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ix-select-option.js","sourceRoot":"","sources":["../../src/selectoption/ix-select-option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,0DAA0D,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,oBAAqB,SAAQ,cAAc;;AACtC,2BAAM,GAAG;IACvB,MAAM;IACN,GAAG,CAAA;;;;;;;;;;;;;KAaF;CACF,CAAC;AAGJ,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { css } from 'lit';\nimport { styles } from '@material/web/menu/internal/menuitem/menu-item-styles.js';\nimport { IxSelectOption } from './IxSelectOption.js';\n\nexport class IxSelectOptionStyled extends IxSelectOption {\n static override styles = [\n styles,\n css`\n ix-icon {\n font-size: 1.5rem;\n display: block;\n }\n\n [slot='end'] {\n margin-right: 2rem;\n }\n\n [slot='start'] {\n margin-right: -0.4rem;\n }\n `,\n ];\n}\n\nwindow.customElements.define('ix-select-option', IxSelectOptionStyled);\n"]}
|
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.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -31,9 +31,9 @@
|
|
|
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
35
|
"@lit/react": "^1.0.2",
|
|
36
|
-
"@material/web": "
|
|
36
|
+
"@material/web": "2.4.0",
|
|
37
37
|
"lit": "^3.2.1",
|
|
38
38
|
"react": "^18.2.0"
|
|
39
39
|
},
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"README.md",
|
|
110
110
|
"LICENSE"
|
|
111
111
|
],
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "5f957be9ee993f439c24887108d7d1f35c40ab17"
|
|
113
113
|
}
|