@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.
Files changed (238) hide show
  1. package/README.md +11 -3
  2. package/dist/components/ui/alert/alert.d.ts +2 -4
  3. package/dist/components/ui/alert/alert.script.d.ts +25 -15
  4. package/dist/components/ui/autocomplete/autocomplete.css +1 -2
  5. package/dist/components/ui/autocomplete/autocomplete.d.ts +8 -3
  6. package/dist/components/ui/autocomplete/autocomplete.script.d.ts +29 -4
  7. package/dist/components/ui/avatar/avatar.css +10 -8
  8. package/dist/components/ui/avatar/avatar.d.ts +3 -1
  9. package/dist/components/ui/breadcrumb/breadcrumb.d.ts +11 -11
  10. package/dist/components/ui/breadcrumb/breadcrumb.script.d.ts +10 -10
  11. package/dist/components/ui/calendar/calendar.css +10 -5
  12. package/dist/components/ui/calendar/calendar.script.d.ts +24 -21
  13. package/dist/components/ui/calendar/index.js +1 -1
  14. package/dist/components/ui/calendar/index.js.map +3 -3
  15. package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
  16. package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
  17. package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
  18. package/dist/components/ui/carousel/carousel.css +71 -18
  19. package/dist/components/ui/carousel/carousel.d.ts +8 -4
  20. package/dist/components/ui/carousel/carousel.script.d.ts +73 -40
  21. package/dist/components/ui/carousel/index.js +1 -1
  22. package/dist/components/ui/carousel/index.js.map +4 -4
  23. package/dist/components/ui/checkbox/checkbox.d.ts +11 -0
  24. package/dist/components/ui/checkbox/checkbox.script.d.ts +31 -8
  25. package/dist/components/ui/checkbox/index.js +1 -1
  26. package/dist/components/ui/checkbox/index.js.map +4 -4
  27. package/dist/components/ui/checkbox-group/checkbox-group.d.ts +4 -2
  28. package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +39 -20
  29. package/dist/components/ui/checkbox-group/index.js +1 -1
  30. package/dist/components/ui/checkbox-group/index.js.map +4 -4
  31. package/dist/components/ui/combobox/combobox.css +9 -1
  32. package/dist/components/ui/combobox/combobox.d.ts +12 -4
  33. package/dist/components/ui/combobox/combobox.script.d.ts +74 -25
  34. package/dist/components/ui/combobox/index.d.ts +2 -2
  35. package/dist/components/ui/combobox/index.js +1 -1
  36. package/dist/components/ui/combobox/index.js.map +4 -4
  37. package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +6 -2
  38. package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +35 -4
  39. package/dist/components/ui/cycle-toggle/index.js +1 -1
  40. package/dist/components/ui/cycle-toggle/index.js.map +3 -3
  41. package/dist/components/ui/date-field/date-field.css +13 -17
  42. package/dist/components/ui/date-field/date-field.d.ts +10 -8
  43. package/dist/components/ui/date-field/date-field.script.d.ts +35 -52
  44. package/dist/components/ui/date-field/index.js +1 -1
  45. package/dist/components/ui/date-field/index.js.map +4 -4
  46. package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
  47. package/dist/components/ui/date-input/date-input.css +50 -0
  48. package/dist/components/ui/date-input/date-input.d.ts +8 -0
  49. package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
  50. package/dist/components/ui/date-input/index.d.ts +2 -0
  51. package/dist/components/ui/date-input/index.js +2 -0
  52. package/dist/components/ui/date-input/index.js.map +7 -0
  53. package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
  54. package/dist/components/ui/date-range-picker/date-range-picker.d.ts +11 -9
  55. package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +42 -51
  56. package/dist/components/ui/date-range-picker/index.js +1 -1
  57. package/dist/components/ui/date-range-picker/index.js.map +4 -4
  58. package/dist/components/ui/dialog/dialog.css +18 -14
  59. package/dist/components/ui/dialog/dialog.d.ts +6 -0
  60. package/dist/components/ui/dialog/dialog.script.d.ts +43 -10
  61. package/dist/components/ui/dialog/index.js +1 -1
  62. package/dist/components/ui/dialog/index.js.map +4 -4
  63. package/dist/components/ui/disclosure/disclosure-group.script.d.ts +19 -3
  64. package/dist/components/ui/disclosure/disclosure.css +3 -6
  65. package/dist/components/ui/disclosure/disclosure.d.ts +23 -7
  66. package/dist/components/ui/disclosure/disclosure.script.d.ts +31 -7
  67. package/dist/components/ui/disclosure/index.d.ts +1 -1
  68. package/dist/components/ui/disclosure/index.js +1 -1
  69. package/dist/components/ui/disclosure/index.js.map +4 -4
  70. package/dist/components/ui/field/field-description.d.ts +1 -0
  71. package/dist/components/ui/field/field-error.d.ts +2 -2
  72. package/dist/components/ui/field/field.d.ts +4 -4
  73. package/dist/components/ui/field/field.script.d.ts +54 -24
  74. package/dist/components/ui/field/index.js +1 -1
  75. package/dist/components/ui/field/index.js.map +4 -4
  76. package/dist/components/ui/form/control-protocol.d.ts +38 -1
  77. package/dist/components/ui/form/form-context.d.ts +3 -0
  78. package/dist/components/ui/form/form.d.ts +6 -0
  79. package/dist/components/ui/form/form.script.d.ts +29 -12
  80. package/dist/components/ui/form/index.d.ts +2 -1
  81. package/dist/components/ui/form/index.js +1 -1
  82. package/dist/components/ui/form/index.js.map +4 -4
  83. package/dist/components/ui/grid/grid.d.ts +4 -3
  84. package/dist/components/ui/grid/grid.script.d.ts +19 -11
  85. package/dist/components/ui/hover-card/hover-card.css +12 -101
  86. package/dist/components/ui/hover-card/hover-card.d.ts +7 -2
  87. package/dist/components/ui/hover-card/hover-card.script.d.ts +36 -5
  88. package/dist/components/ui/hover-card/index.js +1 -1
  89. package/dist/components/ui/hover-card/index.js.map +4 -4
  90. package/dist/components/ui/input/index.js +1 -1
  91. package/dist/components/ui/input/index.js.map +4 -4
  92. package/dist/components/ui/input/input.css +1 -1
  93. package/dist/components/ui/knob/index.js +1 -1
  94. package/dist/components/ui/knob/index.js.map +3 -3
  95. package/dist/components/ui/knob/knob.css +6 -1
  96. package/dist/components/ui/knob/knob.d.ts +4 -4
  97. package/dist/components/ui/knob/knob.script.d.ts +55 -20
  98. package/dist/components/ui/label/index.js +1 -1
  99. package/dist/components/ui/label/index.js.map +4 -4
  100. package/dist/components/ui/label/label.d.ts +2 -1
  101. package/dist/components/ui/listbox/index.d.ts +2 -2
  102. package/dist/components/ui/listbox/index.js +1 -1
  103. package/dist/components/ui/listbox/index.js.map +4 -4
  104. package/dist/components/ui/listbox/listbox.css +14 -0
  105. package/dist/components/ui/listbox/listbox.d.ts +16 -2
  106. package/dist/components/ui/listbox/listbox.script.d.ts +55 -12
  107. package/dist/components/ui/menu-button/index.js +1 -1
  108. package/dist/components/ui/menu-button/index.js.map +4 -4
  109. package/dist/components/ui/menu-button/menu-button.d.ts +2 -2
  110. package/dist/components/ui/menu-button/menu-button.script.d.ts +30 -27
  111. package/dist/components/ui/menubar/index.js +1 -1
  112. package/dist/components/ui/menubar/index.js.map +4 -4
  113. package/dist/components/ui/menubar/menubar.script.d.ts +41 -15
  114. package/dist/components/ui/meter/index.js +1 -1
  115. package/dist/components/ui/meter/index.js.map +3 -3
  116. package/dist/components/ui/meter/meter.css +27 -2
  117. package/dist/components/ui/meter/meter.script.d.ts +19 -14
  118. package/dist/components/ui/navigation-menu/index.d.ts +1 -1
  119. package/dist/components/ui/navigation-menu/index.js +1 -1
  120. package/dist/components/ui/navigation-menu/index.js.map +4 -4
  121. package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
  122. package/dist/components/ui/navigation-menu/navigation-menu.d.ts +34 -5
  123. package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +93 -12
  124. package/dist/components/ui/number-field/index.js +1 -1
  125. package/dist/components/ui/number-field/index.js.map +4 -4
  126. package/dist/components/ui/number-field/number-field.css +1 -1
  127. package/dist/components/ui/number-field/number-field.d.ts +8 -19
  128. package/dist/components/ui/number-field/number-field.script.d.ts +30 -9
  129. package/dist/components/ui/pagination/index.d.ts +1 -1
  130. package/dist/components/ui/pagination/index.js +1 -1
  131. package/dist/components/ui/pagination/index.js.map +3 -3
  132. package/dist/components/ui/pagination/pagination.css +50 -13
  133. package/dist/components/ui/pagination/pagination.d.ts +33 -9
  134. package/dist/components/ui/pagination/pagination.script.d.ts +29 -9
  135. package/dist/components/ui/popover/index.js +1 -1
  136. package/dist/components/ui/popover/index.js.map +4 -4
  137. package/dist/components/ui/popover/popover.d.ts +17 -1
  138. package/dist/components/ui/popover/popover.script.d.ts +57 -9
  139. package/dist/components/ui/radio-group/index.js +1 -1
  140. package/dist/components/ui/radio-group/index.js.map +4 -4
  141. package/dist/components/ui/radio-group/radio-group.d.ts +2 -2
  142. package/dist/components/ui/radio-group/radio-group.script.d.ts +35 -16
  143. package/dist/components/ui/select/index.d.ts +2 -2
  144. package/dist/components/ui/select/index.js +1 -1
  145. package/dist/components/ui/select/index.js.map +4 -4
  146. package/dist/components/ui/select/select.css +8 -6
  147. package/dist/components/ui/select/select.d.ts +18 -9
  148. package/dist/components/ui/select/select.script.d.ts +74 -26
  149. package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
  150. package/dist/components/ui/shared/control-toggle.css +8 -4
  151. package/dist/components/ui/shared/field-label.d.ts +5 -0
  152. package/dist/components/ui/shared/listbox-host-controller.d.ts +41 -0
  153. package/dist/components/ui/shared/listbox-option.d.ts +4 -0
  154. package/dist/components/ui/shared/multi-value.d.ts +23 -1
  155. package/dist/components/ui/shared/numeric-range.d.ts +8 -0
  156. package/dist/components/ui/shared/popover.css +10 -99
  157. package/dist/components/ui/sidebar/index.d.ts +2 -1
  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.d.ts +12 -0
  161. package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +52 -31
  162. package/dist/components/ui/sidebar/sidebar.css +67 -61
  163. package/dist/components/ui/sidebar/sidebar.d.ts +9 -4
  164. package/dist/components/ui/sidebar/sidebar.script.d.ts +42 -20
  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.css +5 -5
  168. package/dist/components/ui/slider/slider.d.ts +20 -10
  169. package/dist/components/ui/slider/slider.script.d.ts +103 -27
  170. package/dist/components/ui/switch/index.js +1 -1
  171. package/dist/components/ui/switch/index.js.map +4 -4
  172. package/dist/components/ui/switch/switch.css +28 -22
  173. package/dist/components/ui/switch/switch.d.ts +13 -0
  174. package/dist/components/ui/switch/switch.script.d.ts +34 -8
  175. package/dist/components/ui/table/index.js +1 -1
  176. package/dist/components/ui/table/index.js.map +4 -4
  177. package/dist/components/ui/table/table.d.ts +9 -7
  178. package/dist/components/ui/table/table.script.d.ts +55 -12
  179. package/dist/components/ui/tabs/tabs.css +18 -12
  180. package/dist/components/ui/tabs/tabs.d.ts +7 -4
  181. package/dist/components/ui/tabs/tabs.script.d.ts +39 -9
  182. package/dist/components/ui/tag-group/index.js +1 -1
  183. package/dist/components/ui/tag-group/index.js.map +4 -4
  184. package/dist/components/ui/tag-group/tag-group.d.ts +19 -7
  185. package/dist/components/ui/tag-group/tag-group.script.d.ts +58 -10
  186. package/dist/components/ui/textarea/index.js +1 -1
  187. package/dist/components/ui/textarea/index.js.map +4 -4
  188. package/dist/components/ui/textarea/textarea.css +1 -1
  189. package/dist/components/ui/toast/index.js +1 -1
  190. package/dist/components/ui/toast/index.js.map +4 -4
  191. package/dist/components/ui/toast/toast.css +35 -32
  192. package/dist/components/ui/toast/toast.script.d.ts +17 -31
  193. package/dist/components/ui/toast/toaster.script.d.ts +24 -12
  194. package/dist/components/ui/toc/toc.script.d.ts +19 -8
  195. package/dist/components/ui/toolbar/toolbar.d.ts +5 -0
  196. package/dist/components/ui/toolbar/toolbar.script.d.ts +24 -4
  197. package/dist/components/ui/tooltip/index.js +1 -1
  198. package/dist/components/ui/tooltip/index.js.map +4 -4
  199. package/dist/components/ui/tooltip/tooltip.css +14 -94
  200. package/dist/components/ui/tooltip/tooltip.d.ts +7 -0
  201. package/dist/components/ui/tooltip/tooltip.script.d.ts +36 -6
  202. package/dist/components/ui/tree/tree.d.ts +4 -3
  203. package/dist/components/ui/tree/tree.script.d.ts +28 -15
  204. package/dist/components/ui/treegrid/treegrid.d.ts +5 -3
  205. package/dist/components/ui/treegrid/treegrid.script.d.ts +33 -14
  206. package/dist/components/ui/window-splitter/index.d.ts +1 -1
  207. package/dist/components/ui/window-splitter/index.js +1 -1
  208. package/dist/components/ui/window-splitter/index.js.map +3 -3
  209. package/dist/components/ui/window-splitter/window-splitter.d.ts +10 -1
  210. package/dist/components/ui/window-splitter/window-splitter.script.d.ts +26 -8
  211. package/dist/index.d.ts +2 -0
  212. package/dist/index.js +1 -1
  213. package/dist/index.js.map +4 -4
  214. package/dist/lib/icons/check.d.ts +3 -0
  215. package/dist/lib/icons/chevron-down.d.ts +0 -1
  216. package/dist/lib/icons/index.d.ts +2 -0
  217. package/dist/lib/icons/x.d.ts +5 -0
  218. package/dist/lib/intl-date/index.d.ts +4 -2
  219. package/dist/lib/intl-date/segment-editing.d.ts +34 -0
  220. package/dist/lib/intl-date/segments.d.ts +26 -4
  221. package/dist/lib/non-empty.d.ts +6 -0
  222. package/dist/lib/unique-id.d.ts +11 -0
  223. package/dist/lib/viewport/breakpoints.d.ts +6 -0
  224. package/dist/lib/viewport/mobile-layout.d.ts +15 -0
  225. package/dist/styles/primitives.css +14 -11
  226. package/dist/styles/radiant-ui-core.css +10 -0
  227. package/dist/styles/radiant-ui.css +40 -11
  228. package/dist/styles/style-dependencies.json +38 -13
  229. package/dist/styles/styles.css +485 -252
  230. package/dist/styles/tailwind.css +40 -101
  231. package/dist/styles/tokens/presets/colors/aurora.css +2 -0
  232. package/dist/styles/tokens/presets/colors/basalt.css +2 -0
  233. package/dist/styles/tokens/presets/colors/ember.css +2 -0
  234. package/dist/styles/tokens/presets/colors/glacier.css +2 -0
  235. package/dist/styles/tokens/semantic.css +1 -0
  236. package/dist/styles/tokens/system.css +11 -3
  237. package/dist/styles/tokens/typography/default.css +8 -0
  238. package/package.json +27 -13
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../../src/components/ui/textarea/textarea.tsx", "../../../../src/lib/cx.ts", "../../../../src/components/ui/form/control-protocol.ts"],
4
- "sourcesContent": ["import { jsx } from \"@ecopages/jsx/jsx-runtime\";\nimport { cx } from \"@/lib/cx\";\nimport { RUI_CONTROL_ATTR } from \"../form/control-protocol\";\nexport function RuiTextarea(props) {\n const {\n class: className,\n rows = 3,\n ...host\n } = props;\n return /* @__PURE__ */jsx(\"textarea\", {\n ...host,\n rows,\n ...{\n [RUI_CONTROL_ATTR]: \"\"\n },\n \"data-rui-control-type\": \"text\",\n class: cx(\"rui-textarea\", className)\n });\n}", "export function cx(...parts) {\n return parts.filter(Boolean).join(\" \");\n}", "export const RUI_CONTROL_ATTR = \"data-rui-control\";\nexport const RUI_FIELD_MANAGED_ATTR = \"data-rui-field-managed\";\nexport const RUI_FIELD_LABEL_ATTR = \"data-rui-field-label\";\nexport const RUI_FIELD_DESCRIPTION_ATTR = \"data-rui-field-description\";\nexport const RUI_FIELD_ERROR_ATTR = \"data-rui-field-error\";\nexport const RUI_FIELD_DEFAULT_VALUE_ATTR = \"data-default-value\";\nexport const RUI_FORM_DEFAULT_VALUES_ATTR = \"data-default-values\";\nconst HOST_CONTROL_TAGS = /* @__PURE__ */new Set([\"rui-combobox\", \"rui-date-field\", \"rui-date-range-picker\", \"rui-select\", \"rui-tag-group\", \"rui-checkbox\", \"rui-checkbox-group\", \"rui-switch\", \"rui-radio-group\", \"rui-slider\", \"rui-knob\", \"rui-number-field\", \"rui-listbox\"]);\nconst CONTROL_SELECTOR = `[${RUI_CONTROL_ATTR}], ${Array.from(HOST_CONTROL_TAGS).join(\", \")}`;\nconst ARIA_TARGET_SELECTORS = {\n \"rui-combobox\": \"[data-combobox-input]\",\n \"rui-date-field\": \"[data-date-field-input]\",\n \"rui-date-range-picker\": \"[data-range-start]\",\n \"rui-select\": \"[data-select-trigger]\",\n \"rui-tag-group\": \"[data-tag-list]\",\n \"rui-number-field\": \"[data-number-field-input], input\",\n \"rui-knob\": \"[data-knob-control]\",\n \"rui-checkbox\": \"input\",\n \"rui-checkbox-group\": \"[data-checkbox-group-root]\",\n \"rui-switch\": \"input\"\n};\nexport function isNativeTextControl(node) {\n return node.localName === \"input\" || node.localName === \"textarea\";\n}\nfunction isNativeInput(node) {\n return node.localName === \"input\";\n}\nfunction isNativeTextarea(node) {\n return node.localName === \"textarea\";\n}\nconst stringValueAdapter = {\n read: host => {\n const value = Reflect.get(host, \"value\");\n return typeof value === \"string\" ? value : host.getAttribute(\"value\") ?? \"\";\n },\n write: (host, value) => {\n const next = value == null ? \"\" : String(value);\n host.setAttribute(\"value\", next);\n if (\"value\" in host) {\n Reflect.set(host, \"value\", next);\n }\n }\n};\nconst numberValueAdapter = {\n read: host => {\n const value = Reflect.get(host, \"value\");\n if (typeof value === \"number\") {\n return value;\n }\n const raw = host.getAttribute(\"value\");\n return raw == null || raw === \"\" ? \"\" : Number(raw);\n },\n write: (host, value) => {\n const next = value == null ? \"\" : String(value);\n host.setAttribute(\"value\", next);\n if (\"value\" in host) {\n Reflect.set(host, \"value\", value);\n }\n }\n};\nconst booleanValueAdapter = {\n read: host => {\n const input = host.querySelector('input[type=\"checkbox\"]');\n return input?.checked ?? host.hasAttribute(\"checked\");\n },\n write: (host, value) => {\n if (value) {\n host.setAttribute(\"checked\", \"\");\n } else {\n host.removeAttribute(\"checked\");\n }\n }\n};\nfunction readNumberProperty(host, property, attribute) {\n const value = Reflect.get(host, property);\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n const raw = host.getAttribute(attribute);\n return raw == null || raw === \"\" ? \"\" : Number(raw);\n}\nfunction isRangeSlider(host) {\n const variant = Reflect.get(host, \"variant\");\n return variant === \"range\" || host.getAttribute(\"variant\") === \"range\";\n}\nconst sliderValueAdapter = {\n read: host => {\n if (isRangeSlider(host)) {\n return [readNumberProperty(host, \"rangeMin\", \"range-min\"), readNumberProperty(host, \"rangeMax\", \"range-max\")];\n }\n return numberValueAdapter.read(host);\n },\n write: (host, value) => {\n if (Array.isArray(value) && value.length >= 2) {\n host.setAttribute(\"variant\", \"range\");\n if (\"variant\" in host) {\n Reflect.set(host, \"variant\", \"range\");\n }\n host.setAttribute(\"range-min\", String(value[0]));\n host.setAttribute(\"range-max\", String(value[1]));\n if (\"rangeMin\" in host) {\n Reflect.set(host, \"rangeMin\", value[0]);\n }\n if (\"rangeMax\" in host) {\n Reflect.set(host, \"rangeMax\", value[1]);\n }\n return;\n }\n numberValueAdapter.write(host, value);\n }\n};\nconst CONTROL_VALUE_ADAPTERS = /* @__PURE__ */new Map([[\"rui-checkbox\", booleanValueAdapter], [\"rui-switch\", booleanValueAdapter], [\"rui-combobox\", stringValueAdapter], [\"rui-date-field\", stringValueAdapter], [\"rui-date-range-picker\", stringValueAdapter], [\"rui-select\", stringValueAdapter], [\"rui-radio-group\", stringValueAdapter], [\"rui-checkbox-group\", stringValueAdapter], [\"rui-listbox\", stringValueAdapter], [\"rui-tag-group\", stringValueAdapter], [\"rui-slider\", sliderValueAdapter], [\"rui-knob\", numberValueAdapter], [\"rui-number-field\", numberValueAdapter]]);\nfunction forEachFieldContentNode(root, visit) {\n const slotHost = root;\n const visited = /* @__PURE__ */new Set();\n const safeVisit = node => {\n if (visited.has(node)) {\n return;\n }\n visited.add(node);\n visit(node);\n };\n if (typeof slotHost.getSlotElements === \"function\") {\n for (const node of slotHost.getSlotElements()) {\n safeVisit(node);\n }\n }\n const renderRoot = root.querySelector(\".rui-field\") ?? root;\n for (const child of Array.from(renderRoot.children)) {\n safeVisit(child);\n }\n for (const node of renderRoot.querySelectorAll(\"*\")) {\n safeVisit(node);\n }\n for (const child of Array.from(root.children)) {\n safeVisit(child);\n }\n const shadow = root.shadowRoot;\n if (shadow) {\n for (const child of Array.from(shadow.children)) {\n safeVisit(child);\n }\n }\n}\nfunction queryFieldContent(root, selector) {\n let found = null;\n forEachFieldContentNode(root, node => {\n if (found || !(node instanceof HTMLElement)) {\n return;\n }\n if (node.matches(selector)) {\n found = node;\n return;\n }\n found = node.querySelector(selector);\n });\n return found;\n}\nfunction pickPrimaryFieldControl(candidates) {\n if (candidates.length === 0) {\n return null;\n }\n if (candidates.length === 1) {\n return candidates[0];\n }\n const hostControl = candidates.find(candidate => HOST_CONTROL_TAGS.has(candidate.localName));\n const markedControl = candidates.find(candidate => candidate.hasAttribute(RUI_CONTROL_ATTR));\n if (markedControl) {\n return markedControl;\n }\n if (hostControl) {\n return hostControl;\n }\n const active = document.activeElement;\n if (active instanceof HTMLElement) {\n for (const candidate of candidates) {\n if (candidate === active || candidate.contains(active)) {\n return candidate;\n }\n }\n }\n const visible = candidates.filter(el => el.isConnected && el.getClientRects().length > 0 && !el.closest('[hidden],[aria-hidden=\"true\"]'));\n const pool = visible.length > 0 ? visible : candidates.filter(el => el.isConnected);\n return pool[pool.length - 1] ?? candidates[candidates.length - 1];\n}\nfunction listFieldControlsInRenderTree(root) {\n const renderRoot = root.querySelector(\".rui-field\");\n if (!(renderRoot instanceof HTMLElement)) {\n return [];\n }\n return Array.from(renderRoot.querySelectorAll(CONTROL_SELECTOR)).filter(el => root.contains(el));\n}\nexport function findFieldControl(root) {\n const fromRenderTree = pickPrimaryFieldControl(listFieldControlsInRenderTree(root));\n if (fromRenderTree) {\n return fromRenderTree;\n }\n let found = null;\n forEachFieldContentNode(root, node => {\n if (found) {\n return;\n }\n const match = findControlInSubtree(node);\n if (match) {\n found = match;\n }\n });\n if (found) {\n return found;\n }\n const renderRoot = root.querySelector(\".rui-field\") ?? root;\n return findControlInSubtree(renderRoot);\n}\nfunction findControlInSubtree(node) {\n if (!(node instanceof HTMLElement)) {\n return null;\n }\n if (node.matches(`[${RUI_CONTROL_ATTR}]`) || HOST_CONTROL_TAGS.has(node.localName)) {\n return node;\n }\n return node.querySelector(CONTROL_SELECTOR);\n}\nexport function readControlValue(control) {\n if (isNativeInput(control)) {\n const host2 = resolveControlHost(control);\n const adapter = host2 === control ? void 0 : CONTROL_VALUE_ADAPTERS.get(host2.localName);\n if (adapter) {\n return adapter.read(host2);\n }\n if (control.type === \"checkbox\") {\n return control.checked;\n }\n if (control.type === \"number\" || control.type === \"range\") {\n return control.value === \"\" ? \"\" : Number(control.value);\n }\n return control.value;\n }\n if (isNativeTextarea(control)) {\n return control.value;\n }\n const host = resolveControlHost(control);\n return CONTROL_VALUE_ADAPTERS.get(host.localName)?.read(host) ?? host.getAttribute(\"value\") ?? \"\";\n}\nexport function writeControlValue(control, value) {\n if (isNativeInput(control)) {\n const host2 = resolveControlHost(control);\n const adapter = host2 === control ? void 0 : CONTROL_VALUE_ADAPTERS.get(host2.localName);\n if (adapter) {\n adapter.write(host2, value);\n return;\n }\n if (control.type === \"checkbox\") {\n control.checked = Boolean(value);\n const ce = control.closest(\"rui-checkbox, rui-switch\");\n if (ce) {\n if (value) {\n ce.setAttribute(\"checked\", \"\");\n } else {\n ce.removeAttribute(\"checked\");\n }\n }\n return;\n }\n control.value = value == null ? \"\" : String(value);\n return;\n }\n if (isNativeTextarea(control)) {\n control.value = value == null ? \"\" : String(value);\n return;\n }\n const host = resolveControlHost(control);\n CONTROL_VALUE_ADAPTERS.get(host.localName)?.write(host, value);\n}\nfunction resolveControlHost(control) {\n if (control.hasAttribute(RUI_CONTROL_ATTR)) {\n const host = control.closest(Array.from(HOST_CONTROL_TAGS).join(\",\"));\n return host ?? control;\n }\n return control;\n}\nexport function findFieldLabel(root) {\n return queryFieldContent(root, `[${RUI_FIELD_LABEL_ATTR}], label.rui-label`);\n}\nexport function findFieldDescription(root) {\n return queryFieldContent(root, `[${RUI_FIELD_DESCRIPTION_ATTR}]`);\n}\nexport function findFieldError(root) {\n const all = findFieldErrorElements(root);\n return all[0] ?? null;\n}\nexport function findFieldErrorElements(root) {\n const renderRoot = root.querySelector(\".rui-field\");\n if (renderRoot instanceof HTMLElement) {\n const inRender = Array.from(renderRoot.querySelectorAll(`[${RUI_FIELD_ERROR_ATTR}]`));\n const visible = inRender.filter(el => el.getClientRects().length > 0);\n if (visible.length > 0) {\n return visible;\n }\n if (inRender.length > 0) {\n return inRender;\n }\n }\n const fromDom = Array.from(root.querySelectorAll(`[${RUI_FIELD_ERROR_ATTR}]`));\n if (fromDom.length > 0) {\n return fromDom;\n }\n const single = queryFieldContent(root, `[${RUI_FIELD_ERROR_ATTR}]`);\n return single ? [single] : [];\n}\nexport function wireFieldControlName(controlHost, ariaTarget, name) {\n if (!name) {\n return;\n }\n if (ariaTarget && isNativeTextControl(ariaTarget)) {\n ariaTarget.name = name;\n }\n if (!controlHost) {\n return;\n }\n if (controlHost === ariaTarget) {\n return;\n }\n if (HOST_CONTROL_TAGS.has(controlHost.localName)) {\n controlHost.setAttribute(\"name\", name);\n }\n}\nfunction isChecked(input) {\n const checked = Reflect.get(input, \"checked\");\n return typeof checked === \"boolean\" ? checked : input.hasAttribute(\"checked\");\n}\nexport function getAriaControlTarget(control) {\n if (isNativeTextControl(control)) {\n return control;\n }\n if (control.hasAttribute(RUI_CONTROL_ATTR)) {\n return control;\n }\n if (control.localName === \"rui-slider\") {\n return control.querySelector(\"[data-thumb]:not([hidden])\") ?? control;\n }\n const marked = control.querySelector(`[${RUI_CONTROL_ATTR}]`);\n if (marked) {\n return marked;\n }\n if (control.localName === \"rui-radio-group\") {\n return getSelectedRadio(control) ?? control;\n }\n const selector = ARIA_TARGET_SELECTORS[control.localName];\n return selector ? control.querySelector(selector) ?? control : control;\n}\nfunction getSelectedRadio(control) {\n const radios = control.querySelectorAll('input[type=\"radio\"]');\n return Array.from(radios).find(isChecked) ?? radios[0];\n}\nexport function getAriaControlTargets(control) {\n if (control.localName === \"rui-slider\") {\n const thumbs = Array.from(control.querySelectorAll(\"[data-thumb]:not([hidden])\"));\n return thumbs.length > 0 ? thumbs : [control];\n }\n return [getAriaControlTarget(control)];\n}"],
5
- "mappings": "AAAA,OAAS,OAAAA,MAAW,4BCAb,SAASC,KAAMC,EAAO,CAC3B,OAAOA,EAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CACvC,CCFO,IAAMC,EAAmB,mBAOhC,IAAMC,EAAmC,IAAI,IAAI,CAAC,eAAgB,iBAAkB,wBAAyB,aAAc,gBAAiB,eAAgB,qBAAsB,aAAc,kBAAmB,aAAc,WAAY,mBAAoB,aAAa,CAAC,EACzQC,EAAmB,IAAIC,CAAgB,MAAM,MAAM,KAAKF,CAAiB,EAAE,KAAK,IAAI,CAAC,GFLpF,SAASG,EAAYC,EAAO,CACjC,GAAM,CACJ,MAAOC,EACP,KAAAC,EAAO,EACP,GAAGC,CACL,EAAIH,EACJ,OAAsBI,EAAI,WAAY,CACpC,GAAGD,EACH,KAAAD,EAEE,CAACG,CAAgB,EAAG,GAEtB,wBAAyB,OACzB,MAAOC,EAAG,eAAgBL,CAAS,CACrC,CAAC,CACH",
6
- "names": ["jsx", "cx", "parts", "RUI_CONTROL_ATTR", "HOST_CONTROL_TAGS", "CONTROL_SELECTOR", "RUI_CONTROL_ATTR", "RuiTextarea", "props", "className", "rows", "host", "jsx", "RUI_CONTROL_ATTR", "cx"]
3
+ "sources": ["../../../../src/components/ui/textarea/textarea.tsx", "../../../../src/lib/cx.ts", "../../../../src/components/ui/shared/multi-value.ts", "../../../../src/components/ui/form/control-protocol.ts"],
4
+ "sourcesContent": ["import { jsx } from \"@ecopages/jsx/jsx-runtime\";\nimport { cx } from \"@/lib/cx\";\nimport { RUI_CONTROL_ATTR } from \"../form/control-protocol\";\nexport function RuiTextarea(props) {\n const {\n class: className,\n rows = 3,\n ...host\n } = props;\n return /* @__PURE__ */jsx(\"textarea\", {\n ...host,\n rows,\n ...{\n [RUI_CONTROL_ATTR]: \"\"\n },\n \"data-rui-control-type\": \"text\",\n class: cx(\"rui-textarea\", className)\n });\n}", "export function cx(...parts) {\n return parts.filter(Boolean).join(\" \");\n}", "export function parseMultiValue(value) {\n if (!value) {\n return [];\n }\n return uniqueTrimmed(value.split(\",\"));\n}\nexport function serializeMultiValue(values) {\n return values.join(\",\");\n}\nexport const multiValueTransform = {\n fromAttribute: value => parseMultiValue(value),\n toAttribute: values => values.length > 0 ? serializeMultiValue(values) : null,\n fromProperty: value => {\n if (Array.isArray(value)) {\n return uniqueTrimmed(value.map(String));\n }\n if (typeof value === \"string\") {\n return parseMultiValue(value);\n }\n return [];\n }\n};\nexport const multiValuePropOptions = {\n type: Array,\n reflect: true,\n transform: multiValueTransform\n};\nexport function parseViewValue(value) {\n return multiValueTransform.fromProperty?.(value) ?? [];\n}\nfunction parseNumberArray(value) {\n if (!value) {\n return [];\n }\n return value.split(\",\").map(item => Number(item.trim())).filter(item => Number.isFinite(item));\n}\nfunction serializeNumberArray(values) {\n return values.join(\",\");\n}\nexport const numberArrayTransform = {\n fromAttribute: value => parseNumberArray(value),\n toAttribute: values => values.length > 0 ? serializeNumberArray(values) : null,\n fromProperty: value => {\n if (Array.isArray(value)) {\n return value.map(Number).filter(item => Number.isFinite(item));\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return [value];\n }\n if (typeof value === \"string\") {\n return parseNumberArray(value);\n }\n return [];\n }\n};\nfunction uniqueTrimmed(values) {\n return [...new Set(values.map(item => item.trim()).filter(Boolean))];\n}", "import { multiValueTransform, numberArrayTransform } from \"../shared/multi-value\";\nexport const RUI_CONTROL_ATTR = \"data-rui-control\";\nexport const RUI_FIELD_MANAGED_ATTR = \"data-rui-field-managed\";\nexport const RUI_FIELD_LABEL_ATTR = \"data-rui-field-label\";\nexport const RUI_FIELD_DESCRIPTION_ATTR = \"data-rui-field-description\";\nexport const RUI_FIELD_ERROR_ATTR = \"data-rui-field-error\";\nexport const RUI_FIELD_DEFAULT_VALUE_ATTR = \"data-default-value\";\nexport const RUI_FORM_DEFAULT_VALUES_ATTR = \"data-default-values\";\nexport const RUI_ARIA_TARGET_ATTR = \"data-rui-aria-target\";\nexport const RUI_ARIA_TARGETS_ATTR = \"data-rui-aria-targets\";\nconst FIELD_COLUMN_SELECTOR = '[data-ref=\"field\"]';\nfunction fieldControlSelector() {\n return `[${RUI_CONTROL_ATTR}], ${hostControlSelector()}`;\n}\nfunction hostControlSelector() {\n return Array.from(CONTROL_VALUE_ADAPTERS.keys()).join(\", \");\n}\nfunction isEmbeddedListbox(node) {\n return node.localName === \"rui-listbox\" && (node.hasAttribute(\"embedded\") || Reflect.get(node, \"embedded\") === true);\n}\nconst ARIA_TARGET_SELECTORS = {\n \"rui-combobox\": \"[data-combobox-input]\",\n \"rui-select\": \"[data-select-trigger]\",\n \"rui-tag-group\": \"[data-tag-list]\",\n \"rui-number-field\": \"[data-number-field-input], input\",\n \"rui-knob\": \"[data-knob-control]\",\n \"rui-checkbox\": \"input\",\n \"rui-checkbox-group\": \"[data-checkbox-group-root]\",\n \"rui-switch\": \"input\"\n};\nexport function isNativeTextControl(node) {\n return node.localName === \"input\" || node.localName === \"textarea\";\n}\nfunction isNativeInput(node) {\n return node.localName === \"input\";\n}\nfunction isNativeTextarea(node) {\n return node.localName === \"textarea\";\n}\nexport function isFormAssociatedHost(host) {\n return Reflect.get(host.constructor, \"formAssociated\") === true;\n}\nconst stringValueAdapter = {\n read: host => {\n const value = Reflect.get(host, \"value\");\n return typeof value === \"string\" ? value : host.getAttribute(\"value\") ?? \"\";\n },\n write: (host, value) => {\n const next = value == null ? \"\" : String(value);\n host.setAttribute(\"value\", next);\n if (\"value\" in host) {\n Reflect.set(host, \"value\", next);\n }\n }\n};\nconst numberValueAdapter = {\n read: host => {\n const value = Reflect.get(host, \"value\");\n if (typeof value === \"number\") {\n return value;\n }\n const raw = host.getAttribute(\"value\");\n return raw == null || raw === \"\" ? \"\" : Number(raw);\n },\n write: (host, value) => {\n const next = value == null ? \"\" : String(value);\n host.setAttribute(\"value\", next);\n if (\"value\" in host) {\n Reflect.set(host, \"value\", value);\n }\n }\n};\nconst booleanValueAdapter = {\n read: host => {\n const input = host.querySelector('input[type=\"checkbox\"]');\n return input?.checked ?? host.hasAttribute(\"checked\");\n },\n write: (host, value) => {\n if (value) {\n host.setAttribute(\"checked\", \"\");\n } else {\n host.removeAttribute(\"checked\");\n }\n }\n};\nfunction readHostValue(host, transform) {\n const value = Reflect.get(host, \"value\");\n if (value !== void 0 && transform.fromProperty) {\n return transform.fromProperty(value);\n }\n if (transform.fromAttribute) {\n return transform.fromAttribute(host.getAttribute(\"value\"));\n }\n return value;\n}\nfunction writeHostValue(host, value) {\n Reflect.set(host, \"value\", value);\n}\nconst stringArrayValueAdapter = {\n read: host => readHostValue(host, multiValueTransform),\n write: writeHostValue\n};\nconst sliderValueAdapter = {\n read: host => readHostValue(host, numberArrayTransform),\n write: writeHostValue\n};\nconst CONTROL_VALUE_ADAPTERS = /* @__PURE__ */new Map([[\"rui-checkbox\", booleanValueAdapter], [\"rui-switch\", booleanValueAdapter], [\"rui-combobox\", {\n ...stringArrayValueAdapter,\n submission: \"none\"\n}], [\"rui-date-field\", stringValueAdapter], [\"rui-date-input\", {\n ...stringValueAdapter,\n submission: \"host\"\n}], [\"rui-date-range-picker\", stringValueAdapter], [\"rui-select\", {\n ...stringArrayValueAdapter,\n submission: \"none\"\n}], [\"rui-radio-group\", stringValueAdapter], [\"rui-checkbox-group\", stringArrayValueAdapter], [\"rui-listbox\", stringArrayValueAdapter], [\"rui-tag-group\", stringArrayValueAdapter], [\"rui-slider\", {\n ...sliderValueAdapter,\n submission: \"host\"\n}], [\"rui-knob\", {\n ...numberValueAdapter,\n submission: \"host\"\n}], [\"rui-number-field\", {\n ...numberValueAdapter,\n submission: \"host\"\n}]]);\nfunction forEachFieldContentNode(root, visit) {\n const slotHost = root;\n const visited = /* @__PURE__ */new Set();\n const safeVisit = node => {\n if (visited.has(node)) {\n return;\n }\n visited.add(node);\n visit(node);\n };\n if (typeof slotHost.getSlotElements === \"function\") {\n for (const node of slotHost.getSlotElements()) {\n safeVisit(node);\n }\n }\n const renderRoot = root.querySelector(FIELD_COLUMN_SELECTOR) ?? root;\n for (const child of Array.from(renderRoot.children)) {\n safeVisit(child);\n }\n for (const node of renderRoot.querySelectorAll(\"*\")) {\n safeVisit(node);\n }\n for (const child of Array.from(root.children)) {\n safeVisit(child);\n }\n const shadow = root.shadowRoot;\n if (shadow) {\n for (const child of Array.from(shadow.children)) {\n safeVisit(child);\n }\n }\n}\nfunction queryFieldContent(root, selector) {\n let found = null;\n forEachFieldContentNode(root, node => {\n if (found || !(node instanceof HTMLElement)) {\n return;\n }\n if (node.matches(selector)) {\n found = node;\n return;\n }\n found = node.querySelector(selector);\n });\n return found;\n}\nfunction pickPrimaryFieldControl(candidates) {\n const eligibleCandidates = candidates.filter(candidate => !isEmbeddedListbox(candidate));\n if (eligibleCandidates.length === 0) {\n return null;\n }\n return eligibleCandidates.find(candidate => !eligibleCandidates.some(ancestor => ancestor !== candidate && ancestor.contains(candidate))) ?? null;\n}\nfunction collectFieldControls(root) {\n const candidates = [];\n forEachFieldContentNode(root, node => {\n if (node instanceof HTMLElement && node.matches(fieldControlSelector())) {\n candidates.push(node);\n }\n });\n return candidates;\n}\nfunction listFieldControlsInRenderTree(root) {\n const renderRoot = root.querySelector(FIELD_COLUMN_SELECTOR);\n if (!(renderRoot instanceof HTMLElement)) {\n return [];\n }\n return Array.from(renderRoot.querySelectorAll(fieldControlSelector())).filter(el => root.contains(el));\n}\nexport function findFieldControl(root) {\n const fromRenderTree = pickPrimaryFieldControl(listFieldControlsInRenderTree(root));\n if (fromRenderTree) {\n return fromRenderTree;\n }\n return pickPrimaryFieldControl(collectFieldControls(root));\n}\nexport function registerFieldControl(tagName, adapter) {\n const tag = tagName.toLowerCase();\n CONTROL_VALUE_ADAPTERS.set(tag, adapter);\n}\nexport function isPrimaryFieldControlEvent(root, event) {\n const control = findFieldControl(root);\n if (!control || !(event.target instanceof Element)) {\n return false;\n }\n if (event.target !== control && !control.contains(event.target)) {\n return false;\n }\n const nestedHost = event.target.closest(hostControlSelector());\n return nestedHost === control || nestedHost == null;\n}\nexport function readControlValue(control) {\n if (isNativeInput(control)) {\n const host2 = resolveControlHost(control);\n const adapter = host2 === control ? void 0 : CONTROL_VALUE_ADAPTERS.get(host2.localName);\n if (adapter) {\n return adapter.read(host2);\n }\n if (control.type === \"checkbox\") {\n return control.checked;\n }\n if (control.type === \"number\" || control.type === \"range\") {\n return control.value === \"\" ? \"\" : Number(control.value);\n }\n return control.value;\n }\n if (isNativeTextarea(control)) {\n return control.value;\n }\n const host = resolveControlHost(control);\n return CONTROL_VALUE_ADAPTERS.get(host.localName)?.read(host) ?? host.getAttribute(\"value\") ?? \"\";\n}\nexport function writeControlValue(control, value) {\n if (isNativeInput(control)) {\n const host2 = resolveControlHost(control);\n const adapter = host2 === control ? void 0 : CONTROL_VALUE_ADAPTERS.get(host2.localName);\n if (adapter) {\n adapter.write(host2, value);\n return;\n }\n if (control.type === \"checkbox\") {\n control.checked = Boolean(value);\n const ce = control.closest(\"rui-checkbox, rui-switch\");\n if (ce) {\n if (value) {\n ce.setAttribute(\"checked\", \"\");\n } else {\n ce.removeAttribute(\"checked\");\n }\n }\n return;\n }\n control.value = value == null ? \"\" : String(value);\n return;\n }\n if (isNativeTextarea(control)) {\n control.value = value == null ? \"\" : String(value);\n return;\n }\n const host = resolveControlHost(control);\n CONTROL_VALUE_ADAPTERS.get(host.localName)?.write(host, value);\n}\nfunction resolveControlHost(control) {\n if (control.hasAttribute(RUI_CONTROL_ATTR)) {\n const host = control.closest(hostControlSelector());\n return host ?? control;\n }\n return control;\n}\nexport function findFieldLabel(root) {\n return queryFieldContent(root, `[${RUI_FIELD_LABEL_ATTR}]`);\n}\nexport function findFieldDescription(root) {\n return queryFieldContent(root, `[${RUI_FIELD_DESCRIPTION_ATTR}]`);\n}\nexport function findFieldError(root) {\n const all = findFieldErrorElements(root);\n return all[0] ?? null;\n}\nexport function findFieldErrorElements(root) {\n const renderRoot = root.querySelector(FIELD_COLUMN_SELECTOR);\n if (renderRoot instanceof HTMLElement) {\n const inRender = Array.from(renderRoot.querySelectorAll(`[${RUI_FIELD_ERROR_ATTR}]`));\n if (inRender.length > 0) {\n return inRender;\n }\n }\n const fromDom = Array.from(root.querySelectorAll(`[${RUI_FIELD_ERROR_ATTR}]`));\n if (fromDom.length > 0) {\n return fromDom;\n }\n const single = queryFieldContent(root, `[${RUI_FIELD_ERROR_ATTR}]`);\n return single ? [single] : [];\n}\nexport function wireFieldControlName(controlHost, ariaTarget, name) {\n if (ariaTarget && isNativeTextControl(ariaTarget)) {\n const submission = controlHost && CONTROL_VALUE_ADAPTERS.get(controlHost.localName)?.submission;\n const namesInner = controlHost == null || controlHost === ariaTarget || !isFormAssociatedHost(controlHost) && submission !== \"host\" && submission !== \"none\";\n if (namesInner && name) {\n ariaTarget.name = name;\n } else {\n ariaTarget.removeAttribute(\"name\");\n }\n }\n if (controlHost && CONTROL_VALUE_ADAPTERS.has(controlHost.localName)) {\n Reflect.set(controlHost, \"name\", name);\n if (name) controlHost.setAttribute(\"name\", name);else controlHost.removeAttribute(\"name\");\n }\n}\nfunction isChecked(input) {\n const checked = Reflect.get(input, \"checked\");\n return typeof checked === \"boolean\" ? checked : input.hasAttribute(\"checked\");\n}\nfunction resolveDeclaredAriaTarget(control) {\n const multi = control.getAttribute(RUI_ARIA_TARGETS_ATTR);\n if (multi) {\n const firstSelector = multi.split(\",\")[0]?.trim();\n if (firstSelector) {\n return control.querySelector(firstSelector);\n }\n }\n const single = control.getAttribute(RUI_ARIA_TARGET_ATTR);\n if (single) {\n return control.querySelector(single);\n }\n return null;\n}\nfunction resolveDeclaredAriaTargets(control) {\n const multi = control.getAttribute(RUI_ARIA_TARGETS_ATTR);\n if (multi) {\n return multi.split(\",\").map(selector => selector.trim()).filter(selector => selector !== \"\").map(selector => control.querySelector(selector)).filter(node => node != null);\n }\n const single = control.getAttribute(RUI_ARIA_TARGET_ATTR);\n if (single) {\n const target = control.querySelector(single);\n return target ? [target] : [];\n }\n return [];\n}\nexport function getAriaControlTarget(control) {\n if (isNativeTextControl(control)) {\n return control;\n }\n const declared = resolveDeclaredAriaTarget(control);\n if (declared) {\n return declared;\n }\n if (control.hasAttribute(RUI_CONTROL_ATTR)) {\n return control;\n }\n if (control.localName === \"rui-slider\") {\n const thumb = Array.from(control.querySelectorAll(\"[data-thumb]\")).find(node => !node.hasAttribute(\"hidden\"));\n return thumb ?? control;\n }\n const marked = control.querySelector(`[${RUI_CONTROL_ATTR}]`);\n if (marked) {\n return marked;\n }\n if (control.localName === \"rui-radio-group\") {\n return getSelectedRadio(control) ?? control;\n }\n const selector = ARIA_TARGET_SELECTORS[control.localName];\n return selector ? control.querySelector(selector) ?? control : control;\n}\nfunction getSelectedRadio(control) {\n const radios = control.querySelectorAll('input[type=\"radio\"]');\n return Array.from(radios).find(isChecked) ?? radios[0];\n}\nexport function getAriaControlTargets(control) {\n const declared = resolveDeclaredAriaTargets(control);\n if (declared.length > 0) {\n return declared;\n }\n if (control.localName === \"rui-slider\") {\n const thumbs = Array.from(control.querySelectorAll(\"[data-thumb]\")).filter(node => !node.hasAttribute(\"hidden\"));\n return thumbs.length > 0 ? thumbs : [control];\n }\n return [getAriaControlTarget(control)];\n}"],
5
+ "mappings": "AAAA,OAAS,OAAAA,MAAW,4BCAb,SAASC,KAAMC,EAAO,CAC3B,OAAOA,EAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CACvC,CCFO,SAASC,EAAgBC,EAAO,CACrC,OAAKA,EAGEC,EAAcD,EAAM,MAAM,GAAG,CAAC,EAF5B,CAAC,CAGZ,CACO,SAASE,EAAoBC,EAAQ,CAC1C,OAAOA,EAAO,KAAK,GAAG,CACxB,CACO,IAAMC,EAAsB,CACjC,cAAeJ,GAASD,EAAgBC,CAAK,EAC7C,YAAaG,GAAUA,EAAO,OAAS,EAAID,EAAoBC,CAAM,EAAI,KACzE,aAAcH,GACR,MAAM,QAAQA,CAAK,EACdC,EAAcD,EAAM,IAAI,MAAM,CAAC,EAEpC,OAAOA,GAAU,SACZD,EAAgBC,CAAK,EAEvB,CAAC,CAEZ,EASA,SAASK,EAAiBC,EAAO,CAC/B,OAAKA,EAGEA,EAAM,MAAM,GAAG,EAAE,IAAIC,GAAQ,OAAOA,EAAK,KAAK,CAAC,CAAC,EAAE,OAAOA,GAAQ,OAAO,SAASA,CAAI,CAAC,EAFpF,CAAC,CAGZ,CACA,SAASC,EAAqBC,EAAQ,CACpC,OAAOA,EAAO,KAAK,GAAG,CACxB,CACO,IAAMC,EAAuB,CAClC,cAAeJ,GAASD,EAAiBC,CAAK,EAC9C,YAAaG,GAAUA,EAAO,OAAS,EAAID,EAAqBC,CAAM,EAAI,KAC1E,aAAcH,GACR,MAAM,QAAQA,CAAK,EACdA,EAAM,IAAI,MAAM,EAAE,OAAOC,GAAQ,OAAO,SAASA,CAAI,CAAC,EAE3D,OAAOD,GAAU,UAAY,OAAO,SAASA,CAAK,EAC7C,CAACA,CAAK,EAEX,OAAOA,GAAU,SACZD,EAAiBC,CAAK,EAExB,CAAC,CAEZ,EACA,SAASK,EAAcF,EAAQ,CAC7B,MAAO,CAAC,GAAG,IAAI,IAAIA,EAAO,IAAIF,GAAQA,EAAK,KAAK,CAAC,EAAE,OAAO,OAAO,CAAC,CAAC,CACrE,CCxDO,IAAMK,EAAmB,mBAyChC,IAAMC,EAAqB,CACzB,KAAMC,GAAQ,CACZ,IAAMC,EAAQ,QAAQ,IAAID,EAAM,OAAO,EACvC,OAAO,OAAOC,GAAU,SAAWA,EAAQD,EAAK,aAAa,OAAO,GAAK,EAC3E,EACA,MAAO,CAACA,EAAMC,IAAU,CACtB,IAAMC,EAAOD,GAAS,KAAO,GAAK,OAAOA,CAAK,EAC9CD,EAAK,aAAa,QAASE,CAAI,EAC3B,UAAWF,GACb,QAAQ,IAAIA,EAAM,QAASE,CAAI,CAEnC,CACF,EACMC,EAAqB,CACzB,KAAMH,GAAQ,CACZ,IAAMC,EAAQ,QAAQ,IAAID,EAAM,OAAO,EACvC,GAAI,OAAOC,GAAU,SACnB,OAAOA,EAET,IAAMG,EAAMJ,EAAK,aAAa,OAAO,EACrC,OAAOI,GAAO,MAAQA,IAAQ,GAAK,GAAK,OAAOA,CAAG,CACpD,EACA,MAAO,CAACJ,EAAMC,IAAU,CACtB,IAAMC,EAAOD,GAAS,KAAO,GAAK,OAAOA,CAAK,EAC9CD,EAAK,aAAa,QAASE,CAAI,EAC3B,UAAWF,GACb,QAAQ,IAAIA,EAAM,QAASC,CAAK,CAEpC,CACF,EACMI,EAAsB,CAC1B,KAAML,GACUA,EAAK,cAAc,wBAAwB,GAC3C,SAAWA,EAAK,aAAa,SAAS,EAEtD,MAAO,CAACA,EAAMC,IAAU,CAClBA,EACFD,EAAK,aAAa,UAAW,EAAE,EAE/BA,EAAK,gBAAgB,SAAS,CAElC,CACF,EACA,SAASM,EAAcN,EAAMO,EAAW,CACtC,IAAMN,EAAQ,QAAQ,IAAID,EAAM,OAAO,EACvC,OAAIC,IAAU,QAAUM,EAAU,aACzBA,EAAU,aAAaN,CAAK,EAEjCM,EAAU,cACLA,EAAU,cAAcP,EAAK,aAAa,OAAO,CAAC,EAEpDC,CACT,CACA,SAASO,EAAeR,EAAMC,EAAO,CACnC,QAAQ,IAAID,EAAM,QAASC,CAAK,CAClC,CACA,IAAMQ,EAA0B,CAC9B,KAAMT,GAAQM,EAAcN,EAAMU,CAAmB,EACrD,MAAOF,CACT,EACMG,EAAqB,CACzB,KAAMX,GAAQM,EAAcN,EAAMY,CAAoB,EACtD,MAAOJ,CACT,EACMK,EAAwC,IAAI,IAAI,CAAC,CAAC,eAAgBR,CAAmB,EAAG,CAAC,aAAcA,CAAmB,EAAG,CAAC,eAAgB,CAClJ,GAAGI,EACH,WAAY,MACd,CAAC,EAAG,CAAC,iBAAkBV,CAAkB,EAAG,CAAC,iBAAkB,CAC7D,GAAGA,EACH,WAAY,MACd,CAAC,EAAG,CAAC,wBAAyBA,CAAkB,EAAG,CAAC,aAAc,CAChE,GAAGU,EACH,WAAY,MACd,CAAC,EAAG,CAAC,kBAAmBV,CAAkB,EAAG,CAAC,qBAAsBU,CAAuB,EAAG,CAAC,cAAeA,CAAuB,EAAG,CAAC,gBAAiBA,CAAuB,EAAG,CAAC,aAAc,CACjM,GAAGE,EACH,WAAY,MACd,CAAC,EAAG,CAAC,WAAY,CACf,GAAGR,EACH,WAAY,MACd,CAAC,EAAG,CAAC,mBAAoB,CACvB,GAAGA,EACH,WAAY,MACd,CAAC,CAAC,CAAC,EHzHI,SAASW,EAAYC,EAAO,CACjC,GAAM,CACJ,MAAOC,EACP,KAAAC,EAAO,EACP,GAAGC,CACL,EAAIH,EACJ,OAAsBI,EAAI,WAAY,CACpC,GAAGD,EACH,KAAAD,EAEE,CAACG,CAAgB,EAAG,GAEtB,wBAAyB,OACzB,MAAOC,EAAG,eAAgBL,CAAS,CACrC,CAAC,CACH",
6
+ "names": ["jsx", "cx", "parts", "parseMultiValue", "value", "uniqueTrimmed", "serializeMultiValue", "values", "multiValueTransform", "parseNumberArray", "value", "item", "serializeNumberArray", "values", "numberArrayTransform", "uniqueTrimmed", "RUI_CONTROL_ATTR", "stringValueAdapter", "host", "value", "next", "numberValueAdapter", "raw", "booleanValueAdapter", "readHostValue", "transform", "writeHostValue", "stringArrayValueAdapter", "multiValueTransform", "sliderValueAdapter", "numberArrayTransform", "CONTROL_VALUE_ADAPTERS", "RuiTextarea", "props", "className", "rows", "host", "jsx", "RUI_CONTROL_ATTR", "cx"]
7
7
  }
