@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 ne,customElement as Be,event as je,onEvent as x,onUpdated as Ge,prop as k,query as Ke}from"@ecopages/radiant";function st(e){let t=e.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:e.parentElement?.querySelector("[data-rui-field-label]")??null}function Oe(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 r=st(e);if(r){Oe(r,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 Ae="data-listbox-option-indicator";function X(e){let t=e.getAttribute("data-label");return t||_t(e).trim()}function P(e){return e.getAttribute("data-value")||X(e)}function _t(e){if(Ce(e))return"";if(e.nodeType===Node.TEXT_NODE)return e.textContent??"";let t="";for(let i of e.childNodes)t+=_t(i);return t}function Ce(e){return e instanceof HTMLElement&&e.hasAttribute(Ae)}function lt(e){return e?ct(e.split(",")):[]}function at(e){return e.join(",")}function N(e){if(e!=null)return typeof e!="string"?at(ct(e)):e}function B(e){return e==null?[]:typeof e!="string"?ct(e):lt(e)}function ct(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))]}var z=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 lt(this.config.getValue())}setSelectedValues(t){this.config.setValue(at(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.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 i of this.getOptions())i.setAttribute("aria-selected",String(t.has(P(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(r=>{let o=this.getOptions().find(n=>P(n)===r);return o?[{value:r,label:X(o)}]:[]});t.embedded=!0,t.setItems(i),t.value=this.config.getValue()}labelForValue(t){let i=this.getOptions().find(r=>P(r)===t);return i?X(i):t}};var Te={top:"bottom",bottom:"top",left:"right",right:"left"},Ie=8;function Ve(e){let t=e.indexOf("-");if(t===-1)return{side:e,align:"center"};let i=e.slice(0,t),r=e.slice(t+1);return{side:i,align:r==="start"||r==="end"?r:"center"}}function Et(e){return e==="top"||e==="bottom"?"y":"x"}function Rt(e,t,i,r,o){let{width:n,height:s}=t,l=0,h=0;switch(i){case"top":h=e.top-s-o;break;case"bottom":h=e.bottom+o;break;case"left":l=e.left-n-o;break;case"right":l=e.right+o;break}return Et(i)==="y"?r==="start"?l=e.left:r==="end"?l=e.right-n:l=e.left+(e.width-n)/2:r==="start"?h=e.top:r==="end"?h=e.bottom-s:h=e.top+(e.height-s)/2,{x:l,y:h}}function _e(e,t,i,r){let{padding:o,width:n,height:s}=r;return i==="top"?Math.max(0,o-e.y):i==="bottom"?Math.max(0,e.y+t.height-(s-o)):i==="left"?Math.max(0,o-e.x):Math.max(0,e.x+t.width-(n-o))}function Lt(e,t,i,r){let{padding:o,width:n,height:s}=r;return i==="top"?e.top-o-t.height:i==="bottom"?s-o-t.height-e.bottom:i==="left"?e.left-o-t.width:n-o-t.width-e.right}function Re(e,t){return t==="center"?e:`${e}-${t}`}function Le(e,t,i,r){let{padding:o,width:n,height:s}=r;if(Et(i)==="y"){let h=Math.max(o,n-o-t.width);return{x:Math.min(Math.max(e.x,o),h),y:e.y}}let l=Math.max(o,s-o-t.height);return{x:e.x,y:Math.min(Math.max(e.y,o),l)}}function Ee(e,t,i,r,o={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Ie}){let{side:n,align:s}=Ve(i),l=Rt(e,t,n,s,r),h=_e(l,t,n,o),b=n,C=l;if(h>0){let T=Te[n],m=Rt(e,t,T,s,r),K=Lt(e,t,n,o);Lt(e,t,T,o)>K&&(b=T,C=m)}return{coords:Le(C,t,b,o),placement:Re(b,s)}}function De(e,t,i,r,o={}){let{coords:n,placement:s}=Ee(e.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},i,r);return Object.assign(t.style,{position:"fixed",left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),o.matchAnchorWidth&&(t.style.width=`${e.offsetWidth}px`),t.setAttribute("data-placement",s),s}function Dt({anchor:e,floating:t,getPlacement:i,gap:r,matchAnchorWidth:o}){let n=()=>{t.hidden||De(e,t,i(),r,{matchAnchorWidth:o})};n(),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0);let s=new ResizeObserver(n);return s.observe(e),s.observe(t),()=>{window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0),s.disconnect()}}function Pt(e,t=document.body){let i=e.parentNode;if(!i)return{unmount:()=>{}};let r=document.createComment("rui-portal");return i.insertBefore(r,e),t.appendChild(e),{unmount:()=>{let o=r.parentNode;o&&(o.insertBefore(e,r),r.remove())}}}function ut(e,t,i){return i?!!(e?.contains(i)||t?.contains(i)):!1}function kt(e,t,i){return i instanceof Node?!ut(e,t,i):!0}function Ft(e,t,i){return!ut(e,t,i)}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 r=this.config.getAnchor();if(!r)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Pt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Dt({anchor:r,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return ut(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 Mt(e){return e.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function Bt(e,t,i){return i===0?-1:t===1?e>=i-1?0:e+1:e<=0?i-1:e-1}function ht(e,t){t?.removeAttribute("aria-activedescendant");for(let i of e)i.removeAttribute("data-active")}function jt(e,t,i,r,o){ht(e,r);let n=t[i];return!n||!r?null:(n.id||(n.id=`${o}-${i}`),n.setAttribute("data-active","true"),r.setAttribute("aria-activedescendant",n.id),n.scrollIntoView({block:"nearest"}),n)}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,i)=>{t.id||(t.id=`${this.config.getOptionIdPrefix()}-${i}`)})}getVisibleOptions(){return Mt(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,ht(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,jt(this.config.getOptions(),i,t,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(t,i){let r=this.getVisibleOptions();if(r.length){if(!this.config.getOpen()){i(t===1?"first":"last");return}if(this.visualFocus){this.setActiveOption(Bt(this.activeIndex,t,r.length));return}this.setActiveOption(t===1?0:r.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 r=t.key==="ArrowDown"?1:-1;if(t.altKey){this.handleModifiedArrow(r,i);return}this.moveActive(r,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 kt(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return Ft(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};var Gt,Kt,Ht,qt,Wt,$t,Ut,Xt,Nt,zt,Yt,Jt,Qt,Zt,te,ee,ie,re;function Pe(e,t,i,r,o,n){var s,l,h,b,C,T,m,K=Symbol.metadata||Symbol.for("Symbol.metadata"),Z=Object.defineProperty,tt=Object.create,bt=[tt(null),tt(null)],mt=t.length;function H(a,O,y){return function(c,d){O&&(d=c,c=e);for(var A=0;A<a.length;A++)d=a[A].apply(c,y?[d]:[]);return y?d:c}}function _(a,O,y,c){if(typeof a!="function"&&(c||a!==void 0))throw new TypeError(O+" must "+(y||"be")+" a function"+(c?"":" or undefined"));return a}function vt(a,O,y,c,d,A,L,S,I,V,yt){function et(g){if(!yt(g))throw new TypeError("Attempted to access private element on non-instance")}var it=[].concat(O[0]),St=O[3],rt=!L,F=d===1,wt=d===3,Ot=d===4,q=d===2;function W(g,D,Tt){return function(U,It){return D&&(It=U,U=a),Tt&&Tt(U),f[g].call(U,It)}}if(!rt){var f={},ot=[],R=wt?"get":Ot||F?"set":"value";if(I?(V||F?f={get:oe(function(){return St(this)},c,"get"),set:function(g){O[4](this,g)}}:f[R]=St,V||oe(f[R],c,q?"":R)):V||(f=Object.getOwnPropertyDescriptor(a,c)),!V&&!I){if((l=bt[+S][c])&&(l^d)!==7)throw Error("Decorating two elements with the same name ("+f[R].name+") is not supported yet");bt[+S][c]=d<3?1:d}}for(var v=a,$=it.length-1;$>=0;$-=y?2:1){var At=_(it[$],"A decorator","be",!0),Ct=y?it[$-1]:void 0,nt={},M={kind:["field","accessor","method","getter","setter","class"][d],name:c,metadata:s,addInitializer:function(g,D){if(g.v)throw new TypeError("attempted to call addInitializer after decoration was finished");_(D,"An initializer","be",!0),A.push(D)}.bind(null,nt)};if(rt)l=At.call(Ct,v,M),nt.v=1,_(l,"class decorators","return")&&(v=l);else if(M.static=S,M.private=I,l=M.access={has:I?yt.bind():function(g){return c in g}},Ot||(l.get=I?q?function(g){return et(g),f.value}:W("get",0,et):function(g){return g[c]}),q||wt||(l.set=I?W("set",0,et):function(g,D){g[c]=D}),v=At.call(Ct,F?{get:f.get,set:f.set}:f[R],M),nt.v=1,F){if(typeof v=="object"&&v)(l=_(v.get,"accessor.get"))&&(f.get=l),(l=_(v.set,"accessor.set"))&&(f.set=l),(l=_(v.init,"accessor.init"))&&ot.unshift(l);else if(v!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else _(v,(V?"field":"method")+" decorators","return")&&(V?ot.unshift(v):f[R]=v)}return d<2&&L.push(H(ot,S,1),H(A,S,0)),V||rt||(I?F?L.splice(-1,0,W("get",S),W("set",S)):L.push(q?f[R]:_.call.bind(f[R])):Z(a,c,f)),v}function xt(a){return Z(a,K,{configurable:!0,enumerable:!0,value:s})}return n!==void 0&&(s=n[K]),s=tt(s??null),C=[],T=function(a){a&&C.push(H(a))},m=function(a,O){for(var y=0;y<i.length;y++){var c=i[y],d=c[1],A=7&d;if((8&d)==a&&!A==O){var L=c[2],S=!!c[3],I=16&d;vt(a?e:e.prototype,c,I,S?"#"+L:ke(L),A,A<2?[]:a?b=b||[]:h=h||[],C,!!a,S,O,a&&S?function(V){return Me(V)===e}:o)}}},m(8,0),m(0,0),m(8,1),m(0,1),T(h),T(b),l=C,mt||xt(e),{e:l,get c(){var a=[];return mt&&[xt(e=vt(e,[t],r,e.name,5,a)),H(a,1)]}}}function ke(e){var t=Fe(e,"string");return typeof t=="symbol"?t:t+""}function Fe(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var r=i.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function oe(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 Me(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 le,se=class extends ne{static{({e:[Ht,qt,Wt,$t,Ut,Xt,Nt,zt,Yt,Jt,Qt,Zt,te,ee,ie,re,Gt],c:[le,Kt]}=Pe(this,[Be("rui-select")],[[k({type:String,reflect:!0,defaultValue:""}),0,"value"],[k({type:String,defaultValue:""}),0,"label"],[k({type:String,defaultValue:""}),0,"placeholder"],[k({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[k({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[k({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[je({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Ke({ref:"root"}),0,"rootTarget"],[Ge(["value","label","placeholder","disabled","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[x({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[x({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[x({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[x({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[x({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[x({selector:"[data-select-clear]",type:"click"}),2,"onClearClick"],[x({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[x({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[x({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[x({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[x({ref:"root",type:"focusout"}),2,"onFocusOut"],[x({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,ne))}constructor(...t){super(...t),re(this)}value=(Gt(this),Ht(this));label=(qt(this),Wt(this));placeholder=($t(this),Ut(this));disabled=(Xt(this),Nt(this));selectionMode=(zt(this),Yt(this));shouldCloseOnSelect=(Jt(this),Qt(this));changeEvent=(Zt(this),te(this));open=(ee(this),!1);uid=Math.random().toString(36).slice(2,9);collection=new z({getRoot:()=>this,getSelectionMode:()=>this.selectionMode,getValue:()=>this.value,setValue:t=>{this.value=t},getPopup:()=>this.getListboxPopup(),tagGroupSelector:"[data-select-value] rui-tag-group"});listboxBehavior=new J({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.collection.getOptions(),getActiveDescendantHost:()=>this.getActiveDescendantHost(),getOptionIdPrefix:()=>`rui-select-option-${this.uid}`});rootTarget=ie(this);get listboxId(){return`rui-select-list-${this.uid}`}get triggerId(){return`rui-select-trigger-${this.uid}`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect!=null?this.shouldCloseOnSelect:!this.isMultiple()}getSearchInput(){return this.querySelector("[data-select-listbox] [data-autocomplete-input]")}hasSearchInput(){return this.getSearchInput()!=null}getActiveDescendantHost(){return this.open&&this.hasSearchInput()?this.getSearchInput():this.getTrigger()}resetSearchFilter(){let t=this.getSearchInput();!t||t.value===""||(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})))}syncSearchInput(){let t=this.getSearchInput(),i=this.getTrigger(),r=this.collection.getListbox();if(!(!t||!r||!i)){if(this.open){t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","true"),t.setAttribute("aria-controls",this.listboxId),i.removeAttribute("aria-activedescendant");return}t.removeAttribute("role"),t.removeAttribute("aria-autocomplete"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls"),t.removeAttribute("aria-activedescendant")}}focusPopupInput(){queueMicrotask(()=>{this.getSearchInput()?.focus()})}hasTagGroup(){return this.collection.getTagGroup()!=null}syncTagGroup(){let t=this.getValueElement();this.collection.syncTagGroup(),!(!t||!this.hasTagGroup())&&this.syncTagGroupPlaceholder(t,this.collection.getSelectedValues().length)}syncTagGroupPlaceholder(t,i){let r=t.querySelector("[data-select-placeholder]");if(!this.placeholder){r?.remove();return}r||(r=document.createElement("span"),r.setAttribute("data-select-placeholder","true"),t.insertBefore(r,t.firstChild)),r.textContent=this.placeholder,r.hidden=i>0,t.toggleAttribute("data-placeholder",i===0)}removeSelectedValue(t){this.collection.removeValue(t)&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.syncClear(),this.changeEvent.emit({value:this.value}))}clearSelection(){this.collection.clearValues()&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.syncClear(),this.changeEvent.emit({value:""}),this.getTrigger()?.focus())}getTrigger(){return this.querySelector("[data-select-trigger]")}getToggle(){return this.querySelector("[data-select-toggle]")}getClear(){return this.querySelector("[data-select-clear]")}getValueElement(){return this.querySelector("[data-select-value]")}getListboxPopup(){return this.querySelector("[data-select-listbox]")}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return st(this)?.textContent?.trim()||this.label||"Options"}syncLabel(){let t=this.getTrigger();Vt(this,t,{controlId:this.triggerId,label:this.label,labelId:`rui-select-label-${this.uid}`})}syncTrigger(){let t=this.getTrigger(),i=this.collection.getListbox(),r=this.getListboxPopup();!t||!i||(t.id||(t.id=this.triggerId),i.id||(i.id=this.listboxId),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-autocomplete","none"),t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",this.listboxId),i.setAttribute("aria-label",this.getAccessibleName()),this.collection.syncMultiselectable(i),r&&(r.removeAttribute("role"),r.removeAttribute("aria-label"),r.removeAttribute("aria-multiselectable")),this.disabled&&(t.disabled=!0),this.syncToggle(),this.syncClear(),this.syncSearchInput())}syncClear(){let t=this.getClear();t&&(t.hidden=this.collection.getSelectedValues().length===0,t.disabled=this.disabled)}syncToggle(){let t=this.getToggle();t&&(t.setAttribute("aria-expanded",String(this.open)),t.disabled=this.disabled)}syncValueDisplay(){if(this.hasTagGroup()){this.syncTagGroup();return}let t=this.getValueElement();if(!t||t.childElementCount>0)return;let i=this.collection.getSelectedValues();if(i.length===0){t.textContent="",t.toggleAttribute("data-placeholder",!0),this.placeholder&&(t.textContent=this.placeholder);return}if(t.toggleAttribute("data-placeholder",!1),this.isMultiple()){t.textContent=i.map(r=>this.collection.labelForValue(r)).join(", ");return}t.textContent=this.collection.labelForValue(i[0])}setOpen(t,i={}){let r=i.activate??"none";this.open=t;let o=this.getTrigger(),n=this.getListboxPopup();if(!(!o||!n)){if(o.setAttribute("aria-expanded",String(t)),n.toggleAttribute("hidden",!t),!t){this.listboxBehavior.clearActiveOption(),this.resetSearchFilter(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition(),this.hasSearchInput()&&this.focusPopupInput(),r==="first"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?0:-1);return}if(r==="last"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?s.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}selectOption(t){this.collection.isSelectableOption(t)&&(this.collection.toggleValue(P(t)),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncClear(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&(this.resetSearchFilter(),this.setOpen(!1),this.getTrigger()?.focus()))}handleListboxKeydown(t){this.listboxBehavior.handleKeydown(t,{isOpen:this.open,canUseSpace:!this.hasSearchInput(),closesOnTab:this.closesOnSelect(),enterWhenClosed:"open",enterWithoutActive:"ignore",onOpen:(i="none")=>this.setOpen(!0,{activate:i}),onClose:i=>{this.setOpen(!1),(i==="arrow"||i==="escape")&&this.getTrigger()?.focus()},onSelectActive:()=>{let i=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];i&&this.selectOption(i)}})}handleTriggerKeydown(t){this.handleListboxKeydown(t)}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection()}onTriggerClick(t){t.preventDefault();let i=this.getTrigger();if(!(!i||i.disabled)){if(this.open?this.setOpen(!1):this.setOpen(!0),this.open&&this.hasSearchInput()){this.focusPopupInput();return}i.focus()}}onTriggerKeydown(t){this.handleTriggerKeydown(t)}onSearchKeydown(t){this.handleListboxKeydown(t)}onSearchInput(){this.open&&this.listboxBehavior.clearActiveOption()}onTagRemove(t){let i=t.detail;i?.value&&this.removeSelectedValue(i.value)}onClearClick(t){t.preventDefault(),t.stopPropagation(),this.clearSelection()}onTagClick(t){t.target.closest("[data-tag-remove]")||t.stopPropagation()}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.selectOption(i)}onFocusOut(t){this.listboxBehavior.shouldDismissFocus(t.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(t){this.open&&this.listboxBehavior.shouldDismissPointer(t.target)&&this.setOpen(!1)}static{Kt()}};import{Fragment as Xe,jsx as p,jsxs as me}from"@ecopages/jsx/jsx-runtime";function j(e,t){return t===void 0||e?.label!==void 0?e:{...e,label:t}}function u(...e){return e.filter(Boolean).join(" ")}function ae(e,...t){let i={...e};for(let r of t)delete i[r];return i}import{jsx as ce}from"@ecopages/jsx/jsx-runtime";function dt({class:e,size:t="sm",...i}){return ce("svg",{...i,class:u("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:ce("path",{d:"m5 12 4 4L19 6"})})}import{jsx as ue}from"@ecopages/jsx/jsx-runtime";function pt({class:e,size:t="sm",...i}){return ue("svg",{...i,class:u("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:ue("path",{d:"m6 9 6 6 6-6"})})}import{jsx as he,jsxs as He}from"@ecopages/jsx/jsx-runtime";function G({class:e,size:t="sm",...i}){return He("svg",{...i,class:u("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:[he("path",{d:"m18 6-12 12"}),he("path",{d:"m6 6 12 12"})]})}import{jsx as E,jsxs as qe}from"@ecopages/jsx/jsx-runtime";function ft({value:e,label:t,children:i,class:r,disabled:o,...n}){return E("div",{...n,class:u("rui-listbox__option",r),role:"option","data-value":e,"data-label":t,"aria-disabled":o?"true":void 0,tabindex:-1,children:i})}function de({children:e,class:t,...i}){return E("span",{...i,"data-listbox-option-indicator":!0,"aria-hidden":"true",class:u("rui-listbox__option-indicator",t),children:e??E(dt,{})})}function We(e,t){return t??!e}function $e({bordered:e,children:t,disabled:i,label:r,selectionMode:o="single"}){return E("div",{class:u("rui-listbox",e&&"rui-listbox--bordered"),role:"listbox","data-rui-control":!0,"data-rui-control-type":"text","aria-label":r||void 0,"aria-disabled":i?"true":void 0,"aria-multiselectable":o==="multiple"?"true":void 0,children:t})}function Q({options:e,children:t,value:i,embedded:r,bordered:o,label:n,disabled:s,selectionMode:l="single",...h}){let b=We(r,o),C=N(i),T=new Set(B(i));return E("rui-listbox",{...h,value:C,embedded:r,bordered:o,label:n,disabled:s,selectionMode:l,children:E($e,{bordered:b,disabled:s,label:n,selectionMode:l,children:e!=null?e.map(m=>qe(ft,{value:m.value,label:typeof m.label=="string"?m.label:void 0,disabled:m.disabled,"aria-selected":T.has(m.value)?"true":void 0,children:[m.label,l==="multiple"?E(de,{}):null]})):t})})}import{jsx as w,jsxs as Ue}from"@ecopages/jsx/jsx-runtime";function fe({children:e,class:t,...i}){return w("div",{...i,"data-tag-list":!0,class:u("rui-tag-group__list",t),children:e})}function ge({value:e,label:t,children:i,class:r,disabled:o,...n}){return Ue("span",{...n,"data-tag":!0,"data-value":e,"data-label":t,class:u("rui-tag",r),"aria-disabled":o?"true":void 0,children:[i,w(be,{})]})}function be({children:e,class:t,aria:i,...r}){return w("button",{...r,aria:j(i,"Remove"),type:"button","data-tag-remove":!0,class:u("rui-tag__remove",t),children:e??w(G,{})})}function pe({children:e}){return w("div",{class:"rui-tag-group","data-ref":"root",children:e})}function gt({tags:e,children:t,...i}){return e!=null?w("rui-tag-group",{...i,children:w(pe,{children:w(fe,{children:e.map(r=>w(ge,{value:r.value,label:typeof r.label=="string"?r.label:void 0,disabled:r.disabled,children:r.label}))})})}):w("rui-tag-group",{...i,children:w(pe,{children:t})})}function ve({children:e,class:t,...i}){return p("div",{...i,class:u("rui-select__control",t),children:e})}function xe({children:e,class:t,disabled:i,...r}){return p("button",{...ae(r,"attr:type"),type:"button","data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:u("rui-select__trigger",t),disabled:i,children:e})}function ye({children:e,class:t,aria:i,disabled:r,...o}){return p("button",{...o,aria:j(i,"Show options"),type:"button","data-select-toggle":!0,class:u("rui-control-toggle",t),disabled:r,tabIndex:-1,children:e??p(pt,{})})}function Ne({children:e,class:t,aria:i,disabled:r,...o}){return p("button",{...o,aria:j(i,"Clear selection"),type:"button","data-select-clear":!0,class:u("rui-control-clear",t),disabled:r,children:e??p(G,{})})}function Se({children:e,class:t,...i}){return p("span",{...i,"data-select-value":!0,class:u("rui-select__value",t),children:e})}function we({children:e,class:t,...i}){return p("div",{...i,"data-select-listbox":!0,class:u("rui-select__listbox rui-popover rui-popover--listbox rui-floating",t),children:e})}function ze({placeholder:e,class:t,disabled:i,...r}){return p("input",{...r,type:"search","data-autocomplete-input":!0,class:u("rui-select__search",t),placeholder:e,disabled:i,autocomplete:"off"})}function Ye(e,t,i){let r=B(t)[0]??"",o=typeof i=="string"?i:"";if(!r)return o;let n=e?.find(s=>s.value===r);return n&&typeof n.label=="string"?n.label:r}function Je({children:e}){return p("div",{class:"rui-select","data-ref":"root",children:e})}function Qe({options:e,children:t,value:i,...r}){let o=N(i),n=B(i),s=r.selectionMode==="multiple",l=e!=null?Ye(e,i,r.placeholder):"",h=e?.filter(b=>n.includes(b.value)).map(b=>({value:b.value,label:b.label}));return p("rui-select",{...r,value:o,children:p(Je,{children:e==null?t:me(Xe,{children:[me(ve,{children:[p(xe,{children:p(Se,{children:s?p(gt,{tags:h??[],label:"Selected options"}):l})}),p(ye,{})]}),p(we,{children:p(Q,{embedded:!0,options:e,selectionMode:r.selectionMode,value:o})})]})})})}export{Q as RuiListbox,ft as RuiListboxOption,Qe as RuiSelect,Ne as RuiSelectClear,ve as RuiSelectControl,le as RuiSelectElement,we as RuiSelectListbox,ze as RuiSelectSearch,ye as RuiSelectToggle,xe as RuiSelectTrigger,Se as RuiSelectValue};
|
|
1
|
+
import{RadiantElement as ft,bindTo as gt,customElement as $i,event as Wi,onEvent as F,onUpdated as Ui,prop as le,query as Hi}from"@ecopages/radiant";var _i=/^[A-Za-z][A-Za-z0-9_-]*$/;function Le(t){return _i.test(t)}function Oi(t){let e=t.trim();if(Le(e))return e;let i=`rui-${e}`;return e&&Le(i)?i:"rui"}function ue(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),i=>i.toString(16).padStart(2,"0")).join("");return`${Oi(t)}-${e}`}function Ae(t){let e=t.previousElementSibling;return e?.tagName.toLowerCase()==="label"?e:t.parentElement?.querySelector("[data-rui-field-label]")??null}function Ti(t,e,i){t.id||(t.id=i.labelId),t.htmlFor||(t.htmlFor=i.controlId),e.setAttribute("aria-labelledby",t.id),e.removeAttribute("aria-label")}function be(t,e,i){if(!e||e.hasAttribute("data-rui-field-managed"))return;let r=Ae(t);if(r){Ti(r,e,i);return}if(i.label){e.setAttribute("aria-label",i.label),e.removeAttribute("aria-labelledby");return}e.removeAttribute("aria-label"),e.removeAttribute("aria-labelledby")}var Ii="data-listbox-option-indicator";function me(t){let e=t.getAttribute("data-label");return e||De(t).trim()}function z(t){return t.getAttribute("data-value")||me(t)}function De(t){if(Ei(t))return"";if(t.nodeType===Node.TEXT_NODE)return t.textContent??"";let e="";for(let i of t.childNodes)e+=De(i);return e}function Ei(t){return t instanceof HTMLElement&&t.hasAttribute(Ii)}var ve=class{config;constructor(e){this.config=e}getListboxHost(){return this.config.getRoot()?.querySelector("rui-listbox")??null}getListbox(){let e=this.getListboxHost();return e?e.querySelector('[role="listbox"]')??e:this.config.getPopup?.()??null}getOptions(){let e=this.getListbox();return e?Array.from(e.querySelectorAll('[role="option"]')):[]}getSelectedValues(){return this.config.getValue()}setSelectedValues(e){this.config.setValue(e)}toggleValue(e){if(this.config.getSelectionMode()==="multiple"){let i=new Set(this.getSelectedValues());i.has(e)?i.delete(e):i.add(e),this.setSelectedValues([...i]);return}this.setSelectedValues([e])}removeValue(e){let i=new Set(this.getSelectedValues());return i.delete(e)?(this.setSelectedValues([...i]),!0):!1}clearValues(){return this.getSelectedValues().length===0?!1:(this.setSelectedValues([]),!0)}findOption(e){return e instanceof Element?e.closest('[role="option"]')??null:null}isSelectableOption(e){return e!=null&&e.getAttribute("aria-disabled")!=="true"&&!e.hidden}syncListboxHost(){let e=this.getListboxHost();e&&(e.embedded=!0,e.selectionMode=this.config.getSelectionMode(),e.value=this.config.getValue())}syncOptionSelection(){let e=new Set(this.getSelectedValues());for(let i of this.getOptions())i.setAttribute("aria-selected",String(e.has(z(i))))}syncMultiselectable(e){if(e){if(this.config.getSelectionMode()==="multiple"){e.setAttribute("aria-multiselectable","true");return}e.removeAttribute("aria-multiselectable")}}getTagGroup(){let e=this.config.tagGroupSelector;if(!e)return null;let i=this.config.getRoot()?.querySelector(e)??null;return!i||typeof i.setItems!="function"?null:i}syncTagGroup(){let e=this.getTagGroup();if(!e)return;let i=this.getSelectedValues().flatMap(r=>{let n=this.getOptions().find(a=>z(a)===r);return n?[{value:r,label:me(n)}]:[]});e.embedded=!0,e.setItems(i),e.value=this.config.getValue()}labelForValue(e){let i=this.getOptions().find(r=>z(r)===e);return i?me(i):e}};var Vi={top:"bottom",bottom:"top",left:"right",right:"left"},Ci=8,_e=new WeakMap;function Ri(t){_e.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",_e.delete(t))}function Li(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let i=t.slice(0,e),r=t.slice(e+1);return{side:i,align:r==="start"||r==="end"?r:"center"}}function je(t){return t==="top"||t==="bottom"?"y":"x"}function ke(t,e,i,r,n){let{width:a,height:u}=e,o=0,f=0;switch(i){case"top":f=t.top-u-n;break;case"bottom":f=t.bottom+n;break;case"left":o=t.left-a-n;break;case"right":o=t.right+n;break}return je(i)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-u:f=t.top+(t.height-u)/2,{x:o,y:f}}function Di(t,e,i,r){let{padding:n,width:a,height:u}=r;return i==="top"?Math.max(0,n-t.y):i==="bottom"?Math.max(0,t.y+e.height-(u-n)):i==="left"?Math.max(0,n-t.x):Math.max(0,t.x+e.width-(a-n))}function Me(t,e,i,r){let{padding:n,width:a,height:u}=r;return i==="top"?t.top-n-e.height:i==="bottom"?u-n-e.height-t.bottom:i==="left"?t.left-n-e.width:a-n-e.width-t.right}function ki(t,e){return e==="center"?t:`${t}-${e}`}function Mi(t,e,i,r){let{padding:n,width:a,height:u}=r;if(je(i)==="y"){let f=Math.max(n,a-n-e.width);return{x:Math.min(Math.max(t.x,n),f),y:Math.max(n,t.y)}}let o=Math.max(n,u-n-e.height);return{x:Math.max(n,t.x),y:Math.min(Math.max(t.y,n),o)}}function ji(t,e,i,r,n={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Ci}){let{side:a,align:u}=Li(i),o=ke(t,e,a,u,r),f=Di(o,e,a,n),_=a,I=o;if(f>0){let C=Vi[a],S=ke(t,e,C,u,r),H=Me(t,e,a,n);Me(t,e,C,n)>H&&(_=C,I=S)}return{coords:Mi(I,e,_,n),placement:ki(_,u)}}function Pi(t,e,i,r,n={}){let a=n.matchAnchorWidth===!0,u=t.offsetWidth,o=a?{width:u,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${u}px`,e.style.minWidth=`${u}px`,e.style.maxWidth=`${u}px`,e.style.boxSizing="border-box",_e.set(e,!0)):Ri(e);let{coords:f,placement:_}=ji(t.getBoundingClientRect(),o,i,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",_),_}function Pe({anchor:t,floating:e,getPlacement:i,gap:r,matchAnchorWidth:n}){let a=()=>{e.hidden||Pi(t,e,i(),r,{matchAnchorWidth:n})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let u=new ResizeObserver(a);return u.observe(t),u.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),u.disconnect()}}function Fe(t,e=document.body){let i=t.parentNode;if(!i)return{unmount:()=>{}};let r=document.createComment("rui-portal");return i.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let n=r.parentNode;n&&(n.insertBefore(t,r),r.remove())}}}function Oe(t,e,i){return i?!!(t?.contains(i)||e?.contains(i)):!1}function Be(t,e,i){return i instanceof Node?!Oe(t,e,i):!0}function Ke(t,e,i){return!Oe(t,e,i)}var ye=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Fe(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Pe({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return Oe(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function qe(t){return t.filter(e=>!e.hidden&&e.getAttribute("aria-disabled")!=="true")}function Ge(t,e,i){return i===0?-1:e===1?t>=i-1?0:t+1:t<=0?i-1:t-1}function Te(t,e){e?.removeAttribute("aria-activedescendant");for(let i of t)i.removeAttribute("data-active")}function $e(t,e,i,r,n){Te(t,r);let a=e[i];return!a||!r?null:(a.id||(a.id=`${n}-${i}`),a.setAttribute("data-active","true"),r.setAttribute("aria-activedescendant",a.id),a.scrollIntoView({block:"nearest"}),a)}var xe=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(e){this.config=e,this.popoverController=new ye({getAnchor:e.getAnchor,getFloating:e.getFloating,getOpen:e.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((e,i)=>{e.id||(e.id=`${this.config.getOptionIdPrefix()}-${i}`)})}getVisibleOptions(){return qe(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,Te(this.config.getOptions(),this.config.getActiveDescendantHost())}setActiveOption(e){let i=this.getVisibleOptions();if(e<0||e>=i.length){this.clearActiveOption();return}this.activeIndex=e,this.visualFocus=!0,$e(this.config.getOptions(),i,e,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(e,i){let r=this.getVisibleOptions();if(r.length){if(!this.config.getOpen()){i(e===1?"first":"last");return}if(this.visualFocus){this.setActiveOption(Ge(this.activeIndex,e,r.length));return}this.setActiveOption(e===1?0:r.length-1)}}handleKeydown(e,i){if(e.ctrlKey||e.shiftKey||e.metaKey)return;this.keydownHandlers[e.key]?.call(this,e,i)}keydownHandlers={ArrowDown:this.handleArrowKey,ArrowUp:this.handleArrowKey,Escape:this.handleEscapeKey,Enter:this.handleActivationKey," ":this.handleActivationKey,Tab:this.handleTabKey};handleArrowKey(e,i){e.preventDefault(),e.stopPropagation();let r=e.key==="ArrowDown"?1:-1;if(e.altKey){this.handleModifiedArrow(r,i);return}this.moveActive(r,n=>i.onOpen(n))}handleModifiedArrow(e,i){e===1&&!i.isOpen&&i.onOpen(),e===-1&&i.isOpen&&i.onClose("arrow")}handleEscapeKey(e,i){e.preventDefault(),i.isOpen?i.onClose("escape"):i.onEscapeWhenClosed?.()}handleActivationKey(e,i){if(!(e.key===" "&&!i.canUseSpace)){if(!i.isOpen&&i.enterWhenClosed==="open"){e.preventDefault(),i.onOpen();return}if(i.isOpen){if(this.hasActiveOption()){e.preventDefault(),i.onSelectActive();return}e.key==="Enter"&&i.enterWithoutActive==="close"&&(e.preventDefault(),i.onClose("enter"))}}}handleTabKey(e,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(e){return Be(this.config.getAnchor(),this.popoverController.getFloatingElement(),e)}shouldDismissPointer(e){return Ke(this.config.getAnchor(),this.popoverController.getFloatingElement(),e)}destroy(){this.popoverController.destroy()}};function We(t){return t?He(t.split(",")):[]}function Fi(t){return t.join(",")}var Ue={fromAttribute:t=>We(t),toAttribute:t=>t.length>0?Fi(t):null,fromProperty:t=>Array.isArray(t)?He(t.map(String)):typeof t=="string"?We(t):[]},ce={type:Array,reflect:!0,transform:Ue};function pe(t){return Ue.fromProperty?.(t)??[]}function He(t){return[...new Set(t.map(e=>e.trim()).filter(Boolean))]}var ze,Xe,Ze,Ye,Je,Qe,Ne,et,tt,it,rt,nt,ot,st,lt,at,ut,ct,dt,ht;function Bi(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:pt(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||pt(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);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,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:Ki(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return Gi(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function Ki(t){var e=qi(t,"string");return typeof e=="symbol"?e:e+""}function qi(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function pt(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function Gi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var mt,bt=class extends ft{static{({e:[Ze,Ye,Je,Qe,Ne,et,tt,it,rt,nt,ot,st,lt,at,ut,ct,dt,ht,ze],c:[mt,Xe]}=Bi(this,[$i("rui-select")],[[[le({...ce,defaultValue:[]}),gt({selector:"[data-select-clear]",bool:"hidden",map:e=>e.length===0})],0,"value"],[le({type:String,defaultValue:""}),0,"label"],[le({type:String,defaultValue:""}),0,"placeholder"],[[le({type:Boolean,reflect:!0,defaultValue:!1}),gt([{selector:"[data-select-trigger]",attr:"aria-disabled",map:e=>e?"true":void 0},{selector:"[data-select-trigger]",prop:"tabIndex",map:e=>e?-1:0},{selector:"[data-select-toggle]",prop:"disabled"},{selector:"[data-select-clear]",prop:"disabled"}])],0,"disabled"],[le({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[le({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[le({type:String,attribute:"trigger-kind",reflect:!0,defaultValue:"manual"}),0,"triggerKind"],[Wi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Hi({ref:"root"}),0,"rootTarget"],[Ui(["value","label","placeholder","disabled","triggerKind","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[F({selector:"[data-select-trigger], [data-select-toggle]",type:"pointerdown"}),2,"onTriggerPointerDown"],[F({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[F({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[F({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[F({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[F({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[F({selector:"[data-select-clear]",type:"click"}),2,"onClearClick"],[F({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[F({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[F({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[F({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[F({ref:"root",type:"focusin"}),2,"onRootFocusIn"],[F({ref:"root",type:"focusout"}),2,"onFocusOut"],[F({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,ft))}constructor(...e){super(...e),ht(this)}value=(ze(this),Ze(this));label=(Ye(this),Je(this));placeholder=(Qe(this),Ne(this));disabled=(et(this),tt(this));selectionMode=(it(this),rt(this));shouldCloseOnSelect=(nt(this),ot(this));triggerKind=(st(this),lt(this));changeEvent=(at(this),ut(this));open=(ct(this),!1);uid=ue("rui-select");collection=new ve({getRoot:()=>this,getSelectionMode:()=>this.selectionMode,getValue:()=>this.value,setValue:e=>{this.value=e},getPopup:()=>this.getListboxPopup(),tagGroupSelector:"[data-select-value] rui-tag-group"});listboxBehavior=new xe({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.collection.getOptions(),getActiveDescendantHost:()=>this.getActiveDescendantHost(),getOptionIdPrefix:()=>`${this.uid}-option`});rootTarget=dt(this);get listboxId(){return`${this.uid}-list`}get triggerId(){return`${this.uid}-trigger`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect!=null?this.shouldCloseOnSelect:!this.isMultiple()}getSearchInput(){return this.querySelector("[data-select-listbox] [data-autocomplete-input]")}hasSearchInput(){return this.getSearchInput()!=null}getActiveDescendantHost(){return this.open&&this.hasSearchInput()?this.getSearchInput():this.getTrigger()}resetSearchFilter(){let e=this.getSearchInput();!e||e.value===""||(e.value="",e.dispatchEvent(new Event("input",{bubbles:!0})))}syncSearchInput(){let e=this.getSearchInput(),i=this.getTrigger(),r=this.collection.getListbox();if(!(!e||!r||!i)){if(this.open){e.setAttribute("role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-expanded","true"),e.setAttribute("aria-controls",this.listboxId),i.removeAttribute("aria-activedescendant");return}e.removeAttribute("role"),e.removeAttribute("aria-autocomplete"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-activedescendant")}}focusPopupInput(){queueMicrotask(()=>{this.getSearchInput()?.focus()})}hasTagGroup(){return this.collection.getTagGroup()!=null}syncTagGroup(){let e=this.getValueElement();this.collection.syncTagGroup(),!(!e||!this.hasTagGroup())&&this.syncTagGroupPlaceholder(e,this.collection.getSelectedValues().length)}syncTagGroupPlaceholder(e,i){let r=e.querySelector("[data-select-placeholder]");if(!this.placeholder){r?.remove();return}r||(r=document.createElement("span"),r.setAttribute("data-select-placeholder","true"),e.insertBefore(r,e.firstChild)),r.textContent=this.placeholder,r.hidden=i>0,e.toggleAttribute("data-placeholder",i===0)}removeSelectedValue(e){this.collection.removeValue(e)&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.changeEvent.emit({value:this.value}))}clearSelection(){this.collection.clearValues()&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.changeEvent.emit({value:[]}),this.getTrigger()?.focus())}getTrigger(){return this.querySelector("[data-select-trigger]")}isTriggerFocusTarget(e){let i=this.getTrigger();return!i||!(e instanceof Node)||!i.contains(e)?!1:!(e instanceof Element&&e.closest("[data-tag-remove]"))}getToggle(){return this.querySelector("[data-select-toggle]")}getValueElement(){return this.querySelector("[data-select-value]")}getListboxPopup(){return this.querySelector("[data-select-listbox]")}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return Ae(this)?.textContent?.trim()||this.label||"Options"}syncLabel(){let e=this.getTrigger();be(this,e,{controlId:this.triggerId,label:this.label,labelId:`${this.uid}-label`})}syncTrigger(){let e=this.getTrigger(),i=this.collection.getListbox(),r=this.getListboxPopup();!e||!i||(e.id||(e.id=this.triggerId),i.id||(i.id=this.listboxId),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-autocomplete","none"),e.setAttribute("aria-expanded",String(this.open)),e.setAttribute("aria-controls",this.listboxId),i.setAttribute("aria-label",this.getAccessibleName()),this.collection.syncMultiselectable(i),r&&(r.removeAttribute("role"),r.removeAttribute("aria-label"),r.removeAttribute("aria-multiselectable")),this.syncToggle(),this.syncSearchInput())}syncToggle(){let e=this.getToggle();e&&e.setAttribute("aria-expanded",String(this.open))}syncValueDisplay(){if(this.hasTagGroup()){this.syncTagGroup();return}let e=this.getValueElement();if(!e||e.childElementCount>0)return;let i=this.collection.getSelectedValues();if(i.length===0){e.textContent="",e.toggleAttribute("data-placeholder",!0),this.placeholder&&(e.textContent=this.placeholder);return}if(e.toggleAttribute("data-placeholder",!1),this.isMultiple()){e.textContent=i.map(r=>this.collection.labelForValue(r)).join(", ");return}e.textContent=this.collection.labelForValue(i[0])}setOpen(e,i={}){let r=i.activate??"none";this.open=e;let n=this.getTrigger(),a=this.getListboxPopup();if(!(!n||!a)){if(n.setAttribute("aria-expanded",String(e)),a.toggleAttribute("hidden",!e),!e){this.listboxBehavior.clearActiveOption(),this.resetSearchFilter(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition(),this.hasSearchInput()&&this.focusPopupInput(),r==="first"){let u=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(u.length?0:-1);return}if(r==="last"){let u=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(u.length?u.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}selectOption(e){this.collection.isSelectableOption(e)&&(this.collection.toggleValue(z(e)),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&(this.resetSearchFilter(),this.setOpen(!1),this.getTrigger()?.focus()))}handleListboxKeydown(e){this.listboxBehavior.handleKeydown(e,{isOpen:this.open,canUseSpace:!this.hasSearchInput(),closesOnTab:this.closesOnSelect(),enterWhenClosed:"open",enterWithoutActive:"ignore",onOpen:(i="none")=>this.setOpen(!0,{activate:i}),onClose:i=>{this.setOpen(!1),(i==="arrow"||i==="escape")&&this.getTrigger()?.focus()},onSelectActive:()=>{let i=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];i&&this.selectOption(i)}})}handleTriggerKeydown(e){this.handleListboxKeydown(e)}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection()}onTriggerPointerDown(e){this.triggerKind==="focus"&&e.preventDefault()}onTriggerClick(e){e.preventDefault();let i=this.getTrigger();if(!(!i||this.disabled)){if(this.open?this.setOpen(!1):this.setOpen(!0),this.open&&this.hasSearchInput()){this.focusPopupInput();return}i.focus()}}onTriggerKeydown(e){this.handleTriggerKeydown(e)}onSearchKeydown(e){this.handleListboxKeydown(e)}onSearchInput(){this.open&&this.listboxBehavior.clearActiveOption()}onTagRemove(e){let i=e.detail;i?.value&&this.removeSelectedValue(i.value)}onClearClick(e){e.preventDefault(),e.stopPropagation(),this.clearSelection()}onTagClick(e){e.target.closest("[data-tag-remove]")||e.stopPropagation()}onOptionPointerOver(e){if(!this.open)return;let i=this.collection.findOption(e.target);if(!this.collection.isSelectableOption(i))return;let n=this.listboxBehavior.getVisibleOptions().indexOf(i);n>=0&&this.listboxBehavior.setActiveOption(n)}onOptionMouseDown(e){e.preventDefault()}onOptionClick(e){let i=this.collection.findOption(e.target);i&&this.selectOption(i)}onRootFocusIn(e){this.triggerKind!=="focus"||this.disabled||this.open||!this.isTriggerFocusTarget(e.target)||e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this.setOpen(!0)}onFocusOut(e){this.listboxBehavior.shouldDismissFocus(e.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(e){this.open&&this.listboxBehavior.shouldDismissPointer(e.target)&&this.setOpen(!1)}static{Xe()}};import{Fragment as br,jsx as V,jsxs as vi}from"@ecopages/jsx/jsx-runtime";function de(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function T(...t){return t.filter(Boolean).join(" ")}import{jsx as vt}from"@ecopages/jsx/jsx-runtime";function Ie({class:t,size:e="sm",...i}){return vt("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:vt("path",{d:"m5 12 4 4L19 6"})})}import{jsx as yt}from"@ecopages/jsx/jsx-runtime";function Ee({class:t,size:e="sm",...i}){return yt("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:yt("path",{d:"m6 9 6 6 6-6"})})}import{jsx as xt,jsxs as zi}from"@ecopages/jsx/jsx-runtime";var St="http://www.w3.org/2000/svg";function fe({class:t,size:e="sm",...i}){return zi("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[xt("path",{d:"m18 6-12 12"}),xt("path",{d:"m6 6 12 12"})]})}function wt(){let t=document.createElementNS(St,"svg");t.setAttribute("class","rui-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let e of["m18 6-12 12","m6 6 12 12"]){let i=document.createElementNS(St,"path");i.setAttribute("d",e),t.append(i)}return t}import{RadiantElement as Kt,bindTo as tr,customElement as ir,event as rr,onEvent as qt,onUpdated as nr,prop as he}from"@ecopages/radiant";function Xi(t,e){t.forEach((i,r)=>{let n=r===e?0:-1;i.tabIndex!==n&&(i.tabIndex=n)})}function Zi(t,e){if(!t.length)return null;let i=Math.max(0,Math.min(t.length-1,e));return Xi(t,i),t[i]?.focus(),t[i]??null}function Yi(t,e){return t==="Home"?"first":t==="End"?"last":e==="horizontal"?t==="ArrowRight"?"next":t==="ArrowLeft"?"prev":null:t==="ArrowDown"?"next":t==="ArrowUp"?"prev":null}function Se(t){let{items:e,current:i,key:r,orientation:n="horizontal",wrap:a=!0}=t;if(!e.length||!i)return{handled:!1};let u=e.indexOf(i);if(u<0)return{handled:!1};let o=Yi(r,n);if(!o)return{handled:!1};let f=u;o==="first"?f=0:o==="last"?f=e.length-1:o==="next"?f=a?(u+1)%e.length:Math.min(e.length-1,u+1):f=a?(u-1+e.length)%e.length:Math.max(0,u-1);let _=Zi(e,f);return _?{handled:!0,index:f,item:_}:{handled:!1}}var At,_t,Ot,Tt,It,Et,Vt,Ct,Rt,Lt,Dt,kt,Mt,jt,Pt,Ft;function Ji(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:Bt(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||Bt(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);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,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:Qi(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return er(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function Qi(t){var e=Ni(t,"string");return typeof e=="symbol"?e:e+""}function Ni(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bt(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function er(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var $t,Gt=class extends Kt{static{({e:[Ot,Tt,It,Et,Vt,Ct,Rt,Lt,Dt,kt,Mt,jt,Pt,Ft,At],c:[$t,_t]}=Ji(this,[ir("rui-listbox")],[[he({...ce,defaultValue:[]}),0,"value"],[he({type:String,defaultValue:""}),0,"label"],[he({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[[he({type:String,attribute:"selection-mode",defaultValue:"single"}),tr({selector:'[role="listbox"]',attr:"aria-multiselectable",map:e=>e==="multiple"?"true":void 0})],0,"selectionMode"],[he({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[he({type:Boolean,reflect:!0}),0,"bordered"],[rr({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[nr(["value","label","disabled","embedded","selectionMode"]),2,"onPropsUpdated"],[qt({selector:'[role="option"]',type:"click"}),2,"onOptionClick"],[qt({selector:'[role="option"]',type:"keydown"}),2,"onOptionKeydown"]],0,void 0,Kt))}value=(At(this),Ot(this));label=(Tt(this),It(this));disabled=(Et(this),Vt(this));selectionMode=(Ct(this),Rt(this));embedded=(Lt(this),Dt(this));bordered=(kt(this),Mt(this));changeEvent=(jt(this),Pt(this));uid=(Ft(this),ue("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 e=this.querySelector('[role="listbox"]');e&&(e.id||(e.id=`${this.uid}-list`),be(this,e,{controlId:e.id,label:this.label,labelId:`${this.uid}-label`}))}getSelectedValues(){return this.value}setSelectedValues(e){this.value=e}tabIndexFor(e,i){return this.embedded?-1:e===i?0:-1}sync(){let e=this.getOptions(),i=new Set(this.getSelectedValues()),r=e.find(n=>i.has(z(n)))??e[0];for(let n of e){let a=i.has(z(n));n.setAttribute("aria-selected",String(a)),n.tabIndex=this.tabIndexFor(n,r)}}select(e){if(this.disabled||e.getAttribute("aria-disabled")==="true")return;let i=z(e);if(this.selectionMode==="multiple"){let r=new Set(this.getSelectedValues());r.has(i)?r.delete(i):r.add(i),this.setSelectedValues([...r])}else this.setSelectedValues([i]);this.sync(),this.changeEvent.emit({value:this.value}),e.focus()}onOptionClick(e){if(this.embedded)return;let i=e.target.closest('[role="option"]');i&&this.contains(i)&&this.select(i)}onOptionKeydown(e){if(this.embedded)return;let i=this.getOptions(),r=e.target.closest('[role="option"]');if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.select(r);return}let n=Se({items:i,current:r,key:e.key,orientation:"vertical"});if(n.handled){if(e.preventDefault(),this.selectionMode==="multiple"){n.item.focus();return}this.select(n.item)}}static{_t()}};import{jsx as ae,jsxs as or}from"@ecopages/jsx/jsx-runtime";function Ve({value:t,label:e,children:i,class:r,disabled:n,...a}){return ae("div",{...a,class:T("rui-listbox__option",r),role:"option","data-value":t,"data-label":e,"aria-disabled":n?"true":void 0,tabindex:-1,children:i})}function Wt({children:t,class:e,...i}){return ae("span",{...i,"data-listbox-option-indicator":!0,"aria-hidden":"true",class:T("rui-listbox__option-indicator",e),children:t??ae(Ie,{})})}function sr(t,e){return e??!t}function lr({bordered:t,children:e,disabled:i,embedded:r,label:n,selectionMode:a="single"}){return ae("div",{class:T("rui-listbox",t&&"rui-listbox--bordered"),role:"listbox","data-rui-control":r?void 0:!0,"data-rui-control-type":r?void 0:"text","aria-label":n||void 0,"aria-disabled":i?"true":void 0,"aria-multiselectable":a==="multiple"?"true":void 0,children:e})}function we({options:t,children:e,value:i,embedded:r,bordered:n,label:a,disabled:u,selectionMode:o="single",...f}){let _=sr(r,n),I=pe(i),C=new Set(I);return ae("rui-listbox",{...f,value:I,embedded:r,bordered:n,label:a,disabled:u,selectionMode:o,children:ae(lr,{bordered:_,disabled:u,embedded:r,label:a,selectionMode:o,children:t!=null?t.map(S=>or(Ve,{value:S.value,label:typeof S.label=="string"?S.label:void 0,disabled:S.disabled,"aria-selected":C.has(S.value)?"true":void 0,children:[S.label,o==="multiple"?ae(Wt,{}):null]})):e})})}import{RadiantElement as ci,customElement as hr,event as di,onEvent as Ce,onUpdated as pr,prop as ge,state as fr}from"@ecopages/radiant";var Ut,Ht,zt,Xt,Zt,Yt,Jt,Qt,Nt,ei,ti,ii,ri,ni,oi,si,li,ai;function ar(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:ui(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||ui(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);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,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:ur(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return dr(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function ur(t){var e=cr(t,"string");return typeof e=="symbol"?e:e+""}function cr(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ui(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function dr(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var pi,hi=class extends ci{static{({e:[zt,Xt,Zt,Yt,Jt,Qt,Nt,ei,ti,ii,ri,ni,oi,si,li,ai,Ut],c:[pi,Ht]}=ar(this,[hr("rui-tag-group")],[[ge({...ce,defaultValue:[]}),0,"value"],[ge({type:String,defaultValue:""}),0,"label"],[ge({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[ge({type:String,attribute:"selection-mode",defaultValue:"multiple"}),0,"selectionMode"],[ge({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[di({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[di({name:"rui-remove",bubbles:!0,composed:!0}),0,"removeEvent"],[fr,0,"derivedItems"],[pr(["value","label","disabled","selectionMode","embedded","derivedItems"]),2,"onPropsUpdated"],[Ce({selector:"[data-tag]",type:"click"}),2,"onTagClick"],[Ce({selector:"[data-tag-remove]",type:"click"}),2,"onRemoveClick"],[Ce({selector:"[data-tag]",type:"keydown"}),2,"onTagKeydown"]],0,void 0,ci))}constructor(...e){super(...e),ai(this)}value=(Ut(this),zt(this));label=(Xt(this),Zt(this));disabled=(Yt(this),Jt(this));selectionMode=(Qt(this),Nt(this));embedded=(ei(this),ti(this));changeEvent=(ii(this),ri(this));removeEvent=(ni(this),oi(this));uid=(si(this),ue("rui-tag-group"));derivedItems=li(this,null);isMultiple(){return this.selectionMode==="multiple"}getSelectedValues(){return this.value}setSelectedValues(e){this.value=e}getList(){let e=this.querySelector("[data-rui-managed-list]");return e||(this.derivedItems!=null?null:this.querySelector("[data-tag-list]"))}getTags(){let e=this.getList();return e?Array.from(e.querySelectorAll("[data-tag]")):[]}getVisibleTags(){return this.getTags().filter(e=>!e.hidden&&e.getAttribute("aria-disabled")!=="true")}getTagValue(e){return e.getAttribute("data-value")||e.textContent?.trim()||""}getTagLabel(e){return e.getAttribute("data-label")||e.textContent?.trim()||""}ensureTagIds(){this.getTags().forEach((e,i)=>{e.id||(e.id=`${this.uid}-tag-${i}`)})}syncList(){let e=this.getList();e&&(e.id||(e.id=`${this.uid}-list`),e.setAttribute("role","list"),e.setAttribute("aria-label",this.label||"Tags"),this.disabled?e.setAttribute("aria-disabled","true"):e.removeAttribute("aria-disabled"))}syncTags(){let e=new Set(this.getSelectedValues());this.getTags().forEach((r,n)=>{r.setAttribute("role","listitem");let a=this.getTagValue(r),u=e.has(a);r.setAttribute("aria-selected",String(u)),r.tabIndex=n===0?0:-1;let o=r.querySelector("[data-tag-remove]");o&&(o.type="button",o.tabIndex=-1,o.setAttribute("aria-label",`Remove ${this.getTagLabel(r)}`))})}selectTag(e){if(this.disabled||this.embedded||e.getAttribute("aria-disabled")==="true")return;let i=this.getTagValue(e);if(this.isMultiple()){let r=new Set(this.getSelectedValues());r.has(i)?r.delete(i):r.add(i),this.setSelectedValues([...r])}else this.value=[i];this.syncTags(),this.changeEvent.emit({value:this.value})}removeTag(e){let i=this.getTagValue(e),r=new Set(this.getSelectedValues());r.delete(i),this.setSelectedValues([...r]),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(e){this.derivedItems=e,this.value=e.map(i=>i.value)}createManagedTag(e){let i=document.createElement("span");i.setAttribute("data-tag",""),i.setAttribute("data-value",e.value),i.setAttribute("data-label",e.label),i.className="rui-tag",i.textContent=e.label,i.setAttribute("aria-label",e.label);let r=document.createElement("button");return r.type="button",r.setAttribute("data-tag-remove",""),r.className="rui-tag__remove",r.setAttribute("aria-label",`Remove ${e.label}`),r.append(wt()),i.append(r),i}syncManagedList(){let e=this.querySelector('[data-ref="root"]');if(!e||this.derivedItems==null)return;e.querySelector("[data-tag-list]:not([data-rui-managed-list])")?.toggleAttribute("hidden",!0);let r=e.querySelector("[data-rui-managed-list]");if(this.derivedItems.length===0){r?.remove();return}r||(r=document.createElement("div"),r.setAttribute("data-tag-list",""),r.setAttribute("data-rui-managed-list",""),r.className="rui-tag-group__list",e.appendChild(r)),r.replaceChildren(...this.derivedItems.map(n=>this.createManagedTag(n))),this.ensureTagIds(),this.syncList(),this.syncTags()}onTagClick(e){let i=e.target;if(i.closest("[data-tag-remove]"))return;let r=i.closest("[data-tag]");r&&this.contains(r)&&this.selectTag(r)}onRemoveClick(e){e.stopPropagation();let r=e.target.closest("[data-tag]");r&&this.contains(r)&&this.removeTag(r)}onTagKeydown(e){let i=this.getVisibleTags(),r=e.target.closest("[data-tag]");if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.embedded||this.selectTag(r);return}if(e.key==="Backspace"||e.key==="Delete"){r.querySelector("[data-tag-remove]")&&(e.preventDefault(),this.removeTag(r));return}Se({items:i,current:r,key:e.key,orientation:"horizontal"}).handled&&e.preventDefault()}static{Ht()}};import{jsx as U,jsxs as gr}from"@ecopages/jsx/jsx-runtime";function gi({children:t,class:e,...i}){return U("div",{...i,"data-tag-list":!0,class:T("rui-tag-group__list",e),children:t})}function bi({value:t,label:e,children:i,class:r,disabled:n,aria:a,...u}){return gr("span",{...u,"data-tag":!0,"data-value":t,"data-label":e,class:T("rui-tag",r),aria:de(a,e),"aria-disabled":n?"true":void 0,children:[i,U(mi,{})]})}function mi({children:t,class:e,aria:i,...r}){return U("button",{...r,aria:de(i,"Remove"),type:"button","data-tag-remove":!0,class:T("rui-tag__remove",e),children:t??U(fe,{})})}function fi({children:t}){return U("div",{class:"rui-tag-group","data-ref":"root",children:t})}function Re({tags:t,children:e,value:i,...r}){return t!=null?U("rui-tag-group",{...r,value:i,children:U(fi,{children:U(gi,{children:t.map(n=>U(bi,{value:n.value,label:typeof n.label=="string"?n.label:void 0,disabled:n.disabled,children:n.label}))})})}):U("rui-tag-group",{...r,value:i,children:U(fi,{children:e})})}function yi({children:t,class:e,...i}){return V("div",{...i,class:T("rui-select__control",e),children:t})}function xi({children:t,class:e,disabled:i,...r}){return V("div",{...r,"data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:T("rui-select__trigger",e),tabIndex:i?-1:0,"aria-disabled":i?"true":void 0,children:t})}function Si({children:t,class:e,aria:i,disabled:r,...n}){return V("button",{...n,aria:de(i,"Show options"),type:"button","data-select-toggle":!0,class:T("rui-control-toggle",e),disabled:r,tabIndex:-1,children:t??V(Ee,{})})}function mr({children:t,class:e,aria:i,disabled:r,...n}){return V("button",{...n,aria:de(i,"Clear selection"),type:"button","data-select-clear":!0,class:T("rui-control-clear",e),disabled:r,children:t??V(fe,{})})}function wi({children:t,class:e,...i}){return V("span",{...i,"data-select-value":!0,class:T("rui-select__value",e),children:t})}function Ai({children:t,class:e,...i}){return V("div",{...i,"data-select-listbox":!0,class:T("rui-select__listbox rui-popover rui-popover--listbox rui-floating",e),children:t})}function vr({placeholder:t,class:e,disabled:i,...r}){return V("input",{...r,type:"search","data-autocomplete-input":!0,class:T("rui-select__search",e),placeholder:t,disabled:i,autocomplete:"off"})}function yr(t,e,i){let r=pe(e)[0]??"",n=typeof i=="string"?i:"";if(!r)return n;let a=t?.find(u=>u.value===r);return a&&typeof a.label=="string"?a.label:r}function xr({children:t}){return V("div",{class:"rui-select","data-ref":"root",children:t})}function Sr({options:t,children:e,value:i,...r}){let n=pe(i),a=r.selectionMode==="multiple",u=t!=null?yr(t,i,r.placeholder):"",o=t?.filter(f=>n.includes(f.value)).map(f=>({value:f.value,label:f.label}));return V("rui-select",{...r,value:n,children:V(xr,{children:t==null?e:vi(br,{children:[vi(yi,{children:[V(xi,{disabled:r.disabled,children:V(wi,{children:a?V(Re,{tags:o??[],label:"Selected options"}):u})}),V(Si,{})]}),V(Ai,{children:V(we,{embedded:!0,options:t,selectionMode:r.selectionMode,value:n})})]})})})}export{we as RuiListbox,Ve as RuiListboxOption,Sr as RuiSelect,mr as RuiSelectClear,yi as RuiSelectControl,mt as RuiSelectElement,Ai as RuiSelectListbox,vr as RuiSelectSearch,Si as RuiSelectToggle,xi as RuiSelectTrigger,wi as RuiSelectValue};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|