@funstack/ui 0.1.0-alpha.17 → 0.1.0-alpha.19

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 (347) hide show
  1. package/dist/accordion/accordion-item.mjs +1 -1
  2. package/dist/accordion/accordion-panel.mjs +1 -1
  3. package/dist/accordion/accordion-root.d.mts.map +1 -1
  4. package/dist/accordion/accordion-root.mjs +35 -38
  5. package/dist/accordion/accordion-root.mjs.map +1 -1
  6. package/dist/accordion/accordion-trigger.mjs +1 -1
  7. package/dist/button/button.d.mts +18 -11
  8. package/dist/button/button.d.mts.map +1 -1
  9. package/dist/button/button.mjs +32 -16
  10. package/dist/button/button.mjs.map +1 -1
  11. package/dist/checkbox/checkbox.mjs +1 -1
  12. package/dist/checkbox/checkbox.mjs.map +1 -1
  13. package/dist/checkbox-group/checkbox-group-item.mjs +3 -3
  14. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  15. package/dist/checkbox-group/checkbox-group-parent.mjs +3 -3
  16. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  17. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  18. package/dist/checkbox-group/checkbox-group-root.mjs +15 -12
  19. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  20. package/dist/combobox/combobox-context.mjs.map +1 -1
  21. package/dist/combobox/combobox-input.mjs +2 -2
  22. package/dist/combobox/combobox-input.mjs.map +1 -1
  23. package/dist/combobox/combobox-keyboard.mjs +81 -0
  24. package/dist/combobox/combobox-keyboard.mjs.map +1 -0
  25. package/dist/combobox/combobox-popup.mjs +3 -3
  26. package/dist/combobox/combobox-popup.mjs.map +1 -1
  27. package/dist/combobox/combobox-root.d.mts.map +1 -1
  28. package/dist/combobox/combobox-root.mjs +44 -129
  29. package/dist/combobox/combobox-root.mjs.map +1 -1
  30. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  31. package/dist/combobox/combobox-trigger.mjs +2 -9
  32. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  33. package/dist/combobox/use-active-option.mjs +49 -0
  34. package/dist/combobox/use-active-option.mjs.map +1 -0
  35. package/dist/combobox/use-combobox-form.mjs +3 -5
  36. package/dist/combobox/use-combobox-form.mjs.map +1 -1
  37. package/dist/combobox/use-combobox-text.mjs +43 -0
  38. package/dist/combobox/use-combobox-text.mjs.map +1 -0
  39. package/dist/combobox/use-option-registry.mjs +7 -17
  40. package/dist/combobox/use-option-registry.mjs.map +1 -1
  41. package/dist/dialog/dialog-close.mjs +2 -2
  42. package/dist/dialog/dialog-close.mjs.map +1 -1
  43. package/dist/dialog/dialog-context.mjs.map +1 -1
  44. package/dist/dialog/dialog-dismiss.mjs +108 -0
  45. package/dist/dialog/dialog-dismiss.mjs.map +1 -0
  46. package/dist/dialog/dialog-form.mjs +4 -4
  47. package/dist/dialog/dialog-form.mjs.map +1 -1
  48. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  49. package/dist/dialog/dialog-popup.mjs +73 -161
  50. package/dist/dialog/dialog-popup.mjs.map +1 -1
  51. package/dist/dialog/dialog-root.d.mts.map +1 -1
  52. package/dist/dialog/dialog-root.mjs +4 -3
  53. package/dist/dialog/dialog-root.mjs.map +1 -1
  54. package/dist/dialog/dialog-trigger.mjs +11 -8
  55. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  56. package/dist/docs/components/accordion.md +1 -1
  57. package/dist/docs/components/button.md +13 -10
  58. package/dist/docs/components/dialog.md +4 -4
  59. package/dist/docs/components/field.md +4 -3
  60. package/dist/docs/components/popover.md +4 -4
  61. package/dist/docs/components/toast.md +8 -5
  62. package/dist/docs/concepts/browser-owned-state.md +1 -1
  63. package/dist/docs/roadmap.md +9 -1
  64. package/dist/field/field-control.d.mts +1 -1
  65. package/dist/field/field-control.mjs +2 -2
  66. package/dist/field/field-control.mjs.map +1 -1
  67. package/dist/field/field-description.d.mts +1 -1
  68. package/dist/field/field-description.mjs +1 -1
  69. package/dist/field/field-description.mjs.map +1 -1
  70. package/dist/field/field-error.d.mts +1 -1
  71. package/dist/field/field-error.mjs +1 -1
  72. package/dist/field/field-error.mjs.map +1 -1
  73. package/dist/field/field-label.d.mts +1 -1
  74. package/dist/field/field-label.mjs +1 -1
  75. package/dist/field/field-label.mjs.map +1 -1
  76. package/dist/field/field-root.d.mts +2 -2
  77. package/dist/field/field-root.d.mts.map +1 -1
  78. package/dist/field/field-root.mjs +4 -4
  79. package/dist/field/field-root.mjs.map +1 -1
  80. package/dist/field/index.d.mts +2 -2
  81. package/dist/form/form-root.d.mts +1 -1
  82. package/dist/form/form-root.d.mts.map +1 -1
  83. package/dist/form/form-root.mjs +14 -4
  84. package/dist/form/form-root.mjs.map +1 -1
  85. package/dist/form/form-submit.d.mts +7 -3
  86. package/dist/form/form-submit.d.mts.map +1 -1
  87. package/dist/form/form-submit.mjs +11 -7
  88. package/dist/form/form-submit.mjs.map +1 -1
  89. package/dist/form/index.d.mts +1 -1
  90. package/dist/index.d.mts +2 -2
  91. package/dist/internal/{action-details.mjs → action/action-details.mjs} +1 -1
  92. package/dist/internal/action/action-details.mjs.map +1 -0
  93. package/dist/internal/{call-urgent-handler.mjs → action/call-urgent-handler.mjs} +5 -10
  94. package/dist/internal/action/call-urgent-handler.mjs.map +1 -0
  95. package/dist/internal/{report-dropped.mjs → action/report-dropped.mjs} +3 -21
  96. package/dist/internal/action/report-dropped.mjs.map +1 -0
  97. package/dist/internal/{use-action-trigger.mjs → action/use-action-trigger.mjs} +3 -2
  98. package/dist/internal/action/use-action-trigger.mjs.map +1 -0
  99. package/dist/internal/action/use-connected.mjs +24 -0
  100. package/dist/internal/action/use-connected.mjs.map +1 -0
  101. package/dist/internal/{use-controllable-action.mjs → action/use-controllable-action.mjs} +20 -32
  102. package/dist/internal/action/use-controllable-action.mjs.map +1 -0
  103. package/dist/internal/action/use-pure-trigger.mjs +34 -0
  104. package/dist/internal/action/use-pure-trigger.mjs.map +1 -0
  105. package/dist/internal/action/use-step-commit.mjs +147 -0
  106. package/dist/internal/action/use-step-commit.mjs.map +1 -0
  107. package/dist/internal/{field-context.d.mts → form/field-context.d.mts} +1 -1
  108. package/dist/internal/form/field-context.d.mts.map +1 -0
  109. package/dist/internal/{field-context.mjs → form/field-context.mjs} +2 -2
  110. package/dist/internal/form/field-context.mjs.map +1 -0
  111. package/dist/internal/{focus-first-invalid.mjs → form/focus-first-invalid.mjs} +3 -3
  112. package/dist/internal/form/focus-first-invalid.mjs.map +1 -0
  113. package/dist/internal/{form-status-watcher.mjs → form/form-status-watcher.mjs} +1 -1
  114. package/dist/internal/form/form-status-watcher.mjs.map +1 -0
  115. package/dist/internal/{group-member.mjs → form/group-member.mjs} +2 -2
  116. package/dist/internal/form/group-member.mjs.map +1 -0
  117. package/dist/internal/{sync-presence.mjs → form/sync-presence.mjs} +1 -1
  118. package/dist/internal/form/sync-presence.mjs.map +1 -0
  119. package/dist/internal/{use-checkable-input.mjs → form/use-checkable-input.mjs} +5 -5
  120. package/dist/internal/form/use-checkable-input.mjs.map +1 -0
  121. package/dist/internal/{use-field-control.mjs → form/use-field-control.mjs} +3 -3
  122. package/dist/internal/form/use-field-control.mjs.map +1 -0
  123. package/dist/internal/{use-fieldset-group.mjs → form/use-fieldset-group.mjs} +3 -3
  124. package/dist/internal/form/use-fieldset-group.mjs.map +1 -0
  125. package/dist/internal/{use-form-owner-event.mjs → form/use-form-owner-event.mjs} +1 -1
  126. package/dist/internal/form/use-form-owner-event.mjs.map +1 -0
  127. package/dist/internal/{use-form-reset.mjs → form/use-form-reset.mjs} +15 -3
  128. package/dist/internal/form/use-form-reset.mjs.map +1 -0
  129. package/dist/internal/{use-native-checked.mjs → form/use-native-checked.mjs} +5 -4
  130. package/dist/internal/form/use-native-checked.mjs.map +1 -0
  131. package/dist/internal/{use-native-group-reconciliation.mjs → form/use-native-group-reconciliation.mjs} +8 -8
  132. package/dist/internal/form/use-native-group-reconciliation.mjs.map +1 -0
  133. package/dist/internal/{use-native-select-value.mjs → form/use-native-select-value.mjs} +2 -2
  134. package/dist/internal/form/use-native-select-value.mjs.map +1 -0
  135. package/dist/internal/{validity.d.mts → form/validity.d.mts} +1 -1
  136. package/dist/internal/form/validity.d.mts.map +1 -0
  137. package/dist/internal/{validity.mjs → form/validity.mjs} +1 -1
  138. package/dist/internal/form/validity.mjs.map +1 -0
  139. package/dist/internal/{anchor-position.d.mts → overlay/anchor-position.d.mts} +1 -1
  140. package/dist/internal/overlay/anchor-position.d.mts.map +1 -0
  141. package/dist/internal/{anchor-position.mjs → overlay/anchor-position.mjs} +1 -1
  142. package/dist/internal/overlay/anchor-position.mjs.map +1 -0
  143. package/dist/internal/{content-focus-probe.mjs → overlay/content-focus-probe.mjs} +1 -1
  144. package/dist/internal/overlay/content-focus-probe.mjs.map +1 -0
  145. package/dist/internal/{css-transition-cut.mjs → overlay/css-transition-cut.mjs} +1 -1
  146. package/dist/internal/overlay/css-transition-cut.mjs.map +1 -0
  147. package/dist/internal/{focus-visible.mjs → overlay/focus-visible.mjs} +1 -1
  148. package/dist/internal/overlay/focus-visible.mjs.map +1 -0
  149. package/dist/internal/{invokers.mjs → overlay/invokers.mjs} +1 -1
  150. package/dist/internal/overlay/invokers.mjs.map +1 -0
  151. package/dist/internal/{modal-registry.mjs → overlay/modal-registry.mjs} +1 -1
  152. package/dist/internal/overlay/modal-registry.mjs.map +1 -0
  153. package/dist/internal/{overlay-popup.mjs → overlay/overlay-popup.mjs} +3 -3
  154. package/dist/internal/overlay/overlay-popup.mjs.map +1 -0
  155. package/dist/internal/overlay/overlay-show.mjs +73 -0
  156. package/dist/internal/overlay/overlay-show.mjs.map +1 -0
  157. package/dist/internal/{popover-open.mjs → overlay/popover-open.mjs} +1 -1
  158. package/dist/internal/overlay/popover-open.mjs.map +1 -0
  159. package/dist/internal/{trigger-ref.mjs → overlay/trigger-ref.mjs} +1 -1
  160. package/dist/internal/overlay/trigger-ref.mjs.map +1 -0
  161. package/dist/internal/overlay/use-apply-open-state.mjs +44 -0
  162. package/dist/internal/overlay/use-apply-open-state.mjs.map +1 -0
  163. package/dist/internal/{use-exit-animation.mjs → overlay/use-exit-animation.mjs} +2 -2
  164. package/dist/internal/overlay/use-exit-animation.mjs.map +1 -0
  165. package/dist/internal/{use-interest-dismiss.mjs → overlay/use-interest-dismiss.mjs} +1 -1
  166. package/dist/internal/overlay/use-interest-dismiss.mjs.map +1 -0
  167. package/dist/internal/{use-modal-registration.mjs → overlay/use-modal-registration.mjs} +1 -1
  168. package/dist/internal/overlay/use-modal-registration.mjs.map +1 -0
  169. package/dist/internal/{use-overlay-close.mjs → overlay/use-overlay-close.mjs} +14 -13
  170. package/dist/internal/overlay/use-overlay-close.mjs.map +1 -0
  171. package/dist/internal/overlay/use-overlay-root.d.mts +2 -0
  172. package/dist/internal/{use-overlay-root.mjs → overlay/use-overlay-root.mjs} +44 -28
  173. package/dist/internal/overlay/use-overlay-root.mjs.map +1 -0
  174. package/dist/internal/{use-popover-popup.mjs → overlay/use-popover-popup.mjs} +74 -63
  175. package/dist/internal/overlay/use-popover-popup.mjs.map +1 -0
  176. package/dist/internal/{use-popover-trigger.d.mts → overlay/use-popover-trigger.d.mts} +3 -3
  177. package/dist/internal/overlay/use-popover-trigger.d.mts.map +1 -0
  178. package/dist/internal/{use-popover-trigger.mjs → overlay/use-popover-trigger.mjs} +47 -26
  179. package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -0
  180. package/dist/internal/{use-resolved-placement.mjs → overlay/use-resolved-placement.mjs} +2 -2
  181. package/dist/internal/overlay/use-resolved-placement.mjs.map +1 -0
  182. package/dist/internal/render-element.mjs +47 -9
  183. package/dist/internal/render-element.mjs.map +1 -1
  184. package/dist/internal/transition-boundary.mjs +4 -8
  185. package/dist/internal/transition-boundary.mjs.map +1 -1
  186. package/dist/internal/use-mount-fixed.mjs +22 -0
  187. package/dist/internal/use-mount-fixed.mjs.map +1 -0
  188. package/dist/internal/use-register-count.mjs +4 -1
  189. package/dist/internal/use-register-count.mjs.map +1 -1
  190. package/dist/internal/use-render.mjs +2 -2
  191. package/dist/internal/use-render.mjs.map +1 -1
  192. package/dist/internal/use-roving-focus.mjs.map +1 -1
  193. package/dist/menu/menu-checkbox-item.mjs +2 -2
  194. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  195. package/dist/menu/menu-context.d.mts +1 -1
  196. package/dist/menu/menu-context.mjs.map +1 -1
  197. package/dist/menu/menu-gestures.mjs +1 -1
  198. package/dist/menu/menu-gestures.mjs.map +1 -1
  199. package/dist/menu/menu-item.d.mts.map +1 -1
  200. package/dist/menu/menu-item.mjs +9 -10
  201. package/dist/menu/menu-item.mjs.map +1 -1
  202. package/dist/menu/menu-outside.mjs +1 -1
  203. package/dist/menu/menu-outside.mjs.map +1 -1
  204. package/dist/menu/menu-popup.d.mts +1 -1
  205. package/dist/menu/menu-popup.d.mts.map +1 -1
  206. package/dist/menu/menu-popup.mjs +10 -6
  207. package/dist/menu/menu-popup.mjs.map +1 -1
  208. package/dist/menu/menu-radio-group.mjs +2 -2
  209. package/dist/menu/menu-radio-group.mjs.map +1 -1
  210. package/dist/menu/menu-root.mjs +2 -2
  211. package/dist/menu/menu-root.mjs.map +1 -1
  212. package/dist/menu/menu-submenu-trigger.mjs +3 -3
  213. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  214. package/dist/menu/menu-trigger.d.mts +1 -1
  215. package/dist/menu/menu-trigger.mjs +3 -3
  216. package/dist/menu/menu-trigger.mjs.map +1 -1
  217. package/dist/number-field/number-field-input.mjs +1 -1
  218. package/dist/number-field/number-field-input.mjs.map +1 -1
  219. package/dist/number-field/number-field-root.d.mts.map +1 -1
  220. package/dist/number-field/number-field-root.mjs +43 -107
  221. package/dist/number-field/number-field-root.mjs.map +1 -1
  222. package/dist/popover/popover-close.mjs +3 -3
  223. package/dist/popover/popover-close.mjs.map +1 -1
  224. package/dist/popover/popover-context.mjs.map +1 -1
  225. package/dist/popover/popover-popup.d.mts +1 -1
  226. package/dist/popover/popover-popup.mjs +3 -3
  227. package/dist/popover/popover-popup.mjs.map +1 -1
  228. package/dist/popover/popover-root.mjs +2 -2
  229. package/dist/popover/popover-root.mjs.map +1 -1
  230. package/dist/popover/popover-trigger.d.mts +1 -1
  231. package/dist/popover/popover-trigger.mjs +1 -1
  232. package/dist/popover/popover-trigger.mjs.map +1 -1
  233. package/dist/radio-group/radio-group-item.mjs +3 -3
  234. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  235. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  236. package/dist/radio-group/radio-group-root.mjs +5 -5
  237. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  238. package/dist/select/select-group-label.d.mts.map +1 -1
  239. package/dist/select/select-group-label.mjs +3 -1
  240. package/dist/select/select-group-label.mjs.map +1 -1
  241. package/dist/select/select-option.mjs +1 -1
  242. package/dist/select/select-option.mjs.map +1 -1
  243. package/dist/select/select-root.d.mts.map +1 -1
  244. package/dist/select/select-root.mjs +7 -7
  245. package/dist/select/select-root.mjs.map +1 -1
  246. package/dist/select/select-trigger.d.mts.map +1 -1
  247. package/dist/select/select-trigger.mjs +3 -1
  248. package/dist/select/select-trigger.mjs.map +1 -1
  249. package/dist/select/select-value.mjs +3 -6
  250. package/dist/select/select-value.mjs.map +1 -1
  251. package/dist/slider/slider-root.d.mts.map +1 -1
  252. package/dist/slider/slider-root.mjs +38 -104
  253. package/dist/slider/slider-root.mjs.map +1 -1
  254. package/dist/slider/use-thumb-registry.mjs.map +1 -1
  255. package/dist/switch/switch.mjs +1 -1
  256. package/dist/switch/switch.mjs.map +1 -1
  257. package/dist/tabs/tabs-panel.mjs +1 -1
  258. package/dist/tabs/tabs-panel.mjs.map +1 -1
  259. package/dist/tabs/tabs-root.d.mts.map +1 -1
  260. package/dist/tabs/tabs-root.mjs +4 -4
  261. package/dist/tabs/tabs-root.mjs.map +1 -1
  262. package/dist/{internal → tabs}/use-until-found.mjs +1 -1
  263. package/dist/tabs/use-until-found.mjs.map +1 -0
  264. package/dist/toast/toast-action.d.mts +13 -3
  265. package/dist/toast/toast-action.d.mts.map +1 -1
  266. package/dist/toast/toast-action.mjs +23 -13
  267. package/dist/toast/toast-action.mjs.map +1 -1
  268. package/dist/toast/toast-close.d.mts +13 -2
  269. package/dist/toast/toast-close.d.mts.map +1 -1
  270. package/dist/toast/toast-close.mjs +16 -6
  271. package/dist/toast/toast-close.mjs.map +1 -1
  272. package/dist/toast/toast-root.mjs +1 -1
  273. package/dist/toast/toast-root.mjs.map +1 -1
  274. package/dist/toast/toast-viewport.d.mts.map +1 -1
  275. package/dist/toast/toast-viewport.mjs +48 -143
  276. package/dist/toast/toast-viewport.mjs.map +1 -1
  277. package/dist/toast/use-modal-portal-host.mjs +1 -1
  278. package/dist/toast/use-modal-portal-host.mjs.map +1 -1
  279. package/dist/toast/use-toast-announcements.mjs +46 -0
  280. package/dist/toast/use-toast-announcements.mjs.map +1 -0
  281. package/dist/toast/use-toast-focus.mjs +75 -0
  282. package/dist/toast/use-toast-focus.mjs.map +1 -0
  283. package/dist/toast/use-toast-pauses.mjs +58 -0
  284. package/dist/toast/use-toast-pauses.mjs.map +1 -0
  285. package/dist/toggle/toggle.mjs +2 -2
  286. package/dist/toggle/toggle.mjs.map +1 -1
  287. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  288. package/dist/toggle-group/toggle-group-root.mjs +5 -5
  289. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  290. package/dist/tooltip/tooltip-context.d.mts +1 -1
  291. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  292. package/dist/tooltip/tooltip-popup.mjs +1 -1
  293. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  294. package/dist/tooltip/tooltip-root.d.mts.map +1 -1
  295. package/dist/tooltip/tooltip-root.mjs +9 -4
  296. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  297. package/dist/tooltip/tooltip-trigger.mjs +1 -1
  298. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  299. package/dist/{internal → tooltip}/tooltip-warm.mjs +1 -1
  300. package/dist/tooltip/tooltip-warm.mjs.map +1 -0
  301. package/dist/tooltip/use-tooltip-interaction.mjs +2 -2
  302. package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
  303. package/package.json +1 -1
  304. package/skills/funstack-ui-knowledge/SKILL.md +1 -1
  305. package/dist/internal/action-details.mjs.map +0 -1
  306. package/dist/internal/anchor-position.d.mts.map +0 -1
  307. package/dist/internal/anchor-position.mjs.map +0 -1
  308. package/dist/internal/call-urgent-handler.mjs.map +0 -1
  309. package/dist/internal/content-focus-probe.mjs.map +0 -1
  310. package/dist/internal/css-transition-cut.mjs.map +0 -1
  311. package/dist/internal/field-context.d.mts.map +0 -1
  312. package/dist/internal/field-context.mjs.map +0 -1
  313. package/dist/internal/focus-first-invalid.mjs.map +0 -1
  314. package/dist/internal/focus-visible.mjs.map +0 -1
  315. package/dist/internal/form-status-watcher.mjs.map +0 -1
  316. package/dist/internal/group-member.mjs.map +0 -1
  317. package/dist/internal/invokers.mjs.map +0 -1
  318. package/dist/internal/modal-registry.mjs.map +0 -1
  319. package/dist/internal/overlay-popup.mjs.map +0 -1
  320. package/dist/internal/popover-open.mjs.map +0 -1
  321. package/dist/internal/report-dropped.mjs.map +0 -1
  322. package/dist/internal/sync-presence.mjs.map +0 -1
  323. package/dist/internal/tooltip-warm.mjs.map +0 -1
  324. package/dist/internal/trigger-ref.mjs.map +0 -1
  325. package/dist/internal/use-action-trigger.mjs.map +0 -1
  326. package/dist/internal/use-checkable-input.mjs.map +0 -1
  327. package/dist/internal/use-controllable-action.mjs.map +0 -1
  328. package/dist/internal/use-exit-animation.mjs.map +0 -1
  329. package/dist/internal/use-field-control.mjs.map +0 -1
  330. package/dist/internal/use-fieldset-group.mjs.map +0 -1
  331. package/dist/internal/use-form-owner-event.mjs.map +0 -1
  332. package/dist/internal/use-form-reset.mjs.map +0 -1
  333. package/dist/internal/use-interest-dismiss.mjs.map +0 -1
  334. package/dist/internal/use-modal-registration.mjs.map +0 -1
  335. package/dist/internal/use-native-checked.mjs.map +0 -1
  336. package/dist/internal/use-native-group-reconciliation.mjs.map +0 -1
  337. package/dist/internal/use-native-select-value.mjs.map +0 -1
  338. package/dist/internal/use-overlay-close.mjs.map +0 -1
  339. package/dist/internal/use-overlay-root.d.mts +0 -2
  340. package/dist/internal/use-overlay-root.mjs.map +0 -1
  341. package/dist/internal/use-popover-popup.mjs.map +0 -1
  342. package/dist/internal/use-popover-trigger.d.mts.map +0 -1
  343. package/dist/internal/use-popover-trigger.mjs.map +0 -1
  344. package/dist/internal/use-resolved-placement.mjs.map +0 -1
  345. package/dist/internal/use-until-found.mjs.map +0 -1
  346. package/dist/internal/validity.d.mts.map +0 -1
  347. package/dist/internal/validity.mjs.map +0 -1
