@solid-design-system/components 3.22.18 → 3.23.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/es/combobox.js +11 -0
- package/dist/components/es/map-marker.js +1 -1
- package/dist/components/es/optgroup.js +1 -0
- package/dist/components/es/option-renderer.js +1 -0
- package/dist/components/es/select.js +7 -3
- package/dist/components/es/solid-components2.js +7 -7
- package/dist/components/es/utils.js +1 -0
- package/dist/components/umd/solid-components.js +37 -23
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/combobox/combobox.d.ts +129 -0
- package/dist/package/components/combobox/combobox.js +958 -0
- package/dist/package/components/combobox/option-renderer.d.ts +5 -0
- package/dist/package/components/combobox/option-renderer.js +4 -0
- package/dist/package/components/combobox/utils.d.ts +8 -0
- package/dist/package/components/combobox/utils.js +14 -0
- package/dist/package/components/optgroup/optgroup.d.ts +20 -0
- package/dist/package/components/optgroup/optgroup.js +68 -0
- package/dist/package/components/select/select.d.ts +5 -1
- package/dist/package/components/select/select.js +94 -29
- package/dist/package/solid-components.d.ts +2 -0
- package/dist/package/solid-components.js +74 -70
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/package/translations/de.js +7 -4
- package/dist/package/translations/en.js +7 -4
- package/dist/package/utilities/localize.d.ts +3 -0
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/audio.js +1 -1
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -1
- package/dist/versioned-components/es/carousel.js +3 -3
- package/dist/versioned-components/es/checkbox-group.js +1 -1
- package/dist/versioned-components/es/checkbox.js +1 -1
- package/dist/versioned-components/es/combobox.js +11 -0
- package/dist/versioned-components/es/dialog.js +1 -1
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/expandable.js +1 -1
- package/dist/versioned-components/es/flipcard.js +1 -1
- package/dist/versioned-components/es/form.js +1 -1
- package/dist/versioned-components/es/header.js +1 -1
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/input.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/map-marker.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/notification.js +1 -1
- package/dist/versioned-components/es/optgroup.js +1 -0
- package/dist/versioned-components/es/option-renderer.js +1 -0
- package/dist/versioned-components/es/option.js +1 -1
- package/dist/versioned-components/es/quickfact.js +1 -1
- package/dist/versioned-components/es/radio-button.js +1 -1
- package/dist/versioned-components/es/radio-group.js +1 -1
- package/dist/versioned-components/es/radio.js +1 -1
- package/dist/versioned-components/es/scrollable.js +1 -1
- package/dist/versioned-components/es/select.js +7 -3
- package/dist/versioned-components/es/solid-components2.js +7 -7
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/step-group.js +1 -1
- package/dist/versioned-components/es/step.js +1 -1
- package/dist/versioned-components/es/switch.js +1 -1
- package/dist/versioned-components/es/tab-group.js +1 -1
- package/dist/versioned-components/es/tab-panel.js +1 -1
- package/dist/versioned-components/es/tab.js +1 -1
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser-media.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/textarea.js +1 -1
- package/dist/versioned-components/es/tooltip.js +2 -2
- package/dist/versioned-components/es/utils.js +1 -0
- package/dist/versioned-components/es/video.js +1 -1
- package/dist/versioned-package/_components/button-group/button-group.d.ts +1 -1
- package/dist/versioned-package/_components/button-group/button-group.js +11 -11
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/audio/audio.d.ts +1 -1
- package/dist/versioned-package/components/audio/audio.js +6 -6
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +1 -1
- package/dist/versioned-package/components/button/button.js +4 -4
- package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
- package/dist/versioned-package/components/carousel/carousel.js +6 -6
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
- package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.d.ts +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.js +3 -3
- package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +1 -1
- package/dist/versioned-package/components/checkbox-group/checkbox-group.js +5 -5
- package/dist/versioned-package/components/combobox/combobox.d.ts +129 -0
- package/dist/versioned-package/components/combobox/combobox.js +958 -0
- package/dist/versioned-package/components/combobox/option-renderer.d.ts +5 -0
- package/dist/versioned-package/components/combobox/option-renderer.js +4 -0
- package/dist/versioned-package/components/combobox/utils.d.ts +8 -0
- package/dist/versioned-package/components/combobox/utils.js +14 -0
- package/dist/versioned-package/components/dialog/dialog.d.ts +1 -1
- package/dist/versioned-package/components/dialog/dialog.js +2 -2
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +8 -8
- package/dist/versioned-package/components/expandable/expandable.d.ts +1 -1
- package/dist/versioned-package/components/expandable/expandable.js +2 -2
- package/dist/versioned-package/components/flipcard/flipcard.d.ts +1 -1
- package/dist/versioned-package/components/flipcard/flipcard.js +1 -1
- package/dist/versioned-package/components/header/header.d.ts +1 -1
- package/dist/versioned-package/components/header/header.js +4 -4
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/input/input.d.ts +1 -1
- package/dist/versioned-package/components/input/input.js +3 -3
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/map-marker/map-marker.d.ts +1 -1
- package/dist/versioned-package/components/map-marker/map-marker.js +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +5 -5
- package/dist/versioned-package/components/notification/notification.d.ts +1 -1
- package/dist/versioned-package/components/notification/notification.js +5 -5
- package/dist/versioned-package/components/optgroup/optgroup.d.ts +20 -0
- package/dist/versioned-package/components/optgroup/optgroup.js +68 -0
- package/dist/versioned-package/components/option/option.d.ts +1 -1
- package/dist/versioned-package/components/option/option.js +2 -2
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/quickfact/quickfact.d.ts +1 -1
- package/dist/versioned-package/components/quickfact/quickfact.js +2 -2
- package/dist/versioned-package/components/radio/radio.d.ts +1 -1
- package/dist/versioned-package/components/radio/radio.js +2 -2
- package/dist/versioned-package/components/radio-button/radio-button.d.ts +1 -1
- package/dist/versioned-package/components/radio-button/radio-button.js +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.js +13 -13
- package/dist/versioned-package/components/scrollable/scrollable.d.ts +1 -1
- package/dist/versioned-package/components/scrollable/scrollable.js +3 -3
- package/dist/versioned-package/components/select/select.d.ts +9 -5
- package/dist/versioned-package/components/select/select.js +115 -50
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/step/step.d.ts +1 -1
- package/dist/versioned-package/components/step/step.js +2 -2
- package/dist/versioned-package/components/step-group/step-group.d.ts +1 -1
- package/dist/versioned-package/components/step-group/step-group.js +2 -2
- package/dist/versioned-package/components/switch/switch.d.ts +1 -1
- package/dist/versioned-package/components/switch/switch.js +1 -1
- package/dist/versioned-package/components/tab/tab.d.ts +1 -1
- package/dist/versioned-package/components/tab/tab.js +2 -2
- package/dist/versioned-package/components/tab-group/tab-group.d.ts +1 -1
- package/dist/versioned-package/components/tab-group/tab-group.js +13 -13
- package/dist/versioned-package/components/tab-panel/tab-panel.d.ts +1 -1
- package/dist/versioned-package/components/tab-panel/tab-panel.js +2 -2
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/components/teaser-media/teaser-media.js +1 -1
- package/dist/versioned-package/components/textarea/textarea.d.ts +1 -1
- package/dist/versioned-package/components/textarea/textarea.js +2 -2
- package/dist/versioned-package/components/tooltip/tooltip.d.ts +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.js +5 -5
- package/dist/versioned-package/components/video/video.d.ts +1 -1
- package/dist/versioned-package/components/video/video.js +2 -2
- package/dist/versioned-package/internal/form.js +3 -3
- package/dist/versioned-package/solid-components.d.ts +2 -0
- package/dist/versioned-package/solid-components.js +74 -70
- package/dist/versioned-package/styles/headline/headline.css.js +1 -1
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-package/translations/de.js +7 -4
- package/dist/versioned-package/translations/en.js +7 -4
- package/dist/versioned-package/utilities/autocomplete-config.js +4 -4
- package/dist/versioned-package/utilities/localize.d.ts +3 -0
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +371 -45
- package/dist/web-types.json +5471 -3959
- package/package.json +3 -3
@@ -0,0 +1,11 @@
|
|
1
|
+
import{s as t,a as e}from"./animate.js";import{S as s,L as i,x as o,t as l,d as a,c as n,i as r,e as d,n as p,a as h}from"./solid-components2.js";import{defaultOptionRenderer as u}from"./option-renderer.js";import{d as c}from"./default-value.js";import{normalizeString as m,getAllOptions as b,getAssignedElementsForSlot as v,filterOnlyOptgroups as y}from"./utils.js";import{F as g}from"./form.js";import{g as f,s as O}from"./animation-registry.js";import{H as x}from"./slot.js";import{r as C}from"./state.js";import{s as w}from"./scroll.js";import{o as S,S as $}from"./icon.js";import{w as I}from"./event.js";import{w as V}from"./watch.js";import T from"./tag.js";var k=Object.defineProperty,L=Object.getOwnPropertyDescriptor,F=(t,e,s,i)=>{for(var o,l=i>1?void 0:i?L(e,s):e,a=t.length-1;a>=0;a--)(o=t[a])&&(l=(i?o(e,s,l):o(l))||l);return i&&l&&k(e,s,l),l};let D=class extends s{constructor(){super(...arguments),this.formControlController=new g(this,{assumeInteractionOn:["sd-blur","sd-input"]}),this.hasSlotController=new x(this,"help-text","label"),this.localize=new i(this),this.hasHover=!1,this.hasFocus=!1,this.displayInputValue="",this.selectedTextLabel="",this.selectedOptions=[],this.filteredOptions=[],this.allOptions=[],this.showValidStyle=!1,this.showInvalidStyle=!1,this.name="",this.value="",this.defaultValue="",this.size="lg",this.placeholder=this.localize.term("comboboxDefaultPlaceholder"),this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.label="",this.placement="bottom",this.helpText="",this.form="",this.required=!1,this.currentPlacement=this.placement,this.getOption=u,this.multiple=!1,this.useTags=!0,this.maxOptionsVisible=3,this.styleOnValid=!1,this.filter=(t,e)=>{const s=m(t.value),i=m(t.getTextLabel()),o=m(e);return s.includes(o)||i.includes(o)},this.getTag=t=>o`<sd-tag ?disabled="${this.disabled}" part="tag" exportparts="
|
2
|
+
base:tag__base,
|
3
|
+
content:tag__content,
|
4
|
+
removable-indicator:tag__removable-indicator,
|
5
|
+
" size="${"sm"===this.size?"sm":"lg"}" removable @keydown="${e=>this.handleTagKeyDown(e,t)}" @sd-remove="${e=>this.handleTagRemove(e,t)}">${t.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()},this.handleDocumentKeyDown=t=>{if(null===t.target.closest(".combobox__clear")){if("Escape"===t.key&&(this.open?(t.preventDefault(),t.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})):this.displayInputValue=""),"Backspace"===t.key&&this.multiple&&""===this.displayInput.value)return this.handleTagRemove(new CustomEvent("sd-remove"),this.selectedOptions[this.selectedOptions.length-1]),void this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0})));if("Enter"===t.key){const e=this.getCurrentOption(),s=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey;if(!this.open&&!s)return void setTimeout((()=>{t.defaultPrevented||this.formControlController.submit()}));if(!this.open||null!=e&&e.disabled)return;if(e&&!e.disabled){const t=this.value;this.multiple?(this.toggleOptionSelection(e),this.lastOption=e,this.setOrderedSelectedOptions(e),this.updateComplete.then((()=>{this.selectionChanged()}))):(this.setOrderedSelectedOptions(e),this.setSelectedOptions(e)),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==t&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")}))}return this.displayInput.focus({preventScroll:!0}),void(this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}["ArrowUp","ArrowDown"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),this.open||this.show(),this.selectNextOption("ArrowDown"===t.key)),["Home","End"].includes(t.key)&&(t.preventDefault(),t.stopPropagation(),"Home"===t.key?this.displayInput.setSelectionRange(0,0):"End"===t.key&&this.displayInput.setSelectionRange(this.displayInput.value.length,this.displayInput.value.length))}},this.handleDocumentMouseDown=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()}}connectedCallback(){super.connectedCallback(),this.open=!1}firstUpdated(){if(!this.multiple){const t=this.findOptionByValue(this.getSlottedOptions(),this.value);this.selectedTextLabel=(null==t?void 0:t.getTextLabel())||""}this.formControlController.updateValidity(),this.applySizeToOptions()}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}get options(){const t=t=>{const e=this.displayInput.value,s=this.getOption(t,e);return o`${"string"==typeof s?S(s):s}`};return this.filteredOptions.map((e=>"sd-optgroup"===e.tagName.toLowerCase()?(Array.from(e.children).forEach((e=>{"sd-option"===e.tagName.toLowerCase()&&t(e)})),e):t(e)))}get tags(){return this.selectedOptions.length<=this.maxOptionsVisible?this.selectedOptions.map(((t,e)=>{if(e<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(t,e);return o`<div @sd-remove="${e=>this.handleTagRemove(e,t)}">${"string"==typeof s?S(s):s}</div>`}return[o``]})):[o`<sd-tag ?disabled="${this.disabled}" part="tag" exportparts="
|
6
|
+
base:tag__base,
|
7
|
+
content:tag__content,
|
8
|
+
removable-indicator:tag__removable-indicator,
|
9
|
+
" size="${"sm"===this.size?"sm":"lg"}" removable @keydown="${t=>this.handleTagMaxOptionsKeyDown(t)}" @sd-remove="${t=>this.handleTagRemove(t)}">${this.selectedOptions.length} ${this.localize.term("tagsSelected")}</sd-tag>`]}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("mousedown",this.handleDocumentMouseDown),this.getRootNode()!==document&&this.getRootNode().addEventListener("focusin",this.handleDocumentFocusIn)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("mousedown",this.handleDocumentMouseDown),this.getRootNode()!==document&&this.getRootNode().removeEventListener("focusin",this.handleDocumentFocusIn)}handleFocus(){this.hasFocus=!0,this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleTagKeyDown(t,e){"Backspace"===t.key&&this.multiple&&(t.stopPropagation(),this.handleTagRemove(new CustomEvent("sd-remove"),e),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))))}handleTagMaxOptionsKeyDown(t){"Backspace"===t.key&&this.multiple&&(t.stopPropagation(),this.handleTagRemove(new CustomEvent("sd-remove"),this.selectedOptions[this.selectedOptions.length-1]),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))))}handleLabelClick(){this.displayInput.focus()}handleTagRemove(t,e){t.stopPropagation(),e||this.clearCombobox(),e&&!this.disabled&&(this.toggleOptionSelection(e,!1),this.setOrderedSelectedOptions(e),this.updateComplete.then((()=>{this.selectionChanged(),this.emit("sd-input"),this.emit("sd-change")})))}handleComboboxMouseDown(t){const e=t.composedPath().some((t=>t instanceof HTMLSlotElement&&"removable-indicator"===t.name));this.disabled||e||(this.open?this.hide():this.show()).then((()=>{setTimeout((()=>this.displayInput.focus({preventScroll:!0})))}))}handleComboboxKeyDown(t){"Tab"!==t.key&&this.handleDocumentKeyDown(t)}handleClearClick(t){t.stopPropagation(),this.clearCombobox()}handleNoResultsClick(t){t.preventDefault(),this.hide()}clearCombobox(){""!==this.value&&(this.value="",this.displayInputValue="",this.selectedTextLabel="",this.lastOption=void 0,this.selectedOptions=[],this.getSlottedOptions().forEach((t=>{t.selected=!1})),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")})))}preventLoosingFocus(t){t.stopPropagation(),t.preventDefault()}handleOptionClick(t){const e=t.target.closest("sd-option"),s=this.value;e&&!e.disabled&&(this.multiple?(this.toggleOptionSelection(e),this.lastOption=e,this.setOrderedSelectedOptions(e),this.updateComplete.then((()=>{this.selectionChanged()}))):(this.setOrderedSelectedOptions(e),this.setSelectedOptions(e)),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}selectNextOption(t){const e=this.getAllFilteredOptions();if(0===e.length)return;const s=this.getCurrentOption(),i=e.indexOf(s);let o=Math.max(0,i);if(t){const t=i+1;o=t>e.length-1?0:t}else{const t=i-1;o=t<0?e.length-1:t}this.setCurrentOption(e[o]),w(this.getCurrentOption(),this.listbox,"vertical","auto")}getAllFilteredOptions(){return[...this.filteredWrapper.querySelectorAll("sd-option")]}getCurrentOption(){return this.getAllFilteredOptions().find((t=>t.current))}setCurrentOption(t){const e=this.getAllFilteredOptions();this.displayInput.removeAttribute("aria-activedescendant"),e.forEach((t=>{t.current=!1,t.setAttribute("aria-selected","false")})),t&&(t.current=!0,t.setAttribute("aria-selected","true"),this.displayInput.setAttribute("aria-activedescendant",t.id))}toggleOptionSelection(t,e){const s=this.getSlottedOptions().find((e=>e.value&&t.value?e.value===t.value:e.getTextLabel()===t.getTextLabel()));s&&(s.selected=e??!s.selected)}findOptionByValue(t,e){if(e)return Array.isArray(e)?t.find((t=>e.includes(t.value))):t.find((t=>t.value===e))}selectedOptionsAndValueSynced(){var t;return!this.value&&0===this.selectedOptions.length||(Array.isArray(this.value)?this.value.length===this.selectedOptions.length:this.value===(null==(t=this.selectedOptions[0])?void 0:t.value))}isOptionSelected(t){return t.value?this.value.includes(t.value):this.value.includes(t.getTextLabel())}syncSelectedOptionsAndValue(){return this.selectedOptionsAndValueSynced()?void 0:(this.getSlottedOptions().forEach((t=>{t.selected=!1})),this.selectedOptions=this.getSlottedOptions().filter((t=>this.isOptionSelected(t))),this.selectedOptions.forEach((t=>{t&&(t.selected=!0)})),Promise.resolve())}compareOptions(t,e){return t.value&&e.value?t.value===e.value:t.getTextLabel()===e.getTextLabel()}setSelectedOptions(t){this.getSlottedOptions().forEach((e=>{e.selected=this.compareOptions(e,t)})),this.selectionChanged()}setOrderedSelectedOptions(t){const e=this.getSlottedOptions().find((e=>this.compareOptions(e,t)));this.multiple?this.selectedOptions.length>0&&e&&this.selectedOptions.find((t=>this.compareOptions(t,e)))?this.selectedOptions=this.selectedOptions.filter((t=>!this.compareOptions(t,e))):this.selectedOptions=[...this.selectedOptions,e]:this.selectedOptions=[e]}selectionChanged(){var t,e,s;const i=this.selectedOptions.some((t=>!!t&&this.isOptionSelected(t)));this.multiple?(!i&&this.selectedOptions.length>0?this.value=[...this.value,...this.selectedOptions.map((t=>t.value||t.getTextLabel()))]:this.value=this.selectedOptions.map((t=>(null==t?void 0:t.value)||(null==t?void 0:t.getTextLabel())||"")),this.displayInputValue=""):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)||(null==(e=this.selectedOptions[0])?void 0:e.getTextLabel())||"",this.selectedTextLabel=(null==(s=this.selectedOptions[0])?void 0:s.getTextLabel())||"",this.displayInputValue=""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}createComboboxOptionsFromQuery(t){const e=[];this.filteredOptions=this.getSlottedOptions().filter((e=>this.filter(e,t)||""===t)).map((t=>{var s,i,o;const l=t.cloneNode(!0);if(l.current=l.value===(null==(s=this.lastOption)?void 0:s.value),l.selected=t.selected,"sd-optgroup"!==(null==(i=t.parentElement)?void 0:i.tagName.toLowerCase()))return l;const a=t.parentElement,n=null==(o=a.querySelector('[slot="label"]'))?void 0:o.cloneNode(!0),r=e.find((t=>t.id===a.id));if(r)return null==r||r.appendChild(l),void(n&&(null==r||r.appendChild(n)));const d=a.cloneNode();return d.appendChild(l),n&&d.appendChild(n),e.push(d),d})).filter(Boolean)}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(t){const e=t.detail;e&&(this.currentPlacement=e)}handleFilterChange(){this.createComboboxOptionsFromQuery(this.displayInputValue)}handleUseTagsChange(){const t=this.getAllFilteredOptions();customElements.get("sd-option")&&t.forEach((t=>{t.checkbox=this.multiple}))}applySizeToOptions(){this.getSlottedOptions().forEach((t=>{t.size=this.size}))}handleDisabledChange(){this.formControlController.setValidity(this.disabled),this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.syncSelectedOptionsAndValue(),this.multiple?this.createComboboxOptionsFromQuery(this.displayInput.value):this.createComboboxOptionsFromQuery("")}handleDisplayInputValueChange(){this.createComboboxOptionsFromQuery(this.displayInputValue)}async handleOpenChange(){if(this.open&&!this.disabled){this.emit("sd-show"),this.addOpenListeners(),await t(this),this.listbox.hidden=!1,this.popup.active=!0;const{keyframes:s,options:i}=f(this,"combobox.show",{dir:this.localize.dir()});return await e(this.popup.popup,s,i),this.emit("sd-after-show"),void(0===this.filteredOptions.length&&this.emit("sd-error"))}this.setCurrentOption(null),this.displayInput.removeAttribute("aria-activedescendant"),this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:s,options:i}=f(this,"combobox.hide",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}async show(){if(!this.open&&!this.disabled)return this.open=!0,Promise.race([I(this,"sd-after-show"),I(this,"sd-error")]);this.open=!1}async hide(){if(this.open&&!this.disabled)return this.displayInputValue="",this.open=!1,I(this,"sd-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(t){this.valueInput.setCustomValidity(t),this.formControlController.updateValidity()}focus(t){this.displayInput.focus(t)}blur(){this.displayInput.blur()}async handleInput(){const t=this.displayInput.value;this.displayInputValue=t,await this.updateComplete,this.open=this.filteredWrapper.children.length>0,this.formControlController.updateValidity(),this.emit("sd-input")}handleChange(){(!this.selectedOptions||!this.multiple)&&(this.selectedTextLabel=this.displayInput.value,this.updateComplete.then((()=>{this.formControlController.updateValidity()})),this.emit("sd-change"))}getSlottedOptions(){return b(v(this.defaultSlot)).flat()}getSlottedOptGroups(){return y(v(this.defaultSlot))}async handleDefaultSlotChange(){if(!customElements.get("sd-option"))return void customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()));const t=this.getSlottedOptions(),e=this.getSlottedOptGroups();t.forEach(((t,e)=>{this.multiple&&(t.checkbox=!0),t.id=t.id||`sd-combobox-option-${e}`})),e.forEach(((t,e)=>{t.id=t.id||`sd-combobox-optgroup-${e}`})),await this.syncSelectedOptionsAndValue(),this.multiple?this.createComboboxOptionsFromQuery(this.displayInputValue):this.createComboboxOptionsFromQuery(""),this.hasFocus&&this.value.length>0&&!this.open&&await this.show()}render(){const t=this.hasSlotController.test("left"),e=(this.hasSlotController.test("right"),this.hasSlotController.test("label")),s=this.hasSlotController.test("help-text"),i=!!this.label||!!e,a=!!this.helpText||!!s,n=this.clearable&&!this.disabled&&this.value.length>0,r=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",d=this.disabled?"cursor-not-allowed":"cursor-pointer",p=this.disabled?"text-neutral-500":"text-primary",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],u={sm:"mr-1",md:"mr-2",lg:"mr-2"}[this.size],c={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return o`<div part="form-control" class="${l("relative text-left",d,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><label id="label" part="form-control-label" class="${i&&"inline-block mb-2"}" aria-hidden="${!i}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><div part="form-control-input" class="relative w-full bg-white text-black"><div part="border" class="${l("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[r],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${l("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
10
|
+
popup:popup__content,
|
11
|
+
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}">${t?o`<slot part="left" name="left" class="${l("inline-flex",u,p,c)}"></slot>`:""} ${this.multiple&&this.useTags&&this.tags.length>0?o`<div part="tags" class="${l("flex items-center gap-1",u)}">${this.tags}</div>`:null} <input id="display-input" name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none bg-transparent flex-auto min-w-0",d,this.selectedTextLabel&&!this.multiple?"placeholder-black":"placeholder-neutral-700")}" type="text" placeholder="${this.selectedTextLabel&&!this.multiple?this.selectedTextLabel:this.placeholder}" .disabled="${this.disabled}" .value="${this.displayInputValue}" autocomplete="off" spellcheck="false" autocapitalize="off" aria-controls="listbox" aria-expanded="${this.open}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled}" aria-describedby="help-text invalid-message" aria-invalid="${this.showInvalidStyle}" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}" aria-autocomplete="list" aria-owns="listbox" @input="${this.handleInput}" @change="${this.handleChange}"><div aria-live="polite" id="control-value" class="absolute top-0 left-0 opacity-0 -z-10">${this.selectedOptions.map((t=>null==t?void 0:t.getTextLabel())).join(", ")}</div><input class="${l("value-input absolute top-0 left-0 w-full h-full opacity-0 -z-10",d)}" type="text" ?disabled="${this.disabled}" ?required="${this.required}" .value="${Array.isArray(this.value)?this.value.join(", "):this.value}" tabindex="-1" aria-controls="control-value" aria-hidden="true" @focus="${()=>this.focus()}" @invalid="${this.handleInvalid}"> ${n?o`<button part="clear-button" class="${l("flex justify-center",h)}" type="button" aria-label="${this.localize.term("clearEntry")}" @mousedown="${this.preventLoosingFocus}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-icon class="${l("text-icon-fill-neutral-800",c)}" name="closing-round" library="system"></sd-icon></slot></button>`:""} ${this.showInvalidStyle?o`<sd-icon part="invalid-icon" class="${l(h,c,"text-error")}" library="system" name="risk"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?o`<sd-icon part="valid-icon" class="${l("flex-shrink-0 text-success",h,c)}" library="system" name="status-check"></sd-icon>`:""}<slot name="right" part="right" class="${l("inline-flex ml-2 leading-[0]",this.disabled?"text-neutral-500":"text-primary",c)}"><sd-icon class="${l("transition-all",this.open?"rotate-180":"rotate-0")}" name="chevron-down" part="chevron" library="system" color="currentColor"></sd-icon></slot></div><div id="listbox" role="listbox" aria-expanded="${this.open}" aria-multiselectable="${this.multiple}" aria-labelledby="label" part="listbox" class="${l("bg-white px-2 py-3 relative border-primary overflow-y-auto",this.open&&"shadow","bottom"===this.currentPlacement?"border-r-2 border-b-2 border-l-2 rounded-br-default rounded-bl-default":"border-r-2 border-t-2 border-l-2 rounded-tr-default rounded-tl-default")}" tabindex="-1" @mousedown="${this.preventLoosingFocus}" @mouseup="${this.handleOptionClick}"><div part="filtered-listbox" class="overflow-y-scroll">${0===this.filteredOptions.length?o`<span id="noResults" class="px-4 flex items-center w-full transition-all text-left text-base relative text-black py-3" aria-hidden="true" @click="${this.handleNoResultsClick}">${this.localize.term("noResults")}</span>`:this.options}</div><slot id="defaultOptionsSlot" class="hidden" @slotchange="${this.handleDefaultSlotChange}"></slot></div></sd-popup></div><div part="form-control-help-text" id="help-text" class="text-sm text-neutral-700" aria-hidden="${!a}"><slot name="help-text">${this.helpText}</slot></div></div>${this.formControlController.renderInvalidMessage()}`}};D.dependencies={"sd-icon":$,"sd-popup":a,"sd-tag":T},D.styles=[n,s.styles,r`:host{position:relative;display:block;width:100%}:host([required]) #label::after{content:' *'}[part=listbox]{max-height:var(--auto-size-available-height,auto)}sd-popup::part(popup){z-index:var(--sd-z-index-dropdown,900)}sd-tag::part(base){border-radius:var(--sd-border-radius-default,.25rem);padding-left:var(--sd-spacing-1,.25rem);padding-right:var(--sd-spacing-1,.25rem)}sd-tag::part(content){max-width:var(--tag-max-width,15ch);overflow:hidden;white-space:nowrap;display:inline-block;text-overflow:ellipsis}sd-tag[size=lg]::part(base){padding-left:var(--sd-spacing-2,.5rem);padding-right:var(--sd-spacing-2,.5rem)}sd-tag[disabled=false]::part(base):hover{--tw-bg-opacity:1;background-color:rgb(var(--sd-color-primary-100,236 240 249) / var(--tw-bg-opacity))}[part=filtered-listbox] sd-optgroup:first-of-type{--display-divider:none}mark{background-color:transparent;font-weight:700;color:inherit}`],F([d("sd-popup")],D.prototype,"popup",2),F([d('[part="combobox"]')],D.prototype,"combobox",2),F([d('[part="display-input"]')],D.prototype,"displayInput",2),F([d(".value-input")],D.prototype,"valueInput",2),F([d('[part="listbox"]')],D.prototype,"listbox",2),F([d('[part="tags"]')],D.prototype,"tagWrapper",2),F([d('[part="filtered-listbox"]')],D.prototype,"filteredWrapper",2),F([d("slot:not([name])")],D.prototype,"defaultSlot",2),F([d("#invalid-message")],D.prototype,"invalidMessage",2),F([C()],D.prototype,"hasHover",2),F([C()],D.prototype,"hasFocus",2),F([C()],D.prototype,"displayInputValue",2),F([C()],D.prototype,"selectedTextLabel",2),F([C()],D.prototype,"selectedOptions",2),F([C()],D.prototype,"filteredOptions",2),F([C()],D.prototype,"allOptions",2),F([C()],D.prototype,"lastOption",2),F([C()],D.prototype,"showValidStyle",2),F([C()],D.prototype,"showInvalidStyle",2),F([p()],D.prototype,"name",2),F([p({converter:{fromAttribute:t=>t.split(" "),toAttribute:t=>t.join(" ")}})],D.prototype,"value",2),F([c()],D.prototype,"defaultValue",2),F([p({reflect:!0})],D.prototype,"size",2),F([p()],D.prototype,"placeholder",2),F([p({reflect:!0,type:Boolean})],D.prototype,"disabled",2),F([p({type:Boolean})],D.prototype,"clearable",2),F([p({reflect:!0,type:Boolean})],D.prototype,"open",2),F([p({type:Boolean})],D.prototype,"hoist",2),F([p()],D.prototype,"label",2),F([p({reflect:!0})],D.prototype,"placement",2),F([p({attribute:"help-text"})],D.prototype,"helpText",2),F([p({reflect:!0})],D.prototype,"form",2),F([p({reflect:!0,type:Boolean})],D.prototype,"required",2),F([C()],D.prototype,"currentPlacement",2),F([p()],D.prototype,"getOption",2),F([p({type:Boolean,reflect:!0})],D.prototype,"multiple",2),F([p({type:Boolean,reflect:!0})],D.prototype,"useTags",2),F([p({attribute:"max-options-visible",type:Number})],D.prototype,"maxOptionsVisible",2),F([p({type:Boolean,reflect:!0,attribute:"style-on-valid"})],D.prototype,"styleOnValid",2),F([p()],D.prototype,"filter",2),F([p()],D.prototype,"getTag",2),F([V("filter",{waitUntilFirstUpdate:!0})],D.prototype,"handleFilterChange",1),F([V("useTags",{waitUntilFirstUpdate:!0})],D.prototype,"handleUseTagsChange",1),F([V("size",{waitUntilFirstUpdate:!0})],D.prototype,"applySizeToOptions",1),F([V("disabled",{waitUntilFirstUpdate:!0})],D.prototype,"handleDisabledChange",1),F([V("value",{waitUntilFirstUpdate:!0})],D.prototype,"handleValueChange",1),F([V("displayInputValue",{waitUntilFirstUpdate:!0})],D.prototype,"handleDisplayInputValueChange",1),F([V("open",{waitUntilFirstUpdate:!0})],D.prototype,"handleOpenChange",1),D=F([h("sd-combobox")],D),O("combobox.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),O("combobox.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{D as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{S as t,
|
1
|
+
import{S as t,j as a,t as e,c as i,i as r,n as s,a as n}from"./solid-components2.js";import{s as l,n as o}from"./static.js";import{o as c}from"./if-defined.js";var h=Object.defineProperty,v=Object.getOwnPropertyDescriptor,p=(t,a,e,i)=>{for(var r,s=i>1?void 0:i?v(a,e):a,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(i?r(a,e,s):r(s))||s);return i&&s&&h(a,e,s),s};let f=class extends t{constructor(){super(...arguments),this.variant="main",this.state="default",this.animated=!1,this.notInteractive=!1,this.href="",this.marker={cluster:a`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><circle cx="25" cy="25" opacity="1" r="20"/><circle cx="25" cy="25" opacity=".3" r="25"/></svg>`,main:a`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 75"><path d="M51 49A29 29 0 0 0 30 0 29 29 0 0 0 9 49l21 22 21-22Z"/><circle cx="30" cy="28" r="10" fill="#fff"/></svg>`,place:a`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 75"><path fill-rule="evenodd" d="M51 49A29 29 0 0 0 30 0 29 29 0 0 0 9 49l21 22 21-22Z" clip-rule="evenodd"/></svg>`}}handleBlur(){this.emit("sd-blur")}handleFocus(){this.emit("sd-focus")}isLink(){return!!this.href}render(){const t=this.isLink(),a=this.notInteractive?l`div`:t?l`a`:l`button`;return o`<${a} part="base" class="${e("flex justify-center",!this.notInteractive&&"focus:outline focus:outline-2 focus:outline-primary focus:outline-offset-2")}" href="${c(t?this.href:void 0)}" target="${c(t?this.target:void 0)}" @blur="${this.handleBlur}" @focus="${this.handleFocus}" role="${c(this.notInteractive||t?void 0:"button")}" aria-labelledby="${c(this.notInteractive?void 0:"content")}"><div part="marker" class="${e("inline-flex",this.animated&&("main"===this.variant||"place"===this.variant)&&"animate-bounce-once","cluster"===this.variant&&"hover"===this.state&&"scale-110 fill-primary-500","cluster"===this.variant&&!this.notInteractive&&"transition-all duration-200 ease-in-out hover:scale-110 hover:fill-primary-500","main"===this.variant&&"hover"===this.state&&"fill-accent-550","main"===this.variant&&"active"===this.state&&"fill-accent-700","main"===this.variant&&!this.notInteractive&&"hover:fill-accent-550 active:fill-accent-700","place"===this.variant&&"default"===this.state&&"fill-white","place"===this.variant&&"hover"===this.state&&"fill-primary-100","place"===this.variant&&"active"===this.state&&"fill-primary-200","place"===this.variant&&!this.notInteractive&&"hover:fill-primary-100",{cluster:"fill-primary",main:"fill-accent *:drop-shadow-md",place:"*:drop-shadow-md"}[this.variant])}">${this.marker[this.variant]}</div><div id="content" part="content" class="${e("absolute self-center pointer-events-none","cluster"===this.variant&&"font-bold text-white")}"><slot></slot></div></${a}>`}};f.styles=[i,t.styles,r`:host{display:block}:host([variant=cluster]) [part=base],svg{width:calc(var(--sd-spacing-12,3rem) * var(--map-marker-scaling,1))}:host([variant=cluster]) [part=base]{height:calc(var(--sd-spacing-12,3rem) * var(--map-marker-scaling,1))}:host(:not([variant=cluster])) [part=base]{height:calc(var(--sd-spacing-16,4rem) * var(--map-marker-scaling,1))}:host([variant=cluster]) [part=content]{font-size:calc(var(--sd-font-size-sm,.875rem) * var(--map-marker-scaling,1))}:host([variant=place]) [part=content]{font-size:calc(var(--sd-font-size-3xl,2rem) * var(--map-marker-scaling,1))}`],p([s({reflect:!0})],f.prototype,"variant",2),p([s({reflect:!0})],f.prototype,"state",2),p([s({type:Boolean,reflect:!0})],f.prototype,"animated",2),p([s({type:Boolean,reflect:!0,attribute:"not-interactive"})],f.prototype,"notInteractive",2),p([s()],f.prototype,"href",2),p([s()],f.prototype,"target",2),f=p([n("sd-map-marker")],f);export{f as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{S as e,t,c as s,i as a,e as i,n as l,a as d}from"./solid-components2.js";import{n as o}from"./static.js";import{w as r}from"./watch.js";import n from"./divider.js";var p=Object.defineProperty,b=Object.getOwnPropertyDescriptor,c=(e,t,s,a)=>{for(var i,l=a>1?void 0:a?b(t,s):t,d=e.length-1;d>=0;d--)(i=e[d])&&(l=(a?i(t,s,l):i(l))||l);return a&&l&&p(t,s,l),l};let h=class extends e{constructor(){super(...arguments),this.disabled=!1,this.label=""}handleDisableOptions(){const{disabled:e}=this;this.defaultSlot.assignedElements().filter((e=>"sd-option"===e.tagName.toLowerCase())).forEach((t=>{t.disabled=e}))}handleDisabledChange(){this.handleDisableOptions()}render(){const{disabled:e}=this;return o`<div role="${e?"presentation":"group"}" class="${t(this.disabled?"text-neutral-500":"")}" part="base" aria-labelledby="group-label"><sd-divider id="divider" class="pt-2 pb-4" part="divider"></sd-divider><div part="label-container" class="${t(this.disabled?"text-neutral-500":"text-black")} px-4 font-bold text-left" role="presentation" id="group-label"><slot name="label"><span>${this.label}</span></slot></div><div role="group" part="options"><slot @slotchange="${this.handleDisableOptions}"></slot></div></div>`}};h.dependencies={"sd-divider":n},h.styles=[s,e.styles,a`:host{--display-divider:block}#divider{display:var(--display-divider)}`],c([i("slot:not([name])")],h.prototype,"defaultSlot",2),c([l({reflect:!0,type:Boolean})],h.prototype,"disabled",2),c([l()],h.prototype,"label",2),c([r("disabled",{waitUntilFirstUpdate:!0})],h.prototype,"handleDisabledChange",1),h=c([d("sd-optgroup")],h);export{h as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=e=>e,n=(e,n)=>{if(!n)return e;const t=e.cloneNode(!0);t.selected=e.selected;const r=t.getTextLabel(),o=r.toLowerCase().indexOf(n.toLowerCase()),c=t.innerHTML.indexOf(r),i=document.createElement("mark");i.textContent=r.slice(o,o+n.length);const l=r.replace(new RegExp(n,"i"),i.outerHTML),s=t.innerHTML.slice(0,c),a=t.innerHTML.slice(c+r.length);return t.innerHTML=s.concat(l,a),t};export{e as defaultOptionRenderer,n as highlightOptionRenderer};
|
@@ -1,7 +1,11 @@
|
|
1
|
-
import{s as
|
1
|
+
import{s as e,a as t}from"./animate.js";import{S as s,L as i,x as o,t as l,d as a,c as n,i as r,e as h,n as d,a as p}from"./solid-components2.js";import{d as c}from"./default-value.js";import{F as u}from"./form.js";import{g as m,s as y}from"./animation-registry.js";import{H as v}from"./slot.js";import{r as b}from"./state.js";import{o as g}from"./query-assigned-elements.js";import{s as f}from"./scroll.js";import{o as x,S as w}from"./icon.js";import{w as O}from"./event.js";import{w as C}from"./watch.js";import S from"./tag.js";var $=Object.defineProperty,k=Object.getOwnPropertyDescriptor,T=(e,t,s,i)=>{for(var o,l=i>1?void 0:i?k(t,s):t,a=e.length-1;a>=0;a--)(o=e[a])&&(l=(i?o(t,s,l):o(l))||l);return i&&l&&$(t,s,l),l};let D=class extends s{constructor(){super(...arguments),this.formControlController=new u(this,{assumeInteractionOn:["sd-blur","sd-input"]}),this.hasSlotController=new v(this,"help-text","label"),this.localize=new i(this),this.typeToSelectString="",this.hasHover=!1,this.displayLabel="",this.deletedTagLabel="",this.hasFocus=!1,this.selectedOptions=[],this.showValidStyle=!1,this.showInvalidStyle=!1,this.defaultValue="",this.open=!1,this.size="lg",this.placement="bottom",this.label="",this.placeholder=this.localize.term("selectDefaultPlaceholder"),this.disabled=!1,this.helpText="",this.currentPlacement=this.placement,this.clearable=!1,this.multiple=!1,this.useTags=!1,this.maxOptionsVisible=3,this.form="",this.name="",this.value="",this.required=!1,this.styleOnValid=!1,this.hoist=!1,this.getTag=e=>o`<sd-tag ?disabled="${this.disabled}" part="tag" exportparts="
|
2
2
|
base:tag__base,
|
3
3
|
content:tag__content,
|
4
4
|
removable-indicator:tag__removable-indicator,
|
5
|
-
" size="${"sm"===this.size?"sm":"lg"}" removable @sd-remove="${e=>this.handleTagRemove(e,t)}">${t.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()},this.handleDocumentKeyDown=t=>{const e=t.target,s=null!==e.closest(".select__clear"),i=null!==e.closest("sd-icon-button");if(!s&&!i){if("Escape"===t.key&&this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===t.key||" "===t.key&&""===this.typeToSelectString)return t.preventDefault(),t.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(["ArrowUp","ArrowDown","Home","End"].includes(t.key)){const e=this.getAllOptions(),s=e.indexOf(this.currentOption);let i=Math.max(0,s);if(t.preventDefault(),!this.open&&(this.show(),this.currentOption))return;"ArrowDown"===t.key?(i=s+1,i>e.length-1&&(i=0)):"ArrowUp"===t.key?(i=s-1,i<0&&(i=e.length-1)):"Home"===t.key?i=0:"End"===t.key&&(i=e.length-1),this.setCurrentOption(e[i])}if(1===t.key.length||"Backspace"===t.key){const e=this.getAllOptions();if(t.metaKey||t.ctrlKey||t.altKey)return;if(!this.open){if("Backspace"===t.key)return;this.show()}t.stopPropagation(),t.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===t.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=t.key.toLowerCase();for(const t of e)if(t.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(t);break}}}},this.handleDocumentMouseDown=t=>{const e=t.composedPath();this&&!e.includes(this)&&this.hide()}}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}connectedCallback(){super.connectedCallback(),this.applySizeToOptions(),this.open=!1}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleLabelClick(){this.displayInput.focus()}handleComboboxMouseDown(t){const e=t.composedPath().some((t=>t instanceof HTMLSlotElement&&"removable-indicator"===t.name));this.disabled||e||(t.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(t){t.stopPropagation(),this.handleDocumentKeyDown(t)}handleClearClick(t){t.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")})))}handleClearMouseDown(t){t.stopPropagation(),t.preventDefault()}handleOptionClick(t){const e=t.target.closest("sd-option"),s=this.value;e&&!e.disabled&&(this.multiple?this.toggleOptionSelection(e):this.setSelectedOptions(e),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}handleDefaultSlotChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value],s=[];customElements.get("sd-option")?(t.forEach((t=>{this.multiple&&(t.checkbox=!0),s.push(t.value)})),this.setSelectedOptions(t.filter((t=>e.includes(t.value))))):customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(t,e){t.stopPropagation(),this.disabled||(this.toggleOptionSelection(e,!1),this.deletedTagLabel=this.localize.term("removed",e.textContent),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})))}getAllOptions(){return[...this.querySelectorAll("sd-option")]}getFirstOption(){return this.querySelector("sd-option")}setCurrentOption(t){this.getAllOptions().forEach((t=>{t.current=!1,t.tabIndex=-1})),t&&(this.currentOption=t,t.current=!0,t.tabIndex=0,t.focus())}setSelectedOptions(t){const e=this.getAllOptions(),s=Array.isArray(t)?t:[t];e.forEach((t=>t.selected=!1)),s.length&&s.forEach((t=>t.selected=!0)),this.selectionChanged()}toggleOptionSelection(t,e){t.selected=!0===e||!1===e?e:!t.selected,this.selectionChanged()}selectionChanged(){var t,e;this.selectedOptions=this.getAllOptions().filter((t=>t.selected)),this.multiple?(this.value=this.selectedOptions.map((t=>t.value)),this.useTags||0===this.value.length?this.displayLabel="":this.displayLabel=this.localize.term("numOptionsSelected",this.selectedOptions.length)):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)??"",this.displayLabel=(null==(e=this.selectedOptions[0])?void 0:e.getTextLabel())??""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}get tags(){return this.selectedOptions.map(((t,e)=>{if(e<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(t,e);return o`<div @sd-remove="${e=>this.handleTagRemove(e,t)}">${"string"==typeof s?x(s):s}</div>`}return e===this.maxOptionsVisible?o`<sd-tag size="${"sm"===this.size?"sm":"lg"}" ?disabled="${this.disabled}">+${this.selectedOptions.length-e}</sd-tag>`:o``}))}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t),this.invalidMessage.textContent=t.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(t){const e=t.detail;e&&(this.currentPlacement=e)}handleUseTagsChange(){const t=this.getAllOptions();customElements.get("sd-option")&&t.forEach((t=>{t.checkbox=this.multiple}))}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("sd-show"),this.addOpenListeners(),await t(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:s,options:i}=m(this,"select.show",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.currentOption&&f(this.currentOption,this.listbox,"vertical","auto"),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await t(this);const{keyframes:s,options:i}=m(this,"select.hide",{dir:this.localize.dir()});await e(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}applySizeToOptions(){this._optionsInDefaultSlot.forEach((t=>{t.size=this.size}))}handleValueChange(){const t=this.getAllOptions(),e=Array.isArray(this.value)?this.value:[this.value];this.setSelectedOptions(t.filter((t=>e.includes(t.value))))}async show(){if(!this.open&&!this.disabled)return this.open=!0,O(this,"sd-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,O(this,"sd-after-hide");this.open=!1}checkValidity(){var t;return null==(t=this.valueInput)?void 0:t.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(t){this.valueInput.setCustomValidity(t),this.formControlController.updateValidity()}focus(t){this.displayInput.focus(t)}blur(){this.displayInput.blur()}render(){this.hasSlotController.test("[default]");const t=this.hasSlotController.test("label"),e=(this.hasSlotController.test("clear-icon"),this.hasSlotController.test("expand-icon"),this.hasSlotController.test("help-text")),s=!!this.label||!!t,i=!!this.helpText||!!e,a=this.clearable&&!this.disabled&&this.value.length>0,n=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",r=this.disabled?"cursor-not-allowed":"cursor-pointer",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],d={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return o`<div part="form-control" class="${l("relative text-left",r,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><span class="sr-only" role="alert" aria-live="assertive">${this.deletedTagLabel}</span><div class="flex items-center gap-1 mb-2"><label id="label" part="form-control-label" class="${s&&"inline-block"}" aria-hidden="${s?"false":"true"}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><slot name="tooltip"></slot></div><div part="form-control-input" class="${l("relative w-full bg-white","disabled"===n?"text-neutral-500":"text-black")}"><div part="border" class="${l("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[n],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${l("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
5
|
+
" size="${"sm"===this.size?"sm":"lg"}" removable @keydown="${t=>this.handleTagKeyDown(t,e)}" @sd-remove="${t=>this.handleTagRemove(t,e)}">${e.getTextLabel()}</sd-tag>`,this.handleDocumentFocusIn=e=>{const t=e.composedPath();this&&!t.includes(this)&&this.hide()},this.handleDocumentKeyDown=e=>{const t=e.target,s=null!==t.closest(".select__clear"),i=null!==t.closest("sd-icon-button");if(!s&&!i){if("Escape"===e.key&&this.open&&(e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===e.key||" "===e.key&&""===this.typeToSelectString)return e.preventDefault(),e.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(["ArrowUp","ArrowDown","Home","End"].includes(e.key)){const t=this.getAllOptions(),s=t.indexOf(this.currentOption);let i=Math.max(0,s);if(e.preventDefault(),!this.open&&(this.show(),this.currentOption))return;"ArrowDown"===e.key?(i=s+1,i>t.length-1&&(i=0)):"ArrowUp"===e.key?(i=s-1,i<0&&(i=t.length-1)):"Home"===e.key?i=0:"End"===e.key&&(i=t.length-1),this.setCurrentOption(t[i])}if(1===e.key.length||"Backspace"===e.key){const t=this.getAllOptions();if(e.metaKey||e.ctrlKey||e.altKey)return;if(!this.open){if("Backspace"===e.key)return;this.show()}e.stopPropagation(),e.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===e.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=e.key.toLowerCase();for(const e of t)if(e.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(e);break}}}},this.handleDocumentMouseDown=e=>{const t=e.composedPath();this&&!t.includes(this)&&this.hide()}}get validity(){return this.valueInput.validity}get validationMessage(){return this.valueInput.validationMessage}connectedCallback(){super.connectedCallback(),this.open=!1}firstUpdated(){this.applySizeToOptions()}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("sd-focus")}handleBlur(){this.hasFocus=!1,this.emit("sd-blur")}handleTagKeyDown(e,t){var s,i,o;if("Backspace"===e.key&&this.multiple){e.stopPropagation();const l=null==(s=e.currentTarget)?void 0:s.parentElement,a=null==(i=null==l?void 0:l.previousElementSibling)?void 0:i.querySelector("sd-tag"),n=null==(o=null==l?void 0:l.nextElementSibling)?void 0:o.querySelector("sd-tag");this.handleTagRemove(new CustomEvent("sd-remove"),t),this.updateComplete.then((()=>{n?n.focus():a?a.focus():this.focus({preventScroll:!0})}))}}handleTagMaxOptionsKeyDown(e){"Backspace"===e.key&&this.multiple&&(e.stopPropagation(),this.handleTagRemove(new CustomEvent("sd-remove"),this.selectedOptions[this.selectedOptions.length-1]),this.updateComplete.then((()=>{var e;const t=null==(e=this.shadowRoot)?void 0:e.querySelectorAll("sd-tag");t&&t.length>0?null==t||t[(null==t?void 0:t.length)-1].focus():this.focus({preventScroll:!0})})))}handleLabelClick(){this.displayInput.focus()}handleComboboxMouseDown(e){const t=e.composedPath().some((e=>e instanceof HTMLSlotElement&&"removable-indicator"===e.name));this.disabled||t||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(e){e.stopPropagation(),this.handleDocumentKeyDown(e)}handleClearClick(e){e.stopPropagation(),this.clearSelect()}clearSelect(){this.setSelectedOptions([]),this.displayInput.focus({preventScroll:!0}),this.updateComplete.then((()=>{this.emit("sd-clear"),this.emit("sd-input"),this.emit("sd-change")}))}handleClearMouseDown(e){e.stopPropagation(),e.preventDefault()}handleOptionClick(e){const t=e.target.closest("sd-option"),s=this.value;t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==s&&this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],s=[];customElements.get("sd-option")?(e.forEach((e=>{this.multiple&&(e.checkbox=!0),s.push(e.value)})),this.setSelectedOptions(e.filter((e=>t.includes(e.value))))):customElements.whenDefined("sd-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(e,t){e.stopPropagation(),t||this.clearSelect(),t&&!this.disabled&&(this.toggleOptionSelection(t,!1),this.deletedTagLabel=this.localize.term("removed",t.textContent),this.updateComplete.then((()=>{this.emit("sd-input"),this.emit("sd-change")})))}getAllOptions(){return[...this.querySelectorAll("sd-option")]}getFirstOption(){return this.querySelector("sd-option")}setCurrentOption(e){this.getAllOptions().forEach((e=>{e.current=!1,e.tabIndex=-1})),e&&(this.currentOption=e,e.current=!0,e.tabIndex=0,e.focus())}setSelectedOptions(e){const t=this.getAllOptions(),s=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),s.length&&s.forEach((e=>e.selected=!0)),Array.isArray(e)?this.selectionChanged():this.selectionChanged(e)}toggleOptionSelection(e,t){e.selected=!0===t||!1===t?t:!e.selected,Array.isArray(e)?this.selectionChanged():this.selectionChanged(e)}selectionChanged(e){var t,s;e&&this.multiple?this.selectedOptions.find((t=>t.value===e.value))?this.selectedOptions=this.selectedOptions.filter((t=>t.value!==e.value)):this.selectedOptions=[...this.selectedOptions,e]:this.selectedOptions=this.getAllOptions().filter((e=>e.selected)),this.multiple?(this.value=this.selectedOptions.map((e=>e.value)),this.useTags||0===this.value.length?this.displayLabel="":this.displayLabel=this.localize.term("numOptionsSelected",this.selectedOptions.length)):(this.value=(null==(t=this.selectedOptions[0])?void 0:t.value)??"",this.displayLabel=(null==(s=this.selectedOptions[0])?void 0:s.getTextLabel())??""),this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}get tags(){return this.selectedOptions.length<=this.maxOptionsVisible?this.selectedOptions.map(((e,t)=>{if(t<this.maxOptionsVisible||this.maxOptionsVisible<=0){const s=this.getTag(e,t);return o`<div @sd-remove="${t=>this.handleTagRemove(t,e)}">${"string"==typeof s?x(s):s}</div>`}return[o``]})):[o`<sd-tag ?disabled="${this.disabled}" part="tag" exportparts="
|
6
|
+
base:tag__base,
|
7
|
+
content:tag__content,
|
8
|
+
removable-indicator:tag__removable-indicator,
|
9
|
+
" size="${"sm"===this.size?"sm":"lg"}" removable @keydown="${e=>this.handleTagMaxOptionsKeyDown(e)}" @sd-remove="${e=>this.handleTagRemove(e)}">${this.selectedOptions.length} ${this.localize.term("tagsSelected")}</sd-tag>`]}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e),this.invalidMessage.textContent=e.target.validationMessage}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleCurrentPlacement(e){const t=e.detail;t&&(this.currentPlacement=t)}handleUseTagsChange(){const e=this.getAllOptions();customElements.get("sd-option")&&e.forEach((e=>{e.checkbox=this.multiple}))}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}async handleOpenChange(){if(this.open&&!this.disabled){this.multiple||this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("sd-show"),this.addOpenListeners(),await e(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:s,options:i}=m(this,"select.show",{dir:this.localize.dir()});await t(this.popup.popup,s,i),this.currentOption&&f(this.currentOption,this.listbox,"vertical","auto"),this.emit("sd-after-show")}else{this.emit("sd-hide"),this.removeOpenListeners(),await e(this);const{keyframes:s,options:i}=m(this,"select.hide",{dir:this.localize.dir()});await t(this.popup.popup,s,i),this.listbox.hidden=!0,this.popup.active=!1,this.emit("sd-after-hide")}}applySizeToOptions(){this._optionsInDefaultSlot.forEach((e=>{e.size=this.size}))}handleValueChange(){if(this.selectedOptions.length===(Array.isArray(this.value)?this.value.length:1))return;const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value];this.setSelectedOptions(e.filter((e=>t.includes(e.value))))}async show(){if(!this.open&&!this.disabled)return this.open=!0,O(this,"sd-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,O(this,"sd-after-hide");this.open=!1}checkValidity(){var e;return null==(e=this.valueInput)?void 0:e.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.formControlController.fakeUserInteraction(),this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}render(){this.hasSlotController.test("[default]");const e=this.hasSlotController.test("label"),t=(this.hasSlotController.test("clear-icon"),this.hasSlotController.test("expand-icon"),this.hasSlotController.test("help-text")),s=!!this.label||!!e,i=!!this.helpText||!!t,a=this.clearable&&!this.disabled&&this.value.length>0,n=this.disabled?"disabled":this.hasFocus&&this.showInvalidStyle?"activeInvalid":this.hasFocus&&this.styleOnValid&&this.showValidStyle?"activeValid":this.hasFocus||this.open?"active":this.showInvalidStyle?"invalid":this.styleOnValid&&this.showValidStyle?"valid":"default",r=this.disabled?"cursor-not-allowed":"cursor-pointer",h={sm:"ml-1",md:"ml-2",lg:"ml-2"}[this.size],d={sm:"text-base",md:"text-lg",lg:"text-xl"}[this.size];return o`<div part="form-control" class="${l("relative text-left",r,"sm"===this.size?"text-sm":"text-base",this.open&&"z-50")}"><span class="sr-only" role="alert" aria-live="assertive">${this.deletedTagLabel}</span><div class="flex items-center gap-1 mb-2"><label id="label" part="form-control-label" class="${s&&"inline-block"}" aria-hidden="${s?"false":"true"}" @click="${this.handleLabelClick}"><slot name="label">${this.label}</slot></label><slot name="tooltip"></slot></div><div part="form-control-input" class="${l("relative w-full bg-white","disabled"===n?"text-neutral-500":"text-black")}"><div part="border" class="${l("absolute top-0 w-full h-full pointer-events-none border rounded-default",this.hasHover&&"bg-neutral-200",{disabled:"border-neutral-500",readonly:"border-neutral-800",activeInvalid:"border-error border-2",activeValid:"border-success border-2",active:"border-primary border-2",invalid:"border-error",valid:"border-success",default:"border-neutral-800"}[n],this.open&&("bottom"===this.currentPlacement?"rounded-bl-none rounded-br-none":"rounded-tl-none rounded-tr-none"))}"></div><sd-popup @sd-current-placement="${this.handleCurrentPlacement}" class="${l("inline-flex relative w-full","bottom"===this.currentPlacement?"origin-top":"origin-bottom")}" placement="${this.placement}" strategy="${this.hoist?"fixed":"absolute"}" flip shift sync="width" auto-size="vertical" auto-size-padding="10" exportparts="
|
6
10
|
popup:popup__content,
|
7
|
-
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><input name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none flex-grow bg-transparent w-full placeholder-neutral-700",r,this.multiple&&this.useTags&&this.value.length>0?"hidden":"")}" type="text" placeholder="${this.placeholder}" .disabled="${this.disabled}" .value="${this.displayLabel}" autocomplete="off" spellcheck="false" autocapitalize="off" readonly="readonly" aria-controls="listbox" aria-expanded="${this.open?"true":"false"}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled?"true":"false"}" aria-invalid="${this.showInvalidStyle}" aria-describedby="help-text invalid-message" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${this.multiple&&this.useTags?o`<div part="tags" class="flex-grow flex flex-wrap items-center gap-1">${this.tags}</div>`:""}
|
11
|
+
"><div part="combobox" class="${l("relative w-full px-4 flex flex-row items-center rounded-default",this.open&&"shadow",{sm:"py-1 min-h-[32px]",md:"py-1 min-h-[40px]",lg:"py-2 min-h-[48px]"}[this.size])}" slot="anchor" @keydown="${this.handleComboboxKeyDown}" @mousedown="${this.handleComboboxMouseDown}" @mouseenter="${this.handleMouseEnter}" @mouseleave="${this.handleMouseLeave}"><input name="${this.name}" form="${this.form}" part="display-input" class="${l("appearance-none outline-none flex-grow bg-transparent w-full placeholder-neutral-700",r,this.multiple&&this.useTags&&this.value.length>0?"hidden":"")}" type="text" placeholder="${this.placeholder}" .disabled="${this.disabled}" .value="${this.displayLabel}" autocomplete="off" spellcheck="false" autocapitalize="off" readonly="readonly" aria-controls="listbox" aria-expanded="${this.open?"true":"false"}" aria-haspopup="listbox" aria-labelledby="label" aria-disabled="${this.disabled?"true":"false"}" aria-invalid="${this.showInvalidStyle}" aria-describedby="help-text invalid-message" role="combobox" tabindex="0" @focus="${this.handleFocus}" @blur="${this.handleBlur}"> ${this.multiple&&this.useTags?o`<div part="tags" class="flex-grow flex flex-wrap items-center gap-1">${this.tags}</div>`:""}<div aria-live="polite" id="control-value" class="absolute top-0 left-0 opacity-0 -z-10">${this.selectedOptions.map((e=>null==e?void 0:e.getTextLabel())).join(", ")}</div><input class="${l("value-input absolute top-0 left-0 w-full h-full opacity-0 -z-10",r)}" type="text" ?disabled="${this.disabled}" ?required="${this.required}" .value="${Array.isArray(this.value)?this.value.join(", "):this.value}" tabindex="-1" aria-controls="control-value" aria-hidden="true" @focus="${()=>this.focus()}" @invalid="${this.handleInvalid}"> ${a?o`<button part="clear-button" class="${l("select__clear flex justify-center",h)}" type="button" aria-label="${this.localize.term("clearEntry")}" @mousedown="${this.handleClearMouseDown}" @click="${this.handleClearClick}" tabindex="-1"><slot name="clear-icon"><sd-icon class="${l("text-icon-fill-neutral-800",d)}" library="system" name="closing-round"></sd-icon></slot></button>`:""} ${this.showInvalidStyle?o`<sd-icon part="invalid-icon" class="${l(h,d,"text-error")}" library="system" name="risk"></sd-icon>`:""} ${this.styleOnValid&&this.showValidStyle?o`<sd-icon part="valid-icon" class="${l("flex-shrink-0 text-success",h,d)}" library="system" name="status-check"></sd-icon>`:""}<slot name="expand-icon" part="expand-icon" class="${l("inline-flex ml-2 transition-all",this.open?"rotate-180":"rotate-0",this.disabled?"text-neutral-500":"text-primary",d)}"><sd-icon name="chevron-down" part="chevron" library="system" color="currentColor"></sd-icon></slot></div><div id="listbox" role="listbox" aria-expanded="${this.open?"true":"false"}" aria-multiselectable="${this.multiple?"true":"false"}" aria-labelledby="label" part="listbox" class="${l("bg-white px-2 py-3 relative border-primary overflow-y-scroll",this.open&&"shadow","bottom"===this.currentPlacement?"border-r-2 border-b-2 border-l-2 rounded-br-default rounded-bl-default":"border-r-2 border-t-2 border-l-2 rounded-tr-default rounded-tl-default")}" tabindex="-1" @mouseup="${this.handleOptionClick}" @slotchange="${this.handleDefaultSlotChange}"><slot></slot></div></sd-popup></div><div class="text-sm text-neutral-700" part="form-control-help-text" id="help-text" aria-hidden="${i?"false":"true"}"><slot name="help-text">${this.helpText}</slot></div></div>${this.formControlController.renderInvalidMessage()}`}};D.dependencies={"sd-icon":w,"sd-popup":a,"sd-tag":S},D.styles=[n,s.styles,r`:host{position:relative;display:block;width:100%}:host([required]) #label::after{content:' *'}[part=listbox]{max-height:var(--auto-size-available-height,auto)}sd-popup::part(popup){z-index:var(--sd-z-index-dropdown,900)}sd-tag::part(base){border-radius:var(--sd-border-radius-default,.25rem);padding-left:var(--sd-spacing-1,.25rem);padding-right:var(--sd-spacing-1,.25rem)}sd-tag[size=lg]::part(base){padding-left:var(--sd-spacing-2,.5rem);padding-right:var(--sd-spacing-2,.5rem)}sd-tag[disabled=false]::part(base):hover{--tw-bg-opacity:1;background-color:rgb(var(--sd-color-primary-100,236 240 249) / var(--tw-bg-opacity))}`],T([g({selector:"sd-option"})],D.prototype,"_optionsInDefaultSlot",2),T([h("sd-popup")],D.prototype,"popup",2),T([h('[part="combobox"]')],D.prototype,"combobox",2),T([h('[part="display-input"]')],D.prototype,"displayInput",2),T([h(".value-input")],D.prototype,"valueInput",2),T([h('[part="listbox"]')],D.prototype,"listbox",2),T([h("#invalid-message")],D.prototype,"invalidMessage",2),T([b()],D.prototype,"hasHover",2),T([b()],D.prototype,"displayLabel",2),T([b()],D.prototype,"deletedTagLabel",2),T([b()],D.prototype,"hasFocus",2),T([b()],D.prototype,"currentOption",2),T([b()],D.prototype,"selectedOptions",2),T([b()],D.prototype,"showValidStyle",2),T([b()],D.prototype,"showInvalidStyle",2),T([c()],D.prototype,"defaultValue",2),T([d({type:Boolean,reflect:!0})],D.prototype,"open",2),T([d({reflect:!0})],D.prototype,"size",2),T([d({reflect:!0})],D.prototype,"placement",2),T([d()],D.prototype,"label",2),T([d()],D.prototype,"placeholder",2),T([d({type:Boolean,reflect:!0})],D.prototype,"disabled",2),T([d({attribute:"help-text"})],D.prototype,"helpText",2),T([b()],D.prototype,"currentPlacement",2),T([d({type:Boolean})],D.prototype,"clearable",2),T([d({type:Boolean,reflect:!0})],D.prototype,"multiple",2),T([d({type:Boolean,reflect:!0})],D.prototype,"useTags",2),T([d({attribute:"max-options-visible",type:Number})],D.prototype,"maxOptionsVisible",2),T([d({reflect:!0})],D.prototype,"form",2),T([d()],D.prototype,"name",2),T([d({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],D.prototype,"value",2),T([d({type:Boolean,reflect:!0})],D.prototype,"required",2),T([d({type:Boolean,reflect:!0,attribute:"style-on-valid"})],D.prototype,"styleOnValid",2),T([d({type:Boolean})],D.prototype,"hoist",2),T([d()],D.prototype,"getTag",2),T([C("useTags",{waitUntilFirstUpdate:!0})],D.prototype,"handleUseTagsChange",1),T([C("disabled",{waitUntilFirstUpdate:!0})],D.prototype,"handleDisabledChange",1),T([C("open",{waitUntilFirstUpdate:!0})],D.prototype,"handleOpenChange",1),T([C("size",{waitUntilFirstUpdate:!0})],D.prototype,"applySizeToOptions",1),T([C("value",{waitUntilFirstUpdate:!0})],D.prototype,"handleValueChange",1),D=T([p("sd-select")],D),y("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),y("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});export{D as default};
|