@funstack/ui 0.1.0-alpha.10 → 0.1.0-alpha.12

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 (404) hide show
  1. package/dist/accordion/accordion-context.mjs.map +1 -1
  2. package/dist/accordion/accordion-item.d.mts +3 -4
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +10 -4
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +3 -4
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -1
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +3 -3
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +8 -19
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +3 -4
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +5 -3
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/button/button.d.mts +4 -2
  19. package/dist/button/button.d.mts.map +1 -1
  20. package/dist/button/button.mjs +3 -2
  21. package/dist/button/button.mjs.map +1 -1
  22. package/dist/checkbox/checkbox.d.mts +4 -5
  23. package/dist/checkbox/checkbox.d.mts.map +1 -1
  24. package/dist/checkbox/checkbox.mjs +16 -59
  25. package/dist/checkbox/checkbox.mjs.map +1 -1
  26. package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
  27. package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
  28. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  29. package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
  30. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  31. package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
  32. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
  34. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
  36. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
  38. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
  40. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  41. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  42. package/dist/combobox/combobox-clear.mjs +5 -6
  43. package/dist/combobox/combobox-clear.mjs.map +1 -1
  44. package/dist/combobox/combobox-context.mjs.map +1 -1
  45. package/dist/combobox/combobox-group.d.mts.map +1 -1
  46. package/dist/combobox/combobox-group.mjs +2 -1
  47. package/dist/combobox/combobox-group.mjs.map +1 -1
  48. package/dist/combobox/combobox-input.d.mts.map +1 -1
  49. package/dist/combobox/combobox-input.mjs +14 -7
  50. package/dist/combobox/combobox-input.mjs.map +1 -1
  51. package/dist/combobox/combobox-list.d.mts.map +1 -1
  52. package/dist/combobox/combobox-list.mjs +6 -10
  53. package/dist/combobox/combobox-list.mjs.map +1 -1
  54. package/dist/combobox/combobox-option.d.mts.map +1 -1
  55. package/dist/combobox/combobox-option.mjs +2 -1
  56. package/dist/combobox/combobox-option.mjs.map +1 -1
  57. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  58. package/dist/combobox/combobox-popup.mjs +9 -25
  59. package/dist/combobox/combobox-popup.mjs.map +1 -1
  60. package/dist/combobox/combobox-root.d.mts +11 -10
  61. package/dist/combobox/combobox-root.d.mts.map +1 -1
  62. package/dist/combobox/combobox-root.mjs +37 -109
  63. package/dist/combobox/combobox-root.mjs.map +1 -1
  64. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  65. package/dist/combobox/combobox-trigger.mjs +6 -25
  66. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  67. package/dist/combobox/index.d.mts +2 -2
  68. package/dist/combobox/index.mjs +3 -3
  69. package/dist/combobox/index.mjs.map +1 -1
  70. package/dist/combobox/use-combobox-form.mjs +56 -0
  71. package/dist/combobox/use-combobox-form.mjs.map +1 -0
  72. package/dist/combobox/use-option-registry.mjs +62 -0
  73. package/dist/combobox/use-option-registry.mjs.map +1 -0
  74. package/dist/dialog/dialog-close.d.mts.map +1 -1
  75. package/dist/dialog/dialog-close.mjs +29 -62
  76. package/dist/dialog/dialog-close.mjs.map +1 -1
  77. package/dist/dialog/dialog-context.mjs.map +1 -1
  78. package/dist/dialog/dialog-form.d.mts.map +1 -1
  79. package/dist/dialog/dialog-form.mjs +5 -4
  80. package/dist/dialog/dialog-form.mjs.map +1 -1
  81. package/dist/dialog/dialog-popup.d.mts +3 -4
  82. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  83. package/dist/dialog/dialog-popup.mjs +37 -98
  84. package/dist/dialog/dialog-popup.mjs.map +1 -1
  85. package/dist/dialog/dialog-root.d.mts.map +1 -1
  86. package/dist/dialog/dialog-root.mjs +30 -118
  87. package/dist/dialog/dialog-root.mjs.map +1 -1
  88. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  89. package/dist/dialog/dialog-trigger.mjs +13 -16
  90. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  91. package/dist/field/field-control.mjs +6 -13
  92. package/dist/field/field-control.mjs.map +1 -1
  93. package/dist/field/field-description.d.mts.map +1 -1
  94. package/dist/field/field-description.mjs +1 -2
  95. package/dist/field/field-description.mjs.map +1 -1
  96. package/dist/field/field-error.d.mts.map +1 -1
  97. package/dist/field/field-error.mjs +1 -2
  98. package/dist/field/field-error.mjs.map +1 -1
  99. package/dist/field/field-label.d.mts.map +1 -1
  100. package/dist/field/field-label.mjs +3 -11
  101. package/dist/field/field-label.mjs.map +1 -1
  102. package/dist/field/field-root.mjs +21 -41
  103. package/dist/field/field-root.mjs.map +1 -1
  104. package/dist/field/index.mjs +1 -1
  105. package/dist/field/use-server-error-visibility.mjs +44 -0
  106. package/dist/field/use-server-error-visibility.mjs.map +1 -0
  107. package/dist/form/form-root.d.mts.map +1 -1
  108. package/dist/form/form-root.mjs +6 -7
  109. package/dist/form/form-root.mjs.map +1 -1
  110. package/dist/form/form-submit.d.mts +1 -1
  111. package/dist/form/form-submit.mjs +4 -10
  112. package/dist/form/form-submit.mjs.map +1 -1
  113. package/dist/index.d.mts +4 -4
  114. package/dist/internal/anchor-position.mjs +1 -59
  115. package/dist/internal/anchor-position.mjs.map +1 -1
  116. package/dist/internal/announce.mjs.map +1 -1
  117. package/dist/internal/arrow-keys.mjs +21 -0
  118. package/dist/internal/arrow-keys.mjs.map +1 -0
  119. package/dist/internal/decimal.mjs +7 -1
  120. package/dist/internal/decimal.mjs.map +1 -1
  121. package/dist/internal/dom-order.mjs +17 -0
  122. package/dist/internal/dom-order.mjs.map +1 -0
  123. package/dist/internal/field-context.d.mts.map +1 -1
  124. package/dist/internal/field-context.mjs +11 -1
  125. package/dist/internal/field-context.mjs.map +1 -1
  126. package/dist/internal/focus-first-invalid.mjs +1 -1
  127. package/dist/internal/focus-first-invalid.mjs.map +1 -1
  128. package/dist/internal/group-member.mjs +37 -0
  129. package/dist/internal/group-member.mjs.map +1 -0
  130. package/dist/internal/overlay-popup.mjs +103 -0
  131. package/dist/internal/overlay-popup.mjs.map +1 -0
  132. package/dist/internal/popover-open.mjs +18 -0
  133. package/dist/internal/popover-open.mjs.map +1 -0
  134. package/dist/internal/render-element.d.mts +2 -0
  135. package/dist/internal/render-element.mjs +20 -2
  136. package/dist/internal/render-element.mjs.map +1 -1
  137. package/dist/internal/shipped-styles.mjs +14 -0
  138. package/dist/internal/shipped-styles.mjs.map +1 -0
  139. package/dist/internal/sync-presence.mjs +5 -1
  140. package/dist/internal/sync-presence.mjs.map +1 -1
  141. package/dist/internal/toolbar-context.mjs.map +1 -1
  142. package/dist/internal/tooltip-warm.mjs +1 -1
  143. package/dist/internal/tooltip-warm.mjs.map +1 -1
  144. package/dist/internal/transition-boundary.mjs +1 -1
  145. package/dist/internal/transition-boundary.mjs.map +1 -1
  146. package/dist/internal/types.d.mts +8 -6
  147. package/dist/internal/types.d.mts.map +1 -1
  148. package/dist/internal/use-action-trigger.mjs +5 -23
  149. package/dist/internal/use-action-trigger.mjs.map +1 -1
  150. package/dist/internal/use-checkable-input.mjs +79 -0
  151. package/dist/internal/use-checkable-input.mjs.map +1 -0
  152. package/dist/internal/use-controllable-action.mjs +16 -24
  153. package/dist/internal/use-controllable-action.mjs.map +1 -1
  154. package/dist/internal/use-dev-warning.mjs +8 -4
  155. package/dist/internal/use-dev-warning.mjs.map +1 -1
  156. package/dist/internal/use-element-check.mjs +39 -0
  157. package/dist/internal/use-element-check.mjs.map +1 -0
  158. package/dist/internal/use-exit-animation.mjs +1 -1
  159. package/dist/internal/use-exit-animation.mjs.map +1 -1
  160. package/dist/internal/use-field-control.mjs +28 -12
  161. package/dist/internal/use-field-control.mjs.map +1 -1
  162. package/dist/internal/use-fieldset-group.mjs +46 -0
  163. package/dist/internal/use-fieldset-group.mjs.map +1 -0
  164. package/dist/internal/use-form-reset.mjs +1 -5
  165. package/dist/internal/use-form-reset.mjs.map +1 -1
  166. package/dist/internal/use-item-order.mjs +42 -0
  167. package/dist/internal/use-item-order.mjs.map +1 -0
  168. package/dist/internal/use-latest.mjs +4 -8
  169. package/dist/internal/use-latest.mjs.map +1 -1
  170. package/dist/internal/use-merged-refs.mjs +19 -0
  171. package/dist/internal/use-merged-refs.mjs.map +1 -0
  172. package/dist/internal/use-name-warning.mjs +84 -0
  173. package/dist/internal/use-name-warning.mjs.map +1 -0
  174. package/dist/internal/use-native-checked.mjs +4 -6
  175. package/dist/internal/use-native-checked.mjs.map +1 -1
  176. package/dist/internal/use-native-focusgroup.mjs +19 -0
  177. package/dist/internal/use-native-focusgroup.mjs.map +1 -0
  178. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  179. package/dist/internal/use-overlay-close.mjs +63 -0
  180. package/dist/internal/use-overlay-close.mjs.map +1 -0
  181. package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
  182. package/dist/internal/use-overlay-root.mjs.map +1 -0
  183. package/dist/internal/use-popover-popup.mjs +32 -78
  184. package/dist/internal/use-popover-popup.mjs.map +1 -1
  185. package/dist/internal/use-popover-trigger.d.mts +15 -0
  186. package/dist/internal/use-popover-trigger.d.mts.map +1 -0
  187. package/dist/internal/use-popover-trigger.mjs +13 -17
  188. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  189. package/dist/internal/use-register-count.mjs +24 -0
  190. package/dist/internal/use-register-count.mjs.map +1 -0
  191. package/dist/internal/use-render.d.mts +2 -0
  192. package/dist/internal/use-render.mjs +2 -2
  193. package/dist/internal/use-render.mjs.map +1 -1
  194. package/dist/internal/use-resolved-placement.mjs +38 -22
  195. package/dist/internal/use-resolved-placement.mjs.map +1 -1
  196. package/dist/internal/use-roving-focus.mjs +5 -18
  197. package/dist/internal/use-roving-focus.mjs.map +1 -1
  198. package/dist/internal/use-superseded-rejection.mjs +47 -0
  199. package/dist/internal/use-superseded-rejection.mjs.map +1 -0
  200. package/dist/internal/validity.mjs +1 -13
  201. package/dist/internal/validity.mjs.map +1 -1
  202. package/dist/internal/value-set.mjs +41 -0
  203. package/dist/internal/value-set.mjs.map +1 -0
  204. package/dist/menu/index.d.mts +1 -1
  205. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  206. package/dist/menu/menu-context-trigger.d.mts +2 -7
  207. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  208. package/dist/menu/menu-context-trigger.mjs +10 -187
  209. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  210. package/dist/menu/menu-context.d.mts +1 -1
  211. package/dist/menu/menu-context.mjs +1 -1
  212. package/dist/menu/menu-context.mjs.map +1 -1
  213. package/dist/menu/menu-dom.mjs +1 -2
  214. package/dist/menu/menu-dom.mjs.map +1 -1
  215. package/dist/menu/menu-gestures.mjs +167 -0
  216. package/dist/menu/menu-gestures.mjs.map +1 -0
  217. package/dist/menu/menu-group.d.mts.map +1 -1
  218. package/dist/menu/menu-group.mjs +2 -1
  219. package/dist/menu/menu-group.mjs.map +1 -1
  220. package/dist/menu/menu-hover.mjs +0 -1
  221. package/dist/menu/menu-hover.mjs.map +1 -1
  222. package/dist/menu/menu-item.mjs.map +1 -1
  223. package/dist/menu/menu-outside.mjs +101 -0
  224. package/dist/menu/menu-outside.mjs.map +1 -0
  225. package/dist/menu/menu-point.mjs +85 -0
  226. package/dist/menu/menu-point.mjs.map +1 -0
  227. package/dist/menu/menu-popup.d.mts +6 -7
  228. package/dist/menu/menu-popup.d.mts.map +1 -1
  229. package/dist/menu/menu-popup.mjs +37 -248
  230. package/dist/menu/menu-popup.mjs.map +1 -1
  231. package/dist/menu/menu-radio-group.mjs.map +1 -1
  232. package/dist/menu/menu-root.d.mts +10 -0
  233. package/dist/menu/menu-root.d.mts.map +1 -1
  234. package/dist/menu/menu-root.mjs +10 -8
  235. package/dist/menu/menu-root.mjs.map +1 -1
  236. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  237. package/dist/menu/menu-submenu-trigger.mjs +6 -6
  238. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  239. package/dist/menu/menu-trigger.d.mts +4 -9
  240. package/dist/menu/menu-trigger.d.mts.map +1 -1
  241. package/dist/menu/menu-trigger.mjs +8 -6
  242. package/dist/menu/menu-trigger.mjs.map +1 -1
  243. package/dist/menu/use-menu-item.mjs +14 -16
  244. package/dist/menu/use-menu-item.mjs.map +1 -1
  245. package/dist/menu/use-menu-keyboard.mjs +88 -0
  246. package/dist/menu/use-menu-keyboard.mjs.map +1 -0
  247. package/dist/meter/meter-root.mjs +1 -1
  248. package/dist/number-field/index.d.mts +2 -1
  249. package/dist/number-field/index.d.mts.map +1 -1
  250. package/dist/number-field/index.mjs +2 -2
  251. package/dist/number-field/index.mjs.map +1 -1
  252. package/dist/number-field/number-field-arithmetic.mjs +30 -11
  253. package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
  254. package/dist/number-field/number-field-context.d.mts +6 -1
  255. package/dist/number-field/number-field-context.d.mts.map +1 -0
  256. package/dist/number-field/number-field-context.mjs.map +1 -1
  257. package/dist/number-field/number-field-decrement.d.mts +1 -1
  258. package/dist/number-field/number-field-decrement.mjs +1 -1
  259. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  260. package/dist/number-field/number-field-increment.d.mts +2 -22
  261. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  262. package/dist/number-field/number-field-increment.mjs +2 -53
  263. package/dist/number-field/number-field-increment.mjs.map +1 -1
  264. package/dist/number-field/number-field-input.d.mts.map +1 -1
  265. package/dist/number-field/number-field-input.mjs +18 -22
  266. package/dist/number-field/number-field-input.mjs.map +1 -1
  267. package/dist/number-field/number-field-label.d.mts.map +1 -1
  268. package/dist/number-field/number-field-label.mjs +3 -9
  269. package/dist/number-field/number-field-label.mjs.map +1 -1
  270. package/dist/number-field/number-field-root.d.mts +2 -1
  271. package/dist/number-field/number-field-root.d.mts.map +1 -1
  272. package/dist/number-field/number-field-root.mjs +81 -91
  273. package/dist/number-field/number-field-root.mjs.map +1 -1
  274. package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
  275. package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
  276. package/dist/number-field/use-step-button.d.mts +24 -0
  277. package/dist/number-field/use-step-button.d.mts.map +1 -0
  278. package/dist/number-field/use-step-button.mjs +57 -3
  279. package/dist/number-field/use-step-button.mjs.map +1 -1
  280. package/dist/popover/popover-close.d.mts.map +1 -1
  281. package/dist/popover/popover-close.mjs +28 -67
  282. package/dist/popover/popover-close.mjs.map +1 -1
  283. package/dist/popover/popover-context.mjs.map +1 -1
  284. package/dist/popover/popover-popup.d.mts +9 -6
  285. package/dist/popover/popover-popup.d.mts.map +1 -1
  286. package/dist/popover/popover-popup.mjs +13 -36
  287. package/dist/popover/popover-popup.mjs.map +1 -1
  288. package/dist/popover/popover-root.mjs +4 -3
  289. package/dist/popover/popover-root.mjs.map +1 -1
  290. package/dist/popover/popover-trigger.d.mts +4 -8
  291. package/dist/popover/popover-trigger.d.mts.map +1 -1
  292. package/dist/popover/popover-trigger.mjs +2 -1
  293. package/dist/popover/popover-trigger.mjs.map +1 -1
  294. package/dist/progress/progress-root.mjs +1 -1
  295. package/dist/radio-group/radio-group-context.mjs.map +1 -1
  296. package/dist/radio-group/radio-group-item.d.mts +3 -4
  297. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  298. package/dist/radio-group/radio-group-item.mjs +20 -25
  299. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  300. package/dist/radio-group/radio-group-label.mjs +1 -6
  301. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  302. package/dist/radio-group/radio-group-root.d.mts +1 -1
  303. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  304. package/dist/radio-group/radio-group-root.mjs +21 -40
  305. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  306. package/dist/select/select-dom.mjs +9 -18
  307. package/dist/select/select-dom.mjs.map +1 -1
  308. package/dist/select/select-option.mjs +1 -1
  309. package/dist/select/select-root.mjs +3 -2
  310. package/dist/select/select-root.mjs.map +1 -1
  311. package/dist/slider/slider-arithmetic.mjs +74 -13
  312. package/dist/slider/slider-arithmetic.mjs.map +1 -1
  313. package/dist/slider/slider-context.mjs.map +1 -1
  314. package/dist/slider/slider-label.d.mts.map +1 -1
  315. package/dist/slider/slider-label.mjs +3 -9
  316. package/dist/slider/slider-label.mjs.map +1 -1
  317. package/dist/slider/slider-root.d.mts +2 -2
  318. package/dist/slider/slider-root.d.mts.map +1 -1
  319. package/dist/slider/slider-root.mjs +36 -116
  320. package/dist/slider/slider-root.mjs.map +1 -1
  321. package/dist/slider/slider-thumb.d.mts.map +1 -1
  322. package/dist/slider/slider-thumb.mjs +8 -6
  323. package/dist/slider/slider-thumb.mjs.map +1 -1
  324. package/dist/slider/slider-value.d.mts.map +1 -1
  325. package/dist/slider/slider-value.mjs +2 -1
  326. package/dist/slider/slider-value.mjs.map +1 -1
  327. package/dist/slider/use-slider-dev-warnings.mjs +29 -0
  328. package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
  329. package/dist/slider/use-thumb-registry.mjs +51 -0
  330. package/dist/slider/use-thumb-registry.mjs.map +1 -0
  331. package/dist/switch/switch.d.mts +4 -5
  332. package/dist/switch/switch.d.mts.map +1 -1
  333. package/dist/switch/switch.mjs +15 -55
  334. package/dist/switch/switch.mjs.map +1 -1
  335. package/dist/tabs/tabs-context.d.mts +2 -3
  336. package/dist/tabs/tabs-context.d.mts.map +1 -1
  337. package/dist/tabs/tabs-context.mjs.map +1 -1
  338. package/dist/tabs/tabs-list.d.mts.map +1 -1
  339. package/dist/tabs/tabs-list.mjs +9 -22
  340. package/dist/tabs/tabs-list.mjs.map +1 -1
  341. package/dist/tabs/tabs-panel.d.mts +3 -4
  342. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  343. package/dist/tabs/tabs-panel.mjs.map +1 -1
  344. package/dist/tabs/tabs-root.d.mts +4 -3
  345. package/dist/tabs/tabs-root.d.mts.map +1 -1
  346. package/dist/tabs/tabs-root.mjs +2 -1
  347. package/dist/tabs/tabs-root.mjs.map +1 -1
  348. package/dist/tabs/tabs-tab.d.mts +3 -4
  349. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  350. package/dist/tabs/tabs-tab.mjs.map +1 -1
  351. package/dist/toast/toast-action.mjs.map +1 -1
  352. package/dist/toast/toast-close.d.mts.map +1 -1
  353. package/dist/toast/toast-close.mjs +2 -8
  354. package/dist/toast/toast-close.mjs.map +1 -1
  355. package/dist/toast/toast-context.mjs.map +1 -1
  356. package/dist/toast/toast-hotkey.mjs +27 -0
  357. package/dist/toast/toast-hotkey.mjs.map +1 -0
  358. package/dist/toast/toast-queue.mjs +137 -0
  359. package/dist/toast/toast-queue.mjs.map +1 -0
  360. package/dist/toast/toast-timers.mjs +65 -0
  361. package/dist/toast/toast-timers.mjs.map +1 -0
  362. package/dist/toast/toast-viewport.d.mts.map +1 -1
  363. package/dist/toast/toast-viewport.mjs +30 -235
  364. package/dist/toast/toast-viewport.mjs.map +1 -1
  365. package/dist/toast/toast.mjs +1 -1
  366. package/dist/toast/toast.mjs.map +1 -1
  367. package/dist/toast/use-modal-portal-host.mjs +52 -0
  368. package/dist/toast/use-modal-portal-host.mjs.map +1 -0
  369. package/dist/toggle/toggle.d.mts +3 -4
  370. package/dist/toggle/toggle.d.mts.map +1 -1
  371. package/dist/toggle/toggle.mjs +7 -10
  372. package/dist/toggle/toggle.mjs.map +1 -1
  373. package/dist/toggle-group/toggle-group-context.d.mts +2 -1
  374. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  375. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  376. package/dist/toggle-group/toggle-group-item.d.mts +5 -3
  377. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  378. package/dist/toggle-group/toggle-group-item.mjs +5 -7
  379. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  380. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  381. package/dist/toggle-group/toggle-group-root.mjs +29 -64
  382. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  383. package/dist/toolbar/toolbar-root.d.mts +2 -2
  384. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  385. package/dist/toolbar/toolbar-root.mjs +3 -4
  386. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  387. package/dist/tooltip/tooltip-context.d.mts +1 -1
  388. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  389. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  390. package/dist/tooltip/tooltip-popup.mjs +6 -15
  391. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  392. package/dist/tooltip/tooltip-root.mjs +2 -2
  393. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  394. package/dist/tooltip/tooltip-trigger.d.mts +2 -1
  395. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  396. package/dist/tooltip/tooltip-trigger.mjs +3 -2
  397. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  398. package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
  399. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  400. package/package.json +3 -2
  401. package/dist/accordion/accordion-context.d.mts +0 -5
  402. package/dist/accordion/accordion-context.d.mts.map +0 -1
  403. package/dist/internal/use-popover-root.mjs.map +0 -1
  404. /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nexport interface ToastCloseState {\n readonly toast: ToastItem;\n}\n\nexport interface ToastCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n children?: StateValue<ReactNode, ToastCloseState>;\n className?: StateValue<string | undefined, ToastCloseState>;\n style?: StateValue<CSSProperties | undefined, ToastCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastCloseState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Dismisses the toast (`reason: \"dismiss\"`, the same as Escape). Label it yourself (`aria-label`\n * or text). No Invoker Command: `hide-popover` would hide the whole region.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.\n */\nexport function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps) {\n const root = useToastRootContext(\"Toast.Close\");\n\n const devRef = useCallback((element: HTMLElement) => {\n if (isDev) {\n // After the commit: the text may come from children rendered in the same commit.\n queueMicrotask(() => {\n if (!element.isConnected) return;\n const named =\n element.hasAttribute(\"aria-label\") ||\n element.hasAttribute(\"aria-labelledby\") ||\n (element.textContent ?? \"\").trim() !== \"\";\n if (!named) {\n console.error(\n \"Toast.Close: the button has no accessible name. Give it text or an `aria-label`.\",\n );\n }\n });\n }\n return () => {};\n }, []);\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (rest.disabled === true) return;\n root.close(\"dismiss\", event.nativeEvent);\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ToastCloseState>({\n defaultElement: \"button\",\n render,\n state: { toast: root.toast },\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nToastClose.displayName = \"ToastClose\";\n"],"mappings":";;;;;;AAuBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;AAQvC,SAAgB,WAAW,EAAE,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAyB;CAC3F,MAAM,OAAO,oBAAoB,aAAa;CAE9C,MAAM,SAAS,aAAa,YAAyB;EACnD,IAAI,OAEF,qBAAqB;GACnB,IAAI,CAAC,QAAQ,aAAa;GAK1B,IAAI,EAHF,QAAQ,aAAa,YAAY,KACjC,QAAQ,aAAa,iBAAiB,MACrC,QAAQ,eAAe,GAAA,CAAI,KAAK,MAAM,KAEvC,QAAQ,MACN,kFACF;EAEJ,CAAC;EAEH,aAAa,CAAC;CAChB,GAAG,CAAC,CAAC;CAEL,MAAM,WAAW,UAAyC;EACxD,IAAI,KAAK,aAAa,MAAM;EAC5B,KAAK,MAAM,WAAW,MAAM,WAAW;CACzC;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD;CACF;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO,EAAE,OAAO,KAAK,MAAM;EAC3B;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,WAAW,cAAc"}