@@ -1,27 +1,33 @@
1
1
  "use client";
2
- import { createActionDetails } from "../internal/action-details.mjs";
3
2
  import { dataAttr } from "../internal/data-attr.mjs";
4
- import { useActionTrigger } from "../internal/use-action-trigger.mjs";
5
3
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
6
4
  import { mergeTokenLists } from "../internal/merge-props.mjs";
7
5
  import { resolveStateValue } from "../internal/render-element.mjs";
8
6
  import { useRender } from "../internal/use-render.mjs";
9
7
  import { transitionTypes } from "../internal/transition-types.mjs";
10
8
  import { useLatest } from "../internal/use-latest.mjs";
11
- import { useControllableAction } from "../internal/use-controllable-action.mjs";
12
- import { useFieldControl, useFieldValueChange } from "../internal/use-field-control.mjs";
13
- import { useNativeGroupReconciliation } from "../internal/use-native-group-reconciliation.mjs";
14
- import { SliderContext } from "./slider-context.mjs";
9
+ import { useFieldControl, useFieldValueChange } from "../internal/form/use-field-control.mjs";
10
+ import { useResetTarget } from "../internal/form/use-form-reset.mjs";
11
+ import { useNativeGroupReconciliation } from "../internal/form/use-native-group-reconciliation.mjs";
15
12
  import { useRegisterCount } from "../internal/use-register-count.mjs";
13
+ import { SliderContext } from "./slider-context.mjs";
14
+ import { useStepCommit } from "../internal/action/use-step-commit.mjs";
16
15
  import { clampToNeighbours, equalValues, nearestThumb, platformDefault, pointerValue, resolveTie, sanitize, shapeOf, sliderGeometry, tiedRange, toArray } from "./slider-arithmetic.mjs";
17
16
  import { useSliderDevWarnings } from "./use-slider-dev-warnings.mjs";
18
17
  import { useThumbRegistry } from "./use-thumb-registry.mjs";
