@zazz-ui/core 0.4.1 → 0.5.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 (331) hide show
  1. package/AUTHORING.md +158 -0
  2. package/CHANGELOG.md +331 -0
  3. package/README.md +55 -23
  4. package/dist/scroll-state-C8mA5gq6.js +1 -0
  5. package/dist/sri.json +124 -72
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +116794 -0
  9. package/editor/zazz.html-data.json +1683 -0
  10. package/editor/zazz.language-data.json +5001 -0
  11. package/editor/zazz.lint-data.json +152 -0
  12. package/package.json +12 -5
  13. package/src/base/_breakpoints.css +12 -0
  14. package/src/base/_layers.css +8 -9
  15. package/src/base/_properties-2xl.css +171 -0
  16. package/src/base/_properties-active.css +107 -0
  17. package/src/base/_properties-checked.css +107 -0
  18. package/src/base/_properties-current.css +107 -0
  19. package/src/base/_properties-disabled.css +107 -0
  20. package/src/base/_properties-focus-visible.css +107 -0
  21. package/src/base/_properties-focus-within.css +107 -0
  22. package/src/base/_properties-hover.css +107 -0
  23. package/src/base/_properties-lg.css +171 -0
  24. package/src/base/_properties-md.css +171 -0
  25. package/src/base/_properties-open.css +107 -0
  26. package/src/base/_properties-sm.css +171 -0
  27. package/src/base/_properties-starting.css +55 -0
  28. package/src/base/_properties-stuck.css +55 -0
  29. package/src/base/_properties-xl.css +171 -0
  30. package/src/base/_properties.css +555 -0
  31. package/src/base/_reset.css +67 -75
  32. package/src/base/_switches.css +145 -0
  33. package/src/base/_typography.css +437 -370
  34. package/src/base/_utilities-box.css +142 -0
  35. package/src/base/_utilities-color.css +290 -0
  36. package/src/base/_utilities-effects.css +235 -0
  37. package/src/base/_utilities-flow.css +312 -0
  38. package/src/base/_utilities-grid.css +143 -0
  39. package/src/base/_utilities-margin.css +376 -0
  40. package/src/base/_utilities-pseudo.css +426 -0
  41. package/src/base/_utilities-sizing.css +259 -0
  42. package/src/base/_utilities-spacing.css +190 -0
  43. package/src/base/_utilities-tier-2xl.css +93 -0
  44. package/src/base/_utilities-tier-active.css +61 -0
  45. package/src/base/_utilities-tier-checked.css +61 -0
  46. package/src/base/_utilities-tier-current.css +61 -0
  47. package/src/base/_utilities-tier-disabled.css +61 -0
  48. package/src/base/_utilities-tier-focus-visible.css +61 -0
  49. package/src/base/_utilities-tier-focus-within.css +61 -0
  50. package/src/base/_utilities-tier-hover.css +63 -0
  51. package/src/base/_utilities-tier-lg.css +93 -0
  52. package/src/base/_utilities-tier-md.css +93 -0
  53. package/src/base/_utilities-tier-open.css +61 -0
  54. package/src/base/_utilities-tier-sm.css +93 -0
  55. package/src/base/_utilities-tier-starting.css +35 -0
  56. package/src/base/_utilities-tier-stuck.css +114 -0
  57. package/src/base/_utilities-tier-xl.css +93 -0
  58. package/src/base/_utilities-typography.css +141 -0
  59. package/src/base/_variables.css +323 -372
  60. package/src/base/_view-transitions.css +10 -12
  61. package/src/base/command-score.d.ts.map +1 -1
  62. package/src/base/command-score.js +1 -2
  63. package/src/base/command-score.ts +1 -2
  64. package/src/base/dialog-lifecycle.js +1 -1
  65. package/src/base/dialog-lifecycle.ts +1 -1
  66. package/src/base/embla.d.ts +6 -7
  67. package/src/base/embla.d.ts.map +1 -1
  68. package/src/base/embla.js +89 -55
  69. package/src/base/embla.ts +89 -55
  70. package/src/base/hotkeys.d.ts +0 -5
  71. package/src/base/hotkeys.d.ts.map +1 -1
  72. package/src/base/hotkeys.ts +0 -5
  73. package/src/base/navigation.d.ts +12 -1
  74. package/src/base/navigation.d.ts.map +1 -1
  75. package/src/base/navigation.js +229 -86
  76. package/src/base/navigation.ts +224 -92
  77. package/src/base/reveal.js +14 -14
  78. package/src/base/reveal.ts +14 -14
  79. package/src/base/scroll-state.d.ts +21 -0
  80. package/src/base/scroll-state.d.ts.map +1 -0
  81. package/src/base/scroll-state.js +177 -0
  82. package/src/base/scroll-state.ts +188 -0
  83. package/src/base/signals.d.ts +1 -2
  84. package/src/base/signals.d.ts.map +1 -1
  85. package/src/base/signals.js +4 -6
  86. package/src/base/signals.ts +4 -6
  87. package/src/base/style-format.d.ts +33 -0
  88. package/src/base/style-format.d.ts.map +1 -0
  89. package/src/base/style-format.js +160 -0
  90. package/src/base/style-format.ts +180 -0
  91. package/src/base/typeahead.d.ts +19 -4
  92. package/src/base/typeahead.d.ts.map +1 -1
  93. package/src/base/typeahead.js +68 -21
  94. package/src/base/typeahead.ts +73 -23
  95. package/src/base/utilities.d.ts +188 -0
  96. package/src/base/utilities.d.ts.map +1 -0
  97. package/src/base/utilities.js +750 -0
  98. package/src/base/utilities.ts +865 -0
  99. package/src/base/utils.d.ts +3 -7
  100. package/src/base/utils.d.ts.map +1 -1
  101. package/src/base/utils.js +4 -8
  102. package/src/base/utils.ts +4 -8
  103. package/src/base/zazz-element.d.ts +14 -8
  104. package/src/base/zazz-element.d.ts.map +1 -1
  105. package/src/base/zazz-element.js +14 -8
  106. package/src/base/zazz-element.ts +15 -8
  107. package/src/globals.d.ts +1 -1
  108. package/src/head.d.ts +50 -4
  109. package/src/head.d.ts.map +1 -1
  110. package/src/head.js +119 -38
  111. package/src/head.ts +172 -41
  112. package/src/index.css +57 -14
  113. package/src/index.js +5 -0
  114. package/src/index.ts +6 -0
  115. package/src/manifest.d.ts +36 -5
  116. package/src/manifest.d.ts.map +1 -1
  117. package/src/manifest.js +150 -6
  118. package/src/manifest.ts +167 -9
  119. package/src/primitives/accordion/accordion.css +18 -17
  120. package/src/primitives/accordion/accordion.html +42 -9
  121. package/src/primitives/alert-dialog/alert-dialog.css +13 -13
  122. package/src/primitives/alert-dialog/alert-dialog.html +26 -12
  123. package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
  124. package/src/primitives/autocomplete/autocomplete.css +43 -39
  125. package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
  126. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
  127. package/src/primitives/autocomplete/autocomplete.html +38 -26
  128. package/src/primitives/autocomplete/autocomplete.js +6 -5
  129. package/src/primitives/autocomplete/autocomplete.ts +6 -5
  130. package/src/primitives/avatar/avatar.html +110 -15
  131. package/src/primitives/badge/badge-icon.html +22 -8
  132. package/src/primitives/badge/badge.css +401 -128
  133. package/src/primitives/badge/badge.html +12 -6
  134. package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
  135. package/src/primitives/button/button-icon-only.html +17 -11
  136. package/src/primitives/button/button-icon.html +9 -3
  137. package/src/primitives/button/button.css +408 -164
  138. package/src/primitives/button/button.html +14 -7
  139. package/src/primitives/button-group/button-group-vertical.html +5 -5
  140. package/src/primitives/button-group/button-group.css +53 -25
  141. package/src/primitives/button-group/button-group.html +18 -12
  142. package/src/primitives/callout/callout.css +114 -0
  143. package/src/primitives/callout/callout.html +188 -0
  144. package/src/primitives/card/card-subgrid.html +249 -34
  145. package/src/primitives/card/card.css +125 -0
  146. package/src/primitives/card/card.html +141 -20
  147. package/src/primitives/carousel/carousel.css +30 -20
  148. package/src/primitives/carousel/carousel.d.ts +7 -10
  149. package/src/primitives/carousel/carousel.d.ts.map +1 -1
  150. package/src/primitives/carousel/carousel.html +420 -84
  151. package/src/primitives/carousel/carousel.js +1 -1
  152. package/src/primitives/carousel/carousel.ts +8 -11
  153. package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
  154. package/src/primitives/checkbox/checkbox.css +98 -40
  155. package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
  156. package/src/primitives/checkbox/checkbox.html +13 -8
  157. package/src/primitives/checkbox/checkbox.js +7 -9
  158. package/src/primitives/checkbox/checkbox.ts +7 -15
  159. package/src/primitives/combobox/combobox-multiselect.html +53 -33
  160. package/src/primitives/combobox/combobox.css +145 -122
  161. package/src/primitives/combobox/combobox.d.ts +12 -11
  162. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  163. package/src/primitives/combobox/combobox.html +48 -28
  164. package/src/primitives/combobox/combobox.js +46 -51
  165. package/src/primitives/combobox/combobox.ts +48 -55
  166. package/src/primitives/command/command-actions.d.ts +2 -3
  167. package/src/primitives/command/command-actions.d.ts.map +1 -1
  168. package/src/primitives/command/command-actions.html +48 -33
  169. package/src/primitives/command/command-actions.js +12 -10
  170. package/src/primitives/command/command-actions.ts +12 -13
  171. package/src/primitives/command/command-dialog.html +49 -25
  172. package/src/primitives/command/command.css +52 -42
  173. package/src/primitives/command/command.d.ts +10 -7
  174. package/src/primitives/command/command.d.ts.map +1 -1
  175. package/src/primitives/command/command.html +95 -46
  176. package/src/primitives/command/command.js +30 -13
  177. package/src/primitives/command/command.ts +30 -12
  178. package/src/primitives/debug/audit-core.d.ts +64 -0
  179. package/src/primitives/debug/audit-core.d.ts.map +1 -0
  180. package/src/primitives/debug/audit-core.js +356 -0
  181. package/src/primitives/debug/audit-core.ts +535 -0
  182. package/src/primitives/debug/debug.d.ts +50 -0
  183. package/src/primitives/debug/debug.d.ts.map +1 -0
  184. package/src/primitives/debug/debug.js +168 -0
  185. package/src/primitives/debug/debug.ts +211 -0
  186. package/src/primitives/dialog/dialog-with-form.html +67 -45
  187. package/src/primitives/dialog/dialog.css +87 -61
  188. package/src/primitives/dialog/dialog.html +25 -17
  189. package/src/primitives/fields/fields.css +108 -134
  190. package/src/primitives/fields/fields.html +39 -0
  191. package/src/primitives/input/input-icon-leading.html +3 -3
  192. package/src/primitives/input/input-icon-trailing.html +3 -3
  193. package/src/primitives/input/input.css +87 -49
  194. package/src/primitives/input/input.html +15 -15
  195. package/src/primitives/input-group/input-group-password-group.html +15 -15
  196. package/src/primitives/input-group/input-group.css +118 -75
  197. package/src/primitives/input-group/input-group.html +42 -30
  198. package/src/primitives/kbd/kbd-group.html +15 -2
  199. package/src/primitives/kbd/kbd.css +44 -31
  200. package/src/primitives/kbd/kbd.html +7 -1
  201. package/src/primitives/layout/layout.css +159 -0
  202. package/src/primitives/layout/layout.html +35 -0
  203. package/src/primitives/lightbox/lightbox.css +178 -105
  204. package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
  205. package/src/primitives/lightbox/lightbox.html +138 -166
  206. package/src/primitives/lightbox/lightbox.js +10 -13
  207. package/src/primitives/lightbox/lightbox.ts +12 -13
  208. package/src/primitives/menu/menu-interest.html +60 -18
  209. package/src/primitives/menu/menu.css +22 -17
  210. package/src/primitives/menu/menu.d.ts +5 -5
  211. package/src/primitives/menu/menu.html +195 -40
  212. package/src/primitives/menu/menu.js +8 -8
  213. package/src/primitives/menu/menu.ts +8 -8
  214. package/src/primitives/menubar/menubar-help-search.html +78 -32
  215. package/src/primitives/menubar/menubar.html +166 -38
  216. package/src/primitives/meter/meter.css +41 -38
  217. package/src/primitives/meter/meter.html +44 -9
  218. package/src/primitives/mobile-menu/mobile-menu.css +47 -40
  219. package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
  220. package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
  221. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
  222. package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
  223. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
  224. package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
  225. package/src/primitives/navigation-menu/navigation-menu.css +104 -106
  226. package/src/primitives/navigation-menu/navigation-menu.html +554 -158
  227. package/src/primitives/otp/otp.css +43 -44
  228. package/src/primitives/otp/otp.d.ts +4 -5
  229. package/src/primitives/otp/otp.d.ts.map +1 -1
  230. package/src/primitives/otp/otp.html +7 -6
  231. package/src/primitives/otp/otp.js +13 -18
  232. package/src/primitives/otp/otp.ts +12 -19
  233. package/src/primitives/password-group/password-group.css +132 -107
  234. package/src/primitives/password-group/password-group.d.ts.map +1 -1
  235. package/src/primitives/password-group/password-group.html +23 -16
  236. package/src/primitives/password-group/password-group.js +11 -12
  237. package/src/primitives/password-group/password-group.ts +11 -12
  238. package/src/primitives/popover/popover.css +88 -95
  239. package/src/primitives/popover/popover.html +18 -0
  240. package/src/primitives/progress/progress-indeterminate.html +1 -1
  241. package/src/primitives/progress/progress.css +34 -35
  242. package/src/primitives/progress/progress.html +18 -4
  243. package/src/primitives/prose/prose.html +19 -12
  244. package/src/primitives/radio/radio.css +83 -46
  245. package/src/primitives/radio/radio.html +16 -11
  246. package/src/primitives/reveal/reveal.css +37 -46
  247. package/src/primitives/reveal/reveal.html +15 -0
  248. package/src/primitives/scroll-fade/scroll-fade.css +115 -0
  249. package/src/primitives/scroll-fade/scroll-fade.html +69 -0
  250. package/src/primitives/select/multiselect.d.ts +8 -10
  251. package/src/primitives/select/multiselect.d.ts.map +1 -1
  252. package/src/primitives/select/multiselect.js +23 -27
  253. package/src/primitives/select/multiselect.ts +23 -29
  254. package/src/primitives/select/select-align.html +79 -16
  255. package/src/primitives/select/select-multiple.html +8 -4
  256. package/src/primitives/select/select-sides.html +104 -21
  257. package/src/primitives/select/select.css +297 -186
  258. package/src/primitives/select/select.html +24 -5
  259. package/src/primitives/separator/separator.css +15 -18
  260. package/src/primitives/separator/separator.html +37 -10
  261. package/src/primitives/slider/slider.css +48 -38
  262. package/src/primitives/slider/slider.html +9 -1
  263. package/src/primitives/style-guard/style-guard.d.ts +19 -0
  264. package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
  265. package/src/primitives/style-guard/style-guard.js +125 -0
  266. package/src/primitives/style-guard/style-guard.ts +153 -0
  267. package/src/primitives/switch/switch.css +42 -33
  268. package/src/primitives/switch/switch.html +11 -6
  269. package/src/primitives/table/table-alternating.html +1 -1
  270. package/src/primitives/table/table-grid.html +5 -5
  271. package/src/primitives/table/table-size-sm.html +1 -1
  272. package/src/primitives/table/table.css +64 -61
  273. package/src/primitives/table/table.html +7 -7
  274. package/src/primitives/tabs/tabs.css +167 -166
  275. package/src/primitives/tabs/tabs.d.ts +10 -11
  276. package/src/primitives/tabs/tabs.d.ts.map +1 -1
  277. package/src/primitives/tabs/tabs.html +192 -36
  278. package/src/primitives/tabs/tabs.js +14 -15
  279. package/src/primitives/tabs/tabs.ts +14 -15
  280. package/src/primitives/textarea/textarea.css +69 -44
  281. package/src/primitives/textarea/textarea.html +3 -3
  282. package/src/primitives/toaster/toaster.css +90 -92
  283. package/src/primitives/toaster/toaster.d.ts +0 -6
  284. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  285. package/src/primitives/toaster/toaster.html +22 -18
  286. package/src/primitives/toaster/toaster.js +64 -72
  287. package/src/primitives/toaster/toaster.ts +71 -87
  288. package/src/primitives/toggle/toggle.css +368 -153
  289. package/src/primitives/toggle/toggle.html +27 -9
  290. package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
  291. package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
  292. package/src/primitives/toggle-group/toggle-group.css +71 -23
  293. package/src/primitives/toggle-group/toggle-group.html +3 -3
  294. package/src/primitives/toolbar/toolbar.html +35 -13
  295. package/src/primitives/tooltip/tooltip-disabled.html +3 -3
  296. package/src/primitives/tooltip/tooltip-sides.html +36 -14
  297. package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
  298. package/src/primitives/tooltip/tooltip.css +111 -80
  299. package/src/primitives/tooltip/tooltip.html +3 -3
  300. package/src/primitives/utilities/aspect-ratio.html +51 -7
  301. package/src/primitives/utilities/basis.html +64 -11
  302. package/src/primitives/utilities/col-span.html +65 -9
  303. package/src/primitives/utilities/compose.html +48 -10
  304. package/src/primitives/utilities/flex-align.html +89 -19
  305. package/src/primitives/utilities/flex-direction.html +111 -13
  306. package/src/primitives/utilities/flex-grow.html +41 -7
  307. package/src/primitives/utilities/gap.html +158 -19
  308. package/src/primitives/utilities/grid-cols.html +75 -7
  309. package/src/primitives/utilities/grid-responsive.html +111 -12
  310. package/src/primitives/utilities/margin-auto.html +38 -7
  311. package/src/primitives/utilities/object-fit.html +75 -13
  312. package/src/primitives/utilities/order.html +40 -4
  313. package/src/primitives/utilities/overflow.html +74 -20
  314. package/src/primitives/utilities/padding-compose.html +67 -10
  315. package/src/primitives/utilities/padding.html +84 -13
  316. package/src/primitives/utilities/pile.html +29 -0
  317. package/src/primitives/utilities/position.html +65 -8
  318. package/src/primitives/utilities/responsive-flex.html +54 -7
  319. package/src/primitives/utilities/responsive-grid.html +115 -12
  320. package/src/primitives/utilities/size.html +120 -16
  321. package/src/primitives/utilities/width.html +123 -16
  322. package/examples/about.html +0 -583
  323. package/examples/components.html +0 -1028
  324. package/examples/forms.html +0 -504
  325. package/examples/index.html +0 -261
  326. package/examples/layout.html +0 -313
  327. package/examples/products.html +0 -839
  328. package/examples/responsive.html +0 -332
  329. package/src/base/_layout.css +0 -571
  330. package/src/base/_utilities.css +0 -6758
  331. package/src/primitives/utilities/grid-pile.html +0 -5
