@redvars/peacock 3.10.0 → 3.11.0
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/BaseInput-CV0pZgSb.js +58 -0
- package/dist/BaseInput-CV0pZgSb.js.map +1 -0
- package/dist/app-bar.js +16 -16
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/assets/theme.d.ts +66 -0
- package/dist/assets/theme.js +134 -0
- package/dist/assets/tokens.css +1 -1
- package/dist/assets/tokens.css.map +1 -1
- package/dist/base-progress-CLZTRveO.js +33 -0
- package/dist/base-progress-CLZTRveO.js.map +1 -0
- package/dist/bottom-sheet.js +1 -1
- package/dist/button-group.js +9 -7
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +225 -187
- package/dist/button.js.map +1 -1
- package/dist/{chart-bar-CapLbc2e.js → chart-bar-D5dGFJfK.js} +2 -2
- package/dist/{chart-bar-CapLbc2e.js.map → chart-bar-D5dGFJfK.js.map} +1 -1
- package/dist/chart-bar.js +1 -1
- package/dist/chart-stacked-bar.js +1 -1
- package/dist/checkbox.js +78 -53
- package/dist/checkbox.js.map +1 -1
- package/dist/chip-set.js +52 -0
- package/dist/chip-set.js.map +1 -0
- package/dist/chip.js +8 -6
- package/dist/chip.js.map +1 -1
- package/dist/circular-progress.js +177 -0
- package/dist/circular-progress.js.map +1 -0
- package/dist/code-editor.js +129 -72
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -38
- package/dist/code-highlighter.js.map +1 -1
- package/dist/color-field.js +309 -0
- package/dist/color-field.js.map +1 -0
- package/dist/color-picker.js +26 -15
- package/dist/color-picker.js.map +1 -1
- package/dist/copy-to-clipboard-upGx-Ueo.js +39 -0
- package/dist/copy-to-clipboard-upGx-Ueo.js.map +1 -0
- package/dist/custom-elements-jsdocs.json +1044 -382
- package/dist/custom-elements.json +8620 -4714
- package/dist/date-picker.js +241 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/{element-internals-2CMts_0M.js → delegate-py-Ets8N.js} +2 -43
- package/dist/delegate-py-Ets8N.js.map +1 -0
- package/dist/element-internals-QME0yEz4.js +43 -0
- package/dist/element-internals-QME0yEz4.js.map +1 -0
- package/dist/fab.js +51 -49
- package/dist/fab.js.map +1 -1
- package/dist/field.js +34 -4
- package/dist/field.js.map +1 -1
- package/dist/flow.js +5 -5
- package/dist/form-associated-Bhwwr6dT.js +162 -0
- package/dist/form-associated-Bhwwr6dT.js.map +1 -0
- package/dist/{form-associated-BXADnjOB.js → form-submitter-DPI4L6gj.js} +3 -159
- package/dist/form-submitter-DPI4L6gj.js.map +1 -0
- package/dist/html-editor.js +3 -1
- package/dist/html-editor.js.map +1 -1
- package/dist/icon-button.js +195 -156
- package/dist/icon-button.js.map +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/input.js +259 -0
- package/dist/input.js.map +1 -0
- package/dist/item.js +2 -1
- package/dist/item.js.map +1 -1
- package/dist/linear-progress.js +192 -0
- package/dist/linear-progress.js.map +1 -0
- package/dist/{list-AdO-PUq_.js → list-item.js} +12 -222
- package/dist/list-item.js.map +1 -0
- package/dist/list.js +225 -6
- package/dist/list.js.map +1 -1
- package/dist/loader-full.js +31 -8
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +52 -12
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -3
- package/dist/markdown-editor.js.map +1 -1
- package/dist/menu-item.js +30 -30
- package/dist/menu.js +1 -1
- package/dist/navigation-bar-item.js +41 -0
- package/dist/navigation-bar-item.js.map +1 -0
- package/dist/navigation-bar.js +128 -0
- package/dist/navigation-bar.js.map +1 -0
- package/dist/navigation-drawer-item.js +236 -0
- package/dist/navigation-drawer-item.js.map +1 -0
- package/dist/navigation-drawer.js +293 -0
- package/dist/navigation-drawer.js.map +1 -0
- package/dist/navigation-rail.js +1 -1
- package/dist/number-field.js +280 -0
- package/dist/number-field.js.map +1 -0
- package/dist/option.js +17 -0
- package/dist/option.js.map +1 -1
- package/dist/pagination.js +1 -1
- package/dist/radio-group.js +209 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/radio.js +47 -37
- package/dist/radio.js.map +1 -1
- package/dist/segmented-button-group.js +12 -0
- package/dist/segmented-button-group.js.map +1 -1
- package/dist/segmented-button.js +10 -6
- package/dist/segmented-button.js.map +1 -1
- package/dist/select.js +653 -0
- package/dist/select.js.map +1 -0
- package/dist/side-sheet.js +1 -1
- package/dist/sidebar-menu-item.js +273 -0
- package/dist/sidebar-menu-item.js.map +1 -0
- package/dist/sidebar-menu.js +193 -0
- package/dist/sidebar-menu.js.map +1 -0
- package/dist/sidebar-sub-menu.js +301 -0
- package/dist/sidebar-sub-menu.js.map +1 -0
- package/dist/slider.js +76 -24
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +3 -3
- package/dist/snackbar.js.map +1 -1
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/utils/size.d.ts +9 -0
- package/dist/src/button/ButtonTypes.d.ts +1 -1
- package/dist/src/checkbox/checkbox.d.ts +28 -22
- package/dist/src/chip/chip/chip.d.ts +3 -0
- package/dist/src/chip/tag/tag.d.ts +5 -1
- package/dist/src/code-editor/code-editor.d.ts +37 -10
- package/dist/src/color-field/color-field.d.ts +55 -0
- package/dist/src/color-field/index.d.ts +1 -0
- package/dist/src/color-picker/color-picker.d.ts +1 -1
- package/dist/src/date-picker/date-picker.d.ts +0 -1
- package/dist/src/field/field.d.ts +2 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/input/BaseInput.d.ts +21 -3
- package/dist/src/input/input.d.ts +15 -7
- package/dist/src/navigation-bar/index.d.ts +2 -0
- package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
- package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
- package/dist/src/navigation-drawer/index.d.ts +2 -0
- package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
- package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
- package/dist/src/number-field/number-field.d.ts +0 -1
- package/dist/src/radio/index.d.ts +1 -0
- package/dist/src/radio/radio-group.d.ts +50 -0
- package/dist/src/radio/radio.d.ts +18 -18
- package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
- package/dist/src/segmented-button/segmented-button.d.ts +2 -1
- package/dist/src/select/select.d.ts +7 -0
- package/dist/src/slider/slider.d.ts +14 -5
- package/dist/src/switch/switch.d.ts +22 -26
- package/dist/src/tabs/tabs.d.ts +3 -0
- package/dist/src/textarea/textarea.d.ts +0 -1
- package/dist/src/time-picker/time-picker.d.ts +0 -1
- package/dist/src/toolbar/toolbar.d.ts +7 -4
- package/dist/src/url-field/url-field.d.ts +0 -1
- package/dist/svg.js +5 -5
- package/dist/switch.js +413 -0
- package/dist/switch.js.map +1 -0
- package/dist/tab.js +2 -1
- package/dist/tab.js.map +1 -1
- package/dist/tabs.js +10 -8
- package/dist/tabs.js.map +1 -1
- package/dist/tag.js +349 -0
- package/dist/tag.js.map +1 -0
- package/dist/test/code-editor.test.d.ts +1 -0
- package/dist/test/color-field.test.d.ts +1 -0
- package/dist/test/color-picker.test.d.ts +1 -0
- package/dist/test/field.test.d.ts +1 -0
- package/dist/test/form-controls.test.d.ts +1 -0
- package/dist/test/icon.test.d.ts +1 -1
- package/dist/test/input.test.d.ts +1 -0
- package/dist/test/navigation.test.d.ts +1 -0
- package/dist/test/segmented-button.test.d.ts +1 -0
- package/dist/test/select.test.d.ts +1 -0
- package/dist/test/slider.test.d.ts +1 -0
- package/dist/textarea.js +237 -0
- package/dist/textarea.js.map +1 -0
- package/dist/time-picker.js +241 -0
- package/dist/time-picker.js.map +1 -0
- package/dist/toolbar.js +26 -9
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/url-field.js +298 -0
- package/dist/url-field.js.map +1 -0
- package/package.json +29 -8
- package/readme.md +2 -2
- package/scss/tokens.css +175 -18
- package/src/__internal/utils/size.ts +23 -0
- package/src/app-bar/app-bar.scss +4 -16
- package/src/bottom-sheet/bottom-sheet.scss +1 -1
- package/src/button/ButtonTypes.ts +2 -0
- package/src/button/button/button-base.scss +84 -84
- package/src/button/button/button-colors.scss +14 -2
- package/src/button/button/button-layers.scss +71 -71
- package/src/button/button/button-shapes.scss +2 -2
- package/src/button/button/button-sizes.scss +35 -35
- package/src/button/button/button.scss +1 -1
- package/src/button/button/button.ts +1 -2
- package/src/button/button-group/button-group.scss +5 -5
- package/src/button/fab/fab-sizes.scss +15 -15
- package/src/button/fab/fab.scss +32 -32
- package/src/button/icon-button/icon-button-sizes.scss +7 -7
- package/src/chart-bar/chart-bar.scss +1 -1
- package/src/checkbox/checkbox.scss +7 -6
- package/src/checkbox/checkbox.ts +92 -40
- package/src/chip/chip/chip.ts +8 -5
- package/src/chip/chip-set/chip-set.ts +2 -0
- package/src/chip/tag/tag-colors.scss +1 -1
- package/src/chip/tag/tag-sizes.scss +9 -0
- package/src/chip/tag/tag.scss +1 -1
- package/src/chip/tag/tag.ts +20 -9
- package/src/code-editor/code-editor.scss +8 -3
- package/src/code-editor/code-editor.ts +148 -79
- package/src/code-highlighter/code-highlighter.scss +1 -1
- package/src/color-field/color-field.scss +48 -0
- package/src/color-field/color-field.ts +239 -0
- package/src/color-field/index.ts +1 -0
- package/src/color-picker/color-picker.scss +33 -15
- package/src/color-picker/color-picker.ts +2 -1
- package/src/date-picker/date-picker.ts +2 -3
- package/src/field/field.scss +31 -0
- package/src/field/field.ts +5 -1
- package/src/flow/flow.scss +5 -5
- package/src/image/image.scss +2 -2
- package/src/index.ts +7 -3
- package/src/input/BaseInput.ts +54 -4
- package/src/input/input.ts +104 -79
- package/src/list/list-item.ts +2 -0
- package/src/loader.ts +28 -6
- package/src/markdown-editor/markdown-editor.scss +2 -2
- package/src/menu/menu/menu.scss +1 -1
- package/src/menu/menu-item/menu-item.scss +30 -30
- package/src/navigation-bar/index.ts +2 -0
- package/src/navigation-bar/navigation-bar-item.ts +25 -0
- package/src/navigation-bar/navigation-bar.scss +27 -0
- package/src/navigation-bar/navigation-bar.ts +96 -0
- package/src/navigation-drawer/index.ts +2 -0
- package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
- package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
- package/src/navigation-drawer/navigation-drawer.scss +99 -0
- package/src/navigation-drawer/navigation-drawer.ts +196 -0
- package/src/navigation-rail/navigation-rail.scss +1 -1
- package/src/number-field/number-field.ts +2 -3
- package/src/pagination/pagination.scss +1 -1
- package/src/progress/circular-progress/circular-progress.ts +2 -0
- package/src/progress/linear-progress/linear-progress.ts +2 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio-group.scss +39 -0
- package/src/radio/radio-group.ts +167 -0
- package/src/radio/radio.ts +74 -31
- package/src/segmented-button/segmented-button-group.ts +12 -0
- package/src/segmented-button/segmented-button.ts +12 -6
- package/src/select/option.ts +17 -0
- package/src/select/select.ts +33 -8
- package/src/side-sheet/side-sheet.scss +1 -1
- package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
- package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
- package/src/sidebar-menu/sidebar-menu.ts +2 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
- package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
- package/src/slider/slider.scss +3 -3
- package/src/slider/slider.ts +119 -31
- package/src/snackbar/snackbar.ts +3 -3
- package/src/split-button/split-button-colors.scss +2 -2
- package/src/svg/svg.scss +5 -5
- package/src/switch/switch.scss +0 -1
- package/src/switch/switch.ts +82 -47
- package/src/tabs/tab.scss +2 -1
- package/src/tabs/tabs.ts +14 -8
- package/src/textarea/textarea.ts +2 -3
- package/src/time-picker/time-picker.ts +2 -3
- package/src/toolbar/toolbar.scss +4 -4
- package/src/toolbar/toolbar.ts +12 -5
- package/src/url-field/url-field.ts +2 -3
- package/dist/BaseInput-CU1zZYKc.js +0 -27
- package/dist/BaseInput-CU1zZYKc.js.map +0 -1
- package/dist/brand-loader.js +0 -358
- package/dist/brand-loader.js.map +0 -1
- package/dist/element-internals-2CMts_0M.js.map +0 -1
- package/dist/form-associated-BXADnjOB.js.map +0 -1
- package/dist/list-AdO-PUq_.js.map +0 -1
- package/dist/select-CnnPbvpQ.js +0 -3955
- package/dist/select-CnnPbvpQ.js.map +0 -1
- package/dist/src/brand-loader/brand-loader.d.ts +0 -33
- package/dist/src/brand-loader/index.d.ts +0 -2
- package/src/brand-loader/brand-loader.scss +0 -270
- package/src/brand-loader/brand-loader.ts +0 -115
- package/src/brand-loader/index.ts +0 -2
- /package/dist/test/{brand-loader.test.d.ts → button.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-button.js","sources":["../../src/segmented-button/segmented-button.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport styles from './segmented-button.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\n\n/**\n * @label Segmented Button\n * @tag wc-segmented-button\n * @rawTag segmented-button\n * @summary An individual segment within a segmented button group.\n * @overview\n * <p>Segmented buttons help people select options, switch views, or sort elements. They are used within a <code>wc-segmented-button-group</code>.</p>\n *\n * @cssprop --segmented-button-height: Height of the segmented button.\n * @cssprop --segmented-button-selected-container-color: Background color when the segment is selected.\n * @cssprop --segmented-button-selected-label-text-color: Text color when the segment is selected.\n * @cssprop --segmented-button-unselected-label-text-color: Text color when the segment is unselected.\n * @cssprop --segmented-button-outline-color: Outline / border color.\n * @cssprop --segmented-button-disabled-opacity: Opacity when the segment is disabled.\n *\n * @fires {CustomEvent}
|
|
1
|
+
{"version":3,"file":"segmented-button.js","sources":["../../src/segmented-button/segmented-button.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport styles from './segmented-button.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\n\n/**\n * @label Segmented Button\n * @tag wc-segmented-button\n * @rawTag segmented-button\n * @summary An individual segment within a segmented button group.\n * @overview\n * <p>Segmented buttons help people select options, switch views, or sort elements. They are used within a <code>wc-segmented-button-group</code>.</p>\n *\n * @cssprop --segmented-button-height: Height of the segmented button.\n * @cssprop --segmented-button-selected-container-color: Background color when the segment is selected.\n * @cssprop --segmented-button-selected-label-text-color: Text color when the segment is selected.\n * @cssprop --segmented-button-unselected-label-text-color: Text color when the segment is unselected.\n * @cssprop --segmented-button-outline-color: Outline / border color.\n * @cssprop --segmented-button-disabled-opacity: Opacity when the segment is disabled.\n *\n * @fires {CustomEvent} change - Dispatched when the segment is activated. Detail: `{ value, selected, originalEvent }`, where `selected` is the requested state. Inside a `wc-segmented-button-group` the group swallows it and fires its own `change` instead.\n * @fires {CustomEvent} segmented-button--change - Deprecated alias of `change`, fired alongside it.\n *\n * @example\n * ```html\n * <wc-segmented-button-group>\n * <wc-segmented-button value=\"day\">Day</wc-segmented-button>\n * <wc-segmented-button value=\"week\" selected>Week</wc-segmented-button>\n * <wc-segmented-button value=\"month\">Month</wc-segmented-button>\n * </wc-segmented-button-group>\n * ```\n *\n * @tags controls\n */\n@IndividualComponent\nexport class SegmentedButton extends LitElement {\n static styles = [styles];\n\n /**\n * The value associated with this segment.\n */\n @property({ type: String, reflect: true })\n value: string = '';\n\n /**\n * Whether this segment is currently selected.\n */\n @property({ type: Boolean, reflect: true })\n selected: boolean = false;\n\n /**\n * If true, the user cannot interact with this segment.\n */\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n /**\n * Optional icon name to display (uses wc-icon).\n */\n @property({ type: String })\n icon?: string;\n\n /** True while the segment has keyboard focus. */\n @state()\n private hasFocus = false;\n\n /** True while the user is actively pressing the segment. */\n @state()\n private isActive = false;\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener('mouseup', this._windowMouseUp);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener('mouseup', this._windowMouseUp);\n }\n\n private _windowMouseUp = () => {\n if (this.isActive) {\n this.isActive = false;\n }\n };\n\n private _mouseDownHandler = () => {\n this.isActive = true;\n };\n\n private _keyDownHandler = (evt: KeyboardEvent) => {\n if (evt.key === ' ' || evt.key === 'Enter') {\n evt.preventDefault();\n this.isActive = true;\n this._toggle(evt);\n }\n };\n\n private _clickHandler = (ev: MouseEvent) => {\n this._toggle(ev);\n };\n\n private _toggle(ev: MouseEvent | KeyboardEvent) {\n if (this.disabled) return;\n const detail = {\n value: this.value || this.textContent?.trim(),\n selected: !this.selected,\n originalEvent: ev,\n };\n this.dispatchEvent(\n new CustomEvent('change', { detail, bubbles: true, composed: true }),\n );\n // Deprecated name, still what wc-segmented-button-group listens for.\n this.dispatchEvent(\n new CustomEvent('segmented-button--change', {\n detail,\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _blurHandler = (ev: FocusEvent) => {\n this.hasFocus = false;\n this.dispatchEvent(\n new CustomEvent('blur', { detail: ev, bubbles: true, composed: true }),\n );\n };\n\n private _focusHandler = (ev: FocusEvent) => {\n this.hasFocus = true;\n this.dispatchEvent(\n new CustomEvent('focus', { detail: ev, bubbles: true, composed: true }),\n );\n };\n\n /** Sets focus on the segment. */\n focus() {\n this.renderRoot.querySelector<HTMLElement>('.segment')?.focus();\n }\n\n /** Removes focus from the segment. */\n blur() {\n this.renderRoot.querySelector<HTMLElement>('.segment')?.blur();\n }\n\n render() {\n const cssClasses = {\n segment: true,\n selected: this.selected,\n disabled: this.disabled,\n 'has-focus': this.hasFocus,\n active: this.isActive,\n 'has-icon': !!this.icon,\n };\n\n return html`\n <div\n class=${classMap(cssClasses)}\n role=\"button\"\n tabindex=${this.disabled ? -1 : 0}\n aria-pressed=${this.selected}\n aria-disabled=${this.disabled}\n @click=${this._clickHandler}\n @mousedown=${this._mouseDownHandler}\n @keydown=${this._keyDownHandler}\n @blur=${this._blurHandler}\n @focus=${this._focusHandler}\n >\n <div class=\"state-layer\"></div>\n <div class=\"content\">\n ${this.selected\n ? html`<wc-icon class=\"check-icon\" name=\"check\"></wc-icon>`\n : this.icon\n ? html`<wc-icon class=\"leading-icon\" name=${this.icon}></wc-icon>`\n : nothing}\n <span class=\"label\"><slot></slot></span>\n </div>\n <div class=\"segment-outline\"></div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","classMap","nothing","styles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQA,GAAU,CAAA;AAAxC,IAAA,WAAA,GAAA;;AAGL;;AAEG;QAEH,IAAA,CAAA,KAAK,GAAW,EAAE;AAElB;;AAEG;QAEH,IAAA,CAAA,QAAQ,GAAY,KAAK;AAEzB;;AAEG;QAEH,IAAA,CAAA,QAAQ,GAAY,KAAK;;QAUjB,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,QAAQ,GAAG,KAAK;QAYhB,IAAA,CAAA,cAAc,GAAG,MAAK;AAC5B,YAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AACjB,gBAAA,IAAI,CAAC,QAAQ,GAAG,KAAK;YACvB;AACF,QAAA,CAAC;QAEO,IAAA,CAAA,iBAAiB,GAAG,MAAK;AAC/B,YAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACtB,QAAA,CAAC;AAEO,QAAA,IAAA,CAAA,eAAe,GAAG,CAAC,GAAkB,KAAI;AAC/C,YAAA,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE;gBAC1C,GAAG,CAAC,cAAc,EAAE;AACpB,gBAAA,IAAI,CAAC,QAAQ,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
|
2
|
+
import { n } from './property-B49QQ8pS.js';
|
|
3
|
+
import { r } from './state-DkTK9EGF.js';
|
|
4
|
+
import { e } from './query-CHb9Ft_d.js';
|
|
5
|
+
import { e as e$1 } from './class-map-DG7CA1et.js';
|
|
6
|
+
import { g as getFormValue } from './form-associated-Bhwwr6dT.js';
|
|
7
|
+
import { B as BaseInput } from './BaseInput-CV0pZgSb.js';
|
|
8
|
+
import { SelectOptionElement } from './option.js';
|
|
9
|
+
import './base-Cl6v8-BZ.js';
|
|
10
|
+
import './directive-ZPhl09Yt.js';
|
|
11
|
+
import './element-internals-QME0yEz4.js';
|
|
12
|
+
|
|
13
|
+
var css_248z = i`@charset "UTF-8";
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
-webkit-tap-highlight-color: transparent;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.screen-reader-only {
|
|
20
|
+
display: none !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[hidden] {
|
|
24
|
+
display: none !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Make the field wrapper behave as a select (pointer cursor) */
|
|
33
|
+
.select-field {
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.select-trigger {
|
|
38
|
+
flex: 1;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
min-height: 1.5rem;
|
|
42
|
+
outline: none;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
user-select: none;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
}
|
|
48
|
+
.select-trigger:focus-visible {
|
|
49
|
+
outline: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.display-value {
|
|
53
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
54
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
55
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
56
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
57
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
58
|
+
color: var(--color-on-surface);
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
text-overflow: ellipsis;
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.placeholder {
|
|
65
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
66
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
67
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
68
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
69
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
70
|
+
color: var(--color-on-surface-variant);
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
text-overflow: ellipsis;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Typeahead search input */
|
|
77
|
+
.search-input {
|
|
78
|
+
flex: 1;
|
|
79
|
+
width: 100%;
|
|
80
|
+
border: none;
|
|
81
|
+
outline: none;
|
|
82
|
+
background: transparent;
|
|
83
|
+
margin: 0;
|
|
84
|
+
padding: 0;
|
|
85
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
86
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
87
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
88
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
89
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
90
|
+
color: var(--color-on-surface);
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
}
|
|
93
|
+
.search-input::placeholder {
|
|
94
|
+
color: var(--color-on-surface-variant);
|
|
95
|
+
}
|
|
96
|
+
.search-input:focus {
|
|
97
|
+
cursor: text;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Field end slot wrapper */
|
|
101
|
+
.field-end-wrapper {
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: var(--spacing-050);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.select-empty-state {
|
|
108
|
+
display: block;
|
|
109
|
+
inline-size: min(22rem, 100%);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Dropdown chevron icon */
|
|
113
|
+
.dropdown-icon {
|
|
114
|
+
--icon-size: 1.5rem;
|
|
115
|
+
--icon-color: var(--color-on-surface-variant);
|
|
116
|
+
transition: transform 200ms ease;
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
}
|
|
119
|
+
.dropdown-icon.dropdown-icon--open {
|
|
120
|
+
transform: rotate(180deg);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Clear button */
|
|
124
|
+
.clear-btn {
|
|
125
|
+
--button-container-shape: var(--shape-corner-full);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Multi-select chips area — single scrollable row, no vertical growth */
|
|
129
|
+
.chips-container {
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
flex: 1;
|
|
133
|
+
padding-block: 0.5rem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Disabled state */
|
|
137
|
+
:host([disabled]) .select-trigger,
|
|
138
|
+
:host([disabled]) .select-field {
|
|
139
|
+
cursor: not-allowed;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* Readonly state */
|
|
143
|
+
:host([readonly]) .select-trigger,
|
|
144
|
+
:host([readonly]) .select-field {
|
|
145
|
+
cursor: default;
|
|
146
|
+
}`;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @label Select
|
|
150
|
+
* @tag wc-select
|
|
151
|
+
* @rawTag select
|
|
152
|
+
*
|
|
153
|
+
* @summary A dropdown select component supporting single and multi-select with optional typeahead search.
|
|
154
|
+
* @overview
|
|
155
|
+
* Select builds on wc-field and wc-menu to provide a fully-featured dropdown picker.
|
|
156
|
+
*
|
|
157
|
+
* - Single and multi-select modes
|
|
158
|
+
* - Client-side typeahead with `search="contains"`
|
|
159
|
+
* - Server-side typeahead with `search="managed"`
|
|
160
|
+
* - Multi-select chips display
|
|
161
|
+
* - Form-associated: submits the value under `name` (one entry per value with `multiple`)
|
|
162
|
+
*
|
|
163
|
+
* @fires {CustomEvent<{value: string}>} change - Dispatched when the selection changes.
|
|
164
|
+
* @fires {CustomEvent<{value: string}>} select-search - Dispatched as the user types when `search="managed"`.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```html
|
|
168
|
+
* <wc-select label="Fruit" placeholder="Pick a fruit...">
|
|
169
|
+
* <wc-option value="apple">Apple</wc-option>
|
|
170
|
+
* <wc-option value="banana">Banana</wc-option>
|
|
171
|
+
* </wc-select>
|
|
172
|
+
* ```
|
|
173
|
+
* @tags form
|
|
174
|
+
*/
|
|
175
|
+
let Select = class Select extends BaseInput {
|
|
176
|
+
constructor() {
|
|
177
|
+
super(...arguments);
|
|
178
|
+
this._menuId = `wc-select-menu-${Math.random().toString(36).slice(2, 9)}`;
|
|
179
|
+
/**
|
|
180
|
+
* Array of options to display in the dropdown.
|
|
181
|
+
* Setting this property creates matching `<wc-option>` children automatically.
|
|
182
|
+
*/
|
|
183
|
+
this.options = [];
|
|
184
|
+
/**
|
|
185
|
+
* The selected value. For multi-select, a comma-separated list of values.
|
|
186
|
+
*/
|
|
187
|
+
this.value = '';
|
|
188
|
+
/**
|
|
189
|
+
* Enable multi-select mode.
|
|
190
|
+
*/
|
|
191
|
+
this.multiple = false;
|
|
192
|
+
/**
|
|
193
|
+
* Enable typeahead search.
|
|
194
|
+
* - `'contains'`: filters options client-side.
|
|
195
|
+
* - `'managed'`: emits a `select-search` event for server-controlled filtering.
|
|
196
|
+
*/
|
|
197
|
+
this.search = '';
|
|
198
|
+
/**
|
|
199
|
+
* Placeholder text shown when no value is selected.
|
|
200
|
+
*/
|
|
201
|
+
this.placeholder = '';
|
|
202
|
+
/**
|
|
203
|
+
* Label displayed above the field.
|
|
204
|
+
*/
|
|
205
|
+
this.label = '';
|
|
206
|
+
/**
|
|
207
|
+
* Visual variant of the field.
|
|
208
|
+
*/
|
|
209
|
+
this.variant = 'default';
|
|
210
|
+
/**
|
|
211
|
+
* Helper text displayed below the field.
|
|
212
|
+
*/
|
|
213
|
+
this.helperText = '';
|
|
214
|
+
this.error = false;
|
|
215
|
+
this.errorText = '';
|
|
216
|
+
this.warning = false;
|
|
217
|
+
this.warningText = '';
|
|
218
|
+
this._open = false;
|
|
219
|
+
this._focused = false;
|
|
220
|
+
this._searchQuery = '';
|
|
221
|
+
/** True when all options are filtered out by the current search query. */
|
|
222
|
+
this._noOptionsVisible = false;
|
|
223
|
+
}
|
|
224
|
+
get _menu() {
|
|
225
|
+
return this.renderRoot?.querySelector('wc-menu') ?? null;
|
|
226
|
+
}
|
|
227
|
+
focus() {
|
|
228
|
+
this._triggerEl?.focus();
|
|
229
|
+
}
|
|
230
|
+
blur() {
|
|
231
|
+
this._triggerEl?.blur();
|
|
232
|
+
}
|
|
233
|
+
// ── Form association ──────────────────────────────────────────────────────
|
|
234
|
+
[getFormValue]() {
|
|
235
|
+
if (!this.multiple)
|
|
236
|
+
return this.value;
|
|
237
|
+
// One entry per selected value, like a native <select multiple>.
|
|
238
|
+
const data = new FormData();
|
|
239
|
+
for (const value of this._selectedValues)
|
|
240
|
+
data.append(this.name, value);
|
|
241
|
+
return data;
|
|
242
|
+
}
|
|
243
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
244
|
+
updated(changedProperties) {
|
|
245
|
+
if (changedProperties.has('options')) {
|
|
246
|
+
this._syncProgrammaticOptions();
|
|
247
|
+
}
|
|
248
|
+
this._syncOptionStates();
|
|
249
|
+
}
|
|
250
|
+
// ── Programmatic options ───────────────────────────────────────────────────
|
|
251
|
+
/**
|
|
252
|
+
* Reconciles the `options` property with auto-generated `<wc-option>` light-DOM
|
|
253
|
+
* children (marked `data-generated`). Declarative children placed by the
|
|
254
|
+
* consumer are left untouched.
|
|
255
|
+
*/
|
|
256
|
+
_syncProgrammaticOptions() {
|
|
257
|
+
this.querySelectorAll('wc-option[data-generated]').forEach(el => el.remove());
|
|
258
|
+
for (const opt of this.options) {
|
|
259
|
+
const el = new SelectOptionElement();
|
|
260
|
+
el.value = opt.value;
|
|
261
|
+
if (opt.icon)
|
|
262
|
+
el.icon = opt.icon;
|
|
263
|
+
el.textContent = opt.label || (opt.value === '' ? 'None' : '');
|
|
264
|
+
el.dataset.generated = '';
|
|
265
|
+
this.appendChild(el);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// ── Option state sync ──────────────────────────────────────────────────────
|
|
269
|
+
/**
|
|
270
|
+
* Pushes `selected`, `keepOpen`, and `filtered` state onto every `<wc-option>`
|
|
271
|
+
* child element so each one can render itself correctly.
|
|
272
|
+
*/
|
|
273
|
+
_syncOptionStates() {
|
|
274
|
+
const optEls = Array.from(this.querySelectorAll('wc-option'));
|
|
275
|
+
let visibleCount = 0;
|
|
276
|
+
for (const opt of optEls) {
|
|
277
|
+
opt.selected = this._isSelected(opt.value);
|
|
278
|
+
opt.keepOpen = this.multiple;
|
|
279
|
+
if (this.search && this.search !== 'managed' && this._searchQuery) {
|
|
280
|
+
const q = this._searchQuery.toLowerCase();
|
|
281
|
+
const label = opt.textContent?.trim() ?? '';
|
|
282
|
+
opt.filtered = !label.toLowerCase().includes(q);
|
|
283
|
+
if (!opt.filtered)
|
|
284
|
+
visibleCount += 1;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
opt.filtered = false;
|
|
288
|
+
visibleCount += 1;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
this._noOptionsVisible = visibleCount === 0;
|
|
292
|
+
}
|
|
293
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
294
|
+
get _selectedValues() {
|
|
295
|
+
if (!this.value)
|
|
296
|
+
return [];
|
|
297
|
+
return this.value
|
|
298
|
+
.split(',')
|
|
299
|
+
.map(v => v.trim())
|
|
300
|
+
.filter(Boolean);
|
|
301
|
+
}
|
|
302
|
+
_isSelected(value) {
|
|
303
|
+
if (!this.multiple) {
|
|
304
|
+
return this.value === value;
|
|
305
|
+
}
|
|
306
|
+
return this._selectedValues.includes(value);
|
|
307
|
+
}
|
|
308
|
+
/** Returns the display label for a given option value. */
|
|
309
|
+
_getLabelForValue(val) {
|
|
310
|
+
for (const opt of this.querySelectorAll('wc-option')) {
|
|
311
|
+
if (opt.value === val) {
|
|
312
|
+
const label = opt.textContent?.trim();
|
|
313
|
+
if (label)
|
|
314
|
+
return label;
|
|
315
|
+
return val === '' ? 'None' : val;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Fallback to options array (before wc-option children are created)
|
|
319
|
+
const programmaticLabel = this.options.find(o => o.value === val)?.label;
|
|
320
|
+
if (programmaticLabel)
|
|
321
|
+
return programmaticLabel;
|
|
322
|
+
return val === '' ? 'None' : val;
|
|
323
|
+
}
|
|
324
|
+
get _displayLabel() {
|
|
325
|
+
if (!this.value)
|
|
326
|
+
return '';
|
|
327
|
+
const firstValue = this._selectedValues[0];
|
|
328
|
+
if (!firstValue)
|
|
329
|
+
return '';
|
|
330
|
+
return this._getLabelForValue(firstValue);
|
|
331
|
+
}
|
|
332
|
+
get _isPopulated() {
|
|
333
|
+
return !!this.value;
|
|
334
|
+
}
|
|
335
|
+
// ── Menu open/close ────────────────────────────────────────────────────────
|
|
336
|
+
_openMenu() {
|
|
337
|
+
if (this.disabled || this.readonly)
|
|
338
|
+
return;
|
|
339
|
+
this._open = true;
|
|
340
|
+
this._focused = true;
|
|
341
|
+
this._triggerEl?.focus();
|
|
342
|
+
const menu = this._menu;
|
|
343
|
+
if (menu && this._triggerEl) {
|
|
344
|
+
// Anchor to the field's bordered box so the menu lines up with its edge
|
|
345
|
+
// and is at least as wide as the field.
|
|
346
|
+
const anchor = this._fieldEl?.fieldBodyElement ?? this._triggerEl;
|
|
347
|
+
menu.anchorElement = anchor;
|
|
348
|
+
menu.style.setProperty('--menu-min-width', `${Math.ceil(anchor.getBoundingClientRect().width)}px`);
|
|
349
|
+
menu.show();
|
|
350
|
+
}
|
|
351
|
+
if (this.search) {
|
|
352
|
+
this._searchQuery = '';
|
|
353
|
+
// Use rAF so that the search input receives focus *after* wc-menu has
|
|
354
|
+
// finished showing and potentially focused a menu item.
|
|
355
|
+
this.updateComplete.then(() => {
|
|
356
|
+
requestAnimationFrame(() => {
|
|
357
|
+
this._searchInputEl?.focus();
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
_closeMenu() {
|
|
363
|
+
if (!this._open)
|
|
364
|
+
return;
|
|
365
|
+
this._open = false;
|
|
366
|
+
this._focused = false;
|
|
367
|
+
this._searchQuery = '';
|
|
368
|
+
this._menu?.close();
|
|
369
|
+
}
|
|
370
|
+
// ── Event handlers ─────────────────────────────────────────────────────────
|
|
371
|
+
_handleTriggerClick(event) {
|
|
372
|
+
event.stopPropagation();
|
|
373
|
+
// Ignore clicks that originated inside the search input — those should not
|
|
374
|
+
// toggle the menu (the input needs to stay open so the user can type).
|
|
375
|
+
if (event.target instanceof HTMLInputElement) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (this._open) {
|
|
379
|
+
this._closeMenu();
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
this._openMenu();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
_handleFieldClick(event) {
|
|
386
|
+
const eventPath = event.composedPath();
|
|
387
|
+
if (eventPath.includes(this._triggerEl) ||
|
|
388
|
+
eventPath.some(target => target instanceof HTMLInputElement ||
|
|
389
|
+
(target instanceof HTMLElement &&
|
|
390
|
+
(target.closest('.clear-btn') != null ||
|
|
391
|
+
target.matches('wc-icon-button'))))) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (this._open) {
|
|
395
|
+
this._closeMenu();
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
this._openMenu();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
_handleTriggerKeyDown(event) {
|
|
402
|
+
// When the typeahead search input is active, let the input handle its own
|
|
403
|
+
// keys (Space, Enter, etc.). Only intercept Escape to close the menu.
|
|
404
|
+
if (event.target instanceof HTMLInputElement) {
|
|
405
|
+
if (event.key === 'Escape') {
|
|
406
|
+
event.preventDefault();
|
|
407
|
+
this._closeMenu();
|
|
408
|
+
}
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
switch (event.key) {
|
|
412
|
+
case 'Enter':
|
|
413
|
+
case ' ':
|
|
414
|
+
case 'ArrowDown':
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
if (!this._open)
|
|
417
|
+
this._openMenu();
|
|
418
|
+
break;
|
|
419
|
+
case 'Escape':
|
|
420
|
+
if (this._open) {
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
this._closeMenu();
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
_handleMenuClosed() {
|
|
428
|
+
this._open = false;
|
|
429
|
+
this._focused = false;
|
|
430
|
+
this._searchQuery = '';
|
|
431
|
+
}
|
|
432
|
+
_handleMenuItemActivate(event) {
|
|
433
|
+
const item = event.detail?.item;
|
|
434
|
+
if (!item)
|
|
435
|
+
return;
|
|
436
|
+
const val = item.value;
|
|
437
|
+
if (val === undefined)
|
|
438
|
+
return;
|
|
439
|
+
if (this.multiple) {
|
|
440
|
+
if (val === '')
|
|
441
|
+
return;
|
|
442
|
+
const values = this._selectedValues;
|
|
443
|
+
const idx = values.indexOf(val);
|
|
444
|
+
if (idx >= 0) {
|
|
445
|
+
values.splice(idx, 1);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
values.push(val);
|
|
449
|
+
}
|
|
450
|
+
this.value = values.join(',');
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
this.value = val;
|
|
454
|
+
this._closeMenu();
|
|
455
|
+
}
|
|
456
|
+
this._dispatchChange();
|
|
457
|
+
}
|
|
458
|
+
_dispatchChange() {
|
|
459
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
460
|
+
detail: { value: this.value },
|
|
461
|
+
bubbles: true,
|
|
462
|
+
composed: true,
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
_handleSearchInput(event) {
|
|
466
|
+
this._searchQuery = event.target.value;
|
|
467
|
+
if (this.search === 'managed') {
|
|
468
|
+
this.dispatchEvent(new CustomEvent('select-search', {
|
|
469
|
+
detail: { value: this._searchQuery },
|
|
470
|
+
bubbles: true,
|
|
471
|
+
composed: true,
|
|
472
|
+
}));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
_handleChipDismiss(event, chipValue) {
|
|
476
|
+
event.stopPropagation();
|
|
477
|
+
const values = this._selectedValues.filter(v => v !== chipValue);
|
|
478
|
+
this.value = values.join(',');
|
|
479
|
+
this._dispatchChange();
|
|
480
|
+
}
|
|
481
|
+
_renderEmptyState() {
|
|
482
|
+
const hasSearchQuery = this._searchQuery.trim().length > 0;
|
|
483
|
+
return b `
|
|
484
|
+
<wc-empty-state
|
|
485
|
+
class="select-empty-state content-center"
|
|
486
|
+
illustration="no-document"
|
|
487
|
+
headline=${hasSearchQuery ? 'No results found' : 'No options available'}
|
|
488
|
+
description=${hasSearchQuery
|
|
489
|
+
? 'Try a different search term.'
|
|
490
|
+
: 'There is nothing to select right now.'}
|
|
491
|
+
></wc-empty-state>
|
|
492
|
+
`;
|
|
493
|
+
}
|
|
494
|
+
// ── Render helpers ─────────────────────────────────────────────────────────
|
|
495
|
+
_renderTriggerContent() {
|
|
496
|
+
// Typeahead: when open, show a text input for filtering
|
|
497
|
+
if (this.search && this._open) {
|
|
498
|
+
return b `<input
|
|
499
|
+
class="search-input"
|
|
500
|
+
.value=${this._searchQuery}
|
|
501
|
+
placeholder=${this._displayLabel || this.placeholder}
|
|
502
|
+
@input=${this._handleSearchInput}
|
|
503
|
+
/>`;
|
|
504
|
+
}
|
|
505
|
+
// Multi-select: show chips for selected items
|
|
506
|
+
if (this.multiple && this._selectedValues.length > 0) {
|
|
507
|
+
return b `<div class="chips-container">
|
|
508
|
+
<wc-chip-set>
|
|
509
|
+
${this._selectedValues.map(val => b `
|
|
510
|
+
<wc-chip
|
|
511
|
+
dismissible
|
|
512
|
+
value=${val}
|
|
513
|
+
@dismiss=${(e) => this._handleChipDismiss(e, val)}
|
|
514
|
+
>${this._getLabelForValue(val)}</wc-chip
|
|
515
|
+
>
|
|
516
|
+
`)}
|
|
517
|
+
</wc-chip-set>
|
|
518
|
+
</div>`;
|
|
519
|
+
}
|
|
520
|
+
// Single select: show selected label or placeholder
|
|
521
|
+
const label = this._displayLabel;
|
|
522
|
+
if (!label) {
|
|
523
|
+
return b `<span class="placeholder">${this.placeholder}</span>`;
|
|
524
|
+
}
|
|
525
|
+
return b `<span class="display-value">${label}</span>`;
|
|
526
|
+
}
|
|
527
|
+
_renderFieldEnd() {
|
|
528
|
+
return b `
|
|
529
|
+
<wc-icon
|
|
530
|
+
class=${e$1({
|
|
531
|
+
'dropdown-icon': true,
|
|
532
|
+
'dropdown-icon--open': this._open,
|
|
533
|
+
})}
|
|
534
|
+
name="arrow_drop_down"
|
|
535
|
+
></wc-icon>
|
|
536
|
+
`;
|
|
537
|
+
}
|
|
538
|
+
render() {
|
|
539
|
+
return b `
|
|
540
|
+
<wc-field
|
|
541
|
+
label=${this.label}
|
|
542
|
+
?required=${this.required}
|
|
543
|
+
?disabled=${this.disabled}
|
|
544
|
+
?readonly=${this.readonly}
|
|
545
|
+
?skeleton=${this.skeleton}
|
|
546
|
+
helper-text=${this.helperText}
|
|
547
|
+
?error=${this.error}
|
|
548
|
+
error-text=${this.errorText}
|
|
549
|
+
?warning=${this.warning}
|
|
550
|
+
warning-text=${this.warningText}
|
|
551
|
+
variant=${this.variant}
|
|
552
|
+
?populated=${this._isPopulated || this._open}
|
|
553
|
+
?focused=${this._focused}
|
|
554
|
+
.host=${this}
|
|
555
|
+
class="select-field"
|
|
556
|
+
@click=${this._handleFieldClick}
|
|
557
|
+
>
|
|
558
|
+
<div
|
|
559
|
+
class="select-trigger"
|
|
560
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
561
|
+
role="combobox"
|
|
562
|
+
aria-label=${this.label || this.placeholder || 'Select option'}
|
|
563
|
+
aria-controls=${this._menuId}
|
|
564
|
+
aria-expanded=${String(this._open)}
|
|
565
|
+
aria-haspopup="listbox"
|
|
566
|
+
@click=${this._handleTriggerClick}
|
|
567
|
+
@keydown=${this._handleTriggerKeyDown}
|
|
568
|
+
>
|
|
569
|
+
${this._renderTriggerContent()}
|
|
570
|
+
</div>
|
|
571
|
+
|
|
572
|
+
<div slot="field-end" class="field-end-wrapper">
|
|
573
|
+
${this._renderFieldEnd()}
|
|
574
|
+
</div>
|
|
575
|
+
</wc-field>
|
|
576
|
+
|
|
577
|
+
<wc-menu
|
|
578
|
+
id=${this._menuId}
|
|
579
|
+
placement="bottom-start"
|
|
580
|
+
aria-label=${this.label || 'Options'}
|
|
581
|
+
@closed=${this._handleMenuClosed}
|
|
582
|
+
@menu-item-activate=${(e) => this._handleMenuItemActivate(e)}
|
|
583
|
+
>
|
|
584
|
+
<slot></slot>
|
|
585
|
+
${this._noOptionsVisible ? this._renderEmptyState() : A}
|
|
586
|
+
</wc-menu>
|
|
587
|
+
`;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
Select.styles = [css_248z];
|
|
591
|
+
__decorate([
|
|
592
|
+
n({ type: Array })
|
|
593
|
+
], Select.prototype, "options", void 0);
|
|
594
|
+
__decorate([
|
|
595
|
+
n({ type: String, reflect: true })
|
|
596
|
+
], Select.prototype, "value", void 0);
|
|
597
|
+
__decorate([
|
|
598
|
+
n({ type: Boolean, reflect: true })
|
|
599
|
+
], Select.prototype, "multiple", void 0);
|
|
600
|
+
__decorate([
|
|
601
|
+
n({ type: String })
|
|
602
|
+
], Select.prototype, "search", void 0);
|
|
603
|
+
__decorate([
|
|
604
|
+
n({ type: String })
|
|
605
|
+
], Select.prototype, "placeholder", void 0);
|
|
606
|
+
__decorate([
|
|
607
|
+
n({ type: String })
|
|
608
|
+
], Select.prototype, "label", void 0);
|
|
609
|
+
__decorate([
|
|
610
|
+
n({ type: String })
|
|
611
|
+
], Select.prototype, "variant", void 0);
|
|
612
|
+
__decorate([
|
|
613
|
+
n({ type: String, attribute: 'helper-text' })
|
|
614
|
+
], Select.prototype, "helperText", void 0);
|
|
615
|
+
__decorate([
|
|
616
|
+
n({ type: Boolean })
|
|
617
|
+
], Select.prototype, "error", void 0);
|
|
618
|
+
__decorate([
|
|
619
|
+
n({ type: String, attribute: 'error-text' })
|
|
620
|
+
], Select.prototype, "errorText", void 0);
|
|
621
|
+
__decorate([
|
|
622
|
+
n({ type: Boolean })
|
|
623
|
+
], Select.prototype, "warning", void 0);
|
|
624
|
+
__decorate([
|
|
625
|
+
n({ type: String, attribute: 'warning-text' })
|
|
626
|
+
], Select.prototype, "warningText", void 0);
|
|
627
|
+
__decorate([
|
|
628
|
+
r()
|
|
629
|
+
], Select.prototype, "_open", void 0);
|
|
630
|
+
__decorate([
|
|
631
|
+
r()
|
|
632
|
+
], Select.prototype, "_focused", void 0);
|
|
633
|
+
__decorate([
|
|
634
|
+
r()
|
|
635
|
+
], Select.prototype, "_searchQuery", void 0);
|
|
636
|
+
__decorate([
|
|
637
|
+
r()
|
|
638
|
+
], Select.prototype, "_noOptionsVisible", void 0);
|
|
639
|
+
__decorate([
|
|
640
|
+
e('.select-trigger')
|
|
641
|
+
], Select.prototype, "_triggerEl", void 0);
|
|
642
|
+
__decorate([
|
|
643
|
+
e('wc-field')
|
|
644
|
+
], Select.prototype, "_fieldEl", void 0);
|
|
645
|
+
__decorate([
|
|
646
|
+
e('.search-input')
|
|
647
|
+
], Select.prototype, "_searchInputEl", void 0);
|
|
648
|
+
Select = __decorate([
|
|
649
|
+
IndividualComponent
|
|
650
|
+
], Select);
|
|
651
|
+
|
|
652
|
+
export { Select };
|
|
653
|
+
//# sourceMappingURL=select.js.map
|