1
+ {"version":3,"file":"toast-close.mjs","names":[],"sources":["../../src/toast/toast-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { TEXT_NAME, useNameWarning } from \"../internal/use-name-warning.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport type { ToastItem } from \"./toast.js\";\nimport { useToastRootContext } from \"./toast-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ToastCloseState {\n readonly toast: ToastItem;\n}\n\nexport interface ToastCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n children?: StateValue<ReactNode, ToastCloseState>;\n className?: StateValue<string | undefined, ToastCloseState>;\n style?: StateValue<CSSProperties | undefined, ToastCloseState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ToastCloseState>;\n}\n\n/**\n * Dismisses the toast (`reason: \"dismiss\"`, the same as Escape). Label it yourself (`aria-label`\n * or text). No Invoker Command: `hide-popover` would hide the whole region.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `onClick`.\n */\nexport function ToastClose({ children, className, style, render, ...rest }: ToastCloseProps) {\n const root = useToastRootContext(\"Toast.Close\");\n\n const devRef = useNameWarning(\n isDev && \"Toast.Close: the button has no accessible name. Give it text or an `aria-label`.\",\n TEXT_NAME,\n );\n\n const onClick = (event: MouseEvent<HTMLElement>): void => {\n if (rest.disabled === true) return;\n root.close(\"dismiss\", event.nativeEvent);\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n onClick,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ToastCloseState>({\n defaultElement: \"button\",\n render,\n state: { toast: root.toast },\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref: devRef,\n });\n}\n\nToastClose.displayName = \"ToastClose\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;AAsBvC,SAAgB,WAAW,EAAE,UAAU,WAAW,OAAO,QAAQ,GAAG,QAAyB;CAC3F,MAAM,OAAO,oBAAoB,aAAa;CAE9C,MAAM,SAAS,eACb,SAAS,oFACT,SACF;CAEA,MAAM,WAAW,UAAyC;EACxD,IAAI,KAAK,aAAa,MAAM;EAC5B,KAAK,MAAM,WAAW,MAAM,WAAW;CACzC;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD;CACF;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAO,EAAE,OAAO,KAAK,MAAM;EAC3B;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;AACH;AAEA,WAAW,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and scheduling `closeAction`. */\n readonly close: (ids: readonly string[], reason: ChangeReason, event: Event | undefined) => void;\n /** Remove an ending toast once its exit animations finished. */\n readonly drop: (id: string) => void;\n /** An action dispatched through the toast's Action part is (no longer) in flight. */\n readonly setActionPending: (id: string, pending: boolean) => void;\n /** The toast's content is (no longer) suspended behind the Root's guard. */\n readonly setSuspended: (id: string, suspended: boolean) => void;\n /** The Root's element, for arrow keys, the hotkey and focus moves; `null` to unregister. */\n readonly registerRoot: (id: string, element: HTMLElement | null) => void;\n /** Focus the next (`1`) or previous (`-1`) toast's Root, without wrapping. */\n readonly focusSibling: (id: string, direction: 1 | -1) => void;\n /** Queue an announcement; skipped when `text` equals the last one announced for `id`. */\n readonly announce: (id: string, text: string | null, priority: ToastPriority) => void;\n /** The Viewport's `announce` prop, read at announcement time. */\n readonly announcer: () => ((toast: ToastItem) => string | null) | undefined;\n /**\n * The animations that ran in the toast before it was marked ending (kept until it is dropped\n * or replaced): its exit waits only for the others.\n */\n readonly exitBaseline: (id: string) => ReadonlySet<Animation> | undefined;\n}\n\nexport const ToastViewportContext = createContext<ToastViewportContextValue | null>(null);\n\nexport function useToastViewportContext(part: string): ToastViewportContextValue {\n const context = use(ToastViewportContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Viewport.`);\n }\n return context;\n}\n\n/** What the parts inside a Root need. */\nexport interface ToastRootContextValue {\n readonly toast: ToastItem;\n readonly ids: { readonly title: string; readonly description: string };\n /** Root state, so Title and Description can resolve their function props against it. */\n readonly state: ToastRootStateShape;\n readonly registerTitle: (element: HTMLElement | null) => void;\n readonly registerDescription: (element: HTMLElement | null) => void;\n /** An Action part's run is (no longer) in flight; `token` identifies the part. */\n readonly setActionPending: (token: object, pending: boolean) => void;\n /**\n * A Title or Description committed: mounted, or shown again by a Suspense boundary inside the\n * Root (the consumer's skeleton), so the Root announces the text that now exists.\n */\n readonly contentCommitted: () => void;\n /** The Suspense guard mounted (`true`) or unmounted (`false`). */\n readonly setSuspended: (suspended: boolean) => void;\n /** Close this toast. */\n readonly close: (reason: ChangeReason, event: Event | undefined) => void;\n}\n\n/** Same shape as `ToastRootState` (declared in toast-root.tsx). */\nexport interface ToastRootStateShape {\n readonly toast: ToastItem;\n readonly pending: boolean;\n readonly ending: boolean;\n readonly type: string | undefined;\n readonly priority: ToastPriority;\n}\n\nexport const ToastRootContext = createContext<ToastRootContextValue | null>(null);\n\nexport function useToastRootContext(part: string): ToastRootContextValue {\n const context = use(ToastRootContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AA8BA,MAAa,uBAAuB,cAAgD,IAAI;AAExF,SAAgB,wBAAwB,MAAyC;CAC/E,MAAM,UAAU,IAAI,oBAAoB;CACxC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,2CAA2C;CAErE,OAAO;AACT;AAgCA,MAAa,mBAAmB,cAA4C,IAAI;AAEhF,SAAgB,oBAAoB,MAAqC;CACvE,MAAM,UAAU,IAAI,gBAAgB;CACpC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,uCAAuC;CAEjE,OAAO;AACT"}
1
+ {"version":3,"file":"toast-context.mjs","names":[],"sources":["../../src/toast/toast-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { ToastRootState } from \"./toast-root.js\";\nimport type { ToastItem, ToastPriority } from \"./toast.js\";\n\n/** What a Root (and the parts under it) need from the Viewport. Stable for the Viewport's life. */\nexport interface ToastViewportContextValue {\n /** Close toasts (`ending: true`), moving focus out first and scheduling `closeAction`. */\n readonly close: (ids: readonly string[], reason: ChangeReason, event: Event | undefined) => void;\n /** Remove an ending toast once its exit animations finished. */\n readonly drop: (id: string) => void;\n /** An action dispatched through the toast's Action part is (no longer) in flight. */\n readonly setActionPending: (id: string, pending: boolean) => void;\n /** The toast's content is (no longer) suspended behind the Root's guard. */\n readonly setSuspended: (id: string, suspended: boolean) => void;\n /** The Root's element, for arrow keys, the hotkey and focus moves; `null` to unregister. */\n readonly registerRoot: (id: string, element: HTMLElement | null) => void;\n /** Focus the next (`1`) or previous (`-1`) toast's Root, without wrapping. */\n readonly focusSibling: (id: string, direction: 1 | -1) => void;\n /** Queue an announcement; skipped when `text` equals the last one announced for `id`. */\n readonly announce: (id: string, text: string | null, priority: ToastPriority) => void;\n /** The Viewport's `announce` prop, read at announcement time. */\n readonly announcer: () => ((toast: ToastItem) => string | null) | undefined;\n /**\n * The animations that ran in the toast before it was marked ending (kept until it is dropped\n * or replaced): its exit waits only for the others.\n */\n readonly exitBaseline: (id: string) => ReadonlySet<Animation> | undefined;\n}\n\nexport const ToastViewportContext = createContext<ToastViewportContextValue | null>(null);\n\nexport function useToastViewportContext(part: string): ToastViewportContextValue {\n const context = use(ToastViewportContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Viewport.`);\n }\n return context;\n}\n\n/** What the parts inside a Root need. */\nexport interface ToastRootContextValue {\n readonly toast: ToastItem;\n readonly ids: { readonly title: string; readonly description: string };\n /** Root state, so Title and Description can resolve their function props against it. */\n readonly state: ToastRootState;\n readonly registerTitle: (element: HTMLElement | null) => void;\n readonly registerDescription: (element: HTMLElement | null) => void;\n /** An Action part's run is (no longer) in flight; `token` identifies the part. */\n readonly setActionPending: (token: object, pending: boolean) => void;\n /**\n * A Title or Description committed: mounted, or shown again by a Suspense boundary inside the\n * Root (the consumer's skeleton), so the Root announces the text that now exists.\n */\n readonly contentCommitted: () => void;\n /** The Suspense guard mounted (`true`) or unmounted (`false`). */\n readonly setSuspended: (suspended: boolean) => void;\n /** Close this toast. */\n readonly close: (reason: ChangeReason, event: Event | undefined) => void;\n}\n\nexport const ToastRootContext = createContext<ToastRootContextValue | null>(null);\n\nexport function useToastRootContext(part: string): ToastRootContextValue {\n const context = use(ToastRootContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Toast.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AA+BA,MAAa,uBAAuB,cAAgD,IAAI;AAExF,SAAgB,wBAAwB,MAAyC;CAC/E,MAAM,UAAU,IAAI,oBAAoB;CACxC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,2CAA2C;CAErE,OAAO;AACT;AAuBA,MAAa,mBAAmB,cAA4C,IAAI;AAEhF,SAAgB,oBAAoB,MAAqC;CACvE,MAAM,UAAU,IAAI,gBAAgB;CACpC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,uCAAuC;CAEjE,OAAO;AACT"}
@@ -0,0 +1,27 @@
1
+ //#region src/toast/toast-hotkey.ts
2
+ const DEFAULT_HOTKEY = ["F8"];
3
+ const MODIFIER_NAMES = {
4
+ altKey: "Alt",
5
+ ctrlKey: "Ctrl",
6
+ metaKey: "Meta",
7
+ shiftKey: "Shift"
8
+ };
9
+ /** `["altKey", "KeyT"]` → `"Alt+T"`, `["F8"]` → `"F8"`. */
10
+ function hotkeyLabel(hotkey) {
11
+ return hotkey.map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, "").replace(/^Digit/, "")).join("+");
12
+ }
13
+ /** The region's built-in accessible name (conventions 11): `"Notifications (F8)"`. */
14
+ function regionLabel(hotkey) {
15
+ if (hotkey === null || hotkey.length === 0) return "Notifications";
16
+ return `Notifications (${hotkeyLabel(hotkey)})`;
17
+ }
18
+ /** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */
19
+ function matchesHotkey(hotkey, event) {
20
+ const flags = event;
21
+ for (const modifier of Object.keys(MODIFIER_NAMES)) if (flags[modifier] === true !== hotkey.includes(modifier)) return false;
22
+ return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);
23
+ }
24
+ //#endregion
25
+ export { DEFAULT_HOTKEY, matchesHotkey, regionLabel };
26
+
27
+ //# sourceMappingURL=toast-hotkey.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-hotkey.mjs","names":[],"sources":["../../src/toast/toast-hotkey.ts"],"sourcesContent":["// The Viewport's hotkey (design/components/toast.md 7) and the region name built from it. No\n// \"use client\" directive: pure (conventions 7.1).\n\nexport const DEFAULT_HOTKEY: readonly string[] = [\"F8\"];\n\nconst MODIFIER_NAMES: Readonly<Record<string, string>> = {\n altKey: \"Alt\",\n ctrlKey: \"Ctrl\",\n metaKey: \"Meta\",\n shiftKey: \"Shift\",\n};\n\n/** `[\"altKey\", \"KeyT\"]` → `\"Alt+T\"`, `[\"F8\"]` → `\"F8\"`. */\nfunction hotkeyLabel(hotkey: readonly string[]): string {\n return hotkey\n .map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, \"\").replace(/^Digit/, \"\"))\n .join(\"+\");\n}\n\n/** The region's built-in accessible name (conventions 11): `\"Notifications (F8)\"`. */\nexport function regionLabel(hotkey: readonly string[] | null): string {\n if (hotkey === null || hotkey.length === 0) return \"Notifications\";\n return `Notifications (${hotkeyLabel(hotkey)})`;\n}\n\n/** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */\nexport function matchesHotkey(hotkey: readonly string[], event: KeyboardEvent): boolean {\n const flags = event as unknown as Record<string, unknown>;\n for (const modifier of Object.keys(MODIFIER_NAMES)) {\n if ((flags[modifier] === true) !== hotkey.includes(modifier)) return false;\n }\n return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);\n}\n"],"mappings":";AAGA,MAAa,iBAAoC,CAAC,IAAI;AAEtD,MAAM,iBAAmD;CACvD,QAAQ;CACR,SAAS;CACT,SAAS;CACT,UAAU;AACZ;;AAGA,SAAS,YAAY,QAAmC;CACtD,OAAO,OACJ,KAAK,QAAQ,eAAe,QAAQ,IAAI,QAAQ,kBAAkB,EAAE,CAAC,CAAC,QAAQ,UAAU,EAAE,CAAC,CAAC,CAC5F,KAAK,GAAG;AACb;;AAGA,SAAgB,YAAY,QAA0C;CACpE,IAAI,WAAW,QAAQ,OAAO,WAAW,GAAG,OAAO;CACnD,OAAO,kBAAkB,YAAY,MAAM,EAAE;AAC/C;;AAGA,SAAgB,cAAc,QAA2B,OAA+B;CACtF,MAAM,QAAQ;CACd,KAAK,MAAM,YAAY,OAAO,KAAK,cAAc,GAC/C,IAAK,MAAM,cAAc,SAAU,OAAO,SAAS,QAAQ,GAAG,OAAO;CAEvE,OAAO,OAAO,OAAO,QAAQ,OAAO,kBAAkB,MAAM,SAAS,GAAG;AAC1E"}
@@ -0,0 +1,137 @@
1
+ //#region src/toast/toast-queue.ts
2
+ function makeEntry(options, flags) {
3
+ return {
4
+ options,
5
+ ...flags,
6
+ item: {
7
+ ...options,
8
+ id: options.id,
9
+ pending: flags.promisePending || flags.actionPending,
10
+ ending: flags.ending
11
+ }
12
+ };
13
+ }
14
+ function withFlags(entry, flags) {
15
+ return makeEntry(entry.options, {
16
+ promisePending: flags.promisePending ?? entry.promisePending,
17
+ actionPending: flags.actionPending ?? entry.actionPending,
18
+ ending: flags.ending ?? entry.ending
19
+ });
20
+ }
21
+ /** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */
22
+ function partition(entries, limit) {
23
+ const visible = [];
24
+ const queued = [];
25
+ let open = 0;
26
+ for (const entry of entries) if (entry.ending) visible.push(entry);
27
+ else if (open < limit) {
28
+ visible.push(entry);
29
+ open++;
30
+ } else queued.push(entry);
31
+ return {
32
+ visible,
33
+ queued
34
+ };
35
+ }
36
+ /** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */
37
+ function plainText(node) {
38
+ if (typeof node === "string") return node;
39
+ if (typeof node === "number" || typeof node === "bigint") return String(node);
40
+ if (Array.isArray(node)) return node.map(plainText).join("");
41
+ return "";
42
+ }
43
+ /**
44
+ * Applies a batch of manager commands to the queue. Dismissals apply in order: each closes the
45
+ * toasts open at that point of the batch, never one added after it. A dismissed toast with a
46
+ * rendered Root (`isRendered`) turns ending; one never rendered (queued beyond `limit`, or added
47
+ * in this tick) leaves at once instead of mounting once as an ending Root. An add with the id of
48
+ * an open toast updates it ("one toast per key"); with the id of an ending one it replaces it
49
+ * (the keyed Root may be reused): a fresh timer, a fresh announcement, no exit.
50
+ */
51
+ function applyCommands(entries, commands, isRendered) {
52
+ const next = [...entries];
53
+ const dismissed = [];
54
+ const forgotten = [];
55
+ const replaced = [];
56
+ const missing = [];
57
+ let added = false;
58
+ for (const command of commands) {
59
+ if (command.kind === "dismiss") {
60
+ for (let i = 0; i < next.length; i++) {
61
+ const entry = next[i];
62
+ if (entry.ending) continue;
63
+ const id = entry.options.id;
64
+ if (command.id !== void 0 && id !== command.id) continue;
65
+ dismissed.push(entry);
66
+ if (isRendered(id)) next[i] = withFlags(entry, { ending: true });
67
+ else {
68
+ next.splice(i--, 1);
69
+ forgotten.push(id);
70
+ }
71
+ }
72
+ continue;
73
+ }
74
+ const index = next.findIndex((e) => e.options.id === command.id);
75
+ const existing = index === -1 ? void 0 : next[index];
76
+ if (command.kind === "add") {
77
+ const options = {
78
+ ...command.options,
79
+ id: command.id
80
+ };
81
+ if (existing !== void 0 && !existing.ending) {
82
+ next[index] = makeEntry({
83
+ ...existing.options,
84
+ ...options
85
+ }, {
86
+ promisePending: command.pending || existing.promisePending,
87
+ actionPending: existing.actionPending,
88
+ ending: false
89
+ });
90
+ continue;
91
+ }
92
+ if (existing !== void 0) {
93
+ next.splice(index, 1);
94
+ replaced.push(command.id);
95
+ forgotten.push(command.id);
96
+ }
97
+ next.push(makeEntry(options, {
98
+ promisePending: command.pending,
99
+ actionPending: false,
100
+ ending: false
101
+ }));
102
+ added = true;
103
+ } else {
104
+ if (existing === void 0) {
105
+ if (!command.settle) missing.push(command.id);
106
+ continue;
107
+ }
108
+ if (existing.ending) continue;
109
+ next[index] = makeEntry(command.settle ? {
110
+ ...command.options,
111
+ id: command.id
112
+ } : {
113
+ ...existing.options,
114
+ ...command.options,
115
+ id: command.id
116
+ }, {
117
+ promisePending: command.settle ? false : existing.promisePending,
118
+ actionPending: existing.actionPending,
119
+ ending: false
120
+ });
121
+ }
122
+ }
123
+ const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));
124
+ return {
125
+ next,
126
+ dismissed,
127
+ leaving: new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id))),
128
+ forgotten,
129
+ replaced,
130
+ added,
131
+ missing
132
+ };
133
+ }
134
+ //#endregion
135
+ export { applyCommands, makeEntry, partition, plainText, withFlags };
136
+
137
+ //# sourceMappingURL=toast-queue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-queue.mjs","names":[],"sources":["../../src/toast/toast-queue.ts"],"sourcesContent":["// The Viewport's queue model (design/components/toast.md 8, 12): entries, their public items, and\n// which of them render. No \"use client\" directive: pure (conventions 7.1).\nimport type { ToastCommand, ToastItem, ToastOptions } from \"./toast.js\";\n\n/** One queue entry: the toast's options and the flags its `ToastItem` is built from. */\nexport interface Entry {\n readonly options: ToastOptions & { readonly id: string };\n readonly promisePending: boolean;\n readonly actionPending: boolean;\n readonly ending: boolean;\n /** The public item, rebuilt whenever any of the above changes (stable identity otherwise). */\n readonly item: ToastItem;\n}\n\nexport function makeEntry(\n options: ToastOptions & { readonly id: string },\n flags: { promisePending: boolean; actionPending: boolean; ending: boolean },\n): Entry {\n return {\n options,\n ...flags,\n item: {\n ...options,\n id: options.id,\n pending: flags.promisePending || flags.actionPending,\n ending: flags.ending,\n },\n };\n}\n\nexport function withFlags(\n entry: Entry,\n flags: Partial<{ promisePending: boolean; actionPending: boolean; ending: boolean }>,\n): Entry {\n return makeEntry(entry.options, {\n promisePending: flags.promisePending ?? entry.promisePending,\n actionPending: flags.actionPending ?? entry.actionPending,\n ending: flags.ending ?? entry.ending,\n });\n}\n\n/** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */\nexport function partition(\n entries: readonly Entry[],\n limit: number,\n): { visible: Entry[]; queued: Entry[] } {\n const visible: Entry[] = [];\n const queued: Entry[] = [];\n let open = 0;\n for (const entry of entries) {\n if (entry.ending) visible.push(entry);\n else if (open < limit) {\n visible.push(entry);\n open++;\n } else queued.push(entry);\n }\n return { visible, queued };\n}\n\n/** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */\nexport function plainText(node: unknown): string {\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\" || typeof node === \"bigint\") return String(node);\n if (Array.isArray(node)) return node.map(plainText).join(\"\");\n return \"\";\n}\n\nexport interface AppliedCommands {\n readonly next: readonly Entry[];\n /** The open toasts the batch dismissed, in order (their `closeAction`s run). */\n readonly dismissed: readonly Entry[];\n /** Dismissed ids that leave the DOM: not those replaced by a later add with the id. */\n readonly leaving: ReadonlySet<string>;\n /**\n * Ids whose announcement and exit baseline start over: dismissed before they rendered, or an\n * ending toast replaced by a new one with its id (listed in `replaced` too).\n */\n readonly forgotten: readonly string[];\n /** Ending toasts replaced by a new add with their id: their timer starts over. */\n readonly replaced: readonly string[];\n /** The batch added a toast (the region re-raises). */\n readonly added: boolean;\n /** Ids of updates that found no toast (a promise settle excepted). */\n readonly missing: readonly string[];\n}\n\n/**\n * Applies a batch of manager commands to the queue. Dismissals apply in order: each closes the\n * toasts open at that point of the batch, never one added after it. A dismissed toast with a\n * rendered Root (`isRendered`) turns ending; one never rendered (queued beyond `limit`, or added\n * in this tick) leaves at once instead of mounting once as an ending Root. An add with the id of\n * an open toast updates it (\"one toast per key\"); with the id of an ending one it replaces it\n * (the keyed Root may be reused): a fresh timer, a fresh announcement, no exit.\n */\nexport function applyCommands(\n entries: readonly Entry[],\n commands: readonly ToastCommand[],\n isRendered: (id: string) => boolean,\n): AppliedCommands {\n const next = [...entries];\n const dismissed: Entry[] = [];\n const forgotten: string[] = [];\n const replaced: string[] = [];\n const missing: string[] = [];\n let added = false;\n for (const command of commands) {\n if (command.kind === \"dismiss\") {\n for (let i = 0; i < next.length; i++) {\n const entry = next[i]!;\n if (entry.ending) continue;\n const id = entry.options.id;\n if (command.id !== undefined && id !== command.id) continue;\n dismissed.push(entry);\n if (isRendered(id)) {\n next[i] = withFlags(entry, { ending: true });\n } else {\n next.splice(i--, 1);\n forgotten.push(id);\n }\n }\n continue;\n }\n const index = next.findIndex((e) => e.options.id === command.id);\n const existing = index === -1 ? undefined : next[index]!;\n if (command.kind === \"add\") {\n const options = { ...command.options, id: command.id };\n if (existing !== undefined && !existing.ending) {\n next[index] = makeEntry(\n { ...existing.options, ...options },\n {\n promisePending: command.pending || existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n },\n );\n continue;\n }\n if (existing !== undefined) {\n next.splice(index, 1);\n replaced.push(command.id);\n forgotten.push(command.id);\n }\n next.push(\n makeEntry(options, {\n promisePending: command.pending,\n actionPending: false,\n ending: false,\n }),\n );\n added = true;\n } else {\n if (existing === undefined) {\n if (!command.settle) missing.push(command.id);\n continue;\n }\n if (existing.ending) continue;\n const options = command.settle\n ? { ...command.options, id: command.id }\n : { ...existing.options, ...command.options, id: command.id };\n next[index] = makeEntry(options, {\n promisePending: command.settle ? false : existing.promisePending,\n actionPending: existing.actionPending,\n ending: false,\n });\n }\n }\n const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));\n const leaving = new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id)));\n return { next, dismissed, leaving, forgotten, replaced, added, missing };\n}\n"],"mappings":";AAcA,SAAgB,UACd,SACA,OACO;CACP,OAAO;EACL;EACA,GAAG;EACH,MAAM;GACJ,GAAG;GACH,IAAI,QAAQ;GACZ,SAAS,MAAM,kBAAkB,MAAM;GACvC,QAAQ,MAAM;EAChB;CACF;AACF;AAEA,SAAgB,UACd,OACA,OACO;CACP,OAAO,UAAU,MAAM,SAAS;EAC9B,gBAAgB,MAAM,kBAAkB,MAAM;EAC9C,eAAe,MAAM,iBAAiB,MAAM;EAC5C,QAAQ,MAAM,UAAU,MAAM;CAChC,CAAC;AACH;;AAGA,SAAgB,UACd,SACA,OACuC;CACvC,MAAM,UAAmB,CAAC;CAC1B,MAAM,SAAkB,CAAC;CACzB,IAAI,OAAO;CACX,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,QAAQ,QAAQ,KAAK,KAAK;MAC/B,IAAI,OAAO,OAAO;EACrB,QAAQ,KAAK,KAAK;EAClB;CACF,OAAO,OAAO,KAAK,KAAK;CAE1B,OAAO;EAAE;EAAS;CAAO;AAC3B;;AAGA,SAAgB,UAAU,MAAuB;CAC/C,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO,OAAO,IAAI;CAC5E,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,IAAI,SAAS,CAAC,CAAC,KAAK,EAAE;CAC3D,OAAO;AACT;;;;;;;;;AA6BA,SAAgB,cACd,SACA,UACA,YACiB;CACjB,MAAM,OAAO,CAAC,GAAG,OAAO;CACxB,MAAM,YAAqB,CAAC;CAC5B,MAAM,YAAsB,CAAC;CAC7B,MAAM,WAAqB,CAAC;CAC5B,MAAM,UAAoB,CAAC;CAC3B,IAAI,QAAQ;CACZ,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,SAAS,WAAW;GAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,QAAQ,KAAK;IACnB,IAAI,MAAM,QAAQ;IAClB,MAAM,KAAK,MAAM,QAAQ;IACzB,IAAI,QAAQ,OAAO,KAAA,KAAa,OAAO,QAAQ,IAAI;IACnD,UAAU,KAAK,KAAK;IACpB,IAAI,WAAW,EAAE,GACf,KAAK,KAAK,UAAU,OAAO,EAAE,QAAQ,KAAK,CAAC;SACtC;KACL,KAAK,OAAO,KAAK,CAAC;KAClB,UAAU,KAAK,EAAE;IACnB;GACF;GACA;EACF;EACA,MAAM,QAAQ,KAAK,WAAW,MAAM,EAAE,QAAQ,OAAO,QAAQ,EAAE;EAC/D,MAAM,WAAW,UAAU,KAAK,KAAA,IAAY,KAAK;EACjD,IAAI,QAAQ,SAAS,OAAO;GAC1B,MAAM,UAAU;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG;GACrD,IAAI,aAAa,KAAA,KAAa,CAAC,SAAS,QAAQ;IAC9C,KAAK,SAAS,UACZ;KAAE,GAAG,SAAS;KAAS,GAAG;IAAQ,GAClC;KACE,gBAAgB,QAAQ,WAAW,SAAS;KAC5C,eAAe,SAAS;KACxB,QAAQ;IACV,CACF;IACA;GACF;GACA,IAAI,aAAa,KAAA,GAAW;IAC1B,KAAK,OAAO,OAAO,CAAC;IACpB,SAAS,KAAK,QAAQ,EAAE;IACxB,UAAU,KAAK,QAAQ,EAAE;GAC3B;GACA,KAAK,KACH,UAAU,SAAS;IACjB,gBAAgB,QAAQ;IACxB,eAAe;IACf,QAAQ;GACV,CAAC,CACH;GACA,QAAQ;EACV,OAAO;GACL,IAAI,aAAa,KAAA,GAAW;IAC1B,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,EAAE;IAC5C;GACF;GACA,IAAI,SAAS,QAAQ;GAIrB,KAAK,SAAS,UAHE,QAAQ,SACpB;IAAE,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,IACrC;IAAE,GAAG,SAAS;IAAS,GAAG,QAAQ;IAAS,IAAI,QAAQ;GAAG,GAC7B;IAC/B,gBAAgB,QAAQ,SAAS,QAAQ,SAAS;IAClD,eAAe,SAAS;IACxB,QAAQ;GACV,CAAC;EACH;CACF;CACA,MAAM,QAAQ,IAAI,IAAI,KAAK,QAAQ,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC;CAE5E,OAAO;EAAE;EAAM;EAAW,SAAA,IADN,IAAI,UAAU,KAAK,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CACxD;EAAG;EAAW;EAAU;EAAO;CAAQ;AACzE"}
@@ -0,0 +1,65 @@
1
+ //#region src/toast/toast-timers.ts
2
+ /** A toast's own `duration`, else none with an action (it waits for the user), else the default. */
3
+ function effectiveDuration(entry, defaultDuration) {
4
+ const own = entry.options.duration;
5
+ if (own !== void 0) return own;
6
+ return entry.options.action !== void 0 ? null : defaultDuration;
7
+ }
8
+ /**
9
+ * Matches the timers to the rendered entries: starts or resumes the timer of each open, timed
10
+ * toast that is not pending, suspended or halted, pauses the others keeping their remaining
11
+ * time, and drops the timers of toasts no longer rendered (or no longer timed).
12
+ */
13
+ function syncToastTimers(map, visible, sync) {
14
+ const now = Date.now();
15
+ const live = /* @__PURE__ */ new Set();
16
+ for (const entry of visible) {
17
+ if (entry.ending) continue;
18
+ const id = entry.options.id;
19
+ const ms = effectiveDuration(entry, sync.defaultDuration);
20
+ if (ms === null) continue;
21
+ live.add(id);
22
+ let timer = map.get(id);
23
+ if (timer === void 0 || timer.duration !== ms) {
24
+ if (timer?.handle != null) clearTimeout(timer.handle);
25
+ timer = {
26
+ duration: ms,
27
+ remaining: ms,
28
+ startedAt: 0,
29
+ handle: null
30
+ };
31
+ map.set(id, timer);
32
+ }
33
+ const run = !sync.halted && !entry.item.pending && !sync.suspended.has(id);
34
+ if (run && timer.handle === null) {
35
+ const current = timer;
36
+ current.startedAt = now;
37
+ current.handle = setTimeout(() => {
38
+ current.handle = null;
39
+ current.remaining = 0;
40
+ sync.expire(id);
41
+ }, Math.max(0, current.remaining));
42
+ } else if (!run && timer.handle !== null) {
43
+ clearTimeout(timer.handle);
44
+ timer.handle = null;
45
+ timer.remaining -= now - timer.startedAt;
46
+ }
47
+ }
48
+ for (const [id, timer] of map) {
49
+ if (live.has(id)) continue;
50
+ if (timer.handle !== null) clearTimeout(timer.handle);
51
+ map.delete(id);
52
+ }
53
+ }
54
+ /** Stops and forgets the timer of `id`, or every timer. */
55
+ function clearToastTimers(map, id) {
56
+ for (const [key, timer] of map) {
57
+ if (id !== void 0 && key !== id) continue;
58
+ if (timer.handle !== null) clearTimeout(timer.handle);
59
+ map.delete(key);
60
+ }
61
+ }
62
+ //#endregion
63
+ export { clearToastTimers, syncToastTimers };
64
+
65
+ //# sourceMappingURL=toast-timers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-timers.mjs","names":[],"sources":["../../src/toast/toast-timers.ts"],"sourcesContent":["// The Viewport's per-toast timers (design/components/toast.md 6). No \"use client\" directive: pure\n// (conventions 7.1); the Viewport keeps the map in a ref.\nimport type { Entry } from \"./toast-queue.js\";\n\nexport interface ToastTimer {\n /** The duration the timer was started with; a different effective duration restarts it. */\n readonly duration: number;\n remaining: number;\n startedAt: number;\n handle: ReturnType<typeof setTimeout> | null;\n}\n\nexport interface TimerSync {\n /** A viewport-wide pause holds, or the Viewport is not mounted: no timer runs. */\n readonly halted: boolean;\n /** Toasts whose content suspends: their timer waits. */\n readonly suspended: ReadonlySet<string>;\n /** The Viewport's `duration`. */\n readonly defaultDuration: number | null;\n /** A timer ran out. */\n readonly expire: (id: string) => void;\n}\n\n/** A toast's own `duration`, else none with an action (it waits for the user), else the default. */\nfunction effectiveDuration(entry: Entry, defaultDuration: number | null): number | null {\n const own = entry.options.duration;\n if (own !== undefined) return own;\n return entry.options.action !== undefined ? null : defaultDuration;\n}\n\n/**\n * Matches the timers to the rendered entries: starts or resumes the timer of each open, timed\n * toast that is not pending, suspended or halted, pauses the others keeping their remaining\n * time, and drops the timers of toasts no longer rendered (or no longer timed).\n */\nexport function syncToastTimers(\n map: Map<string, ToastTimer>,\n visible: readonly Entry[],\n sync: TimerSync,\n): void {\n const now = Date.now();\n const live = new Set<string>();\n for (const entry of visible) {\n if (entry.ending) continue;\n const id = entry.options.id;\n const ms = effectiveDuration(entry, sync.defaultDuration);\n if (ms === null) continue;\n live.add(id);\n let timer = map.get(id);\n if (timer === undefined || timer.duration !== ms) {\n if (timer?.handle != null) clearTimeout(timer.handle);\n timer = { duration: ms, remaining: ms, startedAt: 0, handle: null };\n map.set(id, timer);\n }\n const run = !sync.halted && !entry.item.pending && !sync.suspended.has(id);\n if (run && timer.handle === null) {\n const current = timer;\n current.startedAt = now;\n current.handle = setTimeout(\n () => {\n current.handle = null;\n current.remaining = 0;\n sync.expire(id);\n },\n Math.max(0, current.remaining),\n );\n } else if (!run && timer.handle !== null) {\n clearTimeout(timer.handle);\n timer.handle = null;\n timer.remaining -= now - timer.startedAt;\n }\n }\n for (const [id, timer] of map) {\n if (live.has(id)) continue;\n if (timer.handle !== null) clearTimeout(timer.handle);\n map.delete(id);\n }\n}\n\n/** Stops and forgets the timer of `id`, or every timer. */\nexport function clearToastTimers(map: Map<string, ToastTimer>, id?: string): void {\n for (const [key, timer] of map) {\n if (id !== undefined && key !== id) continue;\n if (timer.handle !== null) clearTimeout(timer.handle);\n map.delete(key);\n }\n}\n"],"mappings":";;AAwBA,SAAS,kBAAkB,OAAc,iBAA+C;CACtF,MAAM,MAAM,MAAM,QAAQ;CAC1B,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,OAAO,MAAM,QAAQ,WAAW,KAAA,IAAY,OAAO;AACrD;;;;;;AAOA,SAAgB,gBACd,KACA,SACA,MACM;CACN,MAAM,MAAM,KAAK,IAAI;CACrB,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,MAAM,QAAQ;EAClB,MAAM,KAAK,MAAM,QAAQ;EACzB,MAAM,KAAK,kBAAkB,OAAO,KAAK,eAAe;EACxD,IAAI,OAAO,MAAM;EACjB,KAAK,IAAI,EAAE;EACX,IAAI,QAAQ,IAAI,IAAI,EAAE;EACtB,IAAI,UAAU,KAAA,KAAa,MAAM,aAAa,IAAI;GAChD,IAAI,OAAO,UAAU,MAAM,aAAa,MAAM,MAAM;GACpD,QAAQ;IAAE,UAAU;IAAI,WAAW;IAAI,WAAW;IAAG,QAAQ;GAAK;GAClE,IAAI,IAAI,IAAI,KAAK;EACnB;EACA,MAAM,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,KAAK,WAAW,CAAC,KAAK,UAAU,IAAI,EAAE;EACzE,IAAI,OAAO,MAAM,WAAW,MAAM;GAChC,MAAM,UAAU;GAChB,QAAQ,YAAY;GACpB,QAAQ,SAAS,iBACT;IACJ,QAAQ,SAAS;IACjB,QAAQ,YAAY;IACpB,KAAK,OAAO,EAAE;GAChB,GACA,KAAK,IAAI,GAAG,QAAQ,SAAS,CAC/B;EACF,OAAO,IAAI,CAAC,OAAO,MAAM,WAAW,MAAM;GACxC,aAAa,MAAM,MAAM;GACzB,MAAM,SAAS;GACf,MAAM,aAAa,MAAM,MAAM;EACjC;CACF;CACA,KAAK,MAAM,CAAC,IAAI,UAAU,KAAK;EAC7B,IAAI,KAAK,IAAI,EAAE,GAAG;EAClB,IAAI,MAAM,WAAW,MAAM,aAAa,MAAM,MAAM;EACpD,IAAI,OAAO,EAAE;CACf;AACF;;AAGA,SAAgB,iBAAiB,KAA8B,IAAmB;CAChF,KAAK,MAAM,CAAC,KAAK,UAAU,KAAK;EAC9B,IAAI,OAAO,KAAA,KAAa,QAAQ,IAAI;EACpC,IAAI,MAAM,WAAW,MAAM,aAAa,MAAM,MAAM;EACpD,IAAI,OAAO,GAAG;CAChB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"toast-viewport.d.mts","names":[],"sources":["../../src/toast/toast-viewport.tsx"],"mappings":";;;;iBAyCiB;;WAEN,iBAAiB;;WAEjB;;WAEA;;iBAGM,2BAA2B,KAC1C;;EAYA,UAAU;;EAEV;;EAEA;;;;;;EAMA;;;;;EAKA,YAAY,OAAO;;EAEnB,WAAW,WAAW,WAAW;EACjC,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,kCAAkC;;;;;;;;;;;wBA0JxC,gBACd,SACA,OACA,UACA,QACA,UACA,UACA,WACA,OACA,WACG,QACF,qCAAkB,IAAA;yBAXL"}
1
+ {"version":3,"file":"toast-viewport.d.mts","names":[],"sources":["../../src/toast/toast-viewport.tsx"],"mappings":";;;;iBA0CiB;;WAEN,iBAAiB;;WAEjB;;WAEA;;iBAGM,2BAA2B,KAC1C;;EAYA,UAAU;;EAEV;;EAEA;;;;;;EAMA;;;;;EAKA,YAAY,OAAO;;EAEnB,WAAW,WAAW,WAAW;EACjC,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,kCAAkC;;;;;;;;;;;wBAiCxC,gBACd,SACA,OACA,UACA,QACA,UACA,UACA,WACA,OACA,WACG,QACF,qCAAkB,IAAA;yBAXL"}
@@ -4,94 +4,20 @@ import { dataAttr } from "../internal/data-attr.mjs";
4
4
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
6
  import { useLatest } from "../internal/use-latest.mjs";
