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

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 (588) hide show
  1. package/README.md +22 -1
  2. package/dist/accordion/accordion-item.d.mts +19 -0
  3. package/dist/accordion/accordion-item.d.mts.map +1 -1
  4. package/dist/accordion/accordion-item.mjs +2 -0
  5. package/dist/accordion/accordion-item.mjs.map +1 -1
  6. package/dist/accordion/accordion-panel.d.mts +16 -0
  7. package/dist/accordion/accordion-panel.d.mts.map +1 -1
  8. package/dist/accordion/accordion-panel.mjs +2 -0
  9. package/dist/accordion/accordion-panel.mjs.map +1 -1
  10. package/dist/accordion/accordion-root.d.mts +36 -2
  11. package/dist/accordion/accordion-root.d.mts.map +1 -1
  12. package/dist/accordion/accordion-root.mjs +3 -1
  13. package/dist/accordion/accordion-root.mjs.map +1 -1
  14. package/dist/accordion/accordion-trigger.d.mts +9 -0
  15. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  16. package/dist/accordion/accordion-trigger.mjs +2 -0
  17. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  18. package/dist/accordion/index.d.mts +2 -0
  19. package/dist/accordion/index.d.mts.map +1 -1
  20. package/dist/accordion/index.mjs +2 -0
  21. package/dist/accordion/index.mjs.map +1 -1
  22. package/dist/bin/skill-installer.d.mts +1 -0
  23. package/dist/bin/skill-installer.mjs +12 -0
  24. package/dist/bin/skill-installer.mjs.map +1 -0
  25. package/dist/button/button.d.mts +46 -15
  26. package/dist/button/button.d.mts.map +1 -1
  27. package/dist/button/button.mjs +10 -6
  28. package/dist/button/button.mjs.map +1 -1
  29. package/dist/checkbox/checkbox.d.mts +25 -3
  30. package/dist/checkbox/checkbox.d.mts.map +1 -1
  31. package/dist/checkbox/checkbox.mjs +2 -0
  32. package/dist/checkbox/checkbox.mjs.map +1 -1
  33. package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
  34. package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
  35. package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
  36. package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
  37. package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
  38. package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
  39. package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
  40. package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
  41. package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
  42. package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
  43. package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
  44. package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
  45. package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
  46. package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
  47. package/dist/checkbox-group/checkbox-group-root.mjs +7 -1
  48. package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
  49. package/dist/checkbox-group/index.d.mts +2 -0
  50. package/dist/checkbox-group/index.d.mts.map +1 -1
  51. package/dist/checkbox-group/index.mjs +2 -0
  52. package/dist/checkbox-group/index.mjs.map +1 -1
  53. package/dist/combobox/combobox-clear.d.mts +18 -0
  54. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  55. package/dist/combobox/combobox-clear.mjs +2 -0
  56. package/dist/combobox/combobox-clear.mjs.map +1 -1
  57. package/dist/combobox/combobox-group.d.mts +49 -1
  58. package/dist/combobox/combobox-group.d.mts.map +1 -1
  59. package/dist/combobox/combobox-group.mjs +11 -1
  60. package/dist/combobox/combobox-group.mjs.map +1 -1
  61. package/dist/combobox/combobox-input.d.mts +11 -0
  62. package/dist/combobox/combobox-input.d.mts.map +1 -1
  63. package/dist/combobox/combobox-input.mjs +2 -0
  64. package/dist/combobox/combobox-input.mjs.map +1 -1
  65. package/dist/combobox/combobox-label.d.mts +16 -0
  66. package/dist/combobox/combobox-label.d.mts.map +1 -1
  67. package/dist/combobox/combobox-label.mjs +2 -0
  68. package/dist/combobox/combobox-label.mjs.map +1 -1
  69. package/dist/combobox/combobox-list.d.mts +14 -0
  70. package/dist/combobox/combobox-list.d.mts.map +1 -1
  71. package/dist/combobox/combobox-list.mjs +2 -0
  72. package/dist/combobox/combobox-list.mjs.map +1 -1
  73. package/dist/combobox/combobox-option.d.mts +25 -3
  74. package/dist/combobox/combobox-option.d.mts.map +1 -1
  75. package/dist/combobox/combobox-option.mjs +2 -0
  76. package/dist/combobox/combobox-option.mjs.map +1 -1
  77. package/dist/combobox/combobox-popup.d.mts +20 -1
  78. package/dist/combobox/combobox-popup.d.mts.map +1 -1
  79. package/dist/combobox/combobox-popup.mjs +2 -0
  80. package/dist/combobox/combobox-popup.mjs.map +1 -1
  81. package/dist/combobox/combobox-root.d.mts +64 -17
  82. package/dist/combobox/combobox-root.d.mts.map +1 -1
  83. package/dist/combobox/combobox-root.mjs +11 -11
  84. package/dist/combobox/combobox-root.mjs.map +1 -1
  85. package/dist/combobox/combobox-trigger.d.mts +16 -0
  86. package/dist/combobox/combobox-trigger.d.mts.map +1 -1
  87. package/dist/combobox/combobox-trigger.mjs +9 -2
  88. package/dist/combobox/combobox-trigger.mjs.map +1 -1
  89. package/dist/combobox/index.d.mts +2 -0
  90. package/dist/combobox/index.d.mts.map +1 -1
  91. package/dist/combobox/index.mjs +2 -0
  92. package/dist/combobox/index.mjs.map +1 -1
  93. package/dist/csp/csp-provider.d.mts +8 -0
  94. package/dist/csp/csp-provider.d.mts.map +1 -1
  95. package/dist/csp/csp-provider.mjs +2 -0
  96. package/dist/csp/csp-provider.mjs.map +1 -1
  97. package/dist/csp/style-hashes.d.mts +2 -0
  98. package/dist/csp/style-hashes.d.mts.map +1 -1
  99. package/dist/csp/style-hashes.mjs +2 -0
  100. package/dist/csp/style-hashes.mjs.map +1 -1
  101. package/dist/dialog/dialog-close.d.mts +31 -3
  102. package/dist/dialog/dialog-close.d.mts.map +1 -1
  103. package/dist/dialog/dialog-close.mjs +5 -2
  104. package/dist/dialog/dialog-close.mjs.map +1 -1
  105. package/dist/dialog/dialog-context.mjs.map +1 -1
  106. package/dist/dialog/dialog-description.d.mts +12 -0
  107. package/dist/dialog/dialog-description.d.mts.map +1 -1
  108. package/dist/dialog/dialog-description.mjs +2 -0
  109. package/dist/dialog/dialog-description.mjs.map +1 -1
  110. package/dist/dialog/dialog-form.d.mts +20 -2
  111. package/dist/dialog/dialog-form.d.mts.map +1 -1
  112. package/dist/dialog/dialog-form.mjs +2 -0
  113. package/dist/dialog/dialog-form.mjs.map +1 -1
  114. package/dist/dialog/dialog-popup.d.mts +34 -8
  115. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  116. package/dist/dialog/dialog-popup.mjs +14 -20
  117. package/dist/dialog/dialog-popup.mjs.map +1 -1
  118. package/dist/dialog/dialog-root.d.mts +53 -25
  119. package/dist/dialog/dialog-root.d.mts.map +1 -1
  120. package/dist/dialog/dialog-root.mjs +12 -8
  121. package/dist/dialog/dialog-root.mjs.map +1 -1
  122. package/dist/dialog/dialog-title.d.mts +11 -0
  123. package/dist/dialog/dialog-title.d.mts.map +1 -1
  124. package/dist/dialog/dialog-title.mjs +2 -0
  125. package/dist/dialog/dialog-title.mjs.map +1 -1
  126. package/dist/dialog/dialog-trigger.d.mts +19 -3
  127. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  128. package/dist/dialog/dialog-trigger.mjs +2 -0
  129. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  130. package/dist/dialog/index.d.mts +7 -5
  131. package/dist/dialog/index.d.mts.map +1 -1
  132. package/dist/dialog/index.mjs +7 -5
  133. package/dist/dialog/index.mjs.map +1 -1
  134. package/dist/docs/components/accordion.md +426 -0
  135. package/dist/docs/components/button.md +508 -0
  136. package/dist/docs/components/checkbox-group.md +483 -0
  137. package/dist/docs/components/checkbox.md +373 -0
  138. package/dist/docs/components/combobox.md +698 -0
  139. package/dist/docs/components/context-menu.md +524 -0
  140. package/dist/docs/components/dialog.md +692 -0
  141. package/dist/docs/components/field.md +587 -0
  142. package/dist/docs/components/menu.md +670 -0
  143. package/dist/docs/components/meter.md +313 -0
  144. package/dist/docs/components/number-field.md +528 -0
  145. package/dist/docs/components/popover.md +656 -0
  146. package/dist/docs/components/progress.md +450 -0
  147. package/dist/docs/components/radio-group.md +457 -0
  148. package/dist/docs/components/select.md +662 -0
  149. package/dist/docs/components/slider.md +558 -0
  150. package/dist/docs/components/switch.md +311 -0
  151. package/dist/docs/components/tabs.md +473 -0
  152. package/dist/docs/components/toast.md +599 -0
  153. package/dist/docs/components/toggle-group.md +341 -0
  154. package/dist/docs/components/toggle.md +245 -0
  155. package/dist/docs/components/toolbar.md +390 -0
  156. package/dist/docs/components/tooltip.md +494 -0
  157. package/dist/docs/concepts/action-props.md +281 -0
  158. package/dist/docs/concepts/ai-agents.md +56 -0
  159. package/dist/docs/concepts/browser-owned-state.md +133 -0
  160. package/dist/docs/concepts/content-security-policy.md +69 -0
  161. package/dist/docs/concepts/experimental.md +36 -0
  162. package/dist/docs/concepts/pending-and-optimistic.md +263 -0
  163. package/dist/docs/concepts/render.md +23 -0
  164. package/dist/docs/concepts/server-components.md +132 -0
  165. package/dist/docs/concepts/suspense.md +129 -0
  166. package/dist/docs/concepts/transitions.md +112 -0
  167. package/dist/docs/getting-started.md +102 -0
  168. package/dist/docs/index.md +182 -0
  169. package/dist/docs/roadmap.md +128 -0
  170. package/dist/docs/why.md +104 -0
  171. package/dist/field/field-control.d.mts +26 -3
  172. package/dist/field/field-control.d.mts.map +1 -1
  173. package/dist/field/field-control.mjs +2 -0
  174. package/dist/field/field-control.mjs.map +1 -1
  175. package/dist/field/field-description.d.mts +11 -0
  176. package/dist/field/field-description.d.mts.map +1 -1
  177. package/dist/field/field-description.mjs +2 -0
  178. package/dist/field/field-description.mjs.map +1 -1
  179. package/dist/field/field-error.d.mts +14 -2
  180. package/dist/field/field-error.d.mts.map +1 -1
  181. package/dist/field/field-error.mjs +2 -0
  182. package/dist/field/field-error.mjs.map +1 -1
  183. package/dist/field/field-label.d.mts +10 -0
  184. package/dist/field/field-label.d.mts.map +1 -1
  185. package/dist/field/field-label.mjs +2 -0
  186. package/dist/field/field-label.mjs.map +1 -1
  187. package/dist/field/field-root.d.mts +21 -2
  188. package/dist/field/field-root.d.mts.map +1 -1
  189. package/dist/field/field-root.mjs +2 -0
  190. package/dist/field/field-root.mjs.map +1 -1
  191. package/dist/field/index.d.mts +9 -0
  192. package/dist/field/index.d.mts.map +1 -1
  193. package/dist/field/index.mjs +9 -0
  194. package/dist/field/index.mjs.map +1 -1
  195. package/dist/form/form-root.d.mts +17 -1
  196. package/dist/form/form-root.d.mts.map +1 -1
  197. package/dist/form/form-root.mjs +2 -0
  198. package/dist/form/form-root.mjs.map +1 -1
  199. package/dist/form/form-submit.d.mts +18 -0
  200. package/dist/form/form-submit.d.mts.map +1 -1
  201. package/dist/form/form-submit.mjs +2 -0
  202. package/dist/form/form-submit.mjs.map +1 -1
  203. package/dist/form/index.d.mts +7 -0
  204. package/dist/form/index.d.mts.map +1 -1
  205. package/dist/form/index.mjs +7 -0
  206. package/dist/form/index.mjs.map +1 -1
  207. package/dist/index.d.mts +3 -2
  208. package/dist/internal/call-urgent-handler.mjs +37 -0
  209. package/dist/internal/call-urgent-handler.mjs.map +1 -0
  210. package/dist/internal/css-transition-cut.mjs +66 -0
  211. package/dist/internal/css-transition-cut.mjs.map +1 -0
  212. package/dist/internal/overlay-popup.mjs.map +1 -1
  213. package/dist/internal/report-dropped.mjs +45 -0
  214. package/dist/internal/report-dropped.mjs.map +1 -0
  215. package/dist/internal/types.d.mts +36 -7
  216. package/dist/internal/types.d.mts.map +1 -1
  217. package/dist/internal/use-action-trigger.mjs +32 -17
  218. package/dist/internal/use-action-trigger.mjs.map +1 -1
  219. package/dist/internal/use-controllable-action.mjs +52 -16
  220. package/dist/internal/use-controllable-action.mjs.map +1 -1
  221. package/dist/internal/use-exit-animation.mjs +1 -1
  222. package/dist/internal/use-exit-animation.mjs.map +1 -1
  223. package/dist/internal/use-native-group-reconciliation.mjs +4 -2
  224. package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
  225. package/dist/internal/use-overlay-close.mjs +10 -4
  226. package/dist/internal/use-overlay-close.mjs.map +1 -1
  227. package/dist/internal/use-overlay-root.mjs +40 -7
  228. package/dist/internal/use-overlay-root.mjs.map +1 -1
  229. package/dist/internal/use-popover-popup.mjs +22 -7
  230. package/dist/internal/use-popover-popup.mjs.map +1 -1
  231. package/dist/internal/use-popover-trigger.d.mts +2 -1
  232. package/dist/internal/use-popover-trigger.d.mts.map +1 -1
  233. package/dist/internal/use-popover-trigger.mjs +11 -3
  234. package/dist/internal/use-popover-trigger.mjs.map +1 -1
  235. package/dist/internal/validity.d.mts +11 -0
  236. package/dist/internal/validity.d.mts.map +1 -1
  237. package/dist/internal/validity.mjs.map +1 -1
  238. package/dist/menu/index.d.mts +2 -0
  239. package/dist/menu/index.d.mts.map +1 -1
  240. package/dist/menu/index.mjs +2 -0
  241. package/dist/menu/index.mjs.map +1 -1
  242. package/dist/menu/menu-checkbox-item.d.mts +27 -3
  243. package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
  244. package/dist/menu/menu-checkbox-item.mjs +2 -0
  245. package/dist/menu/menu-checkbox-item.mjs.map +1 -1
  246. package/dist/menu/menu-context-trigger.d.mts +24 -2
  247. package/dist/menu/menu-context-trigger.d.mts.map +1 -1
  248. package/dist/menu/menu-context-trigger.mjs +2 -0
  249. package/dist/menu/menu-context-trigger.mjs.map +1 -1
  250. package/dist/menu/menu-group.d.mts +36 -1
  251. package/dist/menu/menu-group.d.mts.map +1 -1
  252. package/dist/menu/menu-group.mjs +9 -1
  253. package/dist/menu/menu-group.mjs.map +1 -1
  254. package/dist/menu/menu-item.d.mts +38 -5
  255. package/dist/menu/menu-item.d.mts.map +1 -1
  256. package/dist/menu/menu-item.mjs +12 -5
  257. package/dist/menu/menu-item.mjs.map +1 -1
  258. package/dist/menu/menu-outside.mjs +2 -2
  259. package/dist/menu/menu-outside.mjs.map +1 -1
  260. package/dist/menu/menu-popup.d.mts +36 -8
  261. package/dist/menu/menu-popup.d.mts.map +1 -1
  262. package/dist/menu/menu-popup.mjs +2 -0
  263. package/dist/menu/menu-popup.mjs.map +1 -1
  264. package/dist/menu/menu-radio-group.d.mts +20 -1
  265. package/dist/menu/menu-radio-group.d.mts.map +1 -1
  266. package/dist/menu/menu-radio-group.mjs +2 -0
  267. package/dist/menu/menu-radio-group.mjs.map +1 -1
  268. package/dist/menu/menu-radio-item.d.mts +16 -0
  269. package/dist/menu/menu-radio-item.d.mts.map +1 -1
  270. package/dist/menu/menu-radio-item.mjs +2 -0
  271. package/dist/menu/menu-radio-item.mjs.map +1 -1
  272. package/dist/menu/menu-root.d.mts +49 -15
  273. package/dist/menu/menu-root.d.mts.map +1 -1
  274. package/dist/menu/menu-root.mjs +7 -4
  275. package/dist/menu/menu-root.mjs.map +1 -1
  276. package/dist/menu/menu-submenu-trigger.d.mts +13 -0
  277. package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
  278. package/dist/menu/menu-submenu-trigger.mjs +2 -0
  279. package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
  280. package/dist/menu/menu-trigger.d.mts +15 -0
  281. package/dist/menu/menu-trigger.d.mts.map +1 -1
  282. package/dist/menu/menu-trigger.mjs +2 -0
  283. package/dist/menu/menu-trigger.mjs.map +1 -1
  284. package/dist/meter/index.d.mts +2 -0
  285. package/dist/meter/index.d.mts.map +1 -1
  286. package/dist/meter/index.mjs +2 -0
  287. package/dist/meter/index.mjs.map +1 -1
  288. package/dist/meter/meter-indicator.d.mts +11 -0
  289. package/dist/meter/meter-indicator.d.mts.map +1 -1
  290. package/dist/meter/meter-indicator.mjs +2 -0
  291. package/dist/meter/meter-indicator.mjs.map +1 -1
  292. package/dist/meter/meter-label.d.mts +11 -0
  293. package/dist/meter/meter-label.d.mts.map +1 -1
  294. package/dist/meter/meter-label.mjs +2 -0
  295. package/dist/meter/meter-label.mjs.map +1 -1
  296. package/dist/meter/meter-region.d.mts +5 -0
  297. package/dist/meter/meter-region.d.mts.map +1 -1
  298. package/dist/meter/meter-region.mjs.map +1 -1
  299. package/dist/meter/meter-root.d.mts +52 -10
  300. package/dist/meter/meter-root.d.mts.map +1 -1
  301. package/dist/meter/meter-root.mjs +2 -0
  302. package/dist/meter/meter-root.mjs.map +1 -1
  303. package/dist/meter/meter-track.d.mts +11 -0
  304. package/dist/meter/meter-track.d.mts.map +1 -1
  305. package/dist/meter/meter-track.mjs +2 -0
  306. package/dist/meter/meter-track.mjs.map +1 -1
  307. package/dist/meter/meter-value.d.mts +15 -1
  308. package/dist/meter/meter-value.d.mts.map +1 -1
  309. package/dist/meter/meter-value.mjs +2 -0
  310. package/dist/meter/meter-value.mjs.map +1 -1
  311. package/dist/number-field/index.d.mts +2 -0
  312. package/dist/number-field/index.d.mts.map +1 -1
  313. package/dist/number-field/index.mjs +2 -0
  314. package/dist/number-field/index.mjs.map +1 -1
  315. package/dist/number-field/number-field-decrement.d.mts +2 -0
  316. package/dist/number-field/number-field-decrement.d.mts.map +1 -1
  317. package/dist/number-field/number-field-decrement.mjs +2 -0
  318. package/dist/number-field/number-field-decrement.mjs.map +1 -1
  319. package/dist/number-field/number-field-increment.d.mts +2 -0
  320. package/dist/number-field/number-field-increment.d.mts.map +1 -1
  321. package/dist/number-field/number-field-increment.mjs +2 -0
  322. package/dist/number-field/number-field-increment.mjs.map +1 -1
  323. package/dist/number-field/number-field-input.d.mts +9 -0
  324. package/dist/number-field/number-field-input.d.mts.map +1 -1
  325. package/dist/number-field/number-field-input.mjs +2 -0
  326. package/dist/number-field/number-field-input.mjs.map +1 -1
  327. package/dist/number-field/number-field-label.d.mts +10 -0
  328. package/dist/number-field/number-field-label.d.mts.map +1 -1
  329. package/dist/number-field/number-field-label.mjs +2 -0
  330. package/dist/number-field/number-field-label.mjs.map +1 -1
  331. package/dist/number-field/number-field-root.d.mts +62 -14
  332. package/dist/number-field/number-field-root.d.mts.map +1 -1
  333. package/dist/number-field/number-field-root.mjs +4 -8
  334. package/dist/number-field/number-field-root.mjs.map +1 -1
  335. package/dist/number-field/use-step-button.d.mts +20 -0
  336. package/dist/number-field/use-step-button.d.mts.map +1 -1
  337. package/dist/number-field/use-step-button.mjs.map +1 -1
  338. package/dist/popover/index.d.mts +5 -3
  339. package/dist/popover/index.d.mts.map +1 -1
  340. package/dist/popover/index.mjs +5 -3
  341. package/dist/popover/index.mjs.map +1 -1
  342. package/dist/popover/popover-close.d.mts +32 -3
  343. package/dist/popover/popover-close.d.mts.map +1 -1
  344. package/dist/popover/popover-close.mjs +6 -2
  345. package/dist/popover/popover-close.mjs.map +1 -1
  346. package/dist/popover/popover-description.d.mts +12 -0
  347. package/dist/popover/popover-description.d.mts.map +1 -1
  348. package/dist/popover/popover-description.mjs +2 -0
  349. package/dist/popover/popover-description.mjs.map +1 -1
  350. package/dist/popover/popover-popup.d.mts +36 -7
  351. package/dist/popover/popover-popup.d.mts.map +1 -1
  352. package/dist/popover/popover-popup.mjs +5 -2
  353. package/dist/popover/popover-popup.mjs.map +1 -1
  354. package/dist/popover/popover-root.d.mts +40 -18
  355. package/dist/popover/popover-root.d.mts.map +1 -1
  356. package/dist/popover/popover-root.mjs +11 -7
  357. package/dist/popover/popover-root.mjs.map +1 -1
  358. package/dist/popover/popover-title.d.mts +11 -0
  359. package/dist/popover/popover-title.d.mts.map +1 -1
  360. package/dist/popover/popover-title.mjs +2 -0
  361. package/dist/popover/popover-title.mjs.map +1 -1
  362. package/dist/popover/popover-trigger.d.mts +15 -0
  363. package/dist/popover/popover-trigger.d.mts.map +1 -1
  364. package/dist/popover/popover-trigger.mjs +2 -0
  365. package/dist/popover/popover-trigger.mjs.map +1 -1
  366. package/dist/progress/index.d.mts +2 -0
  367. package/dist/progress/index.d.mts.map +1 -1
  368. package/dist/progress/index.mjs +2 -0
  369. package/dist/progress/index.mjs.map +1 -1
  370. package/dist/progress/progress-indicator.d.mts +11 -0
  371. package/dist/progress/progress-indicator.d.mts.map +1 -1
  372. package/dist/progress/progress-indicator.mjs +2 -0
  373. package/dist/progress/progress-indicator.mjs.map +1 -1
  374. package/dist/progress/progress-label.d.mts +11 -0
  375. package/dist/progress/progress-label.d.mts.map +1 -1
  376. package/dist/progress/progress-label.mjs +2 -0
  377. package/dist/progress/progress-label.mjs.map +1 -1
  378. package/dist/progress/progress-root.d.mts +36 -8
  379. package/dist/progress/progress-root.d.mts.map +1 -1
  380. package/dist/progress/progress-root.mjs +2 -0
  381. package/dist/progress/progress-root.mjs.map +1 -1
  382. package/dist/progress/progress-track.d.mts +11 -0
  383. package/dist/progress/progress-track.d.mts.map +1 -1
  384. package/dist/progress/progress-track.mjs +2 -0
  385. package/dist/progress/progress-track.mjs.map +1 -1
  386. package/dist/progress/progress-value.d.mts +15 -1
  387. package/dist/progress/progress-value.d.mts.map +1 -1
  388. package/dist/progress/progress-value.mjs +2 -0
  389. package/dist/progress/progress-value.mjs.map +1 -1
  390. package/dist/radio-group/index.d.mts +2 -0
  391. package/dist/radio-group/index.d.mts.map +1 -1
  392. package/dist/radio-group/index.mjs +2 -0
  393. package/dist/radio-group/index.mjs.map +1 -1
  394. package/dist/radio-group/radio-group-item.d.mts +18 -1
  395. package/dist/radio-group/radio-group-item.d.mts.map +1 -1
  396. package/dist/radio-group/radio-group-item.mjs +2 -0
  397. package/dist/radio-group/radio-group-item.mjs.map +1 -1
  398. package/dist/radio-group/radio-group-label.d.mts +10 -0
  399. package/dist/radio-group/radio-group-label.d.mts.map +1 -1
  400. package/dist/radio-group/radio-group-label.mjs +2 -0
  401. package/dist/radio-group/radio-group-label.mjs.map +1 -1
  402. package/dist/radio-group/radio-group-root.d.mts +29 -5
  403. package/dist/radio-group/radio-group-root.d.mts.map +1 -1
  404. package/dist/radio-group/radio-group-root.mjs +2 -0
  405. package/dist/radio-group/radio-group-root.mjs.map +1 -1
  406. package/dist/select/index.d.mts +2 -0
  407. package/dist/select/index.d.mts.map +1 -1
  408. package/dist/select/index.mjs +2 -0
  409. package/dist/select/index.mjs.map +1 -1
  410. package/dist/select/select-group-label.d.mts +10 -0
  411. package/dist/select/select-group-label.d.mts.map +1 -1
  412. package/dist/select/select-group-label.mjs +2 -0
  413. package/dist/select/select-group-label.mjs.map +1 -1
  414. package/dist/select/select-group.d.mts +15 -1
  415. package/dist/select/select-group.d.mts.map +1 -1
  416. package/dist/select/select-group.mjs +2 -0
  417. package/dist/select/select-group.mjs.map +1 -1
  418. package/dist/select/select-option.d.mts +19 -1
  419. package/dist/select/select-option.d.mts.map +1 -1
  420. package/dist/select/select-option.mjs +2 -0
  421. package/dist/select/select-option.mjs.map +1 -1
  422. package/dist/select/select-root.d.mts +24 -1
  423. package/dist/select/select-root.d.mts.map +1 -1
  424. package/dist/select/select-root.mjs +2 -0
  425. package/dist/select/select-root.mjs.map +1 -1
  426. package/dist/select/select-separator.d.mts +9 -0
  427. package/dist/select/select-separator.d.mts.map +1 -1
  428. package/dist/select/select-separator.mjs +2 -0
  429. package/dist/select/select-separator.mjs.map +1 -1
  430. package/dist/select/select-trigger.d.mts +9 -0
  431. package/dist/select/select-trigger.d.mts.map +1 -1
  432. package/dist/select/select-trigger.mjs +2 -0
  433. package/dist/select/select-trigger.mjs.map +1 -1
  434. package/dist/select/select-value.d.mts +9 -0
  435. package/dist/select/select-value.d.mts.map +1 -1
  436. package/dist/select/select-value.mjs +2 -0
  437. package/dist/select/select-value.mjs.map +1 -1
  438. package/dist/slider/index.d.mts +2 -0
  439. package/dist/slider/index.d.mts.map +1 -1
  440. package/dist/slider/index.mjs +2 -0
  441. package/dist/slider/index.mjs.map +1 -1
  442. package/dist/slider/slider-indicator.d.mts +12 -0
  443. package/dist/slider/slider-indicator.d.mts.map +1 -1
  444. package/dist/slider/slider-indicator.mjs +2 -0
  445. package/dist/slider/slider-indicator.mjs.map +1 -1
  446. package/dist/slider/slider-label.d.mts +11 -1
  447. package/dist/slider/slider-label.d.mts.map +1 -1
  448. package/dist/slider/slider-label.mjs +2 -0
  449. package/dist/slider/slider-label.mjs.map +1 -1
  450. package/dist/slider/slider-root.d.mts +53 -9
  451. package/dist/slider/slider-root.d.mts.map +1 -1
  452. package/dist/slider/slider-root.mjs +4 -8
  453. package/dist/slider/slider-root.mjs.map +1 -1
  454. package/dist/slider/slider-thumb.d.mts +32 -3
  455. package/dist/slider/slider-thumb.d.mts.map +1 -1
  456. package/dist/slider/slider-thumb.mjs +2 -0
  457. package/dist/slider/slider-thumb.mjs.map +1 -1
  458. package/dist/slider/slider-track.d.mts +17 -0
  459. package/dist/slider/slider-track.d.mts.map +1 -1
  460. package/dist/slider/slider-track.mjs +2 -0
  461. package/dist/slider/slider-track.mjs.map +1 -1
  462. package/dist/slider/slider-value.d.mts +11 -0
  463. package/dist/slider/slider-value.d.mts.map +1 -1
  464. package/dist/slider/slider-value.mjs +2 -0
  465. package/dist/slider/slider-value.mjs.map +1 -1
  466. package/dist/switch/switch.d.mts +23 -3
  467. package/dist/switch/switch.d.mts.map +1 -1
  468. package/dist/switch/switch.mjs +2 -0
  469. package/dist/switch/switch.mjs.map +1 -1
  470. package/dist/tabs/index.d.mts +2 -0
  471. package/dist/tabs/index.d.mts.map +1 -1
  472. package/dist/tabs/index.mjs +2 -0
  473. package/dist/tabs/index.mjs.map +1 -1
  474. package/dist/tabs/tabs-context.d.mts +5 -0
  475. package/dist/tabs/tabs-context.d.mts.map +1 -1
  476. package/dist/tabs/tabs-context.mjs.map +1 -1
  477. package/dist/tabs/tabs-indicator.d.mts +17 -0
  478. package/dist/tabs/tabs-indicator.d.mts.map +1 -1
  479. package/dist/tabs/tabs-indicator.mjs +2 -0
  480. package/dist/tabs/tabs-indicator.mjs.map +1 -1
  481. package/dist/tabs/tabs-list.d.mts +19 -1
  482. package/dist/tabs/tabs-list.d.mts.map +1 -1
  483. package/dist/tabs/tabs-list.mjs +2 -0
  484. package/dist/tabs/tabs-list.mjs.map +1 -1
  485. package/dist/tabs/tabs-panel.d.mts +19 -0
  486. package/dist/tabs/tabs-panel.d.mts.map +1 -1
  487. package/dist/tabs/tabs-panel.mjs +2 -0
  488. package/dist/tabs/tabs-panel.mjs.map +1 -1
  489. package/dist/tabs/tabs-root.d.mts +39 -5
  490. package/dist/tabs/tabs-root.d.mts.map +1 -1
  491. package/dist/tabs/tabs-root.mjs +2 -0
  492. package/dist/tabs/tabs-root.mjs.map +1 -1
  493. package/dist/tabs/tabs-tab.d.mts +22 -1
  494. package/dist/tabs/tabs-tab.d.mts.map +1 -1
  495. package/dist/tabs/tabs-tab.mjs +2 -0
  496. package/dist/tabs/tabs-tab.mjs.map +1 -1
  497. package/dist/toast/index.d.mts +2 -0
  498. package/dist/toast/index.d.mts.map +1 -1
  499. package/dist/toast/index.mjs +2 -0
  500. package/dist/toast/index.mjs.map +1 -1
  501. package/dist/toast/toast-action.d.mts +42 -6
  502. package/dist/toast/toast-action.d.mts.map +1 -1
  503. package/dist/toast/toast-action.mjs +8 -4
  504. package/dist/toast/toast-action.mjs.map +1 -1
  505. package/dist/toast/toast-close.d.mts +16 -0
  506. package/dist/toast/toast-close.d.mts.map +1 -1
  507. package/dist/toast/toast-close.mjs +2 -0
  508. package/dist/toast/toast-close.mjs.map +1 -1
  509. package/dist/toast/toast-context.mjs.map +1 -1
  510. package/dist/toast/toast-description.d.mts +16 -1
  511. package/dist/toast/toast-description.d.mts.map +1 -1
  512. package/dist/toast/toast-description.mjs +2 -0
  513. package/dist/toast/toast-description.mjs.map +1 -1
  514. package/dist/toast/toast-queue.mjs.map +1 -1
  515. package/dist/toast/toast-root.d.mts +20 -0
  516. package/dist/toast/toast-root.d.mts.map +1 -1
  517. package/dist/toast/toast-root.mjs +2 -0
  518. package/dist/toast/toast-root.mjs.map +1 -1
  519. package/dist/toast/toast-title.d.mts +15 -1
  520. package/dist/toast/toast-title.d.mts.map +1 -1
  521. package/dist/toast/toast-title.mjs +2 -0
  522. package/dist/toast/toast-title.mjs.map +1 -1
  523. package/dist/toast/toast-viewport.d.mts +34 -5
  524. package/dist/toast/toast-viewport.d.mts.map +1 -1
  525. package/dist/toast/toast-viewport.mjs +17 -15
  526. package/dist/toast/toast-viewport.mjs.map +1 -1
  527. package/dist/toast/toast.d.mts +56 -13
  528. package/dist/toast/toast.d.mts.map +1 -1
  529. package/dist/toast/toast.mjs +4 -0
  530. package/dist/toast/toast.mjs.map +1 -1
  531. package/dist/toggle/toggle.d.mts +20 -2
  532. package/dist/toggle/toggle.d.mts.map +1 -1
  533. package/dist/toggle/toggle.mjs +2 -0
  534. package/dist/toggle/toggle.mjs.map +1 -1
  535. package/dist/toggle-group/index.d.mts +2 -0
  536. package/dist/toggle-group/index.d.mts.map +1 -1
  537. package/dist/toggle-group/index.mjs +2 -0
  538. package/dist/toggle-group/index.mjs.map +1 -1
  539. package/dist/toggle-group/toggle-group-context.d.mts +1 -0
  540. package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
  541. package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
  542. package/dist/toggle-group/toggle-group-item.d.mts +16 -0
  543. package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
  544. package/dist/toggle-group/toggle-group-item.mjs +2 -0
  545. package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
  546. package/dist/toggle-group/toggle-group-root.d.mts +73 -12
  547. package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
  548. package/dist/toggle-group/toggle-group-root.mjs +3 -1
  549. package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
  550. package/dist/toolbar/index.d.mts +2 -0
  551. package/dist/toolbar/index.d.mts.map +1 -1
  552. package/dist/toolbar/index.mjs +2 -0
  553. package/dist/toolbar/index.mjs.map +1 -1
  554. package/dist/toolbar/toolbar-root.d.mts +30 -3
  555. package/dist/toolbar/toolbar-root.d.mts.map +1 -1
  556. package/dist/toolbar/toolbar-root.mjs +2 -0
  557. package/dist/toolbar/toolbar-root.mjs.map +1 -1
  558. package/dist/toolbar/toolbar-separator.d.mts +13 -0
  559. package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
  560. package/dist/toolbar/toolbar-separator.mjs +2 -0
  561. package/dist/toolbar/toolbar-separator.mjs.map +1 -1
  562. package/dist/tooltip/index.d.mts +2 -0
  563. package/dist/tooltip/index.d.mts.map +1 -1
  564. package/dist/tooltip/index.mjs +2 -0
  565. package/dist/tooltip/index.mjs.map +1 -1
  566. package/dist/tooltip/tooltip-arrow.d.mts +16 -0
  567. package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
  568. package/dist/tooltip/tooltip-arrow.mjs +2 -0
  569. package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
  570. package/dist/tooltip/tooltip-context.d.mts +4 -0
  571. package/dist/tooltip/tooltip-context.d.mts.map +1 -1
  572. package/dist/tooltip/tooltip-context.mjs.map +1 -1
  573. package/dist/tooltip/tooltip-popup.d.mts +24 -3
  574. package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
  575. package/dist/tooltip/tooltip-popup.mjs +2 -0
  576. package/dist/tooltip/tooltip-popup.mjs.map +1 -1
  577. package/dist/tooltip/tooltip-root.d.mts +24 -2
  578. package/dist/tooltip/tooltip-root.d.mts.map +1 -1
  579. package/dist/tooltip/tooltip-root.mjs +2 -0
  580. package/dist/tooltip/tooltip-root.mjs.map +1 -1
  581. package/dist/tooltip/tooltip-trigger.d.mts +18 -1
  582. package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
  583. package/dist/tooltip/tooltip-trigger.mjs +2 -0
  584. package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
  585. package/package.json +9 -1
  586. package/skills/funstack-ui-knowledge/SKILL.md +75 -0
  587. package/dist/internal/use-superseded-rejection.mjs +0 -47
  588. package/dist/internal/use-superseded-rejection.mjs.map +0 -1
