@ecopages/radiant-ui 0.1.0-beta.7 → 0.1.0-beta.8

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.
Files changed (264) hide show
  1. package/README.md +1 -1
  2. package/dist/components/ui/alert/alert.css +88 -50
  3. package/dist/components/ui/alert/alert.d.ts +43 -5
  4. package/dist/components/ui/alert/alert.script.d.ts +51 -4
  5. package/dist/components/ui/alert/index.d.ts +2 -2
  6. package/dist/components/ui/alert/index.js +1 -1
  7. package/dist/components/ui/alert/index.js.map +4 -4
  8. package/dist/components/ui/autocomplete/autocomplete.css +4 -4
  9. package/dist/components/ui/autocomplete/autocomplete.d.ts +15 -5
  10. package/dist/components/ui/autocomplete/autocomplete.script.d.ts +9 -0
  11. package/dist/components/ui/autocomplete/index.js +1 -1
  12. package/dist/components/ui/autocomplete/index.js.map +4 -4
  13. package/dist/components/ui/avatar/avatar.d.ts +15 -1
  14. package/dist/components/ui/avatar/index.js +1 -1
  15. package/dist/components/ui/avatar/index.js.map +4 -4
  16. package/dist/components/ui/breadcrumb/breadcrumb.d.ts +32 -6
  17. package/dist/components/ui/breadcrumb/index.js +1 -1
  18. package/dist/components/ui/breadcrumb/index.js.map +4 -4
  19. package/dist/{styles/components → components/ui/button}/button.css +45 -31
  20. package/dist/components/ui/button/button.d.ts +21 -4
  21. package/dist/components/ui/button-group/button-group.d.ts +7 -1
  22. package/dist/components/ui/button-group/index.js +1 -1
  23. package/dist/components/ui/button-group/index.js.map +4 -4
  24. package/dist/components/ui/calendar/calendar.css +7 -7
  25. package/dist/components/ui/calendar/calendar.d.ts +3 -2
  26. package/dist/components/ui/calendar/calendar.script.d.ts +39 -1
  27. package/dist/components/ui/calendar/index.js +1 -1
  28. package/dist/components/ui/calendar/index.js.map +4 -4
  29. package/dist/components/ui/carousel/carousel.d.ts +32 -6
  30. package/dist/components/ui/carousel/carousel.script.d.ts +44 -0
  31. package/dist/components/ui/carousel/index.js +1 -1
  32. package/dist/components/ui/carousel/index.js.map +4 -4
  33. package/dist/components/ui/checkbox/checkbox.css +1 -1
  34. package/dist/components/ui/checkbox/checkbox.d.ts +3 -2
  35. package/dist/components/ui/checkbox/checkbox.script.d.ts +4 -0
  36. package/dist/components/ui/checkbox/index.js +1 -1
  37. package/dist/components/ui/checkbox/index.js.map +4 -4
  38. package/dist/components/ui/chip/chip.d.ts +8 -0
  39. package/dist/components/ui/chip/index.js +1 -1
  40. package/dist/components/ui/chip/index.js.map +4 -4
  41. package/dist/components/ui/chip-list/chip-list.d.ts +10 -2
  42. package/dist/components/ui/chip-list/index.js +1 -1
  43. package/dist/components/ui/chip-list/index.js.map +4 -4
  44. package/dist/components/ui/combobox/combobox.css +39 -1
  45. package/dist/components/ui/combobox/combobox.d.ts +15 -5
  46. package/dist/components/ui/combobox/combobox.script.d.ts +13 -1
  47. package/dist/components/ui/combobox/index.js +1 -1
  48. package/dist/components/ui/combobox/index.js.map +4 -4
  49. package/dist/components/ui/cycle-toggle/cycle-toggle.css +15 -0
  50. package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +29 -0
  51. package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +61 -0
  52. package/dist/components/ui/cycle-toggle/index.d.ts +5 -0
  53. package/dist/components/ui/cycle-toggle/index.js +2 -0
  54. package/dist/components/ui/cycle-toggle/index.js.map +7 -0
  55. package/dist/components/ui/cycle-toggle/theme-preference-icons.d.ts +12 -0
  56. package/dist/components/ui/date-field/date-field.css +37 -0
  57. package/dist/components/ui/date-field/date-field.d.ts +22 -3
  58. package/dist/components/ui/date-field/date-field.script.d.ts +29 -5
  59. package/dist/components/ui/date-field/index.d.ts +1 -1
  60. package/dist/components/ui/date-field/index.js +1 -1
  61. package/dist/components/ui/date-field/index.js.map +4 -4
  62. package/dist/components/ui/date-range-picker/date-range-picker.css +37 -0
  63. package/dist/components/ui/date-range-picker/date-range-picker.d.ts +37 -4
  64. package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +31 -5
  65. package/dist/components/ui/date-range-picker/index.d.ts +1 -1
  66. package/dist/components/ui/date-range-picker/index.js +1 -1
  67. package/dist/components/ui/date-range-picker/index.js.map +4 -4
  68. package/dist/components/ui/dialog/dialog.css +1 -1
  69. package/dist/components/ui/dialog/dialog.d.ts +30 -5
  70. package/dist/components/ui/dialog/dialog.script.d.ts +3 -0
  71. package/dist/components/ui/dialog/index.js +1 -1
  72. package/dist/components/ui/dialog/index.js.map +4 -4
  73. package/dist/components/ui/disclosure/disclosure-group.css +1 -1
  74. package/dist/components/ui/disclosure/disclosure-group.script.d.ts +6 -0
  75. package/dist/components/ui/disclosure/disclosure.d.ts +26 -7
  76. package/dist/components/ui/disclosure/disclosure.script.d.ts +5 -0
  77. package/dist/components/ui/disclosure/index.js +1 -1
  78. package/dist/components/ui/disclosure/index.js.map +4 -4
  79. package/dist/components/ui/feed/feed.d.ts +37 -7
  80. package/dist/components/ui/feed/index.js +1 -1
  81. package/dist/components/ui/feed/index.js.map +4 -4
  82. package/dist/components/ui/field/field-description.d.ts +5 -1
  83. package/dist/components/ui/field/field-error.d.ts +5 -0
  84. package/dist/components/ui/field/field.d.ts +8 -1
  85. package/dist/components/ui/field/field.script.d.ts +35 -0
  86. package/dist/components/ui/field/index.js +1 -1
  87. package/dist/components/ui/field/index.js.map +4 -4
  88. package/dist/components/ui/form/control-protocol.d.ts +6 -0
  89. package/dist/components/ui/form/form.d.ts +2 -1
  90. package/dist/components/ui/form/form.script.d.ts +16 -1
  91. package/dist/components/ui/form/index.d.ts +1 -1
  92. package/dist/components/ui/form/index.js +1 -1
  93. package/dist/components/ui/form/index.js.map +4 -4
  94. package/dist/components/ui/grid/grid.d.ts +12 -2
  95. package/dist/components/ui/grid/grid.script.d.ts +14 -0
  96. package/dist/components/ui/grid/index.js +1 -1
  97. package/dist/components/ui/grid/index.js.map +4 -4
  98. package/dist/components/ui/heading/heading.d.ts +26 -4
  99. package/dist/components/ui/heading/index.js +1 -1
  100. package/dist/components/ui/heading/index.js.map +4 -4
  101. package/dist/components/ui/headline/headline.d.ts +9 -1
  102. package/dist/components/ui/headline/index.js +1 -1
  103. package/dist/components/ui/headline/index.js.map +4 -4
  104. package/dist/components/ui/input/index.d.ts +1 -1
  105. package/dist/components/ui/input/index.js +1 -1
  106. package/dist/components/ui/input/index.js.map +4 -4
  107. package/dist/components/ui/input/input.css +2 -7
  108. package/dist/components/ui/input/input.d.ts +7 -2
  109. package/dist/components/ui/label/index.js +1 -1
  110. package/dist/components/ui/label/index.js.map +4 -4
  111. package/dist/components/ui/label/label.d.ts +8 -1
  112. package/dist/components/ui/listbox/index.js +1 -1
  113. package/dist/components/ui/listbox/index.js.map +4 -4
  114. package/dist/components/ui/listbox/listbox.css +2 -5
  115. package/dist/components/ui/listbox/listbox.d.ts +7 -3
  116. package/dist/components/ui/listbox/listbox.script.d.ts +14 -1
  117. package/dist/components/ui/menu-button/index.d.ts +1 -1
  118. package/dist/components/ui/menu-button/index.js +1 -1
  119. package/dist/components/ui/menu-button/index.js.map +4 -4
  120. package/dist/components/ui/menu-button/menu-button.css +2 -2
  121. package/dist/components/ui/menu-button/menu-button.d.ts +27 -5
  122. package/dist/components/ui/menu-button/menu-button.script.d.ts +8 -3
  123. package/dist/components/ui/menubar/index.js +1 -1
  124. package/dist/components/ui/menubar/index.js.map +4 -4
  125. package/dist/components/ui/menubar/menubar.css +4 -4
  126. package/dist/components/ui/menubar/menubar.d.ts +14 -2
  127. package/dist/components/ui/menubar/menubar.script.d.ts +10 -1
  128. package/dist/components/ui/meter/index.js +1 -1
  129. package/dist/components/ui/meter/index.js.map +4 -4
  130. package/dist/components/ui/meter/meter.css +1 -1
  131. package/dist/components/ui/meter/meter.d.ts +7 -2
  132. package/dist/components/ui/meter/meter.script.d.ts +21 -0
  133. package/dist/components/ui/navigation-menu/index.js +1 -1
  134. package/dist/components/ui/navigation-menu/index.js.map +4 -4
  135. package/dist/components/ui/navigation-menu/navigation-menu.css +2 -2
  136. package/dist/components/ui/navigation-menu/navigation-menu.d.ts +3 -2
  137. package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +4 -0
  138. package/dist/components/ui/number-field/index.d.ts +1 -1
  139. package/dist/components/ui/number-field/index.js +1 -1
  140. package/dist/components/ui/number-field/index.js.map +4 -4
  141. package/dist/components/ui/number-field/number-field.css +18 -3
  142. package/dist/components/ui/number-field/number-field.d.ts +36 -8
  143. package/dist/components/ui/number-field/number-field.script.d.ts +28 -1
  144. package/dist/components/ui/popover/index.js +1 -1
  145. package/dist/components/ui/popover/index.js.map +4 -4
  146. package/dist/components/ui/popover/popover.d.ts +5 -4
  147. package/dist/components/ui/popover/popover.script.d.ts +4 -0
  148. package/dist/components/ui/radio-group/index.d.ts +1 -1
  149. package/dist/components/ui/radio-group/index.js +1 -1
  150. package/dist/components/ui/radio-group/index.js.map +4 -4
  151. package/dist/components/ui/radio-group/radio-group.d.ts +29 -4
  152. package/dist/components/ui/radio-group/radio-group.script.d.ts +14 -9
  153. package/dist/components/ui/select/index.js +1 -1
  154. package/dist/components/ui/select/index.js.map +4 -4
  155. package/dist/components/ui/select/select.css +48 -6
  156. package/dist/components/ui/select/select.d.ts +29 -8
  157. package/dist/components/ui/select/select.script.d.ts +7 -0
  158. package/dist/components/ui/sidebar/index.js +1 -1
  159. package/dist/components/ui/sidebar/index.js.map +4 -4
  160. package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +4 -0
  161. package/dist/components/ui/sidebar/sidebar.css +41 -24
  162. package/dist/components/ui/sidebar/sidebar.d.ts +68 -14
  163. package/dist/components/ui/sidebar/sidebar.docs.css +5 -2
  164. package/dist/components/ui/sidebar/sidebar.script.d.ts +9 -0
  165. package/dist/components/ui/slider/index.js +1 -1
  166. package/dist/components/ui/slider/index.js.map +4 -4
  167. package/dist/components/ui/slider/slider.d.ts +2 -1
  168. package/dist/components/ui/slider/slider.script.d.ts +29 -1
  169. package/dist/components/ui/switch/index.js +1 -1
  170. package/dist/components/ui/switch/index.js.map +4 -4
  171. package/dist/components/ui/switch/switch.css +3 -3
  172. package/dist/components/ui/switch/switch.d.ts +11 -2
  173. package/dist/components/ui/switch/switch.script.d.ts +5 -0
  174. package/dist/components/ui/tabs/index.js +1 -1
  175. package/dist/components/ui/tabs/index.js.map +4 -4
  176. package/dist/components/ui/tabs/tabs.css +9 -10
  177. package/dist/components/ui/tabs/tabs.d.ts +30 -9
  178. package/dist/components/ui/tag-group/index.js +1 -1
  179. package/dist/components/ui/tag-group/index.js.map +4 -4
  180. package/dist/components/ui/tag-group/tag-group.css +2 -11
  181. package/dist/components/ui/tag-group/tag-group.d.ts +18 -5
  182. package/dist/components/ui/tag-group/tag-group.script.d.ts +9 -2
  183. package/dist/components/ui/textarea/index.d.ts +1 -1
  184. package/dist/components/ui/textarea/index.js +1 -1
  185. package/dist/components/ui/textarea/index.js.map +4 -4
  186. package/dist/components/ui/textarea/textarea.d.ts +7 -2
  187. package/dist/components/ui/toast/index.d.ts +1 -1
  188. package/dist/components/ui/toast/index.js +1 -1
  189. package/dist/components/ui/toast/index.js.map +4 -4
  190. package/dist/components/ui/toast/stack-layout.d.ts +18 -0
  191. package/dist/components/ui/toast/toast-context.d.ts +10 -0
  192. package/dist/components/ui/toast/toast.css +30 -9
  193. package/dist/components/ui/toast/toast.d.ts +12 -2
  194. package/dist/components/ui/toast/toast.script.d.ts +60 -4
  195. package/dist/components/ui/toast/toaster.script.d.ts +71 -2
  196. package/dist/components/ui/toc/index.js +1 -1
  197. package/dist/components/ui/toc/index.js.map +4 -4
  198. package/dist/components/ui/toc/toc.css +3 -0
  199. package/dist/components/ui/toc/toc.d.ts +2 -1
  200. package/dist/components/ui/toc/toc.script.d.ts +15 -0
  201. package/dist/components/ui/toolbar/index.js +1 -1
  202. package/dist/components/ui/toolbar/index.js.map +4 -4
  203. package/dist/components/ui/toolbar/toolbar.d.ts +3 -2
  204. package/dist/components/ui/toolbar/toolbar.script.d.ts +8 -0
  205. package/dist/components/ui/tooltip/index.js +1 -1
  206. package/dist/components/ui/tooltip/index.js.map +4 -4
  207. package/dist/components/ui/tooltip/tooltip.d.ts +3 -2
  208. package/dist/components/ui/tooltip/tooltip.script.d.ts +3 -0
  209. package/dist/components/ui/tree/index.js +1 -1
  210. package/dist/components/ui/tree/index.js.map +4 -4
  211. package/dist/components/ui/tree/tree.d.ts +12 -2
  212. package/dist/components/ui/tree/tree.script.d.ts +18 -1
  213. package/dist/components/ui/treegrid/index.js +1 -1
  214. package/dist/components/ui/treegrid/index.js.map +4 -4
  215. package/dist/components/ui/treegrid/treegrid.d.ts +15 -2
  216. package/dist/components/ui/treegrid/treegrid.script.d.ts +22 -1
  217. package/dist/components/ui/window-splitter/index.js +1 -1
  218. package/dist/components/ui/window-splitter/index.js.map +4 -4
  219. package/dist/components/ui/window-splitter/window-splitter.css +1 -1
  220. package/dist/components/ui/window-splitter/window-splitter.d.ts +3 -2
  221. package/dist/components/ui/window-splitter/window-splitter.script.d.ts +22 -0
  222. package/dist/index.d.ts +1 -0
  223. package/dist/index.js +1 -1
  224. package/dist/index.js.map +4 -4
  225. package/dist/lib/cycle-value.d.ts +8 -0
  226. package/dist/lib/intl-number/range.d.ts +8 -0
  227. package/dist/styles/radiant-ui-core.css +110 -341
  228. package/dist/styles/radiant-ui.css +413 -377
  229. package/dist/styles/styles.css +839 -2731
  230. package/dist/styles/tailwind.css +626 -530
  231. package/dist/styles/tokens/colors/aurora.css +2 -2
  232. package/dist/styles/tokens/colors/basalt.css +2 -1
  233. package/dist/styles/tokens/colors/glacier.css +2 -1
  234. package/dist/styles/tokens/presets/colors/aurora.css +42 -14
  235. package/dist/styles/tokens/presets/colors/basalt.css +28 -0
  236. package/dist/styles/tokens/presets/colors/ember.css +28 -0
  237. package/dist/styles/tokens/presets/colors/glacier.css +28 -0
  238. package/dist/styles/tokens/semantic.css +22 -2
  239. package/dist/styles/tokens/spacing/compact.css +12 -12
  240. package/package.json +21 -8
  241. package/dist/components/ui/dialog/dialog-registry.test.d.ts +0 -1
  242. package/dist/components/ui/field/field-ssr-hydration.test.d.ts +0 -1
  243. package/dist/components/ui/form/form-field.test.d.ts +0 -4
  244. package/dist/components/ui/form/form-store.test.d.ts +0 -1
  245. package/dist/components/ui/shared/collection-navigation.test.d.ts +0 -1
  246. package/dist/components/ui/shared/floating-position.test.d.ts +0 -1
  247. package/dist/components/ui/shared/listbox-popover-behavior.test.d.ts +0 -1
  248. package/dist/components/ui/shared/popover-controller.test.d.ts +0 -1
  249. package/dist/components/ui/shared/portal.test.d.ts +0 -1
  250. package/dist/components/ui/sidebar/sidebar.ssr.test.d.ts +0 -2
  251. package/dist/components/ui/sidebar/sidebar.test.d.ts +0 -1
  252. package/dist/components/ui/toast/toast.test.d.ts +0 -2
  253. package/dist/components/ui/toc/toc-helpers.test.d.ts +0 -1
  254. package/dist/components/ui/toc/toc.ssr.test.d.ts +0 -1
  255. package/dist/components/ui/toc/toc.test.d.ts +0 -1
  256. package/dist/lib/intl-date/parts.test.d.ts +0 -1
  257. package/dist/lib/intl-date/segments.test.d.ts +0 -1
  258. package/dist/lib/intl-date/selection.test.d.ts +0 -1
  259. package/dist/lib/mask/date-mask.test.d.ts +0 -1
  260. package/dist/lib/mask/input-mask.test.d.ts +0 -1
  261. package/dist/lib/radiant-view.d.ts +0 -43
  262. package/dist/lib/text-filter.test.d.ts +0 -1
  263. package/dist/styles/tokens/presets/radius.css +0 -45
  264. package/dist/styles/tokens/presets/spacing.css +0 -57