7
+ import { isPopoverOpen } from "../internal/popover-open.mjs";
7
8
  import { DialogContext } from "../dialog/dialog-context.mjs";
8
9
  import { animationBaseline } from "../internal/use-exit-animation.mjs";
9
- import { getServerTopmostModal, getTopmostModal, subscribeModals } from "../internal/modal-registry.mjs";
10
10
  import { ToastViewportContext } from "./toast-context.mjs";
11
11
  import { toast, toastManagerInternals } from "./toast.mjs";
12
- import { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
12
+ import { DEFAULT_HOTKEY, matchesHotkey, regionLabel } from "./toast-hotkey.mjs";
13
+ import { clearToastTimers, syncToastTimers } from "./toast-timers.mjs";
14
+ import { useModalPortalHost } from "./use-modal-portal-host.mjs";
15
+ import { applyCommands, makeEntry, partition, plainText, withFlags } from "./toast-queue.mjs";
16
+ import { use, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useTransition } from "react";
13
17
  import { createPortal } from "react-dom";
14
18
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
19
  //#region src/toast/toast-viewport.tsx
16
20
  const isDev = process.env.NODE_ENV !== "production";
17
- const DEFAULT_HOTKEY = ["F8"];
18
- const MODIFIER_NAMES = {
19
- altKey: "Alt",
20
- ctrlKey: "Ctrl",
21
- metaKey: "Meta",
22
- shiftKey: "Shift"
23
- };
24
- /** `["altKey", "KeyT"]` → `"Alt+T"`, `["F8"]` → `"F8"`. */
25
- function hotkeyLabel(hotkey) {
26
- return hotkey.map((key) => MODIFIER_NAMES[key] ?? key.replace(/^Key(?=[A-Z]$)/, "").replace(/^Digit/, "")).join("+");
27
- }
28
- /** The region's built-in accessible name (conventions 11): `"Notifications (F8)"`. */
29
- function regionLabel(hotkey) {
30
- if (hotkey === null || hotkey.length === 0) return "Notifications";
31
- return `Notifications (${hotkeyLabel(hotkey)})`;
32
- }
33
- /** The listed keys and modifiers, and no unlisted modifier (Ctrl+F8 is not F8). */
34
- function matchesHotkey(hotkey, event) {
35
- const flags = event;
36
- for (const modifier of Object.keys(MODIFIER_NAMES)) if (flags[modifier] === true !== hotkey.includes(modifier)) return false;
37
- return hotkey.every((key) => key in MODIFIER_NAMES || event.code === key);
38
- }
39
- /** No store: `useSyncExternalStore` only tells the hydration render from a client render. */
40
- const subscribeNothing = () => () => {};
41
- const onClient = () => true;
42
- const onServerOrHydrating = () => false;
43
- /**
44
- * The element the region is portalled into for its whole client life. The library moves this
45
- * element (between its inline anchor and the topmost modal dialog); React never sees the move, so
46
- * the toasts keep their state (an Undo in flight stays pending). `display: contents`: no box.
47
- */
48
- function createHost() {
49
- if (typeof document === "undefined") return null;
50
- const host = document.createElement("div");
51
- host.style.display = "contents";
52
- return host;
53
- }
54
- function makeEntry(options, flags) {
55
- return {
56
- options,
57
- ...flags,
58
- item: {
59
- ...options,
60
- id: options.id,
61
- pending: flags.promisePending || flags.actionPending,
62
- ending: flags.ending
63
- }
64
- };
65
- }
66
- function withFlags(entry, flags) {
67
- return makeEntry(entry.options, {
68
- promisePending: flags.promisePending ?? entry.promisePending,
69
- actionPending: flags.actionPending ?? entry.actionPending,
70
- ending: flags.ending ?? entry.ending
71
- });
72
- }
73
- /** Rendered entries (the first `limit` open ones plus every ending one) and the queued count. */
74
- function partition(entries, limit) {
75
- const visible = [];
76
- const queued = [];
77
- let open = 0;
78
- for (const entry of entries) if (entry.ending) visible.push(entry);
79
- else if (open < limit) {
80
- visible.push(entry);
81
- open++;
82
- } else queued.push(entry);
83
- return {
84
- visible,
85
- queued
86
- };
87
- }
88
- /** Plain text of a `ReactNode` that is text (queued toasts have no DOM to read yet). */
89
- function plainText(node) {
90
- if (typeof node === "string") return node;
91
- if (typeof node === "number" || typeof node === "bigint") return String(node);
92
- if (Array.isArray(node)) return node.map(plainText).join("");
93
- return "";
94
- }
95
21
  /** Document order. */
96
22
  function byDocumentPosition(a, b) {
97
23
  if (a === b) return 0;
@@ -145,59 +71,17 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
145
71
  hotkey,
146
72
  announce
147
73
  });
