cus-outline-offset: 0px; --maui-focus-radius: 0; } .${e}:not(.disabled, .has-error) .control { color: var(--maui-color-text-caption); } .${e}:not(.disabled, .has-error).is-open .control, .${e}:not(.disabled, .has-error).has-value.is-open .control { color: var(--maui-color-interaction-interaction); --maui-icon-color-override: var(--maui-color-interaction-interaction); } .${e}:not(.disabled).has-error .control::placeholder { color: var(--maui-color-text-caption); } .${e}:not(.is-open, .disabled, .has-error).has-value .control { color: var(--maui-color-text-copy); } .${e} .trigger-label { height: var(--maui-line-height-3); transition: padding 0.3s ease-in-out; ${p({ size: "forms-large", tenant: a })}; } .${e}.has-value:not(.disabled, .has-focus, .has-error, .is-open), .${e}:not(.disabled, .has-focus, .has-error, .is-open) { --maui-icon-color-override: var(--maui-color-interaction-buttonsecondary); } .${e} { --maui-icon-color-override: var(--maui-color-interaction-interaction); } .${e}.has-focus:not(.disabled, .has-error) { --maui-icon-color-override: var(--maui-color-interaction-interaction); } .${e}:not(.disabled).has-error .control, .${e}:not(.disabled).has-error maui-icon { --maui-icon-color-override: var(--maui-color-message-error); color: var(--maui-color-message-error); } .${e} .options-wrapper { ${p({ size: "forms-medium", tenant: a })}; } `; }, cg = s` ${C} ${A} .autocomplete { font-family: var(--maui-font-family-copy); position: relative; } .trigger-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-bottom: 10px; } :focus-visible { outline: none; } .result-list { position: absolute; width: 100%; margin: var(--maui-select-dropdown-margin); background-color: var(--maui-select-dropdown-background-color); box-shadow: var(--maui-select-dropdown-shadow); border: var(--maui-select-dropdown-border); z-index: 100; } .options-wrapper { display: flex; align-items: baseline; ${p({ size: "forms-medium", tenant: "wl" })}; box-sizing: border-box; } .options-wrapper.with-group > * { flex: 1; width: calc(33.333% - 2px); } /* If there is no group it should not split the space equal */ .options-wrapper:not(.with-group) > *:not(:first-child) { padding-left: var(--maui-spacing-3, 10px); } .option-value { text-transform: uppercase; text-align: center; } .option-group { text-align: right; } .dropdown-list { list-style: none; padding: var(--maui-select-dropdown-padding); margin: 0; } .result-dropdown.scrolling { max-height: var(--maui-option-list-max-height, 300px); overflow-y: auto; } .bold { font-weight: var(--maui-font-weight-bold); } .skeleton-loaders-container li.skeleton-loader:last-child { width: 61.8%; } maui-error-highlight { display: block; } maui-hint { margin-top: 6px; } .disabled .control, .disabled maui-icon, .disabled maui-hint, .disabled .control::placeholder, .disabled .control[disabled] { --maui-select-button-color: var(--maui-color-disabled-foreground); --maui-label-color-override: var(--maui-color-disabled-foreground); --maui-hint-color-override: var(--maui-color-disabled-foreground); --maui-icon-color-override: var(--maui-color-disabled-foreground); color: var(--maui-color-disabled-foreground); } .icon-expand { transform: rotate(-180deg); transition: transform 0.25s linear; } /* last child is not working anymore needs to be fixed */ .dropdown-list li.skeleton-loader:last-child { width: 61.8%; } .dropdown-list li.skeleton-loader:last-of-type { width: 61.8%; } /* Outline has to be fixed and tranisiton */ maui-icon { outline: none; } .icon-wrapper button { outline: none; } .icon-wrapper .icon { transform: rotate(-180deg); transition: transform 0.25s linear !important; } .is-open .icon-expand { transform: rotate(0); } .wrapper { position: relative; } .overlay { position: absolute; right: var(--maui-select-clear-icon-right, 100px); top: 60%; transform: translateY(-50%); z-index: 2; color: var(--maui-select-optional-color, var(--maui-color-grey-07)); } .control[disabled], .disabled.has-value .control[disabled] { cursor: not-allowed; color: var(--maui-color-disabled-foreground); } `, dg = s` ${lg("lh")} `, ug = s` .os { --maui-select-button-background: var(--maui-color-grey-02); --maui-select-button-height: 50px; --maui-select-button-padding: 0 12px; --maui-select-trigger-label-padding-focus: 22px 0 5px 0px; --maui-select-dropdown-padding: 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-shadow: 0px 2px 4px rgba(57, 69, 81, 0.2); --maui-select-error-box-margin: 6px 0 0 0; --maui-select-hint-box-margin: 6px 0 0 0; --maui-select-dropdown-background-color: var(--maui-color-brand-white); --maui-select-clear-icon-right: 42px; font-weight: var(--maui-font-weight-regular); } .os:not(.disabled, .has-error) maui-icon { --maui-icon-color-override: var(--maui-color-grey-07); } .os .trigger input { border-radius: var(--maui-spacing-1, 3px); background-color: #f1f3f5; } .os .control { padding: 0 12px; font-weight: var(--maui-font-weight-regular); ${p({ size: "forms-large", tenant: "os" })}; } .os .options-wrapper { ${p({ size: "forms-medium", tenant: "os" })}; } .os.has-value .control, .os.is-open .control { padding: 21px 12px 4px; } .os .control::placeholder { color: var(--maui-color-grey-07); padding-top: 0px; } .os:not(:disabled) .control { color: var(--maui-color-text-copy); } .os.disabled .control::placeholder { color: var(--maui-color-disabled-foreground); } .os.has-value .label, .os.has-focus .label { opacity: 1; } .os.has-error .control { color: var(--maui-color-message-error); font-weight: var(--maui-font-weight-regular); } .os:not(.disabled).has-error .control, .os:not(.disabled).has-error maui-icon, .os:not(.disabled).has-error .control::placeholder { --maui-icon-color-override: var(--maui-color-message-error); color: var(--maui-color-message-error); } `, mg = s` .lx { --maui-select-button-color: var(--maui-color-interaction-interaction); --maui-select-button-border: 1px solid var(--maui-color-grey-02); --maui-select-button-border-error: 1px solid var(--maui-color-message-error); --maui-select-button-border-disabled: 1px solid var(--maui-color-disabled-foreground); --maui-select-button-padding: 0px 11px; --maui-select-dropdown-padding: 10px 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-border: var(--maui-select-button-border); --maui-select-error-box-margin: 6px 0 0 0; --maui-select-hint-box-margin: 8px 0 0 0; --maui-select-dropdown-background-color: var(--maui-color-brand-white); --maui-select-button-height: 50px; --maui-select-trigger-label-padding-focus: 21px 0 2px 0px; --maui-select-clear-icon-right: 41px; font-family: var(--maui-font-family-copy, sans-serif); } /* label font size 12 px */ .lx .label { pointer-events: none; position: absolute; z-index: 2; left: 12px; top: 7px; opacity: 0; color: var(--maui-color-interaction-interaction); } /* Linehight for control 24px in figmar but dont exists */ .lx .control { padding: 0 12px; line-height: var(--maui-line-height-2); color: var(--maui-color-text-copy); font-weight: var(--maui-font-weight-regular); ${p({ size: "forms-large", tenant: "lx" })}; } .lx .dropdown { line-height: var(--maui-line-height-3); } .lx.has-value .control, .lx.is-open .control { padding: 21px 0px 1px 11px; } .lx .control::placeholder { font-family: var(--maui-font-family-copy, sans-serif); color: var(--maui-color-interaction-buttonsecondary); padding-top: 0px; } .lx .trigger-label { font-weight: var(--maui-font-weight-regular); ${p({ size: "forms-large", tenant: "lx" })}; } .lx .options-wrapper { ${p({ size: "forms-medium", tenant: "lx" })}; } .lx.has-value .trigger-label { padding: var(--maui-select-trigger-label-padding-focus); } .lx.has-value .label, .lx.has-focus .label { opacity: 1; } `, hg = s` .sn { --maui-select-button-border: 1px solid var(--maui-color-grey-07); --maui-select-button-border-error: 1px solid var(--maui-color-message-error); --maui-select-button-border-disabled: 1px solid var(--maui-color-disabled-foreground); --maui-select-button-padding: 13px 10px; --maui-select-dropdown-padding: 10px 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-border: 1px solid var(--maui-color-grey-04); --maui-select-error-box-margin: 5px 0 0 0; --maui-select-hint-box-margin: 5px 0 0 0; --maui-select-dropdown-background-color: var(--maui-color-brand-white); --maui-select-button-height: 50px; --maui-select-trigger-label-padding-focus: 21px 0 5px 0px; --maui-select-clear-icon-right: 39px; --maui-focus-outline-offset: 5px; --maui-focus-radius: 0px; } .sn:not(.has-value) .control { padding-left: 10px; color: var(--maui-color-text-caption); } .sn.has-value:not(.disabled) .control, .sn.is-open .control { padding: 21px 0 7px 9px; line-height: var(--maui-line-height-4); } .sn.has-error:not(.disabled) .control, .sn.has-error:not(.disabled) .control::placeholder { color: var(--maui-color-message-error); } .sn:not(.disabled) { --maui-icon-color-override: var(--maui-color-interaction-buttonsecondary); } .sn .label { pointer-events: none; position: absolute; z-index: 2; left: 10px; top: 6px; opacity: 0; color: var(--maui-color-text-caption); } .sn .trigger-label { font-weight: var(--maui-font-weight-regular); ${p({ size: "forms-large", tenant: "sn" })}; } .sn maui-hint { margin-top: 5px; } .sn .options-wrapper { ${p({ size: "forms-medium", tenant: "sn" })}; } .sn.has-value .trigger-label { padding: var(--maui-select-trigger-label-padding-focus); } .sn.disabled.has-value .control { padding: 21px 0 5px 10px; } `, pg = s` .b2b { --maui-select-button-color-value: var( --maui-color-interaction-buttonprimary ); --maui-select-button-border-bottom: 2px solid var(--maui-color-grey-07); --maui-select-button-border-bottom-disabled: 2px solid var(--maui-color-disabled-foreground); --maui-select-button-padding: 6px 5px 6px 0; --maui-select-trigger-label-padding-focus: 0 0 0 10px; --maui-select-dropdown-padding: 10px 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-shadow: 0px 0px 4px rgba(0, 0, 0, 0.3); --maui-select-button-shadow-error: 0px 0px 6px var(--maui-color-message-error); --maui-select-dropdown-background-color: var(--maui-color-brand-white); --maui-select-clear-icon-right: 34px; --maui-focus-outline-offset: 0px; --maui-focus-radius: 0; } .b2b .trigger-label { ${p({ size: "forms-large", tenant: "b2b" })}; font-weight: var(--maui-font-weight-regular); height: var(--maui-line-height-3); transition: padding 0.3s ease-in-out; } .b2b .options-wrapper { ${p({ size: "forms-medium", tenant: "b2b" })}; } .b2b .trigger { border-bottom: var(--maui-select-button-border-bottom); } .b2b.has-value:not(.disabled, .has-focus, .has-error) .trigger { --maui-select-button-color: var(--maui-select-button-color-value); border-bottom-color: var(--maui-select-button-color-value); } .b2b.has-value:not(.disabled, .has-focus, .has-error) { --maui-icon-color-override: var(--maui-select-button-color-value); } .b2b.has-focus:not(.disabled, .has-error) .trigger { --maui-select-button-color: var(--maui-color-interaction-interaction); border-bottom-color: var(--maui-color-interaction-interaction); } .b2b.has-focus:not(.disabled, .has-error) { --maui-icon-color-override: var(--maui-color-interaction-interaction); } .b2b.has-error:not(.disabled) .trigger { --maui-select-button-color: var(--maui-color-message-error); border-bottom-color: var(--maui-color-message-error); } .b2b.disabled .trigger { border-bottom-color: var(--maui-select-button-border-bottom-disabled); } `, gg = s` .four_y { --maui-input-inset: calc(var(--maui-spacing-3) + var(--maui-spacing-2)); --maui-select-button-border: 1px solid var(--maui-color-grey-07); --maui-select-button-border-error: 1px solid var(--maui-color-message-error); --maui-select-button-border-disabled: 1px solid var(--maui-color-disabled-foreground); --maui-select-button-padding: 13px 10px; --maui-select-dropdown-padding: 10px 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-border: 1px solid var(--maui-color-grey-04); --maui-select-error-box-margin: 5px 0 0 0; --maui-select-hint-box-margin: 5px 0 0 0; --maui-select-dropdown-background-color: var(--maui-color-brand-white); --maui-select-button-height: 50px; --maui-select-trigger-label-padding-focus: 21px 0 5px var(--maui-input-inset); --maui-select-clear-icon-right: 39px; --maui-focus-outline-offset: 3px; --maui-focus-radius: 0px; } .four_y:not(.has-value) .control { color: var(--maui-color-interaction-interaction); } .four_y.has-value:not(.disabled) .control, .four_y.is-open .control { padding: 21px 0 5px var(--maui-input-inset); line-height: var(--maui-line-height-4); } .four_y:not(.disabled) { --maui-icon-color-override: var(--maui-color-interaction-buttonsecondary); } .four_y .label { pointer-events: none; position: absolute; z-index: 2; left: 10px; top: 6px; opacity: 0; color: var(--maui-color-text-caption); } .four_y .trigger-label { font-weight: var(--maui-font-weight-regular); color: var(--maui-color-interaction-interaction); ${p({ size: "forms-large", tenant: "four_y" })}; } .four_y.has-value .trigger-label { font-weight: var(--maui-font-weight-bold); } .four_y .hint-error-box { margin-left: var(--maui-input-inset); } .four_y maui-hint { margin-top: 6px; } .four_y .options-wrapper { ${p({ size: "forms-medium", tenant: "four_y" })}; } .four_y.disabled.has-value .control { padding: 21px 0 5px var(--maui-input-inset); } .four_y .result-list { width: calc(100% - (var(--maui-spacing-2) * 2)); margin-left: var(--maui-spacing-2); overflow: hidden; border-radius: var(--maui-radii-radius-4); box-shadow: var(--maui-effect-elevation-1); } `, bg = s` .mmg { --maui-select-button-background: var(--maui-color-brand-light); --maui-select-button-height: 50px; --maui-select-button-padding: 0 12px; --maui-select-trigger-label-padding-focus: 22px 0 5px 0px; --maui-select-dropdown-padding: 0; --maui-select-dropdown-margin: 10px 0 0 0; --maui-select-dropdown-shadow: 0px 2px 4px rgba(57, 69, 81, 0.2); --maui-select-error-box-margin: 6px 0 0 0; --maui-select-hint-box-margin: 6px 0 0 0; --maui-select-dropdown-background-color: var(--maui-color-brand-light); --maui-select-clear-icon-right: 42px; --maui-select-option-padding: var(--maui-spacing-3) var(--maui-spacing-2); --maui-select-option-color: var(--maui-color-text-copy); --maui-select-option-background-selected: var( --maui-color-interaction-interaction ); --maui-select-option-background-hover: var( --maui-color-interaction-interactionhover ); --maui-select-option-color-hover: var( --maui-color-interaction-interaction-inverted ); --maui-select-option-font-weight: var(--maui-font-weight-regular); font-weight: var(--maui-font-weight-regular); } .mmg:not(.disabled, .has-error) maui-icon { --maui-icon-color-override: var(--maui-color-grey-07); } .mmg .trigger input { border-radius: var(--maui-spacing-1, 3px); } .mmg .control { padding: 0 var(--maui-spacing-3); font-weight: var(--maui-font-weight-regular); ${p({ size: "forms-large", tenant: "mmg" })}; } .mmg .options-wrapper { ${p({ size: "forms-large", tenant: "mmg" })}; } .mmg.has-value .control, .mmg.is-open .control { padding: var(--maui-spacing-5) var(--maui-spacing-3) var(--maui-spacing-1) var(--maui-spacing-3); } .mmg .control::placeholder { color: var(--maui-color-grey-07); padding-top: 0px; } .mmg.disabled .control::placeholder { color: var(--maui-color-disabled-foreground); } .mmg.has-value .label, .mmg.has-focus .label { opacity: 1; } .mmg.has-error .control { font-weight: var(--maui-font-weight-regular); color: var(--maui-color-message-error); } .mmg:not(.disabled).has-error .control, .mmg:not(.disabled).has-error maui-icon, .mmg:not(.disabled).has-error .control::placeholder { --maui-icon-color-override: var(--maui-color-message-error); color: var(--maui-color-message-error); } .mmg.optgroup { font-weight: var(--maui-select-option-font-weight); } .mmg .icon-expand { transform: rotate(135deg); } .mmg.is-open .icon-expand { transform: rotate(0deg); } `, vg = [ cg, dg, ug, mg, hg, pg, gg, bg ]; class ni { } function wr(a, e, t = !1) { let o; return function(...i) { const r = this, n = () => { o = null, t || e.apply(r, i); }, c = t && !o; typeof o == "number" && clearTimeout(o), o = setTimeout(n, a), c && e.apply(r, i); }; } function fg(a) { return (e, t, o) => { o.value = wr(a, e[t]); }; } var yg = Object.defineProperty, xg = Object.getOwnPropertyDescriptor, J = (a, e, t, o) => { for (var i = o > 1 ? void 0 : o ? xg(e, t) : e, r = a.length - 1, n; r >= 0; r--) (n = a[r]) && (i = (o ? n(e, t, i) : n(i)) || i); return o && i && yg(e, t, i), i; }; class V extends Te { constructor(e) { super(), this.slottedOptions = [], this.optionList = [], this.formControlController = new tt(this, { value: (t) => t.value }), this.fetchedOptions = [], this.isOpen = !1, this.disabled = !1, this.hint = "", this.placeholderPermanent = !1, this.scrollingOptions = "scrolling", this.debounced = !1, this.initializeSlotObserver = () => { const t = this.querySelectorAll("maui-option, maui-optgroup"); t.length > 0 && t.forEach((o) => { o.nodeType === Node.ELEMENT_NODE && this.mutationObserver.observe(o, { childList: !0, subtree: !0, characterData: !0 }); }); }, this.debounceUserInput = wr(500, () => { this.userInput = "", this.debounced = !1; }), this.componentName = e, this.addEventListener("maui-init-selected", (t) => { this.selectOption(t.detail, !1); }), this.addEventListener("maui-selected", (t) => { this.checkState(t.detail); }), this.mutationObserver = new MutationObserver( this.handleSlotTextContentChange.bind(this) ); } /** * find MAUIOption of currently selected option * @param selectedOption label and value state of selected option * @returns selected MAUIOption node */ getSelectedOption(e) { return this.getOptions().find( (t) => t.getAttribute("optionValue") === e?.value ); } connectedCallback() { super.connectedCallback(), this.handleOutsideClick = this.handleOutsideClick.bind(this), this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this), this.isOpen = !1, this.fetchedOptions = [], this.initializeSlotObserver(); } disconnectedCallback() { super.disconnectedCallback(), this.mutationObserver.disconnect(); } updated(e) { super.updated(e), e.has("disabled") && (this.isOpen = !1), e.has("isOpen") && this.isOpen && this.scrollToSelectedOption(); } scrollToSelectedOption() { requestAnimationFrame(() => { const e = this.shadowRoot?.querySelector("[selected]"); e && e.scrollIntoView({ behavior: "auto", block: "center" }); }); } addOpenListeners() { document.addEventListener("focusin", this.handleOutsideClick), document.addEventListener("keydown", this.handleDocumentKeyDown), document.addEventListener("mousedown", this.handleOutsideClick); } removeOpenListeners() { document.removeEventListener("focusin", this.handleOutsideClick), document.removeEventListener("keydown", this.handleDocumentKeyDown), document.removeEventListener("mousedown", this.handleOutsideClick), this.unobserveIntersection(); } handleOutsideClick(e) { const t = e.composedPath(); this && !t.includes(this) && this.handleBlur(); } handleFocus(e) { super.handleFocus(), this.trigger.focus(e); } handleBlur() { super.handleBlur(), this.trigger.blur(), this.isOpen = !1; } focus(e) { this.handleFocus(e); } blur() { this.handleBlur(); } handleClick() { this.isOpen = !this.isOpen; } handleOptionClick(e) { const o = e.target.closest("maui-option"); o && this.selectOption(o); } /** set aria-label instead of aria-labelledby, because id cannot be resolved */ setAriaLabelFromExternalLabel() { } /** * synchronize selected option with selected state (see checkState) * * then synchronize selected state with selected option * @param option selected option * @param shallFocus whether to close the dropdown and focus the input after selection, e.g. after interaction */ selectOption(e, t = !0) { const o = this.selectedOption?.value; this.checkState(e), this.selectedOption?.value && this.selectedOption?.value !== o ? (this.getOptions().forEach((i) => { i.getAttribute("optionValue") === this.selectedOption?.value ? (i.setAttribute("selected", ""), i.originalOption?.setAttribute("selected", "")) : i.hasAttribute("selected") && (i.removeAttribute("selected"), i.originalOption?.removeAttribute("selected")); }), this.emit("maui-change", { detail: this.selectedOption })) : !this.selectedOption && o && (this.getOptions().forEach((i) => { i.hasAttribute("selected") && (i.removeAttribute("selected"), i.originalOption?.removeAttribute("selected")); }), this.emit("maui-change", { detail: this.selectedOption })), t && (this.isOpen = !1, this.trigger.focus()); } loadMore(e, t) { !this.isOpen || !e[0].isIntersecting || ni.mode === "skeleton" || (t.unobserve(e[0].target), this.emit("maui-load")); } observeAnchorItem() { this.anchor && this.observer.observe(this.anchor); } // Triggers actions if text within the slot changes. handleSlotTextContentChange(e) { for (const t of e) (t.type === "characterData" || t.type === "childList") && (this.updateSelectedOption(), this.handleOptionsSlotChange()); } // Only if slot changes, updates the selectedOption based on the current 'maui-option' elements, sets it to undefined if no match is found. updateSelectedOption() { const e = this.querySelectorAll("maui-option"); let t = !1; e.forEach((o) => { const i = o.getAttribute("optionvalue"), r = o.textContent?.trim() ?? ""; this.selectedOption && i === this.selectedOption.value && (r !== this.selectedOption.label && (this.selectedOption.label = r), t = !0); }), t || (this.selectedOption = void 0); } attachAnchor() { const e = document.createElement("li"); if (e.id = "infinity-loading-anchor", Array.from(this.dropdownList.classList).includes("result-dropdown")) { this.dropdownList.querySelector("ul")?.append(e); return; } this.dropdownList.append(e); } setCurrentOption(e) { this.getOptions().forEach((t) => { t.isCurrent = !1, t.tabIndex = -1; }), e ? (this.currentOption = e, this.currentOption.isCurrent = !0, this.currentOption.scrollIntoView({ block: "nearest", inline: "nearest" })) : this.currentOption = void 0; } /** * synchronize selected option with selected state, i.e. * * this.selected = this.selectedOption.value * @param option selected option */ checkState(e) { if (e) { if (this.selectedOption?.value !== e.optionValue) { const t = e.defaultSlot?.assignedNodes({ flatten: !0 })[0], o = t instanceof Element ? t?.querySelector(".option-label") : null; this.selectedOption = { value: e.optionValue, label: e.label || (o || e.defaultSlot?.assignedNodes({ flatten: !0 })[0] || e)?.textContent || // stepper if dropdown closed, i.e. no slot rendered // should not happen, render submit value as last resort e.optionValue }, this.value = this.selectedOption.value || "", this.selected = this.selectedOption.value || ""; } } else this.selectedOption = void 0, this.value = ""; } handleMouseMove(e) { const o = e.target.closest("maui-option"); o && this.currentOption !== o && this.setCurrentOption(o); } /** unset hovered option when dropdown-list is no longer hovered */ handleMouseLeave() { this.setCurrentOption(void 0); } handleDocumentKeyDown(e) { if (e.key === "Escape" && this.isOpen) { e.preventDefault(), this.isOpen = !1, this.trigger.focus(); return; } if (e.key === "Tab") { this.isOpen && (this.currentOption && this.selectOption(this.currentOption, !1), this.isOpen = !1, this.trigger.focus()); return; } if (e.key === "Enter" || e.key === " ") { if (!this.isOpen) { e.preventDefault(), this.isOpen = !0; return; } this.currentOption && (e.preventDefault(), this.selectOption(this.currentOption)); return; } if (["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) { const t = this.getOptions().indexOf(this.currentOption); let o = Math.max(0, t); if (e.preventDefault(), !this.isOpen && (this.isOpen = !0, this.currentOption)) return; e.key === "ArrowDown" ? (o = t + 1, o > this.getOptions().length - 1 && (o = 0)) : e.key === "ArrowUp" ? (o = t - 1, o < 0 && (o = this.getOptions().length - 1)) : e.key === "Home" ? o = 0 : e.key === "End" && (o = this.getOptions().length - 1), this.setCurrentOption(this.getOptions()[o]); } } /** Include whitespaces when debounced(actively performing letterSearch) since we want to preserve e.g. spacebar keydown functionality for selecting option */ isVisualCharacter(e) { return this.debounced ? /^[\s\S]$/.test(e) : /^[\S]$/.test(e); } /** Search for options by typing visual characters */ letterSearch(e) { if (this.isVisualCharacter(e.key)) { this.userInput = this.userInput ? this.userInput + e.key : e.key; const t = this.getOptions().find( (o) => o.textContent?.toLowerCase().startsWith(this.userInput.toLowerCase()) ); this.debounced = !0, this.debounceUserInput(), t && (this.selectOption(t, !1), this.setCurrentOption(t)); } } handleComboboxKeyDown(e) { e.stopPropagation(), this.handleDocumentKeyDown(e); } async handleOpenChange() { this.isOpen && !this.disabled ? (this.setCurrentOption( this.getSelectedOption(this.selectedOption) || void 0 ), this.addOpenListeners(), await this.updateComplete, this.initIntersectionObserve()) : this.removeOpenListeners(); } initIntersectionObserve() { this.dropdownList && (this.observer && this.unobserveIntersection(), this.observer = new IntersectionObserver(this.loadMore.bind(this), { threshold: 0.1, root: this.dropdownList }), this.attachAnchor(), this.observeAnchorItem()); } unobserveIntersection() { this.observer.disconnect(); } handleSelectionChange() { const e = this.getOptions().find( (t) => t.optionValue === this.selected ); e && this.selectOption(e, !1); } handleClearClick() { this.selectOption(null); } /** get options on slotchange to update this.options */ getOptions() { return this.slottedOptions; } updateOptions(e = "maui-optgroup, maui-option") { this.optionList = []; const t = []; return this.querySelectorAll(e).forEach((i) => { if (i.tagName.toLowerCase() === "maui-optgroup") { const r = this.cloneOptGroup(i); this.optionList.push(r), t.push(...r.querySelectorAll("maui-option")); } else if (!i.closest("maui-optgroup")) { const r = this.cloneOption(i); t.push(r), this.optionList.push(r); } }), t; } cloneOption(e) { const t = e.cloneNode(!0); return t.originalOption = e, t; } cloneOptGroup(e) { const t = document.createElement( "maui-optgroup" ); return t.label = e.label, t.hasTopBorder = e.hasTopBorder, e.querySelectorAll("maui-option").forEach((o) => { t.appendChild(this.cloneOption(o)); }), t; } // eslint-disable-next-line @typescript-eslint/no-unused-vars handleOptionsSlotChange(e) { this.slottedOptions = this.updateOptions(), this.slottedOptions.forEach((t, o) => { t.setAttribute("theme", this.theme), t.setAttribute("id", t.id || `${this.id}-${o}`); }), this.handleSelectionChange(), this.initializeSlotObserver(), this.updateSelectedOption(); } // only in select // eslint-disable-next-line @typescript-eslint/no-unused-vars renderLabel(e) { return ""; } renderExpandIcon() { return ""; } renderOptionalLabel() { return ""; } renderClearButton() { return ""; } shouldRenderPlaceholder() { return !1; } renderSelectOrInput(e, t) { return u``; } renderHintOrError() { return ""; } /** * for accessibility reasons, the slot contents are copied to the shadow-dom. * The hidden slot continues to listen to top-level DOM changes in the slot * @returns rendered result list */ renderResultList() { return u`