@@ -1,2 +1,2 @@
1
- import{jsx as Qt,jsxs as qe}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Zt,customElement as We,event as $e,onEvent as D,onUpdated as He,prop as z,query as Ue}from"@ecopages/radiant";function ft(i){let t=i.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:i.parentElement?.querySelector("[data-rui-field-label], label.rui-label")??null}function yt(i,t,e){if(!t||t.hasAttribute("data-rui-field-managed"))return;let r=ft(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 Te={top:"bottom",bottom:"top",left:"right",right:"left"},Re=8;function Ve(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 wt(i){return i==="top"||i==="bottom"?"y":"x"}function xt(i,t,e,r,n){let{width:s,height:l}=t,o=0,f=0;switch(e){case"top":f=i.top-l-n;break;case"bottom":f=i.bottom+n;break;case"left":o=i.left-s-n;break;case"right":o=i.right+n;break}return wt(e)==="y"?r==="start"?o=i.left:r==="end"?o=i.right-s:o=i.left+(i.width-s)/2:r==="start"?f=i.top:r==="end"?f=i.bottom-l:f=i.top+(i.height-l)/2,{x:o,y:f}}function De(i,t,e,r){let{padding:n,width:s,height:l}=r;return e==="top"?Math.max(0,n-i.y):e==="bottom"?Math.max(0,i.y+t.height-(l-n)):e==="left"?Math.max(0,n-i.x):Math.max(0,i.x+t.width-(s-n))}function Ot(i,t,e,r){let{padding:n,width:s,height:l}=r;return e==="top"?i.top-n-t.height:e==="bottom"?l-n-t.height-i.bottom:e==="left"?i.left-n-t.width:s-n-t.width-i.right}function Le(i,t){return t==="center"?i:`${i}-${t}`}function ke(i,t,e,r){let{padding:n,width:s,height:l}=r;if(wt(e)==="y"){let f=Math.max(n,s-n-t.width);return{x:Math.min(Math.max(i.x,n),f),y:i.y}}let o=Math.max(n,l-n-t.height);return{x:i.x,y:Math.min(Math.max(i.y,n),o)}}function Pe(i,t,e,r,n={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Re}){let{side:s,align:l}=Ve(e),o=xt(i,t,s,l,r),f=De(o,t,s,n),A=s,C=o;if(f>0){let T=Te[s],_=xt(i,t,T,l,r),j=Ot(i,t,s,n);Ot(i,t,T,n)>j&&(A=T,C=_)}return{coords:ke(C,t,A,n),placement:Le(A,l)}}function Me(i,t,e,r,n={}){let{coords:s,placement:l}=Pe(i.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},e,r);return Object.assign(t.style,{position:"fixed",left:`${s.x}px`,top:`${s.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),n.matchAnchorWidth&&(t.style.width=`${i.offsetWidth}px`),t.setAttribute("data-placement",l),l}function St({anchor:i,floating:t,getPlacement:e,gap:r,matchAnchorWidth:n}){let s=()=>{t.hidden||Me(i,t,e(),r,{matchAnchorWidth:n})};s(),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0);let l=new ResizeObserver(s);return l.observe(i),l.observe(t),()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),l.disconnect()}}function At(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 n=r.parentNode;n&&(n.insertBefore(i,r),r.remove())}}}function gt(i,t,e){return e?!!(i?.contains(e)||t?.contains(e)):!1}function _t(i,t,e){return e instanceof Node?!gt(i,t,e):!0}function Et(i,t,e){return!gt(i,t,e)}var at=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.hidden=!0;return}let r=this.config.getAnchor();if(!r)return;t.hidden=!1,this.config.portal!==!1?this.portalHandle||(this.portalHandle=At(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=St({anchor:r,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return gt(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 It(i){return i.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function Ct(i,t,e){return e===0?-1:t===1?i>=e-1?0:i+1:i<=0?e-1:i-1}function bt(i,t){t?.removeAttribute("aria-activedescendant");for(let e of i)e.removeAttribute("data-active")}function Tt(i,t,e,r,n){bt(i,r);let s=t[e];return!s||!r?null:(s.id||(s.id=`${n}-${e}`),s.setAttribute("data-active","true"),r.setAttribute("aria-activedescendant",s.id),s.scrollIntoView({block:"nearest"}),s)}var ut=class{config;popoverController;activeIndex=-1;visualFocus=!1;constructor(t){this.config=t,this.popoverController=new at({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 It(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,bt(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,Tt(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(Ct(this.activeIndex,t,r.length));return}this.setActiveOption(t===1?0:r.length-1)}}handleKeydown(t,e){if(!(t.ctrlKey||t.shiftKey||t.metaKey)){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault(),t.stopPropagation();let r=t.key==="ArrowDown"?1:-1;if(t.altKey){r===1&&!e.isOpen?e.onOpen():r===-1&&e.isOpen&&e.onClose("arrow");return}this.moveActive(r,n=>e.onOpen(n));return}if(t.key==="Escape"){t.preventDefault(),e.isOpen?e.onClose("escape"):e.onEscapeWhenClosed?.();return}if(t.key==="Enter"||t.key===" "&&e.canUseSpace){if(!e.isOpen&&e.enterWhenClosed==="open"){t.preventDefault(),e.onOpen();return}let r=this.getVisibleOptions();e.isOpen&&this.visualFocus&&r[this.activeIndex]?(t.preventDefault(),e.onSelectActive()):t.key==="Enter"&&e.isOpen&&e.enterWithoutActive==="close"&&(t.preventDefault(),e.onClose("enter"));return}if(t.key==="Tab"&&e.isOpen){let r=this.getVisibleOptions();if(this.visualFocus&&r[this.activeIndex]&&e.closesOnTab){e.onSelectActive();return}e.onClose("tab")}}}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(t){return _t(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return Et(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};function Rt(i){return i.split(",").map(t=>t.trim()).filter(Boolean)}function Vt(i){return i.join(",")}var Dt,Lt,kt,Pt,Mt,Ft,Bt,jt,Kt,qt,Wt,$t,Ht,Ut,Gt,zt,Xt,Yt;function Fe(i,t,e,r,n,s){var l,o,f,A,C,T,_,j=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,K=Object.create,X=[K(null),K(null)],Y=t.length;function k(a,m,g){return function(u,c){m&&(c=u,u=i);for(var v=0;v<a.length;v++)c=a[v].apply(u,g?[c]:[]);return g?c:u}}function O(a,m,g,u){if(typeof a!="function"&&(u||a!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(u?"":" or undefined"));return a}function J(a,m,g,u,c,v,S,b,y,x,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var W=[].concat(m[0]),N=m[3],$=!S,R=c===1,tt=c===3,et=c===4,P=c===2;function M(h,E,nt){return function(B,ot){return E&&(ot=B,B=a),nt&&nt(B),d[h].call(B,ot)}}if(!$){var d={},H=[],w=tt?"get":et||R?"set":"value";if(y?(x||R?d={get:Jt(function(){return N(this)},u,"get"),set:function(h){m[4](this,h)}}:d[w]=N,x||Jt(d[w],u,P?"":w)):x||(d=Object.getOwnPropertyDescriptor(a,u)),!x&&!y){if((o=X[+b][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[w].name+") is not supported yet");X[+b][u]=c<3?1:c}}for(var p=a,F=W.length-1;F>=0;F-=g?2:1){var it=O(W[F],"A decorator","be",!0),rt=g?W[F-1]:void 0,U={},V={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:l,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");O(E,"An initializer","be",!0),v.push(E)}.bind(null,U)};if($)o=it.call(rt,p,V),U.v=1,O(o,"class decorators","return")&&(p=o);else if(V.static=b,V.private=y,o=V.access={has:y?Z.bind():function(h){return u in h}},et||(o.get=y?P?function(h){return q(h),d.value}:M("get",0,q):function(h){return h[u]}),P||tt||(o.set=y?M("set",0,q):function(h,E){h[u]=E}),p=it.call(rt,R?{get:d.get,set:d.set}:d[w],V),U.v=1,R){if(typeof p=="object"&&p)(o=O(p.get,"accessor.get"))&&(d.get=o),(o=O(p.set,"accessor.set"))&&(d.set=o),(o=O(p.init,"accessor.init"))&&H.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 O(p,(x?"field":"method")+" decorators","return")&&(x?H.unshift(p):d[w]=p)}return c<2&&S.push(k(H,b,1),k(v,b,0)),x||$||(y?R?S.splice(-1,0,M("get",b),M("set",b)):S.push(P?d[w]:O.call.bind(d[w])):G(a,u,d)),p}function Q(a){return G(a,j,{configurable:!0,enumerable:!0,value:l})}return s!==void 0&&(l=s[j]),l=K(l??null),C=[],T=function(a){a&&C.push(k(a))},_=function(a,m){for(var g=0;g<e.length;g++){var u=e[g],c=u[1],v=7&c;if((8&c)==a&&!v==m){var S=u[2],b=!!u[3],y=16&c;J(a?i:i.prototype,u,y,b?"#"+S:Be(S),v,v<2?[]:a?A=A||[]:f=f||[],C,!!a,b,m,a&&b?function(x){return Ke(x)===i}:n)}}},_(8,0),_(0,0),_(8,1),_(0,1),T(f),T(A),o=C,Y||Q(i),{e:o,get c(){var a=[];return Y&&[Q(i=J(i,[t],r,i.name,5,a)),k(a,1)]}}}function Be(i){var t=je(i,"string");return typeof t=="symbol"?t:t+""}function je(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 Jt(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 Ke(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 ct,Nt=class extends Zt{static{({e:[kt,Pt,Mt,Ft,Bt,jt,Kt,qt,Wt,$t,Ht,Ut,Gt,zt,Xt,Yt,Dt],c:[ct,Lt]}=Fe(this,[We("rui-select")],[[z({type:String,reflect:!0,defaultValue:""}),0,"value"],[z({type:String,defaultValue:""}),0,"label"],[z({type:String,defaultValue:""}),0,"placeholder"],[z({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[z({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[z({type:Boolean,attribute:"should-close-on-select"}),0,"shouldCloseOnSelect"],[$e({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[Ue({ref:"root"}),0,"rootTarget"],[He(["value","label","placeholder","disabled","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[D({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[D({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[D({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[D({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[D({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[D({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[D({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[D({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[D({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[D({ref:"root",type:"focusout"}),2,"onFocusOut"],[D({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,Zt))}constructor(...t){super(...t),Yt(this)}value=(Dt(this),kt(this));label=(Pt(this),Mt(this));placeholder=(Ft(this),Bt(this));disabled=(jt(this),Kt(this));selectionMode=(qt(this),Wt(this));shouldCloseOnSelect=($t(this),Ht(this));changeEvent=(Ut(this),Gt(this));open=(zt(this),!1);uid=Math.random().toString(36).slice(2,9);listboxBehavior=new ut({getAnchor:()=>this.rootTarget,getFloating:()=>this.getListboxPopup(),getOpen:()=>this.open,getOptions:()=>this.getOptions(),getActiveDescendantHost:()=>this.getActiveDescendantHost(),getOptionIdPrefix:()=>`rui-select-option-${this.uid}`});rootTarget=Xt(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?Rt(this.value):[]}setSelectedValues(t){this.value=Vt(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(){return this.querySelector("[data-select-value] rui-tag-group")}hasTagGroup(){return this.getTagGroup()!=null}syncTagGroup(){let t=this.getTagGroup(),e=this.getValueElement();if(!t||!e)return;let r=this.getSelectedValues(),n=r.flatMap(s=>{let l=this.getOptions().find(o=>this.getOptionValue(o)===s);return l?[{value:s,label:this.getOptionLabel(l)}]:[]});t.embedded=!0,t.setItems(n),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 ft(this)?.textContent?.trim()||this.label||"Options"}syncLabel(){let t=this.getTrigger();yt(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.setAttribute("data-placeholder","true"),this.placeholder&&(t.textContent=this.placeholder);return}if(t.removeAttribute("data-placeholder"),this.isMultiple()){let n=e.map(s=>{let l=this.getOptions().find(o=>this.getOptionValue(o)===s);return l?this.getOptionLabel(l):s});t.textContent=n.join(", ");return}let r=this.getOptions().find(n=>this.getOptionValue(n)===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),n=t.has(r);e.setAttribute("aria-selected",String(n))}}setOpen(t,e={}){let r=e.activate??"none";this.open=t;let n=this.getTrigger(),s=this.getListboxPopup();if(!(!n||!s)){if(n.setAttribute("aria-expanded",String(t)),s.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 l=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(l.length?0:-1);return}if(r==="last"){let l=this.listboxBehavior.getVisibleOptions();this.listboxBehavior.setActiveOption(l.length?l.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)}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>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 n=this.listboxBehavior.getVisibleOptions().indexOf(e);n>=0&&this.listboxBehavior.setActiveOption(n)}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)}render(){return qe("div",{class:"rui-select","data-ref":"root",children:[Qt("slot",{name:"trigger"}),Qt("slot",{name:"listbox"})]})}static{Lt()}};import{jsx as I,jsxs as Se}from"@ecopages/jsx/jsx-runtime";function L(...i){return i.filter(Boolean).join(" ")}import{jsx as te}from"@ecopages/jsx/jsx-runtime";function mt({class:i,size:t="sm",...e}){return te("svg",{...e,class:L("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:te("path",{d:"m6 9 6 6 6-6"})})}var Ge=Symbol.for("@ecopages/storybook-radiant.viewElement"),ee=Symbol.for("@ecopages/storybook-radiant.scriptModule"),ie=Symbol.for("@ecopages/storybook-radiant.scriptExport");function ze(i,t){i[Ge]=t;let e=t[ee];e&&(i[ee]=e,i[ie]=t[ie]??t.name)}function dt(i,t,e){let r=n=>t(n);return ze(r,i),r}import{jsx as ye}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as xe,customElement as ei,event as ii,onEvent as Oe,onUpdated as ri,prop as st}from"@ecopages/radiant";function Xe(i,t){i.forEach((e,r)=>{e.tabIndex=r===t?0:-1})}function Ye(i,t){if(!i.length)return null;let e=Math.max(0,Math.min(i.length-1,t));return Xe(i,e),i[e]?.focus(),i[e]??null}function Je(i,t){return i==="Home"?"first":i==="End"?"last":t==="horizontal"?i==="ArrowRight"?"next":i==="ArrowLeft"?"prev":null:i==="ArrowDown"?"next":i==="ArrowUp"?"prev":null}function re(i){let{items:t,current:e,key:r,orientation:n="horizontal",wrap:s=!0}=i;if(!t.length||!e)return{handled:!1};let l=t.indexOf(e);if(l<0)return{handled:!1};let o=Je(r,n);if(!o)return{handled:!1};let f=l;o==="first"?f=0:o==="last"?f=t.length-1:o==="next"?f=s?(l+1)%t.length:Math.min(t.length-1,l+1):f=s?(l-1+t.length)%t.length:Math.max(0,l-1);let A=Ye(t,f);return A?{handled:!0,index:f,item:A}:{handled:!1}}var ne,oe,se,le,ae,ue,ce,de,he,pe,fe,ge,be,me;function Qe(i,t,e,r,n,s){var l,o,f,A,C,T,_,j=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,K=Object.create,X=[K(null),K(null)],Y=t.length;function k(a,m,g){return function(u,c){m&&(c=u,u=i);for(var v=0;v<a.length;v++)c=a[v].apply(u,g?[c]:[]);return g?c:u}}function O(a,m,g,u){if(typeof a!="function"&&(u||a!==void 0))throw new TypeError(m+" must "+(g||"be")+" a function"+(u?"":" or undefined"));return a}function J(a,m,g,u,c,v,S,b,y,x,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var W=[].concat(m[0]),N=m[3],$=!S,R=c===1,tt=c===3,et=c===4,P=c===2;function M(h,E,nt){return function(B,ot){return E&&(ot=B,B=a),nt&&nt(B),d[h].call(B,ot)}}if(!$){var d={},H=[],w=tt?"get":et||R?"set":"value";if(y?(x||R?d={get:ve(function(){return N(this)},u,"get"),set:function(h){m[4](this,h)}}:d[w]=N,x||ve(d[w],u,P?"":w)):x||(d=Object.getOwnPropertyDescriptor(a,u)),!x&&!y){if((o=X[+b][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[w].name+") is not supported yet");X[+b][u]=c<3?1:c}}for(var p=a,F=W.length-1;F>=0;F-=g?2:1){var it=O(W[F],"A decorator","be",!0),rt=g?W[F-1]:void 0,U={},V={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:l,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");O(E,"An initializer","be",!0),v.push(E)}.bind(null,U)};if($)o=it.call(rt,p,V),U.v=1,O(o,"class decorators","return")&&(p=o);else if(V.static=b,V.private=y,o=V.access={has:y?Z.bind():function(h){return u in h}},et||(o.get=y?P?function(h){return q(h),d.value}:M("get",0,q):function(h){return h[u]}),P||tt||(o.set=y?M("set",0,q):function(h,E){h[u]=E}),p=it.call(rt,R?{get:d.get,set:d.set}:d[w],V),U.v=1,R){if(typeof p=="object"&&p)(o=O(p.get,"accessor.get"))&&(d.get=o),(o=O(p.set,"accessor.set"))&&(d.set=o),(o=O(p.init,"accessor.init"))&&H.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 O(p,(x?"field":"method")+" decorators","return")&&(x?H.unshift(p):d[w]=p)}return c<2&&S.push(k(H,b,1),k(v,b,0)),x||$||(y?R?S.splice(-1,0,M("get",b),M("set",b)):S.push(P?d[w]:O.call.bind(d[w])):G(a,u,d)),p}function Q(a){return G(a,j,{configurable:!0,enumerable:!0,value:l})}return s!==void 0&&(l=s[j]),l=K(l??null),C=[],T=function(a){a&&C.push(k(a))},_=function(a,m){for(var g=0;g<e.length;g++){var u=e[g],c=u[1],v=7&c;if((8&c)==a&&!v==m){var S=u[2],b=!!u[3],y=16&c;J(a?i:i.prototype,u,y,b?"#"+S:Ze(S),v,v<2?[]:a?A=A||[]:f=f||[],C,!!a,b,m,a&&b?function(x){return ti(x)===i}:n)}}},_(8,0),_(0,0),_(8,1),_(0,1),T(f),T(A),o=C,Y||Q(i),{e:o,get c(){var a=[];return Y&&[Q(i=J(i,[t],r,i.name,5,a)),k(a,1)]}}}function Ze(i){var t=Ne(i,"string");return typeof t=="symbol"?t:t+""}function Ne(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 ve(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 ti(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 vt,we=class extends xe{static{({e:[se,le,ae,ue,ce,de,he,pe,fe,ge,be,me,ne],c:[vt,oe]}=Qe(this,[ei("rui-listbox")],[[st({type:String,reflect:!0,defaultValue:""}),0,"value"],[st({type:String,defaultValue:""}),0,"label"],[st({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[st({type:Boolean,reflect:!0,defaultValue:!1}),0,"embedded"],[st({type:Boolean,reflect:!0}),0,"bordered"],[ii({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ri(["value","disabled","embedded","bordered"]),2,"onPropsUpdated"],[Oe({selector:'[role="option"]',type:"click"}),2,"onOptionClick"],[Oe({selector:'[role="option"]',type:"keydown"}),2,"onOptionKeydown"]],0,void 0,xe))}value=(ne(this),se(this));label=(le(this),ae(this));disabled=(ue(this),ce(this));embedded=(de(this),he(this));bordered=(pe(this),fe(this));changeEvent=(ge(this),be(this));resolvedAriaLabel=(me(this),this.$.label.map(t=>t||void 0));resolvedAriaDisabled=this.$.disabled.map(t=>t?"true":void 0);connectedCallback(){super.connectedCallback(),queueMicrotask(()=>{this.sync(),this.syncPresentation()})}onPropsUpdated(){this.sync(),this.syncPresentation()}getOptions(){return Array.from(this.querySelectorAll('[role="option"]'))}sync(){let t=this.getOptions();for(let e of t){let r=e.getAttribute("data-value")===this.value;e.setAttribute("aria-selected",String(r)),e.tabIndex=this.embedded?-1:r||!this.value&&e===t[0]?0:-1}}select(t){this.disabled||t.getAttribute("aria-disabled")==="true"||(this.value=t.getAttribute("data-value")||t.textContent?.trim()||"",this.sync(),this.changeEvent.emit({value:this.value}),t.focus())}onOptionClick(t){if(this.embedded)return;let e=t.target.closest('[role="option"]');e&&this.contains(e)&&this.select(e)}onOptionKeydown(t){if(this.embedded)return;let e=this.getOptions(),r=t.target.closest('[role="option"]');if(!r)return;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.select(r);return}let n=re({items:e,current:r,key:t.key,orientation:"vertical"});n.handled&&(t.preventDefault(),this.select(n.item))}isBordered(){return this.bordered!=null?this.bordered:!this.embedded}syncPresentation(){let t=this.querySelector(".rui-listbox");t&&t.classList.toggle("rui-listbox--bordered",this.isBordered())}render(){let t=this.isBordered();return ye("div",{class:`rui-listbox${t?" rui-listbox--bordered":""}`,role:"listbox","data-rui-control":!0,"data-rui-control-type":"text","aria-label":this.resolvedAriaLabel,"aria-disabled":this.resolvedAriaDisabled,children:ye("slot",{})})}static{oe()}};import{jsx as ht}from"@ecopages/jsx/jsx-runtime";function lt({value:i,label:t,children:e,class:r,disabled:n,...s}){return ht("div",{...s,class:L("rui-listbox__option",r),role:"option","data-value":i,"data-label":t,"aria-disabled":n?"true":void 0,tabindex:-1,children:e})}var pt=dt(vt,({options:i,children:t,...e})=>i!=null?ht("rui-listbox",{...e,children:i.map(r=>ht(lt,{value:r.value,label:typeof r.label=="string"?r.label:void 0,disabled:r.disabled,children:r.label}))}):ht("rui-listbox",{...e,children:t}),{stylesheets:["./listbox.css"]});function Ae({children:i,slot:t="trigger",class:e,...r}){return I("div",{...r,slot:t,class:L("rui-select__control",e),children:i})}function _e({children:i,class:t,disabled:e,...r}){return I("button",{...r,type:"button","data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:L("rui-select__trigger",t),disabled:e,children:i})}function Ee({children:i,class:t,"aria-label":e="Show options",disabled:r,...n}){return I("button",{...n,type:"button","data-select-toggle":!0,class:L("rui-control-toggle",t),"aria-label":e,disabled:r,tabIndex:-1,children:i??I(mt,{})})}function Ie({children:i,slot:t,class:e,...r}){return I("span",{...r,slot:t,"data-select-value":!0,class:L("rui-select__value",e),children:i})}function Ce({children:i,slot:t="listbox",class:e,...r}){return I("div",{...r,slot:t,"data-select-listbox":!0,class:L("rui-select__listbox rui-popover rui-popover--listbox rui-floating",e),hidden:!0,children:i})}function ni({placeholder:i,slot:t="input",class:e,disabled:r,...n}){return I("input",{...n,type:"search",slot:t,"data-autocomplete-input":!0,class:L("rui-select__search",e),placeholder:i,disabled:r,autocomplete:"off"})}var oi=lt,si=dt(ct,({options:i,children:t,...e})=>i!=null?Se("rui-select",{...e,children:[Se(Ae,{children:[I(_e,{children:I(Ie,{})}),I(Ee,{})]}),I(Ce,{children:I(pt,{embedded:!0,options:i})})]}):I("rui-select",{...e,children:t}),{stylesheets:["./select.css","../shared/control-toggle.css","../../../lib/icons/icons.css"]});export{pt as RuiListbox,lt as RuiListboxOption,si as RuiSelect,Ae as RuiSelectControl,ct as RuiSelectElement,Ce as RuiSelectListbox,oi as RuiSelectOption,ni as RuiSelectSearch,Ee as RuiSelectToggle,_e as RuiSelectTrigger,Ie as RuiSelectValue};
1
+ import{jsx as Xt,jsxs as be}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Yt,customElement as me,event as ve,onEvent as v,onUpdated as xe,prop as P,query as ye}from"@ecopages/radiant";function N(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=N(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 oe={top:"bottom",bottom:"top",left:"right",right:"left"},ne=8;function se(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,p=0;switch(e){case"top":p=i.top-s-o;break;case"bottom":p=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"?p=i.top:r==="end"?p=i.bottom-s:p=i.top+(i.height-s)/2,{x:l,y:p}}function le(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 ae(i,t){return t==="center"?i:`${i}-${t}`}function ue(i,t,e,r){let{padding:o,width:n,height:s}=r;if(vt(e)==="y"){let p=Math.max(o,n-o-t.width);return{x:Math.min(Math.max(i.x,o),p),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 ce(i,t,e,r,o={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:ne}){let{side:n,align:s}=se(e),l=bt(i,t,n,s,r),p=le(l,t,n,o),I=n,_=l;if(p>0){let T=oe[n],V=bt(i,t,T,s,r),k=mt(i,t,n,o);mt(i,t,T,o)>k&&(I=T,_=V)}return{coords:ue(_,t,I,o),placement:ae(I,s)}}function he(i,t,e,r,o={}){let{coords:n,placement:s}=ce(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||he(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 tt(i,t,e){return e?!!(i?.contains(e)||t?.contains(e)):!1}function Ot(i,t,e){return e instanceof Node?!tt(i,t,e):!0}function St(i,t,e){return!tt(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.hidden=!0;return}let r=this.config.getAnchor();if(!r)return;t.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 tt(this.config.getAnchor(),this.resolveFloating(),t)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let t=this.config.getFloating();return t&&(this.floatingElement=t),t??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function wt(i){return i.filter(t=>!t.hidden&&t.getAttribute("aria-disabled")!=="true")}function At(i,t,e){return e===0?-1:t===1?i>=e-1?0:i+1:i<=0?e-1:i-1}function et(i,t){t?.removeAttribute("aria-activedescendant");for(let e of i)e.removeAttribute("data-active")}function Ct(i,t,e,r,o){et(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 wt(this.config.getOptions())}clearActiveOption(){this.activeIndex=-1,this.visualFocus=!1,et(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(At(this.activeIndex,t,r.length));return}this.setActiveOption(t===1?0:r.length-1)}}handleKeydown(t,e){if(!(t.ctrlKey||t.shiftKey||t.metaKey)){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault(),t.stopPropagation();let r=t.key==="ArrowDown"?1:-1;if(t.altKey){r===1&&!e.isOpen?e.onOpen():r===-1&&e.isOpen&&e.onClose("arrow");return}this.moveActive(r,o=>e.onOpen(o));return}if(t.key==="Escape"){t.preventDefault(),e.isOpen?e.onClose("escape"):e.onEscapeWhenClosed?.();return}if(t.key==="Enter"||t.key===" "&&e.canUseSpace){if(!e.isOpen&&e.enterWhenClosed==="open"){t.preventDefault(),e.onOpen();return}let r=this.getVisibleOptions();e.isOpen&&this.visualFocus&&r[this.activeIndex]?(t.preventDefault(),e.onSelectActive()):t.key==="Enter"&&e.isOpen&&e.enterWithoutActive==="close"&&(t.preventDefault(),e.onClose("enter"));return}if(t.key==="Tab"&&e.isOpen){let r=this.getVisibleOptions();if(this.visualFocus&&r[this.activeIndex]&&e.closesOnTab){e.onSelectActive();return}e.onClose("tab")}}}syncPopoverPosition(){this.popoverController.sync()}shouldDismissFocus(t){return Ot(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}shouldDismissPointer(t){return St(this.config.getAnchor(),this.popoverController.getFloatingElement(),t)}destroy(){this.popoverController.destroy()}};function It(i){return i.split(",").map(t=>t.trim()).filter(Boolean)}function _t(i){return i.join(",")}var Tt,Vt,Et,Lt,Pt,Dt,Ft,Rt,kt,Mt,Bt,jt,Ht,Kt,qt,Wt,Gt,$t;function de(i,t,e,r,o,n){var s,l,p,I,_,T,V,k=Symbol.metadata||Symbol.for("Symbol.metadata"),U=Object.defineProperty,X=Object.create,rt=[X(null),X(null)],ot=t.length;function M(a,y,b){return function(u,c){y&&(c=u,u=i);for(var O=0;O<a.length;O++)c=a[O].apply(u,b?[c]:[]);return b?c:u}}function A(a,y,b,u){if(typeof a!="function"&&(u||a!==void 0))throw new TypeError(y+" must "+(b||"be")+" a function"+(u?"":" or undefined"));return a}function nt(a,y,b,u,c,O,E,m,S,w,lt){function Y(d){if(!lt(d))throw new TypeError("Attempted to access private element on non-instance")}var J=[].concat(y[0]),at=y[3],Q=!E,D=c===1,ut=c===3,ct=c===4,B=c===2;function j(d,L,pt){return function(K,gt){return L&&(gt=K,K=a),pt&&pt(K),h[d].call(K,gt)}}if(!Q){var h={},Z=[],C=ut?"get":ct||D?"set":"value";if(S?(w||D?h={get:Ut(function(){return at(this)},u,"get"),set:function(d){y[4](this,d)}}:h[C]=at,w||Ut(h[C],u,B?"":C)):w||(h=Object.getOwnPropertyDescriptor(a,u)),!w&&!S){if((l=rt[+m][u])&&(l^c)!==7)throw Error("Decorating two elements with the same name ("+h[C].name+") is not supported yet");rt[+m][u]=c<3?1:c}}for(var g=a,H=J.length-1;H>=0;H-=b?2:1){var ht=A(J[H],"A decorator","be",!0),dt=b?J[H-1]:void 0,z={},F={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(d,L){if(d.v)throw new TypeError("attempted to call addInitializer after decoration was finished");A(L,"An initializer","be",!0),O.push(L)}.bind(null,z)};if(Q)l=ht.call(dt,g,F),z.v=1,A(l,"class decorators","return")&&(g=l);else if(F.static=m,F.private=S,l=F.access={has:S?lt.bind():function(d){return u in d}},ct||(l.get=S?B?function(d){return Y(d),h.value}:j("get",0,Y):function(d){return d[u]}),B||ut||(l.set=S?j("set",0,Y):function(d,L){d[u]=L}),g=ht.call(dt,D?{get:h.get,set:h.set}:h[C],F),z.v=1,D){if(typeof g=="object"&&g)(l=A(g.get,"accessor.get"))&&(h.get=l),(l=A(g.set,"accessor.set"))&&(h.set=l),(l=A(g.init,"accessor.init"))&&Z.unshift(l);else if(g!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else A(g,(w?"field":"method")+" decorators","return")&&(w?Z.unshift(g):h[C]=g)}return c<2&&E.push(M(Z,m,1),M(O,m,0)),w||Q||(S?D?E.splice(-1,0,j("get",m),j("set",m)):E.push(B?h[C]:A.call.bind(h[C])):U(a,u,h)),g}function st(a){return U(a,k,{configurable:!0,enumerable:!0,value:s})}return n!==void 0&&(s=n[k]),s=X(s??null),_=[],T=function(a){a&&_.push(M(a))},V=function(a,y){for(var b=0;b<e.length;b++){var u=e[b],c=u[1],O=7&c;if((8&c)==a&&!O==y){var E=u[2],m=!!u[3],S=16&c;nt(a?i:i.prototype,u,S,m?"#"+E:pe(E),O,O<2?[]:a?I=I||[]:p=p||[],_,!!a,m,y,a&&m?function(w){return fe(w)===i}:o)}}},V(8,0),V(0,0),V(8,1),V(0,1),T(p),T(I),l=_,ot||st(i),{e:l,get c(){var a=[];return ot&&[st(i=nt(i,[t],r,i.name,5,a)),M(a,1)]}}}function pe(i){var t=ge(i,"string");return typeof t=="symbol"?t:t+""}function ge(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 fe(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 Qt,Jt=class extends Yt{static{({e:[Et,Lt,Pt,Dt,Ft,Rt,kt,Mt,Bt,jt,Ht,Kt,qt,Wt,Gt,$t,Tt],c:[Qt,Vt]}=de(this,[me("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"],[ve({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ye({ref:"root"}),0,"rootTarget"],[xe(["value","label","placeholder","disabled","selectionMode","shouldCloseOnSelect"]),2,"onPropsUpdated"],[v({selector:"[data-select-trigger], [data-select-toggle]",type:"click"}),2,"onTriggerClick"],[v({selector:"[data-select-trigger]",type:"keydown",options:{capture:!0}}),2,"onTriggerKeydown"],[v({selector:"[data-select-listbox] [data-autocomplete-input]",type:"keydown",options:{capture:!0}}),2,"onSearchKeydown"],[v({selector:"[data-select-listbox] [data-autocomplete-input]",type:"input"}),2,"onSearchInput"],[v({selector:"[data-select-value] rui-tag-group",type:"rui-remove"}),2,"onTagRemove"],[v({selector:"[data-select-value] [data-tag]",type:"click"}),2,"onTagClick"],[v({selector:'[data-select-listbox] [role="option"]',type:"pointerover"}),2,"onOptionPointerOver"],[v({selector:'[data-select-listbox] [role="option"]',type:"mousedown"}),2,"onOptionMouseDown"],[v({selector:'[data-select-listbox] [role="option"]',type:"click"}),2,"onOptionClick"],[v({ref:"root",type:"focusout"}),2,"onFocusOut"],[v({document:!0,type:"pointerdown"}),2,"onDocumentPointerDown"]],0,void 0,Yt))}constructor(...t){super(...t),$t(this)}value=(Tt(this),Et(this));label=(Lt(this),Pt(this));placeholder=(Dt(this),Ft(this));disabled=(Rt(this),kt(this));selectionMode=(Mt(this),Bt(this));shouldCloseOnSelect=(jt(this),Ht(this));changeEvent=(Kt(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 N(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.setAttribute("data-placeholder","true"),this.placeholder&&(t.textContent=this.placeholder);return}if(t.removeAttribute("data-placeholder"),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.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)}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>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)}render(){return be("div",{class:"rui-select","data-ref":"root",children:[Xt("slot",{name:"trigger"}),Xt("slot",{name:"listbox"})]})}static{Vt()}};import{jsx as f,jsxs as zt}from"@ecopages/jsx/jsx-runtime";function x(...i){return i.filter(Boolean).join(" ")}import{jsx as Zt}from"@ecopages/jsx/jsx-runtime";function it({class:i,size:t="sm",...e}){return Zt("svg",{...e,class:x("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 G}from"@ecopages/jsx/jsx-runtime";function R({value:i,label:t,children:e,class:r,disabled:o,...n}){return G("div",{...n,class:x("rui-listbox__option",r),role:"option","data-value":i,"data-label":t,"aria-disabled":o?"true":void 0,tabindex:-1,children:e})}function $({options:i,children:t,...e}){return i!=null?G("rui-listbox",{...e,children:i.map(r=>G(R,{value:r.value,label:typeof r.label=="string"?r.label:void 0,disabled:r.disabled,children:r.label}))}):G("rui-listbox",{...e,children:t})}function Nt({children:i,slot:t="trigger",class:e,...r}){return f("div",{...r,slot:t,class:x("rui-select__control",e),children:i})}function te({children:i,class:t,disabled:e,...r}){return f("button",{...r,type:"button","data-select-trigger":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:x("rui-select__trigger",t),disabled:e,children:i})}function ee({children:i,class:t,"aria-label":e="Show options",disabled:r,...o}){return f("button",{...o,type:"button","data-select-toggle":!0,class:x("rui-control-toggle",t),"aria-label":e,disabled:r,tabIndex:-1,children:i??f(it,{})})}function ie({children:i,slot:t,class:e,...r}){return f("span",{...r,slot:t,"data-select-value":!0,class:x("rui-select__value",e),children:i})}function re({children:i,slot:t="listbox",class:e,...r}){return f("div",{...r,slot:t,"data-select-listbox":!0,class:x("rui-select__listbox rui-popover rui-popover--listbox rui-floating",e),hidden:!0,children:i})}function Oe({placeholder:i,slot:t="input",class:e,disabled:r,...o}){return f("input",{...o,type:"search",slot:t,"data-autocomplete-input":!0,class:x("rui-select__search",e),placeholder:i,disabled:r,autocomplete:"off"})}var Se=R;function we(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 Ae({options:i,children:t,...e}){if(i!=null){let r=we(i,e.value,e.placeholder),o=!(typeof e.value=="string"&&e.value.trim())&&!!e.placeholder;return zt("rui-select",{...e,children:[zt(Nt,{children:[f(te,{children:f(ie,{...o?{"data-placeholder":!0}:{},children:r})}),f(ee,{})]}),f(re,{children:f($,{embedded:!0,options:i})})]})}return f("rui-select",{...e,children:t})}export{$ as RuiListbox,R as RuiListboxOption,Ae as RuiSelect,Nt as RuiSelectControl,Qt as RuiSelectElement,re as RuiSelectListbox,Se as RuiSelectOption,Oe as RuiSelectSearch,ee as RuiSelectToggle,te as RuiSelectTrigger,ie as RuiSelectValue};
2
2
  //# sourceMappingURL=index.js.map