@ecopages/radiant-ui 0.1.0-rc.8 → 0.1.0
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.
- package/README.md +9 -1
- package/dist/components/ui/autocomplete/autocomplete.css +1 -2
- package/dist/components/ui/avatar/avatar.css +10 -8
- package/dist/components/ui/avatar/avatar.d.ts +3 -1
- package/dist/components/ui/calendar/calendar.css +10 -5
- package/dist/components/ui/calendar/calendar.script.d.ts +1 -0
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +3 -3
- package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
- package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
- package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
- package/dist/components/ui/carousel/carousel.css +71 -18
- package/dist/components/ui/carousel/carousel.d.ts +1 -1
- package/dist/components/ui/carousel/carousel.script.d.ts +49 -21
- package/dist/components/ui/carousel/index.js +1 -1
- package/dist/components/ui/carousel/index.js.map +4 -4
- package/dist/components/ui/checkbox/checkbox.script.d.ts +0 -3
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/checkbox-group/checkbox-group.d.ts +0 -1
- package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +8 -7
- package/dist/components/ui/checkbox-group/index.js +1 -1
- package/dist/components/ui/checkbox-group/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +2 -2
- package/dist/components/ui/combobox/combobox.d.ts +1 -2
- package/dist/components/ui/combobox/combobox.script.d.ts +13 -6
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +4 -4
- package/dist/components/ui/cycle-toggle/index.js +1 -1
- package/dist/components/ui/cycle-toggle/index.js.map +3 -3
- package/dist/components/ui/date-field/date-field.css +13 -17
- package/dist/components/ui/date-field/date-field.d.ts +7 -5
- package/dist/components/ui/date-field/date-field.script.d.ts +16 -48
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +4 -4
- package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
- package/dist/components/ui/date-input/date-input.css +50 -0
- package/dist/components/ui/date-input/date-input.d.ts +8 -0
- package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
- package/dist/components/ui/date-input/index.d.ts +2 -0
- package/dist/components/ui/date-input/index.js +2 -0
- package/dist/components/ui/date-input/index.js.map +7 -0
- package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +8 -6
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +24 -47
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +4 -4
- package/dist/components/ui/dialog/dialog.css +18 -14
- package/dist/components/ui/dialog/dialog.script.d.ts +10 -3
- package/dist/components/ui/dialog/index.js +1 -1
- package/dist/components/ui/dialog/index.js.map +4 -4
- package/dist/components/ui/disclosure/disclosure.css +3 -6
- package/dist/components/ui/disclosure/disclosure.d.ts +15 -5
- package/dist/components/ui/disclosure/disclosure.script.d.ts +2 -2
- package/dist/components/ui/disclosure/index.d.ts +1 -1
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/field/field.d.ts +1 -1
- package/dist/components/ui/field/field.script.d.ts +27 -4
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +4 -4
- package/dist/components/ui/form/control-protocol.d.ts +38 -1
- package/dist/components/ui/form/form-context.d.ts +3 -0
- package/dist/components/ui/form/form.script.d.ts +7 -0
- package/dist/components/ui/form/index.d.ts +2 -1
- package/dist/components/ui/form/index.js +1 -1
- package/dist/components/ui/form/index.js.map +4 -4
- package/dist/components/ui/hover-card/hover-card.css +12 -101
- package/dist/components/ui/hover-card/hover-card.script.d.ts +7 -0
- package/dist/components/ui/hover-card/index.js +1 -1
- package/dist/components/ui/hover-card/index.js.map +4 -4
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- package/dist/components/ui/input/input.css +1 -1
- package/dist/components/ui/knob/index.js +1 -1
- package/dist/components/ui/knob/index.js.map +3 -3
- package/dist/components/ui/knob/knob.css +6 -1
- package/dist/components/ui/knob/knob.d.ts +1 -1
- package/dist/components/ui/knob/knob.script.d.ts +25 -10
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/listbox/index.js +1 -1
- package/dist/components/ui/listbox/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.d.ts +1 -2
- package/dist/components/ui/listbox/listbox.script.d.ts +7 -5
- package/dist/components/ui/menu-button/index.js +1 -1
- package/dist/components/ui/menu-button/index.js.map +4 -4
- package/dist/components/ui/menu-button/menu-button.script.d.ts +1 -1
- package/dist/components/ui/menubar/index.js +1 -1
- package/dist/components/ui/menubar/index.js.map +4 -4
- package/dist/components/ui/meter/index.js +1 -1
- package/dist/components/ui/meter/index.js.map +3 -3
- package/dist/components/ui/meter/meter.css +27 -2
- package/dist/components/ui/meter/meter.script.d.ts +14 -4
- package/dist/components/ui/navigation-menu/index.d.ts +1 -1
- package/dist/components/ui/navigation-menu/index.js +1 -1
- package/dist/components/ui/navigation-menu/index.js.map +4 -4
- package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +33 -4
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +71 -9
- package/dist/components/ui/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +4 -4
- package/dist/components/ui/number-field/number-field.css +1 -1
- package/dist/components/ui/number-field/number-field.d.ts +1 -1
- package/dist/components/ui/number-field/number-field.script.d.ts +7 -9
- package/dist/components/ui/pagination/index.d.ts +1 -1
- package/dist/components/ui/pagination/index.js +1 -1
- package/dist/components/ui/pagination/index.js.map +3 -3
- package/dist/components/ui/pagination/pagination.css +50 -13
- package/dist/components/ui/pagination/pagination.d.ts +25 -6
- package/dist/components/ui/popover/index.js +1 -1
- package/dist/components/ui/popover/index.js.map +4 -4
- package/dist/components/ui/popover/popover.script.d.ts +5 -0
- package/dist/components/ui/radio-group/index.js +1 -1
- package/dist/components/ui/radio-group/index.js.map +4 -4
- package/dist/components/ui/radio-group/radio-group.script.d.ts +2 -1
- package/dist/components/ui/select/index.d.ts +1 -1
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +4 -4
- package/dist/components/ui/select/select.css +4 -3
- package/dist/components/ui/select/select.d.ts +7 -5
- package/dist/components/ui/select/select.script.d.ts +32 -12
- package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
- package/dist/components/ui/shared/listbox-host-controller.d.ts +5 -4
- package/dist/components/ui/shared/multi-value.d.ts +18 -8
- package/dist/components/ui/shared/numeric-range.d.ts +8 -0
- package/dist/components/ui/shared/popover.css +10 -99
- package/dist/components/ui/sidebar/index.d.ts +2 -1
- package/dist/components/ui/sidebar/index.js +1 -1
- package/dist/components/ui/sidebar/index.js.map +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +42 -29
- package/dist/components/ui/sidebar/sidebar.css +67 -61
- package/dist/components/ui/sidebar/sidebar.d.ts +1 -7
- package/dist/components/ui/sidebar/sidebar.script.d.ts +12 -7
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +4 -4
- package/dist/components/ui/slider/slider.css +5 -5
- package/dist/components/ui/slider/slider.d.ts +5 -6
- package/dist/components/ui/slider/slider.script.d.ts +72 -29
- package/dist/components/ui/switch/index.js +1 -1
- package/dist/components/ui/switch/index.js.map +4 -4
- package/dist/components/ui/switch/switch.css +28 -22
- package/dist/components/ui/switch/switch.script.d.ts +10 -3
- package/dist/components/ui/table/index.js +1 -1
- package/dist/components/ui/table/index.js.map +4 -4
- package/dist/components/ui/table/table.d.ts +5 -3
- package/dist/components/ui/table/table.script.d.ts +25 -10
- package/dist/components/ui/tabs/tabs.css +18 -12
- package/dist/components/ui/tabs/tabs.script.d.ts +7 -0
- package/dist/components/ui/tag-group/index.js +1 -1
- package/dist/components/ui/tag-group/index.js.map +4 -4
- package/dist/components/ui/tag-group/tag-group.d.ts +7 -4
- package/dist/components/ui/tag-group/tag-group.script.d.ts +7 -5
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/components/ui/textarea/textarea.css +1 -1
- package/dist/components/ui/toast/index.js +1 -1
- package/dist/components/ui/toast/index.js.map +3 -3
- package/dist/components/ui/toast/toast.css +35 -32
- package/dist/components/ui/toast/toast.script.d.ts +2 -1
- package/dist/components/ui/toast/toaster.script.d.ts +6 -0
- package/dist/components/ui/tooltip/index.js +1 -1
- package/dist/components/ui/tooltip/index.js.map +4 -4
- package/dist/components/ui/tooltip/tooltip.css +14 -94
- package/dist/components/ui/tooltip/tooltip.script.d.ts +9 -1
- package/dist/components/ui/window-splitter/index.d.ts +1 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +3 -3
- package/dist/components/ui/window-splitter/window-splitter.d.ts +1 -1
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/icons/chevron-down.d.ts +0 -1
- package/dist/lib/intl-date/index.d.ts +4 -2
- package/dist/lib/intl-date/segment-editing.d.ts +34 -0
- package/dist/lib/intl-date/segments.d.ts +26 -4
- package/dist/lib/non-empty.d.ts +6 -0
- package/dist/lib/unique-id.d.ts +11 -0
- package/dist/lib/viewport/breakpoints.d.ts +6 -0
- package/dist/lib/viewport/mobile-layout.d.ts +15 -0
- package/dist/styles/primitives.css +10 -7
- package/dist/styles/radiant-ui-core.css +10 -0
- package/dist/styles/radiant-ui.css +40 -3
- package/dist/styles/style-dependencies.json +18 -6
- package/dist/styles/styles.css +456 -246
- package/dist/styles/tailwind.css +40 -93
- package/dist/styles/tokens/presets/colors/aurora.css +2 -0
- package/dist/styles/tokens/presets/colors/basalt.css +2 -0
- package/dist/styles/tokens/presets/colors/ember.css +2 -0
- package/dist/styles/tokens/presets/colors/glacier.css +2 -0
- package/dist/styles/tokens/semantic.css +1 -0
- package/dist/styles/tokens/system.css +11 -3
- package/dist/styles/tokens/typography/default.css +8 -0
- package/package.json +20 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{RadiantElement as de,customElement as Ne,event as qe,onEvent as y,onUpdated as Ue,prop as T,query as Xe}from"@ecopages/radiant";function Tt(i,t,e="base"){if(!t)return!0;if(e==="case")return i.includes(t);let o=new Intl.Collator(void 0,{sensitivity:e==="accent"?"accent":"base",usage:"search"});for(let n=0;n<=i.length-t.length;n+=1){let r=i.slice(n,n+t.length);if(o.compare(r,t)===0)return!0}return!1}function lt(i){let t=i.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:i.parentElement?.querySelector("[data-rui-field-label]")??null}function Fe(i,t,e){i.id||(i.id=e.labelId),i.htmlFor||(i.htmlFor=e.controlId),t.setAttribute("aria-labelledby",i.id),t.removeAttribute("aria-label")}function kt(i,t,e){if(!t||t.hasAttribute("data-rui-field-managed"))return;let o=lt(i);if(o){Fe(o,t,e);return}if(e.label){t.setAttribute("aria-label",e.label),t.removeAttribute("aria-labelledby");return}t.removeAttribute("aria-label"),t.removeAttribute("aria-labelledby")}var Ee="data-listbox-option-indicator";function L(i){let t=i.getAttribute("data-label");return t||Dt(i).trim()}function M(i){return i.getAttribute("data-value")||L(i)}function Dt(i){if(Le(i))return"";if(i.nodeType===Node.TEXT_NODE)return i.textContent??"";let t="";for(let e of i.childNodes)t+=Dt(e);return t}function Le(i){return i instanceof HTMLElement&&i.hasAttribute(Ee)}function ut(i){return i?ct(i.split(",")):[]}function at(i){return i.join(",")}function X(i){if(i!=null)return typeof i!="string"?at(ct(i)):i}function z(i){return i==null?[]:typeof i!="string"?ct(i):ut(i)}function ct(i){return[...new Set(i.map(t=>t.trim()).filter(Boolean))]}var Q=class{config;constructor(t){this.config=t}getListboxHost(){return this.config.getRoot()?.querySelector("rui-listbox")??null}getListbox(){let t=this.getListboxHost();return t?t.querySelector('[role="listbox"]')??t:this.config.getPopup?.()??null}getOptions(){let t=this.getListbox();return t?Array.from(t.querySelectorAll('[role="option"]')):[]}getSelectedValues(){return ut(this.config.getValue())}setSelectedValues(t){this.config.setValue(at(t))}toggleValue(t){if(this.config.getSelectionMode()==="multiple"){let e=new Set(this.getSelectedValues());e.has(t)?e.delete(t):e.add(t),this.setSelectedValues([...e]);return}this.setSelectedValues([t])}removeValue(t){let e=new Set(this.getSelectedValues());return e.delete(t)?(this.setSelectedValues([...e]),!0):!1}clearValues(){return this.config.getValue()?(this.setSelectedValues([]),!0):!1}findOption(t){return t instanceof Element?t.closest('[role="option"]')??null:null}isSelectableOption(t){return t!=null&&t.getAttribute("aria-disabled")!=="true"&&!t.hidden}syncListboxHost(){let t=this.getListboxHost();t&&(t.embedded=!0,t.selectionMode=this.config.getSelectionMode(),t.value=this.config.getValue())}syncOptionSelection(){let t=new Set(this.getSelectedValues());for(let e of this.getOptions())e.setAttribute("aria-selected",String(t.has(M(e))))}syncMultiselectable(t){if(t){if(this.config.getSelectionMode()==="multiple"){t.setAttribute("aria-multiselectable","true");return}t.removeAttribute("aria-multiselectable")}}getTagGroup(){let t=this.config.tagGroupSelector;if(!t)return null;let e=this.config.getRoot()?.querySelector(t)??null;return!e||typeof e.setItems!="function"?null:e}syncTagGroup(){let t=this.getTagGroup();if(!t)return;let e=this.getSelectedValues().flatMap(o=>{let n=this.getOptions().find(r=>M(r)===o);return n?[{value:o,label:L(n)}]:[]});t.embedded=!0,t.setItems(e),t.value=this.config.getValue()}labelForValue(t){let e=this.getOptions().find(o=>M(o)===t);return e?L(e):t}};var Te={top:"bottom",bottom:"top",left:"right",right:"left"},ke=8;function De(i){let t=i.indexOf("-");if(t===-1)return{side:i,align:"center"};let e=i.slice(0,t),o=i.slice(t+1);return{side:e,align:o==="start"||o==="end"?o:"center"}}function Bt(i){return i==="top"||i==="bottom"?"y":"x"}function Mt(i,t,e,o,n){let{width:r,height:s}=t,l=0,p=0;switch(e){case"top":p=i.top-s-n;break;case"bottom":p=i.bottom+n;break;case"left":l=i.left-r-n;break;case"right":l=i.right+n;break}return Bt(e)==="y"?o==="start"?l=i.left:o==="end"?l=i.right-r:l=i.left+(i.width-r)/2:o==="start"?p=i.top:o==="end"?p=i.bottom-s:p=i.top+(i.height-s)/2,{x:l,y:p}}function Me(i,t,e,o){let{padding:n,width:r,height:s}=o;return e==="top"?Math.max(0,n-i.y):e==="bottom"?Math.max(0,i.y+t.height-(s-n)):e==="left"?Math.max(0,n-i.x):Math.max(0,i.x+t.width-(r-n))}function Pt(i,t,e,o){let{padding:n,width:r,height:s}=o;return e==="top"?i.top-n-t.height:e==="bottom"?s-n-t.height-i.bottom:e==="left"?i.left-n-t.width:r-n-t.width-i.right}function Pe(i,t){return t==="center"?i:`${i}-${t}`}function Be(i,t,e,o){let{padding:n,width:r,height:s}=o;if(Bt(e)==="y"){let p=Math.max(n,r-n-t.width);return{x:Math.min(Math.max(i.x,n),p),y:i.y}}let l=Math.max(n,s-n-t.height);return{x:i.x,y:Math.min(Math.max(i.y,n),l)}}function je(i,t,e,o,n={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:ke}){let{side:r,align:s}=De(e),l=Mt(i,t,r,s,o),p=Me(l,t,r,n),C=r,I=l;if(p>0){let S=Te[r],g=Mt(i,t,S,s,o),G=Pt(i,t,r,n);Pt(i,t,S,n)>G&&(C=S,I=g)}return{coords:Be(I,t,C,n),placement:Pe(C,s)}}function Ke(i,t,e,o,n={}){let{coords:r,placement:s}=je(i.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},e,o);return Object.assign(t.style,{position:"fixed",left:`${r.x}px`,top:`${r.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),n.matchAnchorWidth&&(t.style.width=`${i.offsetWidth}px`),t.setAttribute("data-placement",s),s}function jt({anchor:i,floating:t,getPlacement:e,gap:o,matchAnchorWidth:n}){let r=()=>{t.hidden||Ke(i,t,e(),o,{matchAnchorWidth:n})};r(),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0);let s=new ResizeObserver(r);return s.observe(i),s.observe(t),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0),s.disconnect()}}function Kt(i,t=document.body){let e=i.parentNode;if(!e)return{unmount:()=>{}};let o=document.createComment("rui-portal");return e.insertBefore(o,i),t.appendChild(i),{unmount:()=>{let n=o.parentNode;n&&(n.insertBefore(i,o),o.remove())}}}function pt(i,t,e){return e?!!(i?.contains(e)||t?.contains(e)):!1}function Ht(i,t,e){return e instanceof Node?!pt(i,t,e):!0}function Gt(i,t,e){return!pt(i,t,e)}var Y=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}sync(){let t=this.resolveFloating();if(!t)return;if(!this.config.getOpen()){this.teardown(),t.toggleAttribute("hidden",!0);return}let o=this.config.getAnchor();if(!o)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Kt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=jt({anchor:o,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return pt(this.config.getAnchor(),this.resolveFloating(),t)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let t=this.config.getFloating();return t&&(this.floatingElement=t),t??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function Wt(i){return i.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function $t(i,t,e){return e===0?-1:t===1?i>=e-1?0:i+1:i<=0?e-1:i-1}function ht(i,t){t?.removeAttribute("aria-activedescendant");for(let e of i)e.removeAttribute("data-active")}function Nt(i,t,e,o,n){ht(i,o);let r=t[e];return!r||!o?null:(r.id||(r.id=`${n}-${e}`),r.setAttribute("data-active","true"),o.setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"}),r)}var J=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(t){this.config=t,this.popoverController=new Y({getAnchor:t.getAnchor,getFloating:t.getFloating,getOpen:t.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1,matchAnchorWidth:!0})}get activeOptionIndex(){return this.activeIndex}get hasVisualFocus(){return this.visualFocus}ensureOptionIds(){this.config.getOptions().forEach((t,e)=>{t.id||(t.id=`${this.config.getOptionIdPrefix()}-${e}`)})}getVisibleOptions(){return Wt(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,ht(this.config.getOptions(),this.config.getActiveDescendantHost())}setActiveOption(t){let e=this.getVisibleOptions();if(t<0||t>=e.length){this.clearActiveOption();return}this.activeIndex=t,this.visualFocus=!0,Nt(this.config.getOptions(),e,t,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(t,e){let o=this.getVisibleOptions();if(o.length){if(!this.config.getOpen()){e(t===1?"first":"last");return}if(this.visualFocus){this.setActiveOption($t(this.activeIndex,t,o.length));return}this.setActiveOption(t===1?0:o.length-1)}}handleKeydown(t,e){if(t.ctrlKey||t.shiftKey||t.metaKey)return;this.keydownHandlers[t.key]?.call(this,t,e)}keydownHandlers={ArrowDown:this.handleArrowKey,ArrowUp:this.handleArrowKey,Escape:this.handleEscapeKey,Enter:this.handleActivationKey," ":this.handleActivationKey,Tab:this.handleTabKey};handleArrowKey(t,e){t.preventDefault(),t.stopPropagation();let o=t.key==="ArrowDown"?1:-1;if(t.altKey){this.handleModifiedArrow(o,e);return}this.moveActive(o,n=>e.onOpen(n))}handleModifiedArrow(t,e){t===1&&!e.isOpen&&e.onOpen(),t===-1&&e.isOpen&&e.onClose("arrow")}handleEscapeKey(t,e){t.preventDefault(),e.isOpen?e.onClose("escape"):e.onEscapeWhenClosed?.()}handleActivationKey(t,e){if(!(t.key===" "&&!e.canUseSpace)){if(!e.isOpen&&e.enterWhenClosed==="open"){t.preventDefault(),e.onOpen();return}if(e.isOpen){if(this.hasActiveOption()){t.preventDefault(),e.onSelectActive();return}t.key==="Enter"&&e.enterWithoutActive==="close"&&(t.preventDefault(),e.onClose("enter"))}}}handleTabKey(t,e){e.isOpen&&(this.hasActiveOption()&&e.closesOnTab?e.onSelectActive():e.onClose("tab"))}hasActiveOption(){return this.visualFocus&&!!this.getVisibleOptions()[this.activeIndex]}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(t){return Ht(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return Gt(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};var qt,Ut,Xt,zt,Qt,Yt,Jt,Zt,te,ee,ie,oe,ne,re,se,le,ue,ae,ce,pe;function He(i,t,e,o,n,r){var s,l,p,C,I,S,g,G=Symbol.metadata||Symbol.for("Symbol.metadata"),tt=Object.defineProperty,et=Object.create,Ot=[et(null),et(null)],wt=t.length;function W(u,w,x){return function(c,d){w&&(d=c,c=i);for(var A=0;A<u.length;A++)d=u[A].apply(c,x?[d]:[]);return x?d:c}}function _(u,w,x,c){if(typeof u!="function"&&(c||u!==void 0))throw new TypeError(w+" must "+(x||"be")+" a function"+(c?"":" or undefined"));return u}function At(u,w,x,c,d,A,E,v,R,V,It){function it(b){if(!It(b))throw new TypeError("Attempted to access private element on non-instance")}var ot=[].concat(w[0]),St=w[3],nt=!E,P=d===1,Rt=d===3,Vt=d===4,$=d===2;function N(b,D,Et){return function(U,Lt){return D&&(Lt=U,U=u),Et&&Et(U),f[b].call(U,Lt)}}if(!nt){var f={},rt=[],F=Rt?"get":Vt||P?"set":"value";if(R?(V||P?f={get:he(function(){return St(this)},c,"get"),set:function(b){w[4](this,b)}}:f[F]=St,V||he(f[F],c,$?"":F)):V||(f=Object.getOwnPropertyDescriptor(u,c)),!V&&!R){if((l=Ot[+v][c])&&(l^d)!==7)throw Error("Decorating two elements with the same name ("+f[F].name+") is not supported yet");Ot[+v][c]=d<3?1:d}}for(var m=u,q=ot.length-1;q>=0;q-=x?2:1){var _t=_(ot[q],"A decorator","be",!0),Ft=x?ot[q-1]:void 0,st={},B={kind:["field","accessor","method","getter","setter","class"][d],name:c,metadata:s,addInitializer:function(b,D){if(b.v)throw new TypeError("attempted to call addInitializer after decoration was finished");_(D,"An initializer","be",!0),A.push(D)}.bind(null,st)};if(nt)l=_t.call(Ft,m,B),st.v=1,_(l,"class decorators","return")&&(m=l);else if(B.static=v,B.private=R,l=B.access={has:R?It.bind():function(b){return c in b}},Vt||(l.get=R?$?function(b){return it(b),f.value}:N("get",0,it):function(b){return b[c]}),$||Rt||(l.set=R?N("set",0,it):function(b,D){b[c]=D}),m=_t.call(Ft,P?{get:f.get,set:f.set}:f[F],B),st.v=1,P){if(typeof m=="object"&&m)(l=_(m.get,"accessor.get"))&&(f.get=l),(l=_(m.set,"accessor.set"))&&(f.set=l),(l=_(m.init,"accessor.init"))&&rt.unshift(l);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else _(m,(V?"field":"method")+" decorators","return")&&(V?rt.unshift(m):f[F]=m)}return d<2&&E.push(W(rt,v,1),W(A,v,0)),V||nt||(R?P?E.splice(-1,0,N("get",v),N("set",v)):E.push($?f[F]:_.call.bind(f[F])):tt(u,c,f)),m}function Ct(u){return tt(u,G,{configurable:!0,enumerable:!0,value:s})}return r!==void 0&&(s=r[G]),s=et(s??null),I=[],S=function(u){u&&I.push(W(u))},g=function(u,w){for(var x=0;x<e.length;x++){var c=e[x],d=c[1],A=7&d;if((8&d)==u&&!A==w){var E=c[2],v=!!c[3],R=16&d;At(u?i:i.prototype,c,R,v?"#"+E:Ge(E),A,A<2?[]:u?C=C||[]:p=p||[],I,!!u,v,w,u&&v?function(V){return $e(V)===i}:n)}}},g(8,0),g(0,0),g(8,1),g(0,1),S(p),S(C),l=I,wt||Ct(i),{e:l,get c(){var u=[];return wt&&[Ct(i=At(i,[t],o,i.name,5,u)),W(u,1)]}}}function Ge(i){var t=We(i,"string");return typeof t=="symbol"?t:t+""}function We(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var o=e.call(i,t||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function he(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function $e(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}var be,fe=class extends de{static{({e:[Xt,zt,Qt,Yt,Jt,Zt,te,ee,ie,oe,ne,re,se,le,ue,ae,ce,pe,qt],c:[be,Ut]}=He(this,[Ne("rui-combobox")],[[T({type:String,reflect:!0,defaultValue:""}),0,"value"],[T({type:String,defaultValue:""}),0,"label"],[T({type:String,defaultValue:""}),0,"placeholder"],[T({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[T({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[T({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[T({type:String,attribute:"trigger-kind",reflect:!0,defaultValue:"input"}),0,"triggerKind"],[qe({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Xe({ref:"root"}),0,"rootTarget"],[Ue(["value","label","placeholder","disabled","triggerKind","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[y({ref:"root",type:"focusin"}),2,"onRootFocusIn"],[y({ref:"root",type:"input"}),2,"onRootInput"],[y({ref:"root",type:"keydown",options:{capture:!0}}),2,"onRootKeydown"],[y({selector:"[data-combobox-trigger]",type:"click"}),2,"onTriggerClick"],[y({selector:'[data-combobox-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[y({selector:'[data-combobox-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[y({selector:'[data-combobox-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[y({selector:"[data-combobox-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[y({selector:"[data-combobox-clear]",type:"click"}),2,"onClearClick"],[y({ref:"root",type:"focusout"}),2,"onFocusOut"],[y({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,de))}constructor(...t){super(...t),pe(this)}value=(qt(this),Xt(this));label=(zt(this),Qt(this));placeholder=(Yt(this),Jt(this));disabled=(Zt(this),te(this));selectionMode=(ee(this),ie(this));shouldCloseOnSelect=(oe(this),ne(this));triggerKind=(re(this),se(this));changeEvent=(le(this),ue(this));open=(ae(this),!1);skipNextFocusOpen=!1;uid=Math.random().toString(36).slice(2,9);collection=new Q({getRoot:()=>this,getSelectionMode:()=>this.selectionMode,getValue:()=>this.value,setValue:t=>{this.value=t},getPopup:()=>this.getListboxPopup(),tagGroupSelector:"[data-combobox-value] rui-tag-group"});listboxBehavior=new J({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.collection.getOptions(),getActiveDescendantHost:()=>this.getInput(),getOptionIdPrefix:()=>`rui-combobox-option-${this.uid}`});rootTarget=ce(this);get listboxId(){return`rui-combobox-list-${this.uid}`}get inputId(){return`rui-combobox-input-${this.uid}`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect??!this.isMultiple()}getInput(){return this.querySelector("[data-combobox-input]")}getTrigger(){return this.querySelector("[data-combobox-trigger]")}getClear(){return this.querySelector("[data-combobox-clear]")}getListboxPopup(){return this.querySelector("[data-combobox-listbox]")}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return lt(this)?.textContent?.trim()||this.label||"Suggestions"}isComboboxInput(t){return t instanceof HTMLElement&&t.localName==="input"&&t.hasAttribute("data-combobox-input")}syncLabel(){let t=this.getInput();kt(this,t,{controlId:this.inputId,label:this.label,labelId:`rui-combobox-label-${this.uid}`})}syncTrigger(){let t=this.getTrigger(),e=this.collection.getListbox();!t||!e||(t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",e.id||this.listboxId),t.tabIndex=-1,this.disabled&&(t.disabled=!0))}syncInput(){let t=this.getInput(),e=this.collection.getListbox(),o=this.getListboxPopup();!t||!e||(t.id||(t.id=this.inputId),e.id||(e.id=this.listboxId),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",this.listboxId),e.setAttribute("aria-label",this.getAccessibleName()),this.collection.syncMultiselectable(e),o&&(o.removeAttribute("role"),o.removeAttribute("aria-label")),this.placeholder&&(t.placeholder=this.isMultiple()&&this.collection.getSelectedValues().length?"":this.placeholder),this.disabled&&(t.disabled=!0),this.syncClear(),this.syncTrigger())}syncClear(){let t=this.getClear();t&&(t.hidden=this.collection.getSelectedValues().length===0&&!(this.getInput()?.value??""),t.disabled=this.disabled)}setVisualFocusCombobox(){this.listboxBehavior.clearActiveOption(),this.collection.syncOptionSelection()}setOpen(t,e={}){let o=e.activate??"none";this.open=t;let n=this.getInput(),r=this.getListboxPopup();if(!(!n||!r)){if(n.setAttribute("aria-expanded",String(t)),r.toggleAttribute("hidden",!t),this.syncTrigger(),!t){this.listboxBehavior.clearActiveOption(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.listboxBehavior.syncPopoverPosition(),o==="first"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?0:-1);return}if(o==="last"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?s.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}getAutocomplete(){return this.querySelector("rui-autocomplete")}syncAutocompleteFilter(){let t=this.getAutocomplete();if(t){t.syncFilter();return}let e=this.getInput()?.value??"";for(let o of this.collection.getOptions()){let n=Tt(L(o),e,"base");o.hidden=e.trim()!==""&&!n}}showAllOptions(){for(let t of this.collection.getOptions())t.hidden=!1}syncFilter(){this.syncAutocompleteFilter()}select(t){if(!this.collection.isSelectableOption(t))return;let e=M(t),o=L(t)||e;this.collection.toggleValue(e);let n=this.getInput();n&&(n.value=this.isMultiple()?"":o),this.collection.syncTagGroup(),this.syncInput(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&(this.skipNextFocusOpen=!0,this.setOpen(!1)),this.syncFilter(),n?.focus()}syncFromValue(){let t=this.getInput();if(!t)return;if(this.isMultiple()){t.value="";return}let e=this.collection.getSelectedValues()[0]??"";t.value=e?this.collection.labelForValue(e):""}removeSelectedValue(t){this.collection.removeValue(t)&&(this.collection.syncTagGroup(),this.syncInput(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.getInput()?.focus())}clearSelection(){let t=this.getInput(),e=this.value!=="",o=!!t?.value;this.collection.clearValues(),t&&(t.value=""),this.syncFilter(),this.syncInput(),this.collection.syncTagGroup(),this.collection.syncOptionSelection(),e&&this.changeEvent.emit({value:""}),(o||e)&&t?.focus()}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncInput(),this.collection.syncListboxHost(),this.syncFromValue(),this.collection.syncOptionSelection(),this.collection.syncTagGroup(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.collection.syncListboxHost(),this.syncFromValue(),this.collection.syncOptionSelection(),this.collection.syncTagGroup()}onRootFocusIn(t){if(this.isComboboxInput(t.target)){if(this.skipNextFocusOpen){this.skipNextFocusOpen=!1;return}this.triggerKind==="focus"&&(this.syncFilter(),this.setOpen(!0),this.setVisualFocusCombobox())}}onRootInput(t){if(!this.isComboboxInput(t.target))return;let e=t.target;this.syncFilter();let o=e.value.trim()!=="",n=this.listboxBehavior.getVisibleOptions().length>0;o&&n&&(this.open||this.triggerKind!=="manual")?this.setOpen(!0):!o&&this.triggerKind==="focus"?this.setOpen(!0):(!o||!n)&&this.setOpen(!1),this.setVisualFocusCombobox()}onRootKeydown(t){this.isComboboxInput(t.target)&&this.handleInputKeydown(t)}handleInputKeydown(t){if(t.key==="Home"){let e=this.getInput();if(!e)return;t.preventDefault(),e.setSelectionRange(0,0),this.setVisualFocusCombobox();return}if(t.key==="End"){let e=this.getInput();if(!e)return;t.preventDefault();let o=e.value.length;e.setSelectionRange(o,o),this.setVisualFocusCombobox();return}(t.key==="ArrowDown"||t.key==="ArrowUp")&&(this.syncFilter(),this.listboxBehavior.getVisibleOptions().length||this.showAllOptions()),this.listboxBehavior.handleKeydown(t,{isOpen:this.open,canUseSpace:!1,closesOnTab:!0,enterWhenClosed:"ignore",enterWithoutActive:"close",onOpen:(e="none")=>{this.syncFilter(),this.setOpen(!0,{activate:e})},onClose:()=>this.setOpen(!1),onSelectActive:()=>{let e=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];e&&this.select(e)},onEscapeWhenClosed:()=>{let e=this.getInput();e&&e.value&&(e.value="",this.value="",this.changeEvent.emit({value:""}),this.syncFilter())}})}onTriggerClick(t){t.preventDefault();let e=this.getInput();!e||e.disabled||(this.open?(this.skipNextFocusOpen=!0,this.setOpen(!1)):(this.syncFilter(),this.setOpen(!0),this.setVisualFocusCombobox()),e.focus())}onOptionPointerOver(t){if(!this.open)return;let e=this.collection.findOption(t.target);if(!this.collection.isSelectableOption(e))return;let n=this.listboxBehavior.getVisibleOptions().indexOf(e);n>=0&&this.listboxBehavior.setActiveOption(n)}onOptionMouseDown(t){t.preventDefault()}onOptionClick(t){let e=this.collection.findOption(t.target);e&&this.select(e)}onTagRemove(t){let e=t.detail;e?.value&&this.removeSelectedValue(e.value)}onClearClick(t){t.preventDefault(),t.stopPropagation(),this.clearSelection()}onFocusOut(t){this.listboxBehavior.shouldDismissFocus(t.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(t){this.open&&this.listboxBehavior.shouldDismissPointer(t.target)&&this.setOpen(!1)}static{Ut()}};import{jsx as h,jsxs as yt}from"@ecopages/jsx/jsx-runtime";function j(i,t){return t===void 0||i?.label!==void 0?i:{...i,label:t}}function a(...i){return i.filter(Boolean).join(" ")}import{jsx as ge}from"@ecopages/jsx/jsx-runtime";function dt({class:i,size:t="sm",...e}){return ge("svg",{...e,class:a("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:ge("path",{d:"m5 12 4 4L19 6"})})}import{jsx as me}from"@ecopages/jsx/jsx-runtime";function ft({class:i,size:t="sm",...e}){return me("svg",{...e,class:a("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:me("path",{d:"m6 9 6 6 6-6"})})}import{jsx as xe,jsxs as ze}from"@ecopages/jsx/jsx-runtime";function K({class:i,size:t="sm",...e}){return ze("svg",{...e,class:a("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[xe("path",{d:"m18 6-12 12"}),xe("path",{d:"m6 6 12 12"})]})}import{jsx as H}from"@ecopages/jsx/jsx-runtime";function bt({children:i,class:t,...e}){return H("div",{...e,"data-autocomplete-collection":!0,class:a("rui-autocomplete__collection",t),children:i})}function gt({children:i,class:t,...e}){return H("div",{...e,"data-autocomplete-empty":!0,class:a("rui-autocomplete__empty",t),children:i})}function Qe({children:i}){return H("div",{class:"rui-autocomplete","data-ref":"root",children:i})}function mt({children:i,...t}){return H("rui-autocomplete",{...t,children:H(Qe,{children:i})})}import{jsx as k,jsxs as Ye}from"@ecopages/jsx/jsx-runtime";function xt({value:i,label:t,children:e,class:o,disabled:n,...r}){return k("div",{...r,class:a("rui-listbox__option",o),role:"option","data-value":i,"data-label":t,"aria-disabled":n?"true":void 0,tabindex:-1,children:e})}function ve({children:i,class:t,...e}){return k("span",{...e,"data-listbox-option-indicator":!0,"aria-hidden":"true",class:a("rui-listbox__option-indicator",t),children:i??k(dt,{})})}function Je(i,t){return t??!i}function Ze({bordered:i,children:t,disabled:e,label:o,selectionMode:n="single"}){return k("div",{class:a("rui-listbox",i&&"rui-listbox--bordered"),role:"listbox","data-rui-control":!0,"data-rui-control-type":"text","aria-label":o||void 0,"aria-disabled":e?"true":void 0,"aria-multiselectable":n==="multiple"?"true":void 0,children:t})}function Z({options:i,children:t,value:e,embedded:o,bordered:n,label:r,disabled:s,selectionMode:l="single",...p}){let C=Je(o,n),I=X(e),S=new Set(z(e));return k("rui-listbox",{...p,value:I,embedded:o,bordered:n,label:r,disabled:s,selectionMode:l,children:k(Ze,{bordered:C,disabled:s,label:r,selectionMode:l,children:i!=null?i.map(g=>Ye(xt,{value:g.value,label:typeof g.label=="string"?g.label:void 0,disabled:g.disabled,"aria-selected":S.has(g.value)?"true":void 0,children:[g.label,l==="multiple"?k(ve,{}):null]})):t})})}import{jsx as O,jsxs as ti}from"@ecopages/jsx/jsx-runtime";function Oe({children:i,class:t,...e}){return O("div",{...e,"data-tag-list":!0,class:a("rui-tag-group__list",t),children:i})}function we({value:i,label:t,children:e,class:o,disabled:n,...r}){return ti("span",{...r,"data-tag":!0,"data-value":i,"data-label":t,class:a("rui-tag",o),"aria-disabled":n?"true":void 0,children:[e,O(Ae,{})]})}function Ae({children:i,class:t,aria:e,...o}){return O("button",{...o,aria:j(e,"Remove"),type:"button","data-tag-remove":!0,class:a("rui-tag__remove",t),children:i??O(K,{})})}function ye({children:i}){return O("div",{class:"rui-tag-group","data-ref":"root",children:i})}function vt({tags:i,children:t,...e}){return i!=null?O("rui-tag-group",{...e,children:O(ye,{children:O(Oe,{children:i.map(o=>O(we,{value:o.value,label:typeof o.label=="string"?o.label:void 0,disabled:o.disabled,children:o.label}))})})}):O("rui-tag-group",{...e,children:O(ye,{children:t})})}function Ie({children:i,class:t,...e}){return h("div",{...e,class:a("rui-combobox__control",t),children:i})}function Se({placeholder:i,disabled:t,class:e,...o}){return h("input",{...o,type:"text","data-combobox-input":!0,"data-autocomplete-input":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:a("rui-combobox__input",e),placeholder:i,disabled:t,autocomplete:"off"})}function Re({children:i,class:t,aria:e,disabled:o,...n}){return h("button",{...n,aria:j(e,"Show suggestions"),type:"button","data-combobox-trigger":!0,class:a("rui-control-toggle",t),disabled:o,tabIndex:-1,children:i??h(ft,{})})}function ei({children:i,class:t,aria:e,disabled:o,...n}){return h("button",{...n,aria:j(e,"Clear selection"),type:"button","data-combobox-clear":!0,class:a("rui-control-clear",t),disabled:o,children:i??h(K,{})})}function Ve({children:i,class:t,...e}){return h("span",{...e,"data-combobox-value":!0,class:a("rui-combobox__value",t),children:i})}function _e({children:i,class:t,...e}){return h("div",{...e,"data-combobox-listbox":!0,class:a("rui-combobox__listbox rui-popover rui-popover--listbox rui-floating",t),children:i})}function Ce({children:i}){return h("div",{class:"rui-combobox","data-ref":"root",children:i})}function ii({options:i,children:t,value:e,...o}){let n=X(e),r=z(e),s=i?.filter(p=>r.includes(p.value)).map(p=>({value:p.value,label:p.label})),l=o.selectionMode==="multiple";return i!=null?h("rui-combobox",{...o,value:n,children:yt(Ce,{children:[yt(Ie,{children:[l?h(Ve,{children:h(vt,{tags:s??[],label:"Selected options"})}):null,h(Se,{placeholder:o.placeholder,disabled:o.disabled}),h(Re,{})]}),h(_e,{children:h(mt,{children:yt(bt,{children:[h(Z,{embedded:!0,options:i,selectionMode:o.selectionMode,value:n}),h(gt,{children:"No results found."})]})})})]})}):h("rui-combobox",{...o,value:n,children:h(Ce,{children:t})})}export{ii as RuiCombobox,ei as RuiComboboxClear,Ie as RuiComboboxControl,be as RuiComboboxElement,Se as RuiComboboxInput,_e as RuiComboboxListbox,Re as RuiComboboxTrigger,Ve as RuiComboboxValue,Z as RuiListbox,xt as RuiListboxOption};
|
|
1
|
+
import{RadiantElement as xe,bindTo as sn,customElement as ln,event as an,onEvent as ot,onUpdated as un,prop as at,query as cn}from"@ecopages/radiant";function gt(e,t,i="base"){if(!t)return!0;if(i==="case")return e.includes(t);let n=new Intl.Collator(void 0,{sensitivity:i==="accent"?"accent":"base",usage:"search"});for(let o=0;o<=e.length-t.length;o+=1){let u=e.slice(o,o+t.length);if(n.compare(u,t)===0)return!0}return!1}var Ki=/^[A-Za-z][A-Za-z0-9_-]*$/;function Bt(e){return Ki.test(e)}function qi(e){let t=e.trim();if(Bt(t))return t;let i=`rui-${t}`;return t&&Bt(i)?i:"rui"}function ct(e){let t=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),i=>i.toString(16).padStart(2,"0")).join("");return`${qi(e)}-${t}`}function It(e){let t=e.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:e.parentElement?.querySelector("[data-rui-field-label]")??null}function $i(e,t,i){e.id||(e.id=i.labelId),e.htmlFor||(e.htmlFor=i.controlId),t.setAttribute("aria-labelledby",e.id),t.removeAttribute("aria-label")}function vt(e,t,i){if(!t||t.hasAttribute("data-rui-field-managed"))return;let n=It(e);if(n){$i(n,t,i);return}if(i.label){t.setAttribute("aria-label",i.label),t.removeAttribute("aria-labelledby");return}t.removeAttribute("aria-label"),t.removeAttribute("aria-labelledby")}var Wi="data-listbox-option-indicator";function lt(e){let t=e.getAttribute("data-label");return t||Pt(e).trim()}function st(e){return e.getAttribute("data-value")||lt(e)}function Pt(e){if(Ui(e))return"";if(e.nodeType===Node.TEXT_NODE)return e.textContent??"";let t="";for(let i of e.childNodes)t+=Pt(i);return t}function Ui(e){return e instanceof HTMLElement&&e.hasAttribute(Wi)}var yt=class{config;constructor(t){this.config=t}getListboxHost(){return this.config.getRoot()?.querySelector("rui-listbox")??null}getListbox(){let t=this.getListboxHost();return t?t.querySelector('[role="listbox"]')??t:this.config.getPopup?.()??null}getOptions(){let t=this.getListbox();return t?Array.from(t.querySelectorAll('[role="option"]')):[]}getSelectedValues(){return this.config.getValue()}setSelectedValues(t){this.config.setValue(t)}toggleValue(t){if(this.config.getSelectionMode()==="multiple"){let i=new Set(this.getSelectedValues());i.has(t)?i.delete(t):i.add(t),this.setSelectedValues([...i]);return}this.setSelectedValues([t])}removeValue(t){let i=new Set(this.getSelectedValues());return i.delete(t)?(this.setSelectedValues([...i]),!0):!1}clearValues(){return this.getSelectedValues().length===0?!1:(this.setSelectedValues([]),!0)}findOption(t){return t instanceof Element?t.closest('[role="option"]')??null:null}isSelectableOption(t){return t!=null&&t.getAttribute("aria-disabled")!=="true"&&!t.hidden}syncListboxHost(){let t=this.getListboxHost();t&&(t.embedded=!0,t.selectionMode=this.config.getSelectionMode(),t.value=this.config.getValue())}syncOptionSelection(){let t=new Set(this.getSelectedValues());for(let i of this.getOptions())i.setAttribute("aria-selected",String(t.has(st(i))))}syncMultiselectable(t){if(t){if(this.config.getSelectionMode()==="multiple"){t.setAttribute("aria-multiselectable","true");return}t.removeAttribute("aria-multiselectable")}}getTagGroup(){let t=this.config.tagGroupSelector;if(!t)return null;let i=this.config.getRoot()?.querySelector(t)??null;return!i||typeof i.setItems!="function"?null:i}syncTagGroup(){let t=this.getTagGroup();if(!t)return;let i=this.getSelectedValues().flatMap(n=>{let o=this.getOptions().find(u=>st(u)===n);return o?[{value:n,label:lt(o)}]:[]});t.embedded=!0,t.setItems(i),t.value=this.config.getValue()}labelForValue(t){let i=this.getOptions().find(n=>st(n)===t);return i?lt(i):t}};var Gi={top:"bottom",bottom:"top",left:"right",right:"left"},zi=8,Ot=new WeakMap;function Hi(e){Ot.has(e)&&(e.style.width="",e.style.minWidth="",e.style.maxWidth="",e.style.boxSizing="",Ot.delete(e))}function Xi(e){let t=e.indexOf("-");if(t===-1)return{side:e,align:"center"};let i=e.slice(0,t),n=e.slice(t+1);return{side:i,align:n==="start"||n==="end"?n:"center"}}function $t(e){return e==="top"||e==="bottom"?"y":"x"}function Kt(e,t,i,n,o){let{width:u,height:c}=t,s=0,x=0;switch(i){case"top":x=e.top-c-o;break;case"bottom":x=e.bottom+o;break;case"left":s=e.left-u-o;break;case"right":s=e.right+o;break}return $t(i)==="y"?n==="start"?s=e.left:n==="end"?s=e.right-u:s=e.left+(e.width-u)/2:n==="start"?x=e.top:n==="end"?x=e.bottom-c:x=e.top+(e.height-c)/2,{x:s,y:x}}function Qi(e,t,i,n){let{padding:o,width:u,height:c}=n;return i==="top"?Math.max(0,o-e.y):i==="bottom"?Math.max(0,e.y+t.height-(c-o)):i==="left"?Math.max(0,o-e.x):Math.max(0,e.x+t.width-(u-o))}function qt(e,t,i,n){let{padding:o,width:u,height:c}=n;return i==="top"?e.top-o-t.height:i==="bottom"?c-o-t.height-e.bottom:i==="left"?e.left-o-t.width:u-o-t.width-e.right}function Zi(e,t){return t==="center"?e:`${e}-${t}`}function Yi(e,t,i,n){let{padding:o,width:u,height:c}=n;if($t(i)==="y"){let x=Math.max(o,u-o-t.width);return{x:Math.min(Math.max(e.x,o),x),y:Math.max(o,e.y)}}let s=Math.max(o,c-o-t.height);return{x:Math.max(o,e.x),y:Math.min(Math.max(e.y,o),s)}}function Ji(e,t,i,n,o={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:zi}){let{side:u,align:c}=Xi(i),s=Kt(e,t,u,c,n),x=Qi(s,t,u,o),I=u,C=s;if(x>0){let R=Gi[u],A=Kt(e,t,R,c,n),U=qt(e,t,u,o);qt(e,t,R,o)>U&&(I=R,C=A)}return{coords:Yi(C,t,I,o),placement:Zi(I,c)}}function Ni(e,t,i,n,o={}){let u=o.matchAnchorWidth===!0,c=e.offsetWidth,s=u?{width:c,height:t.offsetHeight}:{width:t.offsetWidth,height:t.offsetHeight};u?(t.style.width=`${c}px`,t.style.minWidth=`${c}px`,t.style.maxWidth=`${c}px`,t.style.boxSizing="border-box",Ot.set(t,!0)):Hi(t);let{coords:x,placement:I}=Ji(e.getBoundingClientRect(),s,i,n);return Object.assign(t.style,{position:"fixed",left:`${x.x}px`,top:`${x.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),t.setAttribute("data-placement",I),I}function Wt({anchor:e,floating:t,getPlacement:i,gap:n,matchAnchorWidth:o}){let u=()=>{t.hidden||Ni(e,t,i(),n,{matchAnchorWidth:o})};u(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0);let c=new ResizeObserver(u);return c.observe(e),c.observe(t),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),c.disconnect()}}function Ut(e,t=document.body){let i=e.parentNode;if(!i)return{unmount:()=>{}};let n=document.createComment("rui-portal");return i.insertBefore(n,e),t.appendChild(e),{unmount:()=>{let o=n.parentNode;o&&(o.insertBefore(e,n),n.remove())}}}function Ct(e,t,i){return i?!!(e?.contains(i)||t?.contains(i)):!1}function Gt(e,t,i){return i instanceof Node?!Ct(e,t,i):!0}function zt(e,t,i){return!Ct(e,t,i)}var xt=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}sync(){let t=this.resolveFloating();if(!t)return;if(!this.config.getOpen()){this.teardown(),t.toggleAttribute("hidden",!0);return}let n=this.config.getAnchor();if(!n)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Ut(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Wt({anchor:n,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return Ct(this.config.getAnchor(),this.resolveFloating(),t)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let t=this.config.getFloating();return t&&(this.floatingElement=t),t??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function Ht(e){return e.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function Xt(e,t,i){return i===0?-1:t===1?e>=i-1?0:e+1:e<=0?i-1:e-1}function Et(e,t){t?.removeAttribute("aria-activedescendant");for(let i of e)i.removeAttribute("data-active")}function Qt(e,t,i,n,o){Et(e,n);let u=t[i];return!u||!n?null:(u.id||(u.id=`${o}-${i}`),u.setAttribute("data-active","true"),n.setAttribute("aria-activedescendant",u.id),u.scrollIntoView({block:"nearest"}),u)}var wt=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(t){this.config=t,this.popoverController=new xt({getAnchor:t.getAnchor,getFloating:t.getFloating,getOpen:t.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1,matchAnchorWidth:!0})}get activeOptionIndex(){return this.activeIndex}get hasVisualFocus(){return this.visualFocus}ensureOptionIds(){this.config.getOptions().forEach((t,i)=>{t.id||(t.id=`${this.config.getOptionIdPrefix()}-${i}`)})}getVisibleOptions(){return Ht(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,Et(this.config.getOptions(),this.config.getActiveDescendantHost())}setActiveOption(t){let i=this.getVisibleOptions();if(t<0||t>=i.length){this.clearActiveOption();return}this.activeIndex=t,this.visualFocus=!0,Qt(this.config.getOptions(),i,t,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(t,i){let n=this.getVisibleOptions();if(n.length){if(!this.config.getOpen()){i(t===1?"first":"last");return}if(this.visualFocus){this.setActiveOption(Xt(this.activeIndex,t,n.length));return}this.setActiveOption(t===1?0:n.length-1)}}handleKeydown(t,i){if(t.ctrlKey||t.shiftKey||t.metaKey)return;this.keydownHandlers[t.key]?.call(this,t,i)}keydownHandlers={ArrowDown:this.handleArrowKey,ArrowUp:this.handleArrowKey,Escape:this.handleEscapeKey,Enter:this.handleActivationKey," ":this.handleActivationKey,Tab:this.handleTabKey};handleArrowKey(t,i){t.preventDefault(),t.stopPropagation();let n=t.key==="ArrowDown"?1:-1;if(t.altKey){this.handleModifiedArrow(n,i);return}this.moveActive(n,o=>i.onOpen(o))}handleModifiedArrow(t,i){t===1&&!i.isOpen&&i.onOpen(),t===-1&&i.isOpen&&i.onClose("arrow")}handleEscapeKey(t,i){t.preventDefault(),i.isOpen?i.onClose("escape"):i.onEscapeWhenClosed?.()}handleActivationKey(t,i){if(!(t.key===" "&&!i.canUseSpace)){if(!i.isOpen&&i.enterWhenClosed==="open"){t.preventDefault(),i.onOpen();return}if(i.isOpen){if(this.hasActiveOption()){t.preventDefault(),i.onSelectActive();return}t.key==="Enter"&&i.enterWithoutActive==="close"&&(t.preventDefault(),i.onClose("enter"))}}}handleTabKey(t,i){i.isOpen&&(this.hasActiveOption()&&i.closesOnTab?i.onSelectActive():i.onClose("tab"))}hasActiveOption(){return this.visualFocus&&!!this.getVisibleOptions()[this.activeIndex]}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(t){return Gt(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return zt(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};function Zt(e){return e?Jt(e.split(",")):[]}function tn(e){return e.join(",")}var Yt={fromAttribute:e=>Zt(e),toAttribute:e=>e.length>0?tn(e):null,fromProperty:e=>Array.isArray(e)?Jt(e.map(String)):typeof e=="string"?Zt(e):[]},dt={type:Array,reflect:!0,transform:Yt};function _t(e){return Yt.fromProperty?.(e)??[]}function Jt(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}var Nt,te,ee,ie,ne,oe,re,se,le,ae,ue,ce,de,he,pe,fe,me,be,ge,ve;function en(e,t,i,n,o,u){var c,s,x,I,C,R,A,U=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,B=Object.create,z=[B(null),B(null)],H=t.length;function D(r,b,f){return function(l,a){b&&(a=l,l=e);for(var g=0;g<r.length;g++)a=r[g].apply(l,f?[a]:[]);return f?a:l}}function w(r,b,f,l){if(typeof r!="function"&&(l||r!==void 0))throw new TypeError(b+" must "+(f||"be")+" a function"+(l?"":" or undefined"));return r}function X(r,b,f,l,a,g,S,m,v,y,Z){function P(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var K=[].concat(b[0]),Y=b[3],q=!S,T=a===1,J=a===3,N=a===4,M=a===2;function k(h,O,it){return function(F,nt){return O&&(nt=F,F=r),it&&it(F),d[h].call(F,nt)}}if(!q){var d={},$=[],_=J?"get":N||T?"set":"value";if(v?(y||T?d={get:ye(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||ye(d[_],l,M?"":_)):y||(d=Object.getOwnPropertyDescriptor(r,l)),!y&&!v){if((s=z[+m][l])&&(s^a)!==7)throw Error("Decorating two elements with the same name ("+d[_].name+") is not supported yet");z[+m][l]=a<3?1:a}}for(var p=r,j=K.length-1;j>=0;j-=f?2:1){var tt=w(K[j],"A decorator","be",!0),et=f?K[j-1]:void 0,W={},V={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,O){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(O,"An initializer","be",!0),g.push(O)}.bind(null,W)};if(q)s=tt.call(et,p,V),W.v=1,w(s,"class decorators","return")&&(p=s);else if(V.static=m,V.private=v,s=V.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?M?function(h){return P(h),d.value}:k("get",0,P):function(h){return h[l]}),M||J||(s.set=v?k("set",0,P):function(h,O){h[l]=O}),p=tt.call(et,T?{get:d.get,set:d.set}:d[_],V),W.v=1,T){if(typeof p=="object"&&p)(s=w(p.get,"accessor.get"))&&(d.get=s),(s=w(p.set,"accessor.set"))&&(d.set=s),(s=w(p.init,"accessor.init"))&&$.unshift(s);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(y?"field":"method")+" decorators","return")&&(y?$.unshift(p):d[_]=p)}return a<2&&S.push(D($,m,1),D(g,m,0)),y||q||(v?T?S.splice(-1,0,k("get",m),k("set",m)):S.push(M?d[_]:w.call.bind(d[_])):G(r,l,d)),p}function Q(r){return G(r,U,{configurable:!0,enumerable:!0,value:c})}return u!==void 0&&(c=u[U]),c=B(c??null),C=[],R=function(r){r&&C.push(D(r))},A=function(r,b){for(var f=0;f<i.length;f++){var l=i[f],a=l[1],g=7&a;if((8&a)==r&&!g==b){var S=l[2],m=!!l[3],v=16&a;X(r?e:e.prototype,l,v,m?"#"+S:nn(S),g,g<2?[]:r?I=I||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return rn(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(I),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),D(r,1)]}}}function nn(e){var t=on(e,"string");return typeof t=="symbol"?t:t+""}function on(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ye(e,t,i){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:i?i+" "+t:t})}catch{}return e}function rn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var _e,we=class extends xe{static{({e:[ee,ie,ne,oe,re,se,le,ae,ue,ce,de,he,pe,fe,me,be,ge,ve,Nt],c:[_e,te]}=en(this,[ln("rui-combobox")],[[at({...dt,defaultValue:[]}),0,"value"],[at({type:String,defaultValue:""}),0,"label"],[at({type:String,defaultValue:""}),0,"placeholder"],[[at({type:Boolean,reflect:!0,defaultValue:!1}),sn({selector:"[data-combobox-clear]",prop:"disabled"})],0,"disabled"],[at({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[at({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[at({type:String,attribute:"trigger-kind",reflect:!0,defaultValue:"input"}),0,"triggerKind"],[an({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[cn({ref:"root"}),0,"rootTarget"],[un(["value","label","placeholder","disabled","triggerKind","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[ot({ref:"root",type:"focusin"}),2,"onRootFocusIn"],[ot({ref:"root",type:"input"}),2,"onRootInput"],[ot({ref:"root",type:"keydown",options:{capture:!0}}),2,"onRootKeydown"],[ot({selector:"[data-combobox-trigger]",type:"click"}),2,"onTriggerClick"],[ot({selector:'[data-combobox-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[ot({selector:'[data-combobox-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[ot({selector:'[data-combobox-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[ot({selector:"[data-combobox-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[ot({selector:"[data-combobox-clear]",type:"click"}),2,"onClearClick"],[ot({ref:"root",type:"focusout"}),2,"onFocusOut"],[ot({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,xe))}constructor(...t){super(...t),ve(this)}value=(Nt(this),ee(this));label=(ie(this),ne(this));placeholder=(oe(this),re(this));disabled=(se(this),le(this));selectionMode=(ae(this),ue(this));shouldCloseOnSelect=(ce(this),de(this));triggerKind=(he(this),pe(this));changeEvent=(fe(this),me(this));open=(be(this),!1);uid=ct("rui-combobox");collection=new yt({getRoot:()=>this,getSelectionMode:()=>this.selectionMode,getValue:()=>this.value,setValue:t=>{this.value=t},getPopup:()=>this.getListboxPopup(),tagGroupSelector:"[data-combobox-value] rui-tag-group"});listboxBehavior=new wt({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.collection.getOptions(),getActiveDescendantHost:()=>this.getInput(),getOptionIdPrefix:()=>`${this.uid}-option`});rootTarget=ge(this);get listboxId(){return`${this.uid}-list`}get inputId(){return`${this.uid}-input`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect??!this.isMultiple()}getInput(){return this.querySelector("[data-combobox-input]")}getTrigger(){return this.querySelector("[data-combobox-trigger]")}getClear(){return this.querySelector("[data-combobox-clear]")}getListboxPopup(){return this.querySelector("[data-combobox-listbox]")}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return It(this)?.textContent?.trim()||this.label||"Suggestions"}isComboboxInput(t){return t instanceof HTMLElement&&t.localName==="input"&&t.hasAttribute("data-combobox-input")}syncLabel(){let t=this.getInput();vt(this,t,{controlId:this.inputId,label:this.label,labelId:`${this.uid}-label`})}syncTrigger(){let t=this.getTrigger(),i=this.collection.getListbox();!t||!i||(t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",i.id||this.listboxId),t.tabIndex=-1,this.disabled&&(t.disabled=!0))}syncInput(){let t=this.getInput(),i=this.collection.getListbox(),n=this.getListboxPopup();!t||!i||(t.id||(t.id=this.inputId),i.id||(i.id=this.listboxId),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",this.listboxId),i.setAttribute("aria-label",this.getAccessibleName()),this.collection.syncMultiselectable(i),n&&(n.removeAttribute("role"),n.removeAttribute("aria-label")),this.placeholder&&(t.placeholder=this.isMultiple()&&this.collection.getSelectedValues().length?"":this.placeholder),this.disabled&&(t.disabled=!0),this.syncClear(),this.syncTrigger())}syncClear(){let t=this.getClear();t&&(t.hidden=this.collection.getSelectedValues().length===0&&!(this.getInput()?.value??""))}setVisualFocusCombobox(){this.listboxBehavior.clearActiveOption(),this.collection.syncOptionSelection()}setOpen(t,i={}){let n=i.activate??"none";this.open=t;let o=this.getInput(),u=this.getListboxPopup();if(!(!o||!u)){if(o.setAttribute("aria-expanded",String(t)),u.toggleAttribute("hidden",!t),this.syncTrigger(),!t){this.listboxBehavior.clearActiveOption(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.listboxBehavior.syncPopoverPosition(),n==="first"){let c=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(c.length?0:-1);return}if(n==="last"){let c=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(c.length?c.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}getAutocomplete(){return this.querySelector("rui-autocomplete")}syncAutocompleteFilter(){let t=this.getAutocomplete();if(t){t.syncFilter();return}let i=this.getInput()?.value??"";for(let n of this.collection.getOptions()){let o=gt(lt(n),i,"base");n.hidden=i.trim()!==""&&!o}}showAllOptions(){for(let t of this.collection.getOptions())t.hidden=!1}syncFilter(){this.syncAutocompleteFilter()}select(t){if(!this.collection.isSelectableOption(t))return;let i=st(t),n=lt(t)||i;this.collection.toggleValue(i);let o=this.getInput();o&&(o.value=this.isMultiple()?"":n),this.collection.syncTagGroup(),this.syncInput(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&this.setOpen(!1),this.syncFilter(),o?.focus()}syncFromValue(){let t=this.getInput();if(!t)return;if(this.isMultiple()){t.value="";return}let i=this.collection.getSelectedValues()[0]??"";t.value=i?this.collection.labelForValue(i):""}removeSelectedValue(t){this.collection.removeValue(t)&&(this.collection.syncTagGroup(),this.syncInput(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.getInput()?.focus())}clearSelection(){let t=this.getInput(),i=this.value.length>0,n=!!t?.value;this.collection.clearValues(),t&&(t.value=""),this.syncFilter(),this.syncInput(),this.collection.syncTagGroup(),this.collection.syncOptionSelection(),i&&this.changeEvent.emit({value:[]}),(n||i)&&t?.focus()}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncInput(),this.collection.syncListboxHost(),this.syncFromValue(),this.collection.syncOptionSelection(),this.collection.syncTagGroup(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.collection.syncListboxHost(),this.syncFromValue(),this.collection.syncOptionSelection(),this.collection.syncTagGroup()}onRootFocusIn(t){this.triggerKind!=="focus"||!this.isComboboxInput(t.target)||t.relatedTarget instanceof Node&&this.contains(t.relatedTarget)||(this.syncFilter(),this.setOpen(!0),this.setVisualFocusCombobox())}onRootInput(t){if(!this.isComboboxInput(t.target))return;let i=t.target;this.syncFilter();let n=i.value.trim()!=="",o=this.listboxBehavior.getVisibleOptions().length>0;n&&o&&(this.open||this.triggerKind!=="manual")?this.setOpen(!0):!n&&this.triggerKind==="focus"?this.setOpen(!0):(!n||!o)&&this.setOpen(!1),this.setVisualFocusCombobox()}onRootKeydown(t){this.isComboboxInput(t.target)&&this.handleInputKeydown(t)}handleInputKeydown(t){if(t.key==="Home"){let i=this.getInput();if(!i)return;t.preventDefault(),i.setSelectionRange(0,0),this.setVisualFocusCombobox();return}if(t.key==="End"){let i=this.getInput();if(!i)return;t.preventDefault();let n=i.value.length;i.setSelectionRange(n,n),this.setVisualFocusCombobox();return}(t.key==="ArrowDown"||t.key==="ArrowUp")&&(this.syncFilter(),this.listboxBehavior.getVisibleOptions().length||this.showAllOptions()),this.listboxBehavior.handleKeydown(t,{isOpen:this.open,canUseSpace:!1,closesOnTab:!0,enterWhenClosed:"ignore",enterWithoutActive:"close",onOpen:(i="none")=>{this.syncFilter(),this.setOpen(!0,{activate:i})},onClose:()=>this.setOpen(!1),onSelectActive:()=>{let i=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];i&&this.select(i)},onEscapeWhenClosed:()=>{let i=this.getInput();i&&i.value&&(i.value="",this.value=[],this.changeEvent.emit({value:[]}),this.syncFilter())}})}onTriggerClick(t){t.preventDefault();let i=this.getInput();!i||i.disabled||(this.open?this.setOpen(!1):(this.syncFilter(),this.setOpen(!0),this.setVisualFocusCombobox()),i.focus())}onOptionPointerOver(t){if(!this.open)return;let i=this.collection.findOption(t.target);if(!this.collection.isSelectableOption(i))return;let o=this.listboxBehavior.getVisibleOptions().indexOf(i);o>=0&&this.listboxBehavior.setActiveOption(o)}onOptionMouseDown(t){t.preventDefault()}onOptionClick(t){let i=this.collection.findOption(t.target);i&&this.select(i)}onTagRemove(t){let i=t.detail;i?.value&&this.removeSelectedValue(i.value)}onClearClick(t){t.preventDefault(),t.stopPropagation(),this.clearSelection()}onFocusOut(t){this.listboxBehavior.shouldDismissFocus(t.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(t){this.open&&this.listboxBehavior.shouldDismissPointer(t.target)&&this.setOpen(!1)}static{te()}};import{jsx as L,jsxs as Ft}from"@ecopages/jsx/jsx-runtime";function ht(e,t){return t===void 0||e?.label!==void 0?e:{...e,label:t}}function E(...e){return e.filter(Boolean).join(" ")}import{jsx as Ae}from"@ecopages/jsx/jsx-runtime";function Tt({class:e,size:t="sm",...i}){return Ae("svg",{...i,class:E("rui-icon",t==="md"&&"rui-icon--md",e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:Ae("path",{d:"m5 12 4 4L19 6"})})}import{jsx as Se}from"@ecopages/jsx/jsx-runtime";function Vt({class:e,size:t="sm",...i}){return Se("svg",{...i,class:E("rui-icon",t==="md"&&"rui-icon--md",e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:Se("path",{d:"m6 9 6 6 6-6"})})}import{jsx as Ie,jsxs as dn}from"@ecopages/jsx/jsx-runtime";var Oe="http://www.w3.org/2000/svg";function ft({class:e,size:t="sm",...i}){return dn("svg",{...i,class:E("rui-icon",t==="md"&&"rui-icon--md",e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Ie("path",{d:"m18 6-12 12"}),Ie("path",{d:"m6 6 12 12"})]})}function Ce(){let e=document.createElementNS(Oe,"svg");e.setAttribute("class","rui-icon"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.setAttribute("stroke","currentColor"),e.setAttribute("stroke-width","2"),e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("aria-hidden","true");for(let t of["m18 6-12 12","m6 6 12 12"]){let i=document.createElementNS(Oe,"path");i.setAttribute("d",t),e.append(i)}return e}import{RadiantElement as ke,customElement as bn,onEvent as gn,onUpdated as vn,prop as je}from"@ecopages/radiant";var Ee,Te,Ve,Re,Le,De;function hn(e,t,i,n,o,u){var c,s,x,I,C,R,A,U=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,B=Object.create,z=[B(null),B(null)],H=t.length;function D(r,b,f){return function(l,a){b&&(a=l,l=e);for(var g=0;g<r.length;g++)a=r[g].apply(l,f?[a]:[]);return f?a:l}}function w(r,b,f,l){if(typeof r!="function"&&(l||r!==void 0))throw new TypeError(b+" must "+(f||"be")+" a function"+(l?"":" or undefined"));return r}function X(r,b,f,l,a,g,S,m,v,y,Z){function P(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var K=[].concat(b[0]),Y=b[3],q=!S,T=a===1,J=a===3,N=a===4,M=a===2;function k(h,O,it){return function(F,nt){return O&&(nt=F,F=r),it&&it(F),d[h].call(F,nt)}}if(!q){var d={},$=[],_=J?"get":N||T?"set":"value";if(v?(y||T?d={get:Me(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||Me(d[_],l,M?"":_)):y||(d=Object.getOwnPropertyDescriptor(r,l)),!y&&!v){if((s=z[+m][l])&&(s^a)!==7)throw Error("Decorating two elements with the same name ("+d[_].name+") is not supported yet");z[+m][l]=a<3?1:a}}for(var p=r,j=K.length-1;j>=0;j-=f?2:1){var tt=w(K[j],"A decorator","be",!0),et=f?K[j-1]:void 0,W={},V={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,O){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(O,"An initializer","be",!0),g.push(O)}.bind(null,W)};if(q)s=tt.call(et,p,V),W.v=1,w(s,"class decorators","return")&&(p=s);else if(V.static=m,V.private=v,s=V.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?M?function(h){return P(h),d.value}:k("get",0,P):function(h){return h[l]}),M||J||(s.set=v?k("set",0,P):function(h,O){h[l]=O}),p=tt.call(et,T?{get:d.get,set:d.set}:d[_],V),W.v=1,T){if(typeof p=="object"&&p)(s=w(p.get,"accessor.get"))&&(d.get=s),(s=w(p.set,"accessor.set"))&&(d.set=s),(s=w(p.init,"accessor.init"))&&$.unshift(s);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(y?"field":"method")+" decorators","return")&&(y?$.unshift(p):d[_]=p)}return a<2&&S.push(D($,m,1),D(g,m,0)),y||q||(v?T?S.splice(-1,0,k("get",m),k("set",m)):S.push(M?d[_]:w.call.bind(d[_])):G(r,l,d)),p}function Q(r){return G(r,U,{configurable:!0,enumerable:!0,value:c})}return u!==void 0&&(c=u[U]),c=B(c??null),C=[],R=function(r){r&&C.push(D(r))},A=function(r,b){for(var f=0;f<i.length;f++){var l=i[f],a=l[1],g=7&a;if((8&a)==r&&!g==b){var S=l[2],m=!!l[3],v=16&a;X(r?e:e.prototype,l,v,m?"#"+S:pn(S),g,g<2?[]:r?I=I||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return mn(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(I),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),D(r,1)]}}}function pn(e){var t=fn(e,"string");return typeof t=="symbol"?t:t+""}function fn(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Me(e,t,i){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:i?i+" "+t:t})}catch{}return e}function mn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var Be,Fe=class extends ke{static{({e:[Ve,Re,Le,De,Ee],c:[Be,Te]}=hn(this,[bn("rui-autocomplete")],[[je({type:String,defaultValue:"base"}),0,"sensitivity"],[je({type:String,attribute:"input-value",defaultValue:""}),0,"inputValue"],[vn(["sensitivity","inputValue"]),2,"onPropsUpdated"],[gn({selector:"[data-autocomplete-input]",type:"input"}),2,"onInput"]],0,void 0,ke))}sensitivity=(Ee(this),Ve(this));inputValue=(Re(this),Le(this));externalInput=(De(this),null);onExternalInput=()=>{this.applyFilter()};getInput(){let t=this.querySelector("[data-autocomplete-input]");return t||(this.closest("rui-combobox, rui-select")?.querySelector("[data-autocomplete-input]")??null)}bindExternalInput(){this.unbindExternalInput();let t=this.getInput();!t||this.contains(t)||(this.externalInput=t,t.addEventListener("input",this.onExternalInput))}unbindExternalInput(){this.externalInput?.removeEventListener("input",this.onExternalInput),this.externalInput=null}syncFilter(){this.applyFilter()}getCollection(){return this.querySelector("[data-autocomplete-collection]")??this}getFilterableItems(){let t=this.getCollection();return t?Array.from(t.querySelectorAll('[role="option"], [data-tag], [role="menuitem"]')).filter(n=>this.contains(n)||t.contains(n)):[]}getItemText(t){return t.getAttribute("data-label")||t.textContent?.trim()||""}getQuery(){return this.inputValue?this.inputValue:this.getInput()?.value??""}applyFilter(){let t=this.getQuery(),i=this.getFilterableItems(),n=0;for(let u of i){let c=gt(this.getItemText(u),t,this.sensitivity);u.hidden=!c,c&&(n+=1)}let o=this.querySelector("[data-autocomplete-empty]");o&&o.toggleAttribute("hidden",n>0)}initialize(){this.applyFilter()}onConnected(){this.bindExternalInput(),this.initialize()}disconnectedCallback(){this.unbindExternalInput(),super.disconnectedCallback()}onPropsUpdated(){this.applyFilter()}onInput(){this.applyFilter()}static{Te()}};import{jsx as mt}from"@ecopages/jsx/jsx-runtime";function Rt({children:e,class:t,...i}){return mt("div",{...i,"data-autocomplete-collection":!0,class:E("rui-autocomplete__collection",t),children:e})}function Lt({children:e,class:t,...i}){return mt("div",{...i,"data-autocomplete-empty":!0,class:E("rui-autocomplete__empty",t),children:e})}function yn({children:e}){return mt("div",{class:"rui-autocomplete","data-ref":"root",children:e})}function Dt({children:e,...t}){return mt("rui-autocomplete",{...t,children:mt(yn,{children:e})})}import{RadiantElement as ii,bindTo as Cn,customElement as En,event as Tn,onEvent as ni,onUpdated as Vn,prop as pt}from"@ecopages/radiant";function xn(e,t){e.forEach((i,n)=>{let o=n===t?0:-1;i.tabIndex!==o&&(i.tabIndex=o)})}function wn(e,t){if(!e.length)return null;let i=Math.max(0,Math.min(e.length-1,t));return xn(e,i),e[i]?.focus(),e[i]??null}function _n(e,t){return e==="Home"?"first":e==="End"?"last":t==="horizontal"?e==="ArrowRight"?"next":e==="ArrowLeft"?"prev":null:e==="ArrowDown"?"next":e==="ArrowUp"?"prev":null}function At(e){let{items:t,current:i,key:n,orientation:o="horizontal",wrap:u=!0}=e;if(!t.length||!i)return{handled:!1};let c=t.indexOf(i);if(c<0)return{handled:!1};let s=_n(n,o);if(!s)return{handled:!1};let x=c;s==="first"?x=0:s==="last"?x=t.length-1:s==="next"?x=u?(c+1)%t.length:Math.min(t.length-1,c+1):x=u?(c-1+t.length)%t.length:Math.max(0,c-1);let I=wn(t,x);return I?{handled:!0,index:x,item:I}:{handled:!1}}var Pe,Ke,qe,$e,We,Ue,Ge,ze,He,Xe,Qe,Ze,Ye,Je,Ne,ti;function An(e,t,i,n,o,u){var c,s,x,I,C,R,A,U=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,B=Object.create,z=[B(null),B(null)],H=t.length;function D(r,b,f){return function(l,a){b&&(a=l,l=e);for(var g=0;g<r.length;g++)a=r[g].apply(l,f?[a]:[]);return f?a:l}}function w(r,b,f,l){if(typeof r!="function"&&(l||r!==void 0))throw new TypeError(b+" must "+(f||"be")+" a function"+(l?"":" or undefined"));return r}function X(r,b,f,l,a,g,S,m,v,y,Z){function P(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var K=[].concat(b[0]),Y=b[3],q=!S,T=a===1,J=a===3,N=a===4,M=a===2;function k(h,O,it){return function(F,nt){return O&&(nt=F,F=r),it&&it(F),d[h].call(F,nt)}}if(!q){var d={},$=[],_=J?"get":N||T?"set":"value";if(v?(y||T?d={get:ei(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||ei(d[_],l,M?"":_)):y||(d=Object.getOwnPropertyDescriptor(r,l)),!y&&!v){if((s=z[+m][l])&&(s^a)!==7)throw Error("Decorating two elements with the same name ("+d[_].name+") is not supported yet");z[+m][l]=a<3?1:a}}for(var p=r,j=K.length-1;j>=0;j-=f?2:1){var tt=w(K[j],"A decorator","be",!0),et=f?K[j-1]:void 0,W={},V={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,O){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(O,"An initializer","be",!0),g.push(O)}.bind(null,W)};if(q)s=tt.call(et,p,V),W.v=1,w(s,"class decorators","return")&&(p=s);else if(V.static=m,V.private=v,s=V.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?M?function(h){return P(h),d.value}:k("get",0,P):function(h){return h[l]}),M||J||(s.set=v?k("set",0,P):function(h,O){h[l]=O}),p=tt.call(et,T?{get:d.get,set:d.set}:d[_],V),W.v=1,T){if(typeof p=="object"&&p)(s=w(p.get,"accessor.get"))&&(d.get=s),(s=w(p.set,"accessor.set"))&&(d.set=s),(s=w(p.init,"accessor.init"))&&$.unshift(s);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(y?"field":"method")+" decorators","return")&&(y?$.unshift(p):d[_]=p)}return a<2&&S.push(D($,m,1),D(g,m,0)),y||q||(v?T?S.splice(-1,0,k("get",m),k("set",m)):S.push(M?d[_]:w.call.bind(d[_])):G(r,l,d)),p}function Q(r){return G(r,U,{configurable:!0,enumerable:!0,value:c})}return u!==void 0&&(c=u[U]),c=B(c??null),C=[],R=function(r){r&&C.push(D(r))},A=function(r,b){for(var f=0;f<i.length;f++){var l=i[f],a=l[1],g=7&a;if((8&a)==r&&!g==b){var S=l[2],m=!!l[3],v=16&a;X(r?e:e.prototype,l,v,m?"#"+S:Sn(S),g,g<2?[]:r?I=I||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return On(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(I),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),D(r,1)]}}}function Sn(e){var t=In(e,"string");return typeof t=="symbol"?t:t+""}function In(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ei(e,t,i){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:i?i+" "+t:t})}catch{}return e}function On(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var ri,oi=class extends ii{static{({e:[qe,$e,We,Ue,Ge,ze,He,Xe,Qe,Ze,Ye,Je,Ne,ti,Pe],c:[ri,Ke]}=An(this,[En("rui-listbox")],[[pt({...dt,defaultValue:[]}),0,"value"],[pt({type:String,defaultValue:""}),0,"label"],[pt({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[[pt({type:String,attribute:"selection-mode",defaultValue:"single"}),Cn({selector:'[role="listbox"]',attr:"aria-multiselectable",map:t=>t==="multiple"?"true":void 0})],0,"selectionMode"],[pt({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[pt({type:Boolean,reflect:!0}),0,"bordered"],[Tn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Vn(["value","label","disabled","embedded","selectionMode"]),2,"onPropsUpdated"],[ni({selector:'[role="option"]',type:"click"}),2,"onOptionClick"],[ni({selector:'[role="option"]',type:"keydown"}),2,"onOptionKeydown"]],0,void 0,ii))}value=(Pe(this),qe(this));label=($e(this),We(this));disabled=(Ue(this),Ge(this));selectionMode=(ze(this),He(this));embedded=(Xe(this),Qe(this));bordered=(Ze(this),Ye(this));changeEvent=(Je(this),Ne(this));uid=(ti(this),ct("rui-listbox"));onConnected(){this.syncLabel(),this.sync()}onPropsUpdated(){this.syncLabel(),this.sync()}getOptions(){return Array.from(this.querySelectorAll('[role="option"]'))}syncLabel(){if(this.embedded)return;let t=this.querySelector('[role="listbox"]');t&&(t.id||(t.id=`${this.uid}-list`),vt(this,t,{controlId:t.id,label:this.label,labelId:`${this.uid}-label`}))}getSelectedValues(){return this.value}setSelectedValues(t){this.value=t}tabIndexFor(t,i){return this.embedded?-1:t===i?0:-1}sync(){let t=this.getOptions(),i=new Set(this.getSelectedValues()),n=t.find(o=>i.has(st(o)))??t[0];for(let o of t){let u=i.has(st(o));o.setAttribute("aria-selected",String(u)),o.tabIndex=this.tabIndexFor(o,n)}}select(t){if(this.disabled||t.getAttribute("aria-disabled")==="true")return;let i=st(t);if(this.selectionMode==="multiple"){let n=new Set(this.getSelectedValues());n.has(i)?n.delete(i):n.add(i),this.setSelectedValues([...n])}else this.setSelectedValues([i]);this.sync(),this.changeEvent.emit({value:this.value}),t.focus()}onOptionClick(t){if(this.embedded)return;let i=t.target.closest('[role="option"]');i&&this.contains(i)&&this.select(i)}onOptionKeydown(t){if(this.embedded)return;let i=this.getOptions(),n=t.target.closest('[role="option"]');if(!n)return;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.select(n);return}let o=At({items:i,current:n,key:t.key,orientation:"vertical"});if(o.handled){if(t.preventDefault(),this.selectionMode==="multiple"){o.item.focus();return}this.select(o.item)}}static{Ke()}};import{jsx as ut,jsxs as Rn}from"@ecopages/jsx/jsx-runtime";function Mt({value:e,label:t,children:i,class:n,disabled:o,...u}){return ut("div",{...u,class:E("rui-listbox__option",n),role:"option","data-value":e,"data-label":t,"aria-disabled":o?"true":void 0,tabindex:-1,children:i})}function si({children:e,class:t,...i}){return ut("span",{...i,"data-listbox-option-indicator":!0,"aria-hidden":"true",class:E("rui-listbox__option-indicator",t),children:e??ut(Tt,{})})}function Ln(e,t){return t??!e}function Dn({bordered:e,children:t,disabled:i,embedded:n,label:o,selectionMode:u="single"}){return ut("div",{class:E("rui-listbox",e&&"rui-listbox--bordered"),role:"listbox","data-rui-control":n?void 0:!0,"data-rui-control-type":n?void 0:"text","aria-label":o||void 0,"aria-disabled":i?"true":void 0,"aria-multiselectable":u==="multiple"?"true":void 0,children:t})}function St({options:e,children:t,value:i,embedded:n,bordered:o,label:u,disabled:c,selectionMode:s="single",...x}){let I=Ln(n,o),C=_t(i),R=new Set(C);return ut("rui-listbox",{...x,value:C,embedded:n,bordered:o,label:u,disabled:c,selectionMode:s,children:ut(Dn,{bordered:I,disabled:c,embedded:n,label:u,selectionMode:s,children:e!=null?e.map(A=>Rn(Mt,{value:A.value,label:typeof A.label=="string"?A.label:void 0,disabled:A.disabled,"aria-selected":R.has(A.value)?"true":void 0,children:[A.label,s==="multiple"?ut(si,{}):null]})):t})})}import{RadiantElement as Oi,customElement as Bn,event as Ci,onEvent as kt,onUpdated as Pn,prop as bt,state as Kn}from"@ecopages/radiant";var li,ai,ui,ci,di,hi,pi,fi,mi,bi,gi,vi,yi,xi,wi,_i,Ai,Si;function Mn(e,t,i,n,o,u){var c,s,x,I,C,R,A,U=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,B=Object.create,z=[B(null),B(null)],H=t.length;function D(r,b,f){return function(l,a){b&&(a=l,l=e);for(var g=0;g<r.length;g++)a=r[g].apply(l,f?[a]:[]);return f?a:l}}function w(r,b,f,l){if(typeof r!="function"&&(l||r!==void 0))throw new TypeError(b+" must "+(f||"be")+" a function"+(l?"":" or undefined"));return r}function X(r,b,f,l,a,g,S,m,v,y,Z){function P(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var K=[].concat(b[0]),Y=b[3],q=!S,T=a===1,J=a===3,N=a===4,M=a===2;function k(h,O,it){return function(F,nt){return O&&(nt=F,F=r),it&&it(F),d[h].call(F,nt)}}if(!q){var d={},$=[],_=J?"get":N||T?"set":"value";if(v?(y||T?d={get:Ii(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||Ii(d[_],l,M?"":_)):y||(d=Object.getOwnPropertyDescriptor(r,l)),!y&&!v){if((s=z[+m][l])&&(s^a)!==7)throw Error("Decorating two elements with the same name ("+d[_].name+") is not supported yet");z[+m][l]=a<3?1:a}}for(var p=r,j=K.length-1;j>=0;j-=f?2:1){var tt=w(K[j],"A decorator","be",!0),et=f?K[j-1]:void 0,W={},V={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,O){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(O,"An initializer","be",!0),g.push(O)}.bind(null,W)};if(q)s=tt.call(et,p,V),W.v=1,w(s,"class decorators","return")&&(p=s);else if(V.static=m,V.private=v,s=V.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?M?function(h){return P(h),d.value}:k("get",0,P):function(h){return h[l]}),M||J||(s.set=v?k("set",0,P):function(h,O){h[l]=O}),p=tt.call(et,T?{get:d.get,set:d.set}:d[_],V),W.v=1,T){if(typeof p=="object"&&p)(s=w(p.get,"accessor.get"))&&(d.get=s),(s=w(p.set,"accessor.set"))&&(d.set=s),(s=w(p.init,"accessor.init"))&&$.unshift(s);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(y?"field":"method")+" decorators","return")&&(y?$.unshift(p):d[_]=p)}return a<2&&S.push(D($,m,1),D(g,m,0)),y||q||(v?T?S.splice(-1,0,k("get",m),k("set",m)):S.push(M?d[_]:w.call.bind(d[_])):G(r,l,d)),p}function Q(r){return G(r,U,{configurable:!0,enumerable:!0,value:c})}return u!==void 0&&(c=u[U]),c=B(c??null),C=[],R=function(r){r&&C.push(D(r))},A=function(r,b){for(var f=0;f<i.length;f++){var l=i[f],a=l[1],g=7&a;if((8&a)==r&&!g==b){var S=l[2],m=!!l[3],v=16&a;X(r?e:e.prototype,l,v,m?"#"+S:kn(S),g,g<2?[]:r?I=I||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return Fn(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(I),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),D(r,1)]}}}function kn(e){var t=jn(e,"string");return typeof t=="symbol"?t:t+""}function jn(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ii(e,t,i){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:i?i+" "+t:t})}catch{}return e}function Fn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var Ti,Ei=class extends Oi{static{({e:[ui,ci,di,hi,pi,fi,mi,bi,gi,vi,yi,xi,wi,_i,Ai,Si,li],c:[Ti,ai]}=Mn(this,[Bn("rui-tag-group")],[[bt({...dt,defaultValue:[]}),0,"value"],[bt({type:String,defaultValue:""}),0,"label"],[bt({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[bt({type:String,attribute:"selection-mode",defaultValue:"multiple"}),0,"selectionMode"],[bt({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[Ci({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Ci({name:"rui-remove",bubbles:!0,composed:!0}),0,"removeEvent"],[Kn,0,"derivedItems"],[Pn(["value","label","disabled","selectionMode","embedded","derivedItems"]),2,"onPropsUpdated"],[kt({selector:"[data-tag]",type:"click"}),2,"onTagClick"],[kt({selector:"[data-tag-remove]",type:"click"}),2,"onRemoveClick"],[kt({selector:"[data-tag]",type:"keydown"}),2,"onTagKeydown"]],0,void 0,Oi))}constructor(...t){super(...t),Si(this)}value=(li(this),ui(this));label=(ci(this),di(this));disabled=(hi(this),pi(this));selectionMode=(fi(this),mi(this));embedded=(bi(this),gi(this));changeEvent=(vi(this),yi(this));removeEvent=(xi(this),wi(this));uid=(_i(this),ct("rui-tag-group"));derivedItems=Ai(this,null);isMultiple(){return this.selectionMode==="multiple"}getSelectedValues(){return this.value}setSelectedValues(t){this.value=t}getList(){let t=this.querySelector("[data-rui-managed-list]");return t||(this.derivedItems!=null?null:this.querySelector("[data-tag-list]"))}getTags(){let t=this.getList();return t?Array.from(t.querySelectorAll("[data-tag]")):[]}getVisibleTags(){return this.getTags().filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}getTagValue(t){return t.getAttribute("data-value")||t.textContent?.trim()||""}getTagLabel(t){return t.getAttribute("data-label")||t.textContent?.trim()||""}ensureTagIds(){this.getTags().forEach((t,i)=>{t.id||(t.id=`${this.uid}-tag-${i}`)})}syncList(){let t=this.getList();t&&(t.id||(t.id=`${this.uid}-list`),t.setAttribute("role","list"),t.setAttribute("aria-label",this.label||"Tags"),this.disabled?t.setAttribute("aria-disabled","true"):t.removeAttribute("aria-disabled"))}syncTags(){let t=new Set(this.getSelectedValues());this.getTags().forEach((n,o)=>{n.setAttribute("role","listitem");let u=this.getTagValue(n),c=t.has(u);n.setAttribute("aria-selected",String(c)),n.tabIndex=o===0?0:-1;let s=n.querySelector("[data-tag-remove]");s&&(s.type="button",s.tabIndex=-1,s.setAttribute("aria-label",`Remove ${this.getTagLabel(n)}`))})}selectTag(t){if(this.disabled||this.embedded||t.getAttribute("aria-disabled")==="true")return;let i=this.getTagValue(t);if(this.isMultiple()){let n=new Set(this.getSelectedValues());n.has(i)?n.delete(i):n.add(i),this.setSelectedValues([...n])}else this.value=[i];this.syncTags(),this.changeEvent.emit({value:this.value})}removeTag(t){let i=this.getTagValue(t),n=new Set(this.getSelectedValues());n.delete(i),this.setSelectedValues([...n]),this.syncTags(),this.removeEvent.emit({value:i}),this.changeEvent.emit({value:this.value})}initialize(){this.syncManagedList(),this.ensureTagIds(),this.syncList(),this.syncTags()}onConnected(){this.initialize()}onPropsUpdated(){this.syncManagedList(),this.syncList(),this.syncTags()}resync(){this.ensureTagIds(),this.syncList(),this.syncTags()}setItems(t){this.derivedItems=t,this.value=t.map(i=>i.value)}createManagedTag(t){let i=document.createElement("span");i.setAttribute("data-tag",""),i.setAttribute("data-value",t.value),i.setAttribute("data-label",t.label),i.className="rui-tag",i.textContent=t.label,i.setAttribute("aria-label",t.label);let n=document.createElement("button");return n.type="button",n.setAttribute("data-tag-remove",""),n.className="rui-tag__remove",n.setAttribute("aria-label",`Remove ${t.label}`),n.append(Ce()),i.append(n),i}syncManagedList(){let t=this.querySelector('[data-ref="root"]');if(!t||this.derivedItems==null)return;t.querySelector("[data-tag-list]:not([data-rui-managed-list])")?.toggleAttribute("hidden",!0);let n=t.querySelector("[data-rui-managed-list]");if(this.derivedItems.length===0){n?.remove();return}n||(n=document.createElement("div"),n.setAttribute("data-tag-list",""),n.setAttribute("data-rui-managed-list",""),n.className="rui-tag-group__list",t.appendChild(n)),n.replaceChildren(...this.derivedItems.map(o=>this.createManagedTag(o))),this.ensureTagIds(),this.syncList(),this.syncTags()}onTagClick(t){let i=t.target;if(i.closest("[data-tag-remove]"))return;let n=i.closest("[data-tag]");n&&this.contains(n)&&this.selectTag(n)}onRemoveClick(t){t.stopPropagation();let n=t.target.closest("[data-tag]");n&&this.contains(n)&&this.removeTag(n)}onTagKeydown(t){let i=this.getVisibleTags(),n=t.target.closest("[data-tag]");if(!n)return;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.embedded||this.selectTag(n);return}if(t.key==="Backspace"||t.key==="Delete"){n.querySelector("[data-tag-remove]")&&(t.preventDefault(),this.removeTag(n));return}At({items:i,current:n,key:t.key,orientation:"horizontal"}).handled&&t.preventDefault()}static{ai()}};import{jsx as rt,jsxs as qn}from"@ecopages/jsx/jsx-runtime";function Ri({children:e,class:t,...i}){return rt("div",{...i,"data-tag-list":!0,class:E("rui-tag-group__list",t),children:e})}function Li({value:e,label:t,children:i,class:n,disabled:o,aria:u,...c}){return qn("span",{...c,"data-tag":!0,"data-value":e,"data-label":t,class:E("rui-tag",n),aria:ht(u,t),"aria-disabled":o?"true":void 0,children:[i,rt(Di,{})]})}function Di({children:e,class:t,aria:i,...n}){return rt("button",{...n,aria:ht(i,"Remove"),type:"button","data-tag-remove":!0,class:E("rui-tag__remove",t),children:e??rt(ft,{})})}function Vi({children:e}){return rt("div",{class:"rui-tag-group","data-ref":"root",children:e})}function jt({tags:e,children:t,value:i,...n}){return e!=null?rt("rui-tag-group",{...n,value:i,children:rt(Vi,{children:rt(Ri,{children:e.map(o=>rt(Li,{value:o.value,label:typeof o.label=="string"?o.label:void 0,disabled:o.disabled,children:o.label}))})})}):rt("rui-tag-group",{...n,value:i,children:rt(Vi,{children:t})})}function ki({children:e,class:t,...i}){return L("div",{...i,class:E("rui-combobox__control",t),children:e})}function ji({placeholder:e,disabled:t,class:i,...n}){return L("input",{...n,type:"text","data-combobox-input":!0,"data-autocomplete-input":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:E("rui-combobox__input",i),placeholder:e,disabled:t,autocomplete:"off"})}function Fi({children:e,class:t,aria:i,disabled:n,...o}){return L("button",{...o,aria:ht(i,"Show suggestions"),type:"button","data-combobox-trigger":!0,class:E("rui-control-toggle",t),disabled:n,tabIndex:-1,children:e??L(Vt,{})})}function $n({children:e,class:t,aria:i,disabled:n,...o}){return L("button",{...o,aria:ht(i,"Clear selection"),type:"button","data-combobox-clear":!0,class:E("rui-control-clear",t),disabled:n,children:e??L(ft,{})})}function Bi({children:e,class:t,...i}){return L("span",{...i,"data-combobox-value":!0,class:E("rui-combobox__value",t),children:e})}function Pi({children:e,class:t,...i}){return L("div",{...i,"data-combobox-listbox":!0,class:E("rui-combobox__listbox rui-popover rui-popover--listbox rui-floating",t),children:e})}function Mi({children:e}){return L("div",{class:"rui-combobox","data-ref":"root",children:e})}function Wn({options:e,children:t,value:i,...n}){let o=_t(i),u=e?.filter(s=>o.includes(s.value)).map(s=>({value:s.value,label:s.label})),c=n.selectionMode==="multiple";return e!=null?L("rui-combobox",{...n,value:o,children:Ft(Mi,{children:[Ft(ki,{children:[c?L(Bi,{children:L(jt,{tags:u??[],label:"Selected options"})}):null,L(ji,{placeholder:n.placeholder,disabled:n.disabled}),L(Fi,{})]}),L(Pi,{children:L(Dt,{children:Ft(Rt,{children:[L(St,{embedded:!0,options:e,selectionMode:n.selectionMode,value:o}),L(Lt,{children:"No results found."})]})})})]})}):L("rui-combobox",{...n,value:o,children:L(Mi,{children:t})})}export{Wn as RuiCombobox,$n as RuiComboboxClear,ki as RuiComboboxControl,_e as RuiComboboxElement,ji as RuiComboboxInput,Pi as RuiComboboxListbox,Fi as RuiComboboxTrigger,Bi as RuiComboboxValue,St as RuiListbox,Mt as RuiListboxOption};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|