@@ -14,7 +14,7 @@
14
14
  border-radius: var(--radius-control);
15
15
  padding-inline: var(--space-control-x);
16
16
  padding-block: var(--space-control-y);
17
- font-size: var(--text-control, 0.875rem);
17
+ font-size: var(--text-control-input);
18
18
  min-height: calc(var(--space-control-y) * 2 + 1.25rem * 3);
19
19
  transition-duration: var(--duration-normal);
20
20
  }
@@ -1,2 +1,2 @@
1
- import{jsx as X,jsxs as te}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as ee,bound as xt,customElement as Fe,onEvent as ie,onUpdated as wt,prop as R,query as $e}from"@ecopages/radiant";var at="rui-toast-show",lt="rui-toast-dismiss",Ve=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"],ut=4e3,yt=356,vt=14,Tt=24,bt=3,gt=3,ct=45,St=200,ht="bottom-end";function K(i){let[t,e]=i.split("-");return{y:t,x:e}}var ke=1;function Ce(){return ke++}function Pt(i,t){return typeof i=="function"?i(t):i}var _t=class{subscribers=[];toasts=[];subscribe=t=>(this.subscribers.push(t),t(this.toasts),()=>{let e=this.subscribers.indexOf(t);e>=0&&this.subscribers.splice(e,1)});getSnapshot=()=>this.toasts;publish(){let t=this.toasts;for(let e of this.subscribers)e(t)}create=(t,e={})=>{let s=e.id??Ce(),a=e.dismissible??!0,h=this.toasts.findIndex(o=>o.id===s),p={id:s,title:t,description:e.description,variant:e.variant??"default",duration:e.duration,action:e.action,dismissible:a,closeButton:e.closeButton,position:e.position,delete:!1};return h>=0?this.toasts=this.toasts.map(o=>o.id===s?{...o,...p,delete:!1}:o):this.toasts=[p,...this.toasts],this.publish(),s};dismiss=t=>{if(t==null){if(this.toasts.length===0)return;this.toasts=this.toasts.map(e=>({...e,delete:!0}))}else{let e=this.toasts.find(s=>s.id===t);if(!e||e.delete)return;this.toasts=this.toasts.map(s=>s.id===t?{...s,delete:!0}:s)}this.publish()};remove=t=>{this.toasts=this.toasts.filter(e=>e.id!==t),this.publish()};clear=()=>{this.toasts.length!==0&&(this.toasts=[],this.publish())};message=(t,e)=>this.create(t,e);success=(t,e)=>this.create(t,{...e,variant:"success"});error=(t,e)=>this.create(t,{...e,variant:"error"});info=(t,e)=>this.create(t,{...e,variant:"info"});warning=(t,e)=>this.create(t,{...e,variant:"warning"});loading=(t,e)=>this.create(t,{...e,variant:"loading",duration:e?.duration??Number.POSITIVE_INFINITY});promise=(t,e)=>{let s=this.loading(e.loading,{duration:Number.POSITIVE_INFINITY,action:e.action,closeButton:e.closeButton,position:e.position,description:typeof e.description=="string"?e.description:void 0});return(typeof t=="function"?t():t).then(h=>{let p=typeof e.description=="function"?e.description(h):e.description;this.create(Pt(e.success,h),{id:s,variant:"success",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}).catch(h=>{let p=typeof e.description=="function"?e.description(h):e.description;this.create(Pt(e.error,h),{id:s,variant:"error",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}),s}},g=new _t;var Dt,At,Lt,Rt,Mt,Vt,kt,Ct,Ut,Bt,jt,Ht,Ft,$t,Nt,qt,Wt,Yt,zt,Kt,Xt,Gt,Jt,Qt;function Ue(i,t,e,s,a,h){var p,o,I,M,f,u,E,j=Symbol.metadata||Symbol.for("Symbol.metadata"),H=Object.defineProperty,L=Object.create,$=[L(null),L(null)],G=t.length;function V(n,T,y){return function(r,l){T&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,T,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(T+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,T,y,r,l,b,O,v,S,_,Z){function N(d){if(!Z(d))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(T[0]),tt=T[3],W=!O,D=l===1,et=l===3,it=l===4,k=l===2;function C(d,P,ot){return function(B,rt){return P&&(rt=B,B=n),ot&&ot(B),c[d].call(B,rt)}}if(!W){var c={},Y=[],w=et?"get":it||D?"set":"value";if(S?(_||D?c={get:Zt(function(){return tt(this)},r,"get"),set:function(d){T[4](this,d)}}:c[w]=tt,_||Zt(c[w],r,k?"":w)):_||(c=Object.getOwnPropertyDescriptor(n,r)),!_&&!S){if((o=$[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");$[+v][r]=l<3?1:l}}for(var m=n,U=q.length-1;U>=0;U-=y?2:1){var st=x(q[U],"A decorator","be",!0),nt=y?q[U-1]:void 0,z={},A={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(d,P){if(d.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,z)};if(W)o=st.call(nt,m,A),z.v=1,x(o,"class decorators","return")&&(m=o);else if(A.static=v,A.private=S,o=A.access={has:S?Z.bind():function(d){return r in d}},it||(o.get=S?k?function(d){return N(d),c.value}:C("get",0,N):function(d){return d[r]}),k||et||(o.set=S?C("set",0,N):function(d,P){d[r]=P}),m=st.call(nt,D?{get:c.get,set:c.set}:c[w],A),z.v=1,D){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&Y.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(_?"field":"method")+" decorators","return")&&(_?Y.unshift(m):c[w]=m)}return l<2&&O.push(V(Y,v,1),V(b,v,0)),_||W||(S?D?O.splice(-1,0,C("get",v),C("set",v)):O.push(k?c[w]:x.call.bind(c[w])):H(n,r,c)),m}function Q(n){return H(n,j,{configurable:!0,enumerable:!0,value:p})}return h!==void 0&&(p=h[j]),p=L(p??null),f=[],u=function(n){n&&f.push(V(n))},E=function(n,T){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==T){var O=r[2],v=!!r[3],S=16&l;J(n?i:i.prototype,r,S,v?"#"+O:Be(O),b,b<2?[]:n?M=M||[]:I=I||[],f,!!n,v,T,n&&v?function(_){return He(_)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(M),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),V(n,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 s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Zt(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 He(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 dt=new Map,ft=new Map;function It(i){return String(i)}function pt(i){if(i==="")return;let t=It(i);dt.delete(t),ft.delete(t)}function Ne(i){if(i==="")return;let t=It(i),e=dt.get(t);e!=null&&(ft.set(t,Math.max(0,e-Date.now())),dt.delete(t))}var ne,se=class extends ee{static{({e:[Lt,Rt,Mt,Vt,kt,Ct,Ut,Bt,jt,Ht,Ft,$t,Nt,qt,Wt,Yt,zt,Kt,Xt,Gt,Jt,Qt,Dt],c:[ne,At]}=Ue(this,[Fe("rui-toast")],[[R({type:String,reflect:!0,defaultValue:""}),0,"toastId"],[R({type:String,defaultValue:""}),0,"title"],[R({type:String,defaultValue:""}),0,"description"],[R({type:String,reflect:!0,defaultValue:"default"}),0,"variant"],[R({type:Number,defaultValue:4e3}),0,"duration"],[R({type:Boolean,defaultValue:!0}),0,"dismissible"],[R({type:Boolean,defaultValue:!1}),0,"closeButton"],[R({type:String,defaultValue:""}),0,"actionLabel"],[R({type:String,defaultValue:ht}),0,"position"],[R({type:Boolean,defaultValue:!1}),0,"markedDelete"],[$e({ref:"toast"}),0,"toastTarget"],[wt("position"),2,"onPositionUpdated"],[wt("duration"),2,"onDurationUpdated"],[wt("markedDelete"),2,"onMarkedDeleteUpdated"],[xt,2,"onPointerDown"],[xt,2,"onPointerMove"],[xt,2,"onPointerUp"],[ie({selector:"[data-toast-close]",type:"click"}),2,"onCloseClick"],[ie({selector:"[data-toast-action]",type:"click"}),2,"onActionClick"]],0,void 0,ee))}toastId=(Dt(this),Lt(this));title=(Rt(this),Mt(this));description=(Vt(this),kt(this));variant=(Ct(this),Ut(this));duration=(Bt(this),jt(this));dismissible=(Ht(this),Ft(this));closeButton=($t(this),Nt(this));actionLabel=(qt(this),Wt(this));position=(Yt(this),zt(this));markedDelete=(Kt(this),Xt(this));toastTarget=(Gt(this),Jt(this));mounted=(Qt(this),!1);removed=!1;swiping=!1;swipeOut=!1;swipeAxis=null;swipeOutDirection=null;held=!1;timerReady=!1;timeoutId=null;pointerStart=null;dragStartTime=null;exitTimer=null;connectedCallback(){super.connectedCallback();let t=this.mounted;if(this.addEventListener("pointerdown",this.onPointerDown),this.addEventListener("pointermove",this.onPointerMove),this.addEventListener("pointerup",this.onPointerUp),this.addEventListener("pointercancel",this.onPointerUp),t){this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer();return}this.timerReady=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.isConnected&&(this.mounted=!0,this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer())})}),this.syncDomState()}disconnectedCallback(){this.clearTimer(),this.exitTimer&&(clearTimeout(this.exitTimer),this.exitTimer=null);let t=this.resolvedId;t!==""&&this.removed&&g.remove(t),this.held=!1,this.timerReady=!1,this.removeEventListener("pointerdown",this.onPointerDown),this.removeEventListener("pointermove",this.onPointerMove),this.removeEventListener("pointerup",this.onPointerUp),this.removeEventListener("pointercancel",this.onPointerUp),super.disconnectedCallback()}onPositionUpdated(){this.syncDomState()}setPaused(t){if(this.held===t){!t&&this.timerReady&&this.mounted&&!this.removed&&!this.timeoutId&&this.startTimer();return}this.held=t,!(!this.timerReady||!this.mounted||this.removed)&&(t||document.hidden?(Ne(this.resolvedId),this.clearTimer()):this.startTimer())}onDurationUpdated(){!this.timerReady||!this.mounted||this.removed||this.held||(pt(this.resolvedId),this.startTimer())}onMarkedDeleteUpdated(){this.markedDelete&&!this.removed&&this.beginRemove()}get resolvedId(){let t=this.toastId;if(t==null||t==="")return"";let e=Number(t);return Number.isFinite(e)&&String(e)===t?e:t}clearTimer(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=null}startTimer(){if(this.held||this.removed||document.hidden||this.duration===Number.POSITIVE_INFINITY||this.variant==="loading")return;if(this.duration<=0){this.beginRemove();return}let t=this.resolvedId,e=It(t),s=Date.now(),a=ft.get(e);if(ft.delete(e),a==null){let h=dt.get(e);a=h!=null?h-s:this.duration}if(a<=0){pt(t),this.beginRemove();return}dt.set(e,s+a),this.clearTimer(),this.timeoutId=setTimeout(()=>{pt(t),this.beginRemove()},a)}beginRemove(){this.removed||(this.removed=!0,this.clearTimer(),pt(this.resolvedId),this.syncDomState(),this.markedDelete||g.dismiss(this.resolvedId),this.exitTimer=setTimeout(()=>{this.exitTimer=null,g.remove(this.resolvedId)},200))}onPointerDown(t){!this.dismissible||this.variant==="loading"||t.button!==0||t.target?.closest("[data-toast-close], [data-toast-action], button, a")||(this.dragStartTime=Date.now(),this.pointerStart={x:t.clientX,y:t.clientY},this.swipeAxis=null,this.setPointerCapture(t.pointerId))}onPointerMove(t){if(!this.pointerStart)return;let e={x:t.clientX-this.pointerStart.x,y:t.clientY-this.pointerStart.y};if(!this.startSwipe(e))return;this.swipeAxis??=Math.abs(e.x)>Math.abs(e.y)?"x":"y";let s=this.swipeAxis==="x"?{x:e.x,y:0}:{x:0,y:e.y};this.isSwipeReversing(s)?this.resetSwipeTranslation():this.setSwipeTranslation(s)}startSwipe(t){return this.swiping?!0:Math.abs(t.x)<8&&Math.abs(t.y)<8?!1:(this.swiping=!0,this.syncDomState(),!0)}isSwipeReversing(t){let{x:e,y:s}=K(this.position);return this.swipeAxis==="y"?(s==="bottom"?t.y<0:t.y>0)&&Math.abs(t.y)<45:e!=="center"&&(e==="start"?t.x>0:t.x<0)&&Math.abs(t.x)<45}setSwipeTranslation(t){this.style.setProperty("--swipe-amount-x",`${t.x}px`),this.style.setProperty("--swipe-amount-y",`${t.y}px`)}resetSwipeTranslation(){this.setSwipeTranslation({x:0,y:0})}onPointerUp(t){if(!this.pointerStart)return;this.releaseToastPointer(t.pointerId);let e=this.readSwipe();this.swiping=!1,e&&this.dismissible&&this.shouldDismissSwipe(e)?this.dismissFromSwipe(e):this.cancelSwipe(),this.clearPointerState()}releaseToastPointer(t){try{this.releasePointerCapture(t)}catch{}}readSwipe(){if(this.swiping)return{x:Number.parseFloat(this.style.getPropertyValue("--swipe-amount-x")||"0"),y:Number.parseFloat(this.style.getPropertyValue("--swipe-amount-y")||"0")}}shouldDismissSwipe(t){let e=this.swipeAxis==="x"?t.x:t.y,s=this.dragStartTime?Date.now()-this.dragStartTime:0;return Math.abs(e)>=45||Math.abs(e)/Math.max(s,1)>.11}dismissFromSwipe(t){let{x:e,y:s}=K(this.position);this.swipeOutDirection=this.swipeAxis==="y"?s==="bottom"?"down":"up":e==="start"?"left":e==="end"?"right":t.x<0?"left":"right",this.swipeOut=!0,this.syncDomState(),this.beginRemove()}cancelSwipe(){this.resetSwipeTranslation(),this.swipeAxis=null,this.syncDomState()}clearPointerState(){this.pointerStart=null,this.dragStartTime=null}onCloseClick(t){t.stopPropagation(),this.dismissible&&this.beginRemove()}onActionClick(t){t.stopPropagation(),g.getSnapshot().find(s=>s.id===this.resolvedId)?.action?.onClick(t),this.dismissible&&this.beginRemove()}syncDomState(){let{y:t,x:e}=K(this.position);this.setAttribute("role","listitem"),this.dataset.mounted=String(this.mounted),this.dataset.removed=String(this.removed),this.dataset.swiping=String(this.swiping),this.dataset.swipeOut=String(this.swipeOut),this.dataset.dismissible=String(this.dismissible),this.dataset.yPosition=t,this.dataset.xPosition=e,this.dataset.variant=this.variant??"default",this.swipeOutDirection?this.dataset.swipeDirection=this.swipeOutDirection:delete this.dataset.swipeDirection}iconForVariant(){switch(this.variant){case"success":return"\u2713";case"error":return"\u2715";case"warning":return"!";case"info":return"i";default:return""}}render(){let t=this.variant??"default",e=this.iconForVariant(),s=t!=="default";return te("div",{ref:"toast",class:`rui-toast rui-toast--${t}`,role:"status","aria-live":"off","data-ref":"toast",children:[this.closeButton&&t!=="loading"?X("button",{type:"button",class:"rui-toast__close","data-toast-close":!0,"aria-label":"Close toast",children:"\xD7"}):null,s?X("span",{class:"rui-toast__icon","data-icon":!0,"aria-hidden":"true",children:t==="loading"?X("span",{class:"rui-toast__loader"}):e}):null,te("div",{class:"rui-toast__content",children:[X("div",{class:"rui-toast__title","data-title":!0,children:this.$.title}),this.description?X("div",{class:"rui-toast__description","data-description":!0,children:this.$.description}):null]}),this.actionLabel?X("button",{type:"button",class:"rui-toast__action rui-button rui-button--outline rui-button--sm","data-toast-action":!0,children:this.$.actionLabel}):null]})}static{At()}};import{jsx as Et}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as De,bound as mt,customElement as Ke,onEvent as Ot,onUpdated as Xe,prop as F,state as Ge}from"@ecopages/radiant";function oe(i,t,e){let s=0;for(let a=0;a<i;a+=1)s+=t[a]??0;return s+i*e}function re(i,t){return i.length===0?0:i.reduce((s,a)=>s+a,0)+Math.max(0,i.length-1)*t}function ae(i,t,e){return t<=0?0:i+Math.max(0,t-1)*e}var le,ue,ce,he,de,pe,fe,me,ye,ve,Te,be,ge,Se,_e,xe,we,Ie,Ee,Oe;function qe(i,t,e,s,a,h){var p,o,I,M,f,u,E,j=Symbol.metadata||Symbol.for("Symbol.metadata"),H=Object.defineProperty,L=Object.create,$=[L(null),L(null)],G=t.length;function V(n,T,y){return function(r,l){T&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,T,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(T+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,T,y,r,l,b,O,v,S,_,Z){function N(d){if(!Z(d))throw new TypeError("Attempted to access private element on non-instance")}var q=[].concat(T[0]),tt=T[3],W=!O,D=l===1,et=l===3,it=l===4,k=l===2;function C(d,P,ot){return function(B,rt){return P&&(rt=B,B=n),ot&&ot(B),c[d].call(B,rt)}}if(!W){var c={},Y=[],w=et?"get":it||D?"set":"value";if(S?(_||D?c={get:Pe(function(){return tt(this)},r,"get"),set:function(d){T[4](this,d)}}:c[w]=tt,_||Pe(c[w],r,k?"":w)):_||(c=Object.getOwnPropertyDescriptor(n,r)),!_&&!S){if((o=$[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");$[+v][r]=l<3?1:l}}for(var m=n,U=q.length-1;U>=0;U-=y?2:1){var st=x(q[U],"A decorator","be",!0),nt=y?q[U-1]:void 0,z={},A={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(d,P){if(d.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,z)};if(W)o=st.call(nt,m,A),z.v=1,x(o,"class decorators","return")&&(m=o);else if(A.static=v,A.private=S,o=A.access={has:S?Z.bind():function(d){return r in d}},it||(o.get=S?k?function(d){return N(d),c.value}:C("get",0,N):function(d){return d[r]}),k||et||(o.set=S?C("set",0,N):function(d,P){d[r]=P}),m=st.call(nt,D?{get:c.get,set:c.set}:c[w],A),z.v=1,D){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&Y.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(_?"field":"method")+" decorators","return")&&(_?Y.unshift(m):c[w]=m)}return l<2&&O.push(V(Y,v,1),V(b,v,0)),_||W||(S?D?O.splice(-1,0,C("get",v),C("set",v)):O.push(k?c[w]:x.call.bind(c[w])):H(n,r,c)),m}function Q(n){return H(n,j,{configurable:!0,enumerable:!0,value:p})}return h!==void 0&&(p=h[j]),p=L(p??null),f=[],u=function(n){n&&f.push(V(n))},E=function(n,T){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==T){var O=r[2],v=!!r[3],S=16&l;J(n?i:i.prototype,r,S,v?"#"+O:We(O),b,b<2?[]:n?M=M||[]:I=I||[],f,!!n,v,T,n&&v?function(_){return ze(_)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(M),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),V(n,1)]}}}function We(i){var t=Ye(i,"string");return typeof t=="symbol"?t:t+""}function Ye(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Pe(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 ze(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}function Ae(i,t){return i instanceof Node&&t.contains(i)}var Re,Le=class extends De{static{({e:[ce,he,de,pe,fe,me,ye,ve,Te,be,ge,Se,_e,xe,we,Ie,Ee,Oe,le],c:[Re,ue]}=qe(this,[Ke("rui-toaster")],[[F({type:String,reflect:!0,defaultValue:ht}),0,"position"],[F({type:Number,defaultValue:4e3}),0,"duration"],[F({type:Number,defaultValue:3}),0,"visibleToasts"],[F({type:Boolean,defaultValue:!1}),0,"closeButton"],[F({type:Boolean,defaultValue:!1}),0,"expand"],[F({type:Number,defaultValue:14}),0,"gap"],[F({type:Number,defaultValue:24}),0,"offset"],[F({type:String,reflect:!0,defaultValue:""}),0,"container"],[Ge,0,"toasts"],[Xe(["position","duration","visibleToasts","closeButton","expand","gap","offset","container"]),2,"onConfigUpdated"],[Ot({document:!0,type:at}),2,"onDocumentShow"],[Ot({document:!0,type:lt}),2,"onDocumentDismiss"],[Ot({selector:"rui-toast",type:"rui-toast-mounted"}),2,"onToastMounted"],[mt,2,"onPointerOver"],[mt,2,"onPointerOut"],[mt,2,"onPointerDown"],[mt,2,"onPointerUp"]],0,void 0,De))}position=(le(this),ce(this));duration=(he(this),de(this));visibleToasts=(pe(this),fe(this));closeButton=(me(this),ye(this));expand=(ve(this),Te(this));gap=(be(this),ge(this));offset=(Se(this),_e(this));container=(xe(this),we(this));toasts=(Ie(this),Ee(this,[]));expanded=(Oe(this),!1);interacting=!1;unsubscribe=null;visibilityHandler=null;heights=new Map;observers=new Map;layoutFrame=null;measuring=!1;connectedCallback(){super.connectedCallback(),this.syncHostPosition(),this.syncContainer(),this.unsubscribe=g.subscribe(t=>{this.toasts=t,t.length===0&&this.resetLayoutState(),this.scheduleLayoutSync()}),this.visibilityHandler=()=>this.syncPauseState(),document.addEventListener("visibilitychange",this.visibilityHandler)}disconnectedCallback(){this.unsubscribe?.(),this.unsubscribe=null,this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerUp),this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.resetLayoutState(),super.disconnectedCallback()}onConfigUpdated(){this.syncHostPosition(),this.syncContainer(),this.scheduleLayoutSync()}onDocumentShow(t){let e=t.detail;e?.title&&g.create(e.title,{id:e.id,description:e.description,variant:e.variant,duration:e.duration,action:e.action,dismissible:e.dismissible,closeButton:e.closeButton,position:e.position})}onDocumentDismiss(t){let e=t.detail;g.dismiss(e?.id)}onToastMounted(){this.scheduleLayoutSync()}filteredToasts(){let t=this.toasts.filter(a=>(a.position??this.position)===this.position),e=[],s=[];for(let a of t)a.delete?s.push(a):e.push(a);return[...e.slice(0,this.visibleToasts),...s]}syncHostPosition(){let{y:t,x:e}=K(this.position);this.dataset.yPosition=t,this.dataset.xPosition=e,this.style.setProperty("--width",`${356}px`),this.style.setProperty("--gap",`${this.gap}px`),this.style.setProperty("--viewport-offset",`${this.offset}px`)}syncContainer(){let t=this.container.trim();if(!t){this.removeAttribute("data-contained"),this.style.position="";return}let e=this.closest(t)??document.querySelector(t);if(!e){this.removeAttribute("data-contained"),this.style.position="";return}getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.contains(this)||e.appendChild(this),this.dataset.contained="true",this.style.position="absolute"}isStackExpanded(){return this.expanded||this.expand}isPaused(){return this.expanded||this.interacting||document.hidden}resetLayoutState(){for(let e of this.observers.values())e.disconnect();this.observers.clear(),this.heights.clear(),this.expanded=!1,this.interacting=!1;let t=this.querySelector(".rui-toaster");t&&(t.style.height="0px",t.dataset.expanded="false"),this.dataset.expanded="false"}syncPauseState(){let t=this.isPaused();for(let e of this.querySelectorAll("rui-toast"))e.setPaused(t);this.patchStackLayout()}scheduleLayoutSync(){this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame(()=>{if(this.layoutFrame=null,this.toasts.length>0&&!this.interacting){let e=!!(this.querySelector(".rui-toaster")?.matches(":hover")||this.matches(":hover"));this.expanded=e}this.observeToasts(),this.syncPauseState()})}measureToast(t){this.measuring=!0;let e=t.style.height,s=t.style.overflow;t.style.height="auto",t.style.overflow="visible";let a=t.querySelector(".rui-toast"),h=Math.round(a instanceof HTMLElement?a.offsetHeight:t.offsetHeight)||64;return t.style.height=e,t.style.overflow=s,this.measuring=!1,h}observeToasts(){let t=this.querySelector(".rui-toaster");if(!t)return;let e=[...t.querySelectorAll("rui-toast")],s=new Set;for(let a of e){let h=a.toastId;if(!h)continue;s.add(h);let p=a.querySelector(".rui-toast")??a;if(!this.observers.has(h)){let o=new ResizeObserver(()=>{if(this.measuring)return;let I=this.measureToast(a);this.heights.get(h)!==I&&(this.heights.set(h,I),this.patchStackLayout())});o.observe(p),this.observers.set(h,o)}this.heights.set(h,this.measureToast(a))}for(let[a,h]of[...this.observers])s.has(a)||(h.disconnect(),this.observers.delete(a),this.heights.delete(a))}patchStackLayout(){let t=this.querySelector(".rui-toaster");if(!t)return;let e=this.isStackExpanded(),{y:s}=K(this.position),a=s==="bottom"?-1:1,h=Math.min(3,Math.max(1,this.visibleToasts));this.dataset.expanded=String(e),t.dataset.expanded=String(e),this.style.setProperty("--lift",String(a)),t.style.setProperty("--gap",`${this.gap}px`);let p=[...t.querySelectorAll("rui-toast")].filter(f=>f.dataset.mounted==="true"&&f.dataset.removed!=="true");if(p.length===0){t.style.height="0px";return}let o=p.map(f=>{let u=this.measureToast(f);return this.heights.set(f.toastId,u),u}),I=o[0]??64;this.style.setProperty("--front-toast-height",`${I}px`);for(let f=0;f<p.length;f+=1){let u=p[f];if(!u)continue;let E=o[f]??64,j=f===0,H=oe(f,o,this.gap),L=f<h;if(u.dataset.index=String(f),u.dataset.front=String(j),u.dataset.expanded=String(e),u.dataset.visible=String(e||L),u.style.setProperty("--z-index",String(p.length-f)),u.style.setProperty("--index",String(f)),u.style.setProperty("--offset",`${H}px`),u.style.setProperty("--initial-height",`${E}px`),u.style.setProperty("--gap",`${this.gap}px`),e)u.style.setProperty("--y",`translateY(${a*H}px)`),u.style.height=`${E}px`,u.style.overflow="visible";else if(!L)u.style.setProperty("--y",`translateY(${a*(h-1)*this.gap}px) scale(0.7)`),u.style.height=`${I}px`,u.style.overflow="hidden";else if(j)u.style.setProperty("--y","translateY(0px)"),u.style.height=`${E}px`,u.style.overflow="visible";else{let $=Math.max(.7,1-f*.05);u.style.setProperty("--y",`translateY(${a*f*this.gap}px) scale(${$})`),u.style.height=`${I}px`,u.style.overflow="hidden"}}let M=Math.min(h,p.length);t.style.height=`${e?re(o,this.gap):ae(I,M,this.gap)}px`}onPointerOver(t){Ae(t.relatedTarget,this)||(this.expanded=!0,this.syncPauseState())}onPointerOut(t){Ae(t.relatedTarget,this)||this.interacting||(this.expanded=!1,this.syncPauseState())}onPointerDown(){this.interacting=!0,this.expanded=!0,this.syncPauseState(),document.addEventListener("pointerup",this.onPointerUp,{once:!0}),document.addEventListener("pointercancel",this.onPointerUp,{once:!0})}onPointerUp(){if(!this.interacting)return;this.interacting=!1,this.querySelector(".rui-toaster")?.matches(":hover")||this.querySelector("rui-toast:hover")||(this.expanded=!1),this.syncPauseState()}render(){let t=this.filteredToasts();return Et("section",{class:"rui-toaster-region","aria-label":"Notifications","aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",tabIndex:-1,children:Et("ol",{class:"rui-toaster","data-rui-toaster":!0,"on:pointerover":this.onPointerOver,"on:pointerout":this.onPointerOut,"on:pointerdown":this.onPointerDown,children:t.map(e=>{let s=e.duration??(e.variant==="loading"?Number.POSITIVE_INFINITY:this.duration);return Et("rui-toast",{"prop:toastId":String(e.id),"prop:title":e.title,"prop:description":e.description??"","prop:variant":e.variant,"prop:duration":s,"prop:dismissible":e.dismissible,"prop:closeButton":e.closeButton??this.closeButton,"prop:actionLabel":e.action?.label??"","prop:position":e.position??this.position,"prop:markedDelete":!!e.delete},String(e.id))})})})}static{ue()}};import{jsx as Me}from"@ecopages/jsx/jsx-runtime";function Je({toastId:i,...t}){return Me("rui-toast",{...t,toastId:i!=null?String(i):void 0})}function Qe({children:i,...t}){return Me("rui-toaster",{...t,children:i})}var Ze=Object.assign((i,t)=>g.create(i,t),{message:(i,t)=>g.message(i,t),success:(i,t)=>g.success(i,t),error:(i,t)=>g.error(i,t),info:(i,t)=>g.info(i,t),warning:(i,t)=>g.warning(i,t),loading:(i,t)=>g.loading(i,t),promise:(i,t)=>g.promise(i,t),dismiss:i=>g.dismiss(i),clear:()=>g.clear()});function ti(i){document.dispatchEvent(new CustomEvent(at,{detail:i,bubbles:!0,composed:!0}))}function ei(i){let t=i==null?{}:{id:i};document.dispatchEvent(new CustomEvent(lt,{detail:t,bubbles:!0,composed:!0}))}export{ht as DEFAULT_TOAST_POSITION,lt as RUI_TOAST_DISMISS_EVENT,at as RUI_TOAST_SHOW_EVENT,Je as RuiToast,ne as RuiToastElement,Qe as RuiToaster,Re as RuiToasterElement,gt as TOAST_COLLAPSED_PEEK,St as TOAST_EXIT_MS,vt as TOAST_GAP,ut as TOAST_LIFETIME,Ve as TOAST_POSITIONS,ct as TOAST_SWIPE_THRESHOLD,Tt as TOAST_VIEWPORT_OFFSET,bt as TOAST_VISIBLE_AMOUNT,yt as TOAST_WIDTH,ei as dismissToast,ti as showToast,Ze as toast};
1
+ import{jsx as F,jsxs as oe}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as re,bindTo as It,bound as Et,customElement as Ge,onEvent as ae,onUpdated as Ot,prop as L,query as Je}from"@ecopages/radiant";function pt(...i){return i.filter(Boolean).join(" ")}import{jsx as Rt}from"@ecopages/jsx/jsx-runtime";function gt({class:i,size:t="sm",...e}){return Rt("svg",{...e,class:pt("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:Rt("path",{d:"m5 12 4 4L19 6"})})}import{jsx as Lt,jsxs as He}from"@ecopages/jsx/jsx-runtime";function ft({class:i,size:t="sm",...e}){return He("svg",{...e,class:pt("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:[Lt("path",{d:"m18 6-12 12"}),Lt("path",{d:"m6 6 12 12"})]})}var at="rui-toast-show",lt="rui-toast-dismiss",Ne=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"],ut=4e3,$e=356,bt=14,Tt=24,_t=3,St=3,ct=45,xt=200,dt="bottom-end";function j(i){let[t,e]=i.split("-");return{y:t,x:e}}var We=1;function qe(){return We++}function kt(i,t){return typeof i=="function"?i(t):i}var wt=class{subscribers=[];toasts=[];subscribe=t=>(this.subscribers.push(t),t(this.toasts),()=>{let e=this.subscribers.indexOf(t);e>=0&&this.subscribers.splice(e,1)});getSnapshot=()=>this.toasts;publish(){let t=this.toasts;for(let e of this.subscribers)e(t)}create=(t,e={})=>{let s=e.id??qe(),a=e.dismissible??!0,d=this.toasts.findIndex(o=>o.id===s),p={id:s,title:t,description:e.description,variant:e.variant??"default",duration:e.duration,action:e.action,dismissible:a,closeButton:e.closeButton,position:e.position,delete:!1};return d>=0?this.toasts=this.toasts.map(o=>o.id===s?{...o,...p,delete:!1}:o):this.toasts=[p,...this.toasts],this.publish(),s};dismiss=t=>{if(t==null){if(this.toasts.length===0)return;this.toasts=this.toasts.map(e=>({...e,delete:!0}))}else{let e=this.toasts.find(s=>s.id===t);if(!e||e.delete)return;this.toasts=this.toasts.map(s=>s.id===t?{...s,delete:!0}:s)}this.publish()};remove=t=>{this.toasts=this.toasts.filter(e=>e.id!==t),this.publish()};clear=()=>{this.toasts.length!==0&&(this.toasts=[],this.publish())};message=(t,e)=>this.create(t,e);success=(t,e)=>this.create(t,{...e,variant:"success"});error=(t,e)=>this.create(t,{...e,variant:"error"});info=(t,e)=>this.create(t,{...e,variant:"info"});warning=(t,e)=>this.create(t,{...e,variant:"warning"});loading=(t,e)=>this.create(t,{...e,variant:"loading",duration:e?.duration??Number.POSITIVE_INFINITY});promise=(t,e)=>{let s=this.loading(e.loading,{duration:Number.POSITIVE_INFINITY,action:e.action,closeButton:e.closeButton,position:e.position,description:typeof e.description=="string"?e.description:void 0});return(typeof t=="function"?t():t).then(d=>{let p=typeof e.description=="function"?e.description(d):e.description;this.create(kt(e.success,d),{id:s,variant:"success",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}).catch(d=>{let p=typeof e.description=="function"?e.description(d):e.description;this.create(kt(e.error,d),{id:s,variant:"error",description:p,duration:e.duration,action:e.action,closeButton:e.closeButton,position:e.position})}),s}},T=new wt;var Ct,Mt,Vt,Bt,Ut,jt,Ft,Ht,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se;function Ye(i,t,e,s,a,d){var p,o,I,k,f,u,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),N=Object.defineProperty,R=Object.create,W=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,b,O,v,_,S,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var Y=[].concat(g[0]),tt=g[3],X=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(h,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),c[h].call(U,rt)}}if(!X){var c={},z=[],w=et?"get":it||A?"set":"value";if(_?(S||A?c={get:ne(function(){return tt(this)},r,"get"),set:function(h){g[4](this,h)}}:c[w]=tt,S||ne(c[w],r,M?"":w)):S||(c=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=W[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");W[+v][r]=l<3?1:l}}for(var m=n,B=Y.length-1;B>=0;B-=y?2:1){var st=x(Y[B],"A decorator","be",!0),nt=y?Y[B-1]:void 0,K={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,K)};if(X)o=st.call(nt,m,D),K.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(h){return r in h}},it||(o.get=_?M?function(h){return q(h),c.value}:V("get",0,q):function(h){return h[r]}),M||et||(o.set=_?V("set",0,q):function(h,P){h[r]=P}),m=st.call(nt,A?{get:c.get,set:c.set}:c[w],D),K.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&z.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?z.unshift(m):c[w]=m)}return l<2&&O.push(C(z,v,1),C(b,v,0)),S||X||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?c[w]:x.call.bind(c[w])):N(n,r,c)),m}function Q(n){return N(n,H,{configurable:!0,enumerable:!0,value:p})}return d!==void 0&&(p=d[H]),p=R(p??null),f=[],u=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:Xe(O),b,b<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return Ke(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function Xe(i){var t=ze(i,"string");return typeof t=="symbol"?t:t+""}function ze(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function ne(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 ht=new Map,yt=new Map;function Pt(i){return String(i)}function mt(i){if(i==="")return;let t=Pt(i);ht.delete(t),yt.delete(t)}function Qe(i){if(i==="")return;let t=Pt(i),e=ht.get(t);e!=null&&(yt.set(t,Math.max(0,e-Date.now())),ht.delete(t))}var ue,le=class extends re{static{({e:[Vt,Bt,Ut,jt,Ft,Ht,Nt,$t,Wt,qt,Yt,Xt,zt,Kt,Gt,Jt,Qt,Zt,te,ee,ie,se,Ct],c:[ue,Mt]}=Ye(this,[Ge("rui-toast")],[[L({type:String,reflect:!0,defaultValue:""}),0,"toastId"],[L({type:String,defaultValue:""}),0,"title"],[L({type:String,defaultValue:""}),0,"description"],[[L({type:String,reflect:!0,defaultValue:"default"}),It({attr:"data-variant",map:t=>t??"default"})],0,"variant"],[L({type:Number,defaultValue:4e3}),0,"duration"],[[L({type:Boolean,defaultValue:!0}),It({attr:"data-dismissible"})],0,"dismissible"],[L({type:Boolean,defaultValue:!1}),0,"closeButton"],[L({type:String,defaultValue:""}),0,"actionLabel"],[[L({type:String,defaultValue:dt}),It([{attr:"data-y-position",map:t=>j(t).y},{attr:"data-x-position",map:t=>j(t).x}])],0,"position"],[L({type:Boolean,defaultValue:!1}),0,"markedDelete"],[Je({ref:"toast"}),0,"toastTarget"],[Ot("position"),2,"onPositionUpdated"],[Ot("duration"),2,"onDurationUpdated"],[Ot("markedDelete"),2,"onMarkedDeleteUpdated"],[Et,2,"onPointerDown"],[Et,2,"onPointerMove"],[Et,2,"onPointerUp"],[ae({selector:"[data-toast-close]",type:"click"}),2,"onCloseClick"],[ae({selector:"[data-toast-action]",type:"click"}),2,"onActionClick"]],0,void 0,re))}toastId=(Ct(this),Vt(this));title=(Bt(this),Ut(this));description=(jt(this),Ft(this));variant=(Ht(this),Nt(this));duration=($t(this),Wt(this));dismissible=(qt(this),Yt(this));closeButton=(Xt(this),zt(this));actionLabel=(Kt(this),Gt(this));position=(Jt(this),Qt(this));markedDelete=(Zt(this),te(this));toastTarget=(ee(this),ie(this));mounted=(se(this),!1);removed=!1;swiping=!1;swipeOut=!1;swipeAxis=null;swipeOutDirection=null;held=!1;timerReady=!1;timeoutId=null;pointerStart=null;dragStartTime=null;exitTimer=null;connectedCallback(){super.connectedCallback();let t=this.mounted;if(this.addEventListener("pointerdown",this.onPointerDown),this.addEventListener("pointermove",this.onPointerMove),this.addEventListener("pointerup",this.onPointerUp),this.addEventListener("pointercancel",this.onPointerUp),t){this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer();return}this.timerReady=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.isConnected&&(this.mounted=!0,this.timerReady=!0,this.syncDomState(),this.dispatchEvent(new CustomEvent("rui-toast-mounted",{bubbles:!0})),!this.held&&!this.removed&&this.startTimer())})}),this.syncDomState()}disconnectedCallback(){this.clearTimer(),this.exitTimer&&(clearTimeout(this.exitTimer),this.exitTimer=null);let t=this.resolvedId;t!==""&&this.removed&&T.remove(t),this.held=!1,this.timerReady=!1,this.removeEventListener("pointerdown",this.onPointerDown),this.removeEventListener("pointermove",this.onPointerMove),this.removeEventListener("pointerup",this.onPointerUp),this.removeEventListener("pointercancel",this.onPointerUp),super.disconnectedCallback()}onPositionUpdated(){this.syncDomState()}setPaused(t){if(this.held===t){!t&&this.timerReady&&this.mounted&&!this.removed&&!this.timeoutId&&this.startTimer();return}this.held=t,!(!this.timerReady||!this.mounted||this.removed)&&(t||document.hidden?(Qe(this.resolvedId),this.clearTimer()):this.startTimer())}onDurationUpdated(){!this.timerReady||!this.mounted||this.removed||this.held||(mt(this.resolvedId),this.startTimer())}onMarkedDeleteUpdated(){this.markedDelete&&!this.removed&&this.beginRemove()}get resolvedId(){let t=this.toastId;if(t==null||t==="")return"";let e=Number(t);return Number.isFinite(e)&&String(e)===t?e:t}clearTimer(){this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=null}startTimer(){if(this.held||this.removed||document.hidden||this.duration===Number.POSITIVE_INFINITY||this.variant==="loading")return;if(this.duration<=0){this.beginRemove();return}let t=this.resolvedId,e=Pt(t),s=Date.now(),a=yt.get(e);if(yt.delete(e),a==null){let d=ht.get(e);a=d!=null?d-s:this.duration}if(a<=0){mt(t),this.beginRemove();return}ht.set(e,s+a),this.clearTimer(),this.timeoutId=setTimeout(()=>{mt(t),this.beginRemove()},a)}beginRemove(){this.removed||(this.removed=!0,this.clearTimer(),mt(this.resolvedId),this.syncDomState(),this.markedDelete||T.dismiss(this.resolvedId),this.exitTimer=setTimeout(()=>{this.exitTimer=null,T.remove(this.resolvedId)},200))}onPointerDown(t){!this.dismissible||this.variant==="loading"||t.button!==0||t.target?.closest("[data-toast-close], [data-toast-action], button, a")||(this.dragStartTime=Date.now(),this.pointerStart={x:t.clientX,y:t.clientY},this.swipeAxis=null,this.setPointerCapture(t.pointerId))}onPointerMove(t){if(!this.pointerStart)return;let e={x:t.clientX-this.pointerStart.x,y:t.clientY-this.pointerStart.y};if(!this.startSwipe(e))return;this.swipeAxis??=Math.abs(e.x)>Math.abs(e.y)?"x":"y";let s=this.swipeAxis==="x"?{x:e.x,y:0}:{x:0,y:e.y};this.isSwipeReversing(s)?this.resetSwipeTranslation():this.setSwipeTranslation(s)}startSwipe(t){return this.swiping?!0:Math.abs(t.x)<8&&Math.abs(t.y)<8?!1:(this.swiping=!0,this.syncDomState(),!0)}isSwipeReversing(t){let{x:e,y:s}=j(this.position);return this.swipeAxis==="y"?(s==="bottom"?t.y<0:t.y>0)&&Math.abs(t.y)<45:e!=="center"&&(e==="start"?t.x>0:t.x<0)&&Math.abs(t.x)<45}setSwipeTranslation(t){this.style.setProperty("--rui-toast-swipe-x",`${t.x}px`),this.style.setProperty("--rui-toast-swipe-y",`${t.y}px`)}resetSwipeTranslation(){this.setSwipeTranslation({x:0,y:0})}onPointerUp(t){if(!this.pointerStart)return;this.releaseToastPointer(t.pointerId);let e=this.readSwipe();this.swiping=!1,e&&this.dismissible&&this.shouldDismissSwipe(e)?this.dismissFromSwipe(e):this.cancelSwipe(),this.clearPointerState()}releaseToastPointer(t){try{this.releasePointerCapture(t)}catch{}}readSwipe(){if(this.swiping)return{x:Number.parseFloat(this.style.getPropertyValue("--rui-toast-swipe-x")||"0"),y:Number.parseFloat(this.style.getPropertyValue("--rui-toast-swipe-y")||"0")}}shouldDismissSwipe(t){let e=this.swipeAxis==="x"?t.x:t.y,s=this.dragStartTime?Date.now()-this.dragStartTime:0;return Math.abs(e)>=45||Math.abs(e)/Math.max(s,1)>.11}dismissFromSwipe(t){let{x:e,y:s}=j(this.position);this.swipeOutDirection=this.swipeAxis==="y"?s==="bottom"?"down":"up":e==="start"?"left":e==="end"?"right":t.x<0?"left":"right",this.swipeOut=!0,this.syncDomState(),this.beginRemove()}cancelSwipe(){this.resetSwipeTranslation(),this.swipeAxis=null,this.syncDomState()}clearPointerState(){this.pointerStart=null,this.dragStartTime=null}onCloseClick(t){t.stopPropagation(),this.dismissible&&this.beginRemove()}onActionClick(t){t.stopPropagation(),T.getSnapshot().find(s=>s.id===this.resolvedId)?.action?.onClick(t),this.dismissible&&this.beginRemove()}syncDomState(){this.setAttribute("role","listitem"),this.dataset.mounted=String(this.mounted),this.dataset.removed=String(this.removed),this.dataset.swiping=String(this.swiping),this.dataset.swipeOut=String(this.swipeOut),this.swipeOutDirection?this.dataset.swipeDirection=this.swipeOutDirection:delete this.dataset.swipeDirection}iconForVariant(){switch(this.variant){case"success":return F(gt,{});case"error":return F(ft,{});case"warning":return"!";case"info":return"i";default:return""}}render(){let t=this.variant??"default",e=this.iconForVariant(),s=t!=="default";return oe("div",{ref:"toast",class:`rui-toast rui-toast--${t}`,role:"status","aria-live":"off","data-ref":"toast",children:[this.closeButton&&t!=="loading"?F("button",{type:"button",class:"rui-toast__close","data-toast-close":!0,"aria-label":"Close toast",children:F(ft,{})}):null,s?F("span",{class:"rui-toast__icon","data-icon":!0,"aria-hidden":"true",children:t==="loading"?F("span",{class:"rui-toast__loader"}):e}):null,oe("div",{class:"rui-toast__content",children:[F("div",{class:"rui-toast__title","data-title":!0,children:this.$.title}),this.description?F("div",{class:"rui-toast__description","data-description":!0,children:this.$.description}):null]}),this.actionLabel?F("button",{type:"button",class:"rui-toast__action rui-button rui-button--outline rui-button--sm","data-toast-action":!0,children:this.$.actionLabel}):null]})}static{Mt()}};import{jsx as At}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Ve,bindTo as si,bound as vt,customElement as ni,onEvent as Dt,onUpdated as oi,prop as $,query as ri,state as ai}from"@ecopages/radiant";function ce(i,t,e){let s=0;for(let a=0;a<i;a+=1)s+=t[a]??0;return s+i*e}function de(i,t){return i.length===0?0:i.reduce((s,a)=>s+a,0)+Math.max(0,i.length-1)*t}function he(i,t,e){return t<=0?0:i+Math.max(0,t-1)*e}var pe,fe,me,ye,ve,ge,be,Te,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce;function Ze(i,t,e,s,a,d){var p,o,I,k,f,u,E,H=Symbol.metadata||Symbol.for("Symbol.metadata"),N=Object.defineProperty,R=Object.create,W=[R(null),R(null)],G=t.length;function C(n,g,y){return function(r,l){g&&(l=r,r=i);for(var b=0;b<n.length;b++)l=n[b].apply(r,y?[l]:[]);return y?l:r}}function x(n,g,y,r){if(typeof n!="function"&&(r||n!==void 0))throw new TypeError(g+" must "+(y||"be")+" a function"+(r?"":" or undefined"));return n}function J(n,g,y,r,l,b,O,v,_,S,Z){function q(h){if(!Z(h))throw new TypeError("Attempted to access private element on non-instance")}var Y=[].concat(g[0]),tt=g[3],X=!O,A=l===1,et=l===3,it=l===4,M=l===2;function V(h,P,ot){return function(U,rt){return P&&(rt=U,U=n),ot&&ot(U),c[h].call(U,rt)}}if(!X){var c={},z=[],w=et?"get":it||A?"set":"value";if(_?(S||A?c={get:Me(function(){return tt(this)},r,"get"),set:function(h){g[4](this,h)}}:c[w]=tt,S||Me(c[w],r,M?"":w)):S||(c=Object.getOwnPropertyDescriptor(n,r)),!S&&!_){if((o=W[+v][r])&&(o^l)!==7)throw Error("Decorating two elements with the same name ("+c[w].name+") is not supported yet");W[+v][r]=l<3?1:l}}for(var m=n,B=Y.length-1;B>=0;B-=y?2:1){var st=x(Y[B],"A decorator","be",!0),nt=y?Y[B-1]:void 0,K={},D={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:p,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");x(P,"An initializer","be",!0),b.push(P)}.bind(null,K)};if(X)o=st.call(nt,m,D),K.v=1,x(o,"class decorators","return")&&(m=o);else if(D.static=v,D.private=_,o=D.access={has:_?Z.bind():function(h){return r in h}},it||(o.get=_?M?function(h){return q(h),c.value}:V("get",0,q):function(h){return h[r]}),M||et||(o.set=_?V("set",0,q):function(h,P){h[r]=P}),m=st.call(nt,A?{get:c.get,set:c.set}:c[w],D),K.v=1,A){if(typeof m=="object"&&m)(o=x(m.get,"accessor.get"))&&(c.get=o),(o=x(m.set,"accessor.set"))&&(c.set=o),(o=x(m.init,"accessor.init"))&&z.unshift(o);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else x(m,(S?"field":"method")+" decorators","return")&&(S?z.unshift(m):c[w]=m)}return l<2&&O.push(C(z,v,1),C(b,v,0)),S||X||(_?A?O.splice(-1,0,V("get",v),V("set",v)):O.push(M?c[w]:x.call.bind(c[w])):N(n,r,c)),m}function Q(n){return N(n,H,{configurable:!0,enumerable:!0,value:p})}return d!==void 0&&(p=d[H]),p=R(p??null),f=[],u=function(n){n&&f.push(C(n))},E=function(n,g){for(var y=0;y<e.length;y++){var r=e[y],l=r[1],b=7&l;if((8&l)==n&&!b==g){var O=r[2],v=!!r[3],_=16&l;J(n?i:i.prototype,r,_,v?"#"+O:ti(O),b,b<2?[]:n?k=k||[]:I=I||[],f,!!n,v,g,n&&v?function(S){return ii(S)===i}:a)}}},E(8,0),E(0,0),E(8,1),E(0,1),u(I),u(k),o=f,G||Q(i),{e:o,get c(){var n=[];return G&&[Q(i=J(i,[t],s,i.name,5,n)),C(n,1)]}}}function ti(i){var t=ei(i,"string");return typeof t=="symbol"?t:t+""}function ei(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var s=e.call(i,t||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function Me(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 ii(i){if(Object(i)!==i)throw TypeError("right-hand side of 'in' should be an object, got "+(i!==null?typeof i:"null"));return i}function Be(i,t){return i instanceof Node&&t.contains(i)}var je,Ue=class extends Ve{static{({e:[me,ye,ve,ge,be,Te,_e,Se,xe,we,Ie,Ee,Oe,Pe,Ae,De,Re,Le,ke,Ce,pe],c:[je,fe]}=Ze(this,[ni("rui-toaster")],[[[$({type:String,reflect:!0,defaultValue:dt}),si([{attr:"data-y-position",map:t=>j(t).y},{attr:"data-x-position",map:t=>j(t).x}])],0,"position"],[$({type:Number,defaultValue:4e3}),0,"duration"],[$({type:Number,defaultValue:3}),0,"visibleToasts"],[$({type:Boolean,defaultValue:!1}),0,"closeButton"],[$({type:Boolean,defaultValue:!1}),0,"expand"],[$({type:Number,defaultValue:14}),0,"gap"],[$({type:Number,defaultValue:24}),0,"offset"],[$({type:String,reflect:!0,defaultValue:""}),0,"container"],[ri({ref:"list"}),0,"listTarget"],[ai,0,"toasts"],[oi(["position","duration","visibleToasts","closeButton","expand","gap","offset","container"]),2,"onConfigUpdated"],[Dt({document:!0,type:at}),2,"onDocumentShow"],[Dt({document:!0,type:lt}),2,"onDocumentDismiss"],[Dt({selector:"rui-toast",type:"rui-toast-mounted"}),2,"onToastMounted"],[vt,2,"onPointerOver"],[vt,2,"onPointerOut"],[vt,2,"onPointerDown"],[vt,2,"onPointerUp"]],0,void 0,Ve))}position=(pe(this),me(this));duration=(ye(this),ve(this));visibleToasts=(ge(this),be(this));closeButton=(Te(this),_e(this));expand=(Se(this),xe(this));gap=(we(this),Ie(this));offset=(Ee(this),Oe(this));container=(Pe(this),Ae(this));listTarget=(De(this),Re(this));toasts=(Le(this),ke(this,[]));expanded=(Ce(this),!1);interacting=!1;unsubscribe=null;visibilityHandler=null;heights=new Map;observers=new Map;layoutFrame=null;measuring=!1;connectedCallback(){super.connectedCallback(),this.syncHostPosition(),this.syncContainer(),this.unsubscribe=T.subscribe(t=>{this.toasts=t,t.length===0&&this.resetLayoutState(),this.scheduleLayoutSync()}),this.visibilityHandler=()=>this.syncPauseState(),document.addEventListener("visibilitychange",this.visibilityHandler)}disconnectedCallback(){this.unsubscribe?.(),this.unsubscribe=null,this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerUp),this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.resetLayoutState(),super.disconnectedCallback()}onConfigUpdated(){this.syncHostPosition(),this.syncContainer(),this.scheduleLayoutSync()}onDocumentShow(t){let e=t.detail;e?.title&&T.create(e.title,{id:e.id,description:e.description,variant:e.variant,duration:e.duration,action:e.action,dismissible:e.dismissible,closeButton:e.closeButton,position:e.position})}onDocumentDismiss(t){let e=t.detail;T.dismiss(e?.id)}onToastMounted(){this.scheduleLayoutSync()}filteredToasts(){let t=this.toasts.filter(a=>(a.position??this.position)===this.position),e=[],s=[];for(let a of t)a.delete?s.push(a):e.push(a);return[...e.slice(0,this.visibleToasts),...s]}syncHostPosition(){this.style.setProperty("--rui-toaster-gap",`${this.gap}px`),this.style.setProperty("--rui-toaster-offset",`${this.offset}px`)}syncContainer(){let t=this.container.trim();if(!t){this.removeAttribute("data-contained"),this.style.position="";return}let e=this.closest(t)??document.querySelector(t);if(!e){this.removeAttribute("data-contained"),this.style.position="";return}getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.contains(this)||e.appendChild(this),this.dataset.contained="true",this.style.position="absolute"}isStackExpanded(){return this.expanded||this.expand}isPaused(){return this.expanded||this.interacting||document.hidden}resetLayoutState(){for(let e of this.observers.values())e.disconnect();this.observers.clear(),this.heights.clear(),this.expanded=!1,this.interacting=!1;let t=this.listTarget;t&&(t.style.height="0px",t.dataset.expanded="false"),this.dataset.expanded="false"}syncPauseState(){let t=this.isPaused();for(let e of this.querySelectorAll("rui-toast"))e.setPaused(t);this.patchStackLayout()}scheduleLayoutSync(){this.layoutFrame!=null&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame(()=>{if(this.layoutFrame=null,this.toasts.length>0&&!this.interacting){let e=!!(this.listTarget?.matches(":hover")||this.matches(":hover"));this.expanded=e}this.observeToasts(),this.syncPauseState()})}measureToast(t){this.measuring=!0;let e=t.style.height,s=t.style.overflow;t.style.height="auto",t.style.overflow="visible";let a=t.getRef("toast"),d=Math.round(a instanceof HTMLElement?a.offsetHeight:t.offsetHeight)||64;return t.style.height=e,t.style.overflow=s,this.measuring=!1,d}observeToasts(){let t=this.listTarget;if(!t)return;let e=[...t.querySelectorAll("rui-toast")],s=new Set;for(let a of e){let d=a.toastId;if(!d)continue;s.add(d);let p=a.getRef("toast")??a;if(!this.observers.has(d)){let o=new ResizeObserver(()=>{if(this.measuring)return;let I=this.measureToast(a);this.heights.get(d)!==I&&(this.heights.set(d,I),this.patchStackLayout())});o.observe(p),this.observers.set(d,o)}this.heights.set(d,this.measureToast(a))}for(let[a,d]of[...this.observers])s.has(a)||(d.disconnect(),this.observers.delete(a),this.heights.delete(a))}patchStackLayout(){let t=this.listTarget;if(!t)return;let e=this.isStackExpanded(),{y:s}=j(this.position),a=s==="bottom"?-1:1,d=Math.min(3,Math.max(1,this.visibleToasts));this.dataset.expanded=String(e),t.dataset.expanded=String(e),this.style.setProperty("--rui-toaster-lift",String(a)),t.style.setProperty("--rui-toaster-gap",`${this.gap}px`);let p=[...t.querySelectorAll("rui-toast")].filter(f=>f.dataset.mounted==="true"&&f.dataset.removed!=="true");if(p.length===0){t.style.height="0px";return}let o=p.map(f=>{let u=this.measureToast(f);return this.heights.set(f.toastId,u),u}),I=o[0]??64;this.style.setProperty("--rui-toaster-front-height",`${I}px`);for(let f=0;f<p.length;f+=1){let u=p[f];if(!u)continue;let E=o[f]??64,H=f===0,N=ce(f,o,this.gap),R=f<d;if(u.dataset.index=String(f),u.dataset.front=String(H),u.dataset.expanded=String(e),u.dataset.visible=String(e||R),u.style.setProperty("--rui-toast-z",String(p.length-f)),u.style.setProperty("--rui-toast-index",String(f)),u.style.setProperty("--rui-toast-offset",`${N}px`),u.style.setProperty("--rui-toast-initial-height",`${E}px`),u.style.setProperty("--rui-toaster-gap",`${this.gap}px`),e)u.style.setProperty("--rui-toast-y",`translateY(${a*N}px)`),u.style.height=`${E}px`,u.style.overflow="visible";else if(!R)u.style.setProperty("--rui-toast-y",`translateY(${a*(d-1)*this.gap}px) scale(0.7)`),u.style.height=`${I}px`,u.style.overflow="hidden";else if(H)u.style.setProperty("--rui-toast-y","translateY(0px)"),u.style.height=`${E}px`,u.style.overflow="visible";else{let W=Math.max(.7,1-f*.05);u.style.setProperty("--rui-toast-y",`translateY(${a*f*this.gap}px) scale(${W})`),u.style.height=`${I}px`,u.style.overflow="hidden"}}let k=Math.min(d,p.length);t.style.height=`${e?de(o,this.gap):he(I,k,this.gap)}px`}onPointerOver(t){Be(t.relatedTarget,this)||(this.expanded=!0,this.syncPauseState())}onPointerOut(t){Be(t.relatedTarget,this)||this.interacting||(this.expanded=!1,this.syncPauseState())}onPointerDown(){this.interacting=!0,this.expanded=!0,this.syncPauseState(),document.addEventListener("pointerup",this.onPointerUp,{once:!0}),document.addEventListener("pointercancel",this.onPointerUp,{once:!0})}onPointerUp(){if(!this.interacting)return;this.interacting=!1,this.listTarget?.matches(":hover")||this.querySelector("rui-toast:hover")||(this.expanded=!1),this.syncPauseState()}render(){let t=this.filteredToasts();return At("section",{class:"rui-toaster-region","aria-label":"Notifications","aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",tabIndex:-1,children:At("ol",{class:"rui-toaster","data-ref":"list","data-rui-toaster":!0,"on:pointerover":this.onPointerOver,"on:pointerout":this.onPointerOut,"on:pointerdown":this.onPointerDown,children:t.map(e=>{let s=e.duration??(e.variant==="loading"?Number.POSITIVE_INFINITY:this.duration);return At("rui-toast",{"prop:toastId":String(e.id),"prop:title":e.title,"prop:description":e.description??"","prop:variant":e.variant,"prop:duration":s,"prop:dismissible":e.dismissible,"prop:closeButton":e.closeButton??this.closeButton,"prop:actionLabel":e.action?.label??"","prop:position":e.position??this.position,"prop:markedDelete":!!e.delete},String(e.id))})})})}static{fe()}};import{jsx as Fe}from"@ecopages/jsx/jsx-runtime";function li({toastId:i,...t}){return Fe("rui-toast",{...t,toastId:i!=null?String(i):void 0})}function ui({children:i,...t}){return Fe("rui-toaster",{...t,children:i})}var ci=Object.assign((i,t)=>T.create(i,t),{message:(i,t)=>T.message(i,t),success:(i,t)=>T.success(i,t),error:(i,t)=>T.error(i,t),info:(i,t)=>T.info(i,t),warning:(i,t)=>T.warning(i,t),loading:(i,t)=>T.loading(i,t),promise:(i,t)=>T.promise(i,t),dismiss:i=>T.dismiss(i),clear:()=>T.clear()});function di(i){document.dispatchEvent(new CustomEvent(at,{detail:i,bubbles:!0,composed:!0}))}function hi(i){let t=i==null?{}:{id:i};document.dispatchEvent(new CustomEvent(lt,{detail:t,bubbles:!0,composed:!0}))}export{dt as DEFAULT_TOAST_POSITION,lt as RUI_TOAST_DISMISS_EVENT,at as RUI_TOAST_SHOW_EVENT,li as RuiToast,ue as RuiToastElement,ui as RuiToaster,je as RuiToasterElement,St as TOAST_COLLAPSED_PEEK,xt as TOAST_EXIT_MS,bt as TOAST_GAP,ut as TOAST_LIFETIME,Ne as TOAST_POSITIONS,ct as TOAST_SWIPE_THRESHOLD,Tt as TOAST_VIEWPORT_OFFSET,_t as TOAST_VISIBLE_AMOUNT,$e as TOAST_WIDTH,hi as dismissToast,di as showToast,ci as toast};
2
2
  //# sourceMappingURL=index.js.map