19
- import { addTransitionType, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
18
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
20
19
  import { jsx } from "react/jsx-runtime";
21
20
  //#region src/slider/slider-root.tsx
22
21
  const isDev = process.env.NODE_ENV !== "production";
23
22
  const STEP_TYPES = transitionTypes("slider", "change");
24
23
  const COMMIT_TYPES = transitionTypes("slider", "commit");
24
+ /** The `details` fields of both actions. */
25
+ function sliderDetails(reason, thumb) {
26
+ return {
27
+ reason,
28
+ thumb
29
+ };
30
+ }
25
31
  function replaceAt(values, index, value) {
26
32
  return values.map((v, i) => i === index ? value : v);
27
33
  }
@@ -59,52 +65,27 @@ function SliderRootImpl(props) {
59
65
  const labelId = `${id}-label`;
60
66
  const [shape] = useState(() => shapeOf(value ?? defaultValue) ?? "number");
61
67
  const fromArray = useCallback((values) => shape === "number" ? values[0] : values, [shape]);
62
- const [live, setLive] = useState(null);
63
68
  const [gestureThumb, setGestureThumb] = useState(null);
64
- /**
65
- * A step was taken and its gesture's commit has not been dispatched yet. Holds `live` on
66
- * screen between a key's native `input` and `change` when no step transition runs (no
67
- * `valueChangeAction`): otherwise react-dom restores the controlled input to the old value
68
- * after `input`, and Firefox then fires no `change`.
69
- */
70
- const [stepHeld, setStepHeld] = useState(false);
71
- const [pendingThumb, setPendingThumb] = useState(null);
72
- /** The value of the latest step, read by the commit in the same or a later event. */
73
- const liveRef = useRef(null);
74
- /** The shown value when the open gesture began; `null` when no gesture is open. */
75
- const gestureStart = useRef(null);
76
69
  const activeGesture = useRef(null);
77
- const commitSeq = useRef(0);
78
70
  const trackRef = useRef(null);
79
- const runCommit = async (next, details) => {
80
- const seq = ++commitSeq.current;
81
- try {
82
- await valueCommitAction?.(next, details);
83
- } catch (error) {
84
- if (value === void 0 && seq === commitSeq.current) {
85
- await void 0;
86
- stepTo(toArray(committedRef.current), null, "dismiss", void 0);
87
- }
88
- throw error;
89
- }
90
- };
91
- const commitState = useControllableAction({
71
+ const { shown, shownRef, optimisticShown: optimisticValues, pending, pendingSource: pendingThumb, step: stepTo, commit: commitGesture, openGesture, captureGesture, markGestureStart, takeEdit } = useStepCommit({
92
72
  controlled: value,
93
73
  defaultValue,
94
74
  initialValue: platformDefault(min, max, step),
95
- action: runCommit,
96
- transitionTypes: () => COMMIT_TYPES,
75
+ stepAction: valueChangeAction,
76
+ commitAction: valueCommitAction,
77
+ stepTypes: STEP_TYPES,
78
+ commitTypes: COMMIT_TYPES,
97
79
  warn: {
98
80
  component: "Slider.Root",
99
81
  prop: "value"
100
- }
82
+ },
83
+ toShown: toArray,
84
+ fromShown: fromArray,
85
+ equals: equalValues,
86
+ details: sliderDetails,
87
+ captured: gestureThumb !== null
101
88
  });
102
- const { optimistic, committed, dispatch } = commitState;
103
- const committedRef = useLatest(committed);
104
- const { pending: stepPending, run: runStep } = useActionTrigger({ ignoreWhilePending: false });
105
- const optimisticValues = useMemo(() => toArray(optimistic), [optimistic]);
106
- const shown = (gestureThumb !== null || stepHeld || stepPending || commitState.pending) && live !== null ? live : optimisticValues;
107
- const pending = stepPending || commitState.pending;
108
89
  const thumbCount = shown.length;
109
90
  const field = useFieldControl({
110
91
  labelable: thumbCount === 1,
@@ -119,16 +100,7 @@ function SliderRootImpl(props) {
119
100
  const thumbId = useCallback((index) => index === 0 && fieldId !== void 0 ? fieldId : `${id}-thumb-${index}`, [id, fieldId]);
120
101
  const rootRef = thumbCount > 1 ? field.ref : void 0;
121
102
  useDevWarning(field.inField && field.required, isDev && "Slider.Root: a range is never empty, so `required` on the enclosing Field.Root has no effect on the slider.");
122
- /**
123
- * The reason of the latest change the user or the platform made, consumed by the Field
124
- * notification below: `"activate"` dismisses a shown server error, a rollback does not.
125
- */
126
- const lastReason = useRef(null);
127
- useFieldValueChange(optimisticValues.join("\0"), () => {
128
- const edit = lastReason.current === "activate";
129
- lastReason.current = null;
130
- return edit;
131
- });
103
+ useFieldValueChange(optimisticValues.join("\0"), takeEdit);
132
104
  const { "aria-labelledby": fieldLabelledBy, "aria-describedby": fieldDescribedBy, "aria-invalid": fieldInvalid, "data-invalid": fieldDataInvalid } = field.attributes;
133
105
  const inField = field.inField;
134
106
  const fieldRef = field.ref;
@@ -151,12 +123,7 @@ function SliderRootImpl(props) {
151
123
  fieldDataInvalid,
152
124
  fieldName
153
125
  ]);
154
- /** What the thumbs show, for handlers; also written by `stepTo` ahead of the render. */
155
- const shownRef = useLatest(shown);
156
126
  const latest = useLatest({
157
- valueChangeAction,
158
- fromArray,
159
- runStep,
160
127
  min,
161
128
  max,
162
129
  step,
@@ -164,42 +131,10 @@ function SliderRootImpl(props) {
164
131
  orientation,
165
132
  disabled
166
133
  });
167
- const stepTo = useCallback((next, thumb, reason, event) => {
168
- if (equalValues(next, shownRef.current)) return false;
169
- liveRef.current = next;
170
- shownRef.current = next;
171
- lastReason.current = reason;
172
- setLive(next);
173
- setPendingThumb(thumb);
174
- if (reason !== "dismiss") setStepHeld(true);
175
- const { valueChangeAction: action, fromArray: toValue, runStep: run } = latest.current;
176
- if (action === void 0) return true;
177
- run(() => {
178
- for (const type of STEP_TYPES) addTransitionType(type);
179
- return action?.(toValue(next), createActionDetails(event, {
180
- reason,
181
- thumb
182
- }));
183
- });
184
- return true;
185
- }, [latest, shownRef]);
186
- const commitGesture = useCallback((thumb, reason, event) => {
187
- const start = gestureStart.current;
188
- gestureStart.current = null;
189
- setStepHeld(false);
190
- const next = liveRef.current;
191
- if (start === null || next === null || equalValues(next, start)) return;
192
- lastReason.current = reason;
193
- setPendingThumb(thumb);
194
- dispatch(latest.current.fromArray(next), createActionDetails(event, {
195
- reason,
196
- thumb
197
- }));
198
- }, [dispatch, latest]);
199
134
  const { registry, registerThumb, formElement } = useThumbRegistry();
200
135
  const { count: labelCount, register: registerLabel, countRef: labelCountRef } = useRegisterCount();
201
- const [mountValue] = useState(value);
202
- const resetTarget = () => value !== void 0 ? toArray(mountValue ?? value) : toArray(defaultValue ?? platformDefault(min, max, step));
136
+ const resetBase = useResetTarget(value, defaultValue);
137
+ const resetTarget = () => toArray(resetBase ?? value ?? platformDefault(min, max, step));
203
138
  const readCurrent = () => shownRef.current.map((v, index) => {
204
139
  const input = registry.get(index);
205
140
  if (input === void 0) return v;
@@ -217,9 +152,7 @@ function SliderRootImpl(props) {
217
152
  },
218
153
  onPlatformChange: (next, event) => {
219
154
  if (next.length !== shownRef.current.length) return;
220
- const before = shownRef.current;
221
- gestureStart.current = before;
222
- liveRef.current = before;
155
+ openGesture();
223
156
  stepTo(next, null, "platform", event);
224
157
  commitGesture(null, "platform", event);
225
158
  },
@@ -231,10 +164,12 @@ function SliderRootImpl(props) {
231
164
  if (!Number.isFinite(raw)) return;
232
165
  const before = shownRef.current;
233
166
  if (index >= before.length) return;
234
- if (stepTo(replaceAt(before, index, raw), index, "activate", event)) {
235
- if (gestureStart.current === null) gestureStart.current = before;
236
- }
237
- }, [shownRef, stepTo]);
167
+ if (stepTo(replaceAt(before, index, raw), index, "activate", event)) markGestureStart(before);
168
+ }, [
169
+ markGestureStart,
170
+ shownRef,
171
+ stepTo
172
+ ]);
238
173
  const inputCommit = useCallback((index, event) => {
239
174
  if (activeGesture.current !== null) return;
240
175
  commitGesture(index, "activate", event);
@@ -261,13 +196,13 @@ function SliderRootImpl(props) {
261
196
  stepTo(next, index, "activate", event);
262
197
  return;
263
198
  }
264
- gestureStart.current = before;
265
- liveRef.current = before;
199
+ openGesture();
266
200
  stepTo(next, index, "activate", event);
267
201
  commitGesture(index, "activate", event);
268
202
  }, [
269
203
  commitGesture,
270
204
  latest,
205
+ openGesture,
271
206
  shownRef,
272
207
  stepTo
273
208
  ]);
@@ -349,12 +284,11 @@ function SliderRootImpl(props) {
349
284
  detach
350
285
  };
351
286
  setGestureThumb(thumb);
352
- gestureStart.current = shownRef.current;
353
- liveRef.current = shownRef.current;
354
- setLive(shownRef.current);
287
+ captureGesture();
355
288
  registry.get(thumb)?.focus({ focusVisible: false });
356
289
  if (decided !== null) moveTo(thumb, start, event);
357
290
  }, [
291
+ captureGesture,
358
292
  commitGesture,
359
293
  latest,
360
294
  registry,
@@ -1 +1 @@
1
- {"version":3,"file":"slider-root.mjs","names":[],"sources":["../../src/slider/slider-root.tsx"],"sourcesContent":["\"use client\";\nimport { addTransitionType, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeTokenLists } from \"../internal/merge-props.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n Orientation,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useFieldControl, useFieldValueChange } from \"../internal/use-field-control.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useNativeGroupReconciliation } from \"../internal/use-native-group-reconciliation.js\";\nimport { useRegisterCount } from \"../internal/use-register-count.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport {\n clampToNeighbours,\n equalValues,\n nearestThumb,\n platformDefault,\n pointerValue,\n resolveTie,\n sanitize,\n shapeOf,\n sliderGeometry,\n tiedRange,\n toArray,\n} from \"./slider-arithmetic.js\";\nimport { SliderContext } from \"./slider-context.js\";\nimport type { SliderContextValue, SliderFieldWiring } from \"./slider-context.js\";\nimport { useSliderDevWarnings } from \"./use-slider-dev-warnings.js\";\nimport { useThumbRegistry } from \"./use-thumb-registry.js\";\n\n/** One number (one thumb) or one number per thumb, in ascending order. */\nexport type SliderValue = number | readonly number[];\n\n/** The arrow-key axis and layout of a Slider. */\nexport type SliderOrientation = Orientation;\n\n/** Details passed as the second argument of `Slider.Root`'s `valueChangeAction` (each step). */\nexport interface SliderValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user moved a thumb (`details.event` is the native `input` event for a key\n * press, the `pointerdown` / `pointermove` / `pointerup` for a drag, the `keydown` for a\n * JS-normalised key).\n * `\"platform\"`: a form reset (the `reset` event) or a value found in the inputs at mount\n * (`undefined`).\n * `\"dismiss\"`: the commit action rejected and the slider reverted to the committed value\n * (uncontrolled mode; `undefined`).\n */\n readonly reason: ChangeReason;\n /** Index of the thumb that moved; `null` on a platform path or a revert, where several may change. */\n readonly thumb: number | null;\n}\n\n/** Details passed as the second argument of `Slider.Root`'s `valueCommitAction` (each gesture). */\nexport interface SliderValueCommitDetails extends ActionDetails {\n /**\n * `\"activate\"`: a gesture ended (`details.event` is the native `change` event for a key press,\n * the `pointerup` / `pointercancel` / `lostpointercapture` for a drag, the `keydown` for a\n * JS-normalised key). `\"platform\"`: a form reset (the `reset` event) or mount reconciliation\n * (`undefined`). Never `\"dismiss\"`.\n */\n readonly reason: ChangeReason;\n /** Index of the thumb the gesture moved; `null` on a platform path. */\n readonly thumb: number | null;\n}\n\n/**\n * State of `Slider.Root` and `Slider.Label`, passed to the function forms of `className`,\n * `style`, `children` and `render`.\n */\nexport interface SliderRootState<T extends SliderValue = number> {\n /**\n * The value the thumbs show: the value a gesture has reached while a pointer is captured or a\n * step or commit is in flight, else the optimistic value. Content rendered from it must not\n * suspend.\n */\n readonly value: T;\n /** `value` as an array, one entry per thumb, in thumb order. */\n readonly values: readonly number[];\n /** A step or commit dispatched through this Slider is in flight. */\n readonly pending: boolean;\n /** A pointer is captured on a thumb. */\n readonly dragging: boolean;\n /** The `orientation` prop. */\n readonly orientation: SliderOrientation;\n /** The `disabled` prop, or the enclosing Field's. */\n readonly disabled: boolean;\n /** The `min` prop. */\n readonly min: number;\n /** The `max` prop. */\n readonly max: number;\n /** The `step` prop. */\n readonly step: number;\n}\n\n/**\n * Props of `Slider.Root`. `T` is `number` (one thumb) or `readonly number[]` (one entry per\n * thumb), inferred from `value` / `defaultValue`.\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport interface SliderRootProps<T extends SliderValue = number> extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"defaultValue\"\n | \"role\"\n | \"className\"\n | \"style\"\n | \"children\"\n // The value attributes are the native inputs' (design 8): never authored.\n | \"aria-valuemin\"\n | \"aria-valuemax\"\n | \"aria-valuenow\"\n | \"aria-valuetext\"\n | \"aria-orientation\"\n> {\n /** Controlled value: one number, or one per thumb in ascending order. `undefined`: uncontrolled. */\n value?: T;\n /**\n * Initial value in uncontrolled mode; also the form-reset target (latest value).\n *\n * @defaultValue the platform's midpoint, `min + (max - min) / 2`, snapped to `step`\n */\n defaultValue?: T;\n /**\n * Runs inside the Root's step transition on every step: each pointer move, each key press,\n * each platform change, and the revert after a rejected commit (`reason: \"dismiss\"`,\n * uncontrolled). Awaited; `data-pending` meanwhile (without this action a step starts no\n * transition and is never pending). Adopt the value here in a controlled\n * parent (`setValue(next)` in the sync prefix is a transition update). Not the place for a\n * save: a pending async action entangles every transition in the app, and a drag is many\n * steps. A `setState` after your own `await` needs `startTransition`.\n */\n valueChangeAction?: ChangeAction<T, SliderValueChangeDetails>;\n /**\n * Runs inside the Root's commit transition once per gesture: pointer release, each key press,\n * a form reset, a value found at mount. Awaited; the thumb keeps the gesture's value and shows\n * `data-pending` until it settles; in uncontrolled mode the value is committed when it\n * resolves and reverts to the previous value if it rejects. May be a Server Function.\n */\n valueCommitAction?: ChangeAction<T, SliderValueCommitDetails>;\n /**\n * Lower bound of the range.\n *\n * @defaultValue `0`\n */\n min?: number;\n /**\n * Upper bound of the range. A `max` that is not on the step grid from `min` is unreachable, as\n * on a native range (dev warning).\n *\n * @defaultValue `100`\n */\n max?: number;\n /**\n * Must be positive. Values snap to `min + n × step`.\n *\n * @defaultValue `1`\n */\n step?: number;\n /**\n * Minimum number of steps between two adjacent thumbs.\n *\n * @defaultValue `0` (thumbs may share a value)\n */\n minStepsBetweenThumbs?: number;\n /**\n * Layout and arrow-key axis. Vertical sliders have `min` at the bottom.\n *\n * @defaultValue `\"horizontal\"`\n */\n orientation?: SliderOrientation;\n /**\n * `aria-valuetext` for a thumb, from the value it shows. Set it when the number alone is not\n * meaningful (\"3 of 5 stars\", \"Tuesday\"). Default: none (the number is announced).\n */\n getAriaValueText?: (value: number, index: number) => string;\n /**\n * Form field name for every thumb's input (a Thumb's own `name` wins). With several thumbs,\n * read with `FormData.getAll()`.\n */\n name?: string;\n /** The `form` attribute for every thumb's input (a Thumb's own `form` wins). */\n form?: string;\n /**\n * Disables every input (native `disabled`; not submitted) and the pointer. Never set while\n * pending. Inside a `Field.Root`, the Field's `disabled` also applies.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SliderRootState<T>>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SliderRootState<T>>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, SliderRootState<T>>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, SliderRootState<T>>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst STEP_TYPES = transitionTypes(\"slider\", \"change\");\nconst COMMIT_TYPES = transitionTypes(\"slider\", \"commit\");\n\nfunction replaceAt(values: readonly number[], index: number, value: number): readonly number[] {\n return values.map((v, i) => (i === index ? value : v));\n}\n\n/** Writes each registered input's `defaultValue` (the attribute a form reset restores). */\nfunction writeDefaults(\n registry: ReadonlyMap<number, HTMLInputElement>,\n target: readonly number[],\n): void {\n for (const [index, input] of registry) {\n const entry = target[index];\n if (entry !== undefined) input.defaultValue = String(entry);\n }\n}\n\n/** A pointer captured on a Thumb or the Track (design 4.1). */\ninterface ActiveGesture {\n readonly pointerId: number;\n /** Detaches the gesture's listeners. */\n readonly detach: () => void;\n}\n\n/**\n * Owns the slider's state (design/components/slider.md 2): the committed value through\n * `useControllableAction` with `valueCommitAction` (once per gesture), each step through its own\n * transition (`valueChangeAction`), and the value a gesture has reached in the urgent lane\n * (`live`), which the thumbs show while a pointer is captured or anything is in flight. Also the\n * pointer gesture, the Thumb registry, mount reconciliation and form reset, and the geometry\n * custom properties `--slider-start`, `--slider-end` and `--slider-value-<i>`.\n *\n * Owned keys (conventions 1.2): `role` (`\"group\"` with several thumbs), `aria-labelledby` (the\n * Label's id while a Label is mounted and there are several thumbs; token-merged with the\n * consumer's), `data-pending`, `data-dragging`, `data-orientation`, `data-disabled`. The custom\n * properties are merged into `style`, where the consumer's entries win.\n *\n * Inside a `Field.Root` (design 9.4) the Root calls `useFieldControl`: with one thumb, Thumb 0's\n * input is the Field's labelable control; with several, the Root registers itself as the group\n * and also owns the Field label in `aria-labelledby`, the Field's `aria-describedby` and\n * `data-invalid`. `name` / `disabled` default from the Field.\n */\nfunction SliderRootImpl<T extends SliderValue = number>(props: SliderRootProps<T>) {\n const {\n value,\n defaultValue,\n valueChangeAction,\n valueCommitAction,\n min = 0,\n max = 100,\n step: stepProp = 1,\n minStepsBetweenThumbs = 0,\n orientation = \"horizontal\",\n getAriaValueText,\n name: nameProp,\n form,\n disabled: disabledProp = false,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n const stepValid = Number.isFinite(stepProp) && stepProp > 0;\n const step = stepValid ? stepProp : 1;\n const gap = Math.max(0, minStepsBetweenThumbs) * step;\n\n const id = useId();\n const labelId = `${id}-label`;\n\n // The shape (one number or an array) is fixed at mount (design 3.1).\n const [shape] = useState<\"number\" | \"array\">(() => shapeOf(value ?? defaultValue) ?? \"number\");\n const fromArray = useCallback(\n (values: readonly number[]): T => (shape === \"number\" ? values[0] : values) as T,\n [shape],\n );\n\n // --- State (design 2) ----------------------------------------------------------------------\n\n const [live, setLive] = useState<readonly number[] | null>(null);\n const [gestureThumb, setGestureThumb] = useState<number | null>(null);\n /**\n * A step was taken and its gesture's commit has not been dispatched yet. Holds `live` on\n * screen between a key's native `input` and `change` when no step transition runs (no\n * `valueChangeAction`): otherwise react-dom restores the controlled input to the old value\n * after `input`, and Firefox then fires no `change`.\n */\n const [stepHeld, setStepHeld] = useState(false);\n const [pendingThumb, setPendingThumb] = useState<number | null>(null);\n\n /** The value of the latest step, read by the commit in the same or a later event. */\n const liveRef = useRef<readonly number[] | null>(null);\n /** The shown value when the open gesture began; `null` when no gesture is open. */\n const gestureStart = useRef<readonly number[] | null>(null);\n const activeGesture = useRef<ActiveGesture | null>(null);\n const commitSeq = useRef(0);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const runCommit = async (next: T, details: SliderValueCommitDetails): Promise<void> => {\n const seq = ++commitSeq.current;\n try {\n await valueCommitAction?.(next, details);\n } catch (error) {\n // Design 2.4: in uncontrolled mode, tell the preview channel about the rollback, for the\n // latest commit only. Yield once to leave the commit's transition (conventions 2.6).\n if (value === undefined && seq === commitSeq.current) {\n await undefined;\n // `stepTo` and `committedRef` are declared below; this runs long after the render.\n stepTo(toArray(committedRef.current), null, \"dismiss\", undefined);\n }\n throw error;\n }\n };\n\n const commitState = useControllableAction<T, SliderValueCommitDetails>({\n controlled: value,\n defaultValue,\n initialValue: platformDefault(min, max, step) as T,\n action: runCommit,\n transitionTypes: () => COMMIT_TYPES,\n warn: { component: \"Slider.Root\", prop: \"value\" },\n });\n const { optimistic, committed, dispatch } = commitState;\n const committedRef = useLatest(committed);\n\n // A step is not a re-entry: a continuous control dispatches one step per key press or pointer\n // move and every step must run (design/components/button.md 16.1), so no in-flight guard.\n const { pending: stepPending, run: runStep } = useActionTrigger({\n ignoreWhilePending: false,\n });\n\n const optimisticValues = useMemo(() => toArray(optimistic), [optimistic]);\n const held = gestureThumb !== null || stepHeld || stepPending || commitState.pending;\n const shown = held && live !== null ? live : optimisticValues;\n const pending = stepPending || commitState.pending;\n\n // --- Inside a Field.Root (design 9.4) ------------------------------------------------------\n\n // One thumb: its input is the Field's labelable control. Several: the Root (`role=\"group\"`)\n // registers, `Field.Label` drops `for` and names the group through `aria-labelledby`.\n const thumbCount = shown.length;\n const field = useFieldControl({\n labelable: thumbCount === 1,\n name: nameProp,\n disabled: disabledProp,\n component: \"Slider.Root\",\n });\n const fieldName = field.fieldName;\n const name = field.name;\n const disabled = field.disabled;\n const fieldId = field.id;\n const thumbId = useCallback(\n (index: number) => (index === 0 && fieldId !== undefined ? fieldId : `${id}-thumb-${index}`),\n [id, fieldId],\n );\n const rootRef = thumbCount > 1 ? field.ref : undefined;\n useDevWarning(\n field.inField && field.required,\n isDev &&\n \"Slider.Root: a range is never empty, so `required` on the enclosing Field.Root has no \" +\n \"effect on the slider.\",\n );\n /**\n * The reason of the latest change the user or the platform made, consumed by the Field\n * notification below: `\"activate\"` dismisses a shown server error, a rollback does not.\n */\n const lastReason = useRef<ChangeReason | null>(null);\n // A pointer gesture and the JS-normalised keys fire no `input` / `change` the Field hears:\n // tell it at the commit, when the optimistic value changes (design 9.4.4).\n useFieldValueChange(optimisticValues.join(\"\\u0000\"), () => {\n const edit = lastReason.current === \"activate\";\n lastReason.current = null;\n return edit;\n });\n const {\n \"aria-labelledby\": fieldLabelledBy,\n \"aria-describedby\": fieldDescribedBy,\n \"aria-invalid\": fieldInvalid,\n \"data-invalid\": fieldDataInvalid,\n } = field.attributes;\n const inField = field.inField;\n const fieldRef = field.ref;\n const fieldWiring = useMemo<SliderFieldWiring | null>(() => {\n if (!inField) return null;\n const single = thumbCount === 1;\n return {\n inputRef: single ? fieldRef : undefined,\n describedBy: single ? fieldDescribedBy : undefined,\n invalid: fieldInvalid,\n dataInvalid: fieldDataInvalid,\n name: fieldName,\n };\n }, [inField, fieldRef, thumbCount, fieldDescribedBy, fieldInvalid, fieldDataInvalid, fieldName]);\n\n /** What the thumbs show, for handlers; also written by `stepTo` ahead of the render. */\n const shownRef = useLatest(shown);\n\n const latest = useLatest({\n valueChangeAction,\n fromArray,\n runStep,\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n });\n\n // --- Step and commit (design 2.4) ---------------------------------------------------------\n\n const stepTo = useCallback(\n (\n next: readonly number[],\n thumb: number | null,\n reason: ChangeReason,\n event: Event | undefined,\n ): boolean => {\n // No-op against what the user sees (conventions 2.3 item 8).\n if (equalValues(next, shownRef.current)) return false;\n liveRef.current = next;\n shownRef.current = next;\n // A controlled parent that adopts steps changes the optimistic value per step.\n lastReason.current = reason;\n setLive(next);\n setPendingThumb(thumb);\n // A revert has no commit after it: the optimistic value already shows the committed one.\n if (reason !== \"dismiss\") setStepHeld(true);\n const { valueChangeAction: action, fromArray: toValue, runStep: run } = latest.current;\n // Without a step action there is nothing to run and no consumer update to keep\n // interruptible: no transition, so `data-pending` does not blink on every pointer move.\n if (action === undefined) return true;\n run(() => {\n for (const type of STEP_TYPES) addTransitionType(type);\n return action?.(toValue(next), createActionDetails(event, { reason, thumb }));\n });\n return true;\n },\n [latest, shownRef],\n );\n\n const commitGesture = useCallback(\n (thumb: number | null, reason: ChangeReason, event: Event | undefined): void => {\n const start = gestureStart.current;\n gestureStart.current = null;\n // The commit's own pending state holds `live` from here (set in this same batch).\n setStepHeld(false);\n const next = liveRef.current;\n // Nothing changed since the gesture began (a drag out and back, a trailing `change`).\n if (start === null || next === null || equalValues(next, start)) return;\n lastReason.current = reason;\n setPendingThumb(thumb);\n dispatch(latest.current.fromArray(next), createActionDetails(event, { reason, thumb }));\n },\n [dispatch, latest],\n );\n\n // --- Thumb registry ------------------------------------------------------------------------\n\n const { registry, registerThumb, formElement } = useThumbRegistry();\n\n // --- Labels --------------------------------------------------------------------------------\n\n // The ref is for the dev warning, which can run before the re-render the registration scheduled.\n const {\n count: labelCount,\n register: registerLabel,\n countRef: labelCountRef,\n } = useRegisterCount();\n\n // --- Residual browser paths: mount reconciliation and form reset (design 9.2, 9.3) --------\n\n const [mountValue] = useState(value);\n const resetTarget = (): readonly number[] =>\n value !== undefined\n ? toArray(mountValue ?? value)\n : toArray(defaultValue ?? platformDefault(min, max, step));\n\n const readCurrent = (): readonly number[] =>\n shownRef.current.map((v, index) => {\n const input = registry.get(index);\n if (input === undefined) return v;\n const read = Number(input.value);\n return Number.isFinite(read) ? read : v;\n });\n\n const { onItemMounted } = useNativeGroupReconciliation<readonly number[]>({\n element: formElement,\n readCurrent,\n readDefault: resetTarget,\n base: () => shownRef.current,\n // Compare as the DOM would hold the values: a consumer's off-grid value is sanitised by the\n // browser (not by jsdom), and that is not a platform change.\n equals: (a, b) => {\n const reference = shownRef.current;\n return equalValues(\n sanitize(a, reference, min, max, step, gap),\n sanitize(b, reference, min, max, step, gap),\n );\n },\n onPlatformChange: (next, event) => {\n if (next.length !== shownRef.current.length) return;\n const before = shownRef.current;\n gestureStart.current = before;\n liveRef.current = before;\n stepTo(next, null, \"platform\", event);\n commitGesture(null, \"platform\", event);\n },\n onResetEvent: () => {\n // react-dom writes `defaultValue = value` after every update of a controlled input, so the\n // reset target is written here, right before the browser's reset algorithm reads it.\n writeDefaults(registry, resetTarget());\n },\n });\n\n // --- Keyboard (design 4.2) -----------------------------------------------------------------\n\n const inputStep = useCallback(\n (index: number, raw: number, event: Event) => {\n if (!Number.isFinite(raw)) return;\n const before = shownRef.current;\n if (index >= before.length) return;\n // A key press is a one-step gesture: it starts at the value shown before it.\n if (stepTo(replaceAt(before, index, raw), index, \"activate\", event)) {\n if (gestureStart.current === null) gestureStart.current = before;\n }\n },\n [shownRef, stepTo],\n );\n\n const inputCommit = useCallback(\n (index: number, event: Event) => {\n // A pointer gesture commits at its release.\n if (activeGesture.current !== null) return;\n commitGesture(index, \"activate\", event);\n },\n [commitGesture],\n );\n\n const inputKeyDown = useCallback(\n (index: number, event: KeyboardEvent) => {\n const {\n orientation: axis,\n disabled: off,\n min: lo,\n max: hi,\n step: inc,\n gap: g,\n } = latest.current;\n if (off) return;\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return;\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n // Vertical: Firefox decreases a vertical range on ArrowRight; the APG says increase.\n // Horizontal RTL: the track is mirrored (min on the right), so ArrowLeft increases;\n // Chromium and Firefox mirror a native range, WebKit does not (design 7). LTR stays native.\n let increaseKey: \"ArrowLeft\" | \"ArrowRight\";\n if (axis === \"vertical\") {\n increaseKey = \"ArrowRight\";\n } else {\n // Read at the keydown: the direction may come from any ancestor and change at any time.\n const input = event.currentTarget as Element | null;\n if (input === null || getComputedStyle(input).direction !== \"rtl\") return;\n increaseKey = \"ArrowLeft\";\n }\n event.preventDefault();\n const before = shownRef.current;\n const current = before[index];\n if (current === undefined) return;\n const delta = event.key === increaseKey ? inc : -inc;\n const next = replaceAt(\n before,\n index,\n clampToNeighbours(before, index, current + delta, lo, hi, inc, g),\n );\n if (activeGesture.current !== null) {\n stepTo(next, index, \"activate\", event);\n return;\n }\n gestureStart.current = before;\n liveRef.current = before;\n stepTo(next, index, \"activate\", event);\n commitGesture(index, \"activate\", event);\n },\n [commitGesture, latest, shownRef, stepTo],\n );\n\n // --- Pointer (design 4.1) ------------------------------------------------------------------\n\n const warnedNoTrack = useRef(false);\n const beginGesture = useCallback(\n (index: number | null, event: PointerEvent, element: HTMLElement) => {\n const { disabled: off } = latest.current;\n if (off || event.button !== 0 || activeGesture.current !== null) return;\n const track = trackRef.current;\n if (track === null) {\n if (isDev && !warnedNoTrack.current) {\n warnedNoTrack.current = true;\n console.error(\n \"Slider.Thumb: a pointer press needs a Slider.Track to map the pointer to a value. \" +\n \"Without a Track the slider is keyboard-only.\",\n );\n }\n return;\n }\n // No text selection, no focus change through the compatibility `mousedown`.\n event.preventDefault();\n const rtl = getComputedStyle(track).direction === \"rtl\";\n\n const valueAt = (clientX: number, clientY: number): number => {\n const { min: lo, max: hi, orientation: axis } = latest.current;\n const rect = (trackRef.current ?? track).getBoundingClientRect();\n return pointerValue(rect, clientX, clientY, axis, rtl, lo, hi);\n };\n const moveTo = (thumb: number, raw: number, cause: Event): void => {\n const { min: lo, max: hi, step: inc, gap: g } = latest.current;\n const before = shownRef.current;\n if (thumb >= before.length) return;\n stepTo(\n replaceAt(before, thumb, clampToNeighbours(before, thumb, raw, lo, hi, inc, g)),\n thumb,\n \"activate\",\n cause,\n );\n };\n\n const start = valueAt(event.clientX, event.clientY);\n const startValues = shownRef.current;\n // A press on a Thumb that shares its value with a neighbour (stacked thumbs) moves the one\n // that can go toward the pointer, the Track's tie rule; when the press is exactly on the\n // value, the first move decides. Otherwise a Thumb press moves that Thumb.\n const tied = index === null ? null : tiedRange(startValues, index);\n /** The thumb the gesture moves; `null` while a press on stacked thumbs is undecided. */\n let decided: number | null =\n index === null ? nearestThumb(startValues, start) : tied ? resolveTie(tied, start) : index;\n /** The thumb shown as dragging and focused meanwhile. */\n let thumb = decided ?? index ?? 0;\n const pointerId = event.pointerId;\n try {\n element.setPointerCapture(pointerId);\n } catch {\n // An inactive pointer id (a synthetic event): the gesture still follows the element.\n }\n\n const decide = (raw: number): boolean => {\n if (decided !== null) return true;\n decided = resolveTie(tied, raw);\n if (decided === null) return false;\n if (decided !== thumb) {\n thumb = decided;\n setGestureThumb(thumb);\n registry.get(thumb)?.focus({ focusVisible: false } as FocusOptions);\n }\n return true;\n };\n const follow = (pointerEvent: PointerEvent): void => {\n const raw = valueAt(pointerEvent.clientX, pointerEvent.clientY);\n if (decide(raw)) moveTo(thumb, raw, pointerEvent);\n };\n\n const onMove = (moveEvent: PointerEvent): void => {\n if (moveEvent.pointerId !== pointerId) return;\n follow(moveEvent);\n };\n const onEnd = (endEvent: PointerEvent): void => {\n if (endEvent.pointerId !== pointerId) return;\n detach();\n // The release position is the gesture's last (an engine may coalesce the final move\n // into the `pointerup`); a cancel or a lost capture keeps the last move's value.\n if (endEvent.type === \"pointerup\") follow(endEvent);\n activeGesture.current = null;\n setGestureThumb(null);\n commitGesture(thumb, \"activate\", endEvent);\n };\n const detach = (): void => {\n element.removeEventListener(\"pointermove\", onMove);\n element.removeEventListener(\"pointerup\", onEnd);\n element.removeEventListener(\"pointercancel\", onEnd);\n element.removeEventListener(\"lostpointercapture\", onEnd);\n };\n element.addEventListener(\"pointermove\", onMove);\n element.addEventListener(\"pointerup\", onEnd);\n element.addEventListener(\"pointercancel\", onEnd);\n element.addEventListener(\"lostpointercapture\", onEnd);\n\n activeGesture.current = { pointerId, detach };\n setGestureThumb(thumb);\n gestureStart.current = shownRef.current;\n liveRef.current = shownRef.current;\n // A capture alone holds `live` on screen: start it from what is shown, not from the value\n // an earlier gesture left behind (a press exactly on the current value steps nothing).\n setLive(shownRef.current);\n // `:focus-visible` does not match after a pointer press, as on a native range.\n registry.get(thumb)?.focus({ focusVisible: false } as FocusOptions);\n if (decided !== null) moveTo(thumb, start, event);\n },\n [commitGesture, latest, registry, shownRef, stepTo],\n );\n\n // An unmount mid-gesture leaves no listener behind.\n useEffect(\n () => () => {\n activeGesture.current?.detach();\n activeGesture.current = null;\n },\n [],\n );\n\n // --- Development warnings ------------------------------------------------------------------\n\n useSliderDevWarnings({\n stepProp,\n stepValid,\n min,\n max,\n step,\n value,\n defaultValue,\n shape,\n // Inside a Field, `Field.Label` names the group (design 9.4.2).\n unnamedGroup:\n shown.length > 1 &&\n !inField &&\n rest[\"aria-label\"] === undefined &&\n rest[\"aria-labelledby\"] === undefined,\n labelCountRef,\n });\n\n // --- Render --------------------------------------------------------------------------------\n\n const count = shown.length;\n const geometry = sliderGeometry(shown, min, max);\n\n const shownValue = fromArray(shown);\n const dragging = gestureThumb !== null;\n const state = useMemo<SliderRootState<T>>(\n () => ({\n value: shownValue,\n values: shown,\n pending,\n dragging,\n orientation,\n disabled,\n min,\n max,\n step,\n }),\n [shownValue, shown, pending, dragging, orientation, disabled, min, max, step],\n );\n\n // Memoised: the functions are stable, so this changes only with the state below.\n const context = useMemo<SliderContextValue>(\n () => ({\n state: state as SliderRootState<SliderValue>,\n shown,\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n pending,\n draggingThumb: gestureThumb,\n pendingThumb,\n name,\n form,\n getAriaValueText,\n labelId,\n thumbId,\n trackRef,\n inputStep,\n inputCommit,\n inputKeyDown,\n beginGesture,\n registerThumb,\n registerLabel,\n onItemMounted,\n field: fieldWiring,\n }),\n [\n state,\n shown,\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n pending,\n gestureThumb,\n pendingThumb,\n name,\n form,\n getAriaValueText,\n labelId,\n thumbId,\n inputStep,\n inputCommit,\n inputKeyDown,\n beginGesture,\n registerThumb,\n registerLabel,\n onItemMounted,\n fieldWiring,\n ],\n );\n\n // Several thumbs: the Field's label, then `Slider.Label` while one is mounted (the consumer's\n // tokens come first through the merge). Only when there is one: an owned `undefined` would\n // remove the consumer's own tokens.\n const labelledBy =\n count > 1 ? mergeTokenLists(fieldLabelledBy, labelCount > 0 ? labelId : undefined) : \"\";\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: count > 1 ? \"group\" : undefined,\n ...(labelledBy !== \"\" ? { \"aria-labelledby\": labelledBy } : {}),\n // The group element is described (read when focus enters it); one thumb: its input is.\n ...(count > 1 && fieldDescribedBy !== undefined\n ? { \"aria-describedby\": fieldDescribedBy }\n : {}),\n // Inside a Field only (`aria-invalid` goes on the inputs, never on the group).\n ...(inField ? { \"data-invalid\": fieldDataInvalid } : {}),\n \"data-pending\": dataAttr(pending),\n \"data-dragging\": dataAttr(dragging),\n \"data-orientation\": orientation,\n \"data-disabled\": dataAttr(disabled),\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, SliderRootState<T>>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The geometry properties lose to the consumer's own entries (design 3.1).\n style: (s) => ({ ...(geometry as CSSProperties), ...resolveStateValue(style, s) }),\n children,\n props: rest,\n libraryProps,\n ref: rootRef,\n });\n\n return <SliderContext value={context}>{element}</SliderContext>;\n}\n\nSliderRootImpl.displayName = \"SliderRoot\";\n\n/**\n * `Slider.Root`. Overloaded so that the value's shape is inferred from `value` / `defaultValue`\n * as `number` or `readonly number[]` (an array literal would otherwise infer a mutable\n * `number[]`), and every action and state function receives that shape (design 3.1).\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport const SliderRoot = SliderRootImpl as {\n (props: SliderRootProps<number>): ReactNode;\n (props: SliderRootProps<readonly number[]>): ReactNode;\n (props: SliderRootProps<SliderValue>): ReactNode;\n displayName?: string;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmNA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,aAAa,gBAAgB,UAAU,QAAQ;AACrD,MAAM,eAAe,gBAAgB,UAAU,QAAQ;AAEvD,SAAS,UAAU,QAA2B,OAAe,OAAkC;CAC7F,OAAO,OAAO,KAAK,GAAG,MAAO,MAAM,QAAQ,QAAQ,CAAE;AACvD;;AAGA,SAAS,cACP,UACA,QACM;CACN,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU;EACrC,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,GAAW,MAAM,eAAe,OAAO,KAAK;CAC5D;AACF;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,eAA+C,OAA2B;CACjF,MAAM,EACJ,OACA,cACA,mBACA,mBACA,MAAM,GACN,MAAM,KACN,MAAM,WAAW,GACjB,wBAAwB,GACxB,cAAc,cACd,kBACA,MAAM,UACN,MACA,UAAU,eAAe,OACzB,WACA,OACA,UACA,QACA,GAAG,SACD;CAEJ,MAAM,YAAY,OAAO,SAAS,QAAQ,KAAK,WAAW;CAC1D,MAAM,OAAO,YAAY,WAAW;CACpC,MAAM,MAAM,KAAK,IAAI,GAAG,qBAAqB,IAAI;CAEjD,MAAM,KAAK,MAAM;CACjB,MAAM,UAAU,GAAG,GAAG;CAGtB,MAAM,CAAC,SAAS,eAAmC,QAAQ,SAAS,YAAY,KAAK,QAAQ;CAC7F,M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EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAKA,MAAM,aACJ,QAAQ,IAAI,gBAAgB,iBAAiB,aAAa,IAAI,UAAU,KAAA,CAAS,IAAI;CACvF,MAAM,eAAuE;EAC3E,MAAM,QAAQ,IAAI,UAAU,KAAA;EAC5B,GAAI,eAAe,KAAK,EAAE,mBAAmB,WAAW,IAAI,CAAC;EAE7D,GAAI,QAAQ,KAAK,qBAAqB,KAAA,IAClC,EAAE,oBAAoB,iBAAiB,IACvC,CAAC;EAEL,GAAI,UAAU,EAAE,gBAAgB,iBAAiB,IAAI,CAAC;EACtD,gBAAgB,SAAS,OAAO;EAChC,iBAAiB,SAAS,QAAQ;EAClC,oBAAoB;EACpB,iBAAiB,SAAS,QAAQ;CACpC;CAEA,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAEA,QAAQ,OAAO;GAAE,GAAI;GAA4B,GAAG,kBAAkB,OAAO,CAAC;EAAE;EAChF;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA;CAAuB,CAAA;AAChE;AAEA,eAAe,cAAc;;;;;;;;AAS7B,MAAa,aAAa"}
1
+ {"version":3,"file":"slider-root.mjs","names":[],"sources":["../../src/slider/slider-root.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeTokenLists } from \"../internal/merge-props.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n Orientation,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useFieldControl, useFieldValueChange } from \"../internal/form/use-field-control.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useNativeGroupReconciliation } from \"../internal/form/use-native-group-reconciliation.js\";\nimport { useResetTarget } from \"../internal/form/use-form-reset.js\";\nimport { useRegisterCount } from \"../internal/use-register-count.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useStepCommit } from \"../internal/action/use-step-commit.js\";\nimport {\n clampToNeighbours,\n equalValues,\n nearestThumb,\n platformDefault,\n pointerValue,\n resolveTie,\n sanitize,\n shapeOf,\n sliderGeometry,\n tiedRange,\n toArray,\n} from \"./slider-arithmetic.js\";\nimport { SliderContext } from \"./slider-context.js\";\nimport type { SliderContextValue, SliderFieldWiring } from \"./slider-context.js\";\nimport { useSliderDevWarnings } from \"./use-slider-dev-warnings.js\";\nimport { useThumbRegistry } from \"./use-thumb-registry.js\";\n\n/** One number (one thumb) or one number per thumb, in ascending order. */\nexport type SliderValue = number | readonly number[];\n\n/** The arrow-key axis and layout of a Slider. */\nexport type SliderOrientation = Orientation;\n\n/** Details passed as the second argument of `Slider.Root`'s `valueChangeAction` (each step). */\nexport interface SliderValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user moved a thumb (`details.event` is the native `input` event for a key\n * press, the `pointerdown` / `pointermove` / `pointerup` for a drag, the `keydown` for a\n * JS-normalised key).\n * `\"platform\"`: a form reset (the `reset` event) or a value found in the inputs at mount\n * (`undefined`).\n * `\"dismiss\"`: the commit action rejected and the slider reverted to the committed value\n * (uncontrolled mode; `undefined`).\n */\n readonly reason: ChangeReason;\n /** Index of the thumb that moved; `null` on a platform path or a revert, where several may change. */\n readonly thumb: number | null;\n}\n\n/** Details passed as the second argument of `Slider.Root`'s `valueCommitAction` (each gesture). */\nexport interface SliderValueCommitDetails extends ActionDetails {\n /**\n * `\"activate\"`: a gesture ended (`details.event` is the native `change` event for a key press,\n * the `pointerup` / `pointercancel` / `lostpointercapture` for a drag, the `keydown` for a\n * JS-normalised key). `\"platform\"`: a form reset (the `reset` event) or mount reconciliation\n * (`undefined`). Never `\"dismiss\"`.\n */\n readonly reason: ChangeReason;\n /** Index of the thumb the gesture moved; `null` on a platform path. */\n readonly thumb: number | null;\n}\n\n/**\n * State of `Slider.Root` and `Slider.Label`, passed to the function forms of `className`,\n * `style`, `children` and `render`.\n */\nexport interface SliderRootState<T extends SliderValue = number> {\n /**\n * The value the thumbs show: the value a gesture has reached while a pointer is captured or a\n * step or commit is in flight, else the optimistic value. Content rendered from it must not\n * suspend.\n */\n readonly value: T;\n /** `value` as an array, one entry per thumb, in thumb order. */\n readonly values: readonly number[];\n /** A step or commit dispatched through this Slider is in flight. */\n readonly pending: boolean;\n /** A pointer is captured on a thumb. */\n readonly dragging: boolean;\n /** The `orientation` prop. */\n readonly orientation: SliderOrientation;\n /** The `disabled` prop, or the enclosing Field's. */\n readonly disabled: boolean;\n /** The `min` prop. */\n readonly min: number;\n /** The `max` prop. */\n readonly max: number;\n /** The `step` prop. */\n readonly step: number;\n}\n\n/**\n * Props of `Slider.Root`. `T` is `number` (one thumb) or `readonly number[]` (one entry per\n * thumb), inferred from `value` / `defaultValue`.\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport interface SliderRootProps<T extends SliderValue = number> extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"defaultValue\"\n | \"role\"\n | \"className\"\n | \"style\"\n | \"children\"\n // The value attributes are the native inputs' (design 8): never authored.\n | \"aria-valuemin\"\n | \"aria-valuemax\"\n | \"aria-valuenow\"\n | \"aria-valuetext\"\n | \"aria-orientation\"\n> {\n /** Controlled value: one number, or one per thumb in ascending order. `undefined`: uncontrolled. */\n value?: T;\n /**\n * Initial value in uncontrolled mode; also the form-reset target (latest value).\n *\n * @defaultValue the platform's midpoint, `min + (max - min) / 2`, snapped to `step`\n */\n defaultValue?: T;\n /**\n * Runs inside the Root's step transition on every step: each pointer move, each key press,\n * each platform change, and the revert after a rejected commit (`reason: \"dismiss\"`,\n * uncontrolled). Awaited; `data-pending` meanwhile (without this action a step starts no\n * transition and is never pending). Adopt the value here in a controlled\n * parent (`setValue(next)` in the sync prefix is a transition update). Not the place for a\n * save: a pending async action entangles every transition in the app, and a drag is many\n * steps. A `setState` after your own `await` needs `startTransition`.\n */\n valueChangeAction?: ChangeAction<T, SliderValueChangeDetails>;\n /**\n * Runs inside the Root's commit transition once per gesture: pointer release, each key press,\n * a form reset, a value found at mount. Awaited; the thumb keeps the gesture's value and shows\n * `data-pending` until it settles; in uncontrolled mode the value is committed when it\n * resolves and reverts to the previous value if it rejects. May be a Server Function.\n */\n valueCommitAction?: ChangeAction<T, SliderValueCommitDetails>;\n /**\n * Lower bound of the range.\n *\n * @defaultValue `0`\n */\n min?: number;\n /**\n * Upper bound of the range. A `max` that is not on the step grid from `min` is unreachable, as\n * on a native range (dev warning).\n *\n * @defaultValue `100`\n */\n max?: number;\n /**\n * Must be positive. Values snap to `min + n × step`.\n *\n * @defaultValue `1`\n */\n step?: number;\n /**\n * Minimum number of steps between two adjacent thumbs.\n *\n * @defaultValue `0` (thumbs may share a value)\n */\n minStepsBetweenThumbs?: number;\n /**\n * Layout and arrow-key axis. Vertical sliders have `min` at the bottom.\n *\n * @defaultValue `\"horizontal\"`\n */\n orientation?: SliderOrientation;\n /**\n * `aria-valuetext` for a thumb, from the value it shows. Set it when the number alone is not\n * meaningful (\"3 of 5 stars\", \"Tuesday\"). Default: none (the number is announced).\n */\n getAriaValueText?: (value: number, index: number) => string;\n /**\n * Form field name for every thumb's input (a Thumb's own `name` wins). With several thumbs,\n * read with `FormData.getAll()`.\n */\n name?: string;\n /** The `form` attribute for every thumb's input (a Thumb's own `form` wins). */\n form?: string;\n /**\n * Disables every input (native `disabled`; not submitted) and the pointer. Never set while\n * pending. Inside a `Field.Root`, the Field's `disabled` also applies.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SliderRootState<T>>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SliderRootState<T>>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, SliderRootState<T>>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, SliderRootState<T>>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst STEP_TYPES = transitionTypes(\"slider\", \"change\");\nconst COMMIT_TYPES = transitionTypes(\"slider\", \"commit\");\n\n/** The `details` fields of both actions. */\nfunction sliderDetails(reason: ChangeReason, thumb: number | null) {\n return { reason, thumb };\n}\n\nfunction replaceAt(values: readonly number[], index: number, value: number): readonly number[] {\n return values.map((v, i) => (i === index ? value : v));\n}\n\n/** Writes each registered input's `defaultValue` (the attribute a form reset restores). */\nfunction writeDefaults(\n registry: ReadonlyMap<number, HTMLInputElement>,\n target: readonly number[],\n): void {\n for (const [index, input] of registry) {\n const entry = target[index];\n if (entry !== undefined) input.defaultValue = String(entry);\n }\n}\n\n/** A pointer captured on a Thumb or the Track (design 4.1). */\ninterface ActiveGesture {\n readonly pointerId: number;\n /** Detaches the gesture's listeners. */\n readonly detach: () => void;\n}\n\n/**\n * Owns the slider's state (design/components/slider.md 2): the committed value through\n * `useControllableAction` with `valueCommitAction` (once per gesture), each step through its own\n * transition (`valueChangeAction`), and the value a gesture has reached in the urgent lane\n * (`live`), which the thumbs show while a pointer is captured or anything is in flight. Also the\n * pointer gesture, the Thumb registry, mount reconciliation and form reset, and the geometry\n * custom properties `--slider-start`, `--slider-end` and `--slider-value-<i>`.\n *\n * Owned keys (conventions 1.2): `role` (`\"group\"` with several thumbs), `aria-labelledby` (the\n * Label's id while a Label is mounted and there are several thumbs; token-merged with the\n * consumer's), `data-pending`, `data-dragging`, `data-orientation`, `data-disabled`. The custom\n * properties are merged into `style`, where the consumer's entries win.\n *\n * Inside a `Field.Root` (design 9.4) the Root calls `useFieldControl`: with one thumb, Thumb 0's\n * input is the Field's labelable control; with several, the Root registers itself as the group\n * and also owns the Field label in `aria-labelledby`, the Field's `aria-describedby` and\n * `data-invalid`. `name` / `disabled` default from the Field.\n */\nfunction SliderRootImpl<T extends SliderValue = number>(props: SliderRootProps<T>) {\n const {\n value,\n defaultValue,\n valueChangeAction,\n valueCommitAction,\n min = 0,\n max = 100,\n step: stepProp = 1,\n minStepsBetweenThumbs = 0,\n orientation = \"horizontal\",\n getAriaValueText,\n name: nameProp,\n form,\n disabled: disabledProp = false,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n const stepValid = Number.isFinite(stepProp) && stepProp > 0;\n const step = stepValid ? stepProp : 1;\n const gap = Math.max(0, minStepsBetweenThumbs) * step;\n\n const id = useId();\n const labelId = `${id}-label`;\n\n // The shape (one number or an array) is fixed at mount (design 3.1).\n const [shape] = useState<\"number\" | \"array\">(() => shapeOf(value ?? defaultValue) ?? \"number\");\n const fromArray = useCallback(\n (values: readonly number[]): T => (shape === \"number\" ? values[0] : values) as T,\n [shape],\n );\n\n // --- State (design 2) ----------------------------------------------------------------------\n\n const [gestureThumb, setGestureThumb] = useState<number | null>(null);\n const activeGesture = useRef<ActiveGesture | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n // The step and commit core (design 2.4), shared with NumberField; values are arrays inside.\n const {\n shown,\n shownRef,\n optimisticShown: optimisticValues,\n pending,\n pendingSource: pendingThumb,\n step: stepTo,\n commit: commitGesture,\n openGesture,\n captureGesture,\n markGestureStart,\n takeEdit,\n } = useStepCommit<T, readonly number[], number, ReturnType<typeof sliderDetails>>({\n controlled: value,\n defaultValue,\n initialValue: platformDefault(min, max, step) as T,\n stepAction: valueChangeAction,\n commitAction: valueCommitAction,\n stepTypes: STEP_TYPES,\n commitTypes: COMMIT_TYPES,\n warn: { component: \"Slider.Root\", prop: \"value\" },\n toShown: toArray,\n fromShown: fromArray,\n equals: equalValues,\n details: sliderDetails,\n captured: gestureThumb !== null,\n });\n\n // --- Inside a Field.Root (design 9.4) ------------------------------------------------------\n\n // One thumb: its input is the Field's labelable control. Several: the Root (`role=\"group\"`)\n // registers, `Field.Label` drops `for` and names the group through `aria-labelledby`.\n const thumbCount = shown.length;\n const field = useFieldControl({\n labelable: thumbCount === 1,\n name: nameProp,\n disabled: disabledProp,\n component: \"Slider.Root\",\n });\n const fieldName = field.fieldName;\n const name = field.name;\n const disabled = field.disabled;\n const fieldId = field.id;\n const thumbId = useCallback(\n (index: number) => (index === 0 && fieldId !== undefined ? fieldId : `${id}-thumb-${index}`),\n [id, fieldId],\n );\n const rootRef = thumbCount > 1 ? field.ref : undefined;\n useDevWarning(\n field.inField && field.required,\n isDev &&\n \"Slider.Root: a range is never empty, so `required` on the enclosing Field.Root has no \" +\n \"effect on the slider.\",\n );\n // A pointer gesture and the JS-normalised keys fire no `input` / `change` the Field hears:\n // tell it at the commit, when the optimistic value changes (design 9.4.4). `\"activate\"`\n // dismisses a shown server error, a rollback does not.\n useFieldValueChange(optimisticValues.join(\"\\u0000\"), takeEdit);\n const {\n \"aria-labelledby\": fieldLabelledBy,\n \"aria-describedby\": fieldDescribedBy,\n \"aria-invalid\": fieldInvalid,\n \"data-invalid\": fieldDataInvalid,\n } = field.attributes;\n const inField = field.inField;\n const fieldRef = field.ref;\n const fieldWiring = useMemo<SliderFieldWiring | null>(() => {\n if (!inField) return null;\n const single = thumbCount === 1;\n return {\n inputRef: single ? fieldRef : undefined,\n describedBy: single ? fieldDescribedBy : undefined,\n invalid: fieldInvalid,\n dataInvalid: fieldDataInvalid,\n name: fieldName,\n };\n }, [inField, fieldRef, thumbCount, fieldDescribedBy, fieldInvalid, fieldDataInvalid, fieldName]);\n\n const latest = useLatest({\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n });\n\n // --- Thumb registry ------------------------------------------------------------------------\n\n const { registry, registerThumb, formElement } = useThumbRegistry();\n\n // --- Labels --------------------------------------------------------------------------------\n\n // The ref is for the dev warning, which can run before the re-render the registration scheduled.\n const {\n count: labelCount,\n register: registerLabel,\n countRef: labelCountRef,\n } = useRegisterCount();\n\n // --- Residual browser paths: mount reconciliation and form reset (design 9.2, 9.3) --------\n\n // Neither mode's target given: the current value (controlled after an uncontrolled mount), else\n // the platform default.\n const resetBase = useResetTarget(value, defaultValue);\n const resetTarget = (): readonly number[] =>\n toArray(resetBase ?? value ?? platformDefault(min, max, step));\n\n const readCurrent = (): readonly number[] =>\n shownRef.current.map((v, index) => {\n const input = registry.get(index);\n if (input === undefined) return v;\n const read = Number(input.value);\n return Number.isFinite(read) ? read : v;\n });\n\n const { onItemMounted } = useNativeGroupReconciliation<readonly number[]>({\n element: formElement,\n readCurrent,\n readDefault: resetTarget,\n base: () => shownRef.current,\n // Compare as the DOM would hold the values: a consumer's off-grid value is sanitised by the\n // browser (not by jsdom), and that is not a platform change.\n equals: (a, b) => {\n const reference = shownRef.current;\n return equalValues(\n sanitize(a, reference, min, max, step, gap),\n sanitize(b, reference, min, max, step, gap),\n );\n },\n onPlatformChange: (next, event) => {\n if (next.length !== shownRef.current.length) return;\n openGesture();\n stepTo(next, null, \"platform\", event);\n commitGesture(null, \"platform\", event);\n },\n onResetEvent: () => {\n // react-dom writes `defaultValue = value` after every update of a controlled input, so the\n // reset target is written here, right before the browser's reset algorithm reads it.\n writeDefaults(registry, resetTarget());\n },\n });\n\n // --- Keyboard (design 4.2) -----------------------------------------------------------------\n\n const inputStep = useCallback(\n (index: number, raw: number, event: Event) => {\n if (!Number.isFinite(raw)) return;\n const before = shownRef.current;\n if (index >= before.length) return;\n // A key press is a one-step gesture: it starts at the value shown before it.\n if (stepTo(replaceAt(before, index, raw), index, \"activate\", event)) {\n markGestureStart(before);\n }\n },\n [markGestureStart, shownRef, stepTo],\n );\n\n const inputCommit = useCallback(\n (index: number, event: Event) => {\n // A pointer gesture commits at its release.\n if (activeGesture.current !== null) return;\n commitGesture(index, \"activate\", event);\n },\n [commitGesture],\n );\n\n const inputKeyDown = useCallback(\n (index: number, event: KeyboardEvent) => {\n const {\n orientation: axis,\n disabled: off,\n min: lo,\n max: hi,\n step: inc,\n gap: g,\n } = latest.current;\n if (off) return;\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return;\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n // Vertical: Firefox decreases a vertical range on ArrowRight; the APG says increase.\n // Horizontal RTL: the track is mirrored (min on the right), so ArrowLeft increases;\n // Chromium and Firefox mirror a native range, WebKit does not (design 7). LTR stays native.\n let increaseKey: \"ArrowLeft\" | \"ArrowRight\";\n if (axis === \"vertical\") {\n increaseKey = \"ArrowRight\";\n } else {\n // Read at the keydown: the direction may come from any ancestor and change at any time.\n const input = event.currentTarget as Element | null;\n if (input === null || getComputedStyle(input).direction !== \"rtl\") return;\n increaseKey = \"ArrowLeft\";\n }\n event.preventDefault();\n const before = shownRef.current;\n const current = before[index];\n if (current === undefined) return;\n const delta = event.key === increaseKey ? inc : -inc;\n const next = replaceAt(\n before,\n index,\n clampToNeighbours(before, index, current + delta, lo, hi, inc, g),\n );\n if (activeGesture.current !== null) {\n stepTo(next, index, \"activate\", event);\n return;\n }\n openGesture();\n stepTo(next, index, \"activate\", event);\n commitGesture(index, \"activate\", event);\n },\n [commitGesture, latest, openGesture, shownRef, stepTo],\n );\n\n // --- Pointer (design 4.1) ------------------------------------------------------------------\n\n const warnedNoTrack = useRef(false);\n const beginGesture = useCallback(\n (index: number | null, event: PointerEvent, element: HTMLElement) => {\n const { disabled: off } = latest.current;\n if (off || event.button !== 0 || activeGesture.current !== null) return;\n const track = trackRef.current;\n if (track === null) {\n if (isDev && !warnedNoTrack.current) {\n warnedNoTrack.current = true;\n console.error(\n \"Slider.Thumb: a pointer press needs a Slider.Track to map the pointer to a value. \" +\n \"Without a Track the slider is keyboard-only.\",\n );\n }\n return;\n }\n // No text selection, no focus change through the compatibility `mousedown`.\n event.preventDefault();\n const rtl = getComputedStyle(track).direction === \"rtl\";\n\n const valueAt = (clientX: number, clientY: number): number => {\n const { min: lo, max: hi, orientation: axis } = latest.current;\n const rect = (trackRef.current ?? track).getBoundingClientRect();\n return pointerValue(rect, clientX, clientY, axis, rtl, lo, hi);\n };\n const moveTo = (thumb: number, raw: number, cause: Event): void => {\n const { min: lo, max: hi, step: inc, gap: g } = latest.current;\n const before = shownRef.current;\n if (thumb >= before.length) return;\n stepTo(\n replaceAt(before, thumb, clampToNeighbours(before, thumb, raw, lo, hi, inc, g)),\n thumb,\n \"activate\",\n cause,\n );\n };\n\n const start = valueAt(event.clientX, event.clientY);\n const startValues = shownRef.current;\n // A press on a Thumb that shares its value with a neighbour (stacked thumbs) moves the one\n // that can go toward the pointer, the Track's tie rule; when the press is exactly on the\n // value, the first move decides. Otherwise a Thumb press moves that Thumb.\n const tied = index === null ? null : tiedRange(startValues, index);\n /** The thumb the gesture moves; `null` while a press on stacked thumbs is undecided. */\n let decided: number | null =\n index === null ? nearestThumb(startValues, start) : tied ? resolveTie(tied, start) : index;\n /** The thumb shown as dragging and focused meanwhile. */\n let thumb = decided ?? index ?? 0;\n const pointerId = event.pointerId;\n try {\n element.setPointerCapture(pointerId);\n } catch {\n // An inactive pointer id (a synthetic event): the gesture still follows the element.\n }\n\n const decide = (raw: number): boolean => {\n if (decided !== null) return true;\n decided = resolveTie(tied, raw);\n if (decided === null) return false;\n if (decided !== thumb) {\n thumb = decided;\n setGestureThumb(thumb);\n registry.get(thumb)?.focus({ focusVisible: false } as FocusOptions);\n }\n return true;\n };\n const follow = (pointerEvent: PointerEvent): void => {\n const raw = valueAt(pointerEvent.clientX, pointerEvent.clientY);\n if (decide(raw)) moveTo(thumb, raw, pointerEvent);\n };\n\n const onMove = (moveEvent: PointerEvent): void => {\n if (moveEvent.pointerId !== pointerId) return;\n follow(moveEvent);\n };\n const onEnd = (endEvent: PointerEvent): void => {\n if (endEvent.pointerId !== pointerId) return;\n detach();\n // The release position is the gesture's last (an engine may coalesce the final move\n // into the `pointerup`); a cancel or a lost capture keeps the last move's value.\n if (endEvent.type === \"pointerup\") follow(endEvent);\n activeGesture.current = null;\n setGestureThumb(null);\n commitGesture(thumb, \"activate\", endEvent);\n };\n const detach = (): void => {\n element.removeEventListener(\"pointermove\", onMove);\n element.removeEventListener(\"pointerup\", onEnd);\n element.removeEventListener(\"pointercancel\", onEnd);\n element.removeEventListener(\"lostpointercapture\", onEnd);\n };\n element.addEventListener(\"pointermove\", onMove);\n element.addEventListener(\"pointerup\", onEnd);\n element.addEventListener(\"pointercancel\", onEnd);\n element.addEventListener(\"lostpointercapture\", onEnd);\n\n activeGesture.current = { pointerId, detach };\n setGestureThumb(thumb);\n // A capture alone holds `live` on screen, from what is shown (a press exactly on the\n // current value steps nothing).\n captureGesture();\n // `:focus-visible` does not match after a pointer press, as on a native range.\n registry.get(thumb)?.focus({ focusVisible: false } as FocusOptions);\n if (decided !== null) moveTo(thumb, start, event);\n },\n [captureGesture, commitGesture, latest, registry, shownRef, stepTo],\n );\n\n // An unmount mid-gesture leaves no listener behind.\n useEffect(\n () => () => {\n activeGesture.current?.detach();\n activeGesture.current = null;\n },\n [],\n );\n\n // --- Development warnings ------------------------------------------------------------------\n\n useSliderDevWarnings({\n stepProp,\n stepValid,\n min,\n max,\n step,\n value,\n defaultValue,\n shape,\n // Inside a Field, `Field.Label` names the group (design 9.4.2).\n unnamedGroup:\n shown.length > 1 &&\n !inField &&\n rest[\"aria-label\"] === undefined &&\n rest[\"aria-labelledby\"] === undefined,\n labelCountRef,\n });\n\n // --- Render --------------------------------------------------------------------------------\n\n const count = shown.length;\n const geometry = sliderGeometry(shown, min, max);\n\n const shownValue = fromArray(shown);\n const dragging = gestureThumb !== null;\n const state = useMemo<SliderRootState<T>>(\n () => ({\n value: shownValue,\n values: shown,\n pending,\n dragging,\n orientation,\n disabled,\n min,\n max,\n step,\n }),\n [shownValue, shown, pending, dragging, orientation, disabled, min, max, step],\n );\n\n // Memoised: the functions are stable, so this changes only with the state below.\n const context = useMemo<SliderContextValue>(\n () => ({\n state: state as SliderRootState<SliderValue>,\n shown,\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n pending,\n draggingThumb: gestureThumb,\n pendingThumb,\n name,\n form,\n getAriaValueText,\n labelId,\n thumbId,\n trackRef,\n inputStep,\n inputCommit,\n inputKeyDown,\n beginGesture,\n registerThumb,\n registerLabel,\n onItemMounted,\n field: fieldWiring,\n }),\n [\n state,\n shown,\n min,\n max,\n step,\n gap,\n orientation,\n disabled,\n pending,\n gestureThumb,\n pendingThumb,\n name,\n form,\n getAriaValueText,\n labelId,\n thumbId,\n inputStep,\n inputCommit,\n inputKeyDown,\n beginGesture,\n registerThumb,\n registerLabel,\n onItemMounted,\n fieldWiring,\n ],\n );\n\n // Several thumbs: the Field's label, then `Slider.Label` while one is mounted (the consumer's\n // tokens come first through the merge). Only when there is one: an owned `undefined` would\n // remove the consumer's own tokens.\n const labelledBy =\n count > 1 ? mergeTokenLists(fieldLabelledBy, labelCount > 0 ? labelId : undefined) : \"\";\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: count > 1 ? \"group\" : undefined,\n ...(labelledBy !== \"\" ? { \"aria-labelledby\": labelledBy } : {}),\n // The group element is described (read when focus enters it); one thumb: its input is.\n ...(count > 1 && fieldDescribedBy !== undefined\n ? { \"aria-describedby\": fieldDescribedBy }\n : {}),\n // Inside a Field only (`aria-invalid` goes on the inputs, never on the group).\n ...(inField ? { \"data-invalid\": fieldDataInvalid } : {}),\n \"data-pending\": dataAttr(pending),\n \"data-dragging\": dataAttr(dragging),\n \"data-orientation\": orientation,\n \"data-disabled\": dataAttr(disabled),\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, SliderRootState<T>>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // The geometry properties lose to the consumer's own entries (design 3.1).\n style: (s) => ({ ...(geometry as CSSProperties), ...resolveStateValue(style, s) }),\n children,\n props: rest,\n libraryProps,\n ref: rootRef,\n });\n\n return <SliderContext value={context}>{element}</SliderContext>;\n}\n\nSliderRootImpl.displayName = \"SliderRoot\";\n\n/**\n * `Slider.Root`. Overloaded so that the value's shape is inferred from `value` / `defaultValue`\n * as `number` or `readonly number[]` (an array literal would otherwise infer a mutable\n * `number[]`), and every action and state function receives that shape (design 3.1).\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport const SliderRoot = SliderRootImpl as {\n (props: SliderRootProps<number>): ReactNode;\n (props: SliderRootProps<readonly number[]>): ReactNode;\n (props: SliderRootProps<SliderValue>): ReactNode;\n displayName?: string;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkNA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,aAAa,gBAAgB,UAAU,QAAQ;AACrD,MAAM,eAAe,gBAAgB,UAAU,QAAQ;;AAGvD,SAAS,cAAc,QAAsB,OAAsB;CACjE,OAAO;EAAE;EAAQ;CAAM;AACzB;AAEA,SAAS,UAAU,QAA2B,OAAe,OAAkC;CAC7F,OAAO,OAAO,KAAK,GAAG,MAAO,MAAM,QAAQ,QAAQ,CAAE;AACvD;;AAGA,SAAS,cACP,UACA,QACM;CACN,KAAK,MAAM,CAAC,OAAO,UAAU,UAAU;EACrC,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,GAAW,MAAM,eAAe,OAAO,KAAK;CAC5D;AACF;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,eAA+C,OAA2B;CACjF,MAAM,EACJ,OACA,cACA,mBACA,mBACA,MAAM,GACN,MAAM,KACN,MAAM,WAAW,GACjB,wBAAwB,GACxB,cAAc,cACd,kBACA,MAAM,UACN,MACA,UAAU,eAAe,OACzB,WACA,OACA,UACA,QACA,GAAG,SACD;CAEJ,MAAM,YAAY,OAAO,SAAS,QAAQ,KAAK,WAAW;CAC1D,MAAM,OAAO,YAAY,WAAW;CACpC,MAAM,MAAM,KAAK,IAAI,GAAG,qBAAqB,IAAI;CAEjD,MAAM,KAAK,MAAM;CACjB,MAAM,UAAU,GAAG,GAAG;CAGtB,MAAM,CAAC,SAAS,eAAmC,QAAQ,SAAS,YAAY,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,OAAO,CAAC;EAAE;EAChF;EACA,OAAO;EACP;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA;CAAuB,CAAA;AAChE;AAEA,eAAe,cAAc;;;;;;;;AAS7B,MAAa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-thumb-registry.mjs","names":[],"sources":["../../src/slider/use-thumb-registry.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { FormAssociatedElement } from \"../internal/use-form-owner-event.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ThumbRegistry {\n /** Thumb index → its input. Mutated in place; one identity for the Root's lifetime. */\n readonly registry: ReadonlyMap<number, HTMLInputElement>;\n /** Stable. Each Thumb registers its input from its ref; returns the unregistration. */\n readonly registerThumb: (index: number, input: HTMLInputElement) => () => void;\n /** The first registered input: the form-associated element the reset subscription follows. */\n readonly formElement: RefObject<FormAssociatedElement | null>;\n}\n\n/**\n * `Slider.Root`'s Thumb registry (design 9.2): the inputs by index, read by the residual browser\n * paths and the pointer gesture's focus. Development warns once about two Thumbs with one index\n * and once about Thumbs in different forms.\n */\nexport function useThumbRegistry(): ThumbRegistry {\n const [registry] = useState(() => new Map<number, HTMLInputElement>());\n const warnedDuplicate = useRef(false);\n const warnedForm = useRef(false);\n const registerThumb = useCallback(\n (index: number, input: HTMLInputElement) => {\n const existing = registry.get(index);\n if (isDev && existing !== undefined && existing !== input && !warnedDuplicate.current) {\n warnedDuplicate.current = true;\n console.error(\n `Slider.Thumb: two Thumbs have \\`index={${index}}\\`. Each value needs exactly one ` +\n `Thumb; give every Thumb a distinct index.`,\n );\n }\n if (isDev && !warnedForm.current) {\n for (const other of registry.values()) {\n if (other !== input && other.form !== input.form) {\n warnedForm.current = true;\n console.error(\n \"Slider.Thumb: the thumbs of one Slider belong to different forms (a Thumb's \" +\n \"`form` prop). A form reset is followed through the first thumb's form only; \" +\n \"keep every thumb in one form.\",\n );\n break;\n }\n }\n }\n registry.set(index, input);\n return () => {\n if (registry.get(index) === input) registry.delete(index);\n };\n },\n [registry],\n );\n\n const formElement = useMemo<RefObject<FormAssociatedElement | null>>(\n () => ({\n get current() {\n let first: HTMLInputElement | null = null;\n let firstIndex = Number.POSITIVE_INFINITY;\n for (const [index, input] of registry) {\n if (index < firstIndex) {\n firstIndex = index;\n first = input;\n }\n }\n return first;\n },\n set current(_ignored) {},\n }),\n [registry],\n );\n\n return { registry, registerThumb, formElement };\n}\n"],"mappings":";;;AAKA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AAgBvC,SAAgB,mBAAkC;CAChD,MAAM,CAAC,YAAY,+BAAe,IAAI,IAA8B,CAAC;CACrE,MAAM,kBAAkB,OAAO,KAAK;CACpC,MAAM,aAAa,OAAO,KAAK;CAkD/B,OAAO;EAAE;EAAU,eAjDG,aACnB,OAAe,UAA4B;GAC1C,MAAM,WAAW,SAAS,IAAI,KAAK;GACnC,IAAI,SAAS,aAAa,KAAA,KAAa,aAAa,SAAS,CAAC,gBAAgB,SAAS;IACrF,gBAAgB,UAAU;IAC1B,QAAQ,MACN,0CAA0C,MAAM,4EAElD;GACF;GACA,IAAI,SAAS,CAAC,WAAW,SAClB;SAAA,MAAM,SAAS,SAAS,OAAO,GAClC,IAAI,UAAU,SAAS,MAAM,SAAS,MAAM,MAAM;KAChD,WAAW,UAAU;KACrB,QAAQ,MACN,uLAGF;KACA;IACF;;GAGJ,SAAS,IAAI,OAAO,KAAK;GACzB,aAAa;IACX,IAAI,SAAS,IAAI,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK;GAC1D;EACF,GACA,CAAC,QAAQ,CAqBoB;EAAG,aAlBd,eACX;GACL,IAAI,UAAU;IACZ,IAAI,QAAiC;IACrC,IAAI,aAAa,OAAO;IACxB,KAAK,MAAM,CAAC,OAAO,UAAU,UAC3B,IAAI,QAAQ,YAAY;KACtB,aAAa;KACb,QAAQ;IACV;IAEF,OAAO;GACT;GACA,IAAI,QAAQ,UAAU,CAAC;EACzB,IACA,CAAC,QAAQ,CAGiC;CAAE;AAChD"}
1
+ {"version":3,"file":"use-thumb-registry.mjs","names":[],"sources":["../../src/slider/use-thumb-registry.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { FormAssociatedElement } from \"../internal/form/use-form-owner-event.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ThumbRegistry {\n /** Thumb index → its input. Mutated in place; one identity for the Root's lifetime. */\n readonly registry: ReadonlyMap<number, HTMLInputElement>;\n /** Stable. Each Thumb registers its input from its ref; returns the unregistration. */\n readonly registerThumb: (index: number, input: HTMLInputElement) => () => void;\n /** The first registered input: the form-associated element the reset subscription follows. */\n readonly formElement: RefObject<FormAssociatedElement | null>;\n}\n\n/**\n * `Slider.Root`'s Thumb registry (design 9.2): the inputs by index, read by the residual browser\n * paths and the pointer gesture's focus. Development warns once about two Thumbs with one index\n * and once about Thumbs in different forms.\n */\nexport function useThumbRegistry(): ThumbRegistry {\n const [registry] = useState(() => new Map<number, HTMLInputElement>());\n const warnedDuplicate = useRef(false);\n const warnedForm = useRef(false);\n const registerThumb = useCallback(\n (index: number, input: HTMLInputElement) => {\n const existing = registry.get(index);\n if (isDev && existing !== undefined && existing !== input && !warnedDuplicate.current) {\n warnedDuplicate.current = true;\n console.error(\n `Slider.Thumb: two Thumbs have \\`index={${index}}\\`. Each value needs exactly one ` +\n `Thumb; give every Thumb a distinct index.`,\n );\n }\n if (isDev && !warnedForm.current) {\n for (const other of registry.values()) {\n if (other !== input && other.form !== input.form) {\n warnedForm.current = true;\n console.error(\n \"Slider.Thumb: the thumbs of one Slider belong to different forms (a Thumb's \" +\n \"`form` prop). A form reset is followed through the first thumb's form only; \" +\n \"keep every thumb in one form.\",\n );\n break;\n }\n }\n }\n registry.set(index, input);\n return () => {\n if (registry.get(index) === input) registry.delete(index);\n };\n },\n [registry],\n );\n\n const formElement = useMemo<RefObject<FormAssociatedElement | null>>(\n () => ({\n get current() {\n let first: HTMLInputElement | null = null;\n let firstIndex = Number.POSITIVE_INFINITY;\n for (const [index, input] of registry) {\n if (index < firstIndex) {\n firstIndex = index;\n first = input;\n }\n }\n return first;\n },\n set current(_ignored) {},\n }),\n [registry],\n );\n\n return { registry, registerThumb, formElement };\n}\n"],"mappings":";;;AAKA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AAgBvC,SAAgB,mBAAkC;CAChD,MAAM,CAAC,YAAY,+BAAe,IAAI,IAA8B,CAAC;CACrE,MAAM,kBAAkB,OAAO,KAAK;CACpC,MAAM,aAAa,OAAO,KAAK;CAkD/B,OAAO;EAAE;EAAU,eAjDG,aACnB,OAAe,UAA4B;GAC1C,MAAM,WAAW,SAAS,IAAI,KAAK;GACnC,IAAI,SAAS,aAAa,KAAA,KAAa,aAAa,SAAS,CAAC,gBAAgB,SAAS;IACrF,gBAAgB,UAAU;IAC1B,QAAQ,MACN,0CAA0C,MAAM,4EAElD;GACF;GACA,IAAI,SAAS,CAAC,WAAW,SAClB;SAAA,MAAM,SAAS,SAAS,OAAO,GAClC,IAAI,UAAU,SAAS,MAAM,SAAS,MAAM,MAAM;KAChD,WAAW,UAAU;KACrB,QAAQ,MACN,uLAGF;KACA;IACF;;GAGJ,SAAS,IAAI,OAAO,KAAK;GACzB,aAAa;IACX,IAAI,SAAS,IAAI,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK;GAC1D;EACF,GACA,CAAC,QAAQ,CAqBoB;EAAG,aAlBd,eACX;GACL,IAAI,UAAU;IACZ,IAAI,QAAiC;IACrC,IAAI,aAAa,OAAO;IACxB,KAAK,MAAM,CAAC,OAAO,UAAU,UAC3B,IAAI,QAAQ,YAAY;KACtB,aAAa;KACb,QAAQ;IACV;IAEF,OAAO;GACT;GACA,IAAI,QAAQ,UAAU,CAAC;EACzB,IACA,CAAC,QAAQ,CAGiC;CAAE;AAChD"}
@@ -2,7 +2,7 @@
2
2
  import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
3
3
  import { useRender } from "../internal/use-render.mjs";
4
4
  import { transitionTypes } from "../internal/transition-types.mjs";
5
- import { useCheckableInput } from "../internal/use-checkable-input.mjs";
5
+ import { useCheckableInput } from "../internal/form/use-checkable-input.mjs";
6
6
  //#region src/switch/switch.tsx
7
7
  /**
8
8
  * An on/off switch (WAI-ARIA "Switch" pattern, HTML checkbox input variant). Renders
@@ -1 +1 @@
1
- {"version":3,"file":"switch.mjs","names":[],"sources":["../../src/switch/switch.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useCheckableInput } from \"../internal/use-checkable-input.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\n/** State of `Switch`, passed to the function forms of `className`, `style` and `render`. */\nexport interface SwitchState {\n /** Optimistic checked state: what the user sees, including an in-flight change. */\n readonly checked: boolean;\n /** An action dispatched by this Switch is in flight (including the resulting render). */\n readonly pending: boolean;\n /** The `disabled` prop (or the enclosing `Field.Root`'s). */\n readonly disabled: boolean;\n}\n\n/** Details passed as the second argument of `checkedChangeAction`. */\nexport interface SwitchCheckedChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user toggled the switch (click, Space, label click); `event` is the native\n * `click` event. `\"platform\"`: the browser changed the value itself: a form reset (`event` is\n * the `reset` event) or a click before hydration / Firefox form-state restoration found on\n * mount (`event` is `undefined`).\n */\n readonly reason: ChangeReason;\n}\n\n/**\n * Props of `Switch`.\n *\n * @see https://ui.funstack.work/components/switch\n */\nexport interface SwitchProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"type\"\n | \"role\"\n | \"checked\"\n | \"defaultChecked\"\n | \"onChange\"\n | \"aria-checked\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Controlled checked state. `undefined` means uncontrolled. */\n checked?: boolean;\n /**\n * Initial checked state in uncontrolled mode. Also the value a form reset\n * returns to: the latest prop value is mirrored into the input's `defaultChecked`.\n *\n * @defaultValue `false`\n */\n defaultChecked?: boolean;\n /**\n * Called with the next checked state on every change. Runs inside the Switch's transition; may\n * be sync or async (also a Server Function). Rejections reach the nearest Error Boundary.\n * Also called with `details.reason === \"platform\"` for a form reset or a pre-hydration click.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation). `details.event.preventDefault()` is not a veto and is\n * unsupported here; use controlled mode to veto a change.\n */\n checkedChangeAction?: ChangeAction<boolean, SwitchCheckedChangeDetails>;\n /**\n * Renders a natively disabled input; never dispatches.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Submitted as the input's value when checked.\n *\n * @defaultValue `\"on\"` (platform)\n */\n value?: string;\n /**\n * Forwarded as `default` to the Switch's `<ViewTransition>`. Default: no boundary. Animates the\n * commit that ends an action, not the optimistic flip; animate the flip with CSS on `:checked`.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SwitchState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SwitchState>;\n /**\n * Replace the rendered element (element form) or take over rendering (function form). Must keep\n * an `<input type=\"checkbox\">`.\n */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, SwitchState>;\n}\n\n/**\n * An on/off switch (WAI-ARIA \"Switch\" pattern, HTML checkbox input variant). Renders\n * `<input type=\"checkbox\" role=\"switch\">` whose DOM `checked` is the optimistic state; the input\n * carries `data-pending` while `checkedChangeAction` is in flight and takes part in forms natively.\n *\n * Owned keys (a `render` element's value is overridden): `type`, `role`, `checked`,\n * `defaultChecked`, `aria-checked` (always removed), `disabled`, `data-checked`, `data-pending`,\n * `data-disabled`; inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`,\n * `aria-describedby` (token-merged) and `data-invalid`, and `disabled` / `name` / `required`\n * default from the Field. Event handlers are merged rather than owned: a `render` element's own\n * `onChange` (or `onClick`) runs first, then the library's; an `onClick` that calls\n * `preventDefault()` cancels the change (nothing is dispatched).\n *\n * @see https://ui.funstack.work/components/switch\n */\nexport function Switch({\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n transition,\n className,\n style,\n render,\n ...rest\n}: SwitchProps) {\n const input = useCheckableInput({\n component: \"Switch\",\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n own: rest,\n transitionTypes: (next) => transitionTypes(\"switch\", next ? \"on\" : \"off\"),\n role: \"switch\",\n });\n\n const state: SwitchState = {\n checked: input.optimistic,\n pending: input.pending,\n disabled: input.disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"input\">, SwitchState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n ref: input.ref,\n // Pass-through layer: a `render` element's own props win over these.\n props: rest,\n libraryProps: input.libraryProps,\n });\n\n return useTransitionBoundary(\"Switch\", transition, element);\n}\n\nSwitch.displayName = \"Switch\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,OAAO,EACrB,SACA,gBACA,qBACA,UACA,YACA,WACA,OACA,QACA,GAAG,QACW;CACd,MAAM,QAAQ,kBAAkB;EAC9B,WAAW;EACX;EACA;EACA;EACA;EACA,KAAK;EACL,kBAAkB,SAAS,gBAAgB,UAAU,OAAO,OAAO,KAAK;EACxE,MAAM;CACR,CAAC;CAED,MAAM,QAAqB;EACzB,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;CAClB;CAEA,MAAM,UAAU,UAAuD;EACrE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,KAAK,MAAM;EAEX,OAAO;EACP,cAAc,MAAM;CACtB,CAAC;CAED,OAAO,sBAAsB,UAAU,YAAY,OAAO;AAC5D;AAEA,OAAO,cAAc"}
1
+ {"version":3,"file":"switch.mjs","names":[],"sources":["../../src/switch/switch.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useCheckableInput } from \"../internal/form/use-checkable-input.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\n/** State of `Switch`, passed to the function forms of `className`, `style` and `render`. */\nexport interface SwitchState {\n /** Optimistic checked state: what the user sees, including an in-flight change. */\n readonly checked: boolean;\n /** An action dispatched by this Switch is in flight (including the resulting render). */\n readonly pending: boolean;\n /** The `disabled` prop (or the enclosing `Field.Root`'s). */\n readonly disabled: boolean;\n}\n\n/** Details passed as the second argument of `checkedChangeAction`. */\nexport interface SwitchCheckedChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user toggled the switch (click, Space, label click); `event` is the native\n * `click` event. `\"platform\"`: the browser changed the value itself: a form reset (`event` is\n * the `reset` event) or a click before hydration / Firefox form-state restoration found on\n * mount (`event` is `undefined`).\n */\n readonly reason: ChangeReason;\n}\n\n/**\n * Props of `Switch`.\n *\n * @see https://ui.funstack.work/components/switch\n */\nexport interface SwitchProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"type\"\n | \"role\"\n | \"checked\"\n | \"defaultChecked\"\n | \"onChange\"\n | \"aria-checked\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Controlled checked state. `undefined` means uncontrolled. */\n checked?: boolean;\n /**\n * Initial checked state in uncontrolled mode. Also the value a form reset\n * returns to: the latest prop value is mirrored into the input's `defaultChecked`.\n *\n * @defaultValue `false`\n */\n defaultChecked?: boolean;\n /**\n * Called with the next checked state on every change. Runs inside the Switch's transition; may\n * be sync or async (also a Server Function). Rejections reach the nearest Error Boundary.\n * Also called with `details.reason === \"platform\"` for a form reset or a pre-hydration click.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation). `details.event.preventDefault()` is not a veto and is\n * unsupported here; use controlled mode to veto a change.\n */\n checkedChangeAction?: ChangeAction<boolean, SwitchCheckedChangeDetails>;\n /**\n * Renders a natively disabled input; never dispatches.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Submitted as the input's value when checked.\n *\n * @defaultValue `\"on\"` (platform)\n */\n value?: string;\n /**\n * Forwarded as `default` to the Switch's `<ViewTransition>`. Default: no boundary. Animates the\n * commit that ends an action, not the optimistic flip; animate the flip with CSS on `:checked`.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SwitchState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SwitchState>;\n /**\n * Replace the rendered element (element form) or take over rendering (function form). Must keep\n * an `<input type=\"checkbox\">`.\n */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, SwitchState>;\n}\n\n/**\n * An on/off switch (WAI-ARIA \"Switch\" pattern, HTML checkbox input variant). Renders\n * `<input type=\"checkbox\" role=\"switch\">` whose DOM `checked` is the optimistic state; the input\n * carries `data-pending` while `checkedChangeAction` is in flight and takes part in forms natively.\n *\n * Owned keys (a `render` element's value is overridden): `type`, `role`, `checked`,\n * `defaultChecked`, `aria-checked` (always removed), `disabled`, `data-checked`, `data-pending`,\n * `data-disabled`; inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`,\n * `aria-describedby` (token-merged) and `data-invalid`, and `disabled` / `name` / `required`\n * default from the Field. Event handlers are merged rather than owned: a `render` element's own\n * `onChange` (or `onClick`) runs first, then the library's; an `onClick` that calls\n * `preventDefault()` cancels the change (nothing is dispatched).\n *\n * @see https://ui.funstack.work/components/switch\n */\nexport function Switch({\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n transition,\n className,\n style,\n render,\n ...rest\n}: SwitchProps) {\n const input = useCheckableInput({\n component: \"Switch\",\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n own: rest,\n transitionTypes: (next) => transitionTypes(\"switch\", next ? \"on\" : \"off\"),\n role: \"switch\",\n });\n\n const state: SwitchState = {\n checked: input.optimistic,\n pending: input.pending,\n disabled: input.disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"input\">, SwitchState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n ref: input.ref,\n // Pass-through layer: a `render` element's own props win over these.\n props: rest,\n libraryProps: input.libraryProps,\n });\n\n return useTransitionBoundary(\"Switch\", transition, element);\n}\n\nSwitch.displayName = \"Switch\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,OAAO,EACrB,SACA,gBACA,qBACA,UACA,YACA,WACA,OACA,QACA,GAAG,QACW;CACd,MAAM,QAAQ,kBAAkB;EAC9B,WAAW;EACX;EACA;EACA;EACA;EACA,KAAK;EACL,kBAAkB,SAAS,gBAAgB,UAAU,OAAO,OAAO,KAAK;EACxE,MAAM;CACR,CAAC;CAED,MAAM,QAAqB;EACzB,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;CAClB;CAEA,MAAM,UAAU,UAAuD;EACrE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,KAAK,MAAM;EAEX,OAAO;EACP,cAAc,MAAM;CACtB,CAAC;CAED,OAAO,sBAAsB,UAAU,YAAY,OAAO;AAC5D;AAEA,OAAO,cAAc"}
@@ -4,7 +4,7 @@ import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
4
4
  import { useRender } from "../internal/use-render.mjs";
5
5
  import { useTabsContext } from "./tabs-context.mjs";
6
6
  import { panelId, tabId } from "./tabs-ids.mjs";
7
- import { useUntilFound } from "../internal/use-until-found.mjs";
7
+ import { useUntilFound } from "./use-until-found.mjs";
8
8
  import { Activity } from "react";
9
9
  import { jsx } from "react/jsx-runtime";
10
10
  //#region src/tabs/tabs-panel.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-panel.mjs","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"sourcesContent":["\"use client\";\nimport { Activity } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useUntilFound } from \"../internal/use-until-found.js\";\nimport { useTabsContext } from \"./tabs-context.js\";\nimport type { TabsContextValue, TabsOrientation } from \"./tabs-context.js\";\nimport { panelId, tabId } from \"./tabs-ids.js\";\n\n/**\n * State of `Tabs.Panel`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface TabsPanelState {\n /** The Panel's `value` prop. */\n readonly value: string;\n /** Committed: true only once the action has resolved and the render has committed. */\n readonly selected: boolean;\n /** The Root's `orientation`. */\n readonly orientation: TabsOrientation;\n}\n\n/**\n * Props of `Tabs.Panel`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport interface TabsPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"hidden\" | \"className\" | \"style\" | \"children\"\n> {\n /** The tab value this panel belongs to. */\n value: string;\n /**\n * What happens while this panel is not the committed selection.\n * - `false` (default): the panel is not rendered.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state are preserved, effects\n * are stopped, content is pre-rendered at low priority. Not part of server-rendered HTML.\n * - `\"until-found\"`: rendered with `hidden=\"until-found\"`: DOM, state and effects stay live,\n * the content is in server-rendered HTML, and find-in-page or a text fragment selects the\n * tab (`details.reason === \"platform\"`).\n *\n * @defaultValue `false`\n */\n keepMounted?: boolean | \"until-found\";\n /**\n * Forwarded to the Panel's `<ViewTransition default>`. Default: no boundary.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, TabsPanelState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, TabsPanelState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, TabsPanelState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TabsPanelState>;\n}\n\n/**\n * A `div[role=tabpanel]`. Renders the **committed** selection, so a newly selected panel that\n * suspends keeps the current panel on screen while the Root shows `data-pending`.\n *\n * Owned keys (conventions 1.2): `role`, `id`, `aria-labelledby` (token-merged), `data-selected`,\n * `hidden`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport function TabsPanel(props: TabsPanelProps) {\n const ctx = useTabsContext(\"Tabs.Panel\");\n const { value, keepMounted = false } = props;\n const selected = ctx.committed === value;\n\n if (keepMounted === false) {\n return selected ? <PanelElement {...props} ctx={ctx} selected untilFound={false} /> : null;\n }\n if (keepMounted === true) {\n // The mode only changes when `committed` does, i.e. inside the Root's transition, so the\n // nested `<ViewTransition>` gets enter / exit (conventions 5.5).\n return (\n <Activity mode={selected ? \"visible\" : \"hidden\"}>\n <PanelElement {...props} ctx={ctx} selected={selected} untilFound={false} />\n </Activity>\n );\n }\n return <PanelElement {...props} ctx={ctx} selected={selected} untilFound />;\n}\n\nTabsPanel.displayName = \"TabsPanel\";\n\ninterface PanelElementProps extends TabsPanelProps {\n ctx: TabsContextValue;\n selected: boolean;\n untilFound: boolean;\n}\n\n/** Split out so that an unrendered panel resolves none of its function props. */\nfunction PanelElement({\n ctx,\n selected,\n untilFound,\n value,\n keepMounted: _keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: PanelElementProps) {\n const untilFoundRef = useUntilFound<HTMLDivElement>({\n // Not while this panel is the optimistic target: the browser has revealed it (or the user\n // selected its tab) and the action is pending; re-hiding it would undo the reveal. A\n // rejection or veto reverts the optimistic value, which re-activates the hook.\n active: untilFound && !selected && ctx.optimistic !== value,\n onMatch: (event) => ctx.select(value, event, \"platform\"),\n });\n\n const state: TabsPanelState = { value, selected, orientation: ctx.orientation };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TabsPanelState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n // `tabIndex` defaults to 0 (APG: the panel is a tab stop) and passes through.\n props: { tabIndex: 0, ...rest },\n libraryProps: {\n role: \"tabpanel\",\n id: panelId(ctx.rootId, value),\n \"aria-labelledby\": tabId(ctx.rootId, value),\n \"data-selected\": dataAttr(selected),\n // Boolean form for SSR; `useUntilFound` upgrades it to \"until-found\" (conventions 7.4).\n hidden: untilFound ? !selected : undefined,\n },\n ref: untilFound ? untilFoundRef : undefined,\n });\n\n return useTransitionBoundary(\"Tabs.Panel\", transition, element);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2EA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,MAAM,eAAe,YAAY;CACvC,MAAM,EAAE,OAAO,cAAc,UAAU;CACvC,MAAM,WAAW,IAAI,cAAc;CAEnC,IAAI,gBAAgB,OAClB,OAAO,WAAW,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAK,UAAA;EAAS,YAAY;CAAQ,CAAA,IAAI;CAExF,IAAI,gBAAgB,MAGlB,OACE,oBAAC,UAAD;EAAU,MAAM,WAAW,YAAY;EACrC,UAAA,oBAAC,cAAD;GAAc,GAAI;GAAY;GAAe;GAAU,YAAY;EAAQ,CAAA;CACnE,CAAA;CAGd,OAAO,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAe;EAAU,YAAA;CAAY,CAAA;AAC5E;AAEA,UAAU,cAAc;;AASxB,SAAS,aAAa,EACpB,KACA,UACA,YACA,OACA,aAAa,cACb,YACA,WACA,OACA,UACA,QACA,GAAG,QACiB;CACpB,MAAM,gBAAgB,cAA8B;EAIlD,QAAQ,cAAc,CAAC,YAAY,IAAI,eAAe;EACtD,UAAU,UAAU,IAAI,OAAO,OAAO,OAAO,UAAU;CACzD,CAAC;CAED,MAAM,QAAwB;EAAE;EAAO;EAAU,aAAa,IAAI;CAAY;CAE9E,MAAM,UAAU,UAAwD;EACtE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EAEA,OAAO;GAAE,UAAU;GAAG,GAAG;EAAK;EAC9B,cAAc;GACZ,MAAM;GACN,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC7B,mBAAmB,MAAM,IAAI,QAAQ,KAAK;GAC1C,iBAAiB,SAAS,QAAQ;GAElC,QAAQ,aAAa,CAAC,WAAW,KAAA;EACnC;EACA,KAAK,aAAa,gBAAgB,KAAA;CACpC,CAAC;CAED,OAAO,sBAAsB,cAAc,YAAY,OAAO;AAChE"}
1
+ {"version":3,"file":"tabs-panel.mjs","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"sourcesContent":["\"use client\";\nimport { Activity } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useUntilFound } from \"./use-until-found.js\";\nimport { useTabsContext } from \"./tabs-context.js\";\nimport type { TabsContextValue, TabsOrientation } from \"./tabs-context.js\";\nimport { panelId, tabId } from \"./tabs-ids.js\";\n\n/**\n * State of `Tabs.Panel`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface TabsPanelState {\n /** The Panel's `value` prop. */\n readonly value: string;\n /** Committed: true only once the action has resolved and the render has committed. */\n readonly selected: boolean;\n /** The Root's `orientation`. */\n readonly orientation: TabsOrientation;\n}\n\n/**\n * Props of `Tabs.Panel`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport interface TabsPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"hidden\" | \"className\" | \"style\" | \"children\"\n> {\n /** The tab value this panel belongs to. */\n value: string;\n /**\n * What happens while this panel is not the committed selection.\n * - `false` (default): the panel is not rendered.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state are preserved, effects\n * are stopped, content is pre-rendered at low priority. Not part of server-rendered HTML.\n * - `\"until-found\"`: rendered with `hidden=\"until-found\"`: DOM, state and effects stay live,\n * the content is in server-rendered HTML, and find-in-page or a text fragment selects the\n * tab (`details.reason === \"platform\"`).\n *\n * @defaultValue `false`\n */\n keepMounted?: boolean | \"until-found\";\n /**\n * Forwarded to the Panel's `<ViewTransition default>`. Default: no boundary.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, TabsPanelState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, TabsPanelState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, TabsPanelState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TabsPanelState>;\n}\n\n/**\n * A `div[role=tabpanel]`. Renders the **committed** selection, so a newly selected panel that\n * suspends keeps the current panel on screen while the Root shows `data-pending`.\n *\n * Owned keys (conventions 1.2): `role`, `id`, `aria-labelledby` (token-merged), `data-selected`,\n * `hidden`.\n *\n * @see https://ui.funstack.work/components/tabs\n */\nexport function TabsPanel(props: TabsPanelProps) {\n const ctx = useTabsContext(\"Tabs.Panel\");\n const { value, keepMounted = false } = props;\n const selected = ctx.committed === value;\n\n if (keepMounted === false) {\n return selected ? <PanelElement {...props} ctx={ctx} selected untilFound={false} /> : null;\n }\n if (keepMounted === true) {\n // The mode only changes when `committed` does, i.e. inside the Root's transition, so the\n // nested `<ViewTransition>` gets enter / exit (conventions 5.5).\n return (\n <Activity mode={selected ? \"visible\" : \"hidden\"}>\n <PanelElement {...props} ctx={ctx} selected={selected} untilFound={false} />\n </Activity>\n );\n }\n return <PanelElement {...props} ctx={ctx} selected={selected} untilFound />;\n}\n\nTabsPanel.displayName = \"TabsPanel\";\n\ninterface PanelElementProps extends TabsPanelProps {\n ctx: TabsContextValue;\n selected: boolean;\n untilFound: boolean;\n}\n\n/** Split out so that an unrendered panel resolves none of its function props. */\nfunction PanelElement({\n ctx,\n selected,\n untilFound,\n value,\n keepMounted: _keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: PanelElementProps) {\n const untilFoundRef = useUntilFound<HTMLDivElement>({\n // Not while this panel is the optimistic target: the browser has revealed it (or the user\n // selected its tab) and the action is pending; re-hiding it would undo the reveal. A\n // rejection or veto reverts the optimistic value, which re-activates the hook.\n active: untilFound && !selected && ctx.optimistic !== value,\n onMatch: (event) => ctx.select(value, event, \"platform\"),\n });\n\n const state: TabsPanelState = { value, selected, orientation: ctx.orientation };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TabsPanelState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n // `tabIndex` defaults to 0 (APG: the panel is a tab stop) and passes through.\n props: { tabIndex: 0, ...rest },\n libraryProps: {\n role: \"tabpanel\",\n id: panelId(ctx.rootId, value),\n \"aria-labelledby\": tabId(ctx.rootId, value),\n \"data-selected\": dataAttr(selected),\n // Boolean form for SSR; `useUntilFound` upgrades it to \"until-found\" (conventions 7.4).\n hidden: untilFound ? !selected : undefined,\n },\n ref: untilFound ? untilFoundRef : undefined,\n });\n\n return useTransitionBoundary(\"Tabs.Panel\", transition, element);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA2EA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,MAAM,eAAe,YAAY;CACvC,MAAM,EAAE,OAAO,cAAc,UAAU;CACvC,MAAM,WAAW,IAAI,cAAc;CAEnC,IAAI,gBAAgB,OAClB,OAAO,WAAW,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAK,UAAA;EAAS,YAAY;CAAQ,CAAA,IAAI;CAExF,IAAI,gBAAgB,MAGlB,OACE,oBAAC,UAAD;EAAU,MAAM,WAAW,YAAY;EACrC,UAAA,oBAAC,cAAD;GAAc,GAAI;GAAY;GAAe;GAAU,YAAY;EAAQ,CAAA;CACnE,CAAA;CAGd,OAAO,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAe;EAAU,YAAA;CAAY,CAAA;AAC5E;AAEA,UAAU,cAAc;;AASxB,SAAS,aAAa,EACpB,KACA,UACA,YACA,OACA,aAAa,cACb,YACA,WACA,OACA,UACA,QACA,GAAG,QACiB;CACpB,MAAM,gBAAgB,cAA8B;EAIlD,QAAQ,cAAc,CAAC,YAAY,IAAI,eAAe;EACtD,UAAU,UAAU,IAAI,OAAO,OAAO,OAAO,UAAU;CACzD,CAAC;CAED,MAAM,QAAwB;EAAE;EAAO;EAAU,aAAa,IAAI;CAAY;CAE9E,MAAM,UAAU,UAAwD;EACtE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EAEA,OAAO;GAAE,UAAU;GAAG,GAAG;EAAK;EAC9B,cAAc;GACZ,MAAM;GACN,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC7B,mBAAmB,MAAM,IAAI,QAAQ,KAAK;GAC1C,iBAAiB,SAAS,QAAQ;GAElC,QAAQ,aAAa,CAAC,WAAW,KAAA;EACnC;EACA,KAAK,aAAa,gBAAgB,KAAA;CACpC,CAAC;CAED,OAAO,sBAAsB,cAAc,YAAY,OAAO;AAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs-root.d.mts","names":[],"sources":["../../src/tabs/tabs-root.tsx"],"mappings":";;;;;iBAyBiB,+BAA+B;;;;;;;WAOrC,QAAQ;;;;;;iBAOF;;WAEN;;WAEA;;WAEA,aAAa;;WAEb;;;;;;;iBAQM,sBAAsB,KACrC;;EAIA;;;;;;EAMA;;;;;;;;;EASA,oBAAoB,qBAAqB;;;;;;EAMzC,cAAc;;;;;;EAMd,iBAAiB;;;;;;EAMjB;;;;;;EAMA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;wBAoBpC,WACd,OACA,cACA,mBACA,aACA,gBACA,MACA,UACA,WACA,OACA,UACA,WACG,QACF,gCAAa,IAAA;yBAbA"}
1
+ {"version":3,"file":"tabs-root.d.mts","names":[],"sources":["../../src/tabs/tabs-root.tsx"],"mappings":";;;;;iBA0BiB,+BAA+B;;;;;;;WAOrC,QAAQ;;;;;;iBAOF;;WAEN;;WAEA;;WAEA,aAAa;;WAEb;;;;;;;iBAQM,sBAAsB,KACrC;;EAIA;;;;;;EAMA;;;;;;;;;EASA,oBAAoB,qBAAqB;;;;;;EAMzC,cAAc;;;;;;EAMd,iBAAiB;;;;;;EAMjB;;;;;;EAMA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;wBAoBpC,WACd,OACA,cACA,mBACA,aACA,gBACA,MACA,UACA,WACA,OACA,UACA,WACG,QACF,gCAAa,IAAA;yBAbA"}
@@ -1,10 +1,11 @@
1
1
  "use client";
2
- import { createActionDetails } from "../internal/action-details.mjs";
2
+ import { createActionDetails } from "../internal/action/action-details.mjs";
3
3
  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 { transitionTypes } from "../internal/transition-types.mjs";
7
- import { useControllableAction } from "../internal/use-controllable-action.mjs";
7
+ import { useControllableAction } from "../internal/action/use-controllable-action.mjs";
8
+ import { compareDocumentOrder } from "../internal/dom-order.mjs";
8
9
  import { TabsContext } from "./tabs-context.mjs";
9
10
  import { tabId } from "./tabs-ids.mjs";
10
11
  import { useId, useMemo, useRef } from "react";
@@ -38,8 +39,7 @@ function TabsRoot({ value, defaultValue, valueChangeAction, orientation = "horiz
38
39
  const prevTab = findById(rootRef.current, tabId(rootId, prev));
39
40
  const nextTab = findById(rootRef.current, tabId(rootId, next));
40
41
  if (prevTab === null || nextTab === null) return transitionTypes("tabs");
41
- const following = prevTab.compareDocumentPosition(nextTab) & Node.DOCUMENT_POSITION_FOLLOWING;
42
- return transitionTypes("tabs", following ? "next" : "prev");
42
+ return transitionTypes("tabs", compareDocumentOrder(prevTab, nextTab) < 0 ? "next" : "prev");
43
43
  },
44
44
  warn: {
45
45
  component: "Tabs.Root",