@@ -3,46 +3,38 @@
3
3
  /**
4
4
  * @fileoverview `<ui-toaster>`: HTML web component for stacked toast notifications.
5
5
  * @description Light-DOM custom element that hosts a top-layer toast stack, plus
6
- * the `window.Toaster` imperative API. The stacking model (newest toast in front,
7
- * older toasts peeking behind, expand on hover, timer pause on hover/hidden tab)
8
- * is adapted from Sonner by Emil Kowalski (https://sonner.emilkowal.ski, MIT).
6
+ * the `window.Toaster` imperative API. Timers pause on hover and in hidden tabs.
9
7
  *
10
8
  * The region is a `popover="manual"` element: it enters the top layer via
11
9
  * `showPopover()` when the first toast arrives and leaves it after the last
12
10
  * toast's exit transition. Toasts are plain `<li>` children, so the collapsed
13
- * stack offsets in `_toaster.css` work with normal CSS transforms.
11
+ * stack offsets in `toaster.css` work with normal CSS transforms.
14
12
  *
15
13
  * Fire toasts two ways:
16
14
  * - Declaratively, from any button, via a custom Invoker Command:
17
15
  * `command="--toast"` (or `--toast-success|info|warning|destructive`) with
18
16
  * `commandfor="<region id>"`. Toast content comes from the button's
19
- * `data-title`, `data-description`, `data-variant`, `data-duration`, and
20
- * `data-close-button` attributes.
17
+ * `data-toaster-title`, `data-toaster-description`, `data-toaster-variant`,
18
+ * `data-toaster-duration`, and `data-toaster-close-button` attributes.
21
19
  * - Imperatively: `window.Toaster.toast({ title, description, variant, … })`
22
20
  * and the `.success()/.info()/.warning()/.error()` shorthands.
23
21
  *
24
22
  * Region attributes:
25
- * - `data-position`: `top-start | top-center | top-end | bottom-start |
23
+ * - `data-toaster-position`: `top-start | top-center | top-end | bottom-start |
26
24
  * bottom-center | bottom-end` (logical; default `bottom-end`).
27
25
  *
28
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
29
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API
30
- *
31
26
  * @example
32
- * <ui-toaster class="ui-toaster" id="toaster" popover="manual"></ui-toaster>
33
- * <button commandfor="toaster" command="--toast" data-title="Saved">Save</button>
27
+ * <ui-toaster id="toaster" popover="manual"></ui-toaster>
28
+ * <button commandfor="toaster" command="--toast" data-toaster-title="Saved">Save</button>
34
29
  */