148
- const container = useSyncExternalStore(subscribeModals, getTopmostModal, getServerTopmostModal);
149
74
  const write = (next) => {
150
75
  entriesRef.current = next;
151
76
  setEntries(next);
152
77
  };
153
- const effectiveDuration = (entry) => {
154
- const own = entry.options.duration;
155
- if (own !== void 0) return own;
156
- return entry.options.action !== void 0 ? null : latest.current.duration;
157
- };
158
78
  const syncTimers = () => {
159
- const map = timers.current;
160
- const { visible } = partition(entriesRef.current, latest.current.limit);
161
- const now = Date.now();
162
- const live = /* @__PURE__ */ new Set();
163
- const halted = !mounted.current || anyPause(pauses.current);
164
- for (const entry of visible) {
165
- if (entry.ending) continue;
166
- const id = entry.options.id;
167
- const ms = effectiveDuration(entry);
168
- if (ms === null) continue;
169
- live.add(id);
170
- let timer = map.get(id);
171
- if (timer === void 0 || timer.duration !== ms) {
172
- if (timer?.handle != null) clearTimeout(timer.handle);
173
- timer = {
174
- duration: ms,
175
- remaining: ms,
176
- startedAt: 0,
177
- handle: null
178
- };
179
- map.set(id, timer);
180
- }
181
- const run = !halted && !entry.item.pending && !suspended.current.has(id);
182
- if (run && timer.handle === null) {
183
- const current = timer;
184
- current.startedAt = now;
185
- current.handle = setTimeout(() => {
186
- current.handle = null;
187
- current.remaining = 0;
188
- close([id], "timeout", void 0);
189
- }, Math.max(0, current.remaining));
190
- } else if (!run && timer.handle !== null) {
191
- clearTimeout(timer.handle);
192
- timer.handle = null;
193
- timer.remaining -= now - timer.startedAt;
194
- }
195
- }
196
- for (const [id, timer] of map) {
197
- if (live.has(id)) continue;
198
- if (timer.handle !== null) clearTimeout(timer.handle);
199
- map.delete(id);
200
- }
79
+ syncToastTimers(timers.current, partition(entriesRef.current, latest.current.limit).visible, {
80
+ halted: !mounted.current || anyPause(pauses.current),
81
+ suspended: suspended.current,
82
+ defaultDuration: latest.current.duration,
83
+ expire: (id) => close([id], "timeout", void 0)
84
+ });
201
85
  };
