@sky.ui/core 0.0.53 → 0.0.55

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.
Files changed (40) hide show
  1. package/dist/custom-elements.json +3785 -3679
  2. package/dist/helper/controllers/popover-controller.js +1 -1
  3. package/dist/helper/controllers/popover-controller.js.map +1 -1
  4. package/dist/helper/index.js +1 -1
  5. package/dist/helper/utils/index.d.ts +1 -0
  6. package/dist/helper/utils/index.js +1 -1
  7. package/dist/helper/utils/stable-array.d.ts +6 -0
  8. package/dist/helper/utils/stable-array.js +2 -0
  9. package/dist/helper/utils/stable-array.js.map +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/sky-avatar/sky-avatar.js +5 -5
  12. package/dist/sky-avatar/sky-avatar.js.map +1 -1
  13. package/dist/sky-chip/sky-chip.d.ts +8 -2
  14. package/dist/sky-chip/sky-chip.js +10 -10
  15. package/dist/sky-chip/sky-chip.js.map +1 -1
  16. package/dist/sky-combobox/sky-combobox.d.ts +2 -0
  17. package/dist/sky-combobox/sky-combobox.js +16 -16
  18. package/dist/sky-combobox/sky-combobox.js.map +1 -1
  19. package/dist/sky-flexbox/sky-flexbox.d.ts +2 -0
  20. package/dist/sky-flexbox/sky-flexbox.js +3 -3
  21. package/dist/sky-flexbox/sky-flexbox.js.map +1 -1
  22. package/dist/sky-form/sky-form.js +7 -7
  23. package/dist/sky-form/sky-form.js.map +1 -1
  24. package/dist/sky-image/sky-image.js +5 -5
  25. package/dist/sky-image/sky-image.js.map +1 -1
  26. package/dist/sky-input/sky-input.js +6 -6
  27. package/dist/sky-input/sky-input.js.map +1 -1
  28. package/dist/sky-list/sky-list.js +3 -3
  29. package/dist/sky-list/sky-list.js.map +1 -1
  30. package/dist/sky-listitem/sky-listitem.d.ts +1 -0
  31. package/dist/sky-listitem/sky-listitem.js +4 -2
  32. package/dist/sky-listitem/sky-listitem.js.map +1 -1
  33. package/dist/sky-radio/sky-radio.js +1 -1
  34. package/dist/sky-radio/sky-radio.js.map +1 -1
  35. package/dist/sky-simple-table/sky-simple-table.d.ts +7 -2
  36. package/dist/sky-simple-table/sky-simple-table.js +9 -9
  37. package/dist/sky-simple-table/sky-simple-table.js.map +1 -1
  38. package/dist/sky-theme-provider/sky-theme-provider.js +2 -2
  39. package/dist/sky-theme-provider/sky-theme-provider.js.map +1 -1
  40. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";import{property as r,state as n,query as a,queryAll as l,queryAssignedElements as h,customElement as d}from"lit/decorators.js";import{unsafeHTML as p}from"lit/directives/unsafe-html.js";import{when as c}from"lit/directives/when.js";import{repeat as u}from"lit/directives/repeat.js";import{classMap as y}from"lit/directives/class-map.js";import{resolveColor as v}from"../helper/utils/color-resolver.js";import{cssOnFillEnhance as m}from"../helper/utils/contrast-color.js";import{PopoverController as g}from"../helper/controllers/popover-controller.js";import{FormControlBase as f}from"../helper/internals/form-control-base.js";import{SkyIcon as b}from"../sky-icon/sky-icon.js";import{SkyCheckbox as k}from"../sky-checkbox/sky-checkbox.js";import{SkyInput as w}from"../sky-input/sky-input.js";import{PresetController as x}from"../helper/controllers/preset-controller.js";var S=Object.defineProperty,I=Object.getOwnPropertyDescriptor,O=(e,t,i,s)=>{for(var o,r=s>1?void 0:s?I(t,i):t,n=e.length-1;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&S(t,i,r),r};const A="$rendererState";function $(e){const t=e?.[A];return function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"function"!=typeof t.option&&"function"!=typeof t.selected}(t)?{...t}:{}}let E=class extends f{constructor(){super(),this.value="",this.placeholder="Select An Option",this.searchPlaceholder="Search...",this.label="",this._options=[],this.chipSize=20,this.color="primary",this.clearable=!1,this.loading=!1,this.compact=!1,this.disabled=!1,this.searchable=!1,this.multiSelect=!1,this.visibleChips=2,this.selectAll=!1,this._validations=[],this.showErrors=!1,this.errorDisplayMode="single",this.required=!1,this.emitFullObject=!1,this.emittedKey="value",this.displayKey="",this._customRenderers={},this.addOption=!1,this.validationArrayFormat=!1,this.prefix="",this.suffix="",this.prefixColor="",this.suffixColor="",this.justify="flex-start",this.zIndex=11,this.height="200px",this.requiredMessage="Selection is required.",this.readonly=!1,this.enforceMinOneSelection=!1,this.openAbove=!1,this.validationActive=!1,this.invalid=!1,this.variant="default",this.multiDisplay="chips",this.searchQuery="",this.filteredOptions=[],this.focused=!1,this.open=!1,this.selectedItems=[],this.hiddenChipsOpen=!1,this.activeIndex=-1,this.validationErrors=[],this.validationStatus=[],this.hasLeftIcon=!1,this.hasRightIcon=!1,this.optionSlotSet=new Set,this._rendererRuntimeState={},this._searchDebounceId=null,this._closeResetId=null,this.dropdownPopover=new g(this,{getAnchor:()=>this.inputWrapperEl,getPopover:()=>this.dropdownEl,cssVarLeft:"--sky-dd-left",cssVarTop:"--sky-dd-top",cssVarWidth:"--sky-dd-width",getPlacement:()=>"bottom",getAlign:()=>"start",getGap:()=>6,getPadding:()=>8,getMatchAnchorWidth:()=>!0,getMaxWidthToViewport:()=>!0,getMaxWidthMode:()=>"cap",getFlip:()=>!0,getFlipOrder:()=>[],getAnimateReposition:()=>!0,getRepositionMs:()=>160,getCloseOnEscape:()=>!0,getCloseOnOutside:()=>!0,getRestoreFocusOnClose:()=>!0,onOpenChange:(e,t)=>{this.open=e,e?(this.focused=!0,null!=this._closeResetId&&(clearTimeout(this._closeResetId),this._closeResetId=null),this.validationActive=!0,this.filterOptions(),requestAnimationFrame(()=>this.focusOnOpen())):(this.activeIndex=-1,null!=this._closeResetId&&clearTimeout(this._closeResetId),this._closeResetId=setTimeout(()=>{this._closeResetId=null,this.open||(this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions())},E._CLOSE_RESET_MS),this.hiddenChipsOpen=!1,this.hiddenPopover.closePopover("api"))}}),this.hiddenPopover=new g(this,{getAnchor:()=>this.overflowChipEl,getPopover:()=>this.hiddenDropdownEl,cssVarLeft:"--sky-hc-left",cssVarTop:"--sky-hc-top",cssVarWidth:"--sky-hc-width",getPlacement:()=>"bottom",getAlign:()=>"center",getGap:()=>4,getPadding:()=>8,getMatchAnchorWidth:()=>!1,getMaxWidthToViewport:()=>!0,getMaxWidthMode:()=>"cap",getFlip:()=>!0,getFlipOrder:()=>[],getAnimateReposition:()=>!0,getRepositionMs:()=>120,getCloseOnEscape:()=>!0,getCloseOnOutside:()=>!0,getRestoreFocusOnClose:()=>!1,onOpenChange:e=>{this.hiddenChipsOpen=e,e&&this.open&&this.dropdownPopover.closePopover("api")}}),this.preset="",this._presets=new x(this),this.refreshOptionSlots=()=>{const e=new Set;this.querySelectorAll('[slot^="option-"]').forEach(t=>{const i=t.slot;i&&e.add(i)}),this.optionSlotSet=e},this.onSearchKeydown=e=>{const{key:t,shiftKey:i}=e;if("Enter"===t)return e.preventDefault(),e.stopPropagation(),void this.commitDropdownEnter();if("ArrowDown"===t||"ArrowUp"===t||"Tab"===t){e.preventDefault(),e.stopPropagation();const i=this.searchable||this.addOption,s=this.multiSelect&&this.selectAll?i?1:0:this.headerRows,o=this.headerRows+Math.max(0,this.filteredOptions.length)-1,r="ArrowUp"===t||"Tab"===t&&e.shiftKey?-1:1;this.activeIndex<s?this.activeIndex=s:this.activeIndex=this.activeIndex+r<s?o:this.activeIndex+r>o?s:this.activeIndex+r,this.scrollActiveItemIntoView()}return"Escape"===t?(e.preventDefault(),e.stopPropagation(),void this.dropdownPopover.closePopover("escape")):void 0},this.handleAddaddOption=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;if(!this.canAddaddOption())return;const t=this.searchQuery.trim();this.dispatchEvent(new CustomEvent("add-new-option",{detail:{value:t},bubbles:!0,composed:!0})),this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions()},this.onIconSlotChange=()=>{this.hasLeftIcon=(this.iconLeftEls?.length??0)>0,this.hasRightIcon=(this.iconRightEls?.length??0)>0},this.captureDefaultValue("")}get options(){return this._options}set options(e){const t=this._options;this._options=Array.isArray(e)?e:[],this.requestUpdate("options",t)}get validations(){return this._validations}set validations(e){const t=this._validations;this._validations=Array.isArray(e)?e:[],this.requestUpdate("validations",t)}get customRenderers(){return this._customRenderers}set customRenderers(e){const t=this._customRenderers;this._customRenderers=null==e||"object"!=typeof e||Array.isArray(e)?{}:e,this.requestUpdate("customRenderers",t)}connectedCallback(){super.connectedCallback(),this.hasAttribute("tabindex")||(this.tabIndex=this.disabled?-1:0),this.refreshOptionSlots()}firstUpdated(){this.dropdownPopover.refreshTargets(),this.hiddenPopover.refreshTargets()}getFormValue(){if(this.disabled||!this.name)return null;if(this.multiSelect){const e=new FormData;return this.selectedItems.forEach(t=>{const i=this.emitFullObject?JSON.stringify(t):String(this.getOptionValue(t));e.append(this.name,i)}),0===this.selectedItems.length&&this.required&&e.append(this.name,""),e}{if(0===this.selectedItems.length)return"";const e=this.selectedItems[0];return this.emitFullObject?JSON.stringify(e):String(this.getOptionValue(e))}}setValueFromFormState(e){if(null===e||""===e)return this.value=this.multiSelect?[]:"",void(this.selectedItems=[]);if(this.multiSelect){let t=[];if(e instanceof FormData)t=e.getAll(this.name);else if(Array.isArray(e))t=e;else if("string"==typeof e)try{const i=JSON.parse(e);t=Array.isArray(i)?i:[e]}catch{t=[e]}this.setValueFromArray(t)}else{let t="";"string"==typeof e?t=e:e instanceof FormData?t=e.get(this.name)?.toString()||"":Array.isArray(e)&&e.length>0&&(t=e[0].toString()),this.value=t,this.syncSelectedItemsWithValue()}}syncFormValue(){if(!this.name||this.disabled)return void this.internals.setFormValue(null);const e=this.getFormValue();if(null!==e)if(this.multiSelect&&Array.isArray(e)){const t=new FormData;e.forEach(e=>{null!=e&&""!==e&&t.append(this.name,String(e))}),this.internals.setFormValue(t)}else this.internals.setFormValue(e);else this.internals.setFormValue(null)}setValueFromArray(e){const t=Array.isArray(this.options)?this.options:[];this.selectedItems=t.filter(t=>{const i=this.getOptionValue(t),s=this.emitFullObject?JSON.stringify(t):String(i);return e.some(e=>{const t=String(e);if(!this.emitFullObject)return t===s;try{const e=JSON.parse(t);return JSON.stringify(e)===s}catch{return t===s}})}),this.value=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e))}getValidityAnchor(){return this}isEmpty(){return this.multiSelect?0===this.selectedItems.length:0===this.selectedItems.length||!this.value}getNativeControl(){return this.inputWrapperEl||null}getCustomErrorMessage(){return this.validationErrors?.[0]||""}onFormReset(){super.onFormReset(),this.searchQuery="",this.emitSearchQueryChanged(),this.open=!1,this.invalid=!1,this.validationErrors=[],this.validationActive=!1}onFormDisabled(e){this.disabled=e}onFormStateRestore(e){this.setValueFromFormState(e)}toggleSelectAll(){if(this.disabled||this.readonly)return;if(this.isAllFilteredSelected()){const e=new Set(this.filteredOptions.map(e=>this.optionKey(e.original))),t=this.selectedItems.filter(t=>!e.has(this.optionKey(t)));if(this.enforceMinOneSelection&&0===t.length)return;this.selectedItems=t}else{const e=new Set(this.selectedItems.map(e=>this.optionKey(e))),t=this.filteredOptions.map(e=>e.original).filter(t=>!e.has(this.optionKey(t)));this.selectedItems=[...this.selectedItems,...t]}const e=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e));this.value=e,this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:e,selectedItems:[...this.selectedItems],emittedValues:e,isFilteredSelection:!!this.searchQuery.trim()},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity(),this.requestUpdate()}isAllFilteredSelected(){if(0===this.filteredOptions.length)return!1;const e=new Set(this.selectedItems.map(e=>this.optionKey(e)));return this.filteredOptions.every(t=>e.has(this.optionKey(t.original)))}truncateText(e,t){return e.length>t?e.slice(0,t)+"...":e}validateInput(){if(!this.validationActive)return;this.validationErrors=[];const e=this.validationArrayFormat?this.selectedItems:this.value;if(this.required&&this.isEmpty())this.validationErrors.push(this.requiredMessage||"Selection is required.");else if(Array.isArray(this.validations)&&this.validations.length)for(const t of this.validations){const i=t(e);!0!==i&&this.validationErrors.push(String(i||"Invalid value."))}this.invalid=this.validationErrors.length>0,this.dispatchEvent(new CustomEvent(this.invalid?"validation-error":"validation-success",{detail:this.invalid?{errors:this.validationErrors}:{value:this.selectedItems},bubbles:!0,composed:!0})),this.syncValidity(),this.requestUpdate()}validateForForm(){if(this.disabled)return"";const e=this.validationArrayFormat?this.selectedItems:this.value;if(Array.isArray(this.validations)&&this.validations.length)for(const t of this.validations){const i=t(e);if(!0!==i)return String(i||"Invalid value.")}return this.enforceMinOneSelection&&this.isEmpty()?this.requiredMessage||"At least one selection is required.":this.required&&this.isEmpty()?this.requiredMessage||"Selection is required.":""}focus(e){super.focus(e),this.searchInputEl?this.searchInputEl.focus(e):this.inputWrapperEl&&this.inputWrapperEl.focus(e)}blur(){this.open&&this.dropdownPopover.closePopover("light-dismiss"),super.blur()}handleFocus(){this.focused=!0,this.validationActive||(this.validationActive=!0)}reset(){this.value=this.multiSelect?[]:"",this.selectedItems=[],this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions(),this.validationErrors=[],this.validationActive=!1,this.open=!1,this.invalid=!1,this.syncFormValue(),this.syncValidity(),this.requestUpdate()}openDropdown(){this.disabled||this.readonly||this.dropdownPopover.openPopover()}closeDropdown(){this.dropdownPopover.closePopover("api")}clearSelection(){this.handleClear()}handleBlur(){this.open||(this.focused=!1,this.validationActive&&this.validateInput())}updated(e){e.has("color")&&this.style.setProperty("--sky-dropdown-color",v(this.color)),e.has("height")&&this.style.setProperty("--sky-scroll-height",this.height)}willUpdate(e){e.has("customRenderers")&&this.syncRendererStateFromProp(),e.has("value")&&(this.syncSelectedItemsWithValue(),this.syncFormValue(),this.syncValidity()),e.has("options")&&(Array.isArray(this.options)||(this.options=[]),this.syncSelectedItemsWithValue(),this.filterOptions(),this.syncFormValue(),this.syncValidity()),e.has("searchable")&&this.filterOptions(),e.has("searchQuery")&&this.filterOptions(),e.has("validationErrors")&&this.requestUpdate()}patchRendererState(e){this._rendererRuntimeState={...this._rendererRuntimeState,...e},this.requestUpdate()}syncRendererStateFromProp(){const e=$(this.customRenderers);this._rendererRuntimeState={...this._rendererRuntimeState,...e}}rendererStateApi(){return{rendererState:this._rendererRuntimeState,patchRendererState:e=>this.patchRendererState(e)}}buildOptionRenderContext(e){return{index:e.index,sourceIndex:e.sourceIndex,label:String(this.getOptionLabel(e.option)),highlightedLabel:e.highlightedLabel,selected:e.selected,active:e.active,multiSelect:this.multiSelect,...this.rendererStateApi()}}buildSelectedRenderContext(e,t){return{selectedItems:[...this.selectedItems],index:t,multiSelect:this.multiSelect,multiDisplay:this.resolveMultiDisplay(),label:String(this.getOptionLabel(e)),...this.rendererStateApi()}}renderOptionContent(e){const t=s`<span