35
30
 
36
31
  import { computed, effect, state } from "../../base/signals.ts";
37
32
  import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
38
33
 
39
- // `using` compiles (target ES2022) to try/finally helpers that read this
40
- // well-known symbol at runtime; engines without native Explicit Resource
41
- // Management (Safari) don't define it, so give them a local stand-in.
34
+ // compiled `using` reads Symbol.dispose, which engines without native Explicit
35
+ // Resource Management (Safari) lack
42
36
  (Symbol as { dispose: symbol }).dispose ??= Symbol("Symbol.dispose");
43
37
 
44
- // --- Constants ---
45
-
46
38
  /** Default toast lifetime in milliseconds. */
47
39
  const TOAST_LIFETIME = 4000;
48
40
 
@@ -54,8 +46,6 @@ const EXIT_FALLBACK_MS = 600;
54
46
 
55
47
  const VARIANTS: ReadonlyArray<string> = ["success", "info", "warning", "destructive"];
56
48
 
57
- // --- Icons (adapted from Sonner's assets.tsx (MIT, Emil Kowalski)) ---
58
-
59
49
  const ICONS: Record<string, string> = {
60
50
  success:
61
51
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"/></svg>',
@@ -68,8 +58,6 @@ const ICONS: Record<string, string> = {
68
58
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
69
59
  };
70
60
 
71
- // --- Typedefs ---
72
-
73
61
  interface ToastAction {
74
62
  /** Button label. */
75
63
  label: string;
@@ -125,8 +113,6 @@ interface ToastStackLayout {
125
113
  visible: boolean;
126
114
  }
127
115
 
128
- // --- Measurement ---
129
-
130
116
  /**
131
117
  * @description Unclamps every toast's block-size for a batch measurement (the
132
118
  * inline style beats the collapsed block-size rule) and returns a disposer
@@ -146,8 +132,6 @@ function unclampForMeasure(toasts: readonly HTMLElement[]): Disposable {
146
132
  };
147
133
  }
148
134
 
149
- // --- Stack math (pure) ---
150
-
151
135
  /**
152
136
  * @description Computes the collapsed-stack placement for every toast from the
153
137
  * measured heights alone (oldest first, matching DOM order). Pure: the
@@ -180,14 +164,29 @@ function computeStackLayout(heights: number[]): {
180
164
  return { toasts, frontToastHeightPx: count > 0 ? heights[count - 1] : null };
181
165
  }
182
166
 
183
- // --- <ui-toaster> element ---
184
-
185
167
  /**
186
168
  * @class
187
169
  * @description Hosts the toast stack: builds toast markup, maintains the
188
170
  * collapsed-stack CSS custom properties, runs auto-dismiss timers, and shows or
189
171
  * hides the `popover="manual"` region as toasts come and go.
190
172
  */
173
+
174
+ /**
175
+ * @description Adds or removes one token of an element's `data-toaster-state`
176
+ * list: `expanded` on the region; `front`, `visible`, `removed` on a toast.
177
+ */
178
+ function setToasterState(node: Element, token: string, on: boolean): void {
179
+ const tokens = (node.getAttribute("data-toaster-state") ?? "").split(/\s+/).filter(Boolean);
180
+ const next = on ? [...new Set([...tokens, token])] : tokens.filter((t) => t !== token);
181
+ if (next.length) node.setAttribute("data-toaster-state", next.join(" "));
182
+ else node.removeAttribute("data-toaster-state");
183
+ }
184
+
185
+ /** @description Whether a toast has been dismissed and is animating out. */
186
+ function isRemoved(toast: Element): boolean {
187
+ return toast.matches('[data-toaster-state~="removed"]');
188
+ }
189
+
191
190
  class UiToaster extends ZazzElement {
192
191
  #timers: Map<string, ToastTimer> = new Map();
193
192
 
@@ -224,9 +223,9 @@ class UiToaster extends ZazzElement {
224
223
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "-1");
225
224
 
226
225
  // The live region must exist before toasts are inserted so additions announce.
227
- if (!this.querySelector('[data-slot~="toaster-list"]')) {
226
+ if (!this.querySelector('[data-toaster-slot~="list"]')) {
228
227
  const list = document.createElement("ol");
229
- list.setAttribute("data-slot", "toaster-list");
228
+ list.setAttribute("data-toaster-slot", "list");
230
229
  list.setAttribute("aria-live", "polite");
231
230
  list.setAttribute("aria-relevant", "additions text");
232
231
  list.setAttribute("aria-atomic", "false");
@@ -263,7 +262,7 @@ class UiToaster extends ZazzElement {
263
262
  // one writes the computed stack placement to the DOM.
264
263
  effect(
265
264
  () => {
266
- this.dataset.expanded = String(this.#expanded.get());
265
+ setToasterState(this, "expanded", this.#expanded.get());
267
266
  },
268
267
  { signal },
269
268
  );
@@ -287,8 +286,8 @@ class UiToaster extends ZazzElement {
287
286
  for (let i = 0; i < entries.length; i++) {
288
287
  const { node, height } = entries[i];
289
288
  const layout = toasts[i];
290
- node.dataset.front = String(layout.front);
291
- node.dataset.visible = String(layout.visible);
289
+ setToasterState(node, "front", layout.front);
290
+ setToasterState(node, "visible", layout.visible);
292
291
  node.style.zIndex = String(layout.zIndex);
293
292
  node.style.setProperty("--toasts-before", String(layout.stackIndex));
294
293
  node.style.setProperty("--initial-height", `${height}px`);
@@ -313,8 +312,6 @@ class UiToaster extends ZazzElement {
313
312
  this.#timers.clear();
314
313
  }
315
314
 
316
- // --- Public API ---
317
-
318
315
  /**
319
316
  * @description Adds a toast to this region and shows the region if needed.
320
317
  *
@@ -347,14 +344,14 @@ class UiToaster extends ZazzElement {
347
344
  return;
348
345
  }
349
346
 
350
- const toast = this.#list().querySelector(`[data-toast-id="${CSS.escape(id)}"]`);
351
- if (!(toast instanceof HTMLElement) || toast.dataset.removed === "true") return;
347
+ const toast = this.#list().querySelector(`[data-toaster-id="${CSS.escape(id)}"]`);
348
+ if (!(toast instanceof HTMLElement) || isRemoved(toast)) return;
352
349
 
353
350
  const timer = this.#timers.get(id);
354
351
  if (timer) clearTimeout(timer.timeoutId);
355
352
  this.#timers.delete(id);
356
353
 
357
- toast.dataset.removed = "true";
354
+ setToasterState(toast, "removed", true);
358
355
 
359
356
  // Keyboard users keep their place: hand focus to the next toast before this
360
357
  // one goes. A mouse click's incidental focus is left to drop to <body>;
@@ -367,7 +364,7 @@ class UiToaster extends ZazzElement {
367
364
  active.matches(":focus-visible")
368
365
  ) {
369
366
  this.#toasts()
370
- .filter((t) => t.dataset.removed !== "true")
367
+ .filter((t) => !isRemoved(t))
371
368
  .at(-1)
372
369
  ?.focus({ preventScroll: true });
373
370
  }
@@ -381,17 +378,15 @@ class UiToaster extends ZazzElement {
381
378
  */
382
379
  dismissAll(): void {
383
380
  for (const toast of this.#toasts()) {
384
- const toastId = toast.dataset.toastId;
381
+ const toastId = toast.dataset.toasterId;
385
382
  if (toastId) this.dismiss(toastId);
386
383
  }
387
384
  }
388
385
 
389
- // --- Invoker Commands ---
390
-
391
386
  /**
392
387
  * @description Handles the custom `--toast` Invoker Command fired by buttons
393
388
  * with `commandfor` pointing at this region. `--toast-success` (etc.) sets the
394
- * variant; everything else comes from the invoker's `data-*` attributes.
389
+ * variant; everything else comes from the invoker's `data-toaster-*` attributes.
395
390
  *
396
391
  * @param event - The command event.
397
392
  */
@@ -418,7 +413,13 @@ class UiToaster extends ZazzElement {
418
413
  }
419
414
 
420
415
  if (source instanceof HTMLElement) {
421
- const { title, description, variant, duration, closeButton } = source.dataset;
416
+ const {
417
+ toasterTitle: title,
418
+ toasterDescription: description,
419
+ toasterVariant: variant,
420
+ toasterDuration: duration,
421
+ toasterCloseButton: closeButton,
422
+ } = source.dataset;
422
423
  if (title) options.title = title;
423
424
  if (description) options.description = description;
424
425
  if (!options.variant && variant && VARIANTS.includes(variant)) {
@@ -439,8 +440,6 @@ class UiToaster extends ZazzElement {
439
440
  this.addToast(options);
440
441
  }
441
442
 
442
- // --- Toast construction ---
443
-
444
443
  /**
445
444
  * @description Builds a toast `<li>`: status icon, title/description, and the
446
445
  * optional action and close buttons. Text is set via `textContent`.
@@ -451,30 +450,30 @@ class UiToaster extends ZazzElement {
451
450
  */
452
451
  #buildToast(options: ToastOptions, id: string): HTMLLIElement {
453
452
  const toast = document.createElement("li");
454
- toast.setAttribute("data-slot", "toaster-toast");
455
- toast.dataset.toastId = id;
453
+ toast.setAttribute("data-toaster-slot", "toast");
454
+ toast.dataset.toasterId = id;
456
455
  toast.tabIndex = 0;
457
- if (options.variant) toast.dataset.variant = options.variant;
456
+ if (options.variant) toast.dataset.toasterVariant = options.variant;
458
457
 
459
458
  if (options.variant) {
460
459
  const icon = document.createElement("span");
461
- icon.setAttribute("data-slot", "toaster-icon");
460
+ icon.setAttribute("data-toaster-slot", "icon");
462
461
  icon.setAttribute("aria-hidden", "true");
463
462
  icon.innerHTML = ICONS[options.variant];
464
463
  toast.append(icon);
465
464
  }
466
465
 
467
466
  const content = document.createElement("div");
468
- content.setAttribute("data-slot", "toaster-content");
467
+ content.setAttribute("data-toaster-slot", "content");
469
468
  if (options.title) {
470
469
  const title = document.createElement("div");
471
- title.setAttribute("data-slot", "toaster-title");
470
+ title.setAttribute("data-toaster-slot", "title");
472
471
  title.textContent = options.title;
473
472
  content.append(title);
474
473
  }
475
474
  if (options.description) {
476
475
  const description = document.createElement("div");
477
- description.setAttribute("data-slot", "toaster-description");
476
+ description.setAttribute("data-toaster-slot", "description");
478
477
  description.textContent = options.description;
479
478
  content.append(description);
480
479
  }
@@ -484,9 +483,9 @@ class UiToaster extends ZazzElement {
484
483
  if (action) {
485
484
  const button = document.createElement("button");
486
485
  button.type = "button";
487
- button.className = "ui-button";
488
- button.setAttribute("data-slot", "toaster-action");
489
- button.dataset.size = "sm";
486
+ button.dataset.ui = "button";
487
+ button.setAttribute("data-toaster-slot", "action");
488
+ button.dataset.buttonSize = "sm";
490
489
  button.textContent = action.label;
491
490
  button.addEventListener("click", (event) => {
492
491
  action.onClick?.(event);
@@ -498,10 +497,10 @@ class UiToaster extends ZazzElement {
498
497
  if (options.closeButton !== false) {
499
498
  const close = document.createElement("button");
500
499
  close.type = "button";
501
- close.className = "ui-button";
502
- close.setAttribute("data-slot", "toaster-close");
503
- close.dataset.variant = "ghost";
504
- close.dataset.size = "icon-sm";
500
+ close.dataset.ui = "button";
501
+ close.setAttribute("data-toaster-slot", "close");
502
+ close.dataset.buttonVariant = "ghost";
503
+ close.dataset.buttonSize = "icon-sm";
505
504
  close.setAttribute("aria-label", "Close notification");
506
505
  close.innerHTML = ICONS.close;
507
506
  close.addEventListener("click", () => this.dismiss(id));
@@ -511,20 +510,18 @@ class UiToaster extends ZazzElement {
511
510
  return toast;
512
511
  }
513
512
 
514
- // --- Stack math ---
515
-
516
513
  /**
517
514
  * @description Remeasures the stack: the measure half of the stacking
518
515
  * model. Batch-reads every live toast's natural height and writes the
519
516
  * result into `#stack`; `#layout` derives the placement purely
520
517
  * (`computeStackLayout`) and the stack effect writes the CSS custom
521
- * properties `_toaster.css` reads (`--toasts-before`, `--offset`,
522
- * `--initial-height`, `--front-toast-height`) plus `data-front`,
523
- * `data-visible`, and z-index. DOM order is chronological; the last child
518
+ * properties `toaster.css` reads (`--toasts-before`, `--offset`,
519
+ * `--initial-height`, `--front-toast-height`) plus `data-toaster-state~="front"`,
520
+ * `data-toaster-state~="visible"`, and z-index. DOM order is chronological; the last child
524
521
  * is the front (newest) toast.
525
522
  */
526
523
  #reindex(): void {
527
- const toasts = this.#toasts().filter((toast) => toast.dataset.removed !== "true");
524
+ const toasts = this.#toasts().filter((toast) => !isRemoved(toast));
528
525
 
529
526
  // Batch-measure with heights unclamped, restored at scope exit: one
530
527
  // layout pass, no visible change (the stack effect is microtask-batched,
@@ -539,10 +536,10 @@ class UiToaster extends ZazzElement {
539
536
  * @returns The toast list (created in `connectedCallback`).
540
537
  */
541
538
  #list(): HTMLOListElement {
542
- let list = this.querySelector('[data-slot~="toaster-list"]');
539
+ let list = this.querySelector('[data-toaster-slot~="list"]');
543
540
  if (!(list instanceof HTMLOListElement)) {
544
541
  list = document.createElement("ol");
545
- list.setAttribute("data-slot", "toaster-list");
542
+ list.setAttribute("data-toaster-slot", "list");
546
543
  this.append(list);
547
544
  }
548
545
  return list as HTMLOListElement;
@@ -554,14 +551,12 @@ class UiToaster extends ZazzElement {
554
551
  #toasts(): HTMLElement[] {
555
552
  return Array.from(this.#list().children)
556
553
  .filter((child): child is HTMLElement => child instanceof HTMLElement)
557
- .filter((child) => child.matches('[data-slot~="toaster-toast"]'));
554
+ .filter((child) => child.matches('[data-toaster-slot~="toast"]'));
558
555
  }
559
556
 
560
- // --- Expand / collapse ---
561
-
562
557
  /**
563
558
  * @description Expands or collapses the stack by writing the signal state.
564
- * The attribute write and the timer pause/resume (matching Sonner) are owned
559
+ * The attribute write and the timer pause/resume are owned
565
560
  * by the effects in `connectedCallback`: no caller has to remember them.
566
561
  *
567
562
  * @param expanded - Whether the stack is expanded.
@@ -586,8 +581,6 @@ class UiToaster extends ZazzElement {
586
581
  }, 100);
587
582
  }
588
583
 
589
- // --- Timers ---
590
-
591
584
  /**
592
585
  * @description Registers a toast's auto-dismiss timer and schedules it unless
593
586
  * the stack is currently paused (expanded or hidden tab).
@@ -635,8 +628,6 @@ class UiToaster extends ZazzElement {
635
628
  }
636
629
  }
637
630
 
638
- // --- Region show/hide ---
639
-
640
631
  /**
641
632
  * @description Puts the region on the top layer if it isn't already.
642
633
  */
@@ -644,8 +635,7 @@ class UiToaster extends ZazzElement {
644
635
  try {
645
636
  if (!this.matches(":popover-open")) this.showPopover();
646
637
  } catch {
647
- // Older engines without the Popover API: the region stays a fixed-position
648
- // element, which still renders (just not on the top layer).
638
+ // without the Popover API the region stays a fixed-position element
649
639
  }
650
640
  }
651
641
 
@@ -664,7 +654,7 @@ class UiToaster extends ZazzElement {
664
654
  * @description Removes a dismissed toast after its exit transition (with a
665
655
  * timeout safety net), then hides the region once the stack is empty.
666
656
  *
667
- * @param toast - The toast marked `data-removed="true"`.
657
+ * @param toast - The toast marked `data-toaster-state~="removed"`.
668
658
  */
669
659
  #finalizeRemoval(toast: HTMLElement): void {
670
660
  let done = false;
@@ -692,8 +682,6 @@ class UiToaster extends ZazzElement {
692
682
  }
693
683
  }
694
684
 
695
- // --- Imperative API ---
696
-
697
685
  /**
698
686
  * @description Resolves a target region from an id, element, or the document.
699
687
  *
@@ -707,12 +695,12 @@ function resolveRegion(region?: string | Element): UiToaster | null {
707
695
  ? region
708
696
  : typeof region === "string"
709
697
  ? document.getElementById(region)
710
- : document.querySelector("ui-toaster");
698
+ : document.querySelector('ui-toaster, [data-ui~="toaster"]');
711
699
 
712
700
  if (node instanceof UiToaster) return node;
713
701
 
714
702
  console.warn(
715
- 'Toaster: no <ui-toaster> found. Add `<ui-toaster class="ui-toaster" popover="manual"></ui-toaster>` to the page.',
703
+ 'Toaster: no <ui-toaster> found. Add `<ui-toaster popover="manual"></ui-toaster>` to the page.',
716
704
  );
717
705
  return null;
718
706
  }
@@ -804,7 +792,7 @@ const Toaster = {
804
792
  * @param id - Toast id returned by `toast()`.
805
793
  */
806
794
  dismiss(id?: string): void {
807
- for (const region of document.querySelectorAll("ui-toaster")) {
795
+ for (const region of document.querySelectorAll('ui-toaster, [data-ui~="toaster"]')) {
808
796
  if (region instanceof UiToaster) region.dismiss(id);
809
797
  }
810
798
  },
@@ -812,12 +800,8 @@ const Toaster = {
812
800
 
813
801
  defineZazzElement("ui-toaster", UiToaster);
814
802
 
815
- // Attach the imperative toast API to window (the documented public surface app
816
- // authors call), then export for module consumers.
817
803
  if (typeof window !== "undefined") {
818
804
  window.Toaster = Toaster;
819
805
  }
820
806
 
821
- // computeStackLayout is exported for unit tests only; not part of the
822
- // documented public API (window.Toaster is the surface app authors use).
823
807
  export { Toaster, UiToaster, computeStackLayout };