@@ -24,14 +24,26 @@ export interface NumberFieldState {
24
24
  readonly text: string;
25
25
  /** A step or commit dispatched through this NumberField is in flight. */
26
26
  readonly pending: boolean;
27
+ /** The `disabled` prop, or the enclosing Field's. */
27
28
  readonly disabled: boolean;
29
+ /** The `readOnly` prop. */
28
30
  readonly readOnly: boolean;
31
+ /** The `required` prop, or the enclosing Field's. */
29
32
  readonly required: boolean;
30
33
  }
34
+ /**
35
+ * Props of `NumberField.Root`.
36
+ *
37
+ * @see https://ui.funstack.work/components/number-field
38
+ */
31
39
  export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "role" | "className" | "style" | "children"> {
32
40
  /** Controlled value; `null` is empty, `undefined` uncontrolled. */
33
41
  value?: number | null;
34
- /** Initial value in uncontrolled mode, and its form-reset target (latest). Default `null` (empty). */
42
+ /**
43
+ * Initial value in uncontrolled mode, and its form-reset target (latest).
44
+ *
45
+ * @defaultValue `null` (empty)
46
+ */
35
47
  defaultValue?: number | null;
36
48
  /**
37
49
  * Runs inside the Root's step transition on every step: the parse of typed text at commit,
@@ -51,9 +63,17 @@ export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">,
51
63
  min?: number;
52
64
  /** Native `max` on the hidden input (a constraint) and the upper bound of stepping. */
53
65
  max?: number;
54
- /** Native `step` and the stepping grid from `min` (else `0`). Default `1`, or `0.01` when `format.style` is `"percent"`. */
66
+ /**
67
+ * Native `step` and the stepping grid from `min` (else `0`).
68
+ *
69
+ * @defaultValue `1`, or `0.01` when `format.style` is `"percent"`
70
+ */
55
71
  step?: number;
56
- /** PageUp / PageDown and Shift+Arrow. Default `10 × step`. */
72
+ /**
73
+ * The step of PageUp / PageDown and Shift+Arrow.
74
+ *
75
+ * @defaultValue `10 × step`
76
+ */
57
77
  largeStep?: number;
58
78
  /**
59
79
  * `Intl.NumberFormatOptions` for the text: `style` `"decimal"` (default), `"percent"`,
@@ -62,32 +82,58 @@ export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">,
62
82
  */
63
83
  format?: Intl.NumberFormatOptions;
64
84
  /**
65
- * BCP 47 tag(s). Default: the runtime's locale (`Intl.NumberFormat().resolvedOptions().locale`).
66
- * Pass the page's `lang`; a dev warning fires when `document.documentElement.lang` disagrees
67
- * and this prop is absent.
85
+ * BCP 47 tag(s). Pass the page's `lang`; a dev warning fires when
86
+ * `document.documentElement.lang` disagrees and this prop is absent.
87
+ *
88
+ * @defaultValue the runtime's locale (`Intl.NumberFormat().resolvedOptions().locale`)
68
89
  */
69
90
  locale?: string | readonly string[];
70
- /** Step with the mouse wheel while the input is focused. Default `false`. */
91
+ /**
92
+ * Step with the mouse wheel while the input is focused.
93
+ *
94
+ * @defaultValue `false`
95
+ */
71
96
  stepOnWheel?: boolean;
72
- /** Native `name` on the hidden input; defaults to the Field's `name` inside a `Field.Root`. */
97
+ /**
98
+ * Native `name` on the hidden input.
99
+ *
100
+ * @defaultValue the Field's `name` inside a `Field.Root`
101
+ */
73
102
  name?: string;
74
103
  /** Native `form` on the hidden input. */
75
104
  form?: string;
76
- /** Disables both inputs and the buttons; inherited by every part. */
105
+ /**
106
+ * Disables both inputs and the buttons; inherited by every part.
107
+ *
108
+ * @defaultValue `false`
109
+ */
77
110
  disabled?: boolean;
78
- /** Native `readonly` on both inputs; no stepping (buttons disabled, keys and wheel inert). */
111
+ /**
112
+ * Native `readonly` on both inputs; no stepping (buttons disabled, keys and wheel inert).
113
+ *
114
+ * @defaultValue `false`
115
+ */
79
116
  readOnly?: boolean;
80
- /** Native `required` on the hidden input (empty is `valueMissing`); or the Field's. */
117
+ /**
118
+ * Native `required` on the hidden input (empty is `valueMissing`); or the Field's.
119
+ *
120
+ * @defaultValue `false`
121
+ */
81
122
  required?: boolean;
82
123
  /**
83
- * What is announced (`ariaNotify()`) after a key press, a wheel event, a
84
- * click activation and a hold's release. Default: `(_, state) => state.text`. Return `null` to
85
- * announce nothing.
124
+ * What is announced (`ariaNotify()`) after a key press, a wheel event, a click activation and a
125
+ * hold's release. Return `null` to announce nothing.
126
+ *
127
+ * @defaultValue `(_, state) => state.text`
86
128
  */
87
129
  announce?: (value: number | null, state: NumberFieldState) => string | null;
130
+ /** Class name, or a function of the part's state that returns one. */
88
131
  className?: StateValue<string | undefined, NumberFieldState>;
132
+ /** Inline style, or a function of the part's state that returns one. */
89
133
  style?: StateValue<CSSProperties | undefined, NumberFieldState>;
134
+ /** The parts. The function form receives the state. */
90
135
  children?: StateValue<ReactNode, NumberFieldState>;
136
+ /** Replace the default `<div>` (element form) or take over rendering (function form). */
91
137
  render?: RenderProp<ComponentPropsWithRef<"div">, NumberFieldState>;
92
138
  }
