@ecopages/radiant-ui 0.1.0-rc.18 → 0.1.0-rc.19
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 +1 -1
- package/dist/components/ui/combobox/combobox.script.d.ts +7 -1
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +2 -2
- package/dist/components/ui/date-field/date-field.script.d.ts +4 -2
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +3 -3
- package/dist/components/ui/date-input/date-input-segment-dom.d.ts +0 -1
- package/dist/components/ui/date-input/date-input.css +6 -5
- package/dist/components/ui/date-input/date-input.d.ts +4 -0
- package/dist/components/ui/date-input/date-input.script.d.ts +67 -14
- package/dist/components/ui/date-input/index.js +1 -1
- package/dist/components/ui/date-input/index.js.map +3 -3
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +5 -4
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +3 -3
- package/dist/components/ui/field/field.d.ts +1 -1
- package/dist/components/ui/field/field.script.d.ts +12 -2
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +3 -3
- package/dist/components/ui/form/control-protocol.d.ts +26 -3
- package/dist/components/ui/form/form.script.d.ts +4 -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 +3 -3
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- 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.script.d.ts +7 -8
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.script.d.ts +1 -0
- 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/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +3 -3
- 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/select/index.d.ts +1 -1
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +3 -3
- package/dist/components/ui/select/select.script.d.ts +18 -0
- 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 +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +35 -38
- package/dist/components/ui/sidebar/sidebar.css +53 -66
- package/dist/components/ui/sidebar/sidebar.script.d.ts +5 -7
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +3 -3
- package/dist/components/ui/slider/slider.script.d.ts +6 -12
- package/dist/components/ui/tag-group/tag-group.script.d.ts +1 -0
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/lib/intl-date/index.d.ts +3 -3
- package/dist/lib/intl-date/segment-editing.d.ts +0 -1
- package/dist/lib/intl-date/segments.d.ts +26 -0
- package/dist/styles/radiant-ui.css +14 -0
- package/dist/styles/styles.css +82 -40
- package/dist/styles/tailwind.css +14 -0
- 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/package.json +7 -7
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ pnpm run lint
|
|
|
46
46
|
pnpm run build:lib # generate exports + build JS/types + compile CSS
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
`test:storybook` runs stories through the Vitest addon (no Storybook dev server). `test:ssr:smoke` and `test:ssr` spawn Storybook, visit stories in Playwright, and fail on `.radiant-ssr-error` banners or disallowed page errors. Empty mounts fail only for stories listed in `scripts/storybook-ssr-harness.ts` (`expectsMount` / `allowEmptyMount`).
|
|
49
|
+
`test:storybook` runs stories through the Vitest addon (no Storybook dev server). `test:ssr:smoke` and `test:ssr` spawn Storybook, visit stories in Playwright, and fail on `.radiant-ssr-error` banners or disallowed page errors. For stories expected to mount, the harness waits briefly for content or an SSR error banner before checking the result. Empty mounts fail only for stories listed in `scripts/storybook-ssr-harness.ts` (`expectsMount` / `allowEmptyMount`).
|
|
50
50
|
|
|
51
51
|
Published CSS under `dist/` is **already compiled** (Tailwind `@apply` resolved). Theme and token values remain CSS custom properties so apps can swap themes at runtime. The package does not minify CSS.
|
|
52
52
|
|
|
@@ -79,6 +79,8 @@ export type RuiComboboxChangeDetail = {
|
|
|
79
79
|
* @remarks
|
|
80
80
|
* Minimum tree: `[data-ref="root"]` > `[data-combobox-input]` + `[data-combobox-listbox]`
|
|
81
81
|
* > `rui-listbox[embedded]` > `[role="option"]`. BEM classes live on the view helpers.
|
|
82
|
+
* Not form-associated: wrap in `rui-field` and read `RuiForm` `onSubmit`.
|
|
83
|
+
* Typed filter text is not a form value and is not listed in native `FormData`.
|
|
82
84
|
*/
|
|
83
85
|
export declare class RuiCombobox extends RadiantElement {
|
|
84
86
|
value: string[];
|
|
@@ -90,7 +92,6 @@ export declare class RuiCombobox extends RadiantElement {
|
|
|
90
92
|
triggerKind: RuiComboboxTriggerKind;
|
|
91
93
|
changeEvent: EventEmitter<RuiComboboxChangeDetail>;
|
|
92
94
|
private open;
|
|
93
|
-
private skipNextFocusOpen;
|
|
94
95
|
private readonly uid;
|
|
95
96
|
private readonly collection;
|
|
96
97
|
private readonly listboxBehavior;
|
|
@@ -125,6 +126,11 @@ export declare class RuiCombobox extends RadiantElement {
|
|
|
125
126
|
protected onConnected(): void;
|
|
126
127
|
disconnectedCallback(): void;
|
|
127
128
|
onPropsUpdated(): void;
|
|
129
|
+
/**
|
|
130
|
+
* @remarks With `trigger-kind="focus"`, only focus arriving from outside the host
|
|
131
|
+
* opens the listbox. Focus the host moves back itself (option select, clear,
|
|
132
|
+
* trigger, tag remove) comes from a descendant and never reopens it.
|
|
133
|
+
*/
|
|
128
134
|
onRootFocusIn(event: FocusEvent): void;
|
|
129
135
|
/** @remarks Typing returns visual focus to the textbox. */
|
|
130
136
|
onRootInput(event: Event): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
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 Ot(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=Ot(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,It=new WeakMap;function Hi(e){It.has(e)&&(e.style.width="",e.style.minWidth="",e.style.maxWidth="",e.style.boxSizing="",It.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),O=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&&(O=R,C=A)}return{coords:Yi(C,t,O,o),placement:Zi(O,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",It.set(t,!0)):Hi(t);let{coords:x,placement:O}=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",O),O}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,O,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 k(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,V=a===1,J=a===3,N=a===4,D=a===2;function F(h,I,it){return function(j,nt){return I&&(nt=j,j=r),it&&it(j),d[h].call(j,nt)}}if(!q){var d={},$=[],_=J?"get":N||V?"set":"value";if(v?(y||V?d={get:ye(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||ye(d[_],l,D?"":_)):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,M=K.length-1;M>=0;M-=f?2:1){var tt=w(K[M],"A decorator","be",!0),et=f?K[M-1]:void 0,W={},T={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,I){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(I,"An initializer","be",!0),g.push(I)}.bind(null,W)};if(q)s=tt.call(et,p,T),W.v=1,w(s,"class decorators","return")&&(p=s);else if(T.static=m,T.private=v,s=T.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?D?function(h){return P(h),d.value}:F("get",0,P):function(h){return h[l]}),D||J||(s.set=v?F("set",0,P):function(h,I){h[l]=I}),p=tt.call(et,V?{get:d.get,set:d.set}:d[_],T),W.v=1,V){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(k($,m,1),k(g,m,0)),y||q||(v?V?S.splice(-1,0,F("get",m),F("set",m)):S.push(D?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(k(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?O=O||[]: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(O),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),k(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);skipNextFocusOpen=!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 Ot(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.skipNextFocusOpen=!0,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){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 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.skipNextFocusOpen=!0,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 jt}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 Vt({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 Tt({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 Oe,jsxs as dn}from"@ecopages/jsx/jsx-runtime";var Ie="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:[Oe("path",{d:"m18 6-12 12"}),Oe("path",{d:"m6 6 12 12"})]})}function Ce(){let e=document.createElementNS(Ie,"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(Ie,"path");i.setAttribute("d",t),e.append(i)}return e}import{RadiantElement as Fe,customElement as bn,onEvent as gn,onUpdated as vn,prop as Me}from"@ecopages/radiant";var Ee,Ve,Te,Re,Le,ke;function hn(e,t,i,n,o,u){var c,s,x,O,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 k(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,V=a===1,J=a===3,N=a===4,D=a===2;function F(h,I,it){return function(j,nt){return I&&(nt=j,j=r),it&&it(j),d[h].call(j,nt)}}if(!q){var d={},$=[],_=J?"get":N||V?"set":"value";if(v?(y||V?d={get:De(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||De(d[_],l,D?"":_)):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,M=K.length-1;M>=0;M-=f?2:1){var tt=w(K[M],"A decorator","be",!0),et=f?K[M-1]:void 0,W={},T={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,I){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(I,"An initializer","be",!0),g.push(I)}.bind(null,W)};if(q)s=tt.call(et,p,T),W.v=1,w(s,"class decorators","return")&&(p=s);else if(T.static=m,T.private=v,s=T.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?D?function(h){return P(h),d.value}:F("get",0,P):function(h){return h[l]}),D||J||(s.set=v?F("set",0,P):function(h,I){h[l]=I}),p=tt.call(et,V?{get:d.get,set:d.set}:d[_],T),W.v=1,V){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(k($,m,1),k(g,m,0)),y||q||(v?V?S.splice(-1,0,F("get",m),F("set",m)):S.push(D?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(k(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?O=O||[]: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(O),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),k(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 De(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,je=class extends Fe{static{({e:[Te,Re,Le,ke,Ee],c:[Be,Ve]}=hn(this,[bn("rui-autocomplete")],[[Me({type:String,defaultValue:"base"}),0,"sensitivity"],[Me({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,Fe))}sensitivity=(Ee(this),Te(this));inputValue=(Re(this),Le(this));externalInput=(ke(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{Ve()}};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 kt({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 Vn,onEvent as ni,onUpdated as Tn,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 O=wn(t,x);return O?{handled:!0,index:x,item:O}:{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,O,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 k(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,V=a===1,J=a===3,N=a===4,D=a===2;function F(h,I,it){return function(j,nt){return I&&(nt=j,j=r),it&&it(j),d[h].call(j,nt)}}if(!q){var d={},$=[],_=J?"get":N||V?"set":"value";if(v?(y||V?d={get:ei(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||ei(d[_],l,D?"":_)):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,M=K.length-1;M>=0;M-=f?2:1){var tt=w(K[M],"A decorator","be",!0),et=f?K[M-1]:void 0,W={},T={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,I){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(I,"An initializer","be",!0),g.push(I)}.bind(null,W)};if(q)s=tt.call(et,p,T),W.v=1,w(s,"class decorators","return")&&(p=s);else if(T.static=m,T.private=v,s=T.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?D?function(h){return P(h),d.value}:F("get",0,P):function(h){return h[l]}),D||J||(s.set=v?F("set",0,P):function(h,I){h[l]=I}),p=tt.call(et,V?{get:d.get,set:d.set}:d[_],T),W.v=1,V){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(k($,m,1),k(g,m,0)),y||q||(v?V?S.splice(-1,0,F("get",m),F("set",m)):S.push(D?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(k(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?O=O||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return In(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(O),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),k(r,1)]}}}function Sn(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 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 In(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"],[Vn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Tn(["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 Dt({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(Vt,{})})}function Ln(e,t){return t??!e}function kn({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 O=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(kn,{bordered:O,disabled:c,embedded:n,label:u,selectionMode:s,children:e!=null?e.map(A=>Rn(Dt,{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 Ii,customElement as Bn,event as Ci,onEvent as Ft,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 Dn(e,t,i,n,o,u){var c,s,x,O,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 k(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,V=a===1,J=a===3,N=a===4,D=a===2;function F(h,I,it){return function(j,nt){return I&&(nt=j,j=r),it&&it(j),d[h].call(j,nt)}}if(!q){var d={},$=[],_=J?"get":N||V?"set":"value";if(v?(y||V?d={get:Oi(function(){return Y(this)},l,"get"),set:function(h){b[4](this,h)}}:d[_]=Y,y||Oi(d[_],l,D?"":_)):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,M=K.length-1;M>=0;M-=f?2:1){var tt=w(K[M],"A decorator","be",!0),et=f?K[M-1]:void 0,W={},T={kind:["field","accessor","method","getter","setter","class"][a],name:l,metadata:c,addInitializer:function(h,I){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(I,"An initializer","be",!0),g.push(I)}.bind(null,W)};if(q)s=tt.call(et,p,T),W.v=1,w(s,"class decorators","return")&&(p=s);else if(T.static=m,T.private=v,s=T.access={has:v?Z.bind():function(h){return l in h}},N||(s.get=v?D?function(h){return P(h),d.value}:F("get",0,P):function(h){return h[l]}),D||J||(s.set=v?F("set",0,P):function(h,I){h[l]=I}),p=tt.call(et,V?{get:d.get,set:d.set}:d[_],T),W.v=1,V){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(k($,m,1),k(g,m,0)),y||q||(v?V?S.splice(-1,0,F("get",m),F("set",m)):S.push(D?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(k(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:Fn(S),g,g<2?[]:r?O=O||[]:x=x||[],C,!!r,m,b,r&&m?function(y){return jn(y)===e}:o)}}},A(8,0),A(0,0),A(8,1),A(0,1),R(x),R(O),s=C,H||Q(e),{e:s,get c(){var r=[];return H&&[Q(e=X(e,[t],n,e.name,5,r)),k(r,1)]}}}function Fn(e){var t=Mn(e,"string");return typeof t=="symbol"?t:t+""}function Mn(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 Oi(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 jn(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 Vi,Ei=class extends Ii{static{({e:[ui,ci,di,hi,pi,fi,mi,bi,gi,vi,yi,xi,wi,_i,Ai,Si,li],c:[Vi,ai]}=Dn(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"],[Ft({selector:"[data-tag]",type:"click"}),2,"onTagClick"],[Ft({selector:"[data-tag-remove]",type:"click"}),2,"onRemoveClick"],[Ft({selector:"[data-tag]",type:"keydown"}),2,"onTagKeydown"]],0,void 0,Ii))}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(ki,{})]})}function ki({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 Ti({children:e}){return rt("div",{class:"rui-tag-group","data-ref":"root",children:e})}function Mt({tags:e,children:t,value:i,...n}){return e!=null?rt("rui-tag-group",{...n,value:i,children:rt(Ti,{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(Ti,{children:t})})}function Fi({children:e,class:t,...i}){return L("div",{...i,class:E("rui-combobox__control",t),children:e})}function Mi({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 ji({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(Tt,{})})}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 Di({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:jt(Di,{children:[jt(Fi,{children:[c?L(Bi,{children:L(Mt,{tags:u??[],label:"Selected options"})}):null,L(Mi,{placeholder:n.placeholder,disabled:n.disabled}),L(ji,{})]}),L(Pi,{children:L(kt,{children:jt(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(Di,{children:t})})}export{Wn as RuiCombobox,$n as RuiComboboxClear,Fi as RuiComboboxControl,_e as RuiComboboxElement,Mi as RuiComboboxInput,Pi as RuiComboboxListbox,ji as RuiComboboxTrigger,Bi as RuiComboboxValue,St as RuiListbox,Dt 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
|