1
+ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as r}from"lit";import{property as o,state as n,query as a,queryAll as l,queryAssignedElements as h,customElement as d}from"lit/decorators.js";import{unsafeHTML as p}from"lit/directives/unsafe-html.js";import{when as c}from"lit/directives/when.js";import{repeat as u}from"lit/directives/repeat.js";import{classMap as y}from"lit/directives/class-map.js";import{resolveColor as v}from"../helper/utils/color-resolver.js";import{cssOnFillEnhance as m}from"../helper/utils/contrast-color.js";import{PopoverController as g}from"../helper/controllers/popover-controller.js";import{FormControlBase as f}from"../helper/internals/form-control-base.js";import{SkyIcon as b}from"../sky-icon/sky-icon.js";import{SkyCheckbox as k}from"../sky-checkbox/sky-checkbox.js";import{SkyInput as w}from"../sky-input/sky-input.js";import{PresetController as x}from"../helper/controllers/preset-controller.js";import{arrayPropHasChanged as S,EMPTY_ARRAY as I,coerceArray as O}from"../helper/utils/stable-array.js";var $=Object.defineProperty,A=Object.getOwnPropertyDescriptor,C=(e,t,i,s)=>{for(var r,o=s>1?void 0:s?A(t,i):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(s?r(t,i,o):r(o))||o);return s&&o&&$(t,i,o),o};const E="$rendererState",z=Object.freeze({});function V(e){const t=e?.[E];return function(e){if(null==e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"function"!=typeof t.option&&"function"!=typeof t.selected}(t)?{...t}:{}}let F=class extends f{constructor(){super(),this.value="",this.placeholder="Select An Option",this.searchPlaceholder="Search...",this.label="",this._options=I,this.chipSize=20,this.color="primary",this.clearable=!1,this.loading=!1,this.compact=!1,this.disabled=!1,this.searchable=!1,this.multiSelect=!1,this.visibleChips=2,this.selectAll=!1,this._validations=I,this.showErrors=!1,this.errorDisplayMode="single",this.required=!1,this.emitFullObject=!1,this.emittedKey="value",this.displayKey="",this._customRenderers=z,this.addOption=!1,this.validationArrayFormat=!1,this.prefix="",this.suffix="",this.prefixColor="",this.suffixColor="",this.justify="flex-start",this.zIndex=11,this.height="200px",this.requiredMessage="Selection is required.",this.readonly=!1,this.enforceMinOneSelection=!1,this.openAbove=!1,this.validationActive=!1,this.invalid=!1,this.variant="default",this.multiDisplay="chips",this.searchQuery="",this.filteredOptions=[],this.focused=!1,this.open=!1,this.selectedItems=[],this.hiddenChipsOpen=!1,this.activeIndex=-1,this.validationErrors=[],this.validationStatus=[],this.hasLeftIcon=!1,this.hasRightIcon=!1,this.optionSlotSet=new Set,this._rendererRuntimeState={},this._searchDebounceId=null,this._deferSearchFilter=!1,this._closeResetId=null,this.dropdownPopover=new g(this,{getAnchor:()=>this.inputWrapperEl,getPopover:()=>this.dropdownEl,cssVarLeft:"--sky-dd-left",cssVarTop:"--sky-dd-top",cssVarWidth:"--sky-dd-width",getPlacement:()=>"bottom",getAlign:()=>"start",getGap:()=>6,getPadding:()=>8,getMatchAnchorWidth:()=>!0,getMaxWidthToViewport:()=>!0,getMaxWidthMode:()=>"cap",getFlip:()=>!0,getFlipOrder:()=>[],getAnimateReposition:()=>!0,getRepositionMs:()=>160,getCloseOnEscape:()=>!0,getCloseOnOutside:()=>!0,getRestoreFocusOnClose:()=>!0,onOpenChange:(e,t)=>{this.open=e,e?(this.focused=!0,null!=this._closeResetId&&(clearTimeout(this._closeResetId),this._closeResetId=null),this.validationActive=!0,this.filterOptions(),requestAnimationFrame(()=>this.focusOnOpen())):(this.activeIndex=-1,null!=this._closeResetId&&clearTimeout(this._closeResetId),this._closeResetId=setTimeout(()=>{this._closeResetId=null,this.open||(this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions())},F._CLOSE_RESET_MS),this.hiddenChipsOpen=!1,this.hiddenPopover.closePopover("api"))}}),this.hiddenPopover=new g(this,{getAnchor:()=>this.overflowChipEl,getPopover:()=>this.hiddenDropdownEl,cssVarLeft:"--sky-hc-left",cssVarTop:"--sky-hc-top",cssVarWidth:"--sky-hc-width",getPlacement:()=>"bottom",getAlign:()=>"center",getGap:()=>4,getPadding:()=>8,getMatchAnchorWidth:()=>!1,getMaxWidthToViewport:()=>!0,getMaxWidthMode:()=>"cap",getFlip:()=>!0,getFlipOrder:()=>[],getAnimateReposition:()=>!0,getRepositionMs:()=>120,getCloseOnEscape:()=>!0,getCloseOnOutside:()=>!0,getRestoreFocusOnClose:()=>!1,onOpenChange:e=>{this.hiddenChipsOpen=e,e&&this.open&&this.dropdownPopover.closePopover("api")}}),this.preset="",this._presets=new x(this),this.refreshOptionSlots=()=>{const e=new Set;this.querySelectorAll('[slot^="option-"]').forEach(t=>{const i=t.slot;i&&e.add(i)}),this.optionSlotSet=e},this.onSearchKeydown=e=>{const{key:t,shiftKey:i}=e;if("Enter"===t)return e.preventDefault(),e.stopPropagation(),void this.commitDropdownEnter();if("ArrowDown"===t||"ArrowUp"===t||"Tab"===t){e.preventDefault(),e.stopPropagation();const i=this.searchable||this.addOption,s=this.multiSelect&&this.selectAll?i?1:0:this.headerRows,r=this.headerRows+Math.max(0,this.filteredOptions.length)-1,o="ArrowUp"===t||"Tab"===t&&e.shiftKey?-1:1;this.activeIndex<s?this.activeIndex=s:this.activeIndex=this.activeIndex+o<s?r:this.activeIndex+o>r?s:this.activeIndex+o,this.scrollActiveItemIntoView()}return"Escape"===t?(e.preventDefault(),e.stopPropagation(),void this.dropdownPopover.closePopover("escape")):void 0},this.handleAddaddOption=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;if(!this.canAddaddOption())return;const t=this.searchQuery.trim();this.dispatchEvent(new CustomEvent("add-new-option",{detail:{value:t},bubbles:!0,composed:!0})),this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions()},this.onIconSlotChange=()=>{this.hasLeftIcon=(this.iconLeftEls?.length??0)>0,this.hasRightIcon=(this.iconRightEls?.length??0)>0},this.captureDefaultValue("")}get options(){return this._options}set options(e){this._options=O(e)}get validations(){return this._validations}set validations(e){this._validations=O(e)}get customRenderers(){return this._customRenderers}set customRenderers(e){this._customRenderers=null==e||"object"!=typeof e||Array.isArray(e)?z:e}connectedCallback(){super.connectedCallback(),this.hasAttribute("tabindex")||(this.tabIndex=this.disabled?-1:0),this.refreshOptionSlots()}firstUpdated(){this.dropdownPopover.refreshTargets(),this.hiddenPopover.refreshTargets()}getFormValue(){if(this.disabled||!this.name)return null;if(this.multiSelect){const e=new FormData;return this.selectedItems.forEach(t=>{const i=this.emitFullObject?JSON.stringify(t):String(this.getOptionValue(t));e.append(this.name,i)}),0===this.selectedItems.length&&this.required&&e.append(this.name,""),e}{if(0===this.selectedItems.length)return"";const e=this.selectedItems[0];return this.emitFullObject?JSON.stringify(e):String(this.getOptionValue(e))}}setValueFromFormState(e){if(null===e||""===e)return this.value=this.multiSelect?[]:"",void(this.selectedItems=[]);if(this.multiSelect){let t=[];if(e instanceof FormData)t=e.getAll(this.name);else if(Array.isArray(e))t=e;else if("string"==typeof e)try{const i=JSON.parse(e);t=Array.isArray(i)?i:[e]}catch{t=[e]}this.setValueFromArray(t)}else{let t="";"string"==typeof e?t=e:e instanceof FormData?t=e.get(this.name)?.toString()||"":Array.isArray(e)&&e.length>0&&(t=e[0].toString()),this.value=t,this.syncSelectedItemsWithValue()}}syncFormValue(){if(!this.name||this.disabled)return void this.internals.setFormValue(null);const e=this.getFormValue();if(null!==e)if(this.multiSelect&&Array.isArray(e)){const t=new FormData;e.forEach(e=>{null!=e&&""!==e&&t.append(this.name,String(e))}),this.internals.setFormValue(t)}else this.internals.setFormValue(e);else this.internals.setFormValue(null)}setValueFromArray(e){const t=Array.isArray(this.options)?this.options:[];this.selectedItems=t.filter(t=>{const i=this.getOptionValue(t),s=this.emitFullObject?JSON.stringify(t):String(i);return e.some(e=>{const t=String(e);if(!this.emitFullObject)return t===s;try{const e=JSON.parse(t);return JSON.stringify(e)===s}catch{return t===s}})}),this.value=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e))}getValidityAnchor(){return this}isEmpty(){return this.multiSelect?0===this.selectedItems.length:0===this.selectedItems.length||!this.value}getNativeControl(){return this.inputWrapperEl||null}getCustomErrorMessage(){return this.validationErrors?.[0]||""}onFormReset(){super.onFormReset(),this.searchQuery="",this.emitSearchQueryChanged(),this.open=!1,this.invalid=!1,this.validationErrors=[],this.validationActive=!1}onFormDisabled(e){this.disabled=e}onFormStateRestore(e){this.setValueFromFormState(e)}toggleSelectAll(){if(this.disabled||this.readonly)return;if(this.isAllFilteredSelected()){const e=new Set(this.filteredOptions.map(e=>this.optionKey(e.original))),t=this.selectedItems.filter(t=>!e.has(this.optionKey(t)));if(this.enforceMinOneSelection&&0===t.length)return;this.selectedItems=t}else{const e=new Set(this.selectedItems.map(e=>this.optionKey(e))),t=this.filteredOptions.map(e=>e.original).filter(t=>!e.has(this.optionKey(t)));this.selectedItems=[...this.selectedItems,...t]}const e=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e));this.value=e,this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:e,selectedItems:[...this.selectedItems],emittedValues:e,isFilteredSelection:!!this.searchQuery.trim()},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity(),this.requestUpdate()}isAllFilteredSelected(){if(0===this.filteredOptions.length)return!1;const e=new Set(this.selectedItems.map(e=>this.optionKey(e)));return this.filteredOptions.every(t=>e.has(this.optionKey(t.original)))}truncateText(e,t){return e.length>t?e.slice(0,t)+"...":e}validateInput(){if(!this.validationActive)return;const e=[],t=this.validationArrayFormat?this.selectedItems:this.value;if(this.required&&this.isEmpty())e.push(this.requiredMessage||"Selection is required.");else if(Array.isArray(this.validations)&&this.validations.length)for(const i of this.validations){const s=i(t);!0!==s&&e.push(String(s||"Invalid value."))}const i=e.length>0;!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}(this.validationErrors,e)&&(this.validationErrors=e),this.invalid!==i&&(this.invalid=i),this.dispatchEvent(new CustomEvent(this.invalid?"validation-error":"validation-success",{detail:this.invalid?{errors:this.validationErrors}:{value:this.selectedItems},bubbles:!0,composed:!0})),this.syncValidity()}validateForForm(){if(this.disabled)return"";const e=this.validationArrayFormat?this.selectedItems:this.value;if(Array.isArray(this.validations)&&this.validations.length)for(const t of this.validations){const i=t(e);if(!0!==i)return String(i||"Invalid value.")}return this.enforceMinOneSelection&&this.isEmpty()?this.requiredMessage||"At least one selection is required.":this.required&&this.isEmpty()?this.requiredMessage||"Selection is required.":""}focus(e){super.focus(e),this.searchInputEl?this.searchInputEl.focus(e):this.inputWrapperEl&&this.inputWrapperEl.focus(e)}blur(){this.open&&this.dropdownPopover.closePopover("light-dismiss"),super.blur()}handleFocus(){this.focused=!0,this.validationActive||(this.validationActive=!0)}reset(){this.value=this.multiSelect?[]:"",this.selectedItems=[],this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions(),this.validationErrors=[],this.validationActive=!1,this.open=!1,this.invalid=!1,this.syncFormValue(),this.syncValidity(),this.requestUpdate()}openDropdown(){this.disabled||this.readonly||this.dropdownPopover.openPopover()}closeDropdown(){this.dropdownPopover.closePopover("api")}clearSelection(){this.handleClear()}handleBlur(){this.open||(this.focused=!1,this.validationActive&&this.validateInput())}updated(e){e.has("color")&&this.style.setProperty("--sky-dropdown-color",v(this.color)),e.has("height")&&this.style.setProperty("--sky-scroll-height",this.height)}willUpdate(e){e.has("customRenderers")&&this.syncRendererStateFromProp(),e.has("value")&&(this.syncSelectedItemsWithValue(),this.syncFormValue(),this.syncValidity()),e.has("options")&&(Array.isArray(this.options)||(this.options=I),this.syncSelectedItemsWithValue(),this.filterOptions(),this.syncFormValue(),this.syncValidity()),e.has("searchable")&&this.filterOptions(),e.has("searchQuery")&&!this._deferSearchFilter&&this.filterOptions()}patchRendererState(e){this._rendererRuntimeState={...this._rendererRuntimeState,...e},this.requestUpdate()}syncRendererStateFromProp(){const e=V(this.customRenderers);this._rendererRuntimeState={...this._rendererRuntimeState,...e}}rendererStateApi(){return{rendererState:this._rendererRuntimeState,patchRendererState:e=>this.patchRendererState(e)}}buildOptionRenderContext(e){return{index:e.index,sourceIndex:e.sourceIndex,label:String(this.getOptionLabel(e.option)),highlightedLabel:e.highlightedLabel,selected:e.selected,active:e.active,multiSelect:this.multiSelect,...this.rendererStateApi()}}buildSelectedRenderContext(e,t){return{selectedItems:[...this.selectedItems],index:t,multiSelect:this.multiSelect,multiDisplay:this.resolveMultiDisplay(),label:String(this.getOptionLabel(e)),...this.rendererStateApi()}}renderOptionContent(e){const t=s`<span
2
2
  class="highlighted-text"
3
3
  part="highlighted-text"
4
4
  >${p(e.highlighted)}</span
@@ -8,7 +8,7 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
8
8
  </div>
9
9
  `;const i=this.customRenderers?.option;if(i){const t=i(e.option,this.buildOptionRenderContext({option:e.option,index:e.index,sourceIndex:e.sourceIndex,highlightedLabel:e.highlighted,selected:e.selected,active:e.active}));return s`<div style="display: flex; gap: 8px;width:100%">
10
10
  ${t}
11
- </div>`}return t}renderSelectedLabel(e,t){const i=this.customRenderers?.selected;return i?i(e,this.buildSelectedRenderContext(e,t)):this.truncateText(String(this.getOptionLabel(e)),this.chipSize)}renderSelectedSummaryLabel(e,t){const i=this.customRenderers?.selected;return i?i(e,this.buildSelectedRenderContext(e,t)):String(this.getOptionLabel(e))}syncSelectedItemsWithValue(){const e=Array.isArray(this.options)?this.options:[],t=this.multiSelect&&Array.isArray(this.value)&&0===this.value.length;if(null==this.value||""===this.value||t)return this.selectedItems=[],void(this.value=this.multiSelect?[]:"");if(this.multiSelect&&"string"==typeof this.value)try{const e=JSON.parse(this.value);Array.isArray(e)&&(this.value=e)}catch(e){}if(this.multiSelect){const t=Array.isArray(this.value)?this.value:[this.value],i=new Set(t.map(e=>this.optionKey(e)));this.selectedItems=e.filter(e=>i.has(this.optionKey(e))),this.value=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e))}else{const t=this.optionKey(this.value),i=e.find(e=>this.optionKey(e)===t);this.selectedItems=i?[i]:[],this.value=i?this.emitFullObject?i:this.getOptionValue(i):""}}filterOptions(){const e=Array.isArray(this.options)?this.options:[],t=(e,t)=>{const i=this.getOptionLabel(e);return{original:e,_idx:t,label:i,highlighted:i}};if(!this.searchable||!this.searchQuery.trim())return void(this.filteredOptions=e.map(t));const i=this.searchQuery.toLowerCase();this.filteredOptions=e.map(t).filter(e=>String(e.label).toLowerCase().includes(i)).map(e=>{const t=new RegExp(`(${i})`,"gi");return{...e,highlighted:String(e.label).replace(t,e=>`<span class="highlight">${e}</span>`)}})}emitSearchQueryChanged(){this.dispatchEvent(new CustomEvent("search-query-changed",{detail:{searchQuery:this.searchQuery},bubbles:!0,composed:!0}))}handleSearchValueChanged(e){e.stopPropagation(),this.disabled||this.readonly||this.applySearchQuery(String(e.detail?.value??""))}handleSearchValueCleared(e){e.stopPropagation(),this.disabled||this.readonly||this.applySearchQuery("")}applySearchQuery(e){this.searchQuery=e;const t=Array.isArray(this.options)?this.options.length:0,i=this.searchable&&t>E._SEARCH_DEBOUNCE_OPTIONS_THRESHOLD,s=()=>{this.filterOptions(),this.emitSearchQueryChanged()};i?(null!=this._searchDebounceId&&clearTimeout(this._searchDebounceId),this._searchDebounceId=setTimeout(()=>{this._searchDebounceId=null,s()},E._SEARCH_DEBOUNCE_MS)):s()}disconnectedCallback(){super.disconnectedCallback(),null!=this._searchDebounceId&&(clearTimeout(this._searchDebounceId),this._searchDebounceId=null),null!=this._closeResetId&&(clearTimeout(this._closeResetId),this._closeResetId=null)}handleClear(){if(this.disabled||this.readonly)return;const e=this.multiSelect?this.selectedItems.length>0:!!this.value;this.enforceMinOneSelection&&e||(this.value=this.multiSelect?[]:"",this.selectedItems=[],this.searchQuery="",this.emitSearchQueryChanged(),this.open=!1,this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:[],isFilteredSelection:!1},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity())}selectOption(e){if(this.disabled||this.readonly)return;const t=e=>this.emitFullObject?e:this.getOptionValue(e),i=""!==this.searchQuery.trim();if(!this.multiSelect){const s=this.selectedItems.length&&this.optionKey(this.selectedItems[0])===this.optionKey(e);return s&&this.enforceMinOneSelection?void(this.open=!1):(s?(this.selectedItems=[],this.value=""):(this.selectedItems=[e],this.value=t(e)),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:this.selectedItems,emittedValues:this.selectedItems.map(t),isFilteredSelection:i},bubbles:!0,composed:!0})),this.dropdownPopover.closePopover("api"),this.syncFormValue(),this.syncValidity(),void this.requestUpdate())}const s=this.selectedItems.findIndex(t=>this.optionKey(t)===this.optionKey(e));let o;o=s>-1?[...this.selectedItems.slice(0,s),...this.selectedItems.slice(s+1)]:[...this.selectedItems,e],this.enforceMinOneSelection&&0===o.length||(this.selectedItems=o,this.value=o.map(t),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:this.selectedItems,emittedValues:this.value,isFilteredSelection:i},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity(),this.open=!0,this.requestUpdate())}toggleHiddenChips(e){e.stopPropagation(),e.preventDefault(),this.disabled||this.readonly||(this.open&&this.dropdownPopover.closePopover("api"),this.hiddenPopover.toggle())}renderHiddenChipsDropdown(){return s`
11
+ </div>`}return t}renderSelectedLabel(e,t){const i=this.customRenderers?.selected;return i?i(e,this.buildSelectedRenderContext(e,t)):this.truncateText(String(this.getOptionLabel(e)),this.chipSize)}renderSelectedSummaryLabel(e,t){const i=this.customRenderers?.selected;return i?i(e,this.buildSelectedRenderContext(e,t)):String(this.getOptionLabel(e))}syncSelectedItemsWithValue(){const e=Array.isArray(this.options)?this.options:[],t=this.multiSelect&&Array.isArray(this.value)&&0===this.value.length;if(null==this.value||""===this.value||t)return this.selectedItems=[],void(this.value=this.multiSelect?[]:"");if(this.multiSelect&&"string"==typeof this.value)try{const e=JSON.parse(this.value);Array.isArray(e)&&(this.value=e)}catch(e){}if(this.multiSelect){const t=Array.isArray(this.value)?this.value:[this.value],i=new Set(t.map(e=>this.optionKey(e)));this.selectedItems=e.filter(e=>i.has(this.optionKey(e))),this.value=this.selectedItems.map(e=>this.emitFullObject?e:this.getOptionValue(e))}else{const t=this.optionKey(this.value),i=e.find(e=>this.optionKey(e)===t);this.selectedItems=i?[i]:[],this.value=i?this.emitFullObject?i:this.getOptionValue(i):""}}filterOptions(){const e=Array.isArray(this.options)?this.options:[],t=(e,t)=>{const i=this.getOptionLabel(e);return{original:e,_idx:t,label:i,highlighted:i}};if(!this.searchable||!this.searchQuery.trim())return void(this.filteredOptions=e.map(t));const i=this.searchQuery.toLowerCase();this.filteredOptions=e.map(t).filter(e=>String(e.label).toLowerCase().includes(i)).map(e=>{const t=new RegExp(`(${i})`,"gi");return{...e,highlighted:String(e.label).replace(t,e=>`<span class="highlight">${e}</span>`)}})}emitSearchQueryChanged(){this.dispatchEvent(new CustomEvent("search-query-changed",{detail:{searchQuery:this.searchQuery},bubbles:!0,composed:!0}))}handleSearchValueChanged(e){e.stopPropagation(),this.disabled||this.readonly||this.applySearchQuery(String(e.detail?.value??""))}handleSearchValueCleared(e){e.stopPropagation(),this.disabled||this.readonly||this.applySearchQuery("")}applySearchQuery(e){const t=Array.isArray(this.options)?this.options.length:0,i=this.searchable&&e.trim().length>0&&t>F._SEARCH_DEBOUNCE_OPTIONS_THRESHOLD;if(null!=this._searchDebounceId&&(clearTimeout(this._searchDebounceId),this._searchDebounceId=null),i)return this._deferSearchFilter=!0,this.searchQuery=e,void(this._searchDebounceId=setTimeout(()=>{this._searchDebounceId=null,this._deferSearchFilter=!1,this.filterOptions(),this.emitSearchQueryChanged()},F._SEARCH_DEBOUNCE_MS));this._deferSearchFilter=!1,this.searchQuery=e,this.filterOptions(),this.emitSearchQueryChanged()}disconnectedCallback(){super.disconnectedCallback(),this._deferSearchFilter=!1,null!=this._searchDebounceId&&(clearTimeout(this._searchDebounceId),this._searchDebounceId=null),null!=this._closeResetId&&(clearTimeout(this._closeResetId),this._closeResetId=null)}handleClear(){if(this.disabled||this.readonly)return;const e=this.multiSelect?this.selectedItems.length>0:!!this.value;this.enforceMinOneSelection&&e||(this.value=this.multiSelect?[]:"",this.selectedItems=[],this.searchQuery="",this.emitSearchQueryChanged(),this.open=!1,this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:[],isFilteredSelection:!1},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity())}selectOption(e){if(this.disabled||this.readonly)return;const t=e=>this.emitFullObject?e:this.getOptionValue(e),i=""!==this.searchQuery.trim();if(!this.multiSelect){const s=this.selectedItems.length&&this.optionKey(this.selectedItems[0])===this.optionKey(e);return s&&this.enforceMinOneSelection?void(this.open=!1):(s?(this.selectedItems=[],this.value=""):(this.selectedItems=[e],this.value=t(e)),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:this.selectedItems,emittedValues:this.selectedItems.map(t),isFilteredSelection:i},bubbles:!0,composed:!0})),this.dropdownPopover.closePopover("api"),this.syncFormValue(),this.syncValidity(),void this.requestUpdate())}const s=this.selectedItems.findIndex(t=>this.optionKey(t)===this.optionKey(e));let r;r=s>-1?[...this.selectedItems.slice(0,s),...this.selectedItems.slice(s+1)]:[...this.selectedItems,e],this.enforceMinOneSelection&&0===r.length||(this.selectedItems=r,this.value=r.map(t),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.value,selectedItems:this.selectedItems,emittedValues:this.value,isFilteredSelection:i},bubbles:!0,composed:!0})),this.syncFormValue(),this.syncValidity(),this.open=!0,this.requestUpdate())}toggleHiddenChips(e){e.stopPropagation(),e.preventDefault(),this.disabled||this.readonly||(this.open&&this.dropdownPopover.closePopover("api"),this.hiddenPopover.toggle())}renderHiddenChipsDropdown(){return s`
12
12
  <div
13
13
  class="hidden-chips-dropdown"
14
14
  part="hidden-chips-dropdown"
@@ -79,19 +79,19 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
79
79
  <span class="value-summary" part="value-summary" title=${t}
80
80
  >${t}</span
81
81
  >
82
- `}if("count"===e){const e=this.selectedItems.length,t=String(this.getOptionLabel(this.selectedItems[0])),i=1===e?t:`${t} +${e-1}`,r=this.selectedItems.map(e=>String(this.getOptionLabel(e))).join(", "),n=this.customRenderers?.selected;return n?s`
83
- <span class="value-summary" part="value-summary" title=${r}>
84
- ${n(this.selectedItems[0],this.buildSelectedRenderContext(this.selectedItems[0],0))}${e>1?" +"+(e-1):o}
82
+ `}if("count"===e){const e=this.selectedItems.length,t=String(this.getOptionLabel(this.selectedItems[0])),i=1===e?t:`${t} +${e-1}`,o=this.selectedItems.map(e=>String(this.getOptionLabel(e))).join(", "),n=this.customRenderers?.selected;return n?s`
83
+ <span class="value-summary" part="value-summary" title=${o}>
84
+ ${n(this.selectedItems[0],this.buildSelectedRenderContext(this.selectedItems[0],0))}${e>1?" +"+(e-1):r}
85
85
  </span>
86
86
  `:s`
87
- <span class="value-summary" part="value-summary" title=${r}
87
+ <span class="value-summary" part="value-summary" title=${o}
88
88
  >${i}</span
89
89
  >
90
90
  `}return s`
91
91
  <div class="chip-container" part="chip-container" ?compact=${this.compact}>
92
92
  ${this.renderChips()}
93
93
  </div>
94
- `}handleKeydown(e){if(e.target?.closest(".search-container"))return;const{key:t,shiftKey:i}=e;if(!this.open&&("ArrowDown"===t||"ArrowUp"===t||"Enter"===t))return this.dropdownPopover.openPopover(),void e.preventDefault();if(!this.open)return;const s=this.searchable||this.addOption,o=this.multiSelect&&this.selectAll?s?1:0:this.headerRows,r=this.headerRows+Math.max(0,this.filteredOptions.length)-1;if(this.activeIndex<o&&(this.activeIndex=o),"ArrowDown"===t){const t=this.activeIndex<o?o:this.activeIndex;return this.activeIndex=t>=r?o:t+1,this.scrollActiveItemIntoView(),void e.preventDefault()}if("ArrowUp"===t){const t=this.activeIndex<o?o:this.activeIndex;return this.activeIndex=t<=o?r:t-1,this.scrollActiveItemIntoView(),void e.preventDefault()}if("Tab"===t){if(i){const e=this.activeIndex<o?o:this.activeIndex;this.activeIndex=e<=o?r:e-1}else{const e=this.activeIndex<o?o:this.activeIndex;this.activeIndex=e>=r?o:e+1}return this.scrollActiveItemIntoView(),void e.preventDefault()}return"Enter"===t?(e.preventDefault(),e.stopPropagation(),void this.commitDropdownEnter()):this.readonly?void("Escape"===t&&(this.open=!1,e.preventDefault())):"Home"===t?(this.activeIndex=o,this.scrollActiveItemIntoView(),void e.preventDefault()):"End"===t?(this.activeIndex=Math.max(o,r),this.scrollActiveItemIntoView(),void e.preventDefault()):void 0}get headerRows(){let e=0;return(this.searchable||this.addOption)&&(e+=1),this.multiSelect&&this.selectAll&&(e+=1),e}getOptionByActiveIndex(){if(!this.open)return null;const e=this.activeIndex;if(e<0)return null;if((this.searchable||this.addOption)&&0===e)return{kind:"search"};const t=this.searchable||this.addOption?1:0;if(this.multiSelect&&this.selectAll&&e===t)return{kind:"select-all"};const i=e-this.headerRows;return i>=0&&i<this.filteredOptions.length?{kind:"option",optionIndex:i}:null}commitDropdownEnter(){const e=this.getOptionByActiveIndex();if(e)if("search"!==e.kind)if("select-all"!==e.kind){if("option"===e.kind&&"number"==typeof e.optionIndex){const t=this.filteredOptions[e.optionIndex].original;this.selectOption(t)}}else this.toggleSelectAll();else this.addOption&&this.canAddaddOption()?(this.dispatchEvent(new CustomEvent("add-new-option",{detail:{value:this.searchQuery.trim()},bubbles:!0,composed:!0})),this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions()):this.filteredOptions.length>0&&this.selectOption(this.filteredOptions[0].original)}focusOnOpen(){const e=this.searchInputEl;if(e&&document.activeElement!==e&&requestAnimationFrame(()=>e.focus()),this.filteredOptions.length>0){let e=0;if(this.selectedItems.length>0){const t=this.optionKey(this.selectedItems[0]),i=this.filteredOptions.findIndex(e=>this.optionKey(e.original)===t);i>=0&&(e=i)}return this.activeIndex=this.headerRows+e,void this.scrollActiveItemIntoView()}this.activeIndex=this.searchable||this.addOption?0:-1}canAddaddOption(){if(!this.addOption)return!1;const e=this.searchQuery.trim();if(!e)return!1;return!(Array.isArray(this.options)?this.options:[]).some(t=>{const i=String(this.getOptionLabel(t)||"").toLowerCase(),s=(this.getOptionValue(t)??"").toString().toLowerCase();return i===e.toLowerCase()||s===e.toLowerCase()})}scrollActiveItemIntoView(){const e=Array.from(this.rowEls).find(e=>Number(e.dataset.rowIndex)===this.activeIndex);e?.scrollIntoView({block:"nearest",behavior:"smooth"})}toggleDropdown(e){e.stopPropagation(),this.disabled||this.readonly||(this.hiddenChipsOpen&&this.hiddenPopover.closePopover("api"),this.validationActive=!0,this.dropdownPopover.toggle())}renderDropdown(){return s`
94
+ `}handleKeydown(e){if(e.target?.closest(".search-container"))return;const{key:t,shiftKey:i}=e;if(!this.open&&("ArrowDown"===t||"ArrowUp"===t||"Enter"===t))return this.dropdownPopover.openPopover(),void e.preventDefault();if(!this.open)return;const s=this.searchable||this.addOption,r=this.multiSelect&&this.selectAll?s?1:0:this.headerRows,o=this.headerRows+Math.max(0,this.filteredOptions.length)-1;if(this.activeIndex<r&&(this.activeIndex=r),"ArrowDown"===t){const t=this.activeIndex<r?r:this.activeIndex;return this.activeIndex=t>=o?r:t+1,this.scrollActiveItemIntoView(),void e.preventDefault()}if("ArrowUp"===t){const t=this.activeIndex<r?r:this.activeIndex;return this.activeIndex=t<=r?o:t-1,this.scrollActiveItemIntoView(),void e.preventDefault()}if("Tab"===t){if(i){const e=this.activeIndex<r?r:this.activeIndex;this.activeIndex=e<=r?o:e-1}else{const e=this.activeIndex<r?r:this.activeIndex;this.activeIndex=e>=o?r:e+1}return this.scrollActiveItemIntoView(),void e.preventDefault()}return"Enter"===t?(e.preventDefault(),e.stopPropagation(),void this.commitDropdownEnter()):this.readonly?void("Escape"===t&&(this.open=!1,e.preventDefault())):"Home"===t?(this.activeIndex=r,this.scrollActiveItemIntoView(),void e.preventDefault()):"End"===t?(this.activeIndex=Math.max(r,o),this.scrollActiveItemIntoView(),void e.preventDefault()):void 0}get headerRows(){let e=0;return(this.searchable||this.addOption)&&(e+=1),this.multiSelect&&this.selectAll&&(e+=1),e}getOptionByActiveIndex(){if(!this.open)return null;const e=this.activeIndex;if(e<0)return null;if((this.searchable||this.addOption)&&0===e)return{kind:"search"};const t=this.searchable||this.addOption?1:0;if(this.multiSelect&&this.selectAll&&e===t)return{kind:"select-all"};const i=e-this.headerRows;return i>=0&&i<this.filteredOptions.length?{kind:"option",optionIndex:i}:null}commitDropdownEnter(){const e=this.getOptionByActiveIndex();if(e)if("search"!==e.kind)if("select-all"!==e.kind){if("option"===e.kind&&"number"==typeof e.optionIndex){const t=this.filteredOptions[e.optionIndex].original;this.selectOption(t)}}else this.toggleSelectAll();else this.addOption&&this.canAddaddOption()?(this.dispatchEvent(new CustomEvent("add-new-option",{detail:{value:this.searchQuery.trim()},bubbles:!0,composed:!0})),this.searchQuery="",this.emitSearchQueryChanged(),this.filterOptions()):this.filteredOptions.length>0&&this.selectOption(this.filteredOptions[0].original)}focusOnOpen(){const e=this.searchInputEl;if(e&&document.activeElement!==e&&requestAnimationFrame(()=>e.focus()),this.filteredOptions.length>0){let e=0;if(this.selectedItems.length>0){const t=this.optionKey(this.selectedItems[0]),i=this.filteredOptions.findIndex(e=>this.optionKey(e.original)===t);i>=0&&(e=i)}return this.activeIndex=this.headerRows+e,void this.scrollActiveItemIntoView()}this.activeIndex=this.searchable||this.addOption?0:-1}canAddaddOption(){if(!this.addOption)return!1;const e=this.searchQuery.trim();if(!e)return!1;return!(Array.isArray(this.options)?this.options:[]).some(t=>{const i=String(this.getOptionLabel(t)||"").toLowerCase(),s=(this.getOptionValue(t)??"").toString().toLowerCase();return i===e.toLowerCase()||s===e.toLowerCase()})}scrollActiveItemIntoView(){const e=Array.from(this.rowEls).find(e=>Number(e.dataset.rowIndex)===this.activeIndex);e?.scrollIntoView({block:"nearest",behavior:"smooth"})}toggleDropdown(e){e.stopPropagation(),this.disabled||this.readonly||(this.hiddenChipsOpen&&this.hiddenPopover.closePopover("api"),this.validationActive=!0,this.dropdownPopover.toggle())}renderDropdown(){return s`
95
95
  <div
96
96
  class="dropdown"
97
97
  part="dropdown"
@@ -158,7 +158,7 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
158
158
  Select All
159
159
  </div>
160
160
  `})}
