@ecopages/radiant-ui 0.1.0-rc.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/components/ui/alert/alert.d.ts +2 -4
- package/dist/components/ui/alert/alert.script.d.ts +25 -15
- package/dist/components/ui/autocomplete/autocomplete.css +1 -2
- package/dist/components/ui/autocomplete/autocomplete.d.ts +8 -3
- package/dist/components/ui/autocomplete/autocomplete.script.d.ts +29 -4
- package/dist/components/ui/avatar/avatar.css +10 -8
- package/dist/components/ui/avatar/avatar.d.ts +3 -1
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +11 -11
- package/dist/components/ui/breadcrumb/breadcrumb.script.d.ts +10 -10
- package/dist/components/ui/calendar/calendar.css +10 -5
- package/dist/components/ui/calendar/calendar.script.d.ts +24 -21
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +3 -3
- package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
- package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
- package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
- package/dist/components/ui/carousel/carousel.css +71 -18
- package/dist/components/ui/carousel/carousel.d.ts +8 -4
- package/dist/components/ui/carousel/carousel.script.d.ts +73 -40
- package/dist/components/ui/carousel/index.js +1 -1
- package/dist/components/ui/carousel/index.js.map +4 -4
- package/dist/components/ui/checkbox/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox/checkbox.script.d.ts +31 -8
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/checkbox-group/checkbox-group.d.ts +4 -2
- package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +39 -20
- package/dist/components/ui/checkbox-group/index.js +1 -1
- package/dist/components/ui/checkbox-group/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +9 -1
- package/dist/components/ui/combobox/combobox.d.ts +12 -4
- package/dist/components/ui/combobox/combobox.script.d.ts +74 -25
- package/dist/components/ui/combobox/index.d.ts +2 -2
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +4 -4
- package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +6 -2
- package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +35 -4
- package/dist/components/ui/cycle-toggle/index.js +1 -1
- package/dist/components/ui/cycle-toggle/index.js.map +3 -3
- package/dist/components/ui/date-field/date-field.css +13 -17
- package/dist/components/ui/date-field/date-field.d.ts +10 -8
- package/dist/components/ui/date-field/date-field.script.d.ts +35 -52
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +4 -4
- package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
- package/dist/components/ui/date-input/date-input.css +50 -0
- package/dist/components/ui/date-input/date-input.d.ts +8 -0
- package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
- package/dist/components/ui/date-input/index.d.ts +2 -0
- package/dist/components/ui/date-input/index.js +2 -0
- package/dist/components/ui/date-input/index.js.map +7 -0
- package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +11 -9
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +42 -51
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +4 -4
- package/dist/components/ui/dialog/dialog.css +18 -14
- package/dist/components/ui/dialog/dialog.d.ts +6 -0
- package/dist/components/ui/dialog/dialog.script.d.ts +43 -10
- package/dist/components/ui/dialog/index.js +1 -1
- package/dist/components/ui/dialog/index.js.map +4 -4
- package/dist/components/ui/disclosure/disclosure-group.script.d.ts +19 -3
- package/dist/components/ui/disclosure/disclosure.css +3 -6
- package/dist/components/ui/disclosure/disclosure.d.ts +23 -7
- package/dist/components/ui/disclosure/disclosure.script.d.ts +31 -7
- package/dist/components/ui/disclosure/index.d.ts +1 -1
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/field/field-description.d.ts +1 -0
- package/dist/components/ui/field/field-error.d.ts +2 -2
- package/dist/components/ui/field/field.d.ts +4 -4
- package/dist/components/ui/field/field.script.d.ts +54 -24
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +4 -4
- package/dist/components/ui/form/control-protocol.d.ts +38 -1
- package/dist/components/ui/form/form-context.d.ts +3 -0
- package/dist/components/ui/form/form.d.ts +6 -0
- package/dist/components/ui/form/form.script.d.ts +29 -12
- package/dist/components/ui/form/index.d.ts +2 -1
- package/dist/components/ui/form/index.js +1 -1
- package/dist/components/ui/form/index.js.map +4 -4
- package/dist/components/ui/grid/grid.d.ts +4 -3
- package/dist/components/ui/grid/grid.script.d.ts +19 -11
- package/dist/components/ui/hover-card/hover-card.css +12 -101
- package/dist/components/ui/hover-card/hover-card.d.ts +7 -2
- package/dist/components/ui/hover-card/hover-card.script.d.ts +36 -5
- package/dist/components/ui/hover-card/index.js +1 -1
- package/dist/components/ui/hover-card/index.js.map +4 -4
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- package/dist/components/ui/input/input.css +1 -1
- package/dist/components/ui/knob/index.js +1 -1
- package/dist/components/ui/knob/index.js.map +3 -3
- package/dist/components/ui/knob/knob.css +6 -1
- package/dist/components/ui/knob/knob.d.ts +4 -4
- package/dist/components/ui/knob/knob.script.d.ts +55 -20
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/label/label.d.ts +2 -1
- package/dist/components/ui/listbox/index.d.ts +2 -2
- package/dist/components/ui/listbox/index.js +1 -1
- package/dist/components/ui/listbox/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.css +14 -0
- package/dist/components/ui/listbox/listbox.d.ts +16 -2
- package/dist/components/ui/listbox/listbox.script.d.ts +55 -12
- package/dist/components/ui/menu-button/index.js +1 -1
- package/dist/components/ui/menu-button/index.js.map +4 -4
- package/dist/components/ui/menu-button/menu-button.d.ts +2 -2
- package/dist/components/ui/menu-button/menu-button.script.d.ts +30 -27
- package/dist/components/ui/menubar/index.js +1 -1
- package/dist/components/ui/menubar/index.js.map +4 -4
- package/dist/components/ui/menubar/menubar.script.d.ts +41 -15
- 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 +19 -14
- package/dist/components/ui/navigation-menu/index.d.ts +1 -1
- package/dist/components/ui/navigation-menu/index.js +1 -1
- package/dist/components/ui/navigation-menu/index.js.map +4 -4
- package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +34 -5
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +93 -12
- package/dist/components/ui/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +4 -4
- package/dist/components/ui/number-field/number-field.css +1 -1
- package/dist/components/ui/number-field/number-field.d.ts +8 -19
- package/dist/components/ui/number-field/number-field.script.d.ts +30 -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 +33 -9
- package/dist/components/ui/pagination/pagination.script.d.ts +29 -9
- package/dist/components/ui/popover/index.js +1 -1
- package/dist/components/ui/popover/index.js.map +4 -4
- package/dist/components/ui/popover/popover.d.ts +17 -1
- package/dist/components/ui/popover/popover.script.d.ts +57 -9
- package/dist/components/ui/radio-group/index.js +1 -1
- package/dist/components/ui/radio-group/index.js.map +4 -4
- package/dist/components/ui/radio-group/radio-group.d.ts +2 -2
- package/dist/components/ui/radio-group/radio-group.script.d.ts +35 -16
- package/dist/components/ui/select/index.d.ts +2 -2
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +4 -4
- package/dist/components/ui/select/select.css +8 -6
- package/dist/components/ui/select/select.d.ts +18 -9
- package/dist/components/ui/select/select.script.d.ts +74 -26
- package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
- package/dist/components/ui/shared/control-toggle.css +8 -4
- package/dist/components/ui/shared/field-label.d.ts +5 -0
- package/dist/components/ui/shared/listbox-host-controller.d.ts +41 -0
- package/dist/components/ui/shared/listbox-option.d.ts +4 -0
- package/dist/components/ui/shared/multi-value.d.ts +23 -1
- package/dist/components/ui/shared/numeric-range.d.ts +8 -0
- package/dist/components/ui/shared/popover.css +10 -99
- package/dist/components/ui/sidebar/index.d.ts +2 -1
- package/dist/components/ui/sidebar/index.js +1 -1
- package/dist/components/ui/sidebar/index.js.map +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +52 -31
- package/dist/components/ui/sidebar/sidebar.css +67 -61
- package/dist/components/ui/sidebar/sidebar.d.ts +9 -4
- package/dist/components/ui/sidebar/sidebar.script.d.ts +42 -20
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +4 -4
- package/dist/components/ui/slider/slider.css +5 -5
- package/dist/components/ui/slider/slider.d.ts +20 -10
- package/dist/components/ui/slider/slider.script.d.ts +103 -27
- package/dist/components/ui/switch/index.js +1 -1
- package/dist/components/ui/switch/index.js.map +4 -4
- package/dist/components/ui/switch/switch.css +28 -22
- package/dist/components/ui/switch/switch.d.ts +13 -0
- package/dist/components/ui/switch/switch.script.d.ts +34 -8
- package/dist/components/ui/table/index.js +1 -1
- package/dist/components/ui/table/index.js.map +4 -4
- package/dist/components/ui/table/table.d.ts +9 -7
- package/dist/components/ui/table/table.script.d.ts +55 -12
- package/dist/components/ui/tabs/tabs.css +18 -12
- package/dist/components/ui/tabs/tabs.d.ts +7 -4
- package/dist/components/ui/tabs/tabs.script.d.ts +39 -9
- package/dist/components/ui/tag-group/index.js +1 -1
- package/dist/components/ui/tag-group/index.js.map +4 -4
- package/dist/components/ui/tag-group/tag-group.d.ts +19 -7
- package/dist/components/ui/tag-group/tag-group.script.d.ts +58 -10
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/components/ui/textarea/textarea.css +1 -1
- package/dist/components/ui/toast/index.js +1 -1
- package/dist/components/ui/toast/index.js.map +4 -4
- package/dist/components/ui/toast/toast.css +35 -32
- package/dist/components/ui/toast/toast.script.d.ts +17 -31
- package/dist/components/ui/toast/toaster.script.d.ts +24 -12
- package/dist/components/ui/toc/toc.script.d.ts +19 -8
- package/dist/components/ui/toolbar/toolbar.d.ts +5 -0
- package/dist/components/ui/toolbar/toolbar.script.d.ts +24 -4
- package/dist/components/ui/tooltip/index.js +1 -1
- package/dist/components/ui/tooltip/index.js.map +4 -4
- package/dist/components/ui/tooltip/tooltip.css +14 -94
- package/dist/components/ui/tooltip/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip/tooltip.script.d.ts +36 -6
- package/dist/components/ui/tree/tree.d.ts +4 -3
- package/dist/components/ui/tree/tree.script.d.ts +28 -15
- package/dist/components/ui/treegrid/treegrid.d.ts +5 -3
- package/dist/components/ui/treegrid/treegrid.script.d.ts +33 -14
- package/dist/components/ui/window-splitter/index.d.ts +1 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +3 -3
- package/dist/components/ui/window-splitter/window-splitter.d.ts +10 -1
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +26 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/icons/check.d.ts +3 -0
- package/dist/lib/icons/chevron-down.d.ts +0 -1
- package/dist/lib/icons/index.d.ts +2 -0
- package/dist/lib/icons/x.d.ts +5 -0
- package/dist/lib/intl-date/index.d.ts +4 -2
- package/dist/lib/intl-date/segment-editing.d.ts +34 -0
- package/dist/lib/intl-date/segments.d.ts +26 -4
- package/dist/lib/non-empty.d.ts +6 -0
- package/dist/lib/unique-id.d.ts +11 -0
- package/dist/lib/viewport/breakpoints.d.ts +6 -0
- package/dist/lib/viewport/mobile-layout.d.ts +15 -0
- package/dist/styles/primitives.css +14 -11
- package/dist/styles/radiant-ui-core.css +10 -0
- package/dist/styles/radiant-ui.css +40 -11
- package/dist/styles/style-dependencies.json +38 -13
- package/dist/styles/styles.css +485 -252
- package/dist/styles/tailwind.css +40 -101
- package/dist/styles/tokens/presets/colors/aurora.css +2 -0
- package/dist/styles/tokens/presets/colors/basalt.css +2 -0
- package/dist/styles/tokens/presets/colors/ember.css +2 -0
- package/dist/styles/tokens/presets/colors/glacier.css +2 -0
- package/dist/styles/tokens/semantic.css +1 -0
- package/dist/styles/tokens/system.css +11 -3
- package/dist/styles/tokens/typography/default.css +8 -0
- package/package.json +27 -13
|
@@ -14,42 +14,61 @@ export type RuiRadioGroupChangeDetail = {
|
|
|
14
14
|
value: string;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* `<rui-radio-group>` —
|
|
18
|
-
*
|
|
17
|
+
* `<rui-radio-group>` — radio group behavior host.
|
|
18
|
+
*
|
|
19
|
+
* The custom element is a behavior host: it does not render the composed tree.
|
|
20
|
+
* Import the script and place light-DOM children that match the contract below,
|
|
21
|
+
* or use the `RuiRadioGroup` view helpers which stamp the same targets.
|
|
19
22
|
*
|
|
20
23
|
* Implements the WAI-ARIA APG Radio Group pattern using native
|
|
21
|
-
* `<input type="radio">` controls
|
|
22
|
-
*
|
|
24
|
+
* `<input type="radio">` controls. Arrow-key navigation and Space activation
|
|
25
|
+
* are provided by the browser.
|
|
23
26
|
*
|
|
24
|
-
*
|
|
27
|
+
* ## Light-DOM contract
|
|
28
|
+
*
|
|
29
|
+
* Required:
|
|
30
|
+
* - `[data-radio-group-root]` — radiogroup container. Host sets `aria-label`, `aria-disabled`.
|
|
31
|
+
* - `input[type="radio"]` — one per option. Host sets `name`, `checked`, `disabled`.
|
|
32
|
+
*
|
|
33
|
+
* Per radio:
|
|
34
|
+
* - `value` — selection identity.
|
|
35
|
+
* - `data-disabled` — per-item disabled flag preserved when the group is enabled.
|
|
36
|
+
*
|
|
37
|
+
* Do not set `name`, `checked`, or `disabled` on radios — the host owns those.
|
|
25
38
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* - `Space`: check the focused radio
|
|
39
|
+
* Nested hosts: none.
|
|
40
|
+
*
|
|
41
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/radio/
|
|
30
42
|
*
|
|
31
43
|
* @element rui-radio-group
|
|
32
44
|
*
|
|
33
45
|
* @attr {string} value - Selected radio value. Reflects to markup. Default: `''`.
|
|
34
|
-
* @attr {string} name - Form field name shared by all radios in the group. Default: `''`.
|
|
35
|
-
* @attr {string} label - Accessible name when no visible legend is
|
|
46
|
+
* @attr {string} name - Form field name shared by all radios in the group. Empty falls back to `rui-radio-group` on each radio. Default: `''`.
|
|
47
|
+
* @attr {string} label - Accessible name when no visible legend is composed. Default: `''`.
|
|
36
48
|
* @attr {boolean} disabled - Disables every radio in the group. Default: `false`.
|
|
37
49
|
*
|
|
38
|
-
* @slot - One or more `<label>` children each wrapping a radio input with a unique `value`.
|
|
39
|
-
*
|
|
40
50
|
* @fires rui-change - Emitted after the selected value changes; `detail.value` holds the new value.
|
|
41
51
|
*
|
|
42
52
|
* @remarks
|
|
43
|
-
*
|
|
44
|
-
*
|
|
53
|
+
* Minimum headless tree:
|
|
54
|
+
*
|
|
55
|
+
* ```html
|
|
56
|
+
* <rui-radio-group value="pro" name="plan" label="Plan">
|
|
57
|
+
* <div data-radio-group-root role="radiogroup">
|
|
58
|
+
* <label><input type="radio" value="free" /> Free</label>
|
|
59
|
+
* <label><input type="radio" value="pro" /> Pro</label>
|
|
60
|
+
* </div>
|
|
61
|
+
* </rui-radio-group>
|
|
62
|
+
* ```
|
|
45
63
|
*
|
|
46
|
-
*
|
|
64
|
+
* BEM classes are presentation-only; see view `@cssclass`.
|
|
47
65
|
*/
|
|
48
66
|
export declare class RuiRadioGroup extends RadiantElement {
|
|
49
67
|
value: string;
|
|
50
68
|
name: string;
|
|
51
69
|
label: string;
|
|
52
70
|
disabled: boolean;
|
|
71
|
+
radioTargets: HTMLInputElement[];
|
|
53
72
|
changeEvent: EventEmitter<RuiRadioGroupChangeDetail>;
|
|
54
73
|
protected onConnected(): void;
|
|
55
74
|
syncRadios(): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RuiSelect as RuiSelectElement, type RuiSelectProps, type RuiSelectChangeDetail, type RuiSelectSelectionMode, } from './select.script';
|
|
2
|
-
export { RuiSelect, RuiSelectControl, RuiSelectTrigger, RuiSelectToggle, RuiSelectValue, RuiSelectListbox, RuiSelectSearch, type RuiSelectOptionData, type RuiSelectViewProps, } from './select';
|
|
1
|
+
export { RuiSelect as RuiSelectElement, type RuiSelectProps, type RuiSelectChangeDetail, type RuiSelectSelectionMode, type RuiSelectTriggerKind, } from './select.script';
|
|
2
|
+
export { RuiSelect, RuiSelectControl, RuiSelectTrigger, RuiSelectToggle, RuiSelectClear, RuiSelectValue, RuiSelectListbox, RuiSelectSearch, type RuiSelectOptionData, type RuiSelectClearProps, type RuiSelectViewProps, } from './select';
|
|
3
3
|
export { RuiListbox, RuiListboxOption } from '../listbox';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{RadiantElement as Xt,customElement as ve,event as xe,onEvent as x,onUpdated as ye,prop as P,query as Oe}from"@ecopages/radiant";function z(i){let t=i.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:i.parentElement?.querySelector("[data-rui-field-label], label.rui-label")??null}function ft(i,t,e){if(!t||t.hasAttribute("data-rui-field-managed"))return;let r=z(i);if(r){r.id||(r.id=e.labelId),r.htmlFor||(r.htmlFor=e.controlId),t.setAttribute("aria-labelledby",r.id),t.removeAttribute("aria-label");return}if(e.label){t.setAttribute("aria-label",e.label),t.removeAttribute("aria-labelledby");return}t.removeAttribute("aria-label"),t.removeAttribute("aria-labelledby")}var se={top:"bottom",bottom:"top",left:"right",right:"left"},le=8;function ae(i){let t=i.indexOf("-");if(t===-1)return{side:i,align:"center"};let e=i.slice(0,t),r=i.slice(t+1);return{side:e,align:r==="start"||r==="end"?r:"center"}}function vt(i){return i==="top"||i==="bottom"?"y":"x"}function bt(i,t,e,r,o){let{width:n,height:s}=t,l=0,c=0;switch(e){case"top":c=i.top-s-o;break;case"bottom":c=i.bottom+o;break;case"left":l=i.left-n-o;break;case"right":l=i.right+o;break}return vt(e)==="y"?r==="start"?l=i.left:r==="end"?l=i.right-n:l=i.left+(i.width-n)/2:r==="start"?c=i.top:r==="end"?c=i.bottom-s:c=i.top+(i.height-s)/2,{x:l,y:c}}function ue(i,t,e,r){let{padding:o,width:n,height:s}=r;return e==="top"?Math.max(0,o-i.y):e==="bottom"?Math.max(0,i.y+t.height-(s-o)):e==="left"?Math.max(0,o-i.x):Math.max(0,i.x+t.width-(n-o))}function mt(i,t,e,r){let{padding:o,width:n,height:s}=r;return e==="top"?i.top-o-t.height:e==="bottom"?s-o-t.height-i.bottom:e==="left"?i.left-o-t.width:n-o-t.width-i.right}function ce(i,t){return t==="center"?i:`${i}-${t}`}function he(i,t,e,r){let{padding:o,width:n,height:s}=r;if(vt(e)==="y"){let c=Math.max(o,n-o-t.width);return{x:Math.min(Math.max(i.x,o),c),y:i.y}}let l=Math.max(o,s-o-t.height);return{x:i.x,y:Math.min(Math.max(i.y,o),l)}}function de(i,t,e,r,o={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:le}){let{side:n,align:s}=ae(e),l=bt(i,t,n,s,r),c=ue(l,t,n,o),I=n,_=l;if(c>0){let T=se[n],E=bt(i,t,T,s,r),M=mt(i,t,n,o);mt(i,t,T,o)>M&&(I=T,_=E)}return{coords:he(_,t,I,o),placement:ce(I,s)}}function pe(i,t,e,r,o={}){let{coords:n,placement:s}=de(i.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},e,r);return Object.assign(t.style,{position:"fixed",left:`${n.x}px`,top:`${n.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),o.matchAnchorWidth&&(t.style.width=`${i.offsetWidth}px`),t.setAttribute("data-placement",s),s}function xt({anchor:i,floating:t,getPlacement:e,gap:r,matchAnchorWidth:o}){let n=()=>{t.hidden||pe(i,t,e(),r,{matchAnchorWidth:o})};n(),window.addEventListener("resize",n),window.addEventListener("scroll",n,!0);let s=new ResizeObserver(n);return s.observe(i),s.observe(t),()=>{window.removeEventListener("resize",n),window.removeEventListener("scroll",n,!0),s.disconnect()}}function yt(i,t=document.body){let e=i.parentNode;if(!e)return{unmount:()=>{}};let r=document.createComment("rui-portal");return e.insertBefore(r,i),t.appendChild(i),{unmount:()=>{let o=r.parentNode;o&&(o.insertBefore(i,r),r.remove())}}}function N(i,t,e){return e?!!(i?.contains(e)||t?.contains(e)):!1}function Ot(i,t,e){return e instanceof Node?!N(i,t,e):!0}function wt(i,t,e){return!N(i,t,e)}var q=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}sync(){let t=this.resolveFloating();if(!t)return;if(!this.config.getOpen()){this.teardown(),t.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=yt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=xt({anchor:r,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return N(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 At(i){return i.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function St(i,t,e){return e===0?-1:t===1?i>=e-1?0:i+1:i<=0?e-1:i-1}function tt(i,t){t?.removeAttribute("aria-activedescendant");for(let e of i)e.removeAttribute("data-active")}function Ct(i,t,e,r,o){tt(i,r);let n=t[e];return!n||!r?null:(n.id||(n.id=`${o}-${e}`),n.setAttribute("data-active","true"),r.setAttribute("aria-activedescendant",n.id),n.scrollIntoView({block:"nearest"}),n)}var W=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(t){this.config=t,this.popoverController=new q({getAnchor:t.getAnchor,getFloating:t.getFloating,getOpen:t.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1,matchAnchorWidth:!0})}get activeOptionIndex(){return this.activeIndex}get hasVisualFocus(){return this.visualFocus}ensureOptionIds(){this.config.getOptions().forEach((t,e)=>{t.id||(t.id=`${this.config.getOptionIdPrefix()}-${e}`)})}getVisibleOptions(){return At(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,tt(this.config.getOptions(),this.config.getActiveDescendantHost())}setActiveOption(t){let e=this.getVisibleOptions();if(t<0||t>=e.length){this.clearActiveOption();return}this.activeIndex=t,this.visualFocus=!0,Ct(this.config.getOptions(),e,t,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(t,e){let r=this.getVisibleOptions();if(r.length){if(!this.config.getOpen()){e(t===1?"first":"last");return}if(this.visualFocus){this.setActiveOption(St(this.activeIndex,t,r.length));return}this.setActiveOption(t===1?0:r.length-1)}}handleKeydown(t,e){if(t.ctrlKey||t.shiftKey||t.metaKey)return;this.keydownHandlers[t.key]?.call(this,t,e)}keydownHandlers={ArrowDown:this.handleArrowKey,ArrowUp:this.handleArrowKey,Escape:this.handleEscapeKey,Enter:this.handleActivationKey," ":this.handleActivationKey,Tab:this.handleTabKey};handleArrowKey(t,e){t.preventDefault(),t.stopPropagation();let r=t.key==="ArrowDown"?1:-1;if(t.altKey){this.handleModifiedArrow(r,e);return}this.moveActive(r,o=>e.onOpen(o))}handleModifiedArrow(t,e){t===1&&!e.isOpen&&e.onOpen(),t===-1&&e.isOpen&&e.onClose("arrow")}handleEscapeKey(t,e){t.preventDefault(),e.isOpen?e.onClose("escape"):e.onEscapeWhenClosed?.()}handleActivationKey(t,e){if(!(t.key===" "&&!e.canUseSpace)){if(!e.isOpen&&e.enterWhenClosed==="open"){t.preventDefault(),e.onOpen();return}if(e.isOpen){if(this.hasActiveOption()){t.preventDefault(),e.onSelectActive();return}t.key==="Enter"&&e.enterWithoutActive==="close"&&(t.preventDefault(),e.onClose("enter"))}}}handleTabKey(t,e){e.isOpen&&(this.hasActiveOption()&&e.closesOnTab?e.onSelectActive():e.onClose("tab"))}hasActiveOption(){return this.visualFocus&&!!this.getVisibleOptions()[this.activeIndex]}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(t){return Ot(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return wt(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};function It(i){return i?i.split(",").map(t=>t.trim()).filter(Boolean):[]}function _t(i){return i.join(",")}var Tt,Et,Lt,Vt,Dt,Pt,Ft,Rt,Mt,Bt,kt,Kt,jt,Ht,qt,Wt,Gt,$t;function ge(i,t,e,r,o,n){var s,l,c,I,_,T,E,M=Symbol.metadata||Symbol.for("Symbol.metadata"),$=Object.defineProperty,U=Object.create,rt=[U(null),U(null)],ot=t.length;function B(a,y,m){return function(u,h){y&&(h=u,u=i);for(var O=0;O<a.length;O++)h=a[O].apply(u,m?[h]:[]);return m?h:u}}function S(a,y,m,u){if(typeof a!="function"&&(u||a!==void 0))throw new TypeError(y+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return a}function nt(a,y,m,u,h,O,L,v,w,A,lt){function X(p){if(!lt(p))throw new TypeError("Attempted to access private element on non-instance")}var Y=[].concat(y[0]),at=y[3],J=!L,F=h===1,ut=h===3,ct=h===4,k=h===2;function K(p,D,pt){return function(H,gt){return D&&(gt=H,H=a),pt&&pt(H),d[p].call(H,gt)}}if(!J){var d={},Q=[],C=ut?"get":ct||F?"set":"value";if(w?(A||F?d={get:Ut(function(){return at(this)},u,"get"),set:function(p){y[4](this,p)}}:d[C]=at,A||Ut(d[C],u,k?"":C)):A||(d=Object.getOwnPropertyDescriptor(a,u)),!A&&!w){if((l=rt[+v][u])&&(l^h)!==7)throw Error("Decorating two elements with the same name ("+d[C].name+") is not supported yet");rt[+v][u]=h<3?1:h}}for(var f=a,j=Y.length-1;j>=0;j-=m?2:1){var ht=S(Y[j],"A decorator","be",!0),dt=m?Y[j-1]:void 0,Z={},R={kind:["field","accessor","method","getter","setter","class"][h],name:u,metadata:s,addInitializer:function(p,D){if(p.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(D,"An initializer","be",!0),O.push(D)}.bind(null,Z)};if(J)l=ht.call(dt,f,R),Z.v=1,S(l,"class decorators","return")&&(f=l);else if(R.static=v,R.private=w,l=R.access={has:w?lt.bind():function(p){return u in p}},ct||(l.get=w?k?function(p){return X(p),d.value}:K("get",0,X):function(p){return p[u]}),k||ut||(l.set=w?K("set",0,X):function(p,D){p[u]=D}),f=ht.call(dt,F?{get:d.get,set:d.set}:d[C],R),Z.v=1,F){if(typeof f=="object"&&f)(l=S(f.get,"accessor.get"))&&(d.get=l),(l=S(f.set,"accessor.set"))&&(d.set=l),(l=S(f.init,"accessor.init"))&&Q.unshift(l);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else S(f,(A?"field":"method")+" decorators","return")&&(A?Q.unshift(f):d[C]=f)}return h<2&&L.push(B(Q,v,1),B(O,v,0)),A||J||(w?F?L.splice(-1,0,K("get",v),K("set",v)):L.push(k?d[C]:S.call.bind(d[C])):$(a,u,d)),f}function st(a){return $(a,M,{configurable:!0,enumerable:!0,value:s})}return n!==void 0&&(s=n[M]),s=U(s??null),_=[],T=function(a){a&&_.push(B(a))},E=function(a,y){for(var m=0;m<e.length;m++){var u=e[m],h=u[1],O=7&h;if((8&h)==a&&!O==y){var L=u[2],v=!!u[3],w=16&h;nt(a?i:i.prototype,u,w,v?"#"+L:fe(L),O,O<2?[]:a?I=I||[]:c=c||[],_,!!a,v,y,a&&v?function(A){return me(A)===i}:o)}}},E(8,0),E(0,0),E(8,1),E(0,1),T(c),T(I),l=_,ot||st(i),{e:l,get c(){var a=[];return ot&&[st(i=nt(i,[t],r,i.name,5,a)),B(a,1)]}}}function fe(i){var t=be(i,"string");return typeof t=="symbol"?t:t+""}function be(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var r=e.call(i,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Ut(i,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(i,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return i}function me(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}var Jt,Yt=class extends Xt{static{({e:[Lt,Vt,Dt,Pt,Ft,Rt,Mt,Bt,kt,Kt,jt,Ht,qt,Wt,Gt,$t,Tt],c:[Jt,Et]}=ge(this,[ve("rui-select")],[[P({type:String,reflect:!0,defaultValue:""}),0,"value"],[P({type:String,defaultValue:""}),0,"label"],[P({type:String,defaultValue:""}),0,"placeholder"],[P({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[P({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[P({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[xe({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Oe({ref:"root"}),0,"rootTarget"],[ye(["value","label","placeholder","disabled","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[x({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[x({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[x({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[x({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[x({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[x({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[x({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[x({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[x({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[x({ref:"root",type:"focusout"}),2,"onFocusOut"],[x({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,Xt))}constructor(...t){super(...t),$t(this)}value=(Tt(this),Lt(this));label=(Vt(this),Dt(this));placeholder=(Pt(this),Ft(this));disabled=(Rt(this),Mt(this));selectionMode=(Bt(this),kt(this));shouldCloseOnSelect=(Kt(this),jt(this));changeEvent=(Ht(this),qt(this));open=(Wt(this),!1);uid=Math.random().toString(36).slice(2,9);listboxBehavior=new W({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.getOptions(),getActiveDescendantHost:()=>this.getActiveDescendantHost(),getOptionIdPrefix:()=>`rui-select-option-${this.uid}`});rootTarget=Gt(this);get listboxId(){return`rui-select-list-${this.uid}`}get triggerId(){return`rui-select-trigger-${this.uid}`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect!=null?this.shouldCloseOnSelect:!this.isMultiple()}getSelectedValues(){return this.value?It(this.value):[]}setSelectedValues(t){this.value=_t(t)}getSearchInput(){return this.querySelector("[data-select-listbox] [data-autocomplete-input]")}hasSearchInput(){return this.getSearchInput()!=null}getActiveDescendantHost(){return this.open&&this.hasSearchInput()?this.getSearchInput():this.getTrigger()}resetSearchFilter(){let t=this.getSearchInput();!t||t.value===""||(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})))}syncSearchInput(){let t=this.getSearchInput(),e=this.getTrigger(),r=this.getListbox();if(!(!t||!r||!e)){if(this.open){t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-expanded","true"),t.setAttribute("aria-controls",this.listboxId),e.removeAttribute("aria-activedescendant");return}t.removeAttribute("role"),t.removeAttribute("aria-autocomplete"),t.removeAttribute("aria-expanded"),t.removeAttribute("aria-controls"),t.removeAttribute("aria-activedescendant")}}focusPopupInput(){queueMicrotask(()=>{this.getSearchInput()?.focus()})}getTagGroup(){let t=this.querySelector("[data-select-value] rui-tag-group");return!t||typeof t.setItems!="function"?null:t}hasTagGroup(){return this.getTagGroup()!=null}syncTagGroup(){let t=this.getTagGroup(),e=this.getValueElement();if(!t||!e)return;let r=this.getSelectedValues(),o=r.flatMap(n=>{let s=this.getOptions().find(l=>this.getOptionValue(l)===n);return s?[{value:n,label:this.getOptionLabel(s)}]:[]});t.embedded=!0,t.setItems(o),t.value=this.value,this.syncTagGroupPlaceholder(e,r.length)}syncTagGroupPlaceholder(t,e){let r=t.querySelector("[data-select-placeholder]");if(!this.placeholder){r?.remove();return}r||(r=document.createElement("span"),r.setAttribute("data-select-placeholder","true"),t.insertBefore(r,t.firstChild)),r.textContent=this.placeholder,r.hidden=e>0,t.toggleAttribute("data-placeholder",e===0)}removeSelectedValue(t){let e=new Set(this.getSelectedValues());e.has(t)&&(e.delete(t),this.setSelectedValues([...e]),this.syncValueDisplay(),this.syncOptionSelection(),this.syncTagGroup(),this.changeEvent.emit({value:this.value}))}getTrigger(){return this.querySelector("[data-select-trigger]")}getToggle(){return this.querySelector("[data-select-toggle]")}getValueElement(){return this.querySelector("[data-select-value]")}getListboxPopup(){return this.querySelector("[data-select-listbox]")}getListbox(){let t=this.querySelector("rui-listbox");return t?t.querySelector('[role="listbox"]'):this.getListboxPopup()}getListboxHost(){return this.querySelector("rui-listbox")}getOptions(){let t=this.getListbox();return t?Array.from(t.querySelectorAll('[role="option"]')):[]}getOptionLabel(t){return t.getAttribute("data-label")||t.textContent?.trim()||""}getOptionValue(t){return t.getAttribute("data-value")||this.getOptionLabel(t)}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return z(this)?.textContent?.trim()||this.label||"Options"}syncLabel(){let t=this.getTrigger();ft(this,t,{controlId:this.triggerId,label:this.label,labelId:`rui-select-label-${this.uid}`})}syncTrigger(){let t=this.getTrigger(),e=this.getListbox(),r=this.getListboxPopup();!t||!e||(t.id||(t.id=this.triggerId),e.id||(e.id=this.listboxId),t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-autocomplete","none"),t.setAttribute("aria-expanded",String(this.open)),t.setAttribute("aria-controls",this.listboxId),e.setAttribute("aria-label",this.getAccessibleName()),this.isMultiple()?e.setAttribute("aria-multiselectable","true"):e.removeAttribute("aria-multiselectable"),r&&(r.removeAttribute("role"),r.removeAttribute("aria-label"),r.removeAttribute("aria-multiselectable")),this.disabled&&(t.disabled=!0),this.syncToggle(),this.syncSearchInput())}syncToggle(){let t=this.getToggle();t&&(t.setAttribute("aria-expanded",String(this.open)),t.disabled=this.disabled)}syncListboxHost(){let t=this.getListboxHost();t&&(t.embedded=!0,this.isMultiple()||(t.value=this.value))}syncValueDisplay(){if(this.hasTagGroup()){this.syncTagGroup();return}let t=this.getValueElement();if(!t||t.childElementCount>0)return;let e=this.getSelectedValues();if(e.length===0){t.textContent="",t.toggleAttribute("data-placeholder",!0),this.placeholder&&(t.textContent=this.placeholder);return}if(t.toggleAttribute("data-placeholder",!1),this.isMultiple()){let o=e.map(n=>{let s=this.getOptions().find(l=>this.getOptionValue(l)===n);return s?this.getOptionLabel(s):n});t.textContent=o.join(", ");return}let r=this.getOptions().find(o=>this.getOptionValue(o)===e[0]);t.textContent=r?this.getOptionLabel(r):e[0]}syncOptionSelection(){let t=new Set(this.getSelectedValues());for(let e of this.getOptions()){let r=this.getOptionValue(e),o=t.has(r);e.setAttribute("aria-selected",String(o))}}setOpen(t,e={}){let r=e.activate??"none";this.open=t;let o=this.getTrigger(),n=this.getListboxPopup();if(!(!o||!n)){if(o.setAttribute("aria-expanded",String(t)),n.toggleAttribute("hidden",!t),!t){this.listboxBehavior.clearActiveOption(),this.resetSearchFilter(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition(),this.hasSearchInput()&&this.focusPopupInput(),r==="first"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?0:-1);return}if(r==="last"){let s=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(s.length?s.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}selectOption(t){if(t.getAttribute("aria-disabled")==="true")return;let e=this.getOptionValue(t);if(this.isMultiple()){let r=new Set(this.getSelectedValues());r.has(e)?r.delete(e):r.add(e),this.setSelectedValues([...r])}else this.value=e;this.syncValueDisplay(),this.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&(this.resetSearchFilter(),this.setOpen(!1),this.getTrigger()?.focus())}handleListboxKeydown(t){this.listboxBehavior.handleKeydown(t,{isOpen:this.open,canUseSpace:!this.hasSearchInput(),closesOnTab:this.closesOnSelect(),enterWhenClosed:"open",enterWithoutActive:"ignore",onOpen:(e="none")=>this.setOpen(!0,{activate:e}),onClose:e=>{this.setOpen(!1),(e==="arrow"||e==="escape")&&this.getTrigger()?.focus()},onSelectActive:()=>{let e=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];e&&this.selectOption(e)}})}handleTriggerKeydown(t){this.handleListboxKeydown(t)}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncTrigger(),this.syncListboxHost(),this.syncValueDisplay(),this.syncOptionSelection(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncTrigger(),this.syncListboxHost(),this.syncValueDisplay(),this.syncOptionSelection()}onTriggerClick(t){t.preventDefault();let e=this.getTrigger();if(!(!e||e.disabled)){if(this.open?this.setOpen(!1):this.setOpen(!0),this.open&&this.hasSearchInput()){this.focusPopupInput();return}e.focus()}}onTriggerKeydown(t){this.handleTriggerKeydown(t)}onSearchKeydown(t){this.handleListboxKeydown(t)}onSearchInput(){this.open&&this.listboxBehavior.clearActiveOption()}onTagRemove(t){let e=t.detail;e?.value&&this.removeSelectedValue(e.value)}onTagClick(t){t.target.closest("[data-tag-remove]")||t.stopPropagation()}onOptionPointerOver(t){if(!this.open)return;let e=t.target.closest('[role="option"]');if(!e||e.getAttribute("aria-disabled")==="true"||e.hidden)return;let o=this.listboxBehavior.getVisibleOptions().indexOf(e);o>=0&&this.listboxBehavior.setActiveOption(o)}onOptionMouseDown(t){t.preventDefault()}onOptionClick(t){let e=t.target.closest('[role="option"]');e&&this.selectOption(e)}onFocusOut(t){this.listboxBehavior.shouldDismissFocus(t.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(t){this.open&&this.listboxBehavior.shouldDismissPointer(t.target)&&this.setOpen(!1)}static{Et()}};import{Fragment as Ae,jsx as g,jsxs as te}from"@ecopages/jsx/jsx-runtime";function Qt(i,t){return t===void 0||i?.label!==void 0?i:{...i,label:t}}function b(...i){return i.filter(Boolean).join(" ")}function Zt(i,...t){let e={...i};for(let r of t)delete e[r];return e}import{jsx as zt}from"@ecopages/jsx/jsx-runtime";function et({class:i,size:t="sm",...e}){return zt("svg",{...e,class:b("rui-icon",t==="md"&&"rui-icon--md",i),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:zt("path",{d:"m6 9 6 6 6-6"})})}import{jsx as V}from"@ecopages/jsx/jsx-runtime";function it({value:i,label:t,children:e,class:r,disabled:o,...n}){return V("div",{...n,class:b("rui-listbox__option",r),role:"option","data-value":i,"data-label":t,"aria-disabled":o?"true":void 0,tabindex:-1,children:e})}function we(i,t){return t??!i}function Nt({bordered:i,children:t,disabled:e,label:r}){return V("div",{class:b("rui-listbox",i&&"rui-listbox--bordered"),role:"listbox","data-rui-control":!0,"data-rui-control-type":"text","aria-label":r||void 0,"aria-disabled":e?"true":void 0,children:t})}function G({options:i,children:t,embedded:e,bordered:r,label:o,disabled:n,...s}){let l=we(e,r);return i!=null?V("rui-listbox",{...s,embedded:e,bordered:r,label:o,disabled:n,children:V(Nt,{bordered:l,disabled:n,label:o,children:i.map(c=>V(it,{value:c.value,label:typeof c.label=="string"?c.label:void 0,disabled:c.disabled,children:c.label}))})}):V("rui-listbox",{...s,embedded:e,bordered:r,label:o,disabled:n,children:V(Nt,{bordered:l,disabled:n,label:o,children:t})})}function ee({children:i,class:t,...e}){return g("div",{...e,class:b("rui-select__control",t),children:i})}function ie({children:i,class:t,disabled:e,...r}){return g("button",{...Zt(r,"attr:type"),type:"button","data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:b("rui-select__trigger",t),disabled:e,children:i})}function re({children:i,class:t,aria:e,disabled:r,...o}){return g("button",{...o,aria:Qt(e,"Show options"),type:"button","data-select-toggle":!0,class:b("rui-control-toggle",t),disabled:r,tabIndex:-1,children:i??g(et,{})})}function oe({children:i,class:t,...e}){return g("span",{...e,"data-select-value":!0,class:b("rui-select__value",t),children:i})}function ne({children:i,class:t,...e}){return g("div",{...e,"data-select-listbox":!0,class:b("rui-select__listbox rui-popover rui-popover--listbox rui-floating",t),children:i})}function Se({placeholder:i,class:t,disabled:e,...r}){return g("input",{...r,type:"search","data-autocomplete-input":!0,class:b("rui-select__search",t),placeholder:i,disabled:e,autocomplete:"off"})}function Ce(i,t,e){let r=typeof t=="string"?t.trim():"",o=typeof e=="string"?e:"";if(!r)return o;let n=i?.find(s=>s.value===r);return n&&typeof n.label=="string"?n.label:r}function Ie({children:i}){return g("div",{class:"rui-select","data-ref":"root",children:i})}function _e({options:i,children:t,...e}){let r=i!=null?Ce(i,e.value,e.placeholder):"";return g("rui-select",{...e,children:g(Ie,{children:i==null?t:te(Ae,{children:[te(ee,{children:[g(ie,{children:g(oe,{children:r})}),g(re,{})]}),g(ne,{children:g(G,{embedded:!0,options:i})})]})})})}export{G as RuiListbox,it as RuiListboxOption,_e as RuiSelect,ee as RuiSelectControl,Jt as RuiSelectElement,ne as RuiSelectListbox,Se as RuiSelectSearch,re as RuiSelectToggle,ie as RuiSelectTrigger,oe as RuiSelectValue};
|
|
1
|
+
import{RadiantElement as ft,bindTo as gt,customElement as $i,event as Wi,onEvent as F,onUpdated as Ui,prop as le,query as Hi}from"@ecopages/radiant";var _i=/^[A-Za-z][A-Za-z0-9_-]*$/;function Le(t){return _i.test(t)}function Oi(t){let e=t.trim();if(Le(e))return e;let i=`rui-${e}`;return e&&Le(i)?i:"rui"}function ue(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),i=>i.toString(16).padStart(2,"0")).join("");return`${Oi(t)}-${e}`}function Ae(t){let e=t.previousElementSibling;return e?.tagName.toLowerCase()==="label"?e:t.parentElement?.querySelector("[data-rui-field-label]")??null}function Ti(t,e,i){t.id||(t.id=i.labelId),t.htmlFor||(t.htmlFor=i.controlId),e.setAttribute("aria-labelledby",t.id),e.removeAttribute("aria-label")}function be(t,e,i){if(!e||e.hasAttribute("data-rui-field-managed"))return;let r=Ae(t);if(r){Ti(r,e,i);return}if(i.label){e.setAttribute("aria-label",i.label),e.removeAttribute("aria-labelledby");return}e.removeAttribute("aria-label"),e.removeAttribute("aria-labelledby")}var Ii="data-listbox-option-indicator";function me(t){let e=t.getAttribute("data-label");return e||De(t).trim()}function z(t){return t.getAttribute("data-value")||me(t)}function De(t){if(Ei(t))return"";if(t.nodeType===Node.TEXT_NODE)return t.textContent??"";let e="";for(let i of t.childNodes)e+=De(i);return e}function Ei(t){return t instanceof HTMLElement&&t.hasAttribute(Ii)}var ve=class{config;constructor(e){this.config=e}getListboxHost(){return this.config.getRoot()?.querySelector("rui-listbox")??null}getListbox(){let e=this.getListboxHost();return e?e.querySelector('[role="listbox"]')??e:this.config.getPopup?.()??null}getOptions(){let e=this.getListbox();return e?Array.from(e.querySelectorAll('[role="option"]')):[]}getSelectedValues(){return this.config.getValue()}setSelectedValues(e){this.config.setValue(e)}toggleValue(e){if(this.config.getSelectionMode()==="multiple"){let i=new Set(this.getSelectedValues());i.has(e)?i.delete(e):i.add(e),this.setSelectedValues([...i]);return}this.setSelectedValues([e])}removeValue(e){let i=new Set(this.getSelectedValues());return i.delete(e)?(this.setSelectedValues([...i]),!0):!1}clearValues(){return this.getSelectedValues().length===0?!1:(this.setSelectedValues([]),!0)}findOption(e){return e instanceof Element?e.closest('[role="option"]')??null:null}isSelectableOption(e){return e!=null&&e.getAttribute("aria-disabled")!=="true"&&!e.hidden}syncListboxHost(){let e=this.getListboxHost();e&&(e.embedded=!0,e.selectionMode=this.config.getSelectionMode(),e.value=this.config.getValue())}syncOptionSelection(){let e=new Set(this.getSelectedValues());for(let i of this.getOptions())i.setAttribute("aria-selected",String(e.has(z(i))))}syncMultiselectable(e){if(e){if(this.config.getSelectionMode()==="multiple"){e.setAttribute("aria-multiselectable","true");return}e.removeAttribute("aria-multiselectable")}}getTagGroup(){let e=this.config.tagGroupSelector;if(!e)return null;let i=this.config.getRoot()?.querySelector(e)??null;return!i||typeof i.setItems!="function"?null:i}syncTagGroup(){let e=this.getTagGroup();if(!e)return;let i=this.getSelectedValues().flatMap(r=>{let n=this.getOptions().find(a=>z(a)===r);return n?[{value:r,label:me(n)}]:[]});e.embedded=!0,e.setItems(i),e.value=this.config.getValue()}labelForValue(e){let i=this.getOptions().find(r=>z(r)===e);return i?me(i):e}};var Vi={top:"bottom",bottom:"top",left:"right",right:"left"},Ci=8,_e=new WeakMap;function Ri(t){_e.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",_e.delete(t))}function Li(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let i=t.slice(0,e),r=t.slice(e+1);return{side:i,align:r==="start"||r==="end"?r:"center"}}function je(t){return t==="top"||t==="bottom"?"y":"x"}function ke(t,e,i,r,n){let{width:a,height:u}=e,o=0,f=0;switch(i){case"top":f=t.top-u-n;break;case"bottom":f=t.bottom+n;break;case"left":o=t.left-a-n;break;case"right":o=t.right+n;break}return je(i)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-u:f=t.top+(t.height-u)/2,{x:o,y:f}}function Di(t,e,i,r){let{padding:n,width:a,height:u}=r;return i==="top"?Math.max(0,n-t.y):i==="bottom"?Math.max(0,t.y+e.height-(u-n)):i==="left"?Math.max(0,n-t.x):Math.max(0,t.x+e.width-(a-n))}function Me(t,e,i,r){let{padding:n,width:a,height:u}=r;return i==="top"?t.top-n-e.height:i==="bottom"?u-n-e.height-t.bottom:i==="left"?t.left-n-e.width:a-n-e.width-t.right}function ki(t,e){return e==="center"?t:`${t}-${e}`}function Mi(t,e,i,r){let{padding:n,width:a,height:u}=r;if(je(i)==="y"){let f=Math.max(n,a-n-e.width);return{x:Math.min(Math.max(t.x,n),f),y:Math.max(n,t.y)}}let o=Math.max(n,u-n-e.height);return{x:Math.max(n,t.x),y:Math.min(Math.max(t.y,n),o)}}function ji(t,e,i,r,n={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Ci}){let{side:a,align:u}=Li(i),o=ke(t,e,a,u,r),f=Di(o,e,a,n),_=a,I=o;if(f>0){let C=Vi[a],S=ke(t,e,C,u,r),H=Me(t,e,a,n);Me(t,e,C,n)>H&&(_=C,I=S)}return{coords:Mi(I,e,_,n),placement:ki(_,u)}}function Pi(t,e,i,r,n={}){let a=n.matchAnchorWidth===!0,u=t.offsetWidth,o=a?{width:u,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${u}px`,e.style.minWidth=`${u}px`,e.style.maxWidth=`${u}px`,e.style.boxSizing="border-box",_e.set(e,!0)):Ri(e);let{coords:f,placement:_}=ji(t.getBoundingClientRect(),o,i,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",_),_}function Pe({anchor:t,floating:e,getPlacement:i,gap:r,matchAnchorWidth:n}){let a=()=>{e.hidden||Pi(t,e,i(),r,{matchAnchorWidth:n})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let u=new ResizeObserver(a);return u.observe(t),u.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),u.disconnect()}}function Fe(t,e=document.body){let i=t.parentNode;if(!i)return{unmount:()=>{}};let r=document.createComment("rui-portal");return i.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let n=r.parentNode;n&&(n.insertBefore(t,r),r.remove())}}}function Oe(t,e,i){return i?!!(t?.contains(i)||e?.contains(i)):!1}function Be(t,e,i){return i instanceof Node?!Oe(t,e,i):!0}function Ke(t,e,i){return!Oe(t,e,i)}var ye=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Fe(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Pe({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return Oe(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function qe(t){return t.filter(e=>!e.hidden&&e.getAttribute("aria-disabled")!=="true")}function Ge(t,e,i){return i===0?-1:e===1?t>=i-1?0:t+1:t<=0?i-1:t-1}function Te(t,e){e?.removeAttribute("aria-activedescendant");for(let i of t)i.removeAttribute("data-active")}function $e(t,e,i,r,n){Te(t,r);let a=e[i];return!a||!r?null:(a.id||(a.id=`${n}-${i}`),a.setAttribute("data-active","true"),r.setAttribute("aria-activedescendant",a.id),a.scrollIntoView({block:"nearest"}),a)}var xe=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(e){this.config=e,this.popoverController=new ye({getAnchor:e.getAnchor,getFloating:e.getFloating,getOpen:e.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1,matchAnchorWidth:!0})}get activeOptionIndex(){return this.activeIndex}get hasVisualFocus(){return this.visualFocus}ensureOptionIds(){this.config.getOptions().forEach((e,i)=>{e.id||(e.id=`${this.config.getOptionIdPrefix()}-${i}`)})}getVisibleOptions(){return qe(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,Te(this.config.getOptions(),this.config.getActiveDescendantHost())}setActiveOption(e){let i=this.getVisibleOptions();if(e<0||e>=i.length){this.clearActiveOption();return}this.activeIndex=e,this.visualFocus=!0,$e(this.config.getOptions(),i,e,this.config.getActiveDescendantHost(),this.config.getOptionIdPrefix())}moveActive(e,i){let r=this.getVisibleOptions();if(r.length){if(!this.config.getOpen()){i(e===1?"first":"last");return}if(this.visualFocus){this.setActiveOption(Ge(this.activeIndex,e,r.length));return}this.setActiveOption(e===1?0:r.length-1)}}handleKeydown(e,i){if(e.ctrlKey||e.shiftKey||e.metaKey)return;this.keydownHandlers[e.key]?.call(this,e,i)}keydownHandlers={ArrowDown:this.handleArrowKey,ArrowUp:this.handleArrowKey,Escape:this.handleEscapeKey,Enter:this.handleActivationKey," ":this.handleActivationKey,Tab:this.handleTabKey};handleArrowKey(e,i){e.preventDefault(),e.stopPropagation();let r=e.key==="ArrowDown"?1:-1;if(e.altKey){this.handleModifiedArrow(r,i);return}this.moveActive(r,n=>i.onOpen(n))}handleModifiedArrow(e,i){e===1&&!i.isOpen&&i.onOpen(),e===-1&&i.isOpen&&i.onClose("arrow")}handleEscapeKey(e,i){e.preventDefault(),i.isOpen?i.onClose("escape"):i.onEscapeWhenClosed?.()}handleActivationKey(e,i){if(!(e.key===" "&&!i.canUseSpace)){if(!i.isOpen&&i.enterWhenClosed==="open"){e.preventDefault(),i.onOpen();return}if(i.isOpen){if(this.hasActiveOption()){e.preventDefault(),i.onSelectActive();return}e.key==="Enter"&&i.enterWithoutActive==="close"&&(e.preventDefault(),i.onClose("enter"))}}}handleTabKey(e,i){i.isOpen&&(this.hasActiveOption()&&i.closesOnTab?i.onSelectActive():i.onClose("tab"))}hasActiveOption(){return this.visualFocus&&!!this.getVisibleOptions()[this.activeIndex]}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(e){return Be(this.config.getAnchor(),this.popoverController.getFloatingElement(),e)}shouldDismissPointer(e){return Ke(this.config.getAnchor(),this.popoverController.getFloatingElement(),e)}destroy(){this.popoverController.destroy()}};function We(t){return t?He(t.split(",")):[]}function Fi(t){return t.join(",")}var Ue={fromAttribute:t=>We(t),toAttribute:t=>t.length>0?Fi(t):null,fromProperty:t=>Array.isArray(t)?He(t.map(String)):typeof t=="string"?We(t):[]},ce={type:Array,reflect:!0,transform:Ue};function pe(t){return Ue.fromProperty?.(t)??[]}function He(t){return[...new Set(t.map(e=>e.trim()).filter(Boolean))]}var ze,Xe,Ze,Ye,Je,Qe,Ne,et,tt,it,rt,nt,ot,st,lt,at,ut,ct,dt,ht;function Bi(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:pt(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||pt(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:Ki(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return Gi(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function Ki(t){var e=qi(t,"string");return typeof e=="symbol"?e:e+""}function qi(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function pt(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function Gi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var mt,bt=class extends ft{static{({e:[Ze,Ye,Je,Qe,Ne,et,tt,it,rt,nt,ot,st,lt,at,ut,ct,dt,ht,ze],c:[mt,Xe]}=Bi(this,[$i("rui-select")],[[[le({...ce,defaultValue:[]}),gt({selector:"[data-select-clear]",bool:"hidden",map:e=>e.length===0})],0,"value"],[le({type:String,defaultValue:""}),0,"label"],[le({type:String,defaultValue:""}),0,"placeholder"],[[le({type:Boolean,reflect:!0,defaultValue:!1}),gt([{selector:"[data-select-trigger]",attr:"aria-disabled",map:e=>e?"true":void 0},{selector:"[data-select-trigger]",prop:"tabIndex",map:e=>e?-1:0},{selector:"[data-select-toggle]",prop:"disabled"},{selector:"[data-select-clear]",prop:"disabled"}])],0,"disabled"],[le({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[le({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[le({type:String,attribute:"trigger-kind",reflect:!0,defaultValue:"manual"}),0,"triggerKind"],[Wi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Hi({ref:"root"}),0,"rootTarget"],[Ui(["value","label","placeholder","disabled","triggerKind","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[F({selector:"[data-select-trigger], [data-select-toggle]",type:"pointerdown"}),2,"onTriggerPointerDown"],[F({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[F({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[F({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[F({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[F({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[F({selector:"[data-select-clear]",type:"click"}),2,"onClearClick"],[F({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[F({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[F({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[F({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[F({ref:"root",type:"focusin"}),2,"onRootFocusIn"],[F({ref:"root",type:"focusout"}),2,"onFocusOut"],[F({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,ft))}constructor(...e){super(...e),ht(this)}value=(ze(this),Ze(this));label=(Ye(this),Je(this));placeholder=(Qe(this),Ne(this));disabled=(et(this),tt(this));selectionMode=(it(this),rt(this));shouldCloseOnSelect=(nt(this),ot(this));triggerKind=(st(this),lt(this));changeEvent=(at(this),ut(this));open=(ct(this),!1);uid=ue("rui-select");collection=new ve({getRoot:()=>this,getSelectionMode:()=>this.selectionMode,getValue:()=>this.value,setValue:e=>{this.value=e},getPopup:()=>this.getListboxPopup(),tagGroupSelector:"[data-select-value] rui-tag-group"});listboxBehavior=new xe({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.collection.getOptions(),getActiveDescendantHost:()=>this.getActiveDescendantHost(),getOptionIdPrefix:()=>`${this.uid}-option`});rootTarget=dt(this);get listboxId(){return`${this.uid}-list`}get triggerId(){return`${this.uid}-trigger`}isMultiple(){return this.selectionMode==="multiple"}closesOnSelect(){return this.shouldCloseOnSelect!=null?this.shouldCloseOnSelect:!this.isMultiple()}getSearchInput(){return this.querySelector("[data-select-listbox] [data-autocomplete-input]")}hasSearchInput(){return this.getSearchInput()!=null}getActiveDescendantHost(){return this.open&&this.hasSearchInput()?this.getSearchInput():this.getTrigger()}resetSearchFilter(){let e=this.getSearchInput();!e||e.value===""||(e.value="",e.dispatchEvent(new Event("input",{bubbles:!0})))}syncSearchInput(){let e=this.getSearchInput(),i=this.getTrigger(),r=this.collection.getListbox();if(!(!e||!r||!i)){if(this.open){e.setAttribute("role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-expanded","true"),e.setAttribute("aria-controls",this.listboxId),i.removeAttribute("aria-activedescendant");return}e.removeAttribute("role"),e.removeAttribute("aria-autocomplete"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-activedescendant")}}focusPopupInput(){queueMicrotask(()=>{this.getSearchInput()?.focus()})}hasTagGroup(){return this.collection.getTagGroup()!=null}syncTagGroup(){let e=this.getValueElement();this.collection.syncTagGroup(),!(!e||!this.hasTagGroup())&&this.syncTagGroupPlaceholder(e,this.collection.getSelectedValues().length)}syncTagGroupPlaceholder(e,i){let r=e.querySelector("[data-select-placeholder]");if(!this.placeholder){r?.remove();return}r||(r=document.createElement("span"),r.setAttribute("data-select-placeholder","true"),e.insertBefore(r,e.firstChild)),r.textContent=this.placeholder,r.hidden=i>0,e.toggleAttribute("data-placeholder",i===0)}removeSelectedValue(e){this.collection.removeValue(e)&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.changeEvent.emit({value:this.value}))}clearSelection(){this.collection.clearValues()&&(this.syncValueDisplay(),this.collection.syncOptionSelection(),this.syncTagGroup(),this.changeEvent.emit({value:[]}),this.getTrigger()?.focus())}getTrigger(){return this.querySelector("[data-select-trigger]")}isTriggerFocusTarget(e){let i=this.getTrigger();return!i||!(e instanceof Node)||!i.contains(e)?!1:!(e instanceof Element&&e.closest("[data-tag-remove]"))}getToggle(){return this.querySelector("[data-select-toggle]")}getValueElement(){return this.querySelector("[data-select-value]")}getListboxPopup(){return this.querySelector("[data-select-listbox]")}ensureOptionIds(){this.listboxBehavior.ensureOptionIds()}getAccessibleName(){return Ae(this)?.textContent?.trim()||this.label||"Options"}syncLabel(){let e=this.getTrigger();be(this,e,{controlId:this.triggerId,label:this.label,labelId:`${this.uid}-label`})}syncTrigger(){let e=this.getTrigger(),i=this.collection.getListbox(),r=this.getListboxPopup();!e||!i||(e.id||(e.id=this.triggerId),i.id||(i.id=this.listboxId),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-autocomplete","none"),e.setAttribute("aria-expanded",String(this.open)),e.setAttribute("aria-controls",this.listboxId),i.setAttribute("aria-label",this.getAccessibleName()),this.collection.syncMultiselectable(i),r&&(r.removeAttribute("role"),r.removeAttribute("aria-label"),r.removeAttribute("aria-multiselectable")),this.syncToggle(),this.syncSearchInput())}syncToggle(){let e=this.getToggle();e&&e.setAttribute("aria-expanded",String(this.open))}syncValueDisplay(){if(this.hasTagGroup()){this.syncTagGroup();return}let e=this.getValueElement();if(!e||e.childElementCount>0)return;let i=this.collection.getSelectedValues();if(i.length===0){e.textContent="",e.toggleAttribute("data-placeholder",!0),this.placeholder&&(e.textContent=this.placeholder);return}if(e.toggleAttribute("data-placeholder",!1),this.isMultiple()){e.textContent=i.map(r=>this.collection.labelForValue(r)).join(", ");return}e.textContent=this.collection.labelForValue(i[0])}setOpen(e,i={}){let r=i.activate??"none";this.open=e;let n=this.getTrigger(),a=this.getListboxPopup();if(!(!n||!a)){if(n.setAttribute("aria-expanded",String(e)),a.toggleAttribute("hidden",!e),!e){this.listboxBehavior.clearActiveOption(),this.resetSearchFilter(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition();return}if(this.ensureOptionIds(),this.syncSearchInput(),this.listboxBehavior.syncPopoverPosition(),this.hasSearchInput()&&this.focusPopupInput(),r==="first"){let u=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(u.length?0:-1);return}if(r==="last"){let u=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(u.length?u.length-1:-1);return}this.listboxBehavior.clearActiveOption()}}selectOption(e){this.collection.isSelectableOption(e)&&(this.collection.toggleValue(z(e)),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.changeEvent.emit({value:this.value}),this.closesOnSelect()&&(this.resetSearchFilter(),this.setOpen(!1),this.getTrigger()?.focus()))}handleListboxKeydown(e){this.listboxBehavior.handleKeydown(e,{isOpen:this.open,canUseSpace:!this.hasSearchInput(),closesOnTab:this.closesOnSelect(),enterWhenClosed:"open",enterWithoutActive:"ignore",onOpen:(i="none")=>this.setOpen(!0,{activate:i}),onClose:i=>{this.setOpen(!1),(i==="arrow"||i==="escape")&&this.getTrigger()?.focus()},onSelectActive:()=>{let i=this.listboxBehavior.getVisibleOptions()[this.listboxBehavior.activeOptionIndex];i&&this.selectOption(i)}})}handleTriggerKeydown(e){this.handleListboxKeydown(e)}initialize(){this.ensureOptionIds(),this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.listboxBehavior.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncTrigger(),this.collection.syncListboxHost(),this.syncValueDisplay(),this.collection.syncOptionSelection()}onTriggerPointerDown(e){this.triggerKind==="focus"&&e.preventDefault()}onTriggerClick(e){e.preventDefault();let i=this.getTrigger();if(!(!i||this.disabled)){if(this.open?this.setOpen(!1):this.setOpen(!0),this.open&&this.hasSearchInput()){this.focusPopupInput();return}i.focus()}}onTriggerKeydown(e){this.handleTriggerKeydown(e)}onSearchKeydown(e){this.handleListboxKeydown(e)}onSearchInput(){this.open&&this.listboxBehavior.clearActiveOption()}onTagRemove(e){let i=e.detail;i?.value&&this.removeSelectedValue(i.value)}onClearClick(e){e.preventDefault(),e.stopPropagation(),this.clearSelection()}onTagClick(e){e.target.closest("[data-tag-remove]")||e.stopPropagation()}onOptionPointerOver(e){if(!this.open)return;let i=this.collection.findOption(e.target);if(!this.collection.isSelectableOption(i))return;let n=this.listboxBehavior.getVisibleOptions().indexOf(i);n>=0&&this.listboxBehavior.setActiveOption(n)}onOptionMouseDown(e){e.preventDefault()}onOptionClick(e){let i=this.collection.findOption(e.target);i&&this.selectOption(i)}onRootFocusIn(e){this.triggerKind!=="focus"||this.disabled||this.open||!this.isTriggerFocusTarget(e.target)||e.relatedTarget instanceof Node&&this.contains(e.relatedTarget)||this.setOpen(!0)}onFocusOut(e){this.listboxBehavior.shouldDismissFocus(e.relatedTarget)&&this.setOpen(!1)}onDocumentPointerDown(e){this.open&&this.listboxBehavior.shouldDismissPointer(e.target)&&this.setOpen(!1)}static{Xe()}};import{Fragment as br,jsx as V,jsxs as vi}from"@ecopages/jsx/jsx-runtime";function de(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function T(...t){return t.filter(Boolean).join(" ")}import{jsx as vt}from"@ecopages/jsx/jsx-runtime";function Ie({class:t,size:e="sm",...i}){return vt("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:vt("path",{d:"m5 12 4 4L19 6"})})}import{jsx as yt}from"@ecopages/jsx/jsx-runtime";function Ee({class:t,size:e="sm",...i}){return yt("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:yt("path",{d:"m6 9 6 6 6-6"})})}import{jsx as xt,jsxs as zi}from"@ecopages/jsx/jsx-runtime";var St="http://www.w3.org/2000/svg";function fe({class:t,size:e="sm",...i}){return zi("svg",{...i,class:T("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[xt("path",{d:"m18 6-12 12"}),xt("path",{d:"m6 6 12 12"})]})}function wt(){let t=document.createElementNS(St,"svg");t.setAttribute("class","rui-icon"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let e of["m18 6-12 12","m6 6 12 12"]){let i=document.createElementNS(St,"path");i.setAttribute("d",e),t.append(i)}return t}import{RadiantElement as Kt,bindTo as tr,customElement as ir,event as rr,onEvent as qt,onUpdated as nr,prop as he}from"@ecopages/radiant";function Xi(t,e){t.forEach((i,r)=>{let n=r===e?0:-1;i.tabIndex!==n&&(i.tabIndex=n)})}function Zi(t,e){if(!t.length)return null;let i=Math.max(0,Math.min(t.length-1,e));return Xi(t,i),t[i]?.focus(),t[i]??null}function Yi(t,e){return t==="Home"?"first":t==="End"?"last":e==="horizontal"?t==="ArrowRight"?"next":t==="ArrowLeft"?"prev":null:t==="ArrowDown"?"next":t==="ArrowUp"?"prev":null}function Se(t){let{items:e,current:i,key:r,orientation:n="horizontal",wrap:a=!0}=t;if(!e.length||!i)return{handled:!1};let u=e.indexOf(i);if(u<0)return{handled:!1};let o=Yi(r,n);if(!o)return{handled:!1};let f=u;o==="first"?f=0:o==="last"?f=e.length-1:o==="next"?f=a?(u+1)%e.length:Math.min(e.length-1,u+1):f=a?(u-1+e.length)%e.length:Math.max(0,u-1);let _=Zi(e,f);return _?{handled:!0,index:f,item:_}:{handled:!1}}var At,_t,Ot,Tt,It,Et,Vt,Ct,Rt,Lt,Dt,kt,Mt,jt,Pt,Ft;function Ji(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:Bt(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||Bt(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:Qi(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return er(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function Qi(t){var e=Ni(t,"string");return typeof e=="symbol"?e:e+""}function Ni(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bt(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function er(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var $t,Gt=class extends Kt{static{({e:[Ot,Tt,It,Et,Vt,Ct,Rt,Lt,Dt,kt,Mt,jt,Pt,Ft,At],c:[$t,_t]}=Ji(this,[ir("rui-listbox")],[[he({...ce,defaultValue:[]}),0,"value"],[he({type:String,defaultValue:""}),0,"label"],[he({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[[he({type:String,attribute:"selection-mode",defaultValue:"single"}),tr({selector:'[role="listbox"]',attr:"aria-multiselectable",map:e=>e==="multiple"?"true":void 0})],0,"selectionMode"],[he({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[he({type:Boolean,reflect:!0}),0,"bordered"],[rr({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[nr(["value","label","disabled","embedded","selectionMode"]),2,"onPropsUpdated"],[qt({selector:'[role="option"]',type:"click"}),2,"onOptionClick"],[qt({selector:'[role="option"]',type:"keydown"}),2,"onOptionKeydown"]],0,void 0,Kt))}value=(At(this),Ot(this));label=(Tt(this),It(this));disabled=(Et(this),Vt(this));selectionMode=(Ct(this),Rt(this));embedded=(Lt(this),Dt(this));bordered=(kt(this),Mt(this));changeEvent=(jt(this),Pt(this));uid=(Ft(this),ue("rui-listbox"));onConnected(){this.syncLabel(),this.sync()}onPropsUpdated(){this.syncLabel(),this.sync()}getOptions(){return Array.from(this.querySelectorAll('[role="option"]'))}syncLabel(){if(this.embedded)return;let e=this.querySelector('[role="listbox"]');e&&(e.id||(e.id=`${this.uid}-list`),be(this,e,{controlId:e.id,label:this.label,labelId:`${this.uid}-label`}))}getSelectedValues(){return this.value}setSelectedValues(e){this.value=e}tabIndexFor(e,i){return this.embedded?-1:e===i?0:-1}sync(){let e=this.getOptions(),i=new Set(this.getSelectedValues()),r=e.find(n=>i.has(z(n)))??e[0];for(let n of e){let a=i.has(z(n));n.setAttribute("aria-selected",String(a)),n.tabIndex=this.tabIndexFor(n,r)}}select(e){if(this.disabled||e.getAttribute("aria-disabled")==="true")return;let i=z(e);if(this.selectionMode==="multiple"){let r=new Set(this.getSelectedValues());r.has(i)?r.delete(i):r.add(i),this.setSelectedValues([...r])}else this.setSelectedValues([i]);this.sync(),this.changeEvent.emit({value:this.value}),e.focus()}onOptionClick(e){if(this.embedded)return;let i=e.target.closest('[role="option"]');i&&this.contains(i)&&this.select(i)}onOptionKeydown(e){if(this.embedded)return;let i=this.getOptions(),r=e.target.closest('[role="option"]');if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.select(r);return}let n=Se({items:i,current:r,key:e.key,orientation:"vertical"});if(n.handled){if(e.preventDefault(),this.selectionMode==="multiple"){n.item.focus();return}this.select(n.item)}}static{_t()}};import{jsx as ae,jsxs as or}from"@ecopages/jsx/jsx-runtime";function Ve({value:t,label:e,children:i,class:r,disabled:n,...a}){return ae("div",{...a,class:T("rui-listbox__option",r),role:"option","data-value":t,"data-label":e,"aria-disabled":n?"true":void 0,tabindex:-1,children:i})}function Wt({children:t,class:e,...i}){return ae("span",{...i,"data-listbox-option-indicator":!0,"aria-hidden":"true",class:T("rui-listbox__option-indicator",e),children:t??ae(Ie,{})})}function sr(t,e){return e??!t}function lr({bordered:t,children:e,disabled:i,embedded:r,label:n,selectionMode:a="single"}){return ae("div",{class:T("rui-listbox",t&&"rui-listbox--bordered"),role:"listbox","data-rui-control":r?void 0:!0,"data-rui-control-type":r?void 0:"text","aria-label":n||void 0,"aria-disabled":i?"true":void 0,"aria-multiselectable":a==="multiple"?"true":void 0,children:e})}function we({options:t,children:e,value:i,embedded:r,bordered:n,label:a,disabled:u,selectionMode:o="single",...f}){let _=sr(r,n),I=pe(i),C=new Set(I);return ae("rui-listbox",{...f,value:I,embedded:r,bordered:n,label:a,disabled:u,selectionMode:o,children:ae(lr,{bordered:_,disabled:u,embedded:r,label:a,selectionMode:o,children:t!=null?t.map(S=>or(Ve,{value:S.value,label:typeof S.label=="string"?S.label:void 0,disabled:S.disabled,"aria-selected":C.has(S.value)?"true":void 0,children:[S.label,o==="multiple"?ae(Wt,{}):null]})):e})})}import{RadiantElement as ci,customElement as hr,event as di,onEvent as Ce,onUpdated as pr,prop as ge,state as fr}from"@ecopages/radiant";var Ut,Ht,zt,Xt,Zt,Yt,Jt,Qt,Nt,ei,ti,ii,ri,ni,oi,si,li,ai;function ar(t,e,i,r,n,a){var u,o,f,_,I,C,S,H=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,B=Object.create,Z=[B(null),B(null)],Y=e.length;function D(s,m,g){return function(l,c){m&&(c=l,l=t);for(var v=0;v<s.length;v++)c=s[v].apply(l,g?[c]:[]);return g?c:l}}function w(s,m,g,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(l?"":" or undefined"));return s}function J(s,m,g,l,c,v,O,b,y,x,N){function K(h){if(!N(h))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(m[0]),ee=m[3],G=!O,R=c===1,te=c===3,ie=c===4,k=c===2;function M(h,E,oe){return function(P,se){return E&&(se=P,P=s),oe&&oe(P),d[h].call(P,se)}}if(!G){var d={},$=[],A=te?"get":ie||R?"set":"value";if(y?(x||R?d={get:ui(function(){return ee(this)},l,"get"),set:function(h){m[4](this,h)}}:d[A]=ee,x||ui(d[A],l,k?"":A)):x||(d=Object.getOwnPropertyDescriptor(s,l)),!x&&!y){if((o=Z[+b][l])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[A].name+") is not supported yet");Z[+b][l]=c<3?1:c}}for(var p=s,j=q.length-1;j>=0;j-=g?2:1){var re=w(q[j],"A decorator","be",!0),ne=g?q[j-1]:void 0,W={},L={kind:["field","accessor","method","getter","setter","class"][c],name:l,metadata:u,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");w(E,"An initializer","be",!0),v.push(E)}.bind(null,W)};if(G)o=re.call(ne,p,L),W.v=1,w(o,"class decorators","return")&&(p=o);else if(L.static=b,L.private=y,o=L.access={has:y?N.bind():function(h){return l in h}},ie||(o.get=y?k?function(h){return K(h),d.value}:M("get",0,K):function(h){return h[l]}),k||te||(o.set=y?M("set",0,K):function(h,E){h[l]=E}),p=re.call(ne,R?{get:d.get,set:d.set}:d[A],L),W.v=1,R){if(typeof p=="object"&&p)(o=w(p.get,"accessor.get"))&&(d.get=o),(o=w(p.set,"accessor.set"))&&(d.set=o),(o=w(p.init,"accessor.init"))&&$.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else w(p,(x?"field":"method")+" decorators","return")&&(x?$.unshift(p):d[A]=p)}return c<2&&O.push(D($,b,1),D(v,b,0)),x||G||(y?R?O.splice(-1,0,M("get",b),M("set",b)):O.push(k?d[A]:w.call.bind(d[A])):X(s,l,d)),p}function Q(s){return X(s,H,{configurable:!0,enumerable:!0,value:u})}return a!==void 0&&(u=a[H]),u=B(u??null),I=[],C=function(s){s&&I.push(D(s))},S=function(s,m){for(var g=0;g<i.length;g++){var l=i[g],c=l[1],v=7&c;if((8&c)==s&&!v==m){var O=l[2],b=!!l[3],y=16&c;J(s?t:t.prototype,l,y,b?"#"+O:ur(O),v,v<2?[]:s?_=_||[]:f=f||[],I,!!s,b,m,s&&b?function(x){return dr(x)===t}:n)}}},S(8,0),S(0,0),S(8,1),S(0,1),C(f),C(_),o=I,Y||Q(t),{e:o,get c(){var s=[];return Y&&[Q(t=J(t,[e],r,t.name,5,s)),D(s,1)]}}}function ur(t){var e=cr(t,"string");return typeof e=="symbol"?e:e+""}function cr(t,e){if(typeof t!="object"||!t)return t;var i=t[Symbol.toPrimitive];if(i!==void 0){var r=i.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ui(t,e,i){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:i?i+" "+e:e})}catch{}return t}function dr(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var pi,hi=class extends ci{static{({e:[zt,Xt,Zt,Yt,Jt,Qt,Nt,ei,ti,ii,ri,ni,oi,si,li,ai,Ut],c:[pi,Ht]}=ar(this,[hr("rui-tag-group")],[[ge({...ce,defaultValue:[]}),0,"value"],[ge({type:String,defaultValue:""}),0,"label"],[ge({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[ge({type:String,attribute:"selection-mode",defaultValue:"multiple"}),0,"selectionMode"],[ge({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[di({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[di({name:"rui-remove",bubbles:!0,composed:!0}),0,"removeEvent"],[fr,0,"derivedItems"],[pr(["value","label","disabled","selectionMode","embedded","derivedItems"]),2,"onPropsUpdated"],[Ce({selector:"[data-tag]",type:"click"}),2,"onTagClick"],[Ce({selector:"[data-tag-remove]",type:"click"}),2,"onRemoveClick"],[Ce({selector:"[data-tag]",type:"keydown"}),2,"onTagKeydown"]],0,void 0,ci))}constructor(...e){super(...e),ai(this)}value=(Ut(this),zt(this));label=(Xt(this),Zt(this));disabled=(Yt(this),Jt(this));selectionMode=(Qt(this),Nt(this));embedded=(ei(this),ti(this));changeEvent=(ii(this),ri(this));removeEvent=(ni(this),oi(this));uid=(si(this),ue("rui-tag-group"));derivedItems=li(this,null);isMultiple(){return this.selectionMode==="multiple"}getSelectedValues(){return this.value}setSelectedValues(e){this.value=e}getList(){let e=this.querySelector("[data-rui-managed-list]");return e||(this.derivedItems!=null?null:this.querySelector("[data-tag-list]"))}getTags(){let e=this.getList();return e?Array.from(e.querySelectorAll("[data-tag]")):[]}getVisibleTags(){return this.getTags().filter(e=>!e.hidden&&e.getAttribute("aria-disabled")!=="true")}getTagValue(e){return e.getAttribute("data-value")||e.textContent?.trim()||""}getTagLabel(e){return e.getAttribute("data-label")||e.textContent?.trim()||""}ensureTagIds(){this.getTags().forEach((e,i)=>{e.id||(e.id=`${this.uid}-tag-${i}`)})}syncList(){let e=this.getList();e&&(e.id||(e.id=`${this.uid}-list`),e.setAttribute("role","list"),e.setAttribute("aria-label",this.label||"Tags"),this.disabled?e.setAttribute("aria-disabled","true"):e.removeAttribute("aria-disabled"))}syncTags(){let e=new Set(this.getSelectedValues());this.getTags().forEach((r,n)=>{r.setAttribute("role","listitem");let a=this.getTagValue(r),u=e.has(a);r.setAttribute("aria-selected",String(u)),r.tabIndex=n===0?0:-1;let o=r.querySelector("[data-tag-remove]");o&&(o.type="button",o.tabIndex=-1,o.setAttribute("aria-label",`Remove ${this.getTagLabel(r)}`))})}selectTag(e){if(this.disabled||this.embedded||e.getAttribute("aria-disabled")==="true")return;let i=this.getTagValue(e);if(this.isMultiple()){let r=new Set(this.getSelectedValues());r.has(i)?r.delete(i):r.add(i),this.setSelectedValues([...r])}else this.value=[i];this.syncTags(),this.changeEvent.emit({value:this.value})}removeTag(e){let i=this.getTagValue(e),r=new Set(this.getSelectedValues());r.delete(i),this.setSelectedValues([...r]),this.syncTags(),this.removeEvent.emit({value:i}),this.changeEvent.emit({value:this.value})}initialize(){this.syncManagedList(),this.ensureTagIds(),this.syncList(),this.syncTags()}onConnected(){this.initialize()}onPropsUpdated(){this.syncManagedList(),this.syncList(),this.syncTags()}resync(){this.ensureTagIds(),this.syncList(),this.syncTags()}setItems(e){this.derivedItems=e,this.value=e.map(i=>i.value)}createManagedTag(e){let i=document.createElement("span");i.setAttribute("data-tag",""),i.setAttribute("data-value",e.value),i.setAttribute("data-label",e.label),i.className="rui-tag",i.textContent=e.label,i.setAttribute("aria-label",e.label);let r=document.createElement("button");return r.type="button",r.setAttribute("data-tag-remove",""),r.className="rui-tag__remove",r.setAttribute("aria-label",`Remove ${e.label}`),r.append(wt()),i.append(r),i}syncManagedList(){let e=this.querySelector('[data-ref="root"]');if(!e||this.derivedItems==null)return;e.querySelector("[data-tag-list]:not([data-rui-managed-list])")?.toggleAttribute("hidden",!0);let r=e.querySelector("[data-rui-managed-list]");if(this.derivedItems.length===0){r?.remove();return}r||(r=document.createElement("div"),r.setAttribute("data-tag-list",""),r.setAttribute("data-rui-managed-list",""),r.className="rui-tag-group__list",e.appendChild(r)),r.replaceChildren(...this.derivedItems.map(n=>this.createManagedTag(n))),this.ensureTagIds(),this.syncList(),this.syncTags()}onTagClick(e){let i=e.target;if(i.closest("[data-tag-remove]"))return;let r=i.closest("[data-tag]");r&&this.contains(r)&&this.selectTag(r)}onRemoveClick(e){e.stopPropagation();let r=e.target.closest("[data-tag]");r&&this.contains(r)&&this.removeTag(r)}onTagKeydown(e){let i=this.getVisibleTags(),r=e.target.closest("[data-tag]");if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.embedded||this.selectTag(r);return}if(e.key==="Backspace"||e.key==="Delete"){r.querySelector("[data-tag-remove]")&&(e.preventDefault(),this.removeTag(r));return}Se({items:i,current:r,key:e.key,orientation:"horizontal"}).handled&&e.preventDefault()}static{Ht()}};import{jsx as U,jsxs as gr}from"@ecopages/jsx/jsx-runtime";function gi({children:t,class:e,...i}){return U("div",{...i,"data-tag-list":!0,class:T("rui-tag-group__list",e),children:t})}function bi({value:t,label:e,children:i,class:r,disabled:n,aria:a,...u}){return gr("span",{...u,"data-tag":!0,"data-value":t,"data-label":e,class:T("rui-tag",r),aria:de(a,e),"aria-disabled":n?"true":void 0,children:[i,U(mi,{})]})}function mi({children:t,class:e,aria:i,...r}){return U("button",{...r,aria:de(i,"Remove"),type:"button","data-tag-remove":!0,class:T("rui-tag__remove",e),children:t??U(fe,{})})}function fi({children:t}){return U("div",{class:"rui-tag-group","data-ref":"root",children:t})}function Re({tags:t,children:e,value:i,...r}){return t!=null?U("rui-tag-group",{...r,value:i,children:U(fi,{children:U(gi,{children:t.map(n=>U(bi,{value:n.value,label:typeof n.label=="string"?n.label:void 0,disabled:n.disabled,children:n.label}))})})}):U("rui-tag-group",{...r,value:i,children:U(fi,{children:e})})}function yi({children:t,class:e,...i}){return V("div",{...i,class:T("rui-select__control",e),children:t})}function xi({children:t,class:e,disabled:i,...r}){return V("div",{...r,"data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:T("rui-select__trigger",e),tabIndex:i?-1:0,"aria-disabled":i?"true":void 0,children:t})}function Si({children:t,class:e,aria:i,disabled:r,...n}){return V("button",{...n,aria:de(i,"Show options"),type:"button","data-select-toggle":!0,class:T("rui-control-toggle",e),disabled:r,tabIndex:-1,children:t??V(Ee,{})})}function mr({children:t,class:e,aria:i,disabled:r,...n}){return V("button",{...n,aria:de(i,"Clear selection"),type:"button","data-select-clear":!0,class:T("rui-control-clear",e),disabled:r,children:t??V(fe,{})})}function wi({children:t,class:e,...i}){return V("span",{...i,"data-select-value":!0,class:T("rui-select__value",e),children:t})}function Ai({children:t,class:e,...i}){return V("div",{...i,"data-select-listbox":!0,class:T("rui-select__listbox rui-popover rui-popover--listbox rui-floating",e),children:t})}function vr({placeholder:t,class:e,disabled:i,...r}){return V("input",{...r,type:"search","data-autocomplete-input":!0,class:T("rui-select__search",e),placeholder:t,disabled:i,autocomplete:"off"})}function yr(t,e,i){let r=pe(e)[0]??"",n=typeof i=="string"?i:"";if(!r)return n;let a=t?.find(u=>u.value===r);return a&&typeof a.label=="string"?a.label:r}function xr({children:t}){return V("div",{class:"rui-select","data-ref":"root",children:t})}function Sr({options:t,children:e,value:i,...r}){let n=pe(i),a=r.selectionMode==="multiple",u=t!=null?yr(t,i,r.placeholder):"",o=t?.filter(f=>n.includes(f.value)).map(f=>({value:f.value,label:f.label}));return V("rui-select",{...r,value:n,children:V(xr,{children:t==null?e:vi(br,{children:[vi(yi,{children:[V(xi,{disabled:r.disabled,children:V(wi,{children:a?V(Re,{tags:o??[],label:"Selected options"}):u})}),V(Si,{})]}),V(Ai,{children:V(we,{embedded:!0,options:t,selectionMode:r.selectionMode,value:n})})]})})})}export{we as RuiListbox,Ve as RuiListboxOption,Sr as RuiSelect,mr as RuiSelectClear,yi as RuiSelectControl,mt as RuiSelectElement,Ai as RuiSelectListbox,vr as RuiSelectSearch,Si as RuiSelectToggle,xi as RuiSelectTrigger,wi as RuiSelectValue};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|