93
139
  /**
@@ -100,6 +146,8 @@ export interface NumberFieldRootProps extends Omit<ComponentPropsWithRef<"div">,
100
146
  * Owned keys (conventions 1.2): `role="group"`, `aria-labelledby` (token-merged: the consumer's,
101
147
  * then `NumberField.Label`'s id while one is mounted, then a Field's label id), `data-pending`,
102
148
  * `data-disabled`, `data-invalid` (inside a Field).
149
+ *
150
+ * @see https://ui.funstack.work/components/number-field
103
151
  */
104
152
  export declare function NumberFieldRoot(props: NumberFieldRootProps): import("react").JSX.Element;
105
153
  export declare namespace NumberFieldRoot {
@@ -1 +1 @@
1
- {"version":3,"file":"number-field-root.d.mts","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"mappings":";;;;;iBA+CiB,sCAAsC;;;;;;;;;WAS5C,QAAQ;;WAER,QAAQ;;;iBAIF;;WAEN;;WAEA;;WAEA;WACA;WACA;WACA;;iBAGM,6BAA6B,KAC5C;;EAIA;;EAEA;;;;;;;EAOA,oBAAoB,4BAA4B;;;;;;;EAOhD,oBAAoB,4BAA4B;;EAEhD;;EAEA;;EAEA;;EAEA;;;;;;EAMA,SAAS,KAAK;;;;;;EAMd;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,YAAY,sBAAsB,OAAO;EACzC,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;wBAyDpC,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
1
+ {"version":3,"file":"number-field-root.d.mts","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"mappings":";;;;;iBA8CiB,sCAAsC;;;;;;;;;WAS5C,QAAQ;;WAER,QAAQ;;;iBAIF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;iBAQM,6BAA6B,KAC5C;;EAIA;;;;;;EAMA;;;;;;;EAOA,oBAAoB,4BAA4B;;;;;;;EAOhD,oBAAoB,4BAA4B;;EAEhD;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,SAAS,KAAK;;;;;;;EAOd;;;;;;EAMA;;;;;;EAMA;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA,YAAY,sBAAsB,OAAO;;EAEzC,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;;wBA2DpC,gBAAgB,OAAO,uCAAoB,IAAA;yBAA3C"}
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  import { createActionDetails } from "../internal/action-details.mjs";
3
3
  import { dataAttr } from "../internal/data-attr.mjs";
4
- import { useSupersededRejection } from "../internal/use-superseded-rejection.mjs";
5
4
  import { useActionTrigger } from "../internal/use-action-trigger.mjs";
6
5
  import { mergeTokenLists } from "../internal/merge-props.mjs";
7
6
  import { useRender } from "../internal/use-render.mjs";
@@ -63,6 +62,8 @@ function readVisible(visible, current, formatter, adoptDraft) {
63
62
  * Owned keys (conventions 1.2): `role="group"`, `aria-labelledby` (token-merged: the consumer's,
64
63
  * then `NumberField.Label`'s id while one is mounted, then a Field's label id), `data-pending`,
65
64
  * `data-disabled`, `data-invalid` (inside a Field).
65
+ *
66
+ * @see https://ui.funstack.work/components/number-field
66
67
  */
67
68
  function NumberFieldRoot(props) {
68
69
  const { value: valueProp, defaultValue: defaultValueProp, valueChangeAction, valueCommitAction, min, max, step: stepProp, largeStep: largeStepProp, format, locale, stepOnWheel = false, name: nameProp, form, disabled: disabledProp = false, readOnly = false, required: requiredProp = false, announce: announce$1, className, style, children, render, ...rest } = props;
@@ -132,11 +133,7 @@ function NumberFieldRoot(props) {
132
133
  const message = hidden.validationMessage;
133
134
  if (visible.validationMessage !== message) visible.setCustomValidity(message);
134
135
  }, []);
135
- const captureSuperseded = useSupersededRejection();
136
- const { pending: stepPending, run: runStep } = useActionTrigger({
137
- ignoreWhilePending: false,
138
- captureSuperseded
139
- });
136
+ const { pending: stepPending, run: runStep } = useActionTrigger({ ignoreWhilePending: false });
140
137
  const runCommit = async (next, details) => {
141
138
  const seq = ++commitSeq.current;
142
139
  try {
@@ -158,8 +155,7 @@ function NumberFieldRoot(props) {
158
155
  warn: {
159
156
  component: "NumberField.Root",
160
157
  prop: "value"
161
- },
162
- captureSuperseded
158
+ }
163
159
  });
164
160
  const { optimistic, committed, dispatch } = commitState;
165
161
  const committedRef = useLatest(committed);
@@ -1 +1 @@
1
- {"version":3,"file":"number-field-root.mjs","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n addTransitionType,\n use,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, RefObject } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { announce as speak } from \"../internal/announce.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { FieldContext } from \"../internal/field-context.js\";\nimport { mergeTokenLists } from \"../internal/merge-props.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 { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { resolveFieldDefaults, useFieldValueChange } from \"../internal/use-field-control.js\";\nimport type { FormAssociatedElement } from \"../internal/use-form-owner-event.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useNativeGroupReconciliation } from \"../internal/use-native-group-reconciliation.js\";\nimport { useSupersededRejection } from \"../internal/use-superseded-rejection.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { keyStep, stepValue } from \"./number-field-arithmetic.js\";\nimport type { StepBounds } from \"./number-field-arithmetic.js\";\nimport { NumberFieldContext } from \"./number-field-context.js\";\nimport type {\n NumberFieldContextValue,\n NumberFieldSource,\n StepDirection,\n} from \"./number-field-context.js\";\nimport { createNumberFormatter, formatKey } from \"./number-field-format.js\";\nimport type { NumberFormatter } from \"./number-field-format.js\";\nimport { useNumberFieldDevWarnings } from \"./use-number-field-dev-warnings.js\";\n\n/** Details passed as the second argument of both NumberField actions. */\nexport interface NumberFieldValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user typed, pressed a key, a button or turned the wheel (`details.event` is\n * the `focusout` / Enter `keydown` of a typed value, the `keydown` of a key, the `pointerdown` /\n * `pointerup` of a button (`undefined` for the repeats of a held button and for a hold that\n * ended at its bound), the `wheel` event). `\"platform\"`: a form reset (the `reset`\n * event) or text typed before hydration (`undefined`). `\"dismiss\"`: the commit action rejected\n * and the field reverted to the committed value (uncontrolled; `valueChangeAction` only).\n */\n readonly reason: ChangeReason;\n /** What produced the value: typed text, a button, a key, the wheel; `null` for \"platform\" and \"dismiss\". */\n readonly source: NumberFieldSource;\n}\n\n/** The state every NumberField part's function props receive (one object, Field's precedent). */\nexport interface NumberFieldState {\n /** The shown value: the gesture's value while one is open or in flight, else the optimistic value; `null` when empty. */\n readonly value: number | null;\n /** The shown text: the draft while the user is editing, else `value` formatted. */\n readonly text: string;\n /** A step or commit dispatched through this NumberField is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n readonly required: boolean;\n}\n\nexport interface NumberFieldRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"defaultValue\" | \"role\" | \"className\" | \"style\" | \"children\"\n> {\n /** Controlled value; `null` is empty, `undefined` uncontrolled. */\n value?: number | null;\n /** Initial value in uncontrolled mode, and its form-reset target (latest). Default `null` (empty). */\n defaultValue?: number | null;\n /**\n * Runs inside the Root's step transition on every step: the parse of typed text at commit,\n * each key press, each tick of a hold, each wheel event, each platform change, and the revert\n * after a rejected commit (`reason: \"dismiss\"`, uncontrolled). Keep it cheap: adopt the value\n * (`setValue(next)` in the sync prefix is a transition update), start a deferred render.\n */\n valueChangeAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;\n /**\n * Runs inside the Root's commit transition once per gesture: a typed text's blur or Enter, a\n * hold's release, each key press, each wheel event, a form reset, text typed before hydration.\n * Where the save goes; uncontrolled state is committed when it resolves and reverts when it\n * rejects. May be a Server Function.\n */\n valueCommitAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;\n /** Native `min` on the hidden input (a constraint) and the lower bound of stepping. */\n min?: number;\n /** Native `max` on the hidden input (a constraint) and the upper bound of stepping. */\n max?: number;\n /** Native `step` and the stepping grid from `min` (else `0`). Default `1`, or `0.01` when `format.style` is `\"percent\"`. */\n step?: number;\n /** PageUp / PageDown and Shift+Arrow. Default `10 × step`. */\n largeStep?: number;\n /**\n * `Intl.NumberFormatOptions` for the text: `style` `\"decimal\"` (default), `\"percent\"`,\n * `\"currency\"` (with `currency`), `\"unit\"` (with `unit`); fraction digits, grouping, sign\n * display. `notation: \"compact\"` is a dev warning (unparsable).\n */\n format?: Intl.NumberFormatOptions;\n /**\n * BCP 47 tag(s). Default: the runtime's locale (`Intl.NumberFormat().resolvedOptions().locale`).\n * Pass the page's `lang`; a dev warning fires when `document.documentElement.lang` disagrees\n * and this prop is absent.\n */\n locale?: string | readonly string[];\n /** Step with the mouse wheel while the input is focused. Default `false`. */\n stepOnWheel?: boolean;\n /** Native `name` on the hidden input; defaults to the Field's `name` inside a `Field.Root`. */\n name?: string;\n /** Native `form` on the hidden input. */\n form?: string;\n /** Disables both inputs and the buttons; inherited by every part. */\n disabled?: boolean;\n /** Native `readonly` on both inputs; no stepping (buttons disabled, keys and wheel inert). */\n readOnly?: boolean;\n /** Native `required` on the hidden input (empty is `valueMissing`); or the Field's. */\n required?: boolean;\n /**\n * What is announced (`ariaNotify()`) after a key press, a wheel event, a\n * click activation and a hold's release. Default: `(_, state) => state.text`. Return `null` to\n * announce nothing.\n */\n announce?: (value: number | null, state: NumberFieldState) => string | null;\n className?: StateValue<string | undefined, NumberFieldState>;\n style?: StateValue<CSSProperties | undefined, NumberFieldState>;\n children?: StateValue<ReactNode, NumberFieldState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, NumberFieldState>;\n}\n\nconst STEP_TYPES = transitionTypes(\"number-field\", \"change\");\nconst COMMIT_TYPES = transitionTypes(\"number-field\", \"commit\");\n\n/** A finite number, or `null` (`NaN` / `Infinity` are treated as empty). */\nfunction sanitize(value: number | null | undefined): number | null | undefined {\n if (value === undefined || value === null) return value;\n return Number.isFinite(value) ? value : null;\n}\n\n/** The hidden input's value for `value`. */\nfunction hiddenText(value: number | null): string {\n return value === null ? \"\" : String(value);\n}\n\n/**\n * Mount reconciliation's read of the visible input (design 4.5): the value the hydrated text\n * means. The client's own formatting of `current` is `current`. Focused text is still being typed\n * (even a partial `12,` or `-`): handed to `adoptDraft`, never overwritten under the caret; the\n * blur commits or reverts it by the ordinary rule. Otherwise the parsed text, or, for another\n * locale's formatting of the same value or text that is no number, `current` with the client's\n * text written back (react-dom kept the hydrated DOM value).\n */\nfunction readVisible(\n visible: HTMLInputElement | null,\n current: number | null,\n formatter: NumberFormatter,\n adoptDraft: (text: string) => void,\n): number | null {\n if (visible === null) return current;\n const domText = visible.value;\n if (domText === formatter.format(current)) return current;\n if (visible.ownerDocument.activeElement === visible) {\n adoptDraft(domText);\n return current;\n }\n const parsed = formatter.parse(domText);\n if (parsed === undefined || Object.is(parsed, current)) {\n visible.value = formatter.format(current);\n return current;\n }\n return parsed;\n}\n\n/**\n * Owns the number field's state (design/components/number-field.md 2): the committed value\n * through `useControllableAction` with `valueCommitAction` (once per gesture), each step through\n * its own transition (`valueChangeAction`), the urgent draft text, the urgent value of the open\n * gesture (`live`), the press-and-hold, the formatter and parser, the announcements, mount\n * reconciliation and form reset (through the hidden input the Input renders).\n *\n * Owned keys (conventions 1.2): `role=\"group\"`, `aria-labelledby` (token-merged: the consumer's,\n * then `NumberField.Label`'s id while one is mounted, then a Field's label id), `data-pending`,\n * `data-disabled`, `data-invalid` (inside a Field).\n */\nexport function NumberFieldRoot(props: NumberFieldRootProps) {\n const {\n value: valueProp,\n defaultValue: defaultValueProp,\n valueChangeAction,\n valueCommitAction,\n min,\n max,\n step: stepProp,\n largeStep: largeStepProp,\n format,\n locale,\n stepOnWheel = false,\n name: nameProp,\n form,\n disabled: disabledProp = false,\n readOnly = false,\n required: requiredProp = false,\n announce,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n const value = sanitize(valueProp);\n const defaultValue = sanitize(defaultValueProp);\n\n // --- Format, bounds -----------------------------------------------------------------------\n\n const key = formatKey(format);\n const localeKey = locale === undefined ? \"\" : JSON.stringify(locale);\n // Memoised on the content of `format` and `locale`, not their identity (an inline object).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const formatter = useMemo(() => createNumberFormatter(locale, format), [localeKey, key]);\n const defaultStep = formatter.percent ? 0.01 : 1;\n const stepValid = stepProp === undefined || (Number.isFinite(stepProp) && stepProp > 0);\n const stepSize = stepProp !== undefined && stepValid ? stepProp : defaultStep;\n const largeStepValid =\n largeStepProp === undefined || (Number.isFinite(largeStepProp) && largeStepProp > 0);\n const largeStep = largeStepProp !== undefined && largeStepValid ? largeStepProp : 10 * stepSize;\n const bounds = useMemo<StepBounds>(\n () => ({\n min: Number.isFinite(min) ? min : undefined,\n max: Number.isFinite(max) ? max : undefined,\n step: stepSize,\n }),\n [min, max, stepSize],\n );\n\n // --- Field ----------------------------------------------------------------------------------\n\n // NumberField.Input registers the control (design 7.1); the Root only resolves the defaults.\n const fieldContext = use(FieldContext);\n const { disabled, required, name } = resolveFieldDefaults(fieldContext, {\n name: nameProp,\n disabled: disabledProp,\n required: requiredProp,\n });\n const fieldInvalid = fieldContext === null ? undefined : fieldContext.state.invalid;\n\n const id = useId();\n const inputId = fieldContext?.ids.control ?? `${id}-input`;\n const labelId = `${id}-label`;\n\n // --- State (design 2) -----------------------------------------------------------------------\n\n const [draft, setDraft] = useState<string | null>(null);\n const draftRef = useRef<string | null>(null);\n /** The value the open gesture has reached (`null` inside: an empty value). */\n const [live, setLive] = useState<{ readonly value: number | null } | null>(null);\n const [hold, setHold] = useState<StepDirection | null>(null);\n const [stepHeld, setStepHeld] = useState(false);\n const [pendingSource, setPendingSource] = useState<NumberFieldSource>(null);\n\n const liveRef = useRef<number | null>(null);\n /** The shown value when the open gesture began; `null` when no gesture is open. */\n const gestureStart = useRef<{ readonly value: number | null } | null>(null);\n /** The value the next tick of a hold steps from. */\n const holdBase = useRef<number | null>(null);\n const holdRef = useRef<StepDirection | null>(null);\n const commitSeq = useRef(0);\n const lastReason = useRef<ChangeReason | null>(null);\n const visibleRef = useRef<HTMLInputElement | null>(null);\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n\n const clearDraft = useCallback(() => {\n if (draftRef.current === null) return;\n draftRef.current = null;\n setDraft(null);\n }, []);\n\n /**\n * Writes `next` into the hidden input, then mirrors its validity onto the visible input, which\n * is invalid exactly when the hidden one is (6.2).\n */\n const syncHidden = useCallback((next: number | null) => {\n const hidden = hiddenRef.current;\n if (hidden !== null) {\n const text = hiddenText(next);\n if (hidden.value !== text) hidden.value = text;\n }\n const visible = visibleRef.current;\n if (hidden === null || visible === null) return;\n const message = hidden.validationMessage;\n if (visible.validationMessage !== message) visible.setCustomValidity(message);\n }, []);\n\n // One capture for both channels, before both transitions (see `captureSuperseded`).\n const captureSuperseded = useSupersededRejection();\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 captureSuperseded,\n });\n\n const runCommit = async (\n next: number | null,\n details: NumberFieldValueChangeDetails,\n ): 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 (valueProp === undefined && seq === commitSeq.current) {\n await undefined;\n // `step` and `committedRef` are declared below; this runs long after the render.\n step(committedRef.current, null, \"dismiss\", undefined);\n }\n throw error;\n }\n };\n\n const commitState = useControllableAction<number | null, NumberFieldValueChangeDetails>({\n controlled: value,\n defaultValue,\n initialValue: null,\n action: runCommit,\n transitionTypes: () => COMMIT_TYPES,\n warn: { component: \"NumberField.Root\", prop: \"value\" },\n captureSuperseded,\n });\n const { optimistic, committed, dispatch } = commitState;\n const committedRef = useLatest(committed);\n\n const held = hold !== null || stepHeld || stepPending || commitState.pending;\n const shown = held && live !== null ? live.value : optimistic;\n const pending = stepPending || commitState.pending;\n const text = draft ?? formatter.format(shown);\n // The value a button press steps from (4.3 step 3): the parsed draft while one is open.\n const parsedDraft = draft === null ? undefined : formatter.parse(draft);\n const stepBase = parsedDraft === undefined ? shown : parsedDraft;\n /** What the input shows, for handlers; also written by `step` ahead of the render. */\n const shownRef = useLatest(shown);\n\n const state = useMemo<NumberFieldState>(\n () => ({ value: shown, text, pending, disabled, readOnly, required }),\n [shown, text, pending, disabled, readOnly, required],\n );\n\n // A step, a key and a typed commit fire no `input` / `change` on the element the Field hears\n // for the value (the hidden input is written by script): tell it at the commit (design 7.2).\n useFieldValueChange(optimistic, () => {\n const edit = lastReason.current === \"activate\";\n lastReason.current = null;\n return edit;\n });\n\n const latest = useLatest({\n valueChangeAction,\n runStep,\n formatter,\n bounds,\n largeStep,\n disabled,\n readOnly,\n announce,\n state,\n });\n\n // --- Step and commit (design 2.4) -----------------------------------------------------------\n\n const step = useCallback(\n (\n next: number | null,\n source: NumberFieldSource,\n reason: ChangeReason,\n event: Event | undefined,\n ): boolean => {\n // What the text can show is what the form posts (5.4): a step finer than the format's\n // digits is rounded like a typed value.\n const { formatter: f } = latest.current;\n if (next !== null) next = f.round(next);\n // No-op against what the user sees (conventions 2.3 item 8).\n if (Object.is(next, shownRef.current)) return false;\n liveRef.current = next;\n shownRef.current = next;\n lastReason.current = reason;\n setLive({ value: next });\n clearDraft();\n setPendingSource(source);\n syncHidden(next);\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, runStep: run } = latest.current;\n // Without a step action nothing runs and no transition starts (as Slider).\n if (action === undefined) return true;\n run(() => {\n for (const type of STEP_TYPES) addTransitionType(type);\n return action(next, createActionDetails(event, { reason, source }));\n });\n return true;\n },\n [clearDraft, latest, shownRef, syncHidden],\n );\n\n const announceValue = useCallback(\n (next: number | null) => {\n const visible = visibleRef.current;\n if (visible === null) return;\n const { announce: compose, formatter: f, state: s } = latest.current;\n const nextState: NumberFieldState = { ...s, value: next, text: f.format(next) };\n const message = compose === undefined ? nextState.text : compose(next, nextState);\n if (message !== null) speak(visible, message);\n },\n [latest],\n );\n\n const commit = useCallback(\n (source: NumberFieldSource, reason: ChangeReason, event: Event | undefined): boolean => {\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 hold that returned to its start).\n if (start === null || Object.is(next, start.value)) return false;\n lastReason.current = reason;\n setPendingSource(source);\n dispatch(next, createActionDetails(event, { reason, source }));\n if (reason === \"activate\" && source !== \"input\" && source !== null) announceValue(next);\n return true;\n },\n [announceValue, dispatch],\n );\n\n /** Opens a gesture at the shown value. */\n const openGesture = useCallback(() => {\n gestureStart.current = { value: shownRef.current };\n liveRef.current = shownRef.current;\n }, [shownRef]);\n\n /** The value a key or a button steps from: the parsed draft if one is open, else the shown value. */\n const resolveBase = useCallback((): number | null => {\n const open = draftRef.current;\n if (open !== null) {\n const parsed = latest.current.formatter.parse(open);\n clearDraft();\n if (parsed !== undefined) return parsed;\n }\n return shownRef.current;\n }, [clearDraft, latest, shownRef]);\n\n /** A one-step gesture: a key press, a wheel event, a click activation. */\n const oneStep = useCallback(\n (compute: (base: number | null) => number | null, source: NumberFieldSource, event: Event) => {\n const base = resolveBase();\n openGesture();\n step(compute(base), source, \"activate\", event);\n commit(source, \"activate\", event);\n },\n [commit, openGesture, resolveBase, step],\n );\n\n // --- Typing (design 4.1) ----------------------------------------------------------------------\n\n const typed = useCallback((next: string) => {\n draftRef.current = next;\n setDraft(next);\n }, []);\n\n const commitDraft = useCallback(\n (event: Event) => {\n const open = draftRef.current;\n if (open === null) return;\n const { formatter: f, disabled: off, readOnly: ro } = latest.current;\n if (off || ro) {\n clearDraft();\n return;\n }\n const parsed = f.parse(open);\n // Unparsable: revert to the committed value's text, no dispatch, no error.\n if (parsed === undefined || Object.is(parsed, shownRef.current)) {\n clearDraft();\n return;\n }\n openGesture();\n step(parsed, \"input\", \"activate\", event);\n commit(\"input\", \"activate\", event);\n },\n [clearDraft, commit, latest, openGesture, shownRef, step],\n );\n\n // --- Keyboard and wheel (design 4.2, 4.4) ----------------------------------------------------\n\n const keyDown = useCallback(\n (event: KeyboardEvent) => {\n const { disabled: off, readOnly: ro, bounds: b, largeStep: large } = latest.current;\n // WebKit fires `compositionend` before the confirming keydown, which then has\n // `isComposing === false` and `keyCode === 229` (Combobox's guard).\n if (off || ro || event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\") {\n commitDraft(event);\n return;\n }\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const compute = keyStep(event.key, event.shiftKey, b, large);\n if (compute === null) return;\n event.preventDefault();\n oneStep(compute, \"keyboard\", event);\n },\n [commitDraft, latest, oneStep],\n );\n\n const wheel = useCallback(\n (event: WheelEvent) => {\n const { disabled: off, readOnly: ro, bounds: b } = latest.current;\n const visible = visibleRef.current;\n if (off || ro || visible === null || event.deltaY === 0) return;\n // Only while the input is focused; unfocused, the page scrolls.\n if (visible.ownerDocument.activeElement !== visible) return;\n event.preventDefault();\n const n = event.deltaY < 0 ? 1 : -1;\n oneStep((v) => stepValue(v, n, b), \"wheel\", event);\n },\n [latest, oneStep],\n );\n\n // --- Buttons (design 4.3) ---------------------------------------------------------------------\n\n const endHold = useCallback(\n (direction: StepDirection, event: Event | undefined) => {\n if (holdRef.current !== direction) return;\n holdRef.current = null;\n setHold(null);\n commit(direction, \"activate\", event);\n },\n [commit],\n );\n\n const tickHold = useCallback(\n (direction: StepDirection, event: Event | undefined): boolean => {\n if (holdRef.current !== direction) return false;\n const { bounds: b } = latest.current;\n const n = direction === \"increment\" ? 1 : -1;\n const next = stepValue(holdBase.current, n, b);\n holdBase.current = next;\n step(next, direction, \"activate\", event);\n // At the bound: end the hold now, before the button re-renders disabled (a disabled\n // element may not deliver the release).\n if (stepValue(next, n, b) === next) {\n endHold(direction, event);\n return false;\n }\n return true;\n },\n [endHold, latest, step],\n );\n\n const beginHold = useCallback(\n (direction: StepDirection, event: Event): boolean => {\n const { disabled: off, readOnly: ro } = latest.current;\n if (off || ro || holdRef.current !== null) return false;\n const base = resolveBase();\n openGesture();\n // A capture alone holds `live` on screen: start it from what is shown.\n setLive({ value: shownRef.current });\n holdBase.current = base;\n holdRef.current = direction;\n setHold(direction);\n return tickHold(direction, event);\n },\n [latest, openGesture, resolveBase, shownRef, tickHold],\n );\n\n const activate = useCallback(\n (direction: StepDirection, event: Event) => {\n const { disabled: off, readOnly: ro, bounds: b } = latest.current;\n if (off || ro || holdRef.current !== null) return;\n const n = direction === \"increment\" ? 1 : -1;\n oneStep((v) => stepValue(v, n, b), direction, event);\n },\n [latest, oneStep],\n );\n\n // --- Labels ---------------------------------------------------------------------------------\n\n const [labelCount, setLabelCount] = useState(0);\n const registerLabel = useCallback(() => {\n setLabelCount((count) => count + 1);\n return () => setLabelCount((count) => count - 1);\n }, []);\n\n // --- Residual browser paths: mount reconciliation and form reset (design 4.5, 6.4) ----------\n\n const [mountValue] = useState(value);\n const resetTarget = (): number | null =>\n valueProp !== undefined ? (mountValue ?? null) : (defaultValue ?? null);\n const resetTargetText = hiddenText(resetTarget());\n\n const { onItemMounted } = useNativeGroupReconciliation<number | null>({\n element: hiddenRef as RefObject<FormAssociatedElement | null>,\n readCurrent: () =>\n readVisible(visibleRef.current, shownRef.current, formatter, (text) => {\n draftRef.current = text;\n setDraft(text);\n }),\n readDefault: () => {\n // A reset clears an open draft whatever the target.\n clearDraft();\n return resetTarget();\n },\n base: () => shownRef.current,\n onPlatformChange: (next, event) => {\n openGesture();\n step(next, null, \"platform\", event);\n commit(null, \"platform\", event);\n },\n onResetEvent: () => {\n // react-dom rewrites a controlled text input's `defaultValue` after every update; the\n // visible text's reset target is written right before the reset algorithm reads it.\n const visible = visibleRef.current;\n if (visible !== null) visible.defaultValue = formatter.format(resetTarget());\n },\n });\n\n // --- Development warnings -------------------------------------------------------------------\n\n useNumberFieldDevWarnings({\n value: valueProp,\n defaultValue: defaultValueProp,\n min,\n max,\n bounds,\n stepValid,\n largeStepValid,\n formatter,\n locale,\n });\n\n // An unmount mid-hold leaves nothing behind (the buttons detach their own listeners).\n useEffect(\n () => () => {\n holdRef.current = null;\n },\n [],\n );\n\n // --- Render ---------------------------------------------------------------------------------\n\n const context = useMemo<NumberFieldContextValue>(\n () => ({\n state,\n bounds,\n stepBase,\n pendingSource: pending ? pendingSource : null,\n inputId,\n labelId,\n name,\n form,\n allowsFractions: formatter.allowsFractions || !Number.isInteger(stepSize),\n stepOnWheel,\n resetTargetText,\n fieldInvalid,\n visibleRef,\n hiddenRef,\n typed,\n commitDraft,\n keyDown,\n wheel,\n beginHold,\n tickHold,\n endHold,\n activate,\n syncHidden,\n registerLabel,\n onItemMounted,\n }),\n [\n state,\n bounds,\n stepBase,\n pending,\n pendingSource,\n inputId,\n labelId,\n name,\n form,\n formatter,\n stepSize,\n stepOnWheel,\n resetTargetText,\n fieldInvalid,\n typed,\n commitDraft,\n keyDown,\n wheel,\n beginHold,\n tickHold,\n endHold,\n activate,\n syncHidden,\n registerLabel,\n onItemMounted,\n ],\n );\n\n const labelledBy = mergeTokenLists(labelCount > 0 ? labelId : undefined, fieldContext?.ids.label);\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: \"group\",\n ...(labelledBy !== \"\" ? { \"aria-labelledby\": labelledBy } : {}),\n ...(fieldContext !== null ? { \"data-invalid\": dataAttr(fieldInvalid === true) } : {}),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, NumberFieldState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n });\n\n return <NumberFieldContext value={context}>{element}</NumberFieldContext>;\n}\n\nNumberFieldRoot.displayName = \"NumberFieldRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4IA,MAAM,aAAa,gBAAgB,gBAAgB,QAAQ;AAC3D,MAAM,eAAe,gBAAgB,gBAAgB,QAAQ;;AAG7D,SAAS,SAAS,OAA6D;CAC7E,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;;AAGA,SAAS,WAAW,OAA8B;CAChD,OAAO,UAAU,OAAO,KAAK,OAAO,KAAK;AAC3C;;;;;;;;;AAUA,SAAS,YACP,SACA,SACA,WACA,YACe;CACf,IAAI,YAAY,MAAM,OAAO;CAC7B,MAAM,UAAU,QAAQ;CACxB,IAAI,YAAY,UAAU,OAAO,OAAO,GAAG,OAAO;CAClD,IAAI,QAAQ,cAAc,kBAAkB,SAAS;EACnD,WAAW,OAAO;EAClB,OAAO;CACT;CACA,MAAM,SAAS,UAAU,MAAM,OAAO;CACtC,IAAI,WAAW,KAAA,KAAa,OAAO,GAAG,QAAQ,OAAO,GAAG;EACtD,QAAQ,QA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KAAK;EAChC;EACA,oBAAoB;GAGlB,MAAM,UAAU,WAAW;GAC3B,IAAI,YAAY,MAAM,QAAQ,eAAe,UAAU,OAAO,YAAY,CAAC;EAC7E;CACF,CAAC;CAID,0BAA0B;EACxB,OAAO;EACP,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAGD,sBACc;EACV,QAAQ,UAAU;CACpB,GACA,CAAC,CACH;CAIA,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA,eAAe,UAAU,gBAAgB;EACzC;EACA;EACA;EACA;EACA,iBAAiB,UAAU,mBAAmB,CAAC,OAAO,UAAU,QAAQ;EACxE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,aAAa,gBAAgB,aAAa,IAAI,UAAU,KAAA,GAAW,cAAc,IAAI,KAAK;CAChG,MAAM,eAAuE;EAC3E,MAAM;EACN,GAAI,eAAe,KAAK,EAAE,mBAAmB,WAAW,IAAI,CAAC;EAC7D,GAAI,iBAAiB,OAAO,EAAE,gBAAgB,SAAS,iBAAiB,IAAI,EAAE,IAAI,CAAC;EACnF,gBAAgB,SAAS,OAAO;EAChC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,MAAM,UAAU,UAA0D;EACxE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;CACF,CAAC;CAED,OAAO,oBAAC,oBAAD;EAAoB,OAAO;EAAU,UAAA;CAA4B,CAAA;AAC1E;AAEA,gBAAgB,cAAc"}
1
+ {"version":3,"file":"number-field-root.mjs","names":[],"sources":["../../src/number-field/number-field-root.tsx"],"sourcesContent":["\"use client\";\nimport {\n addTransitionType,\n use,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, RefObject } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { announce as speak } from \"../internal/announce.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { FieldContext } from \"../internal/field-context.js\";\nimport { mergeTokenLists } from \"../internal/merge-props.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 { useActionTrigger } from \"../internal/use-action-trigger.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { resolveFieldDefaults, useFieldValueChange } from \"../internal/use-field-control.js\";\nimport type { FormAssociatedElement } from \"../internal/use-form-owner-event.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useNativeGroupReconciliation } from \"../internal/use-native-group-reconciliation.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { keyStep, stepValue } from \"./number-field-arithmetic.js\";\nimport type { StepBounds } from \"./number-field-arithmetic.js\";\nimport { NumberFieldContext } from \"./number-field-context.js\";\nimport type {\n NumberFieldContextValue,\n NumberFieldSource,\n StepDirection,\n} from \"./number-field-context.js\";\nimport { createNumberFormatter, formatKey } from \"./number-field-format.js\";\nimport type { NumberFormatter } from \"./number-field-format.js\";\nimport { useNumberFieldDevWarnings } from \"./use-number-field-dev-warnings.js\";\n\n/** Details passed as the second argument of both NumberField actions. */\nexport interface NumberFieldValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user typed, pressed a key, a button or turned the wheel (`details.event` is\n * the `focusout` / Enter `keydown` of a typed value, the `keydown` of a key, the `pointerdown` /\n * `pointerup` of a button (`undefined` for the repeats of a held button and for a hold that\n * ended at its bound), the `wheel` event). `\"platform\"`: a form reset (the `reset`\n * event) or text typed before hydration (`undefined`). `\"dismiss\"`: the commit action rejected\n * and the field reverted to the committed value (uncontrolled; `valueChangeAction` only).\n */\n readonly reason: ChangeReason;\n /** What produced the value: typed text, a button, a key, the wheel; `null` for \"platform\" and \"dismiss\". */\n readonly source: NumberFieldSource;\n}\n\n/** The state every NumberField part's function props receive (one object, Field's precedent). */\nexport interface NumberFieldState {\n /** The shown value: the gesture's value while one is open or in flight, else the optimistic value; `null` when empty. */\n readonly value: number | null;\n /** The shown text: the draft while the user is editing, else `value` formatted. */\n readonly text: string;\n /** A step or commit dispatched through this NumberField is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop, or the enclosing Field's. */\n readonly disabled: boolean;\n /** The `readOnly` prop. */\n readonly readOnly: boolean;\n /** The `required` prop, or the enclosing Field's. */\n readonly required: boolean;\n}\n\n/**\n * Props of `NumberField.Root`.\n *\n * @see https://ui.funstack.work/components/number-field\n */\nexport interface NumberFieldRootProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"defaultValue\" | \"role\" | \"className\" | \"style\" | \"children\"\n> {\n /** Controlled value; `null` is empty, `undefined` uncontrolled. */\n value?: number | null;\n /**\n * Initial value in uncontrolled mode, and its form-reset target (latest).\n *\n * @defaultValue `null` (empty)\n */\n defaultValue?: number | null;\n /**\n * Runs inside the Root's step transition on every step: the parse of typed text at commit,\n * each key press, each tick of a hold, each wheel event, each platform change, and the revert\n * after a rejected commit (`reason: \"dismiss\"`, uncontrolled). Keep it cheap: adopt the value\n * (`setValue(next)` in the sync prefix is a transition update), start a deferred render.\n */\n valueChangeAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;\n /**\n * Runs inside the Root's commit transition once per gesture: a typed text's blur or Enter, a\n * hold's release, each key press, each wheel event, a form reset, text typed before hydration.\n * Where the save goes; uncontrolled state is committed when it resolves and reverts when it\n * rejects. May be a Server Function.\n */\n valueCommitAction?: ChangeAction<number | null, NumberFieldValueChangeDetails>;\n /** Native `min` on the hidden input (a constraint) and the lower bound of stepping. */\n min?: number;\n /** Native `max` on the hidden input (a constraint) and the upper bound of stepping. */\n max?: number;\n /**\n * Native `step` and the stepping grid from `min` (else `0`).\n *\n * @defaultValue `1`, or `0.01` when `format.style` is `\"percent\"`\n */\n step?: number;\n /**\n * The step of PageUp / PageDown and Shift+Arrow.\n *\n * @defaultValue `10 × step`\n */\n largeStep?: number;\n /**\n * `Intl.NumberFormatOptions` for the text: `style` `\"decimal\"` (default), `\"percent\"`,\n * `\"currency\"` (with `currency`), `\"unit\"` (with `unit`); fraction digits, grouping, sign\n * display. `notation: \"compact\"` is a dev warning (unparsable).\n */\n format?: Intl.NumberFormatOptions;\n /**\n * BCP 47 tag(s). Pass the page's `lang`; a dev warning fires when\n * `document.documentElement.lang` disagrees and this prop is absent.\n *\n * @defaultValue the runtime's locale (`Intl.NumberFormat().resolvedOptions().locale`)\n */\n locale?: string | readonly string[];\n /**\n * Step with the mouse wheel while the input is focused.\n *\n * @defaultValue `false`\n */\n stepOnWheel?: boolean;\n /**\n * Native `name` on the hidden input.\n *\n * @defaultValue the Field's `name` inside a `Field.Root`\n */\n name?: string;\n /** Native `form` on the hidden input. */\n form?: string;\n /**\n * Disables both inputs and the buttons; inherited by every part.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Native `readonly` on both inputs; no stepping (buttons disabled, keys and wheel inert).\n *\n * @defaultValue `false`\n */\n readOnly?: boolean;\n /**\n * Native `required` on the hidden input (empty is `valueMissing`); or the Field's.\n *\n * @defaultValue `false`\n */\n required?: boolean;\n /**\n * What is announced (`ariaNotify()`) after a key press, a wheel event, a click activation and a\n * hold's release. Return `null` to announce nothing.\n *\n * @defaultValue `(_, state) => state.text`\n */\n announce?: (value: number | null, state: NumberFieldState) => string | null;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, NumberFieldState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, NumberFieldState>;\n /** The parts. The function form receives the state. */\n children?: StateValue<ReactNode, NumberFieldState>;\n /** Replace the default `<div>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, NumberFieldState>;\n}\n\nconst STEP_TYPES = transitionTypes(\"number-field\", \"change\");\nconst COMMIT_TYPES = transitionTypes(\"number-field\", \"commit\");\n\n/** A finite number, or `null` (`NaN` / `Infinity` are treated as empty). */\nfunction sanitize(value: number | null | undefined): number | null | undefined {\n if (value === undefined || value === null) return value;\n return Number.isFinite(value) ? value : null;\n}\n\n/** The hidden input's value for `value`. */\nfunction hiddenText(value: number | null): string {\n return value === null ? \"\" : String(value);\n}\n\n/**\n * Mount reconciliation's read of the visible input (design 4.5): the value the hydrated text\n * means. The client's own formatting of `current` is `current`. Focused text is still being typed\n * (even a partial `12,` or `-`): handed to `adoptDraft`, never overwritten under the caret; the\n * blur commits or reverts it by the ordinary rule. Otherwise the parsed text, or, for another\n * locale's formatting of the same value or text that is no number, `current` with the client's\n * text written back (react-dom kept the hydrated DOM value).\n */\nfunction readVisible(\n visible: HTMLInputElement | null,\n current: number | null,\n formatter: NumberFormatter,\n adoptDraft: (text: string) => void,\n): number | null {\n if (visible === null) return current;\n const domText = visible.value;\n if (domText === formatter.format(current)) return current;\n if (visible.ownerDocument.activeElement === visible) {\n adoptDraft(domText);\n return current;\n }\n const parsed = formatter.parse(domText);\n if (parsed === undefined || Object.is(parsed, current)) {\n visible.value = formatter.format(current);\n return current;\n }\n return parsed;\n}\n\n/**\n * Owns the number field's state (design/components/number-field.md 2): the committed value\n * through `useControllableAction` with `valueCommitAction` (once per gesture), each step through\n * its own transition (`valueChangeAction`), the urgent draft text, the urgent value of the open\n * gesture (`live`), the press-and-hold, the formatter and parser, the announcements, mount\n * reconciliation and form reset (through the hidden input the Input renders).\n *\n * Owned keys (conventions 1.2): `role=\"group\"`, `aria-labelledby` (token-merged: the consumer's,\n * then `NumberField.Label`'s id while one is mounted, then a Field's label id), `data-pending`,\n * `data-disabled`, `data-invalid` (inside a Field).\n *\n * @see https://ui.funstack.work/components/number-field\n */\nexport function NumberFieldRoot(props: NumberFieldRootProps) {\n const {\n value: valueProp,\n defaultValue: defaultValueProp,\n valueChangeAction,\n valueCommitAction,\n min,\n max,\n step: stepProp,\n largeStep: largeStepProp,\n format,\n locale,\n stepOnWheel = false,\n name: nameProp,\n form,\n disabled: disabledProp = false,\n readOnly = false,\n required: requiredProp = false,\n announce,\n className,\n style,\n children,\n render,\n ...rest\n } = props;\n\n const value = sanitize(valueProp);\n const defaultValue = sanitize(defaultValueProp);\n\n // --- Format, bounds -----------------------------------------------------------------------\n\n const key = formatKey(format);\n const localeKey = locale === undefined ? \"\" : JSON.stringify(locale);\n // Memoised on the content of `format` and `locale`, not their identity (an inline object).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const formatter = useMemo(() => createNumberFormatter(locale, format), [localeKey, key]);\n const defaultStep = formatter.percent ? 0.01 : 1;\n const stepValid = stepProp === undefined || (Number.isFinite(stepProp) && stepProp > 0);\n const stepSize = stepProp !== undefined && stepValid ? stepProp : defaultStep;\n const largeStepValid =\n largeStepProp === undefined || (Number.isFinite(largeStepProp) && largeStepProp > 0);\n const largeStep = largeStepProp !== undefined && largeStepValid ? largeStepProp : 10 * stepSize;\n const bounds = useMemo<StepBounds>(\n () => ({\n min: Number.isFinite(min) ? min : undefined,\n max: Number.isFinite(max) ? max : undefined,\n step: stepSize,\n }),\n [min, max, stepSize],\n );\n\n // --- Field ----------------------------------------------------------------------------------\n\n // NumberField.Input registers the control (design 7.1); the Root only resolves the defaults.\n const fieldContext = use(FieldContext);\n const { disabled, required, name } = resolveFieldDefaults(fieldContext, {\n name: nameProp,\n disabled: disabledProp,\n required: requiredProp,\n });\n const fieldInvalid = fieldContext === null ? undefined : fieldContext.state.invalid;\n\n const id = useId();\n const inputId = fieldContext?.ids.control ?? `${id}-input`;\n const labelId = `${id}-label`;\n\n // --- State (design 2) -----------------------------------------------------------------------\n\n const [draft, setDraft] = useState<string | null>(null);\n const draftRef = useRef<string | null>(null);\n /** The value the open gesture has reached (`null` inside: an empty value). */\n const [live, setLive] = useState<{ readonly value: number | null } | null>(null);\n const [hold, setHold] = useState<StepDirection | null>(null);\n const [stepHeld, setStepHeld] = useState(false);\n const [pendingSource, setPendingSource] = useState<NumberFieldSource>(null);\n\n const liveRef = useRef<number | null>(null);\n /** The shown value when the open gesture began; `null` when no gesture is open. */\n const gestureStart = useRef<{ readonly value: number | null } | null>(null);\n /** The value the next tick of a hold steps from. */\n const holdBase = useRef<number | null>(null);\n const holdRef = useRef<StepDirection | null>(null);\n const commitSeq = useRef(0);\n const lastReason = useRef<ChangeReason | null>(null);\n const visibleRef = useRef<HTMLInputElement | null>(null);\n const hiddenRef = useRef<HTMLInputElement | null>(null);\n\n const clearDraft = useCallback(() => {\n if (draftRef.current === null) return;\n draftRef.current = null;\n setDraft(null);\n }, []);\n\n /**\n * Writes `next` into the hidden input, then mirrors its validity onto the visible input, which\n * is invalid exactly when the hidden one is (6.2).\n */\n const syncHidden = useCallback((next: number | null) => {\n const hidden = hiddenRef.current;\n if (hidden !== null) {\n const text = hiddenText(next);\n if (hidden.value !== text) hidden.value = text;\n }\n const visible = visibleRef.current;\n if (hidden === null || visible === null) return;\n const message = hidden.validationMessage;\n if (visible.validationMessage !== message) visible.setCustomValidity(message);\n }, []);\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 runCommit = async (\n next: number | null,\n details: NumberFieldValueChangeDetails,\n ): 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 (valueProp === undefined && seq === commitSeq.current) {\n await undefined;\n // `step` and `committedRef` are declared below; this runs long after the render.\n step(committedRef.current, null, \"dismiss\", undefined);\n }\n throw error;\n }\n };\n\n const commitState = useControllableAction<number | null, NumberFieldValueChangeDetails>({\n controlled: value,\n defaultValue,\n initialValue: null,\n action: runCommit,\n transitionTypes: () => COMMIT_TYPES,\n warn: { component: \"NumberField.Root\", prop: \"value\" },\n });\n const { optimistic, committed, dispatch } = commitState;\n const committedRef = useLatest(committed);\n\n const held = hold !== null || stepHeld || stepPending || commitState.pending;\n const shown = held && live !== null ? live.value : optimistic;\n const pending = stepPending || commitState.pending;\n const text = draft ?? formatter.format(shown);\n // The value a button press steps from (4.3 step 3): the parsed draft while one is open.\n const parsedDraft = draft === null ? undefined : formatter.parse(draft);\n const stepBase = parsedDraft === undefined ? shown : parsedDraft;\n /** What the input shows, for handlers; also written by `step` ahead of the render. */\n const shownRef = useLatest(shown);\n\n const state = useMemo<NumberFieldState>(\n () => ({ value: shown, text, pending, disabled, readOnly, required }),\n [shown, text, pending, disabled, readOnly, required],\n );\n\n // A step, a key and a typed commit fire no `input` / `change` on the element the Field hears\n // for the value (the hidden input is written by script): tell it at the commit (design 7.2).\n useFieldValueChange(optimistic, () => {\n const edit = lastReason.current === \"activate\";\n lastReason.current = null;\n return edit;\n });\n\n const latest = useLatest({\n valueChangeAction,\n runStep,\n formatter,\n bounds,\n largeStep,\n disabled,\n readOnly,\n announce,\n state,\n });\n\n // --- Step and commit (design 2.4) -----------------------------------------------------------\n\n const step = useCallback(\n (\n next: number | null,\n source: NumberFieldSource,\n reason: ChangeReason,\n event: Event | undefined,\n ): boolean => {\n // What the text can show is what the form posts (5.4): a step finer than the format's\n // digits is rounded like a typed value.\n const { formatter: f } = latest.current;\n if (next !== null) next = f.round(next);\n // No-op against what the user sees (conventions 2.3 item 8).\n if (Object.is(next, shownRef.current)) return false;\n liveRef.current = next;\n shownRef.current = next;\n lastReason.current = reason;\n setLive({ value: next });\n clearDraft();\n setPendingSource(source);\n syncHidden(next);\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, runStep: run } = latest.current;\n // Without a step action nothing runs and no transition starts (as Slider).\n if (action === undefined) return true;\n run(() => {\n for (const type of STEP_TYPES) addTransitionType(type);\n return action(next, createActionDetails(event, { reason, source }));\n });\n return true;\n },\n [clearDraft, latest, shownRef, syncHidden],\n );\n\n const announceValue = useCallback(\n (next: number | null) => {\n const visible = visibleRef.current;\n if (visible === null) return;\n const { announce: compose, formatter: f, state: s } = latest.current;\n const nextState: NumberFieldState = { ...s, value: next, text: f.format(next) };\n const message = compose === undefined ? nextState.text : compose(next, nextState);\n if (message !== null) speak(visible, message);\n },\n [latest],\n );\n\n const commit = useCallback(\n (source: NumberFieldSource, reason: ChangeReason, event: Event | undefined): boolean => {\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 hold that returned to its start).\n if (start === null || Object.is(next, start.value)) return false;\n lastReason.current = reason;\n setPendingSource(source);\n dispatch(next, createActionDetails(event, { reason, source }));\n if (reason === \"activate\" && source !== \"input\" && source !== null) announceValue(next);\n return true;\n },\n [announceValue, dispatch],\n );\n\n /** Opens a gesture at the shown value. */\n const openGesture = useCallback(() => {\n gestureStart.current = { value: shownRef.current };\n liveRef.current = shownRef.current;\n }, [shownRef]);\n\n /** The value a key or a button steps from: the parsed draft if one is open, else the shown value. */\n const resolveBase = useCallback((): number | null => {\n const open = draftRef.current;\n if (open !== null) {\n const parsed = latest.current.formatter.parse(open);\n clearDraft();\n if (parsed !== undefined) return parsed;\n }\n return shownRef.current;\n }, [clearDraft, latest, shownRef]);\n\n /** A one-step gesture: a key press, a wheel event, a click activation. */\n const oneStep = useCallback(\n (compute: (base: number | null) => number | null, source: NumberFieldSource, event: Event) => {\n const base = resolveBase();\n openGesture();\n step(compute(base), source, \"activate\", event);\n commit(source, \"activate\", event);\n },\n [commit, openGesture, resolveBase, step],\n );\n\n // --- Typing (design 4.1) ----------------------------------------------------------------------\n\n const typed = useCallback((next: string) => {\n draftRef.current = next;\n setDraft(next);\n }, []);\n\n const commitDraft = useCallback(\n (event: Event) => {\n const open = draftRef.current;\n if (open === null) return;\n const { formatter: f, disabled: off, readOnly: ro } = latest.current;\n if (off || ro) {\n clearDraft();\n return;\n }\n const parsed = f.parse(open);\n // Unparsable: revert to the committed value's text, no dispatch, no error.\n if (parsed === undefined || Object.is(parsed, shownRef.current)) {\n clearDraft();\n return;\n }\n openGesture();\n step(parsed, \"input\", \"activate\", event);\n commit(\"input\", \"activate\", event);\n },\n [clearDraft, commit, latest, openGesture, shownRef, step],\n );\n\n // --- Keyboard and wheel (design 4.2, 4.4) ----------------------------------------------------\n\n const keyDown = useCallback(\n (event: KeyboardEvent) => {\n const { disabled: off, readOnly: ro, bounds: b, largeStep: large } = latest.current;\n // WebKit fires `compositionend` before the confirming keydown, which then has\n // `isComposing === false` and `keyCode === 229` (Combobox's guard).\n if (off || ro || event.isComposing || event.keyCode === 229) return;\n if (event.key === \"Enter\") {\n commitDraft(event);\n return;\n }\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const compute = keyStep(event.key, event.shiftKey, b, large);\n if (compute === null) return;\n event.preventDefault();\n oneStep(compute, \"keyboard\", event);\n },\n [commitDraft, latest, oneStep],\n );\n\n const wheel = useCallback(\n (event: WheelEvent) => {\n const { disabled: off, readOnly: ro, bounds: b } = latest.current;\n const visible = visibleRef.current;\n if (off || ro || visible === null || event.deltaY === 0) return;\n // Only while the input is focused; unfocused, the page scrolls.\n if (visible.ownerDocument.activeElement !== visible) return;\n event.preventDefault();\n const n = event.deltaY < 0 ? 1 : -1;\n oneStep((v) => stepValue(v, n, b), \"wheel\", event);\n },\n [latest, oneStep],\n );\n\n // --- Buttons (design 4.3) ---------------------------------------------------------------------\n\n const endHold = useCallback(\n (direction: StepDirection, event: Event | undefined) => {\n if (holdRef.current !== direction) return;\n holdRef.current = null;\n setHold(null);\n commit(direction, \"activate\", event);\n },\n [commit],\n );\n\n const tickHold = useCallback(\n (direction: StepDirection, event: Event | undefined): boolean => {\n if (holdRef.current !== direction) return false;\n const { bounds: b } = latest.current;\n const n = direction === \"increment\" ? 1 : -1;\n const next = stepValue(holdBase.current, n, b);\n holdBase.current = next;\n step(next, direction, \"activate\", event);\n // At the bound: end the hold now, before the button re-renders disabled (a disabled\n // element may not deliver the release).\n if (stepValue(next, n, b) === next) {\n endHold(direction, event);\n return false;\n }\n return true;\n },\n [endHold, latest, step],\n );\n\n const beginHold = useCallback(\n (direction: StepDirection, event: Event): boolean => {\n const { disabled: off, readOnly: ro } = latest.current;\n if (off || ro || holdRef.current !== null) return false;\n const base = resolveBase();\n openGesture();\n // A capture alone holds `live` on screen: start it from what is shown.\n setLive({ value: shownRef.current });\n holdBase.current = base;\n holdRef.current = direction;\n setHold(direction);\n return tickHold(direction, event);\n },\n [latest, openGesture, resolveBase, shownRef, tickHold],\n );\n\n const activate = useCallback(\n (direction: StepDirection, event: Event) => {\n const { disabled: off, readOnly: ro, bounds: b } = latest.current;\n if (off || ro || holdRef.current !== null) return;\n const n = direction === \"increment\" ? 1 : -1;\n oneStep((v) => stepValue(v, n, b), direction, event);\n },\n [latest, oneStep],\n );\n\n // --- Labels ---------------------------------------------------------------------------------\n\n const [labelCount, setLabelCount] = useState(0);\n const registerLabel = useCallback(() => {\n setLabelCount((count) => count + 1);\n return () => setLabelCount((count) => count - 1);\n }, []);\n\n // --- Residual browser paths: mount reconciliation and form reset (design 4.5, 6.4) ----------\n\n const [mountValue] = useState(value);\n const resetTarget = (): number | null =>\n valueProp !== undefined ? (mountValue ?? null) : (defaultValue ?? null);\n const resetTargetText = hiddenText(resetTarget());\n\n const { onItemMounted } = useNativeGroupReconciliation<number | null>({\n element: hiddenRef as RefObject<FormAssociatedElement | null>,\n readCurrent: () =>\n readVisible(visibleRef.current, shownRef.current, formatter, (text) => {\n draftRef.current = text;\n setDraft(text);\n }),\n readDefault: () => {\n // A reset clears an open draft whatever the target.\n clearDraft();\n return resetTarget();\n },\n base: () => shownRef.current,\n onPlatformChange: (next, event) => {\n openGesture();\n step(next, null, \"platform\", event);\n commit(null, \"platform\", event);\n },\n onResetEvent: () => {\n // react-dom rewrites a controlled text input's `defaultValue` after every update; the\n // visible text's reset target is written right before the reset algorithm reads it.\n const visible = visibleRef.current;\n if (visible !== null) visible.defaultValue = formatter.format(resetTarget());\n },\n });\n\n // --- Development warnings -------------------------------------------------------------------\n\n useNumberFieldDevWarnings({\n value: valueProp,\n defaultValue: defaultValueProp,\n min,\n max,\n bounds,\n stepValid,\n largeStepValid,\n formatter,\n locale,\n });\n\n // An unmount mid-hold leaves nothing behind (the buttons detach their own listeners).\n useEffect(\n () => () => {\n holdRef.current = null;\n },\n [],\n );\n\n // --- Render ---------------------------------------------------------------------------------\n\n const context = useMemo<NumberFieldContextValue>(\n () => ({\n state,\n bounds,\n stepBase,\n pendingSource: pending ? pendingSource : null,\n inputId,\n labelId,\n name,\n form,\n allowsFractions: formatter.allowsFractions || !Number.isInteger(stepSize),\n stepOnWheel,\n resetTargetText,\n fieldInvalid,\n visibleRef,\n hiddenRef,\n typed,\n commitDraft,\n keyDown,\n wheel,\n beginHold,\n tickHold,\n endHold,\n activate,\n syncHidden,\n registerLabel,\n onItemMounted,\n }),\n [\n state,\n bounds,\n stepBase,\n pending,\n pendingSource,\n inputId,\n labelId,\n name,\n form,\n formatter,\n stepSize,\n stepOnWheel,\n resetTargetText,\n fieldInvalid,\n typed,\n commitDraft,\n keyDown,\n wheel,\n beginHold,\n tickHold,\n endHold,\n activate,\n syncHidden,\n registerLabel,\n onItemMounted,\n ],\n );\n\n const labelledBy = mergeTokenLists(labelCount > 0 ? labelId : undefined, fieldContext?.ids.label);\n const libraryProps: Partial<ComponentPropsWithRef<\"div\">> & DataAttributes = {\n role: \"group\",\n ...(labelledBy !== \"\" ? { \"aria-labelledby\": labelledBy } : {}),\n ...(fieldContext !== null ? { \"data-invalid\": dataAttr(fieldInvalid === true) } : {}),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, NumberFieldState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n });\n\n return <NumberFieldContext value={context}>{element}</NumberFieldContext>;\n}\n\nNumberFieldRoot.displayName = \"NumberFieldRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyLA,MAAM,aAAa,gBAAgB,gBAAgB,QAAQ;AAC3D,MAAM,eAAe,gBAAgB,gBAAgB,QAAQ;;AAG7D,SAAS,SAAS,OAA6D;CAC7E,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;;AAGA,SAAS,WAAW,OAA8B;CAChD,OAAO,UAAU,OAAO,KAAK,OAAO,KAAK;AAC3C;;;;;;;;;AAUA,SAAS,YACP,SACA,SACA,WACA,YACe;CACf,IAAI,YAAY,MAAM,OAAO;CAC7B,MAAM,UAAU,QAAQ;CACxB,IAAI,YAAY,UAAU,OAAO,OAAO,GAAG,OAAO;CAClD,IAAI,QAAQ,cAAc,kBAAkB,SAAS;EACnD,WAAW,OAAO;EAClB,OAAO;CACT;CACA,MAAM,SAAS,UAAU,MAAM,OAAO;CACtC,IAAI,WAAW,KAAA,KAAa,OAAO,GAAG,QAAQ,OAAO,GAAG;EACtD,QAAQ,QAAQ,UAAU,OAAO,OAAO;EACxC,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,gBAAgB,OAA6B;CAC3D,MAAM,EACJ,OAAO,WACP,cAAc,kBACd,mBACA,mBACA,KACA,KACA,MAAM,UACN,WAAW,eACX,QACA,QACA,cAAc,OACd,MAAM,UACN,MACA,UAAU,eAAe,OACzB,WAAW,OACX,UAAU,eAAe,OACzB,UAAA,YACA,WACA,OACA,UACA,QACA,GAAG,SACD;CAEJ,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,eAAe,SAAS,gBAAgB;CAI9C,MA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ACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,aAAa,gBAAgB,aAAa,IAAI,UAAU,KAAA,GAAW,cAAc,IAAI,KAAK;CAChG,MAAM,eAAuE;EAC3E,MAAM;EACN,GAAI,eAAe,KAAK,EAAE,mBAAmB,WAAW,IAAI,CAAC;EAC7D,GAAI,iBAAiB,OAAO,EAAE,gBAAgB,SAAS,iBAAiB,IAAI,EAAE,IAAI,CAAC;EACnF,gBAAgB,SAAS,OAAO;EAChC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,MAAM,UAAU,UAA0D;EACxE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;CACF,CAAC;CAED,OAAO,oBAAC,oBAAD;EAAoB,OAAO;EAAU,UAAA;CAA4B,CAAA;AAC1E;AAEA,gBAAgB,cAAc"}
@@ -2,23 +2,43 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
2
2
  import "./number-field-context.mjs";
3
3
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
4
4
  //#region src/number-field/use-step-button.d.ts
5
+ /**
6
+ * State of `NumberField.Increment`, `NumberField.Decrement`, passed to the function forms of
7
+ * `className`, `style`, `children` and `render`.
8
+ */
5
9
  export interface NumberFieldButtonState {
6
10
  /** The Root is pending and the latest step or commit came from this button. */
7
11
  readonly pending: boolean;
8
12
  /** The prop, the Root's `disabled` or `readOnly`, or the next step would change nothing. */
9
13
  readonly disabled: boolean;
10
14
  }
15
+ /**
16
+ * Props of `NumberField.Increment` (`NumberField.Decrement` takes the same props).
17
+ *
18
+ * @see https://ui.funstack.work/components/number-field
19
+ */
11
20
  export interface NumberFieldIncrementProps extends Omit<ComponentPropsWithRef<"button">, "type" | "tabIndex" | "disabled" | "onPointerDown" | "onClick" | "onContextMenu" | "aria-controls" | "className" | "style" | "children"> {
12
21
  /**
13
22
  * Never steps. Native `disabled` on a `<button>` (also at the bound and under `readOnly`); with
14
23
  * a link or component `render`, `aria-disabled="true"` instead.
24
+ *
25
+ * @defaultValue `false`
15
26
  */
16
27
  disabled?: boolean;
28
+ /** Class name, or a function of the part's state that returns one. */
17
29
  className?: StateValue<string | undefined, NumberFieldButtonState>;
30
+ /** Inline style, or a function of the part's state that returns one. */
18
31
  style?: StateValue<CSSProperties | undefined, NumberFieldButtonState>;
32
+ /** Content, or a function of the part's state. */
19
33
  children?: StateValue<ReactNode, NumberFieldButtonState>;
34
+ /** Replace the default `<button>` (element form) or take over rendering (function form). */
20
35
  render?: RenderProp<ComponentPropsWithRef<"button">, NumberFieldButtonState>;
21
36
  }
37
+ /**
38
+ * Props of `NumberField.Decrement`: the same as `NumberFieldIncrementProps`.
39
+ *
40
+ * @see https://ui.funstack.work/components/number-field
41
+ */
22
42
  export type NumberFieldDecrementProps = NumberFieldIncrementProps;
23
43
  //#endregion
24
44
  //# sourceMappingURL=use-step-button.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-step-button.d.mts","names":[],"sources":["../../src/number-field/use-step-button.ts"],"mappings":";;;;iBA0JiB;;WAEN;;WAEA;;iBAGM,kCAAkC,KACjD;;;;;EAgBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;YAG3C,4BAA4B"}
1
+ {"version":3,"file":"use-step-button.d.mts","names":[],"sources":["../../src/number-field/use-step-button.ts"],"mappings":";;;;;;;;iBA8JiB;;WAEN;;WAEA;;;;;;;iBAQM,kCAAkC,KACjD;;;;;;;EAkBA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;YAQ3C,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-step-button.mjs","names":[],"sources":["../../src/number-field/use-step-button.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { disabledButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { isAtBound } from \"./number-field-arithmetic.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\nimport type { NumberFieldContextValue, StepDirection } from \"./number-field-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** First repeat after the press, then the interval between repeats (Base UI, React Aria). */\nconst HOLD_DELAY = 400;\nconst HOLD_INTERVAL = 60;\n\ninterface ActiveHold {\n readonly pointerId: number;\n readonly detach: () => void;\n}\n\nexport interface StepButtonHandlers {\n readonly onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;\n readonly onClick: (event: ReactMouseEvent<HTMLElement>) => void;\n readonly onContextMenu: (event: ReactMouseEvent<HTMLElement>) => void;\n}\n\n/**\n * The press-and-hold of `NumberField.Increment` / `Decrement` (design 4.3): one step at\n * `pointerdown`, a repeat after 400 ms then every 60 ms, one commit at the release\n * (`pointerup`, `pointercancel`, `lostpointercapture`, or `blur` on the window). The press is\n * `preventDefault()`ed so focus stays where it is. A `click` with no pointer gesture before it\n * (assistive technology: `detail === 0`) is a one-step gesture.\n */\nexport function useStepButton(\n ctx: NumberFieldContextValue,\n direction: StepDirection,\n disabled: boolean,\n): StepButtonHandlers {\n const active = useRef<ActiveHold | null>(null);\n /** A pointer gesture started on this button; the click that follows it is not an activation. */\n const pointerSeen = useRef(false);\n const latest = useRef({ ctx, disabled });\n useEffect(() => {\n latest.current = { ctx, disabled };\n });\n\n // An unmount mid-hold leaves no timer or listener behind.\n useEffect(\n () => () => {\n active.current?.detach();\n active.current = null;\n },\n [],\n );\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>): void => {\n if (event.button !== 0 || !event.isPrimary) return;\n if (disabled) {\n // A focusable disabled render (`aria-disabled`) must not take focus from the input\n // either; native `disabled` focused nothing.\n event.preventDefault();\n return;\n }\n if (active.current !== null) return;\n const element = event.currentTarget;\n const native = event.nativeEvent;\n // No focus move off the input, no touch keyboard, no text selection.\n event.preventDefault();\n pointerSeen.current = true;\n const pointerId = native.pointerId;\n try {\n element.setPointerCapture(pointerId);\n } catch {\n // An inactive pointer id (a synthetic event): the hold still follows the element.\n }\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const view = element.ownerDocument.defaultView;\n const detach = (): void => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n element.removeEventListener(\"pointerup\", onEnd);\n element.removeEventListener(\"pointercancel\", onEnd);\n element.removeEventListener(\"lostpointercapture\", onEnd);\n view?.removeEventListener(\"blur\", onBlur);\n if (active.current?.pointerId === pointerId) active.current = null;\n // A click that follows this release (same task, or a touch tap later) is ignored; an\n // activation without a pointer afterwards is not.\n setTimeout(() => {\n pointerSeen.current = false;\n }, 0);\n };\n function onEnd(endEvent: Event): void {\n if ((endEvent as PointerEvent).pointerId !== pointerId) return;\n detach();\n latest.current.ctx.endHold(direction, endEvent);\n }\n function onBlur(blurEvent: Event): void {\n detach();\n latest.current.ctx.endHold(direction, blurEvent);\n }\n const tick = (): void => {\n timer = setTimeout(() => {\n timer = undefined;\n if (latest.current.ctx.tickHold(direction, undefined)) tick();\n else detach();\n }, HOLD_INTERVAL);\n };\n\n if (!ctx.beginHold(direction, native)) {\n // The first step reached the bound: the hold already committed.\n detach();\n return;\n }\n element.addEventListener(\"pointerup\", onEnd);\n element.addEventListener(\"pointercancel\", onEnd);\n element.addEventListener(\"lostpointercapture\", onEnd);\n view?.addEventListener(\"blur\", onBlur);\n active.current = { pointerId, detach };\n timer = setTimeout(() => {\n timer = undefined;\n if (latest.current.ctx.tickHold(direction, undefined)) tick();\n else detach();\n }, HOLD_DELAY);\n };\n\n const onClick = (event: ReactMouseEvent<HTMLElement>): void => {\n // A disabled link or component render (`aria-disabled`) must not navigate either.\n if (disabled) event.preventDefault();\n if (pointerSeen.current || active.current !== null || event.detail !== 0) {\n pointerSeen.current = false;\n return;\n }\n if (disabled) return;\n ctx.activate(direction, event.nativeEvent);\n };\n\n const onContextMenu = (event: ReactMouseEvent<HTMLElement>): void => {\n // A touch long-press would open the context menu mid-hold.\n if (active.current !== null) event.preventDefault();\n };\n\n return { onPointerDown, onClick, onContextMenu };\n}\n\nexport interface NumberFieldButtonState {\n /** The Root is pending and the latest step or commit came from this button. */\n readonly pending: boolean;\n /** The prop, the Root's `disabled` or `readOnly`, or the next step would change nothing. */\n readonly disabled: boolean;\n}\n\nexport interface NumberFieldIncrementProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"type\"\n | \"tabIndex\"\n | \"disabled\"\n | \"onPointerDown\"\n | \"onClick\"\n | \"onContextMenu\"\n | \"aria-controls\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Never steps. Native `disabled` on a `<button>` (also at the bound and under `readOnly`); with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, NumberFieldButtonState>;\n style?: StateValue<CSSProperties | undefined, NumberFieldButtonState>;\n children?: StateValue<ReactNode, NumberFieldButtonState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>;\n}\n\nexport type NumberFieldDecrementProps = NumberFieldIncrementProps;\n\nconst LABELS: Record<StepDirection, string> = { increment: \"Increase\", decrement: \"Decrease\" };\n\n/** Shared by `NumberField.Increment` and `NumberField.Decrement` (design 3.3, 4.3). */\nexport function useStepButtonElement(\n direction: StepDirection,\n part: string,\n props: NumberFieldIncrementProps,\n): ReactNode {\n const { disabled: disabledProp = false, className, style, children, render, ...rest } = props;\n const ctx = useNumberFieldContext(part);\n const { state } = ctx;\n const atBound = isAtBound(ctx.stepBase, direction === \"increment\" ? 1 : -1, ctx.bounds);\n const disabled = disabledProp || state.disabled || state.readOnly || atBound;\n const pending = ctx.pendingSource === direction;\n const buttonState: NumberFieldButtonState = { pending, disabled };\n const handlers = useStepButton(ctx, direction, disabled);\n\n useDevWarning(\n rest[\"aria-label\"] === \"\",\n isDev &&\n `${part}: \\`aria-label=\"\"\\` leaves the button without a name. Pass the label text instead ` +\n `(the default is \"${LABELS[direction]}\").`,\n );\n\n // The built-in name is a default the consumer's `aria-label` or `aria-labelledby` replaces.\n const props$ = {\n ...(rest[\"aria-labelledby\"] === undefined ? { \"aria-label\": LABELS[direction] } : {}),\n ...rest,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>({\n defaultElement: \"button\",\n render,\n state: buttonState,\n className,\n style,\n children,\n props: props$,\n libraryProps: {\n ...(rendersButton(render) ? { type: \"button\" as const } : {}),\n tabIndex: -1,\n \"aria-controls\": ctx.inputId,\n // A link or component render: native `disabled` would mean nothing on a link; the press and\n // click handlers refuse, so `aria-disabled`. The at-bound case follows the same branch.\n ...disabledButton(render, disabled).props,\n onPointerDown: handlers.onPointerDown,\n onClick: handlers.onClick,\n onContextMenu: handlers.onContextMenu,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n } as Partial<ComponentPropsWithRef<\"button\">> & DataAttributes,\n });\n}\n"],"mappings":";;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAGvC,MAAM,aAAa;AACnB,MAAM,gBAAgB;;;;;;;;AAoBtB,SAAgB,cACd,KACA,WACA,UACoB;CACpB,MAAM,SAAS,OAA0B,IAAI;;CAE7C,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,SAAS,OAAO;EAAE;EAAK;CAAS,CAA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BAAuB,KAAA,IAAY,EAAE,cAAc,OAAO,WAAW,IAAI,CAAC;EACnF,GAAG;CACL;CAEA,OAAO,UAAmE;EACxE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAI,cAAc,MAAM,IAAI,EAAE,MAAM,SAAkB,IAAI,CAAC;GAC3D,UAAU;GACV,iBAAiB,IAAI;GAGrB,GAAG,eAAe,QAAQ,QAAQ,CAAC,CAAC;GACpC,eAAe,SAAS;GACxB,SAAS,SAAS;GAClB,eAAe,SAAS;GACxB,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-step-button.mjs","names":[],"sources":["../../src/number-field/use-step-button.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent as ReactMouseEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { disabledButton, rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { isAtBound } from \"./number-field-arithmetic.js\";\nimport { useNumberFieldContext } from \"./number-field-context.js\";\nimport type { NumberFieldContextValue, StepDirection } from \"./number-field-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** First repeat after the press, then the interval between repeats (Base UI, React Aria). */\nconst HOLD_DELAY = 400;\nconst HOLD_INTERVAL = 60;\n\ninterface ActiveHold {\n readonly pointerId: number;\n readonly detach: () => void;\n}\n\nexport interface StepButtonHandlers {\n readonly onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;\n readonly onClick: (event: ReactMouseEvent<HTMLElement>) => void;\n readonly onContextMenu: (event: ReactMouseEvent<HTMLElement>) => void;\n}\n\n/**\n * The press-and-hold of `NumberField.Increment` / `Decrement` (design 4.3): one step at\n * `pointerdown`, a repeat after 400 ms then every 60 ms, one commit at the release\n * (`pointerup`, `pointercancel`, `lostpointercapture`, or `blur` on the window). The press is\n * `preventDefault()`ed so focus stays where it is. A `click` with no pointer gesture before it\n * (assistive technology: `detail === 0`) is a one-step gesture.\n */\nexport function useStepButton(\n ctx: NumberFieldContextValue,\n direction: StepDirection,\n disabled: boolean,\n): StepButtonHandlers {\n const active = useRef<ActiveHold | null>(null);\n /** A pointer gesture started on this button; the click that follows it is not an activation. */\n const pointerSeen = useRef(false);\n const latest = useRef({ ctx, disabled });\n useEffect(() => {\n latest.current = { ctx, disabled };\n });\n\n // An unmount mid-hold leaves no timer or listener behind.\n useEffect(\n () => () => {\n active.current?.detach();\n active.current = null;\n },\n [],\n );\n\n const onPointerDown = (event: ReactPointerEvent<HTMLElement>): void => {\n if (event.button !== 0 || !event.isPrimary) return;\n if (disabled) {\n // A focusable disabled render (`aria-disabled`) must not take focus from the input\n // either; native `disabled` focused nothing.\n event.preventDefault();\n return;\n }\n if (active.current !== null) return;\n const element = event.currentTarget;\n const native = event.nativeEvent;\n // No focus move off the input, no touch keyboard, no text selection.\n event.preventDefault();\n pointerSeen.current = true;\n const pointerId = native.pointerId;\n try {\n element.setPointerCapture(pointerId);\n } catch {\n // An inactive pointer id (a synthetic event): the hold still follows the element.\n }\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const view = element.ownerDocument.defaultView;\n const detach = (): void => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n element.removeEventListener(\"pointerup\", onEnd);\n element.removeEventListener(\"pointercancel\", onEnd);\n element.removeEventListener(\"lostpointercapture\", onEnd);\n view?.removeEventListener(\"blur\", onBlur);\n if (active.current?.pointerId === pointerId) active.current = null;\n // A click that follows this release (same task, or a touch tap later) is ignored; an\n // activation without a pointer afterwards is not.\n setTimeout(() => {\n pointerSeen.current = false;\n }, 0);\n };\n function onEnd(endEvent: Event): void {\n if ((endEvent as PointerEvent).pointerId !== pointerId) return;\n detach();\n latest.current.ctx.endHold(direction, endEvent);\n }\n function onBlur(blurEvent: Event): void {\n detach();\n latest.current.ctx.endHold(direction, blurEvent);\n }\n const tick = (): void => {\n timer = setTimeout(() => {\n timer = undefined;\n if (latest.current.ctx.tickHold(direction, undefined)) tick();\n else detach();\n }, HOLD_INTERVAL);\n };\n\n if (!ctx.beginHold(direction, native)) {\n // The first step reached the bound: the hold already committed.\n detach();\n return;\n }\n element.addEventListener(\"pointerup\", onEnd);\n element.addEventListener(\"pointercancel\", onEnd);\n element.addEventListener(\"lostpointercapture\", onEnd);\n view?.addEventListener(\"blur\", onBlur);\n active.current = { pointerId, detach };\n timer = setTimeout(() => {\n timer = undefined;\n if (latest.current.ctx.tickHold(direction, undefined)) tick();\n else detach();\n }, HOLD_DELAY);\n };\n\n const onClick = (event: ReactMouseEvent<HTMLElement>): void => {\n // A disabled link or component render (`aria-disabled`) must not navigate either.\n if (disabled) event.preventDefault();\n if (pointerSeen.current || active.current !== null || event.detail !== 0) {\n pointerSeen.current = false;\n return;\n }\n if (disabled) return;\n ctx.activate(direction, event.nativeEvent);\n };\n\n const onContextMenu = (event: ReactMouseEvent<HTMLElement>): void => {\n // A touch long-press would open the context menu mid-hold.\n if (active.current !== null) event.preventDefault();\n };\n\n return { onPointerDown, onClick, onContextMenu };\n}\n\n/**\n * State of `NumberField.Increment`, `NumberField.Decrement`, passed to the function forms of\n * `className`, `style`, `children` and `render`.\n */\nexport interface NumberFieldButtonState {\n /** The Root is pending and the latest step or commit came from this button. */\n readonly pending: boolean;\n /** The prop, the Root's `disabled` or `readOnly`, or the next step would change nothing. */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `NumberField.Increment` (`NumberField.Decrement` takes the same props).\n *\n * @see https://ui.funstack.work/components/number-field\n */\nexport interface NumberFieldIncrementProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"type\"\n | \"tabIndex\"\n | \"disabled\"\n | \"onPointerDown\"\n | \"onClick\"\n | \"onContextMenu\"\n | \"aria-controls\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * Never steps. Native `disabled` on a `<button>` (also at the bound and under `readOnly`); with\n * a link or component `render`, `aria-disabled=\"true\"` instead.\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, NumberFieldButtonState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, NumberFieldButtonState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, NumberFieldButtonState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>;\n}\n\n/**\n * Props of `NumberField.Decrement`: the same as `NumberFieldIncrementProps`.\n *\n * @see https://ui.funstack.work/components/number-field\n */\nexport type NumberFieldDecrementProps = NumberFieldIncrementProps;\n\nconst LABELS: Record<StepDirection, string> = { increment: \"Increase\", decrement: \"Decrease\" };\n\n/** Shared by `NumberField.Increment` and `NumberField.Decrement` (design 3.3, 4.3). */\nexport function useStepButtonElement(\n direction: StepDirection,\n part: string,\n props: NumberFieldIncrementProps,\n): ReactNode {\n const { disabled: disabledProp = false, className, style, children, render, ...rest } = props;\n const ctx = useNumberFieldContext(part);\n const { state } = ctx;\n const atBound = isAtBound(ctx.stepBase, direction === \"increment\" ? 1 : -1, ctx.bounds);\n const disabled = disabledProp || state.disabled || state.readOnly || atBound;\n const pending = ctx.pendingSource === direction;\n const buttonState: NumberFieldButtonState = { pending, disabled };\n const handlers = useStepButton(ctx, direction, disabled);\n\n useDevWarning(\n rest[\"aria-label\"] === \"\",\n isDev &&\n `${part}: \\`aria-label=\"\"\\` leaves the button without a name. Pass the label text instead ` +\n `(the default is \"${LABELS[direction]}\").`,\n );\n\n // The built-in name is a default the consumer's `aria-label` or `aria-labelledby` replaces.\n const props$ = {\n ...(rest[\"aria-labelledby\"] === undefined ? { \"aria-label\": LABELS[direction] } : {}),\n ...rest,\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, NumberFieldButtonState>({\n defaultElement: \"button\",\n render,\n state: buttonState,\n className,\n style,\n children,\n props: props$,\n libraryProps: {\n ...(rendersButton(render) ? { type: \"button\" as const } : {}),\n tabIndex: -1,\n \"aria-controls\": ctx.inputId,\n // A link or component render: native `disabled` would mean nothing on a link; the press and\n // click handlers refuse, so `aria-disabled`. The at-bound case follows the same branch.\n ...disabledButton(render, disabled).props,\n onPointerDown: handlers.onPointerDown,\n onClick: handlers.onClick,\n onContextMenu: handlers.onContextMenu,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n } as Partial<ComponentPropsWithRef<\"button\">> & DataAttributes,\n });\n}\n"],"mappings":";;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAGvC,MAAM,aAAa;AACnB,MAAM,gBAAgB;;;;;;;;AAoBtB,SAAgB,cACd,KACA,WACA,UACoB;CACpB,MAAM,SAAS,OAA0B,IAAI;;CAE7C,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,SAAS,OAAO;EAAE;EAAK;CAAS,CAAC;CACvC,gBAAgB;EACd,OAAO,UAAU;GAAE;GAAK;EAAS;CACnC,CAAC;CAGD,sBACc;EACV,OAAO,SAAS,OAAO;EACvB,OAAO,UAAU;CACnB,GACA,CAAC,CACH;CAEA,MAAM,iBAAiB,UAAgD;EACrE,IAAI,MAAM,WAAW,KAAK,CAAC,MAAM,WAAW;EAC5C,IAAI,UAAU;GAGZ,MAAM,eAAe;GACrB;EACF;EACA,IAAI,OAAO,YAAY,MAAM;EAC7B,MAAM,UAAU,MAAM;EACtB,MAAM,SAAS,MAAM;EAErB,MAAM,eAAe;EACrB,YAAY,UAAU;EACtB,MAAM,YAAY,OAAO;EACzB,IAAI;GACF,QAAQ,kBAAkB,SAAS;EACrC,QAAQ,CAER;EAEA,IAAI;EAC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Props, PopoverTriggerState } from "./popo
11
11
  * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
12
12
  * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,
13
13
  * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /
14
- * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are
15
- * transitions (pending Trigger, content from committed state), and dismissals are notified
16
- * through `openChangeAction(false)`.
14
+ * `defaultOpen` / `openChangeAction` / `onOpenChange`; otherwise opening and the closes a part
15
+ * asks for are requests, transitions (pending Trigger, content from committed state), and
16
+ * dismissals are facts, reported to `onOpenChange(false)`.
17
+ *
18
+ * @see https://ui.funstack.work/components/popover
17
19
  */
18
20
  export declare const Popover: {
19
21
  readonly Root: typeof PopoverRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/popover/index.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAmBa;WACX,aAAI;WACJ,gBAAO;WACP,cAAK;WACL,cAAK;WACL,cAAK;WACL,oBAAW"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/popover/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAqBa;WACX,aAAI;WACJ,gBAAO;WACP,cAAK;WACL,cAAK;WACL,cAAK;WACL,oBAAW"}
@@ -10,9 +10,11 @@ import { PopoverTrigger } from "./popover-trigger.mjs";
10
10
  * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >
11
11
  * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,
12
12
  * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /
13
- * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are
14
- * transitions (pending Trigger, content from committed state), and dismissals are notified
15
- * through `openChangeAction(false)`.
13
+ * `defaultOpen` / `openChangeAction` / `onOpenChange`; otherwise opening and the closes a part
14
+ * asks for are requests, transitions (pending Trigger, content from committed state), and
15
+ * dismissals are facts, reported to `onOpenChange(false)`.
16
+ *
17
+ * @see https://ui.funstack.work/components/popover
16
18
  */
17
19
  const Popover = {
18
20
  Root: PopoverRoot,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/popover/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { PopoverClose } from \"./popover-close.js\";\nimport { PopoverDescription } from \"./popover-description.js\";\nimport { PopoverPopup } from \"./popover-popup.js\";\nimport { PopoverRoot } from \"./popover-root.js\";\nimport { PopoverTitle } from \"./popover-title.js\";\nimport { PopoverTrigger } from \"./popover-trigger.js\";\n\n/**\n * Popover built on `popover=\"auto\"` and Invoker Commands: `Root` (no DOM) > `Trigger`\n * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >\n * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,\n * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /\n * `defaultOpen` / `openChangeAction`; otherwise opening and the closes a part asks for are\n * transitions (pending Trigger, content from committed state), and dismissals are notified\n * through `openChangeAction(false)`.\n */\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Popup: PopoverPopup,\n Close: PopoverClose,\n Title: PopoverTitle,\n Description: PopoverDescription,\n} as const;\n\nexport type {\n PopoverRootProps,\n PopoverRootState,\n PopoverOpenChangeDetails,\n} from \"./popover-root.js\";\nexport type { PopoverTriggerProps, PopoverTriggerState } from \"./popover-trigger.js\";\nexport type {\n PopoverPopupProps,\n PopoverPopupState,\n PopoverSide,\n PopoverAlign,\n} from \"./popover-popup.js\";\nexport type { PopoverCloseProps, PopoverCloseState } from \"./popover-close.js\";\nexport type { PopoverTitleProps, PopoverTitleState } from \"./popover-title.js\";\nexport type { PopoverDescriptionProps, PopoverDescriptionState } from \"./popover-description.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,OAAO;CACP,aAAa;AACf"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/popover/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { PopoverClose } from \"./popover-close.js\";\nimport { PopoverDescription } from \"./popover-description.js\";\nimport { PopoverPopup } from \"./popover-popup.js\";\nimport { PopoverRoot } from \"./popover-root.js\";\nimport { PopoverTitle } from \"./popover-title.js\";\nimport { PopoverTrigger } from \"./popover-trigger.js\";\n\n/**\n * Popover built on `popover=\"auto\"` and Invoker Commands: `Root` (no DOM) > `Trigger`\n * (`button[popovertarget]`) + `Popup` (`dialog[popover=auto][aria-modal=false]`) >\n * `Title`, `Description`, `Close`. The platform gives the top layer, light dismiss, Escape,\n * nesting, the implicit anchor and focus return. JS-free when the Root has none of `open` /\n * `defaultOpen` / `openChangeAction` / `onOpenChange`; otherwise opening and the closes a part\n * asks for are requests, transitions (pending Trigger, content from committed state), and\n * dismissals are facts, reported to `onOpenChange(false)`.\n *\n * @see https://ui.funstack.work/components/popover\n */\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Popup: PopoverPopup,\n Close: PopoverClose,\n Title: PopoverTitle,\n Description: PopoverDescription,\n} as const;\n\nexport type {\n PopoverRootProps,\n PopoverRootState,\n PopoverOpenChangeDetails,\n} from \"./popover-root.js\";\nexport type { PopoverTriggerProps, PopoverTriggerState } from \"./popover-trigger.js\";\nexport type {\n PopoverPopupProps,\n PopoverPopupState,\n PopoverSide,\n PopoverAlign,\n} from \"./popover-popup.js\";\nexport type { PopoverCloseProps, PopoverCloseState } from \"./popover-close.js\";\nexport type { PopoverTitleProps, PopoverTitleState } from \"./popover-title.js\";\nexport type { PopoverDescriptionProps, PopoverDescriptionState } from \"./popover-description.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,OAAO;CACP,aAAa;AACf"}
@@ -1,11 +1,21 @@
1
- import { Action, ActionDetails, RenderProp, StateValue } from "../internal/types.mjs";
1
+ import { Action, ActionDetails, RenderProp, StateValue, WhilePending } from "../internal/types.mjs";
2
2
  import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
3
3
  //#region src/popover/popover-close.d.ts
4
+ /**
5
+ * State of `Popover.Close`, passed to the function forms of `className`, `style`, `children` and
6
+ * `render`.
7
+ */
4
8
  export interface PopoverCloseState {
5
9
  /** The `action` is in flight. */
6
10
  readonly pending: boolean;
11
+ /** The `disabled` prop. */
7
12
  readonly disabled: boolean;
8
13
  }
14
+ /**
15
+ * Props of `Popover.Close`.
16
+ *
17
+ * @see https://ui.funstack.work/components/popover
18
+ */
9
19
  export interface PopoverCloseProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "className" | "style" | "children"> {
10
20
  /**
11
21
  * Runs inside this part's own transition (`data-pending` on the button), then closes the
@@ -16,15 +26,31 @@ export interface PopoverCloseProps extends Omit<ComponentPropsWithRef<"button">,
16
26
  * JS-free mode the button is a native `command="hide-popover"` invoker.
17
27
  */
18
28
  action?: Action<[details: ActionDetails]>;
29
+ /**
30
+ * What a click does while this part's `action` is pending. `"ignore"`: nothing (the click is
31
+ * cancelled, `aria-disabled="true"` meanwhile). `"run"`: the action runs again (`data-pending`
32
+ * until every run has settled); the popover closes once, when the last run settles and only
33
+ * if the latest run resolved (a rejection leaves it open, as in `"ignore"` mode). No effect
34
+ * without `action`.
35
+ *
36
+ * @defaultValue `"ignore"`
37
+ */
38
+ whilePending?: WhilePending;
19
39
  /**
20
40
  * Never closes. Native `disabled` on a `<button>`; owned, so a `render` element cannot
21
41
  * re-enable it. With a link or component `render` whose click this part handles (library mode,
22
42
  * or with `action`), `aria-disabled="true"` instead: the element stays focusable.
43
+ *
44
+ * @defaultValue `false`
23
45
  */
24
46
  disabled?: boolean;
47
+ /** Class name, or a function of the part's state that returns one. */
25
48
  className?: StateValue<string | undefined, PopoverCloseState>;
49
+ /** Inline style, or a function of the part's state that returns one. */
26
50
  style?: StateValue<CSSProperties | undefined, PopoverCloseState>;
51
+ /** Content, or a function of the part's state. */
27
52
  children?: StateValue<ReactNode, PopoverCloseState>;
53
+ /** Replace the default `<button>` (element form) or take over rendering (function form). */
28
54
  render?: RenderProp<ComponentPropsWithRef<"button">, PopoverCloseState>;
29
55
  }
30
56
  /**
@@ -32,7 +58,8 @@ export interface PopoverCloseProps extends Omit<ComponentPropsWithRef<"button">,
32
58
  * without `action` the browser hides the popover. In library mode the click is always cancelled
33
59
  * and the close goes through the Root (`openChangeAction(false)` awaited, `hidePopover()` in the
34
60
  * commit). With `action` the action runs first in this part's own transition (`data-pending` on
35
- * the button, with `aria-disabled`; a second click meanwhile is ignored); a rejection leaves the
61
+ * the button, with `aria-disabled`; a second click meanwhile is ignored unless
62
+ * `whilePending="run"`); a rejection leaves the
36
63
  * popover open. It keeps `commandfor` where the Trigger has `popovertarget`: an invoker
37
64
  * inside its own popover exposes no state either way, and the `command` event tells the Popup a
38
65
  * foreign hide's reason.
@@ -40,8 +67,10 @@ export interface PopoverCloseProps extends Omit<ComponentPropsWithRef<"button">,
40
67
  * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,
41
68
  * `command`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,
42
69
  * `data-disabled`.
70
+ *
71
+ * @see https://ui.funstack.work/components/popover
43
72
  */
44
- export declare function PopoverClose({ action, disabled, className, style, children, render, ...rest }: PopoverCloseProps): ReactNode;
73
+ export declare function PopoverClose({ action, whilePending, disabled, className, style, children, render, ...rest }: PopoverCloseProps): ReactNode;
45
74
  export declare namespace PopoverClose {
46
75
  var displayName: string;
47
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"popover-close.d.mts","names":[],"sources":["../../src/popover/popover-close.tsx"],"mappings":";;;iBAQiB;;WAEN;WACA;;iBAGM,0BAA0B,KACzC;;;;;;;;;EAWA,SAAS,QAAQ,SAAS;;;;;;EAM1B;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;wBAiBvC,eACd,QACA,UACA,WACA,OACA,UACA,WACG,QACF,oBAAiB;yBARJ"}
1
+ {"version":3,"file":"popover-close.d.mts","names":[],"sources":["../../src/popover/popover-close.tsx"],"mappings":";;;;;;;iBAkBiB;;WAEN;;WAEA;;;;;;;iBAQM,0BAA0B,KACzC;;;;;;;;;EAWA,SAAS,QAAQ,SAAS;;;;;;;;;;EAU1B,eAAe;;;;;;;;EAQf;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;;;;wBAoBvC,eACd,QACA,cACA,UACA,WACA,OACA,UACA,WACG,QACF,oBAAiB;yBATJ"}