161
- ${c(this.filteredOptions.length>0,()=>u(this.filteredOptions,({original:e,_idx:t})=>`${t}-${this.optionKey(e)}`,({original:e,highlighted:t,_idx:i},o)=>{const r=`option-${i}`,n=this.optionSlotSet.has(r),a=Array.isArray(this.selectedItems)&&this.selectedItems.some(t=>this.optionKey(t)===this.optionKey(e)),l=this.headerRows+o,h=l===this.activeIndex,d=y({"dropdown-item":!0,active:h,selected:a});return s`
161
+ ${c(this.filteredOptions.length>0,()=>u(this.filteredOptions,({original:e,_idx:t})=>`${t}-${this.optionKey(e)}`,({original:e,highlighted:t,_idx:i},r)=>{const o=`option-${i}`,n=this.optionSlotSet.has(o),a=Array.isArray(this.selectedItems)&&this.selectedItems.some(t=>this.optionKey(t)===this.optionKey(e)),l=this.headerRows+r,h=l===this.activeIndex,d=y({"dropdown-item":!0,active:h,selected:a});return s`
162
162
  <div
163
163
  class=${d}
164
164
  data-row-index=${l}
@@ -172,7 +172,7 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
172
172
  .checked=${a}
173
173
  readonly
174
174
  ></sky-checkbox>`)}
175
- ${this.renderOptionContent({option:e,index:o,sourceIndex:i,highlighted:t,selected:a,active:h,hasSlot:n,slotName:r})}
175
+ ${this.renderOptionContent({option:e,index:r,sourceIndex:i,highlighted:t,selected:a,active:h,hasSlot:n,slotName:o})}
176
176
  </div>
177
177
  `}),()=>s`<div
178
178
  class="dropdown-item"
@@ -189,7 +189,7 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
189
189
  ${u(e,e=>e,e=>s`<li class="error" part="error-item">${e}</li>`)}
190
190
  </ul>
191
191
  </div>
192
- `}getErrorMessages(){const e=Array.isArray(this.validationErrors)?this.validationErrors:[];switch(this.errorDisplayMode){case"single":return e.slice(0,1);case"all":return e;default:return[]}}handleIconClick(e,t){this.dispatchEvent(new CustomEvent("icon-click",{detail:{position:e,event:t},bubbles:!0,composed:!0}))}render(){const e=y({"icon-slot":!0,left:!0,focused:this.focused}),t=y({"icon-slot":!0,right:!0,focused:this.focused}),i=y({"placeholder-label":!0,active:this.selectedItems.length>0}),r="fieldset"===this.variant,n="inside"===this.variant,a=this.label?r?s`<legend class="label" part="label"><span class="legend-text">${this.label}</span></legend>`:s`<div class="label" part="label">${this.label}</div>`:null,l=s`
192
+ `}getErrorMessages(){const e=Array.isArray(this.validationErrors)?this.validationErrors:[];switch(this.errorDisplayMode){case"single":return e.slice(0,1);case"all":return e;default:return[]}}handleIconClick(e,t){this.dispatchEvent(new CustomEvent("icon-click",{detail:{position:e,event:t},bubbles:!0,composed:!0}))}render(){const e=y({"icon-slot":!0,left:!0,focused:this.focused}),t=y({"icon-slot":!0,right:!0,focused:this.focused}),i=y({"placeholder-label":!0,active:this.selectedItems.length>0}),o="fieldset"===this.variant,n="inside"===this.variant,a=this.label?o?s`<legend class="label" part="label"><span class="legend-text">${this.label}</span></legend>`:s`<div class="label" part="label">${this.label}</div>`:null,l=s`
193
193
  <div
194
194
  class=${e}
195
195
  part="icon-slot"
@@ -244,7 +244,7 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
244
244
  `,p=s`
245
245
  ${l}
246
246
  <div class="field-main" part="field-main">${h}</div>
247
- ${this.readonly?o:d}
247
+ ${this.readonly?r:d}
248
248
  `,u=s`
249
249
  ${l}
250
250
  <div class="input-inside-main">
@@ -253,8 +253,8 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
253
253
  <div class="field-main" part="field-main">${h}</div>
254
254
  </div>
255
255
  </div>
256
- ${this.readonly?o:d}
257
- `,v=n?u:p,m=e=>{this.disabled||this.readonly||this.toggleDropdown(e)},g=this.handleKeydown,f=r?s`
256
+ ${this.readonly?r:d}
257
+ `,v=n?u:p,m=e=>{this.disabled||this.readonly||this.toggleDropdown(e)},g=this.handleKeydown,f=o?s`
258
258
  <fieldset
259
259
  class="input-wrapper"
260
260
  tabindex="0"
@@ -287,13 +287,13 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
287
287
  </div>
288
288
  `;return s`
289
289
  <div class="combo-box-container" part="combo-box-container">
290
- ${r||n?o:a}
290
+ ${o||n?r:a}
291
291
  ${f}
292
292
  ${this.renderHiddenChipsDropdown()} ${this.renderDropdown()}
293
293
  ${this.renderValidationErrors()}
294
294
  <slot style="display:none" @slotchange=${this.refreshOptionSlots}></slot>
295
295
  </div>
296
- `}};E.dependencies={"sky-icon":b,"sky-checkbox":k,"sky-input":w},E._SEARCH_DEBOUNCE_MS=150,E._SEARCH_DEBOUNCE_OPTIONS_THRESHOLD=30,E._CLOSE_RESET_MS=250,E.styles=t`
296
+ `}};F.dependencies={"sky-icon":b,"sky-checkbox":k,"sky-input":w},F._SEARCH_DEBOUNCE_MS=150,F._SEARCH_DEBOUNCE_OPTIONS_THRESHOLD=30,F._CLOSE_RESET_MS=250,F.styles=t`
297
297
  :host {
298
298
  display: block;
299
299
  font-family: var(--sky-font);
@@ -1423,5 +1423,5 @@ import{unsafeCSS as e,css as t,LitElement as i,html as s,nothing as o}from"lit";
1423
1423
  }
1424
1424
 
1425
1425
  ${e(m([{selector:".placeholder-label.active[compact]",fillVar:"--sky-dropdown-color"},{selector:".sky-checkbox:checked::after",fillVar:"--sky-active-primary",property:"border-color"},{selector:".sky-checkbox.indeterminate::after",fillVar:"--sky-active-primary",property:"background-color"}]))}
1426
- `,E.shadowRootOptions={...i.shadowRootOptions,delegatesFocus:!0},O([r()],E.prototype,"value",2),O([r({type:String})],E.prototype,"placeholder",2),O([r({type:String})],E.prototype,"searchPlaceholder",2),O([r({type:String})],E.prototype,"label",2),O([r({type:Array})],E.prototype,"options",1),O([r({type:Number})],E.prototype,"chipSize",2),O([r({type:String})],E.prototype,"color",2),O([r({type:Boolean,reflect:!0})],E.prototype,"clearable",2),O([r({type:Boolean,reflect:!0})],E.prototype,"loading",2),O([r({type:Boolean,reflect:!0})],E.prototype,"compact",2),O([r({type:Boolean,reflect:!0})],E.prototype,"disabled",2),O([r({type:Boolean,reflect:!0})],E.prototype,"searchable",2),O([r({type:Boolean,reflect:!0})],E.prototype,"multiSelect",2),O([r({type:Number,reflect:!0})],E.prototype,"visibleChips",2),O([r({type:Boolean,reflect:!0})],E.prototype,"selectAll",2),O([r({type:Array})],E.prototype,"validations",1),O([r({type:Boolean})],E.prototype,"showErrors",2),O([r({type:String})],E.prototype,"errorDisplayMode",2),O([r({type:Boolean,reflect:!0})],E.prototype,"required",2),O([r({type:Boolean,reflect:!0})],E.prototype,"emitFullObject",2),O([r({type:String})],E.prototype,"emittedKey",2),O([r({type:String})],E.prototype,"displayKey",2),O([r({type:Object})],E.prototype,"customRenderers",1),O([r({type:Boolean})],E.prototype,"addOption",2),O([r({type:Boolean})],E.prototype,"validationArrayFormat",2),O([r({type:String})],E.prototype,"prefix",2),O([r({type:String})],E.prototype,"suffix",2),O([r({type:String})],E.prototype,"prefixColor",2),O([r({type:String})],E.prototype,"suffixColor",2),O([r({type:String})],E.prototype,"justify",2),O([r({type:Number})],E.prototype,"zIndex",2),O([r({type:String})],E.prototype,"height",2),O([r({type:String})],E.prototype,"requiredMessage",2),O([r({type:Boolean,reflect:!0})],E.prototype,"readonly",2),O([r({type:Boolean})],E.prototype,"enforceMinOneSelection",2),O([r({type:Boolean})],E.prototype,"openAbove",2),O([r({type:Boolean,reflect:!0})],E.prototype,"validationActive",2),O([r({type:Boolean,reflect:!0})],E.prototype,"invalid",2),O([r({type:String,reflect:!0})],E.prototype,"variant",2),O([r({type:String,reflect:!0,attribute:"multi-display"})],E.prototype,"multiDisplay",2),O([r({type:String,attribute:!1})],E.prototype,"searchQuery",2),O([n()],E.prototype,"filteredOptions",2),O([n()],E.prototype,"focused",2),O([n()],E.prototype,"open",2),O([n()],E.prototype,"selectedItems",2),O([n()],E.prototype,"hiddenChipsOpen",2),O([n()],E.prototype,"activeIndex",2),O([n()],E.prototype,"validationErrors",2),O([n()],E.prototype,"validationStatus",2),O([n()],E.prototype,"hasLeftIcon",2),O([n()],E.prototype,"hasRightIcon",2),O([n()],E.prototype,"optionSlotSet",2),O([a(".input-wrapper")],E.prototype,"inputWrapperEl",2),O([a(".dropdown")],E.prototype,"dropdownEl",2),O([a(".hidden-chips-dropdown")],E.prototype,"hiddenDropdownEl",2),O([a(".search-container sky-input")],E.prototype,"searchInputEl",2),O([a(".overflow-chip")],E.prototype,"overflowChipEl",2),O([a(".combo-box-container")],E.prototype,"comboContainerEl",2),O([l("[data-row-index]")],E.prototype,"rowEls",2),O([h({slot:"icon-left"})],E.prototype,"iconLeftEls",2),O([h({slot:"icon-right"})],E.prototype,"iconRightEls",2),O([r({type:String,reflect:!0})],E.prototype,"preset",2),E=O([d("sky-combobox")],E);export{A as COMBOBOX_RENDERERS_STATE_KEY,E as SkyCombobox};
1426
+ `,F.shadowRootOptions={...i.shadowRootOptions,delegatesFocus:!0},C([o()],F.prototype,"value",2),C([o({type:String})],F.prototype,"placeholder",2),C([o({type:String})],F.prototype,"searchPlaceholder",2),C([o({type:String})],F.prototype,"label",2),C([o({type:Array,hasChanged:S})],F.prototype,"options",1),C([o({type:Number})],F.prototype,"chipSize",2),C([o({type:String})],F.prototype,"color",2),C([o({type:Boolean,reflect:!0})],F.prototype,"clearable",2),C([o({type:Boolean,reflect:!0})],F.prototype,"loading",2),C([o({type:Boolean,reflect:!0})],F.prototype,"compact",2),C([o({type:Boolean,reflect:!0})],F.prototype,"disabled",2),C([o({type:Boolean,reflect:!0})],F.prototype,"searchable",2),C([o({type:Boolean,reflect:!0})],F.prototype,"multiSelect",2),C([o({type:Number,reflect:!0})],F.prototype,"visibleChips",2),C([o({type:Boolean,reflect:!0})],F.prototype,"selectAll",2),C([o({type:Array,hasChanged:S})],F.prototype,"validations",1),C([o({type:Boolean})],F.prototype,"showErrors",2),C([o({type:String})],F.prototype,"errorDisplayMode",2),C([o({type:Boolean,reflect:!0})],F.prototype,"required",2),C([o({type:Boolean,reflect:!0})],F.prototype,"emitFullObject",2),C([o({type:String})],F.prototype,"emittedKey",2),C([o({type:String})],F.prototype,"displayKey",2),C([o({type:Object})],F.prototype,"customRenderers",1),C([o({type:Boolean})],F.prototype,"addOption",2),C([o({type:Boolean})],F.prototype,"validationArrayFormat",2),C([o({type:String})],F.prototype,"prefix",2),C([o({type:String})],F.prototype,"suffix",2),C([o({type:String})],F.prototype,"prefixColor",2),C([o({type:String})],F.prototype,"suffixColor",2),C([o({type:String})],F.prototype,"justify",2),C([o({type:Number})],F.prototype,"zIndex",2),C([o({type:String})],F.prototype,"height",2),C([o({type:String})],F.prototype,"requiredMessage",2),C([o({type:Boolean,reflect:!0})],F.prototype,"readonly",2),C([o({type:Boolean})],F.prototype,"enforceMinOneSelection",2),C([o({type:Boolean})],F.prototype,"openAbove",2),C([o({type:Boolean,reflect:!0})],F.prototype,"validationActive",2),C([o({type:Boolean,reflect:!0})],F.prototype,"invalid",2),C([o({type:String,reflect:!0})],F.prototype,"variant",2),C([o({type:String,reflect:!0,attribute:"multi-display"})],F.prototype,"multiDisplay",2),C([o({type:String,attribute:!1})],F.prototype,"searchQuery",2),C([n()],F.prototype,"filteredOptions",2),C([n()],F.prototype,"focused",2),C([n()],F.prototype,"open",2),C([n()],F.prototype,"selectedItems",2),C([n()],F.prototype,"hiddenChipsOpen",2),C([n()],F.prototype,"activeIndex",2),C([n()],F.prototype,"validationErrors",2),C([n()],F.prototype,"validationStatus",2),C([n()],F.prototype,"hasLeftIcon",2),C([n()],F.prototype,"hasRightIcon",2),C([n()],F.prototype,"optionSlotSet",2),C([a(".input-wrapper")],F.prototype,"inputWrapperEl",2),C([a(".dropdown")],F.prototype,"dropdownEl",2),C([a(".hidden-chips-dropdown")],F.prototype,"hiddenDropdownEl",2),C([a(".search-container sky-input")],F.prototype,"searchInputEl",2),C([a(".overflow-chip")],F.prototype,"overflowChipEl",2),C([a(".combo-box-container")],F.prototype,"comboContainerEl",2),C([l("[data-row-index]")],F.prototype,"rowEls",2),C([h({slot:"icon-left"})],F.prototype,"iconLeftEls",2),C([h({slot:"icon-right"})],F.prototype,"iconRightEls",2),C([o({type:String,reflect:!0})],F.prototype,"preset",2),F=C([d("sky-combobox")],F);export{E as COMBOBOX_RENDERERS_STATE_KEY,F as SkyCombobox};
1427
1427
  //# sourceMappingURL=sky-combobox.js.map