202
86
  const setPause = (source, value) => {
203
87
  if (pauses.current[source] === value) return;
@@ -254,11 +138,6 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
254
138
  exitBaselines.current.set(id, animationBaseline(element));
255
139
  }
256
140
  };
257
- const clearTimer = (id) => {
258
- const timer = timers.current.get(id);
259
- if (timer?.handle != null) clearTimeout(timer.handle);
260
- timers.current.delete(id);
261
- };
262
141
  const scheduleCloseActions = (closed, reason, event) => {
263
142
  for (const entry of closed) {
264
143
  const closeAction = entry.options.closeAction;
@@ -294,86 +173,23 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
294
173
  write(next);
295
174
  };
296
175
  const apply = (commands) => {
297
- const next = [...entriesRef.current];
298
- const dismissed = [];
299
- for (const command of commands) {
300
- if (command.kind === "dismiss") {
301
- for (let i = 0; i < next.length; i++) {
302
- const entry = next[i];
303
- if (entry.ending) continue;
304
- const id = entry.options.id;
305
- if (command.id !== void 0 && id !== command.id) continue;
306
- dismissed.push(entry);
307
- if (roots.current.has(id)) next[i] = withFlags(entry, { ending: true });
308
- else {
309
- next.splice(i--, 1);
310
- lastAnnounced.current.delete(id);
311
- exitBaselines.current.delete(id);
312
- }
313
- }
314
- continue;
315
- }
316
- const index = next.findIndex((e) => e.options.id === command.id);
317
- const existing = index === -1 ? void 0 : next[index];
318
- if (command.kind === "add") {
319
- const options = {
320
- ...command.options,
321
- id: command.id
322
- };
323
- if (existing !== void 0 && !existing.ending) {
324
- next[index] = makeEntry({
325
- ...existing.options,
326
- ...options
327
- }, {
328
- promisePending: command.pending || existing.promisePending,
329
- actionPending: existing.actionPending,
330
- ending: false
331
- });
332
- continue;
333
- }
334
- if (existing !== void 0) {
335
- next.splice(index, 1);
336
- clearTimer(command.id);
337
- lastAnnounced.current.delete(command.id);
338
- exitBaselines.current.delete(command.id);
339
- }
340
- next.push(makeEntry(options, {
341
- promisePending: command.pending,
342
- actionPending: false,
343
- ending: false
344
- }));
345
- addedSinceEffect.current = true;
346
- } else {
347
- if (existing === void 0) {
348
- if (isDev && !command.settle) console.error(`toast.update: no toast with id "${command.id}"; the update is ignored.`);
349
- continue;
350
- }
351
- if (existing.ending) continue;
352
- next[index] = makeEntry(command.settle ? {
353
- ...command.options,
354
- id: command.id
355
- } : {
356
- ...existing.options,
357
- ...command.options,
358
- id: command.id
359
- }, {
360
- promisePending: command.settle ? false : existing.promisePending,
361
- actionPending: existing.actionPending,
362
- ending: false
363
- });
364
- }
176
+ const result = applyCommands(entriesRef.current, commands, (id) => roots.current.has(id));
177
+ for (const id of result.replaced) clearToastTimers(timers.current, id);
178
+ for (const id of result.forgotten) {
179
+ lastAnnounced.current.delete(id);
180
+ exitBaselines.current.delete(id);
365
181
  }
366
- if (dismissed.length === 0) {
367
- write(next);
182
+ if (result.added) addedSinceEffect.current = true;
183
+ if (isDev) for (const id of result.missing) console.error(`toast.update: no toast with id "${id}"; the update is ignored.`);
184
+ if (result.dismissed.length === 0) {
185
+ write(result.next);
368
186
  return;
369
187
  }
370
- const stays = new Set(next.filter((e) => !e.ending).map((e) => e.options.id));
371
- const leaving = new Set(dismissed.map((e) => e.options.id).filter((id) => !stays.has(id)));
372
- moveFocusOut(leaving);
373
- snapshotExitBaselines(leaving);
374
- write(next);
188
+ moveFocusOut(result.leaving);
189
+ snapshotExitBaselines(result.leaving);
190
+ write(result.next);
375
191
  syncTimers();
376
- scheduleCloseActions(dismissed, "dismiss", void 0);
192
+ scheduleCloseActions(result.dismissed, "dismiss", void 0);
377
193
  };
378
194
  const setActionPending = (id, pending) => {
379
195
  const index = entriesRef.current.findIndex((e) => e.options.id === id);
@@ -425,8 +241,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
425
241
  /** Forgets the queue of the previous manager (its own copy is retained by that manager). */
426
242
  const reset = () => {
427
243
  moveFocusOut(new Set(entriesRef.current.filter((e) => !e.ending).map((e) => e.options.id)));
428
- for (const timer of timers.current.values()) if (timer.handle !== null) clearTimeout(timer.handle);
429
- timers.current.clear();
244
+ clearToastTimers(timers.current);
430
245
  lastAnnounced.current.clear();
431
246
  exitBaselines.current.clear();
432
247
  write([]);
@@ -503,8 +318,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
503
318
  doc.removeEventListener("visibilitychange", onVisibility);
504
319
  view.removeEventListener("blur", onWindowBlur);
505
320
  view.removeEventListener("focus", onWindowFocus);
506
- for (const timer of map.values()) if (timer.handle !== null) clearTimeout(timer.handle);
507
- map.clear();
321
+ clearToastTimers(map);
508
322
  };
509
323
  }, [handlers, rejected]);
510
324
  const hotkeyKey = hotkey === null ? null : hotkey.join("\0");
@@ -524,21 +338,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
524
338
  doc.addEventListener("keydown", onKeyDown);
525
339
  return () => doc.removeEventListener("keydown", onKeyDown);
526
340
  }, [hotkeyKey, rejected]);
