@scania/tegel
Version:
Tegel Design System
1 lines • 29.5 kB
JavaScript
import{r as t,c as o,h as s,H as i,a as e}from"./p-9xxNGlso.js";import{g as r}from"./p-Cn4f8w1e.js";const d=t=>null==t?"":t.toString(),l=t=>t.map((t=>d(t))),n=class{constructor(s){t(this,s),this.tdsChange=o(this,"tdsChange",6),this.tdsFocus=o(this,"tdsFocus",6),this.tdsBlur=o(this,"tdsBlur",6),this.tdsInput=o(this,"tdsInput",6),this.tdsClear=o(this,"tdsClear",6),this.disabled=!1,this.modeVariant=null,this.openDirection="auto",this.size="lg",this.animation="slide",this.error=!1,this.multiselect=!1,this.filter=!1,this.normalizeText=!0,this.noResultText="No result",this.value=null,this.open=!1,this.internalValue="",this.filterResult=null,this.filterFocus=!1,this.internalDefaultValue="",this.selectedOptions=[],this.filterQuery="",this.hasFocus=!1,this.uuid=r(),this.setDefaultOption=()=>{if(this.internalDefaultValue){const t=this.multiselect?this.internalDefaultValue.split(","):[this.internalDefaultValue];this.updateDropdownStateInternal(t)}},this.getChildren=()=>{const t=Array.from(this.host.children).filter((t=>"TDS-DROPDOWN-OPTION"===t.tagName));return 0===t.length&&console.warn("TDS DROPDOWN: No options found. Disregard if loading data asynchronously."),t},this.getSelectedChildren=()=>0===this.selectedOptions.length?[]:this.selectedOptions.map((t=>{var o;return null===(o=this.getChildren())||void 0===o?void 0:o.find((o=>d(o.value)===d(t)))})).filter(Boolean),this.getSelectedChildrenLabels=()=>{var t;return null===(t=this.getSelectedChildren())||void 0===t?void 0:t.map((t=>{var o;return null===(o=t.textContent)||void 0===o?void 0:o.trim()}))},this.getValue=()=>{const t=this.getSelectedChildrenLabels();return t?null==t?void 0:t.join(", "):""},this.setValueAttribute=()=>{0===this.selectedOptions.length?this.host.removeAttribute("value"):this.host.setAttribute("value",this.selectedOptions.join(","))},this.getOpenDirection=()=>{var t,o,s,i,e;if("auto"===this.openDirection||!this.openDirection){const r=null!==(o=null===(t=this.dropdownList)||void 0===t?void 0:t.offsetHeight)&&void 0!==o?o:0;return(null!==(e=null===(i=(s=this.host).getBoundingClientRect)||void 0===i?void 0:i.call(s).top)&&void 0!==e?e:0)+r+57>window.innerHeight?"up":"down"}return this.openDirection},this.handleToggleOpen=()=>{var t;if(!this.disabled&&(this.open=!this.open,this.open))if(this.filter)this.focusInputElement();else{const o=null===(t=this.host.shadowRoot)||void 0===t?void 0:t.querySelector("button");o&&o.focus()}},this.focusInputElement=()=>{this.inputElement&&this.inputElement.focus()},this.handleFilter=t=>{const o=t.currentTarget;if(this.multiselect&&0===this.filterQuery.length&&this.selectedOptions.length>0&&this.inputElement){const t=this.getValue(),s=o.value,i=function(t,o){return t.length<=o.length+1?t:t.startsWith(o)?t.slice(o.length):t.endsWith(o)?t.slice(0,t.length-o.length):t}(s,t);i!==s&&(this.inputElement.value=i)}this.tdsInput.emit(t);const s=this.inputElement?this.inputElement.value.toLowerCase():o.value.toLowerCase();this.filterQuery=s;const i=this.getChildren();""===s?(i.forEach((t=>(t.removeAttribute("hidden"),t))),this.filterResult=null):this.filterResult=i.filter((t=>{var o;return this.normalizeString(null!==(o=null==t?void 0:t.textContent)&&void 0!==o?o:"").toLowerCase().includes(this.normalizeString(s).toLowerCase())?t.removeAttribute("hidden"):t.setAttribute("hidden",""),!t.hasAttribute("hidden")})).length},this.handleFilterReset=()=>{if(this.multiselect){if(this.filterQuery.length>0){const t=this.filterQuery;this.filterQuery="",this.resetFilterVisibility(),this.inputElement&&(this.inputElement.value=this.getValue(),this.inputElement.focus()),this.tdsClear.emit({clearedValue:t})}else if(this.selectedOptions.length>0){const t=this.selectedOptions.join(",");this.updateDropdownStateFromUser([]),this.inputElement&&(this.inputElement.value="",this.inputElement.focus()),this.tdsClear.emit({clearedValue:t})}}else{const t=[];this.filterQuery.length>0&&(t.push(this.filterQuery),this.filterQuery="",this.resetFilterVisibility()),this.selectedOptions.length>0&&(t.push(this.selectedOptions.join(",")),this.updateDropdownStateFromUser([])),this.inputElement&&(this.inputElement.value="",this.inputElement.focus()),t.length>0&&this.tdsClear.emit({clearedValue:t.join(",")})}},this.resetFilterVisibility=()=>{this.filterQuery="",this.getChildren().forEach((t=>{t.removeAttribute("hidden")})),this.filterResult=null},this.handleMultiselectClear=()=>{const t=this.selectedOptions.join(",");this.updateDropdownStateFromUser([]),this.tdsClear.emit({clearedValue:t})},this.handleFocus=()=>{this.open=!0,this.filterFocus=!0,this.multiselect&&this.filter?this.inputElement&&(this.inputElement.value=this.getValue()):this.inputElement&&(this.inputElement.value=""),this.filter&&this.resetFilterVisibility()},this.handleBlur=()=>{this.filterFocus=!1,this.filterQuery="",this.inputElement&&(this.inputElement.value=this.getValue()),this.filter&&this.resetFilterVisibility()},this.handleInputClick=()=>{this.multiselect&&this.filter&&(this.filterQuery="",this.inputElement&&(this.inputElement.value=""),this.resetFilterVisibility())},this.resetInput=()=>{this.host.querySelector("input")&&this.reset()}}handleValueChange(t){const o=this.normalizeValue(t);(function(t,o){return t.length!==o.length||t.some((t=>!o.includes(t)))})(o,this.selectedOptions)&&this.updateDropdownStateFromUser(o)}normalizeValue(t){return null==t||""===t?[]:this.multiselect?Array.isArray(t)?l(t):t.toString().split(",").filter((t=>""!==t)):Array.isArray(t)?[d(t[0])]:[d(t)]}updateDropdownStateInternal(t){this.updateDropdownState(t,!1)}updateDropdownStateFromUser(t){this.updateDropdownState(t,!0)}updateDropdownState(t,o=!0){const s=this.validateValues(t);this.selectedOptions=[...s],this.value=this.multiselect?this.selectedOptions:this.selectedOptions[0]||null,this.internalValue=this.getValue(),this.updateOptionElements(),this.updateDisplayValue(),o&&this.emitChange(),this.setValueAttribute()}validateValues(t){const o=this.getChildren();return o&&0!==o.length?t.filter((t=>{const s=o.some((o=>d(o.value)===d(t)));return s||console.warn(`Option with value "${t}" does not exist`),s})):(console.warn("No dropdown options found"),t)}updateOptionElements(){var t;null===(t=this.getChildren())||void 0===t||t.forEach((t=>{t.setSelected(this.selectedOptions.includes(d(t.value)))}))}updateDisplayValue(){this.internalValue=this.getSelectedChildrenLabels().join(", "),this.filter&&this.inputElement&&(this.inputElement.value=this.internalValue)}emitChange(){const t=this.multiselect?this.selectedOptions.join(","):this.selectedOptions[0]||null;this.tdsChange.emit({name:this.name,value:null!=t?t:null})}async setValue(t,o){let s;return s=Array.isArray(t)?l(t):[d(t)],this.updateDropdownStateFromUser(s),this.getSelectedChildren().map((t=>{var o;return{value:t.value,label:null===(o=t.textContent)||void 0===o?void 0:o.trim()}}))}async reset(){this.updateDropdownStateFromUser([])}async removeValue(t){const o=this.selectedOptions.filter((o=>o!==t));this.updateDropdownStateFromUser(o)}async focusElement(){var t;if(this.filter)this.focusInputElement();else{const o=null===(t=this.host.shadowRoot)||void 0===t?void 0:t.querySelector("button");o&&o.focus()}this.handleFocus()}async close(){this.open=!1}async updateDisplay(){this.updateDisplayValue()}onAnyClick(t){this.open&&!t.composedPath().includes(this.host)&&(this.filter&&this.filterQuery&&this.tdsClear.emit({clearedValue:this.filterQuery}),this.open=!1)}onFocusIn(t){this.host.contains(t.target)&&(this.hasFocus||(this.hasFocus=!0,this.tdsFocus.emit(t)))}onFocusOut(t){const o=t.relatedTarget;!this.hasFocus||o&&this.host.contains(o)||(this.hasFocus=!1,this.handleBlur(),this.tdsBlur.emit(t))}async onKeyDown(t){var o,s;const{activeElement:i}=document;if(!i)return;const e=this.getChildren();if("ArrowDown"===t.key){const t=i.nextElementSibling?e.findIndex((t=>t===i.nextElementSibling)):0;if(e.length>0){const o=((t,o)=>{if(void 0===t[o])return 0;for(let s=o;s<t.length;s++)if(!t[s].disabled)return s})(e,t),s="number"==typeof o?e[o]:e[0];null==s||s.focus()}}else if("ArrowUp"===t.key){const t=i.nextElementSibling?this.getChildren().findIndex((t=>t===i.previousElementSibling)):0;if(e.length>0){const o=((t,o)=>{if(void 0===t[o])return t.length-1;for(let s=o;s>=0;s--)if(!t[s].disabled)return s})(e,t),s="number"==typeof o?e[o]:e[e.length-1];null==s||s.focus()}}else if("Escape"===t.key)if(this.open=!1,this.filter)null===(o=this.inputElement)||void 0===o||o.focus();else{const t=null===(s=this.host.shadowRoot)||void 0===s?void 0:s.querySelector("button");null==t||t.focus()}}handleOpenState(){this.filter&&(this.open||(this.filterQuery="",this.resetFilterVisibility(),this.inputElement&&(this.inputElement.value=this.selectedOptions.length?this.getValue():""))),this.updateDropdownListInertState()}handleDefaultValueChange(t){null!=t&&(this.internalDefaultValue=d(t),this.setDefaultOption())}componentWillLoad(){if(null==this.value){if(null!=this.defaultValue){const t=d(this.defaultValue),o=this.multiselect?t.split(",").map(d):[t];this.updateDropdownStateInternal(o)}}else{const t=this.normalizeValue(this.value);this.updateDropdownStateInternal(t)}}handleSlotChange(){this.setDefaultOption()}normalizeString(t){return this.normalizeText?t.normalize("NFD").replace(/\p{Diacritic}/gu,""):t}async appendValue(t){this.filter&&this.filterQuery.length>0&&(this.filterQuery="",this.resetFilterVisibility()),this.updateDropdownStateFromUser(this.multiselect?[...this.selectedOptions,t]:[t]),this.filter&&this.multiselect&&this.inputElement&&(this.inputElement.value=this.getValue())}componentDidRender(){const t=this.host.closest("form");t&&t.addEventListener("reset",this.resetInput),this.updateDropdownListInertState()}disconnectedCallback(){const t=this.host.closest("form");t&&t.removeEventListener("reset",this.resetInput)}updateDropdownListInertState(){this.dropdownList&&(this.open?this.dropdownList.removeAttribute("inert"):this.dropdownList.setAttribute("inert",""))}render(){var t,o,e,r;((t,o,s,i)=>{let e=t.querySelector("input");t.querySelector("input")||(e=t.ownerDocument.createElement("input"),e.type="hidden",t.appendChild(e)),e&&(e.disabled=i,e.name=o||"",e.value=s||"")})(this.host,this.name,this.selectedOptions.join(","),this.disabled);const d=this.name||this.uuid,l=`dropdown-input-${d}`,n=this.label?`dropdown-label-${d}`:void 0,h=this.helper?`dropdown-helper-${d}`:void 0,a=this.selectedOptions.length>0,p=this.filterQuery.length>0,c=this.filterFocus||a||p,b=this.open||a,u="inside"!==this.labelPosition||b,v=null!==(t=this.tdsAriaLabel)&&void 0!==t?t:this.label?void 0:"Dropdown";let w=null!==(o=this.placeholder)&&void 0!==o?o:"";"inside"===this.labelPosition&&(w=!this.filterFocus||p||a||null===(e=this.placeholder)||void 0===e?"":e);let f="";return this.selectedOptions.length>0?f=this.getValue():u&&(f=null!==(r=this.placeholder)&&void 0!==r?r:""),s(i,{key:"e7c3ade8e5b56a41f78016c44fb75efcaaf666c1",class:{[`tds-mode-variant-${this.modeVariant}`]:Boolean(this.modeVariant)}},this.label&&"outside"===this.labelPosition&&s("div",{key:"26dd2d4137fea024b4b436fca739cfecaea13491",id:n,class:"label-outside "+(this.disabled?"disabled":"")},this.label),s("div",{key:"ce88e29fa87c4c9e54ea68bef9bde26b6300bae9",class:{"dropdown-select":!0,[this.size]:!0,disabled:this.disabled}},this.filter?s("div",{class:{filter:!0,focus:this.filterFocus,disabled:this.disabled,error:this.error}},s("div",{class:"value-wrapper"},this.label&&"inside"===this.labelPosition&&s("label",{id:n,htmlFor:l,class:{"label-inside":!0,[this.size]:!0,floated:c}},this.label),s("input",{"aria-label":v,"aria-labelledby":n,"aria-describedby":h,"aria-disabled":this.disabled,ref:t=>{this.inputElement=t,this.inputElement&&!this.filterFocus&&(this.inputElement.value=this.getValue())},class:{placeholder:"inside"===this.labelPosition},id:l,type:"text",placeholder:w,disabled:this.disabled,onInput:t=>this.handleFilter(t),onFocus:()=>this.handleFocus(),onClick:()=>this.handleInputClick(),onKeyDown:t=>{"Escape"===t.key&&(this.open=!1)}})),s("tds-icon",{tabIndex:0,role:"button","aria-label":this.filterQuery.length>0?"Clear filter":"Clear selection",svgTitle:this.filterQuery.length>0?"Clear filter":"Clear selection",onClick:this.handleFilterReset,onKeyDown:t=>{"Enter"===t.key&&this.handleFilterReset()},class:{"clear-icon":!0,hide:!(this.filterQuery.length>0||this.selectedOptions.length>0)},name:"cross",size:"16px"}),s("tds-icon",{tdsAriaHidden:!0,role:"button","aria-label":"Open/Close dropdown",svgTitle:"Open/Close dropdown",onClick:this.handleToggleOpen,onKeyDown:t=>{"Enter"===t.key&&this.handleToggleOpen()},class:"menu-icon "+(this.open?"open":"closed"),name:"chevron_down",size:"16px"})):s("button",{"aria-label":this.tdsAriaLabel,"aria-labelledby":n,"aria-describedby":h,"aria-disabled":this.disabled,onClick:()=>this.handleToggleOpen(),onKeyDown:t=>{"Escape"===t.key&&(this.open=!1)},class:`\n ${this.selectedOptions.length?"value":"placeholder"}\n ${this.open?"open":"closed"}\n ${this.error?"error":""}\n `,disabled:this.disabled},s("div",{class:`value-wrapper ${this.size}`},this.label&&"inside"===this.labelPosition&&s("div",{id:n,class:{"label-inside":!0,[this.size]:!0,floated:b}},this.label),s("div",{"aria-label":this.tdsAriaLabel?`Selected options for ${this.tdsAriaLabel}`:void 0,class:`placeholder ${this.size}`},f)),s("tds-icon",{tabIndex:0,role:"button","aria-label":"Clear selection",svgTitle:"Clear selection",onClick:t=>{t.stopPropagation(),this.handleMultiselectClear()},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.stopPropagation(),t.preventDefault(),this.handleMultiselectClear())},class:{"clear-icon":!0,hide:!(this.multiselect&&this.selectedOptions.length>0)},name:"cross",size:"16px"}),s("tds-icon",{"aria-label":"Open/Close dropdown",svgTitle:"Open/Close dropdown",class:"menu-icon "+(this.open?"open":"closed"),name:"chevron_down",size:"16px"}))),s("div",{key:"0d76e422a2f0887595f60d57e03ec3980d4b9774",role:"listbox","aria-label":this.tdsAriaLabel,inert:!this.open,"aria-orientation":"vertical","aria-multiselectable":this.multiselect,ref:t=>{t&&(this.dropdownList=t)},class:{"dropdown-list":!0,[this.size]:!0,[this.getOpenDirection()]:!0,"label-outside":!(!this.label||"outside"!==this.labelPosition),open:this.open,closed:!this.open,[`animation-enter-${this.animation}`]:"none"!==this.animation&&this.open,[`animation-exit-${this.animation}`]:"none"!==this.animation&&!this.open}},s("slot",{key:"f971e4e9e24fe8d9092066d72bb05b76547f05a7",onSlotchange:()=>this.handleSlotChange()}),0===this.filterResult&&""!==this.noResultText&&s("div",{key:"0d8f90a543bf7b8dc3b3185d27f05d0517b4e0e6",class:`no-result ${this.size}`},this.noResultText)),this.helper&&s("div",{key:"4f17cfead0616b262e91e0e5b82cf59ce1309d73",id:h,class:{helper:!0,error:this.error,disabled:this.disabled}},this.error&&s("tds-icon",{key:"032599d86280e2a204c22fb97409f097841259b5",name:"error",size:"16px"}),this.helper))}get host(){return e(this)}static get watchers(){return{value:[{handleValueChange:0}],open:[{handleOpenState:0}],defaultValue:[{handleDefaultValueChange:0}]}}};n.style='@charset "UTF-8";:host button{all:unset;display:flex;align-items:center;height:100%;width:100%;box-sizing:border-box;background-color:var(--tds-dropdown-bg);border-bottom:1px solid var(--tds-dropdown-border-bottom);border-radius:var(--tds-dropdown-border-radius);padding:0 16px}:host button:hover{border-bottom:1px solid var(--tds-dropdown-border-bottom-hover)}:host button .value-wrapper{flex:1;min-width:0;display:flex;align-items:center;padding:0}:host button .menu-icon{margin-right:16px}:host button.placeholder{color:var(--tds-dropdown-placeholder-color);line-height:1.3}:host button.value{color:var(--tds-dropdown-value-color);font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);line-height:1.3}:host button:focus{border-bottom:0}:host button.error{border-bottom:1px solid var(--tds-dropdown-error)}:host button.error:focus{border-bottom-color:transparent}:host button.error:focus::before{content:"";position:absolute;bottom:0;left:0;width:100%;height:1px;background:var(--tds-dropdown-error)}:host button:disabled{color:var(--tds-dropdown-disabled-color);border-bottom:1px solid transparent}:host button .menu-icon{margin-right:0}:host .dropdown-select:focus-within{outline:2px solid var(--tds-focus-outline-color);box-shadow:0 0 0 1px var(--tds-white);outline-offset:1px;z-index:1}:host .filter{display:flex;align-items:center;justify-content:space-between;height:100%;background-color:var(--tds-dropdown-bg);border-bottom:1px solid var(--tds-dropdown-border-bottom);padding-left:16px;border-radius:4px 4px 0 0}:host .filter:hover{border-bottom:1px solid var(--tds-dropdown-border-bottom-hover)}:host .filter.disabled{color:var(--tds-dropdown-disabled-color);border-bottom:1px solid transparent}:host .filter.disabled .value-wrapper input{color:var(--tds-dropdown-disabled-color)}:host .filter .value-wrapper{display:flex;align-items:center;width:100%;height:100%}:host .filter .value-wrapper input{color:var(--tds-dropdown-filter-input-color)}:host .filter .label-inside-as-placeholder{position:absolute;font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);line-height:1.3;color:var(--tds-dropdown-placeholder-color)}:host .filter .label-inside-as-placeholder.lg{top:20px}:host .filter .label-inside-as-placeholder.md{top:16px}:host .filter .label-inside-as-placeholder.sm{display:none}:host .filter .label-inside-as-placeholder.selected{font:var(--tds-detail-07);letter-spacing:var(--tds-detail-07-ls);transition:all 0.2s ease-in-out}:host .filter .label-inside-as-placeholder.selected.lg{top:12px}:host .filter .label-inside-as-placeholder.selected.md{top:8px}:host .filter .label-inside-as-placeholder.selected.sm{display:none}:host .filter .label-inside-as-placeholder.selected+.placeholder:not(.sm){margin-top:8px}:host .filter.focus{border-bottom:0}:host .filter.focus:hover{border-bottom:0}:host .filter.error{border-bottom:1px solid var(--tds-dropdown-error)}:host .filter.error.focus{border-bottom-color:transparent}:host .filter.error.focus::before{content:"";position:absolute;bottom:0;left:0;width:100%;height:1px;background:var(--tds-dropdown-error)}:host .filter input{flex:1;all:unset;width:100%}:host .filter input::placeholder{color:var(--tds-dropdown-placeholder-color)}:host .filter input:disabled::placeholder{color:var(--tds-dropdown-disabled-color)}:host .filter tds-icon{cursor:pointer}:host .filter .menu-icon{margin-right:16px}:host,:root{--tds-scrollbar-width-standard:thin;--tds-scrollbar-width:10px;--tds-scrollbar-height:10px;--tds-scrollbar-thumb-border-width:3px;--tds-scrollbar-thumb-border-hover-width:2px}body{scrollbar-width:thin}:host{display:block;position:relative;font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls)}:host .label-outside{font:var(--tds-detail-05);letter-spacing:var(--tds-detail-05-ls);color:var(--tds-dropdown-label-color);margin-bottom:8px}:host .label-outside.disabled{color:var(--tds-dropdown-disabled-color)}:host .dropdown-select{position:relative}:host .dropdown-select button:focus{outline:2px solid var(--tds-focus-outline-color);box-shadow:0 0 0 1px var(--tds-white);outline-offset:1px;z-index:1;border-radius:0}:host .dropdown-select button{transition:border-bottom-color var(--tds-motion-duration-fast-02) var(--tds-motion-easing-scania)}:host .dropdown-select button:hover{border-bottom-color:var(--tds-dropdown-border-bottom-hover)}:host .dropdown-select button{border-bottom-color:var(--tds-dropdown-border-bottom)}:host .dropdown-select button.error{border-bottom-color:var(--tds-dropdown-error)}:host .dropdown-select button.error:focus{border-bottom-color:transparent}:host .dropdown-select.disabled .label-inside,:host .dropdown-select.disabled .placeholder,:host .dropdown-select.disabled .label-inside-as-placeholder,:host .dropdown-select.disabled .value-wrapper,:host .dropdown-select.disabled .menu-icon{color:var(--tds-dropdown-disabled-color)}:host .dropdown-select.disabled button{border:none}:host .dropdown-select .label-inside{position:absolute;font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);color:var(--tds-dropdown-label-inside-color);left:16px;transition:all 0.2s ease-in-out}:host .dropdown-select .label-inside.lg{top:20px;left:16px}:host .dropdown-select .label-inside.md{top:16px;left:16px}:host .dropdown-select .label-inside.sm{display:none}:host .dropdown-select .label-inside.xs{display:none}:host .dropdown-select .label-inside+.placeholder:not(.sm){margin-top:8px}:host .dropdown-select .label-inside.floated{font:var(--tds-detail-07);letter-spacing:var(--tds-detail-07-ls)}:host .dropdown-select .label-inside.floated.lg{top:12px}:host .dropdown-select .label-inside.floated.md{top:8px}:host .dropdown-select .placeholder{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-right:var(--tds-placeholder-margin);}:host .dropdown-select .placeholder.xs{line-height:1}:host .dropdown-select .label-inside-as-placeholder{color:var(--tds-dropdown-placeholder-color)}:host .dropdown-select .label-inside-as-placeholder.selected{position:absolute;font:var(--tds-detail-07);letter-spacing:var(--tds-detail-07-ls);transition:all 0.2s ease-in-out}:host .dropdown-select .label-inside-as-placeholder.selected.lg{top:12px}:host .dropdown-select .label-inside-as-placeholder.selected.md{top:8px}:host .dropdown-select .label-inside-as-placeholder.selected.sm{display:none}:host .dropdown-select .label-inside-as-placeholder.selected+.placeholder:not(.sm){margin-top:8px}:host .dropdown-select.lg{height:55px}:host .dropdown-select.md{height:47px}:host .dropdown-select.sm{height:39px}:host .dropdown-select.xs{height:29px}:host .helper{margin-top:4px;color:var(--tds-dropdown-helper-color);font:var(--tds-detail-05);letter-spacing:var(--tds-detail-05-ls);display:flex;align-items:center;gap:8px}:host .helper.error{color:var(--tds-dropdown-error)}:host .helper.disabled{color:var(--tds-dropdown-disabled-color)}:host .dropdown-list{z-index:100;position:absolute;width:100%;transform-origin:top;box-shadow:0 2px 3px 0 rgba(0, 0, 0, 0.1);border-radius:var(--tds-dropdown-list-border-radius-down);overflow-y:auto;transform:scaleY(0);pointer-events:none;background-color:var(--tds-dropdown-bg)}:host .dropdown-list:hover::-webkit-scrollbar-thumb{border:var(--tds-scrollbar-thumb-border-hover-width) solid transparent;background-clip:padding-box}:host .dropdown-list::-webkit-scrollbar{width:var(--tds-scrollbar-width)}:host .dropdown-list::-webkit-scrollbar-track{background:var(--tds-scrollbar-track-color)}:host .dropdown-list::-webkit-scrollbar-thumb{border-radius:40px;background:var(--tds-scrollbar-thumb-color);border:var(--tds-scrollbar-thumb-border-width) solid transparent;background-clip:padding-box}:host .dropdown-list::-webkit-scrollbar-button{height:0;width:0}@supports not selector(::-webkit-scrollbar){:host .dropdown-list{scrollbar-color:var(--tds-scrollbar-thumb-color) var(--tds-scrollbar-track-color);scrollbar-width:var(--tds-scrollbar-width-standard)}}:host .dropdown-list.lg{max-height:312px}:host .dropdown-list.md{max-height:312px}:host .dropdown-list.sm{max-height:260px}:host .dropdown-list.xs{max-height:260px}:host .dropdown-list.up{bottom:100%;margin-top:0;margin-bottom:1px;transform-origin:bottom;display:flex;flex-direction:column-reverse;border-radius:var(--tds-dropdown-list-border-radius-up)}:host .dropdown-list.up.label-outside{bottom:calc(100% - 24px)}:host .dropdown-list.closed{transform:scaleY(0);pointer-events:none}:host .dropdown-list.open{transform:scaleY(1);visibility:visible;opacity:1;pointer-events:auto}:host .dropdown-list.animation-enter-slide{transition:transform var(--tds-motion-duration-moderate-01) var(--tds-motion-easing-enter)}:host .dropdown-list.animation-exit-slide{transition:transform var(--tds-motion-duration-moderate-01) var(--tds-motion-easing-exit)}:host .dropdown-list .no-result{font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);display:flex;align-items:center;padding:0 16px;background-color:var(--tds-dropdown-bg)}:host .dropdown-list .no-result.lg{height:56px}:host .dropdown-list .no-result.md{height:48px}:host .dropdown-list .no-result.sm{height:40px}:host .dropdown-list .no-result.xs{height:40px}:host .menu-icon{color:var(--tds-dropdown-menu-icon-color)}:host .clear-icon{cursor:pointer;flex-shrink:0;margin:0;margin-right:8px;color:var(--tds-dropdown-clear-icon-color);padding-right:8px;border-right:1px solid var(--tds-dropdown-clear-icon-color)}:host .clear-icon:hover{color:var(--tds-dropdown-clear-icon-hover-color)}:host .clear-icon.hide{display:none;visibility:hidden}:host tds-icon{transition:transform var(--tds-motion-duration-fast-02) var(--tds-motion-easing-scania)}:host tds-icon.open{transform:rotateZ(180deg)}';const h=class{constructor(s){t(this,s),this.tdsSelect=o(this,"tdsSelect",6),this.tdsFocus=o(this,"tdsFocus",6),this.tdsBlur=o(this,"tdsBlur",6),this.internalValue="",this.disabled=!1,this.selected=!1,this.multiselect=!1,this.size="lg",this.parentDropdown=null,this.label="",this.componentWillRender=()=>{var t,o,s;this.host.parentElement&&(this.parentDropdown="TDS-DROPDOWN"===(null===(t=this.host.parentElement)||void 0===t?void 0:t.tagName)?this.host.parentElement:this.host.getRootNode().host,this.parentDropdown&&(this.multiselect=null!==(o=this.parentDropdown.multiselect)&&void 0!==o&&o,this.size=this.parentDropdown.size||"lg"),this.label=(null===(s=this.host.textContent)||void 0===s?void 0:s.trim())||"")},this.handleSingleSelect=()=>{var t,o;this.disabled||(this.selected=!0,null===(t=this.parentDropdown)||void 0===t||t.appendValue(this.internalValue),null===(o=this.parentDropdown)||void 0===o||o.close(),this.tdsSelect.emit({value:this.internalValue,selected:this.selected}))},this.handleMultiselect=t=>{var o,s;this.disabled||(t.detail.checked?(null===(o=this.parentDropdown)||void 0===o||o.appendValue(this.internalValue),this.selected=!0,this.tdsSelect.emit({value:this.internalValue,selected:this.selected})):(null===(s=this.parentDropdown)||void 0===s||s.removeValue(this.internalValue),this.selected=!1,this.tdsSelect.emit({value:this.internalValue,selected:this.selected})),t.stopPropagation())},this.handleFocus=t=>{this.parentDropdown||this.tdsFocus.emit(t)},this.handleBlur=t=>{this.parentDropdown||this.tdsBlur.emit(t)}}async setSelected(t){this.selected=t}valueWatcher(t){this.internalValue=d(t)}componentWillLoad(){this.internalValue=d(this.value)}render(){return s(i,{key:"35542ea54d2ba455982e2470190711f75f88a999"},s("div",{key:"4236d5281cf4675586a7d8b16e80141b9689dad3",class:`dropdown-option\n ${this.size}\n ${this.selected?"selected":""}\n ${this.disabled?"disabled":""}\n `},this.multiselect?s("div",{class:"multiselect",onKeyDown:t=>{var o;"Escape"===t.key&&(null===(o=this.parentDropdown)||void 0===o||o.close())}},s("tds-checkbox",{onTdsChange:t=>{this.handleMultiselect(t)},onTdsBlur:t=>{t.stopPropagation()},disabled:this.disabled,checked:this.selected,tdsAriaLabel:this.tdsAriaLabel,class:{[this.size]:!0}},s("div",{slot:"label"},s("slot",null)))):s("button",{role:"option","aria-disabled":this.disabled,"aria-selected":this.selected,"aria-label":this.tdsAriaLabel,onClick:()=>{this.handleSingleSelect()},onFocus:t=>this.handleFocus(t),onBlur:t=>this.handleBlur(t),disabled:this.disabled,class:this.size},s("div",{class:"single-select"},s("slot",null),this.selected&&s("tds-icon",{name:"tick",size:"16px"})))))}static get delegatesFocus(){return!0}get host(){return e(this)}static get watchers(){return{value:[{valueWatcher:0}]}}};h.style=":host{box-sizing:border-box;display:block;background-color:var(--tds-dropdown-option-background)}:host *{box-sizing:border-box}:host .dropdown-option{color:var(--tds-dropdown-option-color);border-bottom:1px solid var(--tds-dropdown-option-border);font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);overflow-wrap:anywhere;transition:background-color var(--tds-motion-duration-fast-02) var(--tds-motion-easing-scania)}:host .dropdown-option.selected{background-color:var(--tds-dropdown-option-background-selected)}:host .dropdown-option.disabled{color:var(--tds-dropdown-option-color-disabled)}:host .dropdown-option button:focus{outline:2px solid var(--tds-focus-outline-color);box-shadow:inset 0 0 0 3px var(--tds-white);outline-offset:-2px}:host .dropdown-option button{all:unset;width:100%}:host .dropdown-option button.lg{padding:19px 0 20px}:host .dropdown-option button.md{padding:15px 0 16px}:host .dropdown-option button.sm{padding:11px 0 12px}:host .dropdown-option button.xs{padding:7px 0 8px}:host .dropdown-option button .single-select{display:flex;align-items:center;justify-content:space-between;padding:0 16px}:host .dropdown-option .multiselect{width:100%;height:100%}:host .dropdown-option .multiselect tds-checkbox{display:flex;height:100%;width:100%}:host .dropdown-option .multiselect tds-checkbox.lg{padding:15px 16px 16px}:host .dropdown-option .multiselect tds-checkbox.md{padding:11px 16px 12px}:host .dropdown-option .multiselect tds-checkbox.sm{padding:7px 16px 8px}:host .dropdown-option .multiselect tds-checkbox.xs{padding:7px 16px 8px}:host .dropdown-option:hover{border-bottom-color:var(--tds-dropdown-option-border-hover);cursor:pointer}:host .dropdown-option:hover.disabled{border-bottom-color:var(--tds-dropdown-option-border-hover);cursor:not-allowed}:host([hidden]){display:none}";export{n as tds_dropdown,h as tds_dropdown_option}