UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

5 lines 27.5 kB
/*! * KoliBri - The accessible HTML-Standard */ import{h as n,r as e,g as t}from"./index-BQlHOxik.js";import{_ as i}from"./tslib.es6-QNbPBOk5.js";import{b as o}from"./component-names-Dy77vq43.js";import{a as s,F as a}from"./FormFieldStateWrapper-BWTMRKXT.js";import{I as l,a as r}from"./controller-icon-DekcIBGR.js";import{I as h}from"./InputStateWrapper-CDDIvfo0.js";import{C as c,a as d}from"./CustomSuggestionsOptionsGroup-86r-pE0e.js";import{t as f}from"./i18n-Br16IAnY.js";import{I as u}from"./component-DzaT2WlJ.js";import{c as m}from"./clsx-COFh-Vc8.js";import{c as p}from"./dev.utils-02Sl9bQo.js";import{d as b,a as k,c as g}from"./element-interaction-Bv-mPSBn.js";import{e as v,g as y}from"./common-Cx_AGO_M.js";import{v as w}from"./placeholder-DTOUrN5s.js";import{v as _}from"./required-DFzRSWky.js";import{v as x}from"./suggestions-DEcHprcz.js";import"./access-and-short-key-D734WtlX.js";import"./disabled-gyBUQRnY.js";import"./hide-label-6Bx1MH20.js";import"./label-Fyi30H9j.js";import"./tooltip-align-mwhvx9nK.js";import"./align-DxZmRFcp.js";import"./variant-class-name-BCcQYpIV.js";import"./events-VVvk1win.js";import"./associated.controller-Bagx9pCw.js";import"./bootstrap-DPKvOz00.js";import"./i18n-B2d_exHc.js";import"./_Uint8Array-kJHDjtoP.js";import"./isArray-CcrBs4JM.js";import"./variant-quote-y0Z1TRdz.js";import"./normalizers-m3s9sgmq.js";import"./component-Dh0cPCxF.js";import"./component-DvjvBJeK.js";import"./bem-registry-CWvl2xho.js";import"./controller-Bdve6A-Q.js";import"./align-floating-elements-D5XJiLiU.js";import"./tooltip-open-tracking-D3tCiiGP.js";import"./label-KTv-zMW0.js";import"./base-controller-CXhqh4cR.js";import"./Alert-BP_7bRZF.js";import"./Heading-q2Ue3Ixd.js";import"./icons-oAzMYWgV.js";import"./Input-DQJln-L5.js";import"./element-focus-CRwW4N4R.js";class j extends l{constructor(n,e,t){super(n,e,t);this.component=n}validateHasClearButton(n){v(this.component,"_hasClearButton",n)}validatePlaceholder(n){w(this.component,n)}validateRequired(n){_(this.component,n)}validateSuggestions(n){x(this.component,n)}validateValue(n){y(this.component,"_value",n)}componentWillLoad(){super.componentWillLoad();this.validateHasClearButton(this.component._hasClearButton);this.validatePlaceholder(this.component._placeholder);this.validateRequired(this.component._required);this.validateSuggestions(this.component._suggestions);this.validateValue(this.component._value)}}const z='@charset "UTF-8";\n/*\n* This file defines the layer order for all CSS layers used in KoliBri.\n* The order is important as it determines the cascade priority.\n*\n* Layer order (lowest to highest priority):\n* 1. kol-a11y - Accessibility defaults and requirements\n* 2. kol-global - Global component styles and resets\n* 3. kol-component - Component-specific styles\n* 4. kol-theme-global - Theme-specific global styles\n* 5. kol-theme-component - Theme-specific component styles\n*/\n@layer kol-a11y, kol-global, kol-component, kol-theme-global, kol-theme-component;\n/* forward the rem function */\n/*\n * This file contains all rules for accessibility.\n */\n@layer kol-a11y {\n :host {\n /*\n * Minimum size of interactive elements.\n */\n --a11y-min-size: calc(44 * 1rem / var(--kolibri-root-font-size, 16));\n /*\n * No element should be used without verifying the contrast ratio of its background and font colors.\n * By initially setting the background color to white and the font color to black,\n * the contrast ratio is ensured and explicit adjustment is forced.\n */\n color: black;\n background-color: white;\n /*\n * Verdana is an accessible font that can be used without requiring additional loading time.\n */\n font-family: Verdana;\n /*\n * Letter spacing is required for all texts.\n */\n letter-spacing: inherit;\n /*\n * Word spacing is required for all texts.\n */\n word-spacing: inherit;\n /*\n * Text should be aligned left by default to provide a predictable starting point.\n */\n text-align: left;\n }\n * {\n /*\n * This rule enables the word dividing for all texts. That is important for high zoom levels.\n */\n hyphens: auto;\n /*\n * This rule enables the word dividing for all texts. That is important for high zoom levels.\n */\n word-break: break-word;\n }\n /*\n * All interactive elements should have a minimum size of to-rem(44).\n */\n /* input:not([type=\'checkbox\'], [type=\'radio\'], [type=\'range\']), */\n /* option, */\n /* select, */\n /* textarea, */\n button,\n .kol-input .input {\n min-width: var(--a11y-min-size);\n min-height: var(--a11y-min-size);\n }\n /*\n * Some interactive elements should not inherit the font-family and font-size.\n */\n a,\n button,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n input,\n option,\n select,\n textarea {\n /*\n * All elements should inherit the text color from his parent element.\n */\n color: inherit;\n /*\n * All elements should inherit the font family from his parent element.\n */\n font-family: inherit;\n /*\n * All elements should inherit the font size from his parent element.\n */\n font-size: inherit;\n /*\n * Letter spacing is required for all texts.\n */\n letter-spacing: inherit;\n /*\n * Word spacing is required for all texts.\n */\n word-spacing: inherit;\n }\n /**\n * Sometimes we need the semantic element for accessibility reasons,\n * but we don\'t want to show it.\n *\n * - https://www.a11yproject.com/posts/how-to-hide-content/\n */\n .visually-hidden {\n position: fixed;\n top: 0;\n left: 0;\n width: 1px;\n height: 1px;\n overflow: hidden;\n white-space: nowrap;\n clip-path: inset(50%);\n }\n}\n@layer kol-global {\n /*\n * Dieses CSS stellt sicher, dass der Standard-Style\n * von A und Button resettet werden.\n */\n :is(a, button) {\n background-color: transparent;\n width: 100%;\n margin: 0;\n padding: 0;\n border: none;\n /* 100% needed for custom width from outside */\n }\n /*\n * Ensure elements with hidden attribute to be actually not visible\n * @see https://meowni.ca/hidden.is.a.lie.html\n */\n [hidden] {\n display: none !important;\n }\n .badge-text-hint {\n color: black;\n background-color: white;\n }\n}\n@layer kol-global {\n :host {\n /*\n * The max-width is needed to prevent the table from overflowing the\n * parent node, if the table is wider than the parent node.\n */\n max-width: 100%;\n font-size: calc(16 * 1rem / var(--kolibri-root-font-size, 16));\n }\n * {\n /*\n * We prefer to box-sizing: border-box for all elements.\n */\n box-sizing: border-box;\n }\n .kol-span {\n /* KolSpan is a layout component with icons in all directions and a label text in the middle. */\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: center;\n /* The sub span in KolSpan is the horizontal span with icon left and right and the label text in the middle. */\n }\n .kol-span__container {\n display: flex;\n align-items: center;\n }\n a,\n button {\n cursor: pointer;\n }\n .kol-span .kol-span__label--hide-label .kol-span__label {\n display: none;\n }\n /* Reset browser agent style. */\n button:disabled {\n color: unset;\n }\n .disabled label,\n .disabled:focus-within label,\n [aria-disabled=true],\n [aria-disabled=true]:focus,\n [disabled],\n [disabled]:focus {\n outline: none;\n cursor: not-allowed;\n }\n [aria-disabled=true]:focus .kol-span,\n [disabled]:focus .kol-span {\n outline: none !important;\n }\n .hastooltip {\n z-index: 900 !important;\n }\n}\n@layer kol-component {\n :host {\n display: block;\n }\n}\n@font-face {\n font-family: "kolicons";\n src: url("kolicons.eot?t=1780571516250"); /* IE9*/\n src: url("kolicons.eot?t=1780571516250#iefix") format("embedded-opentype"), url("kolicons.woff2?t=1780571516250") format("woff2"), url("kolicons.woff?t=1780571516250") format("woff"), url("kolicons.ttf?t=1780571516250") format("truetype"), url("kolicons.svg?t=1780571516250#kolicons") format("svg"); /* iOS 4.1- */\n}\n@layer kol-component {\n [class^=kolicon-], [class*=" kolicon-"] {\n font-family: "kolicons";\n font-style: normal;\n font-weight: 400;\n line-height: 1em;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n .kolicon-alert-error::before {\n content: "\\ea01";\n }\n .kolicon-alert-info::before {\n content: "\\ea02";\n }\n .kolicon-alert-success::before {\n content: "\\ea03";\n }\n .kolicon-alert-warning::before {\n content: "\\ea04";\n }\n .kolicon-check::before {\n content: "\\ea05";\n }\n .kolicon-chevron-double-left::before {\n content: "\\ea06";\n }\n .kolicon-chevron-double-right::before {\n content: "\\ea07";\n }\n .kolicon-chevron-down::before {\n content: "\\ea08";\n }\n .kolicon-chevron-left::before {\n content: "\\ea09";\n }\n .kolicon-chevron-right::before {\n content: "\\ea0a";\n }\n .kolicon-chevron-up::before {\n content: "\\ea0b";\n }\n .kolicon-cogwheel::before {\n content: "\\ea0c";\n }\n .kolicon-cross::before {\n content: "\\ea0d";\n }\n .kolicon-eye-closed::before {\n content: "\\ea0e";\n }\n .kolicon-eye::before {\n content: "\\ea0f";\n }\n .kolicon-house::before {\n content: "\\ea10";\n }\n .kolicon-kolibri::before {\n content: "\\ea11";\n }\n .kolicon-link-external::before {\n content: "\\ea12";\n }\n .kolicon-link::before {\n content: "\\ea13";\n }\n .kolicon-minus::before {\n content: "\\ea14";\n }\n .kolicon-plus::before {\n content: "\\ea15";\n }\n .kolicon-settings::before {\n content: "\\ea16";\n }\n .kolicon-sort-asc::before {\n content: "\\ea17";\n }\n .kolicon-sort-desc::before {\n content: "\\ea18";\n }\n .kolicon-sort-neutral::before {\n content: "\\ea19";\n }\n .kolicon-up::before {\n content: "\\ea1a";\n }\n .kolicon-version::before {\n content: "\\ea1b";\n }\n}\n@layer kol-component {\n .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-tooltip {\n display: contents;\n }\n .kol-tooltip__floating {\n opacity: 0;\n display: none;\n position: fixed;\n /* Avoid layout interference - see https://floating-ui.com/docs/computePosition */\n top: 0;\n left: 0;\n /* Can be used to specify the tooltip-width from the outside. Unset by default. */\n width: var(--kol-tooltip-width, max-content);\n min-width: calc(8 * 1rem / var(--kolibri-root-font-size, 16));\n max-width: 90vw;\n max-height: 90vh;\n animation-direction: normal;\n /* Can be used to specify the animation duration from the outside. 250ms by default. */\n animation-duration: var(--kolibri-tooltip-animation-duration, 250ms);\n animation-fill-mode: forwards;\n animation-iteration-count: 1;\n animation-timing-function: ease-in;\n }\n .kol-tooltip__floating.hide {\n animation-name: hideTooltip;\n }\n .kol-tooltip__floating.show {\n animation-name: showTooltip;\n }\n .kol-tooltip__arrow {\n transform: rotate(45deg);\n color: black;\n background-color: white;\n position: absolute;\n z-index: 999;\n width: calc(10 * 1rem / var(--kolibri-root-font-size, 16));\n height: calc(10 * 1rem / var(--kolibri-root-font-size, 16));\n }\n .kol-tooltip__content {\n color: black;\n background-color: white;\n position: relative;\n z-index: 1000;\n }\n @keyframes hideTooltip {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n display: none;\n }\n }\n @keyframes showTooltip {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n}\n@layer kol-component {\n .kol-alert .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-alert :host {\n display: inline-block;\n }\n .kol-alert .kol-button {\n display: flex;\n min-height: var(--a11y-min-size);\n font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));\n text-decoration-line: none;\n }\n .kol-alert .kol-button::before {\n /* Render zero-width character as first element to set the baseline correctly. */\n content: "​";\n }\n .kol-alert .kol-button__text {\n flex: 1 0 100%;\n }\n .kol-alert {\n display: grid;\n }\n .kol-alert__container {\n display: flex;\n place-items: center;\n }\n .kol-alert__container-content {\n flex-grow: 1;\n }\n .kol-alert__closer {\n /* Visible with forced colors */\n outline: transparent solid calc(1 * 1rem / var(--kolibri-root-font-size, 16));\n }\n .kol-custom-suggestions-option {\n line-height: 1.5;\n white-space: normal;\n cursor: pointer;\n overflow-wrap: break-word;\n }\n .kol-custom-suggestions-options-group--cursor-hidden .kol-custom-suggestions-option {\n cursor: none !important;\n }\n .kol-custom-suggestions-option--disabled:focus, .kol-custom-suggestions-option--disabled:focus * {\n cursor: not-allowed;\n }\n .kol-custom-suggestions-options-group {\n background-color: white;\n display: block;\n position: absolute;\n z-index: 2;\n max-height: calc(250 * 1rem / var(--kolibri-root-font-size, 16));\n margin: 0;\n padding: 0;\n overflow-x: hidden;\n overflow-y: auto;\n list-style-type: none;\n }\n .kol-input-container:has(.kol-custom-suggestions-options-group--open) {\n z-index: 10;\n }\n .kol-custom-suggestions-toggle {\n display: flex;\n min-width: var(--a11y-min-size);\n min-height: var(--a11y-min-size);\n align-items: center;\n justify-content: center;\n cursor: default;\n }\n .kol-custom-suggestions-toggle.kol-custom-suggestions-toggle--disabled {\n cursor: not-allowed;\n }\n .kol-form-field {\n display: grid;\n }\n .kol-form-field:not(.kol-form-field--disabled) .kol-form-field__label {\n cursor: pointer;\n }\n .kol-form-field__label-text {\n flex-flow: row;\n align-items: flex-start;\n justify-content: flex-start;\n }\n .kol-form-field--required .kol-form-field__label-text:has(.kol-span__slot[hidden])::after,\n .kol-form-field--required .kol-tooltip__content .kol-span__label::after {\n content: "*"/"";\n }\n .kol-input-container {\n background-color: transparent;\n display: grid;\n position: relative;\n width: 100%;\n min-width: var(--a11y-min-size);\n min-height: var(--a11y-min-size);\n align-items: center;\n grid-template-columns: 1fr;\n }\n .kol-input-container:has(> .kol-input-container__adornment--start) {\n grid-template-columns: auto 1fr auto;\n }\n .kol-input-container__container {\n position: relative;\n z-index: 1;\n }\n .kol-input-container__adornment {\n display: flex;\n align-items: center;\n }\n .kol-input-container__adornment .kol-icon {\n display: grid;\n min-height: var(--a11y-min-size);\n place-items: center;\n }\n .kol-input {\n background-color: transparent;\n width: 100%;\n min-width: var(--a11y-min-size);\n }\n .kol-input:focus {\n outline: none;\n }\n .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-combobox__delete .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-combobox__delete :host {\n display: inline-block;\n }\n .kol-combobox__delete .kol-button {\n display: flex;\n min-height: var(--a11y-min-size);\n font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));\n text-decoration-line: none;\n }\n .kol-combobox__delete .kol-button::before {\n /* Render zero-width character as first element to set the baseline correctly. */\n content: "​";\n }\n .kol-combobox__delete .kol-button__text {\n flex: 1 0 100%;\n }\n .kol-combobox-toggle {\n min-height: 0;\n flex: 0;\n align-self: stretch;\n }\n}';const C=class{async getValue(){return this.state._value}async focus(){}async click(){}selectOption(n){var e;this.controller.onFacade.onInput(new CustomEvent("input",{bubbles:true,detail:{name:this.state._name,value:n}}),true,n);this.controller.onFacade.onChange(new CustomEvent("change",{bubbles:true,detail:{name:this.state._name,value:n}}),n);this.controller.setFormAssociatedValue(n);this._filteredSuggestions=[...this.state._suggestions];this.state._value=n;(e=this.ctaRef.el)===null||e===void 0?void 0:e.focus()}clearSelection(){var n;const e=this.state._disabled===true;if(e){return}const t="";this._focusedOptionIndex=-1;this._value=t;this.state._value=t;this._filteredSuggestions=[...this.state._suggestions];this._isOpen=false;const i={name:this.state._name,value:t};this.controller.onFacade.onInput(new CustomEvent("input",{bubbles:true,detail:i}),true,t);this.controller.onFacade.onChange(new CustomEvent("change",{bubbles:true,detail:i}),t);this.controller.setFormAssociatedValue(t);(n=this.ctaRef.el)===null||n===void 0?void 0:n.focus()}onInput(n){const e=n.target;this.state._value=e.value;this._value=e.value;this.controller.onFacade.onInput(n);this.setFilteredSuggestionsByQuery(e.value);this._focusedOptionIndex=-1}handleKeyDownDropdown(n){if(n.key.length===1&&/[a-z0-9]/i.test(n.key)){this._isOpen=true;this.focusSuggestionStartingWith(n.key)}}setFilteredSuggestionsByQuery(n){var e;if(n===undefined){return}if(n.trim()===""){this._filteredSuggestions=[...this.state._suggestions]}else{this._filteredSuggestions=Array.isArray(this.state._suggestions)?this.state._suggestions.filter((e=>e.toLowerCase().includes(n.trim().toLowerCase()))):this._filteredSuggestions;if(((e=this._filteredSuggestions)===null||e===void 0?void 0:e.length)===1&&this._filteredSuggestions[0]===n){this._isOpen=false}else if(this._filteredSuggestions&&this._filteredSuggestions.length>0){this._isOpen=true}else{this._isOpen=false}}}moveFocus(n){if(!this._filteredSuggestions){return}let e=this._focusedOptionIndex+n;if(e>=this._filteredSuggestions.length){e=0}if(e<0){e=this._filteredSuggestions.length-1}this.focusOption(e)}focusOption(n){this._focusedOptionIndex=n;if(this.refSuggestions){const e=this.refSuggestions[n];e===null||e===void 0?void 0:e.focus()}}selectFocusedOption(){if(this._filteredSuggestions&&this._focusedOptionIndex>=0&&this._focusedOptionIndex<this._filteredSuggestions.length){this.selectOption(this._filteredSuggestions[this._focusedOptionIndex]);return true}return false}focusSuggestionStartingWith(n){const e=n.toLowerCase();const t=Array.isArray(this._filteredSuggestions)&&this._filteredSuggestions.length>0&&this._filteredSuggestions.findIndex((n=>n.toLowerCase().startsWith(e)));if(typeof t==="number"){this.focusOption(t)}}getFormFieldProps(){return{state:this.state,class:m("kol-combobox",{"has-value":this.state._hasValue}),tooltipAlign:this._tooltipAlign,alert:this.showAsAlert()}}getInputProps(){const{ariaDescribedBy:n}=s(this.state);const e=this.state._disabled===true;return Object.assign(Object.assign({ref:this.ctaRef,state:this.state,class:"kol-combobox__input",type:"text",role:"combobox","aria-activedescendant":this._isOpen&&this._focusedOptionIndex>=0?`option-${this._focusedOptionIndex}`:undefined,"aria-autocomplete":"both","aria-controls":this.state._id+"-listbox","aria-describedby":n.length>0?n.join(" "):undefined,"aria-expanded":this._isOpen?"true":"false","aria-label":this.state._hideLabel&&typeof this.state._label==="string"?this.state._label:undefined,"aria-labelledby":this.state._id+"-label","aria-keyshortcuts":this.state._shortKey,value:this.state._value,accessKey:this.state._accessKey,autocapitalize:"off",autocorrect:"off",disabled:e,customSuggestions:true,id:this.state._id,name:this.state._name,required:this.state._required},this.controller.onFacade),{onChange:this.onChange.bind(this),onInput:this.onInput.bind(this),placeholder:this.state._placeholder})}render(){const e=this.state._disabled===true;return n(a,Object.assign({key:"d40cc02f6a681ae8e0f6e67e73ef77f097604d42"},this.getFormFieldProps()),n(r,{key:"335b385682f97b5de3a92a569e2f536438001b82",state:this.state},n("div",{key:"a2980ac0e3089745472544c6542b3fe9c483dd2b",class:"kol-combobox__group"},n(h,Object.assign({key:"e826b131ca765cf94d735529c00bacd3b838584f"},this.getInputProps())),this.state._value&&this.state._hasClearButton&&n(o,{key:"31af956f8bbe0a487632f754d6dcfe223187898b",_icons:"kolicon-cross",_label:this.translateDeleteSelection,_hideLabel:true,_variant:"ghost",_disabled:e,"data-testid":"combobox-delete",class:"kol-combobox__delete",hidden:e,_on:{onClick:()=>{this.clearSelection()},onFocus:()=>{this.clearButtonFocused=true},onBlur:()=>{this.clearButtonFocused=false}}}),n("button",{key:"071132d137881c0fa4cb2fe24c5233c6ad3d6b28",type:"button",tabIndex:-1,class:"kol-combobox-toggle",onClick:this.toggleListbox.bind(this),disabled:this._disabled,hidden:e},n(u,{key:"3497d9c30eb58675b33ee840564e7d5c2c4e59be",icons:"kolicon-chevron-down",label:""}))),n(c,{key:"df461d34efb6db64a8f88998db27b5dc205d8023",blockSuggestionMouseOver:this.blockSuggestionMouseOver,onKeyDown:this.handleKeyDownDropdown.bind(this),hidden:!this._isOpen||e,id:this.state._id+"-listbox"},Array.isArray(this._filteredSuggestions)&&this._filteredSuggestions.length>0&&this._filteredSuggestions.map(((e,t)=>n(d,{disabled:false,index:t,option:e,searchTerm:this.state._value,ref:n=>{if(n)this.refSuggestions[t]=n},selected:this.state._value===e,onClick:()=>{this.selectOption(e);this.toggleListbox();this._isOpen=false},onMouseOver:()=>{if(!this.blockSuggestionMouseOver){this.focusOption(t)}},onFocus:()=>{this.focusOption(t)}}))))))}handleKeyDown(n){var e,t;const i=(e,t)=>{var i;n.preventDefault();if(e!==undefined){this._isOpen=e;if(!e){(i=this.ctaRef.el)===null||i===void 0?void 0:i.focus()}}t===null||t===void 0?void 0:t()};switch(n.key){case"Down":case"ArrowDown":{this.blockSuggestionMouseOver=true;i(true,(()=>this.moveFocus(1)));break}case"Up":case"ArrowUp":{this.blockSuggestionMouseOver=true;i(true,(()=>this.moveFocus(-1)));break}case"Tab":if(this._isOpen){this._isOpen=false;(e=this.ctaRef.el)===null||e===void 0?void 0:e.focus()}break;case"Esc":case"Escape":{this._isOpen=false;n.preventDefault();(t=this.ctaRef.el)===null||t===void 0?void 0:t.focus();break}case" ":case"Enter":case"NumpadEnter":{if(this.clearButtonFocused){this.clearSelection()}else if(this._isOpen){if(this.selectFocusedOption()){this._isOpen=false}}else{this.toggleListbox()}n.preventDefault();break}case"Space":{if(this.clearButtonFocused){this.clearSelection()}break}case"Home":{this.blockSuggestionMouseOver=true;i(undefined,(()=>{if(this._isOpen){this.focusOption(0)}}));break}case"End":{this.blockSuggestionMouseOver=true;i(undefined,(()=>{if(this._isOpen){this.focusOption(this._filteredSuggestions?this._filteredSuggestions.length-1:0)}}));break}case"PageUp":{this.blockSuggestionMouseOver=true;i(undefined,(()=>this._isOpen&&this.moveFocus(-10)));break}case"PageDown":{this.blockSuggestionMouseOver=true;i(undefined,(()=>this._isOpen&&this.moveFocus(10)));break}}}handleWindowClick(n){if(this.host!==undefined&&!this.host.contains(n.target)){this._isOpen=false}}constructor(n){e(this,n);this.ctaRef=g();this.refSuggestions=[];this._focusedOptionIndex=-1;this.translateDeleteSelection=f("kol-delete-selection");this.clearButtonFocused=false;this.toggleListbox=()=>{var n;const e=this.state._disabled===true;if(e){this._isOpen=false}else{(n=this.ctaRef.el)===null||n===void 0?void 0:n.focus();if(this._isOpen){this._isOpen=false}else if(Array.isArray(this._filteredSuggestions)&&this._filteredSuggestions.length>0){this._isOpen=true;const n=this._filteredSuggestions.findIndex((n=>n===this.state._value));this._focusedOptionIndex=n>=0?n:-1;this.focusOption(this._focusedOptionIndex)}}};this.blockSuggestionMouseOver=false;this._isOpen=false;this._disabled=false;this._hideMsg=false;this._hideLabel=false;this._hint="";this._hasClearButton=true;this._required=false;this._tooltipAlign="top";this._touched=false;this.state={_hasValue:false,_hasClearButton:true,_hideMsg:false,_id:p("combobox"),_label:"",_suggestions:[],_value:""};this.inputHasFocus=false;this.controller=new j(this,"combobox",this.host);this.onInput=this.onInput.bind(this)}showAsAlert(){return Boolean(this.state._touched)&&!this.inputHasFocus}validatePlaceholder(n){this.controller.validatePlaceholder(n)}validateAccessKey(n){this.controller.validateAccessKey(n)}validateDisabled(n){this.controller.validateDisabled(n)}validateHideMsg(n){this.controller.validateHideMsg(n)}validateHideLabel(n){this.controller.validateHideLabel(n)}validateHint(n){this.controller.validateHint(n)}validateIcons(n){this.controller.validateIcons(n)}validateLabel(n){this.controller.validateLabel(n)}validateMsg(n){this.controller.validateMsg(n)}validateName(n){this.controller.validateName(n)}validateOn(n){this.controller.validateOn(n)}validateShortKey(n){this.controller.validateShortKey(n)}validateSuggestions(n){this.controller.validateSuggestions(n);this._filteredSuggestions=n;this.setFilteredSuggestionsByQuery(this._value)}validateHasClearButton(n){this.controller.validateHasClearButton(n)}validateRequired(n){this.controller.validateRequired(n)}validateSyncValueBySelector(n){this.controller.validateSyncValueBySelector(n)}validateTouched(n){this.controller.validateTouched(n)}validateValue(n){this.controller.validateValue(n);this.controller.setFormAssociatedValue(n)}validateVariant(n){this.controller.validateVariant(n)}componentWillLoad(){this.refSuggestions=[];this._touched=this._touched===true;this.controller.componentWillLoad();this.state._hasValue=!!this.state._value;this.controller.addValueChangeListener((n=>this.state._hasValue=!!n));this._filteredSuggestions=this.state._suggestions}handleMouseEvent(){this.blockSuggestionMouseOver=false}handleFocusIn(n){setTimeout((()=>{var e;if(((e=this.host)===null||e===void 0?void 0:e.contains(document.activeElement))&&!this.inputHasFocus){this.controller.onFacade.onFocus(n);this.inputHasFocus=true}}))}handleFocusOut(n){setTimeout((()=>{var e;if(this.inputHasFocus&&!((e=this.host)===null||e===void 0?void 0:e.contains(document.activeElement))){this.controller.onFacade.onBlur(n);this.inputHasFocus=false;if(this._isOpen){this._isOpen=false}}}))}onChange(n){this.controller.onFacade.onChange(n);this.controller.setFormAssociatedValue(this.state._value)}get host(){return t(this)}static get watchers(){return{_placeholder:["validatePlaceholder"],_accessKey:["validateAccessKey"],_disabled:["validateDisabled"],_hideMsg:["validateHideMsg"],_hideLabel:["validateHideLabel"],_hint:["validateHint"],_icons:["validateIcons"],_label:["validateLabel"],_msg:["validateMsg"],_name:["validateName"],_on:["validateOn"],_shortKey:["validateShortKey"],_suggestions:["validateSuggestions"],_hasClearButton:["validateHasClearButton"],_required:["validateRequired"],_syncValueBySelector:["validateSyncValueBySelector"],_touched:["validateTouched"],_value:["validateValue"],_variant:["validateVariant"]}}};i([b("ctaRef")],C.prototype,"focus",null);i([k("ctaRef")],C.prototype,"click",null);C.style={default:z};export{C as kol_combobox}; //# sourceMappingURL=kol-combobox.entry.js.map