527
- const portalled = useSyncExternalStore(subscribeNothing, onClient, onServerOrHydrating);
528
- const [host] = useState(createHost);
529
- const anchorRef = useRef(null);
530
- useLayoutEffect(() => {
531
- if (host === null) return;
532
- return () => host.remove();
533
- }, [host]);
534
- useLayoutEffect(() => {
535
- if (host === null || !portalled) return;
536
- const target = container ?? anchorRef.current;
537
- if (target === null || host.parentNode === target) return;
538
- const moved = host.parentNode !== null;
539
- target.append(host);
540
- if (moved) setPause("hover", false);
541
- });
341
+ const { portalled, host, anchorRef } = useModalPortalHost(() => setPause("hover", false));
542
342
  useLayoutEffect(() => {
543
343
  const region = regionRef.current;
544
344
  const current = entriesRef.current;
@@ -547,12 +347,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
547
347
  setPause("focus", false);
548
348
  }
549
349
  if (region !== null && region.isConnected && region.hasAttribute("popover")) {
550
- let open = false;
551
- try {
552
- open = region.matches(":popover-open");
553
- } catch {
554
- open = false;
555
- }
350
+ const open = isPopoverOpen(region);
556
351
  try {
557
352
  if (current.length > 0) {
558
353
  if (!open) region.showPopover();
@@ -577,7 +372,7 @@ function ToastViewport({ manager = toast, limit = 3, duration = 5e3, hotkey = DE
577
372
  syncTimers();
578
373
  });
579
374
  const insideDialog = use(DialogContext) !== null;
580
- useDevWarning(insideDialog, "Toast.Viewport: rendered inside a Dialog. The region would close with the dialog; render the Viewport once near the root of the app (it moves into open modal Dialogs by itself).");
375
+ useDevWarning(insideDialog, isDev && "Toast.Viewport: rendered inside a Dialog. The region would close with the dialog; render the Viewport once near the root of the app (it moves into open modal Dialogs by itself).");
581
376
  const { visible, queued } = partition(entries, limit);
582
377
  const state = {
583
378
  toasts: visible.map((e) => e.item),