@ariakit/react-components 0.1.1 → 0.1.2

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 (500) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/button/button.d.ts +1 -1
  3. package/dist/{button-Cp853csH.d.ts → button-CVWcOgxs.d.ts} +3 -3
  4. package/dist/{button-Cp853csH.d.ts.map → button-CVWcOgxs.d.ts.map} +1 -1
  5. package/dist/checkbox/checkbox-check.d.ts +1 -1
  6. package/dist/checkbox/checkbox-check.d.ts.map +1 -1
  7. package/dist/checkbox/checkbox.d.ts +2 -2
  8. package/dist/checkbox/checkbox.d.ts.map +1 -1
  9. package/dist/collection/collection-item-offscreen.d.ts +1 -1
  10. package/dist/collection/collection-item-offscreen.js +1 -1
  11. package/dist/collection/collection-item-offscreen.js.map +1 -1
  12. package/dist/collection/collection-item.d.ts +1 -1
  13. package/dist/collection/collection-renderer.d.ts +1 -1
  14. package/dist/collection/collection-renderer.js +1 -1
  15. package/dist/collection/collection-renderer.js.map +1 -1
  16. package/dist/collection/collection.d.ts +1 -1
  17. package/dist/collection/collection.d.ts.map +1 -1
  18. package/dist/{collection-item-offscreen-DyXa-sqj.d.ts → collection-item-offscreen-B5E5vNFi.d.ts} +2 -2
  19. package/dist/{collection-item-offscreen-DyXa-sqj.d.ts.map → collection-item-offscreen-B5E5vNFi.d.ts.map} +1 -1
  20. package/dist/{collection-item-C-g2BwVF.d.ts → collection-item-pvEWNoNs.d.ts} +2 -2
  21. package/dist/{collection-item-C-g2BwVF.d.ts.map → collection-item-pvEWNoNs.d.ts.map} +1 -1
  22. package/dist/{collection-renderer-DsPD9ksD.d.ts → collection-renderer-BhzF21Du.d.ts} +29 -15
  23. package/dist/collection-renderer-BhzF21Du.d.ts.map +1 -0
  24. package/dist/combobox/combobox-cancel.d.ts +2 -2
  25. package/dist/combobox/combobox-cancel.d.ts.map +1 -1
  26. package/dist/combobox/combobox-cancel.js +1 -1
  27. package/dist/combobox/combobox-cancel.js.map +1 -1
  28. package/dist/combobox/combobox-disclosure.d.ts +2 -2
  29. package/dist/combobox/combobox-disclosure.d.ts.map +1 -1
  30. package/dist/combobox/combobox-disclosure.js +1 -1
  31. package/dist/combobox/combobox-disclosure.js.map +1 -1
  32. package/dist/combobox/combobox-group-label.d.ts +1 -1
  33. package/dist/combobox/combobox-group-label.d.ts.map +1 -1
  34. package/dist/combobox/combobox-group.d.ts +1 -1
  35. package/dist/combobox/combobox-group.d.ts.map +1 -1
  36. package/dist/combobox/combobox-group.js +1 -1
  37. package/dist/combobox/combobox-group.js.map +1 -1
  38. package/dist/combobox/combobox-item-check.d.ts +1 -1
  39. package/dist/combobox/combobox-item-check.d.ts.map +1 -1
  40. package/dist/combobox/combobox-item-value.d.ts +1 -1
  41. package/dist/combobox/combobox-item-value.d.ts.map +1 -1
  42. package/dist/combobox/combobox-item.d.ts +3 -3
  43. package/dist/combobox/combobox-item.d.ts.map +1 -1
  44. package/dist/combobox/combobox-item.js +1 -1
  45. package/dist/combobox/combobox-item.js.map +1 -1
  46. package/dist/combobox/combobox-label.d.ts +1 -1
  47. package/dist/combobox/combobox-label.d.ts.map +1 -1
  48. package/dist/combobox/combobox-label.js +1 -1
  49. package/dist/combobox/combobox-label.js.map +1 -1
  50. package/dist/combobox/combobox-list.d.ts +1 -1
  51. package/dist/combobox/combobox-list.d.ts.map +1 -1
  52. package/dist/combobox/combobox-list.js +1 -1
  53. package/dist/combobox/combobox-list.js.map +1 -1
  54. package/dist/combobox/combobox-popover.d.ts +1 -1
  55. package/dist/combobox/combobox-popover.js +1 -1
  56. package/dist/combobox/combobox-popover.js.map +1 -1
  57. package/dist/combobox/combobox-row.d.ts +1 -1
  58. package/dist/combobox/combobox-row.d.ts.map +1 -1
  59. package/dist/combobox/combobox-row.js +1 -1
  60. package/dist/combobox/combobox-row.js.map +1 -1
  61. package/dist/combobox/combobox-separator.d.ts +1 -1
  62. package/dist/combobox/combobox-separator.d.ts.map +1 -1
  63. package/dist/combobox/combobox-separator.js +1 -1
  64. package/dist/combobox/combobox-separator.js.map +1 -1
  65. package/dist/combobox/combobox-value.js +1 -1
  66. package/dist/combobox/combobox-value.js.map +1 -1
  67. package/dist/combobox/combobox.d.ts +3 -3
  68. package/dist/combobox/combobox.d.ts.map +1 -1
  69. package/dist/combobox/combobox.js +16 -2
  70. package/dist/combobox/combobox.js.map +1 -1
  71. package/dist/command/command.d.ts +1 -1
  72. package/dist/{command-DckndCUK.d.ts → command-B9C8p3_S.d.ts} +3 -3
  73. package/dist/{command-DckndCUK.d.ts.map → command-B9C8p3_S.d.ts.map} +1 -1
  74. package/dist/composite/composite-container.d.ts +1 -1
  75. package/dist/composite/composite-container.d.ts.map +1 -1
  76. package/dist/composite/composite-container.js +2 -2
  77. package/dist/composite/composite-container.js.map +1 -1
  78. package/dist/composite/composite-group-label.d.ts +2 -2
  79. package/dist/composite/composite-group-label.d.ts.map +1 -1
  80. package/dist/composite/composite-group.d.ts +2 -2
  81. package/dist/composite/composite-group.d.ts.map +1 -1
  82. package/dist/composite/composite-hover.d.ts +1 -1
  83. package/dist/composite/composite-hover.js +9 -13
  84. package/dist/composite/composite-hover.js.map +1 -1
  85. package/dist/composite/composite-input.d.ts +1 -1
  86. package/dist/composite/composite-input.d.ts.map +1 -1
  87. package/dist/composite/composite-input.js +1 -1
  88. package/dist/composite/composite-input.js.map +1 -1
  89. package/dist/composite/composite-item-offscreen.d.ts +2 -2
  90. package/dist/composite/composite-item-offscreen.js +2 -2
  91. package/dist/composite/composite-item-offscreen.js.map +1 -1
  92. package/dist/composite/composite-item.d.ts +1 -1
  93. package/dist/composite/composite-item.js +2 -2
  94. package/dist/composite/composite-item.js.map +1 -1
  95. package/dist/composite/composite-overflow-disclosure.d.ts +2 -2
  96. package/dist/composite/composite-overflow-disclosure.d.ts.map +1 -1
  97. package/dist/composite/composite-overflow.d.ts +2 -2
  98. package/dist/composite/composite-overflow.d.ts.map +1 -1
  99. package/dist/composite/composite-renderer.d.ts +28 -14
  100. package/dist/composite/composite-renderer.d.ts.map +1 -1
  101. package/dist/composite/composite-renderer.js +2 -2
  102. package/dist/composite/composite-renderer.js.map +1 -1
  103. package/dist/composite/composite-row.d.ts +1 -1
  104. package/dist/composite/composite-row.d.ts.map +1 -1
  105. package/dist/composite/composite-row.js +3 -3
  106. package/dist/composite/composite-row.js.map +1 -1
  107. package/dist/composite/composite-separator.d.ts +2 -2
  108. package/dist/composite/composite-separator.d.ts.map +1 -1
  109. package/dist/composite/composite-separator.js +3 -3
  110. package/dist/composite/composite-separator.js.map +1 -1
  111. package/dist/composite/composite-typeahead.d.ts +1 -1
  112. package/dist/composite/composite-typeahead.js +3 -3
  113. package/dist/composite/composite-typeahead.js.map +1 -1
  114. package/dist/composite/composite.d.ts +1 -1
  115. package/dist/composite/composite.js +3 -3
  116. package/dist/composite/composite.js.map +1 -1
  117. package/dist/{composite-DLvyFHMq.d.ts → composite-KBhCGLEy.d.ts} +3 -3
  118. package/dist/{composite-DLvyFHMq.d.ts.map → composite-KBhCGLEy.d.ts.map} +1 -1
  119. package/dist/{composite-hover-C7ul163w.d.ts → composite-hover-BpXq3T8J.d.ts} +2 -2
  120. package/dist/{composite-hover-C7ul163w.d.ts.map → composite-hover-BpXq3T8J.d.ts.map} +1 -1
  121. package/dist/{composite-item-B4WTelVz.d.ts → composite-item-d4UXaZ84.d.ts} +4 -4
  122. package/dist/{composite-item-B4WTelVz.d.ts.map → composite-item-d4UXaZ84.d.ts.map} +1 -1
  123. package/dist/{composite-typeahead-DDhpyKqm.d.ts → composite-typeahead-0euW43GU.d.ts} +2 -2
  124. package/dist/{composite-typeahead-DDhpyKqm.d.ts.map → composite-typeahead-0euW43GU.d.ts.map} +1 -1
  125. package/dist/dialog/dialog-backdrop.d.ts +1 -1
  126. package/dist/dialog/dialog-description.d.ts +1 -1
  127. package/dist/dialog/dialog-disclosure.d.ts +1 -1
  128. package/dist/dialog/dialog-disclosure.js +1 -1
  129. package/dist/dialog/dialog-disclosure.js.map +1 -1
  130. package/dist/dialog/dialog-dismiss.d.ts +1 -1
  131. package/dist/dialog/dialog-heading.d.ts +1 -1
  132. package/dist/dialog/dialog.d.ts +1 -1
  133. package/dist/dialog/dialog.js +18 -6
  134. package/dist/dialog/dialog.js.map +1 -1
  135. package/dist/dialog/utils/disable-accessibility-tree-outside.d.ts +1 -3
  136. package/dist/dialog/utils/disable-accessibility-tree-outside.d.ts.map +1 -1
  137. package/dist/dialog/utils/disable-accessibility-tree-outside.js +1 -15
  138. package/dist/dialog/utils/disable-accessibility-tree-outside.js.map +1 -1
  139. package/dist/dialog/utils/use-hide-on-interact-outside.d.ts +1 -1
  140. package/dist/dialog/utils/use-hide-on-interact-outside.js +2 -2
  141. package/dist/dialog/utils/use-hide-on-interact-outside.js.map +1 -1
  142. package/dist/dialog/utils/use-prevent-body-scroll.js +2 -1
  143. package/dist/dialog/utils/use-prevent-body-scroll.js.map +1 -1
  144. package/dist/dialog/utils/use-previous-mouse-down-ref.d.ts +1 -1
  145. package/dist/dialog/utils/use-previous-mouse-down-ref.d.ts.map +1 -1
  146. package/dist/{dialog-C__C-zX2.d.ts → dialog-D23r2ZWj.d.ts} +4 -4
  147. package/dist/{dialog-C__C-zX2.d.ts.map → dialog-D23r2ZWj.d.ts.map} +1 -1
  148. package/dist/{dialog-description-BCZJ1Kyd.d.ts → dialog-description-CJGxnEvk.d.ts} +2 -2
  149. package/dist/{dialog-description-BCZJ1Kyd.d.ts.map → dialog-description-CJGxnEvk.d.ts.map} +1 -1
  150. package/dist/{dialog-disclosure-DLD10zlb.d.ts → dialog-disclosure-DSESk5pv.d.ts} +3 -3
  151. package/dist/{dialog-disclosure-DLD10zlb.d.ts.map → dialog-disclosure-DSESk5pv.d.ts.map} +1 -1
  152. package/dist/{dialog-dismiss-CnwEbzc6.d.ts → dialog-dismiss-DW3XQYvp.d.ts} +3 -3
  153. package/dist/{dialog-dismiss-CnwEbzc6.d.ts.map → dialog-dismiss-DW3XQYvp.d.ts.map} +1 -1
  154. package/dist/{dialog-heading-DQvnOfZH.d.ts → dialog-heading-DGA5d8VH.d.ts} +3 -3
  155. package/dist/{dialog-heading-DQvnOfZH.d.ts.map → dialog-heading-DGA5d8VH.d.ts.map} +1 -1
  156. package/dist/disclosure/disclosure-content.js +1 -1
  157. package/dist/disclosure/disclosure-content.js.map +1 -1
  158. package/dist/disclosure/disclosure.d.ts +1 -1
  159. package/dist/disclosure/disclosure.js +1 -1
  160. package/dist/disclosure/disclosure.js.map +1 -1
  161. package/dist/{disclosure-CQ37hPVP.d.ts → disclosure-C4F4sCVZ.d.ts} +3 -3
  162. package/dist/{disclosure-CQ37hPVP.d.ts.map → disclosure-C4F4sCVZ.d.ts.map} +1 -1
  163. package/dist/focus-trap/focus-trap-region.d.ts +1 -1
  164. package/dist/focus-trap/focus-trap-region.d.ts.map +1 -1
  165. package/dist/focus-trap/focus-trap.d.ts +1 -1
  166. package/dist/focus-trap/focus-trap.d.ts.map +1 -1
  167. package/dist/focusable/focusable-container.d.ts +1 -1
  168. package/dist/focusable/focusable-container.d.ts.map +1 -1
  169. package/dist/focusable/focusable.d.ts +1 -1
  170. package/dist/focusable/focusable.js +49 -8
  171. package/dist/focusable/focusable.js.map +1 -1
  172. package/dist/{focusable-B00tOxtB.d.ts → focusable-dBZH13-T.d.ts} +2 -2
  173. package/dist/{focusable-B00tOxtB.d.ts.map → focusable-dBZH13-T.d.ts.map} +1 -1
  174. package/dist/form/form-checkbox.d.ts +1 -1
  175. package/dist/form/form-checkbox.d.ts.map +1 -1
  176. package/dist/form/form-checkbox.js +1 -1
  177. package/dist/form/form-checkbox.js.map +1 -1
  178. package/dist/form/form-control.d.ts +2 -2
  179. package/dist/form/form-control.d.ts.map +1 -1
  180. package/dist/form/form-control.js +1 -1
  181. package/dist/form/form-control.js.map +1 -1
  182. package/dist/form/form-description.d.ts +2 -2
  183. package/dist/form/form-description.d.ts.map +1 -1
  184. package/dist/form/form-description.js +1 -1
  185. package/dist/form/form-description.js.map +1 -1
  186. package/dist/form/form-error.d.ts +2 -2
  187. package/dist/form/form-error.d.ts.map +1 -1
  188. package/dist/form/form-error.js +1 -1
  189. package/dist/form/form-error.js.map +1 -1
  190. package/dist/form/form-field.d.ts +1 -1
  191. package/dist/form/form-field.d.ts.map +1 -1
  192. package/dist/form/form-group-label.d.ts +2 -2
  193. package/dist/form/form-group-label.d.ts.map +1 -1
  194. package/dist/form/form-group.d.ts +2 -2
  195. package/dist/form/form-group.d.ts.map +1 -1
  196. package/dist/form/form-input.d.ts +2 -2
  197. package/dist/form/form-input.d.ts.map +1 -1
  198. package/dist/form/form-input.js +1 -1
  199. package/dist/form/form-input.js.map +1 -1
  200. package/dist/form/form-label.d.ts +2 -2
  201. package/dist/form/form-label.d.ts.map +1 -1
  202. package/dist/form/form-label.js +1 -1
  203. package/dist/form/form-label.js.map +1 -1
  204. package/dist/form/form-push.d.ts +3 -3
  205. package/dist/form/form-push.d.ts.map +1 -1
  206. package/dist/form/form-push.js +1 -1
  207. package/dist/form/form-push.js.map +1 -1
  208. package/dist/form/form-radio-group.d.ts +1 -1
  209. package/dist/form/form-radio-group.d.ts.map +1 -1
  210. package/dist/form/form-radio.d.ts +1 -1
  211. package/dist/form/form-radio.d.ts.map +1 -1
  212. package/dist/form/form-radio.js +1 -1
  213. package/dist/form/form-radio.js.map +1 -1
  214. package/dist/form/form-remove.d.ts +16 -12
  215. package/dist/form/form-remove.d.ts.map +1 -1
  216. package/dist/form/form-remove.js +15 -11
  217. package/dist/form/form-remove.js.map +1 -1
  218. package/dist/form/form-reset.d.ts +2 -2
  219. package/dist/form/form-reset.d.ts.map +1 -1
  220. package/dist/form/form-reset.js +1 -1
  221. package/dist/form/form-reset.js.map +1 -1
  222. package/dist/form/form-submit.d.ts +2 -2
  223. package/dist/form/form-submit.d.ts.map +1 -1
  224. package/dist/form/form-submit.js +1 -1
  225. package/dist/form/form-submit.js.map +1 -1
  226. package/dist/form/form.d.ts +1 -1
  227. package/dist/form/form.d.ts.map +1 -1
  228. package/dist/form/form.js +1 -1
  229. package/dist/form/form.js.map +1 -1
  230. package/dist/group/group-label.d.ts +1 -1
  231. package/dist/group/group.d.ts +1 -1
  232. package/dist/{group-label-C16IDs1b.d.ts → group-label-BKYqD4Sj.d.ts} +2 -2
  233. package/dist/{group-label-C16IDs1b.d.ts.map → group-label-BKYqD4Sj.d.ts.map} +1 -1
  234. package/dist/{group-CamegDJA.d.ts → group-nGD9e6Dj.d.ts} +2 -2
  235. package/dist/{group-CamegDJA.d.ts.map → group-nGD9e6Dj.d.ts.map} +1 -1
  236. package/dist/heading/heading.d.ts +1 -1
  237. package/dist/heading/heading.js +2 -2
  238. package/dist/heading/heading.js.map +1 -1
  239. package/dist/{heading-zY9g_9K-.d.ts → heading-D_AmeqL5.d.ts} +2 -2
  240. package/dist/{heading-zY9g_9K-.d.ts.map → heading-D_AmeqL5.d.ts.map} +1 -1
  241. package/dist/hovercard/hovercard-anchor.d.ts +2 -2
  242. package/dist/hovercard/hovercard-anchor.d.ts.map +1 -1
  243. package/dist/hovercard/hovercard-anchor.js +1 -1
  244. package/dist/hovercard/hovercard-anchor.js.map +1 -1
  245. package/dist/hovercard/hovercard-arrow.d.ts +1 -1
  246. package/dist/hovercard/hovercard-arrow.d.ts.map +1 -1
  247. package/dist/hovercard/hovercard-description.d.ts +2 -2
  248. package/dist/hovercard/hovercard-description.d.ts.map +1 -1
  249. package/dist/hovercard/hovercard-disclosure.d.ts +2 -2
  250. package/dist/hovercard/hovercard-disclosure.d.ts.map +1 -1
  251. package/dist/hovercard/hovercard-disclosure.js +4 -4
  252. package/dist/hovercard/hovercard-disclosure.js.map +1 -1
  253. package/dist/hovercard/hovercard-dismiss.d.ts +2 -2
  254. package/dist/hovercard/hovercard-dismiss.d.ts.map +1 -1
  255. package/dist/hovercard/hovercard-heading.d.ts +2 -2
  256. package/dist/hovercard/hovercard-heading.d.ts.map +1 -1
  257. package/dist/hovercard/hovercard.d.ts +1 -1
  258. package/dist/hovercard/hovercard.js +2 -2
  259. package/dist/hovercard/hovercard.js.map +1 -1
  260. package/dist/menu/menu-arrow.d.ts +2 -2
  261. package/dist/menu/menu-arrow.d.ts.map +1 -1
  262. package/dist/menu/menu-bar-provider.js +1 -1
  263. package/dist/menu/menu-bar-provider.js.map +1 -1
  264. package/dist/menu/menu-bar-store.d.ts +3 -3
  265. package/dist/menu/menu-bar-store.js +3 -3
  266. package/dist/menu/menu-bar-store.js.map +1 -1
  267. package/dist/menu/menu-bar.d.ts +1 -1
  268. package/dist/menu/menu-bar.d.ts.map +1 -1
  269. package/dist/menu/menu-bar.js +1 -1
  270. package/dist/menu/menu-bar.js.map +1 -1
  271. package/dist/menu/menu-button-arrow.d.ts +2 -2
  272. package/dist/menu/menu-button-arrow.d.ts.map +1 -1
  273. package/dist/menu/menu-button.d.ts +3 -3
  274. package/dist/menu/menu-button.d.ts.map +1 -1
  275. package/dist/menu/menu-button.js +1 -1
  276. package/dist/menu/menu-button.js.map +1 -1
  277. package/dist/menu/menu-context.d.ts +10 -3
  278. package/dist/menu/menu-context.d.ts.map +1 -1
  279. package/dist/menu/menu-context.js +8 -1
  280. package/dist/menu/menu-context.js.map +1 -1
  281. package/dist/menu/menu-description.d.ts +2 -2
  282. package/dist/menu/menu-description.d.ts.map +1 -1
  283. package/dist/menu/menu-dismiss.d.ts +2 -2
  284. package/dist/menu/menu-dismiss.d.ts.map +1 -1
  285. package/dist/menu/menu-group-label.d.ts +2 -2
  286. package/dist/menu/menu-group-label.d.ts.map +1 -1
  287. package/dist/menu/menu-group.d.ts +2 -2
  288. package/dist/menu/menu-group.d.ts.map +1 -1
  289. package/dist/menu/menu-heading.d.ts +2 -2
  290. package/dist/menu/menu-heading.d.ts.map +1 -1
  291. package/dist/menu/menu-item-check.d.ts +2 -2
  292. package/dist/menu/menu-item-check.d.ts.map +1 -1
  293. package/dist/menu/menu-item-checkbox.d.ts +2 -2
  294. package/dist/menu/menu-item-checkbox.d.ts.map +1 -1
  295. package/dist/menu/menu-item-checkbox.js +1 -1
  296. package/dist/menu/menu-item-checkbox.js.map +1 -1
  297. package/dist/menu/menu-item-radio.d.ts +2 -2
  298. package/dist/menu/menu-item-radio.d.ts.map +1 -1
  299. package/dist/menu/menu-item-radio.js +1 -1
  300. package/dist/menu/menu-item-radio.js.map +1 -1
  301. package/dist/menu/menu-item.d.ts +5 -5
  302. package/dist/menu/menu-item.d.ts.map +1 -1
  303. package/dist/menu/menu-item.js +8 -4
  304. package/dist/menu/menu-item.js.map +1 -1
  305. package/dist/menu/menu-list.d.ts +4 -4
  306. package/dist/menu/menu-list.d.ts.map +1 -1
  307. package/dist/menu/menu-list.js +6 -2
  308. package/dist/menu/menu-list.js.map +1 -1
  309. package/dist/menu/menu-provider.d.ts +1 -1
  310. package/dist/menu/menu-separator.d.ts +2 -2
  311. package/dist/menu/menu-separator.d.ts.map +1 -1
  312. package/dist/menu/menu-store.d.ts +1 -1
  313. package/dist/menu/menu.js +1 -1
  314. package/dist/menu/menu.js.map +1 -1
  315. package/dist/{menu-store-0CKKmNek.d.ts → menu-store-BpTJdcL8.d.ts} +2 -2
  316. package/dist/{menu-store-0CKKmNek.d.ts.map → menu-store-BpTJdcL8.d.ts.map} +1 -1
  317. package/dist/menubar/menubar-context.d.ts +2 -3
  318. package/dist/menubar/menubar-context.d.ts.map +1 -1
  319. package/dist/menubar/menubar-context.js +1 -3
  320. package/dist/menubar/menubar-context.js.map +1 -1
  321. package/dist/menubar/menubar-provider.d.ts +1 -1
  322. package/dist/menubar/menubar-store.d.ts +1 -1
  323. package/dist/menubar/menubar-store.js +2 -2
  324. package/dist/menubar/menubar-store.js.map +1 -1
  325. package/dist/menubar/menubar.d.ts +3 -3
  326. package/dist/menubar/menubar.d.ts.map +1 -1
  327. package/dist/{menubar-store-3h0eNIbS.d.ts → menubar-store-C553OKBw.d.ts} +3 -3
  328. package/dist/{menubar-store-3h0eNIbS.d.ts.map → menubar-store-C553OKBw.d.ts.map} +1 -1
  329. package/dist/popover/popover-anchor.d.ts +1 -1
  330. package/dist/popover/popover-arrow.d.ts +1 -1
  331. package/dist/popover/popover-arrow.d.ts.map +1 -1
  332. package/dist/popover/popover-arrow.js +4 -4
  333. package/dist/popover/popover-arrow.js.map +1 -1
  334. package/dist/popover/popover-description.d.ts +1 -1
  335. package/dist/popover/popover-disclosure-arrow.d.ts +1 -1
  336. package/dist/popover/popover-disclosure-arrow.d.ts.map +1 -1
  337. package/dist/popover/popover-disclosure-arrow.js +1 -1
  338. package/dist/popover/popover-disclosure-arrow.js.map +1 -1
  339. package/dist/popover/popover-disclosure.d.ts +3 -3
  340. package/dist/popover/popover-disclosure.d.ts.map +1 -1
  341. package/dist/popover/popover-disclosure.js +1 -1
  342. package/dist/popover/popover-disclosure.js.map +1 -1
  343. package/dist/popover/popover-dismiss.d.ts +1 -1
  344. package/dist/popover/popover-heading.d.ts +1 -1
  345. package/dist/popover/popover.d.ts +1 -1
  346. package/dist/popover/popover.js +2 -2
  347. package/dist/popover/popover.js.map +1 -1
  348. package/dist/{popover-CCqiRKqg.d.ts → popover-B9PxE5iP.d.ts} +10 -2
  349. package/dist/popover-B9PxE5iP.d.ts.map +1 -0
  350. package/dist/{popover-anchor-PgfeXyzs.d.ts → popover-anchor-W18KUmuM.d.ts} +2 -2
  351. package/dist/{popover-anchor-PgfeXyzs.d.ts.map → popover-anchor-W18KUmuM.d.ts.map} +1 -1
  352. package/dist/{popover-description-DU753dah.d.ts → popover-description-DbW4mVBb.d.ts} +3 -3
  353. package/dist/{popover-description-DU753dah.d.ts.map → popover-description-DbW4mVBb.d.ts.map} +1 -1
  354. package/dist/{popover-dismiss-DPeI6Zse.d.ts → popover-dismiss-CQFvuLzJ.d.ts} +3 -3
  355. package/dist/{popover-dismiss-DPeI6Zse.d.ts.map → popover-dismiss-CQFvuLzJ.d.ts.map} +1 -1
  356. package/dist/{popover-heading-DGsr6D5W.d.ts → popover-heading-DC8rYnwo.d.ts} +3 -3
  357. package/dist/{popover-heading-DGsr6D5W.d.ts.map → popover-heading-DC8rYnwo.d.ts.map} +1 -1
  358. package/dist/portal/portal.d.ts +1 -1
  359. package/dist/{portal-CMBWiayp.d.ts → portal-CKFTfCWH.d.ts} +2 -2
  360. package/dist/{portal-CMBWiayp.d.ts.map → portal-CKFTfCWH.d.ts.map} +1 -1
  361. package/dist/radio/radio-group.d.ts +2 -2
  362. package/dist/radio/radio-group.d.ts.map +1 -1
  363. package/dist/radio/radio-group.js +1 -1
  364. package/dist/radio/radio-group.js.map +1 -1
  365. package/dist/radio/radio.d.ts +2 -2
  366. package/dist/radio/radio.d.ts.map +1 -1
  367. package/dist/select/select-arrow.d.ts +1 -1
  368. package/dist/select/select-arrow.d.ts.map +1 -1
  369. package/dist/select/select-dismiss.d.ts +2 -2
  370. package/dist/select/select-dismiss.d.ts.map +1 -1
  371. package/dist/select/select-group-label.d.ts +1 -1
  372. package/dist/select/select-group-label.d.ts.map +1 -1
  373. package/dist/select/select-group.d.ts +1 -1
  374. package/dist/select/select-group.d.ts.map +1 -1
  375. package/dist/select/select-heading.d.ts +2 -2
  376. package/dist/select/select-heading.d.ts.map +1 -1
  377. package/dist/select/select-item-check.d.ts +1 -1
  378. package/dist/select/select-item-check.d.ts.map +1 -1
  379. package/dist/select/select-item.d.ts +3 -3
  380. package/dist/select/select-item.d.ts.map +1 -1
  381. package/dist/select/select-item.js +1 -1
  382. package/dist/select/select-item.js.map +1 -1
  383. package/dist/select/select-label.d.ts +1 -1
  384. package/dist/select/select-label.d.ts.map +1 -1
  385. package/dist/select/select-label.js +1 -1
  386. package/dist/select/select-label.js.map +1 -1
  387. package/dist/select/select-list.d.ts +3 -3
  388. package/dist/select/select-list.d.ts.map +1 -1
  389. package/dist/select/select-list.js +1 -1
  390. package/dist/select/select-list.js.map +1 -1
  391. package/dist/select/select-popover.d.ts +1 -1
  392. package/dist/select/select-renderer.d.ts +2 -2
  393. package/dist/select/select-renderer.d.ts.map +1 -1
  394. package/dist/select/select-row.d.ts +1 -1
  395. package/dist/select/select-row.d.ts.map +1 -1
  396. package/dist/select/select-row.js +1 -1
  397. package/dist/select/select-row.js.map +1 -1
  398. package/dist/select/select-separator.d.ts +1 -1
  399. package/dist/select/select-separator.d.ts.map +1 -1
  400. package/dist/select/select.d.ts +2 -2
  401. package/dist/select/select.d.ts.map +1 -1
  402. package/dist/select/select.js +1 -1
  403. package/dist/select/select.js.map +1 -1
  404. package/dist/separator/separator.d.ts +1 -1
  405. package/dist/{separator--ozQfMcK.d.ts → separator-BnvSVwBa.d.ts} +2 -2
  406. package/dist/{separator--ozQfMcK.d.ts.map → separator-BnvSVwBa.d.ts.map} +1 -1
  407. package/dist/tab/tab-list.d.ts +2 -2
  408. package/dist/tab/tab-list.d.ts.map +1 -1
  409. package/dist/tab/tab-list.js +1 -1
  410. package/dist/tab/tab-list.js.map +1 -1
  411. package/dist/tab/tab-panel.d.ts +3 -3
  412. package/dist/tab/tab-panel.d.ts.map +1 -1
  413. package/dist/tab/tab-panel.js +2 -3
  414. package/dist/tab/tab-panel.js.map +1 -1
  415. package/dist/tab/tab.d.ts +2 -2
  416. package/dist/tab/tab.d.ts.map +1 -1
  417. package/dist/tab/tab.js +1 -1
  418. package/dist/tab/tab.js.map +1 -1
  419. package/dist/tag/tag-input.d.ts +2 -2
  420. package/dist/tag/tag-input.d.ts.map +1 -1
  421. package/dist/tag/tag-input.js +1 -2
  422. package/dist/tag/tag-input.js.map +1 -1
  423. package/dist/tag/tag-list-label.d.ts +2 -2
  424. package/dist/tag/tag-list-label.d.ts.map +1 -1
  425. package/dist/tag/tag-list-label.js +1 -1
  426. package/dist/tag/tag-list-label.js.map +1 -1
  427. package/dist/tag/tag-list.d.ts +2 -2
  428. package/dist/tag/tag-list.d.ts.map +1 -1
  429. package/dist/tag/tag-list.js +1 -1
  430. package/dist/tag/tag-list.js.map +1 -1
  431. package/dist/tag/tag-remove.d.ts +1 -1
  432. package/dist/tag/tag-remove.d.ts.map +1 -1
  433. package/dist/tag/tag-remove.js +1 -2
  434. package/dist/tag/tag-remove.js.map +1 -1
  435. package/dist/tag/tag-value.js +1 -1
  436. package/dist/tag/tag-value.js.map +1 -1
  437. package/dist/tag/tag-values.js +1 -1
  438. package/dist/tag/tag-values.js.map +1 -1
  439. package/dist/tag/tag.d.ts +2 -2
  440. package/dist/tag/tag.d.ts.map +1 -1
  441. package/dist/tag/tag.js +1 -1
  442. package/dist/tag/tag.js.map +1 -1
  443. package/dist/toolbar/toolbar-container.d.ts +1 -1
  444. package/dist/toolbar/toolbar-container.d.ts.map +1 -1
  445. package/dist/toolbar/toolbar-input.d.ts +1 -1
  446. package/dist/toolbar/toolbar-input.d.ts.map +1 -1
  447. package/dist/toolbar/toolbar-item.d.ts +2 -2
  448. package/dist/toolbar/toolbar-item.d.ts.map +1 -1
  449. package/dist/toolbar/toolbar-separator.d.ts +1 -1
  450. package/dist/toolbar/toolbar-separator.d.ts.map +1 -1
  451. package/dist/toolbar/toolbar.d.ts +2 -2
  452. package/dist/toolbar/toolbar.d.ts.map +1 -1
  453. package/dist/tooltip/tooltip-anchor.d.ts +1 -1
  454. package/dist/tooltip/tooltip-anchor.d.ts.map +1 -1
  455. package/dist/tooltip/tooltip-anchor.js +15 -4
  456. package/dist/tooltip/tooltip-anchor.js.map +1 -1
  457. package/dist/tooltip/tooltip-arrow.d.ts +1 -1
  458. package/dist/tooltip/tooltip-arrow.d.ts.map +1 -1
  459. package/dist/tooltip/tooltip-arrow.js +1 -1
  460. package/dist/tooltip/tooltip-arrow.js.map +1 -1
  461. package/dist/tooltip/tooltip.js +1 -1
  462. package/dist/tooltip/tooltip.js.map +1 -1
  463. package/dist/visually-hidden/visually-hidden.d.ts +1 -1
  464. package/dist/visually-hidden/visually-hidden.d.ts.map +1 -1
  465. package/package.json +8 -8
  466. package/src/collection/collection-item-offscreen.tsx +1 -1
  467. package/src/combobox/combobox.tsx +47 -1
  468. package/src/composite/composite-container.tsx +2 -2
  469. package/src/composite/composite-hover.tsx +8 -14
  470. package/src/composite/composite-item-offscreen.tsx +2 -2
  471. package/src/composite/composite-item.tsx +2 -2
  472. package/src/composite/composite-renderer.tsx +2 -2
  473. package/src/composite/composite-row.tsx +2 -2
  474. package/src/composite/composite-separator.tsx +2 -2
  475. package/src/composite/composite-typeahead.tsx +2 -2
  476. package/src/composite/composite.tsx +3 -3
  477. package/src/dialog/dialog.tsx +33 -10
  478. package/src/dialog/utils/disable-accessibility-tree-outside.ts +0 -25
  479. package/src/dialog/utils/use-hide-on-interact-outside.ts +3 -2
  480. package/src/focusable/focusable.tsx +53 -10
  481. package/src/form/form-remove.tsx +14 -10
  482. package/src/form/form.tsx +3 -1
  483. package/src/heading/heading.tsx +2 -5
  484. package/src/hovercard/hovercard-disclosure.tsx +18 -4
  485. package/src/hovercard/hovercard.tsx +1 -1
  486. package/src/menu/menu-bar-store.ts +2 -2
  487. package/src/menu/menu-context.tsx +8 -0
  488. package/src/menu/menu-item.tsx +18 -1
  489. package/src/menu/menu-list.tsx +15 -0
  490. package/src/menubar/menubar-context.tsx +0 -5
  491. package/src/menubar/menubar-store.ts +2 -2
  492. package/src/popover/popover-arrow.tsx +3 -3
  493. package/src/popover/popover.tsx +8 -0
  494. package/src/tab/tab-panel.tsx +1 -1
  495. package/src/tag/tag-input.tsx +0 -1
  496. package/src/tag/tag-remove.tsx +0 -1
  497. package/src/tooltip/tooltip-anchor.tsx +23 -8
  498. package/dist/collection-renderer-DsPD9ksD.d.ts.map +0 -1
  499. package/dist/popover-CCqiRKqg.d.ts.map +0 -1
  500. package/src/hovercard/utils/__tests__/polygon-test.ts +0 -66
@@ -1 +1 @@
1
- {"version":3,"file":"form-control.js","names":[],"sources":["../../src/form/form-control.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useBooleanEvent,\n useEvent,\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { getDocument, cx, invariant } from \"@ariakit/utils\";\nimport type { BooleanOrCallback } from \"@ariakit/utils\";\nimport type { ElementType, FocusEvent, RefObject } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\ntype ItemType = \"label\" | \"error\" | \"description\";\n\nfunction getNamedElement(\n ref: RefObject<HTMLInputElement | null>,\n name: string,\n) {\n const element = ref.current;\n if (!element) return null;\n if (element.name === name) return element;\n if (element.form) {\n return element.form.elements.namedItem(name) as HTMLInputElement | null;\n }\n const document = getDocument(element);\n return document.getElementsByName(name)[0] as HTMLInputElement | null;\n}\n\nfunction useItem(store: FormStore, name: string, type: ItemType) {\n return useStoreState(store, (state) =>\n state.items.find((item) => item.type === type && item.name === name),\n );\n}\n\n/**\n * Returns props to create a `FormControl` component. Unlike `useFormInput`,\n * this hook doesn't automatically returns the `value` and `onChange` props.\n * This is so we can use it not only for native form elements but also for\n * custom components whose value is not controlled by the native `value` and\n * `onChange` props.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { content: \"\" } });\n * const props = useFormControl({ store, name: store.names.content });\n * const value = store.useValue(store.names.content);\n *\n * <Form store={store}>\n * <FormLabel name={store.names.content}>Content</FormLabel>\n * <Role\n * {...props}\n * value={value}\n * onChange={(value) => store.setValue(store.names.content, value)}\n * render={<Editor />}\n * />\n * </Form>\n * ```\n */\nexport const useFormControl = createHook<TagName, FormControlOptions>(\n function useFormControl({\n store,\n name: nameProp,\n getItem: getItemProp,\n touchOnBlur = true,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormControl must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n\n store.useValidate(async () => {\n const element = getNamedElement(ref, name);\n if (!element) return;\n // Flush microtasks to make sure the validity state is up to date\n await Promise.resolve();\n if (\"validity\" in element && !element.validity.valid) {\n store?.setError(name, element.validationMessage);\n }\n });\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"field\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const onBlurProp = props.onBlur;\n const touchOnBlurProp = useBooleanEvent(touchOnBlur);\n\n const onBlur = useEvent((event: FocusEvent<HTMLType>) => {\n onBlurProp?.(event);\n if (event.defaultPrevented) return;\n if (!touchOnBlurProp(event)) return;\n store?.setFieldTouched(name, true);\n });\n\n const label = useItem(store, name, \"label\");\n const error = useItem(store, name, \"error\");\n const description = useItem(store, name, \"description\");\n const describedBy = cx(\n error?.id,\n description?.id,\n props[\"aria-describedby\"],\n );\n\n const invalid = useStoreState(\n store,\n () => !!store?.getError(name) && store.getFieldTouched(name),\n );\n\n props = {\n \"aria-labelledby\": props[\"aria-label\"] != null ? undefined : label?.id,\n \"aria-invalid\": invalid,\n ...props,\n id,\n \"aria-describedby\": describedBy || undefined,\n ref: useMergeRefs(ref, props.ref),\n onBlur,\n };\n\n props = useCollectionItem<TagName>({ store, ...props, name, getItem });\n\n return props;\n },\n);\n\n/**\n * Abstract component that renders a form control. Unlike\n * [`FormInput`](https://ariakit.com/reference/form-input), this component\n * doesn't automatically pass the `value` and `onChange` props down to the\n * underlying element. This is so we can use it not only for native form\n * elements but also for custom components whose value is not controlled by the\n * native `value` and `onChange` props.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {11-19}\n * const form = useFormStore({\n * defaultValues: {\n * content: \"\",\n * },\n * });\n *\n * const value = form.useValue(form.names.content);\n *\n * <Form store={form}>\n * <FormLabel name={form.names.content}>Content</FormLabel>\n * <FormControl\n * name={form.names.content}\n * render={\n * <Editor\n * value={value}\n * onChange={(value) => form.setValue(form.names.content, value)}\n * />\n * }\n * />\n * </Form>\n * ```\n */\nexport const FormControl = memo(\n forwardRef(function FormControl(props: FormControlProps) {\n const htmlProps = useFormControl(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormControlOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Field name. This can either be a string corresponding to an existing\n * property name in the\n * [`values`](https://ariakit.com/reference/use-form-store#values) state of\n * the store, or a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, ensuring type safety.\n *\n * Live examples:\n * - [FormRadio](https://ariakit.com/examples/form-radio)\n * - [Form with Select](https://ariakit.com/examples/form-select)\n */\n name: StringLike;\n /**\n * Whether the field should be marked touched on blur.\n * @default true\n */\n touchOnBlur?: BooleanOrCallback<FocusEvent>;\n}\n\nexport type FormControlProps<T extends ElementType = TagName> = Props<\n T,\n FormControlOptions<T>\n>;\n"],"mappings":";;;;;;;;AA2BA,MAAA,UAAS;SAID,gBAAc,KAAA,MAAA;CACpB,MAAK,UAAS,IAAA;CACd,IAAI,CAAA,SAAQ,OAAS;CACrB,IAAI,QAAQ,SACV,MAAO,OAAQ;CAGjB,IAAA,QADiB,MAAA,OAAY,QACb,KAAA,SAAkB,UAAM,IAAA;CAC1C,OAAA,YAAA,OAAA,EAAA,kBAAA,IAAA,EAAA;AAEA;SACS,QAAA,OAAc,MAAQ,MAAA;CAG/B,OAAA,cAAA,QAAA,UAAA,MAAA,MAAA,MAAA,SAAA,KAAA,SAAA,QAAA,KAAA,SAAA,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MAkCI,iBAAgB,WAAe,SAAA,eAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,cAAA,MAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAO,kDAAe;CAC5B,MAAM,OAAK,OAAM,QAAQ;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CAEjC,MAAM,MAAA,OAAY,IAAA;OAChB,YAAgB,YAAA;EAChB,MAAK,UAAS,gBAAA,KAAA,IAAA;EAEd,IAAA,CAAA,SAAc;EACd,MAAI,QAAA,QAAc;EAGnB,IAAA,cAAA,WAAA,CAAA,QAAA,SAAA,OAAA,OAAA,SAAA,MAAA,QAAA,iBAAA;CAED,CAAA;OAEI,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;CACA,MAAM,aAAA,MAAkB;CAExB,MAAM,kBAAS,gBAA0C,WAAA;OACvD,SAAa,UAAK,UAAA;EAClB,aAAU,KAAA;EACV,IAAI,MAAC,kBAAqB;EAC1B,IAAA,CAAA,gBAAO,KAAgB,GAAM;EAC9B,OAAA,gBAAA,MAAA,IAAA;CAED,CAAA;CACA,MAAM,QAAQ,QAAQ,OAAO,MAAM,OAAO;CAC1C,MAAM,QAAA,QAAc,OAAQ,MAAO,OAAM;CACzC,MAAM,cAAc,QAClB,OACA,MAAA,aACA;CAGF,MAAM,cAAU,GAAA,OACd,IAAA,aACQ,IAAA,MAAO,mBAAwB;CAGzC,MAAA,UAAQ,cAAA,aAAA,CAAA,CAAA,OAAA,SAAA,IAAA,KAAA,MAAA,gBAAA,IAAA,CAAA;SACN;EACA,mBAAgB,MAAA,iBAAA,OAAA,KAAA,IAAA,OAAA;EAChB,gBAAG;EACH,GAAA;EACA;EACA,oBAAkB,eAAc,KAAA;EAChC,KAAA,aAAA,KAAA,MAAA,GAAA;EACF;CAEA;SAAqC,kBAAA;EAAO;EAAU,GAAA;EAAM;EAAS;CAErE,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqCI,cAAO,KAAc,WADH,SAAA,YACqB,OAAA;CACxC,OACH,cAAA,SAAA,eAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-control.js","names":[],"sources":["../../src/form/form-control.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useBooleanEvent,\n useEvent,\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { getDocument, cx, invariant } from \"@ariakit/utils\";\nimport type { BooleanOrCallback } from \"@ariakit/utils\";\nimport type { ElementType, FocusEvent, RefObject } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\ntype ItemType = \"label\" | \"error\" | \"description\";\n\nfunction getNamedElement(\n ref: RefObject<HTMLInputElement | null>,\n name: string,\n) {\n const element = ref.current;\n if (!element) return null;\n if (element.name === name) return element;\n if (element.form) {\n return element.form.elements.namedItem(name) as HTMLInputElement | null;\n }\n const document = getDocument(element);\n return document.getElementsByName(name)[0] as HTMLInputElement | null;\n}\n\nfunction useItem(store: FormStore, name: string, type: ItemType) {\n return useStoreState(store, (state) =>\n state.items.find((item) => item.type === type && item.name === name),\n );\n}\n\n/**\n * Returns props to create a `FormControl` component. Unlike `useFormInput`,\n * this hook doesn't automatically returns the `value` and `onChange` props.\n * This is so we can use it not only for native form elements but also for\n * custom components whose value is not controlled by the native `value` and\n * `onChange` props.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { content: \"\" } });\n * const props = useFormControl({ store, name: store.names.content });\n * const value = store.useValue(store.names.content);\n *\n * <Form store={store}>\n * <FormLabel name={store.names.content}>Content</FormLabel>\n * <Role\n * {...props}\n * value={value}\n * onChange={(value) => store.setValue(store.names.content, value)}\n * render={<Editor />}\n * />\n * </Form>\n * ```\n */\nexport const useFormControl = createHook<TagName, FormControlOptions>(\n function useFormControl({\n store,\n name: nameProp,\n getItem: getItemProp,\n touchOnBlur = true,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormControl must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n\n store.useValidate(async () => {\n const element = getNamedElement(ref, name);\n if (!element) return;\n // Flush microtasks to make sure the validity state is up to date\n await Promise.resolve();\n if (\"validity\" in element && !element.validity.valid) {\n store?.setError(name, element.validationMessage);\n }\n });\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"field\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const onBlurProp = props.onBlur;\n const touchOnBlurProp = useBooleanEvent(touchOnBlur);\n\n const onBlur = useEvent((event: FocusEvent<HTMLType>) => {\n onBlurProp?.(event);\n if (event.defaultPrevented) return;\n if (!touchOnBlurProp(event)) return;\n store?.setFieldTouched(name, true);\n });\n\n const label = useItem(store, name, \"label\");\n const error = useItem(store, name, \"error\");\n const description = useItem(store, name, \"description\");\n const describedBy = cx(\n error?.id,\n description?.id,\n props[\"aria-describedby\"],\n );\n\n const invalid = useStoreState(\n store,\n () => !!store?.getError(name) && store.getFieldTouched(name),\n );\n\n props = {\n \"aria-labelledby\": props[\"aria-label\"] != null ? undefined : label?.id,\n \"aria-invalid\": invalid,\n ...props,\n id,\n \"aria-describedby\": describedBy || undefined,\n ref: useMergeRefs(ref, props.ref),\n onBlur,\n };\n\n props = useCollectionItem<TagName>({ store, ...props, name, getItem });\n\n return props;\n },\n);\n\n/**\n * Abstract component that renders a form control. Unlike\n * [`FormInput`](https://ariakit.com/reference/form-input), this component\n * doesn't automatically pass the `value` and `onChange` props down to the\n * underlying element. This is so we can use it not only for native form\n * elements but also for custom components whose value is not controlled by the\n * native `value` and `onChange` props.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {11-19}\n * const form = useFormStore({\n * defaultValues: {\n * content: \"\",\n * },\n * });\n *\n * const value = form.useValue(form.names.content);\n *\n * <Form store={form}>\n * <FormLabel name={form.names.content}>Content</FormLabel>\n * <FormControl\n * name={form.names.content}\n * render={\n * <Editor\n * value={value}\n * onChange={(value) => form.setValue(form.names.content, value)}\n * />\n * }\n * />\n * </Form>\n * ```\n */\nexport const FormControl = memo(\n forwardRef(function FormControl(props: FormControlProps) {\n const htmlProps = useFormControl(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormControlOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Field name. This can either be a string corresponding to an existing\n * property name in the\n * [`values`](https://ariakit.com/reference/use-form-store#values) state of\n * the store, or a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, ensuring type safety.\n *\n * Live examples:\n * - [FormRadio](https://ariakit.com/examples/form-radio)\n * - [Form with Select](https://ariakit.com/examples/form-select)\n */\n name: StringLike;\n /**\n * Whether the field should be marked touched on blur.\n * @default true\n */\n touchOnBlur?: BooleanOrCallback<FocusEvent>;\n}\n\nexport type FormControlProps<T extends ElementType = TagName> = Props<\n T,\n FormControlOptions<T>\n>;\n"],"mappings":";;;;;;;;AA2BA,MAAA,UAAS;SAID,gBAAc,KAAA,MAAA;CACpB,MAAK,UAAS,IAAA;CACd,IAAI,CAAA,SAAQ,OAAS;CACrB,IAAI,QAAQ,SACV,MAAO,OAAQ;CAGjB,IAAA,QADiB,MAAA,OAAY,QACb,KAAA,SAAkB,UAAM,IAAA;CAC1C,OAAA,YAAA,OAAA,EAAA,kBAAA,IAAA,EAAA;AAEA;SACS,QAAA,OAAc,MAAQ,MAAA;CAG/B,OAAA,cAAA,QAAA,UAAA,MAAA,MAAA,MAAA,SAAA,KAAA,SAAA,QAAA,KAAA,SAAA,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MAkCI,iBAAgB,WAAe,SAAA,eAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,cAAA,MAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAO,QAAO,IAAQ,aAAA,gBAAA,kDAAA;CAC5B,MAAM,OAAK,OAAM,QAAQ;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CAEjC,MAAM,MAAA,OAAY,IAAA;OAChB,YAAgB,YAAA;EAChB,MAAK,UAAS,gBAAA,KAAA,IAAA;EAEd,IAAA,CAAA,SAAc;EACd,MAAI,QAAA,QAAc;EAGnB,IAAA,cAAA,WAAA,CAAA,QAAA,SAAA,OAAA,OAAA,SAAA,MAAA,QAAA,iBAAA;CAED,CAAA;OAEI,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;CACA,MAAM,aAAA,MAAkB;CAExB,MAAM,kBAAS,gBAA0C,WAAA;OACvD,SAAa,UAAK,UAAA;EAClB,aAAU,KAAA;EACV,IAAI,MAAC,kBAAqB;EAC1B,IAAA,CAAA,gBAAO,KAAgB,GAAM;EAC9B,OAAA,gBAAA,MAAA,IAAA;CAED,CAAA;CACA,MAAM,QAAQ,QAAQ,OAAO,MAAM,OAAO;CAC1C,MAAM,QAAA,QAAc,OAAQ,MAAO,OAAM;CACzC,MAAM,cAAc,QAClB,OACA,MAAA,aACA;CAGF,MAAM,cAAU,GAAA,OACd,IAAA,aACQ,IAAA,MAAO,mBAAwB;CAGzC,MAAA,UAAQ,cAAA,aAAA,CAAA,CAAA,OAAA,SAAA,IAAA,KAAA,MAAA,gBAAA,IAAA,CAAA;SACN;EACA,mBAAgB,MAAA,iBAAA,OAAA,KAAA,IAAA,OAAA;EAChB,gBAAG;EACH,GAAA;EACA;EACA,oBAAkB,eAAc,KAAA;EAChC,KAAA,aAAA,KAAA,MAAA,GAAA;EACF;CAEA;SAAqC,kBAAA;EAAO;EAAU,GAAA;EAAM;EAAS;CAErE,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqCI,cAAO,KAAc,WADH,SAAA,YACqB,OAAA;CACxC,OACH,cAAA,SAAA,eAAA,KAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { n as CollectionItemOptions } from "../collection-item-C-g2BwVF.js";
1
+ import { n as CollectionItemOptions } from "../collection-item-pvEWNoNs.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -43,7 +43,7 @@ declare const useFormDescription: import("@ariakit/react-utils").Hook<"div", For
43
43
  * </Form>
44
44
  * ```
45
45
  */
46
- declare const FormDescription: (props: FormDescriptionProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
46
+ declare const FormDescription: (props: FormDescriptionProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
47
47
  interface FormDescriptionOptions<T extends ElementType = TagName> extends CollectionItemOptions<T> {
48
48
  /**
49
49
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-description.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormDescription","FormDescriptionOptions","Hook","FormDescription","FormDescriptionProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-description.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAe7B;;;;AAjBiD,cAiB5BC,kBAAAA,iCAAmDE,IAAAA,QAAYD,sBAAsB;AAsB1G;;;;;;;;;AAAuJ;AACvJ;;;;;;;;;;;AADA,cAAqBE,eAAAA,GAAkBE,KAAAA,EAAOD,oBAAoB,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACjHN,sBAAAA,WAAiCL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAAvCT;;;;;;;EAQ5DU,KAAAA,GAAQX,SAAAA;EAaQ;AAEpB;;;;;;;;;;;EAFIY,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,oBAAAA,WAA+BR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,sBAAAA,CAAuBO,CAAAA"}
1
+ {"version":3,"file":"form-description.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormDescription","FormDescriptionOptions","Hook","FormDescription","FormDescriptionProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-description.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAe7B;;;;AAjBiD,cAiB5BC,kBAAAA,iCAAmDE,IAAAA,QAAYD,sBAAsB;AAsB1G;;;;;;;;;AAA2J;AAC3J;;;;;;;;;;;AADA,cAAqBE,eAAAA,GAAkBE,KAAAA,EAAOD,oBAAoB,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACrHN,sBAAAA,WAAiCL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAAvCT;;;;;;;EAQ5DU,KAAAA,GAAQX,SAAAA;EAaQ;AAEpB;;;;;;;;;;;EAFIY,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,oBAAAA,WAA+BR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,sBAAAA,CAAuBO,CAAAA"}
@@ -23,7 +23,7 @@ const TagName = "div";
23
23
  const useFormDescription = createHook(function useFormDescription({ store, name: nameProp, getItem: getItemProp, ...props }) {
24
24
  const context = useFormContext();
25
25
  store = store || context;
26
- invariant(store, "FormDescription must be wrapped in a Form component.");
26
+ invariant(store, process.env.NODE_ENV !== "production" && "FormDescription must be wrapped in a Form component.");
27
27
  const id = useId(props.id);
28
28
  const ref = useRef(null);
29
29
  const name = String(nameProp);
@@ -1 +1 @@
1
- {"version":3,"file":"form-description.js","names":[],"sources":["../../src/form/form-description.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport {\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"div\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormDescription` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { password: \"\" } });\n * const props = useFormDescription({ store, name: store.names.password });\n * <Form store={store}>\n * <FormLabel name={store.names.password}>Password</FormLabel>\n * <FormInput name={store.names.password} type=\"password\" />\n * <Role {...props}>Password with at least 8 characters.</Role>\n * </Form>\n * ```\n */\nexport const useFormDescription = createHook<TagName, FormDescriptionOptions>(\n function useFormDescription({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormDescription must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = {\n ...item,\n id: id || item.id,\n name,\n type: \"description\",\n };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n props = {\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n };\n\n props = useCollectionItem({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a description element for a form field, which will automatically\n * receive an `aria-describedby` attribute pointing to this element.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {10-12}\n * const form = useFormStore({\n * defaultValues: {\n * password: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.password}>Password</FormLabel>\n * <FormInput name={form.names.password} type=\"password\" />\n * <FormDescription name={form.names.password}>\n * Password with at least 8 characters.\n * </FormDescription>\n * </Form>\n * ```\n */\nexport const FormDescription = memo(\n forwardRef(function FormDescription(props: FormDescriptionProps) {\n const htmlProps = useFormDescription(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormDescriptionOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field described by this element. This can either be a string or\n * a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormDescription name=\"password\">\n * Password with at least 8 characters.\n * </FormDescription>\n * ```\n */\n name: StringLike;\n}\n\nexport type FormDescriptionProps<T extends ElementType = TagName> = Props<\n T,\n FormDescriptionOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;MA2CI,qBAAgB,WAAe,SAAA,mBAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAW,sDAAQ;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QACZ,WAAA;GACH,GAAA;GACA,IAAA,MAAA,KAAA;GACA;GACF,MAAA;EACA;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;SACK;EACH,GAAA;EACA;EACF,KAAA,aAAA,KAAA,MAAA,GAAA;CAEA;SAA4B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAEtD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;MA0BI,kBAAqB,KAAA,WADH,SAAA,gBACqB,OAAA;CACxC,OACH,cAAA,SAAA,mBAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-description.js","names":[],"sources":["../../src/form/form-description.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport {\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"div\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormDescription` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { password: \"\" } });\n * const props = useFormDescription({ store, name: store.names.password });\n * <Form store={store}>\n * <FormLabel name={store.names.password}>Password</FormLabel>\n * <FormInput name={store.names.password} type=\"password\" />\n * <Role {...props}>Password with at least 8 characters.</Role>\n * </Form>\n * ```\n */\nexport const useFormDescription = createHook<TagName, FormDescriptionOptions>(\n function useFormDescription({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormDescription must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = {\n ...item,\n id: id || item.id,\n name,\n type: \"description\",\n };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n props = {\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n };\n\n props = useCollectionItem({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a description element for a form field, which will automatically\n * receive an `aria-describedby` attribute pointing to this element.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {10-12}\n * const form = useFormStore({\n * defaultValues: {\n * password: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.password}>Password</FormLabel>\n * <FormInput name={form.names.password} type=\"password\" />\n * <FormDescription name={form.names.password}>\n * Password with at least 8 characters.\n * </FormDescription>\n * </Form>\n * ```\n */\nexport const FormDescription = memo(\n forwardRef(function FormDescription(props: FormDescriptionProps) {\n const htmlProps = useFormDescription(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormDescriptionOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field described by this element. This can either be a string or\n * a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormDescription name=\"password\">\n * Password with at least 8 characters.\n * </FormDescription>\n * ```\n */\n name: StringLike;\n}\n\nexport type FormDescriptionProps<T extends ElementType = TagName> = Props<\n T,\n FormDescriptionOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;MA2CI,qBAAgB,WAAe,SAAA,mBAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAW,QAAQ,IAAA,aAAA,gBAAA,sDAAA;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QACZ,WAAA;GACH,GAAA;GACA,IAAA,MAAA,KAAA;GACA;GACF,MAAA;EACA;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;SACK;EACH,GAAA;EACA;EACF,KAAA,aAAA,KAAA,MAAA,GAAA;CAEA;SAA4B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAEtD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;MA0BI,kBAAqB,KAAA,WADH,SAAA,gBACqB,OAAA;CACxC,OACH,cAAA,SAAA,mBAAA,KAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { n as CollectionItemOptions } from "../collection-item-C-g2BwVF.js";
1
+ import { n as CollectionItemOptions } from "../collection-item-pvEWNoNs.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -54,7 +54,7 @@ declare const useFormError: import("@ariakit/react-utils").Hook<"div", FormError
54
54
  * </Form>
55
55
  * ```
56
56
  */
57
- declare const FormError: (props: FormErrorProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
57
+ declare const FormError: (props: FormErrorProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
58
58
  interface FormErrorOptions<T extends ElementType = TagName> extends CollectionItemOptions<T> {
59
59
  /**
60
60
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-error.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormError","FormErrorOptions","Hook","FormError","FormErrorProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-error.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAsB7B;;;;AAA8F;AA0B9F;;;;;;AAlDiD,cAwB5BC,YAAAA,iCAA6CE,IAAAA,QAAYD,gBAAgB;;;AA0B6C;AAC3I;;;;;;;;;;;;;;;;;;;;;AAmBoB;cApBCE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAqBvEA;;;;;;;EAbtBC,KAAAA,GAAQX,SAAAA;EAauD;;;;;;;;;AAAsB;EAFrFY,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-error.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormError","FormErrorOptions","Hook","FormError","FormErrorProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-error.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAsB7B;;;;AAA8F;AA0B9F;;;;;;AAlDiD,cAwB5BC,YAAAA,iCAA6CE,IAAAA,QAAYD,gBAAgB;;;AA0BiD;AAC/I;;;;;;;;;;;;;;;;;;;;;AAmBoB;cApBCE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAqBvEA;;;;;;;EAbtBC,KAAAA,GAAQX,SAAAA;EAauD;;;;;;;;;AAAsB;EAFrFY,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -31,7 +31,7 @@ const TagName = "div";
31
31
  const useFormError = createHook(function useFormError({ store, name: nameProp, getItem: getItemProp, ...props }) {
32
32
  const context = useFormContext();
33
33
  store = store || context;
34
- invariant(store, "FormError must be wrapped in a Form component.");
34
+ invariant(store, process.env.NODE_ENV !== "production" && "FormError must be wrapped in a Form component.");
35
35
  const id = useId(props.id);
36
36
  const ref = useRef(null);
37
37
  const name = String(nameProp);
@@ -1 +1 @@
1
- {"version":3,"file":"form-error.js","names":[],"sources":["../../src/form/form-error.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"div\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormDescription` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormError({ store, name: store.names.email });\n *\n * store.useValidate(() => {\n * if (!store.getValue(store.names.email)) {\n * store.setError(store.names.email, \"Email is required!\");\n * }\n * });\n *\n * <Form store={store}>\n * <FormLabel name={store.names.email}>Email</FormLabel>\n * <FormInput name={store.names.email} />\n * <Role {...props} />\n * </Form>\n * ```\n */\nexport const useFormError = createHook<TagName, FormErrorOptions>(\n function useFormError({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormError must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"error\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const children = useStoreState(store, () => {\n const error = store?.getError(name);\n if (error == null) return;\n if (!store?.getFieldTouched(name)) return;\n return error;\n });\n\n props = {\n role: \"alert\",\n children,\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n };\n\n props = useCollectionItem({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders an element that shows an error message. The `children` will\n * automatically display the error message defined in the store.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {16}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * form.useValidate(() => {\n * if (!form.values.email) {\n * form.setError(form.names.email, \"Email is required!\");\n * }\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</FormLabel>\n * <FormInput name={form.names.email} />\n * <FormError name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormError = memo(\n forwardRef(function FormError(props: FormErrorProps) {\n const htmlProps = useFormError(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormErrorOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field associated with this error. This can either be a string\n * or a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormError name=\"password\" />\n * ```\n */\n name: StringLike;\n}\n\nexport type FormErrorProps<T extends ElementType = TagName> = Props<\n T,\n FormErrorOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmDI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAW,gDAAQ;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CASA,CAAA;SACQ;EACN,MAAA;YARM,cAAe,aAAa;GAClC,MAAI,QAAS,OAAM,SAAA,IAAA;GACnB,IAAI,SAAQ,MAAA;GACZ,IAAA,CAAA,OAAO,gBAAA,IAAA,GAAA;GAKA,OAAA;EACP,CAAA;EACA,GAAA;EACA;EACF,KAAA,aAAA,KAAA,MAAA,GAAA;CAEA;SAA4B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAEtD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-error.js","names":[],"sources":["../../src/form/form-error.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useId,\n useMergeRefs,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"div\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormDescription` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormError({ store, name: store.names.email });\n *\n * store.useValidate(() => {\n * if (!store.getValue(store.names.email)) {\n * store.setError(store.names.email, \"Email is required!\");\n * }\n * });\n *\n * <Form store={store}>\n * <FormLabel name={store.names.email}>Email</FormLabel>\n * <FormInput name={store.names.email} />\n * <Role {...props} />\n * </Form>\n * ```\n */\nexport const useFormError = createHook<TagName, FormErrorOptions>(\n function useFormError({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormError must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"error\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const children = useStoreState(store, () => {\n const error = store?.getError(name);\n if (error == null) return;\n if (!store?.getFieldTouched(name)) return;\n return error;\n });\n\n props = {\n role: \"alert\",\n children,\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n };\n\n props = useCollectionItem({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders an element that shows an error message. The `children` will\n * automatically display the error message defined in the store.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {16}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * form.useValidate(() => {\n * if (!form.values.email) {\n * form.setError(form.names.email, \"Email is required!\");\n * }\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</FormLabel>\n * <FormInput name={form.names.email} />\n * <FormError name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormError = memo(\n forwardRef(function FormError(props: FormErrorProps) {\n const htmlProps = useFormError(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormErrorOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field associated with this error. This can either be a string\n * or a reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormError name=\"password\" />\n * ```\n */\n name: StringLike;\n}\n\nexport type FormErrorProps<T extends ElementType = TagName> = Props<\n T,\n FormErrorOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmDI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAW,QAAQ,IAAA,aAAA,gBAAA,gDAAA;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CASA,CAAA;SACQ;EACN,MAAA;YARM,cAAe,aAAa;GAClC,MAAI,QAAS,OAAM,SAAA,IAAA;GACnB,IAAI,SAAQ,MAAA;GACZ,IAAA,CAAA,OAAO,gBAAA,IAAA,GAAA;GAKA,OAAA;EACP,CAAA;EACA,GAAA;EACA;EACF,KAAA,aAAA,KAAA,MAAA,GAAA;CAEA;SAA4B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAEtD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
@@ -65,7 +65,7 @@ declare const useFormField: import("@ariakit/react-utils").Hook<"input", FormFie
65
65
  * </Form>
66
66
  * ```
67
67
  */
68
- declare const FormField: (props: FormFieldProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
68
+ declare const FormField: (props: FormFieldProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
69
69
  interface FormFieldOptions<T extends ElementType = TagName> extends FormControlOptions<T> {}
70
70
  type FormFieldProps<T extends ElementType = TagName> = Props<T, FormFieldOptions<T>>;
71
71
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"form-field.d.ts","names":["Props","ElementType","FormControlOptions","TagName","useFormField","FormFieldOptions","Hook","FormField","FormFieldProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-field.d.ts"],"mappings":";;;;;cAGcG,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAyB7B;;;;AAAgG;AAoChG;;;;;;;;;AA/D6D,cA2BxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;AAqChG;;;;;;;;;;;;;;;AAA+F;AAE/F;;;;;;;;;;;;;;;;;;;AAFA,cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BJ,WAAAA,GAAcE,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA;AAAAA,KAElFJ,cAAAA,WAAyBP,WAAAA,GAAcE,OAAAA,IAAWH,KAAAA,CAAMY,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-field.d.ts","names":["Props","ElementType","FormControlOptions","TagName","useFormField","FormFieldOptions","Hook","FormField","FormFieldProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-field.d.ts"],"mappings":";;;;;cAGcG,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAyB7B;;;;AAAgG;AAoChG;;;;;;;;;AA/D6D,cA2BxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;AAqChG;;;;;;;;;;;;;;;AAA+F;AAE/F;;;;;;;;;;;;;;;;;;;AAFA,cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BJ,WAAAA,GAAcE,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA;AAAAA,KAElFJ,cAAAA,WAAyBP,WAAAA,GAAcE,OAAAA,IAAWH,KAAAA,CAAMY,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -1,4 +1,4 @@
1
- import { n as GroupLabelOptions } from "../group-label-C16IDs1b.js";
1
+ import { n as GroupLabelOptions } from "../group-label-BKYqD4Sj.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -45,7 +45,7 @@ declare const useFormGroupLabel: import("@ariakit/react-utils").Hook<"div", Form
45
45
  * </Form>
46
46
  * ```
47
47
  */
48
- declare const FormGroupLabel: (props: FormGroupLabelProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
48
+ declare const FormGroupLabel: (props: FormGroupLabelProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
49
49
  interface FormGroupLabelOptions<T extends ElementType = TagName> extends GroupLabelOptions<T> {
50
50
  /**
51
51
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-group-label.d.ts","names":["Props","ElementType","GroupLabelOptions","FormStore","TagName","useFormGroupLabel","FormGroupLabelOptions","Hook","FormGroupLabel","FormGroupLabelProps","props","ReactElement","JSXElementConstructor","T","store"],"sources":["../../src/form/form-group-label.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAa7B;;AAfiD,cAe5BC,iBAAAA,iCAAkDE,IAAAA,QAAYD,qBAAqB;;AAAA;AA2BxG;;;;;;;;;AAAqJ;AACrJ;;;;;;;;;;;;;;cADqBE,cAAAA,GAAiBE,KAAAA,EAAOD,mBAAmB,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UAC/GN,qBAAAA,WAAgCL,WAAAA,GAAcG,OAAAA,UAAiBF,iBAAAA,CAAkBW,CAAAA;EAQtFV;;AAAS;AAErB;;;;EAFIW,KAAAA,GAAQX,SAAAA;AAAAA;AAAAA,KAEAM,mBAAAA,WAA8BR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,qBAAAA,CAAsBO,CAAAA"}
1
+ {"version":3,"file":"form-group-label.d.ts","names":["Props","ElementType","GroupLabelOptions","FormStore","TagName","useFormGroupLabel","FormGroupLabelOptions","Hook","FormGroupLabel","FormGroupLabelProps","props","ReactElement","JSXElementConstructor","T","store"],"sources":["../../src/form/form-group-label.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAa7B;;AAfiD,cAe5BC,iBAAAA,iCAAkDE,IAAAA,QAAYD,qBAAqB;;AAAA;AA2BxG;;;;;;;;;AAAyJ;AACzJ;;;;;;;;;;;;;;cADqBE,cAAAA,GAAiBE,KAAAA,EAAOD,mBAAmB,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACnHN,qBAAAA,WAAgCL,WAAAA,GAAcG,OAAAA,UAAiBF,iBAAAA,CAAkBW,CAAAA;EAQtFV;;AAAS;AAErB;;;;EAFIW,KAAAA,GAAQX,SAAAA;AAAAA;AAAAA,KAEAM,mBAAAA,WAA8BR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,qBAAAA,CAAsBO,CAAAA"}
@@ -1,4 +1,4 @@
1
- import { n as GroupOptions } from "../group-CamegDJA.js";
1
+ import { n as GroupOptions } from "../group-nGD9e6Dj.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -47,7 +47,7 @@ declare const useFormGroup: import("@ariakit/react-utils").Hook<"div", FormGroup
47
47
  * </Form>
48
48
  * ```
49
49
  */
50
- declare const FormGroup: (props: FormGroupProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
50
+ declare const FormGroup: (props: FormGroupProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
51
51
  interface FormGroupOptions<T extends ElementType = TagName> extends GroupOptions<T> {
52
52
  /**
53
53
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-group.d.ts","names":["Props","ElementType","GroupOptions","FormStore","TagName","useFormGroup","FormGroupOptions","Hook","FormGroup","FormGroupProps","props","ReactElement","JSXElementConstructor","T","store"],"sources":["../../src/form/form-group.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAe7B;;;;AAjBiD,cAiB5BC,YAAAA,iCAA6CE,IAAAA,QAAYD,gBAAgB;AA2B9F;;;;;;;;;AAA2I;AAC3I;;;;;;;;;;;;;;;;AADA,cAAqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,YAAAA,CAAaW,CAAAA;EAQnE;AAErB;;;;;;EAFIC,KAAAA,GAAQX,SAAAA;AAAAA;AAAAA,KAEAM,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-group.d.ts","names":["Props","ElementType","GroupOptions","FormStore","TagName","useFormGroup","FormGroupOptions","Hook","FormGroup","FormGroupProps","props","ReactElement","JSXElementConstructor","T","store"],"sources":["../../src/form/form-group.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAe7B;;;;AAjBiD,cAiB5BC,YAAAA,iCAA6CE,IAAAA,QAAYD,gBAAgB;AA2B9F;;;;;;;;;AAA+I;AAC/I;;;;;;;;;;;;;;;;AADA,cAAqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,YAAAA,CAAaW,CAAAA;EAQnE;AAErB;;;;;;EAFIC,KAAAA,GAAQX,SAAAA;AAAAA;AAAAA,KAEAM,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -1,4 +1,4 @@
1
- import { n as FocusableOptions } from "../focusable-B00tOxtB.js";
1
+ import { n as FocusableOptions } from "../focusable-dBZH13-T.js";
2
2
  import { FormControlOptions } from "./form-control.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -42,7 +42,7 @@ declare const useFormInput: import("@ariakit/react-utils").Hook<"input", FormInp
42
42
  * </Form>
43
43
  * ```
44
44
  */
45
- declare const FormInput: (props: FormInputProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
45
+ declare const FormInput: (props: FormInputProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
46
46
  interface FormInputOptions<T extends ElementType = TagName> extends FormControlOptions<T>, FocusableOptions<T> {}
47
47
  type FormInputProps<T extends ElementType = TagName> = Props<T, FormInputOptions<T>>;
48
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"form-input.d.ts","names":["Props","ElementType","FocusableOptions","FormControlOptions","TagName","useFormInput","FormInputOptions","Hook","FormInput","FormInputProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-input.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAgB7B;;;;AAAgG;AAlBnC,cAkBxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;;;;;AAqB2C;AAC3I;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA,GAAIX,gBAAAA,CAAiBW,CAAAA;AAAAA,KAEvGJ,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-input.d.ts","names":["Props","ElementType","FocusableOptions","FormControlOptions","TagName","useFormInput","FormInputOptions","Hook","FormInput","FormInputProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-input.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAgB7B;;;;AAAgG;AAlBnC,cAkBxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;;;;;AAqB+C;AAC/I;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA,GAAIX,gBAAAA,CAAiBW,CAAAA;AAAAA,KAEvGJ,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -24,7 +24,7 @@ const TagName = "input";
24
24
  const useFormInput = createHook(function useFormInput({ store, name: nameProp, ...props }) {
25
25
  const context = useFormContext();
26
26
  store = store || context;
27
- invariant(store, "FormInput must be wrapped in a Form component.");
27
+ invariant(store, process.env.NODE_ENV !== "production" && "FormInput must be wrapped in a Form component.");
28
28
  const name = String(nameProp);
29
29
  const onChangeProp = props.onChange;
30
30
  const onChange = useEvent((event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"form-input.js","names":[],"sources":["../../src/form/form-input.tsx"],"sourcesContent":["import {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ChangeEvent, ElementType } from \"react\";\nimport type { FocusableOptions } from \"../focusable/focusable.tsx\";\nimport { useFocusable } from \"../focusable/focusable.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormControlOptions } from \"./form-control.tsx\";\nimport { useFormControl } from \"./form-control.tsx\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormInput` component. Unlike `useFormControl`, this\n * hook returns the `value` and `onChange` props that can be passed to a native\n * input, select or textarea elements.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormInput({ store, name: store.names.email });\n * <Form store={store}>\n * <FormLabel name={store.names.email}>Email</FormLabel>\n * <Role {...props} render={<input />} />\n * </Form>\n * ```\n */\nexport const useFormInput = createHook<TagName, FormInputOptions>(\n function useFormInput({ store, name: nameProp, ...props }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormInput must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const onChangeProp = props.onChange;\n\n const onChange = useEvent((event: ChangeEvent<HTMLType>) => {\n onChangeProp?.(event);\n if (event.defaultPrevented) return;\n store?.setValue(name, event.target.value);\n });\n\n const value = store.useValue(name);\n\n props = {\n value,\n ...props,\n onChange,\n };\n\n props = useFocusable<TagName>(props);\n props = useFormControl({ store, name, ...props });\n\n return props;\n },\n);\n\n/**\n * Renders a form input. Unlike\n * [`FormControl`](https://ariakit.com/reference/form-control), this component\n * passes the `value` and `onChange` props down to the underlying element that\n * can be native input, select or textarea elements.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {9}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</FormLabel>\n * <FormInput name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormInput = memo(\n forwardRef(function FormInput(props: FormInputProps) {\n const htmlProps = useFormInput(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormInputOptions<T extends ElementType = TagName>\n extends FormControlOptions<T>, FocusableOptions<T> {}\n\nexport type FormInputProps<T extends ElementType = TagName> = Props<\n T,\n FormInputOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAqCI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAO,gDAAe;CAC5B,MAAM,OAAA,OAAA,QAAqB;CAE3B,MAAM,eAAW,MAAU;OACzB,WAAe,UAAK,UAAA;EACpB,eAAU,KAAA;EACV,IAAA,MAAO,kBAAqB;EAC7B,OAAA,SAAA,MAAA,MAAA,OAAA,KAAA;CAID,CAAA;SAFc;EAIZ,OAAG,MAAA,SAAA,IAAA;EACH,GAAA;EACF;CAEA;CACA,QAAQ,aAAA,KAAe;SAAE,eAAA;EAAO;EAAM;EAAU,GAAA;CAEhD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;MAyBI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-input.js","names":[],"sources":["../../src/form/form-input.tsx"],"sourcesContent":["import {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ChangeEvent, ElementType } from \"react\";\nimport type { FocusableOptions } from \"../focusable/focusable.tsx\";\nimport { useFocusable } from \"../focusable/focusable.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormControlOptions } from \"./form-control.tsx\";\nimport { useFormControl } from \"./form-control.tsx\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FormInput` component. Unlike `useFormControl`, this\n * hook returns the `value` and `onChange` props that can be passed to a native\n * input, select or textarea elements.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormInput({ store, name: store.names.email });\n * <Form store={store}>\n * <FormLabel name={store.names.email}>Email</FormLabel>\n * <Role {...props} render={<input />} />\n * </Form>\n * ```\n */\nexport const useFormInput = createHook<TagName, FormInputOptions>(\n function useFormInput({ store, name: nameProp, ...props }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormInput must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const onChangeProp = props.onChange;\n\n const onChange = useEvent((event: ChangeEvent<HTMLType>) => {\n onChangeProp?.(event);\n if (event.defaultPrevented) return;\n store?.setValue(name, event.target.value);\n });\n\n const value = store.useValue(name);\n\n props = {\n value,\n ...props,\n onChange,\n };\n\n props = useFocusable<TagName>(props);\n props = useFormControl({ store, name, ...props });\n\n return props;\n },\n);\n\n/**\n * Renders a form input. Unlike\n * [`FormControl`](https://ariakit.com/reference/form-control), this component\n * passes the `value` and `onChange` props down to the underlying element that\n * can be native input, select or textarea elements.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {9}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</FormLabel>\n * <FormInput name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormInput = memo(\n forwardRef(function FormInput(props: FormInputProps) {\n const htmlProps = useFormInput(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormInputOptions<T extends ElementType = TagName>\n extends FormControlOptions<T>, FocusableOptions<T> {}\n\nexport type FormInputProps<T extends ElementType = TagName> = Props<\n T,\n FormInputOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAqCI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAO,QAAO,IAAQ,aAAA,gBAAA,gDAAA;CAC5B,MAAM,OAAA,OAAA,QAAqB;CAE3B,MAAM,eAAW,MAAU;OACzB,WAAe,UAAK,UAAA;EACpB,eAAU,KAAA;EACV,IAAA,MAAO,kBAAqB;EAC7B,OAAA,SAAA,MAAA,MAAA,OAAA,KAAA;CAID,CAAA;SAFc;EAIZ,OAAG,MAAA,SAAA,IAAA;EACH,GAAA;EACF;CAEA;CACA,QAAQ,aAAA,KAAe;SAAE,eAAA;EAAO;EAAM;EAAU,GAAA;CAEhD,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;MAyBI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { n as CollectionItemOptions } from "../collection-item-C-g2BwVF.js";
1
+ import { n as CollectionItemOptions } from "../collection-item-pvEWNoNs.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -49,7 +49,7 @@ declare const useFormLabel: import("@ariakit/react-utils").Hook<"label", FormLab
49
49
  * </Form>
50
50
  * ```
51
51
  */
52
- declare const FormLabel: (props: FormLabelProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
52
+ declare const FormLabel: (props: FormLabelProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
53
53
  interface FormLabelOptions<T extends ElementType = TagName> extends CollectionItemOptions<T> {
54
54
  /**
55
55
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-label.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormLabel","FormLabelOptions","Hook","FormLabel","FormLabelProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-label.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAkB7B;;;;AAAgG;AAyBhG;;AA7CiD,cAoB5BC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;;;AAyB2C;AAC3I;;;;;;;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAmBvFd;;AAAU;AAEpB;;;;EAbIe,KAAAA,GAAQX,SAAAA;EAawDU;;;;;;;;;;EAFhEE,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-label.d.ts","names":["StringLike","Props","ElementType","CollectionItemOptions","FormStore","TagName","useFormLabel","FormLabelOptions","Hook","FormLabel","FormLabelProps","props","ReactElement","JSXElementConstructor","T","store","name"],"sources":["../../src/form/form-label.d.ts"],"mappings":";;;;;;;cAKcK,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AAkB7B;;;;AAAgG;AAyBhG;;AA7CiD,cAoB5BC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;;;AAyB+C;AAC/I;;;;;;;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBF,qBAAAA,CAAsBW,CAAAA;EAmBvFd;;AAAU;AAEpB;;;;EAbIe,KAAAA,GAAQX,SAAAA;EAawDU;;;;;;;;;;EAFhEE,IAAAA,EAAMhB,UAAAA;AAAAA;AAAAA,KAEEU,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -31,7 +31,7 @@ function supportsNativeLabel(tagName) {
31
31
  const useFormLabel = createHook(function useFormLabel({ store, name: nameProp, getItem: getItemProp, ...props }) {
32
32
  const context = useFormContext();
33
33
  store = store || context;
34
- invariant(store, "FormLabel must be wrapped in a Form component.");
34
+ invariant(store, process.env.NODE_ENV !== "production" && "FormLabel must be wrapped in a Form component.");
35
35
  const id = useId(props.id);
36
36
  const ref = useRef(null);
37
37
  const name = String(nameProp);
@@ -1 +1 @@
1
- {"version":3,"file":"form-label.js","names":[],"sources":["../../src/form/form-label.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useEvent,\n useId,\n useMergeRefs,\n useTagName,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { getFirstTabbableIn, invariant } from \"@ariakit/utils\";\nimport type { ElementType, MouseEvent } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"label\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\nfunction supportsNativeLabel(tagName?: string) {\n return (\n tagName === \"input\" ||\n tagName === \"textarea\" ||\n tagName === \"select\" ||\n tagName === \"meter\" ||\n tagName === \"progress\"\n );\n}\n\n/**\n * Returns props to create a `FormLabel` component. If the field is not a native\n * input, select or textarea element, the hook will return props to render a\n * `span` element. Instead of relying on the `htmlFor` prop, it'll rely on the\n * `aria-labelledby` attribute on the form field. Clicking on the label will\n * move focus to the field even if it's not a native input.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormLabel({ store, name: store.names.email });\n * <Form store={store}>\n * <Role {...props}>Email</Role>\n * <FormInput name={store.names.email} />\n * </Form>\n * ```\n */\nexport const useFormLabel = createHook<TagName, FormLabelOptions>(\n function useFormLabel({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormLabel must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"label\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const field = useStoreState(store, (state) =>\n state.items.find((item) => item.type === \"field\" && item.name === name),\n );\n const fieldTagName = useTagName(field?.element, \"input\");\n const isNativeLabel = supportsNativeLabel(fieldTagName);\n\n const onClickProp = props.onClick;\n\n const onClick = useEvent((event: MouseEvent<HTMLLabelElement>) => {\n onClickProp?.(event);\n if (event.defaultPrevented) return;\n if (isNativeLabel) return;\n const fieldElement = field?.element;\n if (!fieldElement) return;\n queueMicrotask(() => {\n const focusableElement = getFirstTabbableIn(fieldElement, true, true);\n focusableElement?.focus();\n const role = focusableElement?.getAttribute(\"role\");\n // If the field is a combobox, we don't want to click on it, as it'll\n // open the listbox.\n if (role === \"combobox\") return;\n focusableElement?.click();\n });\n });\n\n props = {\n render: isNativeLabel ? <label /> : <span />,\n htmlFor: isNativeLabel ? field?.id : undefined,\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n onClick,\n };\n\n if (!isNativeLabel) {\n props = {\n ...props,\n style: {\n cursor: \"default\",\n ...props.style,\n },\n };\n }\n\n props = useCollectionItem<TagName>({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a label associated with a form field, even if the field is not a\n * native input.\n *\n * If the field is a native input, select or textarea element, this component\n * will render a native `label` element and rely on its `htmlFor` prop.\n * Otherwise, it'll render a `span` element and rely on the `aria-labelledby`\n * attribute on the form field instead. Clicking on the label will move focus to\n * the field even if it's not a native input.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {8}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</Role>\n * <FormInput name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormLabel = memo(\n forwardRef(function FormLabel(props: FormLabelProps) {\n const htmlProps = useFormLabel(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormLabelOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field labeled by this element. This can either be a string or a\n * reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormLabel name=\"email\">Email</FormLabel>\n * ```\n */\n name: StringLike;\n}\n\nexport type FormLabelProps<T extends ElementType = TagName> = Props<\n T,\n FormLabelOptions<T>\n>;\n"],"mappings":";;;;;;;;;AAyBA,MAAA,UAAS;SAEL,oBAAY,SACZ;CAKJ,OAAA,YAAA,WAAA,YAAA,cAAA,YAAA,YAAA,YAAA,WAAA,YAAA;;;;;;;;;;;;;;;;;;;MA0BI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAW,gDAAQ;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;CAIA,MAAM,QAAA,cAAgB,QAAA,UADD,MAAA,MAAW,MAAO,SAAS,KACM,SAAA,WAAA,KAAA,SAAA,IAAA,CAAA;CAEtD,MAAM,gBAAc,oBAAM,WAAA,OAAA,SAAA,OAAA,CAAA;CAE1B,MAAM,cAAU,MAAU;OACxB,UAAc,UAAK,UAAA;EACnB,cAAU,KAAA;EACV,IAAI,MAAA,kBAAe;EACnB,IAAA,eAAM;EACN,MAAK,eAAc,OAAA;EACnB,IAAA,CAAA,cAAA;uBACQ;GACN,MAAA,mBAAwB,mBAAA,cAAA,MAAA,IAAA;GAIxB,kBAHa,MAAkB;GAI/B,IAAA,kBAAkB,aAAM,MAAA,MAAA,YAAA;GACzB,kBAAA,MAAA;EACF,CAAA;CAED,CAAA;SACE;EACA,QAAA,gBAAqC,oBAAA,SAAA,CAAA,CAAA,IAAA,oBAAA,QAAA,CAAA,CAAA;EACrC,SAAG,gBAAA,OAAA,KAAA,KAAA;EACH,GAAA;EACA;EACA,KAAA,aAAA,KAAA,MAAA,GAAA;EACF;CAEA;KAEO,CAAA,eAAA,QAAA;EACH,GAAA;SACE;GACA,QAAG;GACL,GAAA,MAAA;EACF;CAGF;SAAqC,kBAAA;EAAO;EAAU,GAAA;EAAS;CAE/D,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-label.js","names":[],"sources":["../../src/form/form-label.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport { useStoreState } from \"@ariakit/react-store\";\nimport {\n useEvent,\n useId,\n useMergeRefs,\n useTagName,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { getFirstTabbableIn, invariant } from \"@ariakit/utils\";\nimport type { ElementType, MouseEvent } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore } from \"./form-store.ts\";\n\nconst TagName = \"label\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\nfunction supportsNativeLabel(tagName?: string) {\n return (\n tagName === \"input\" ||\n tagName === \"textarea\" ||\n tagName === \"select\" ||\n tagName === \"meter\" ||\n tagName === \"progress\"\n );\n}\n\n/**\n * Returns props to create a `FormLabel` component. If the field is not a native\n * input, select or textarea element, the hook will return props to render a\n * `span` element. Instead of relying on the `htmlFor` prop, it'll rely on the\n * `aria-labelledby` attribute on the form field. Clicking on the label will\n * move focus to the field even if it's not a native input.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { email: \"\" } });\n * const props = useFormLabel({ store, name: store.names.email });\n * <Form store={store}>\n * <Role {...props}>Email</Role>\n * <FormInput name={store.names.email} />\n * </Form>\n * ```\n */\nexport const useFormLabel = createHook<TagName, FormLabelOptions>(\n function useFormLabel({\n store,\n name: nameProp,\n getItem: getItemProp,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormLabel must be wrapped in a Form component.\",\n );\n\n const id = useId(props.id);\n const ref = useRef<HTMLType>(null);\n const name = String(nameProp);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, id: id || item.id, name, type: \"label\" };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [id, name, getItemProp],\n );\n\n const field = useStoreState(store, (state) =>\n state.items.find((item) => item.type === \"field\" && item.name === name),\n );\n const fieldTagName = useTagName(field?.element, \"input\");\n const isNativeLabel = supportsNativeLabel(fieldTagName);\n\n const onClickProp = props.onClick;\n\n const onClick = useEvent((event: MouseEvent<HTMLLabelElement>) => {\n onClickProp?.(event);\n if (event.defaultPrevented) return;\n if (isNativeLabel) return;\n const fieldElement = field?.element;\n if (!fieldElement) return;\n queueMicrotask(() => {\n const focusableElement = getFirstTabbableIn(fieldElement, true, true);\n focusableElement?.focus();\n const role = focusableElement?.getAttribute(\"role\");\n // If the field is a combobox, we don't want to click on it, as it'll\n // open the listbox.\n if (role === \"combobox\") return;\n focusableElement?.click();\n });\n });\n\n props = {\n render: isNativeLabel ? <label /> : <span />,\n htmlFor: isNativeLabel ? field?.id : undefined,\n ...props,\n id,\n ref: useMergeRefs(ref, props.ref),\n onClick,\n };\n\n if (!isNativeLabel) {\n props = {\n ...props,\n style: {\n cursor: \"default\",\n ...props.style,\n },\n };\n }\n\n props = useCollectionItem<TagName>({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a label associated with a form field, even if the field is not a\n * native input.\n *\n * If the field is a native input, select or textarea element, this component\n * will render a native `label` element and rely on its `htmlFor` prop.\n * Otherwise, it'll render a `span` element and rely on the `aria-labelledby`\n * attribute on the form field instead. Clicking on the label will move focus to\n * the field even if it's not a native input.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {8}\n * const form = useFormStore({\n * defaultValues: {\n * email: \"\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormLabel name={form.names.email}>Email</Role>\n * <FormInput name={form.names.email} />\n * </Form>\n * ```\n */\nexport const FormLabel = memo(\n forwardRef(function FormLabel(props: FormLabelProps) {\n const htmlProps = useFormLabel(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormLabelOptions<\n T extends ElementType = TagName,\n> extends CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the field labeled by this element. This can either be a string or a\n * reference to a field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n * @example\n * ```jsx\n * <FormLabel name=\"email\">Email</FormLabel>\n * ```\n */\n name: StringLike;\n}\n\nexport type FormLabelProps<T extends ElementType = TagName> = Props<\n T,\n FormLabelOptions<T>\n>;\n"],"mappings":";;;;;;;;;AAyBA,MAAA,UAAS;SAEL,oBAAY,SACZ;CAKJ,OAAA,YAAA,WAAA,YAAA,cAAA,YAAA,YAAA,YAAA,WAAA,YAAA;;;;;;;;;;;;;;;;;;;MA0BI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,SAAA,aAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAW,QAAQ,IAAA,aAAA,gBAAA,gDAAA;CACzB,MAAM,KAAA,MAAM,MAAqB,EAAA;CACjC,MAAM,MAAA,OAAO,IAAO;CAEpB,MAAM,OAAA,OAAU,QAAA;OAEZ,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAmB,IAAA,MAAA,KAAA;GAAM;GAAc,MAAA;EACnE;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACA;IAAC;EAAI;EAAM;EACb;CAEA,CAAA;CAIA,MAAM,QAAA,cAAgB,QAAA,UADD,MAAA,MAAW,MAAO,SAAS,KACM,SAAA,WAAA,KAAA,SAAA,IAAA,CAAA;CAEtD,MAAM,gBAAc,oBAAM,WAAA,OAAA,SAAA,OAAA,CAAA;CAE1B,MAAM,cAAU,MAAU;OACxB,UAAc,UAAK,UAAA;EACnB,cAAU,KAAA;EACV,IAAI,MAAA,kBAAe;EACnB,IAAA,eAAM;EACN,MAAK,eAAc,OAAA;EACnB,IAAA,CAAA,cAAA;uBACQ;GACN,MAAA,mBAAwB,mBAAA,cAAA,MAAA,IAAA;GAIxB,kBAHa,MAAkB;GAI/B,IAAA,kBAAkB,aAAM,MAAA,MAAA,YAAA;GACzB,kBAAA,MAAA;EACF,CAAA;CAED,CAAA;SACE;EACA,QAAA,gBAAqC,oBAAA,SAAA,CAAA,CAAA,IAAA,oBAAA,QAAA,CAAA,CAAA;EACrC,SAAG,gBAAA,OAAA,KAAA,KAAA;EACH,GAAA;EACA;EACA,KAAA,aAAA,KAAA,MAAA,GAAA;EACF;CAEA;KAEO,CAAA,eAAA,QAAA;EACH,GAAA;SACE;GACA,QAAG;GACL,GAAA,MAAA;EACF;CAGF;SAAqC,kBAAA;EAAO;EAAU,GAAA;EAAS;CAE/D,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import { n as ButtonOptions } from "../button-Cp853csH.js";
2
- import { n as CollectionItemOptions } from "../collection-item-C-g2BwVF.js";
1
+ import { n as ButtonOptions } from "../button-CVWcOgxs.js";
2
+ import { n as CollectionItemOptions } from "../collection-item-pvEWNoNs.js";
3
3
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
4
4
  import { Props } from "@ariakit/react-utils";
5
5
  import { ElementType } from "react";
@@ -68,7 +68,7 @@ declare const useFormPush: import("@ariakit/react-utils").Hook<"button", FormPus
68
68
  * </Form>
69
69
  * ```
70
70
  */
71
- declare const FormPush: (props: FormPushProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
71
+ declare const FormPush: (props: FormPushProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
72
72
  interface FormPushOptions<T extends ElementType = TagName> extends ButtonOptions<T>, CollectionItemOptions<T> {
73
73
  /**
74
74
  * Object returned by the
@@ -1 +1 @@
1
- {"version":3,"file":"form-push.d.ts","names":["StringLike","Props","ElementType","ButtonOptions","CollectionItemOptions","FormStore","TagName","useFormPush","FormPushOptions","Hook","FormPush","FormPushProps","props","ReactElement","JSXElementConstructor","T","store","name","value","autoFocusOnClick"],"sources":["../../src/form/form-push.d.ts"],"mappings":";;;;;;;;cAMcM,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AA0B7B;;;;AAA+F;AAmC/F;;;;;;;;;AAAyI;AA/DxF,cA4B5BC,WAAAA,iCAA4CE,IAAAA,WAAeD,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6D3E;AAEpB;;;;;;;cA5BqBE,QAAAA,GAAWE,KAAAA,EAAOD,aAAa,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACnGN,eAAAA,WAA0BN,WAAAA,GAAcI,OAAAA,UAAiBH,aAAAA,CAAcY,CAAAA,GAAIX,qBAAAA,CAAsBW,CAAAA;EA2BhD;;;;;;;EAnB9DC,KAAAA,GAAQX,SAAAA;EAmB0EU;;AAAC;;;;EAZnFE,IAAAA,EAAMjB,UAAAA;;;;EAINkB,KAAAA;;;;;;EAMAC,gBAAAA;AAAAA;AAAAA,KAEQR,aAAAA,WAAwBT,WAAAA,GAAcI,OAAAA,IAAWL,KAAAA,CAAMc,CAAAA,EAAGP,eAAAA,CAAgBO,CAAAA"}
1
+ {"version":3,"file":"form-push.d.ts","names":["StringLike","Props","ElementType","ButtonOptions","CollectionItemOptions","FormStore","TagName","useFormPush","FormPushOptions","Hook","FormPush","FormPushProps","props","ReactElement","JSXElementConstructor","T","store","name","value","autoFocusOnClick"],"sources":["../../src/form/form-push.d.ts"],"mappings":";;;;;;;;cAMcM,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFoB;;;;AAC5B;AAAA;;;;AACQ;AA0B7B;;;;AAA+F;AAmC/F;;;;;;;;;AAA6I;AA/D5F,cA4B5BC,WAAAA,iCAA4CE,IAAAA,WAAeD,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6D3E;AAEpB;;;;;;;cA5BqBE,QAAAA,GAAWE,KAAAA,EAAOD,aAAa,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACvGN,eAAAA,WAA0BN,WAAAA,GAAcI,OAAAA,UAAiBH,aAAAA,CAAcY,CAAAA,GAAIX,qBAAAA,CAAsBW,CAAAA;EA2BhD;;;;;;;EAnB9DC,KAAAA,GAAQX,SAAAA;EAmB0EU;;AAAC;;;;EAZnFE,IAAAA,EAAMjB,UAAAA;;;;EAINkB,KAAAA;;;;;;EAMAC,gBAAAA;AAAAA;AAAAA,KAEQR,aAAAA,WAAwBT,WAAAA,GAAcI,OAAAA,IAAWL,KAAAA,CAAMc,CAAAA,EAAGP,eAAAA,CAAgBO,CAAAA"}
@@ -47,7 +47,7 @@ function getFirstFieldsByName(items, name) {
47
47
  const useFormPush = createHook(function useFormPush({ store, value, name: nameProp, getItem: getItemProp, autoFocusOnClick = true, ...props }) {
48
48
  const context = useFormContext();
49
49
  store = store || context;
50
- invariant(store, "FormPush must be wrapped in a Form component.");
50
+ invariant(store, process.env.NODE_ENV !== "production" && "FormPush must be wrapped in a Form component.");
51
51
  const name = String(nameProp);
52
52
  const [shouldFocus, setShouldFocus] = useState(false);
53
53
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"form-push.js","names":[],"sources":["../../src/form/form-push.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType, MouseEvent } from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport type { ButtonOptions } from \"../button/button.tsx\";\nimport { useButton } from \"../button/button.tsx\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore, FormStoreState } from \"./form-store.ts\";\n\nconst TagName = \"button\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\nfunction getFirstFieldsByName(\n items: FormStoreState[\"items\"] | undefined,\n name: string,\n) {\n if (!items) return [];\n const fields: FormStoreState[\"items\"] = [];\n for (const item of items) {\n if (item.type !== \"field\") continue;\n if (!item.name.startsWith(name)) continue;\n const nameWithIndex = item.name.replace(/(\\.\\d+)\\..+$/, \"$1\");\n const regex = new RegExp(`^${nameWithIndex}`);\n if (!fields.some((i) => regex.test(i.name))) {\n fields.push(item);\n }\n }\n return fields;\n}\n\n/**\n * Returns props to create a `FormPush` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({\n * defaultValues: {\n * languages: [\"JavaScript\", \"PHP\"],\n * },\n * });\n * const props = useFormPush({\n * store,\n * name: store.names.languages,\n * value: \"\",\n * });\n * const values = useStoreState(store, \"values\");\n *\n * <Form store={store}>\n * {values.languages.map((_, i) => (\n * <FormInput key={i} name={store.names.languages[i]} />\n * ))}\n * <Role {...props}>Add new language</Role>\n * </Form>\n * ```\n */\nexport const useFormPush = createHook<TagName, FormPushOptions>(\n function useFormPush({\n store,\n value,\n name: nameProp,\n getItem: getItemProp,\n autoFocusOnClick = true,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormPush must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const [shouldFocus, setShouldFocus] = useState(false);\n\n useEffect(() => {\n if (!shouldFocus) return;\n const items = getFirstFieldsByName(store?.getState().items, name);\n const element = items?.[items.length - 1]?.element;\n if (!element) return;\n element.focus();\n setShouldFocus(false);\n }, [store, shouldFocus, name]);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, type: \"button\", name };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [name, getItemProp],\n );\n\n const onClickProp = props.onClick;\n\n const onClick = useEvent((event: MouseEvent<HTMLType>) => {\n onClickProp?.(event);\n if (event.defaultPrevented) return;\n store?.pushValue(name, value);\n if (!autoFocusOnClick) return;\n setShouldFocus(true);\n });\n\n props = {\n ...props,\n onClick,\n };\n\n props = useButton(props);\n props = useCollectionItem<TagName>({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a button that will push items to an array value in the form store\n * when clicked.\n *\n * The [`name`](https://ariakit.com/reference/form-push#name) prop needs to be\n * provided to identify the array field. The\n * [`value`](https://ariakit.com/reference/form-push#value) prop is required to\n * define the value that will be added to the array.\n *\n * By default, the newly added input will be automatically focused when the\n * button is clicked unless the\n * [`autoFocusOnClick`](https://ariakit.com/reference/form-push#autofocusonclick)\n * prop is set to `false`.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {13-15}\n * const form = useFormStore({\n * defaultValues: {\n * languages: [\"JavaScript\", \"PHP\"],\n * },\n * });\n *\n * const values = useStoreState(form, \"values\");\n *\n * <Form store={form}>\n * {values.languages.map((_, i) => (\n * <FormInput key={i} name={form.names.languages[i]} />\n * ))}\n * <FormPush name={form.names.languages} value=\"\">\n * Add new language\n * </FormPush>\n * </Form>\n * ```\n */\nexport const FormPush = forwardRef(function FormPush(props: FormPushProps) {\n const htmlProps = useFormPush(props);\n return createElement(TagName, htmlProps);\n});\n\nexport interface FormPushOptions<T extends ElementType = TagName>\n extends ButtonOptions<T>, CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the array field. This can either be a string or a reference to a\n * field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n */\n name: StringLike;\n /**\n * Value that will initially be assigned to the array item when it's pushed.\n */\n value: unknown;\n /**\n * Whether the newly added input should be automatically focused when the\n * button is clicked.\n * @default true\n */\n autoFocusOnClick?: boolean;\n}\n\nexport type FormPushProps<T extends ElementType = TagName> = Props<\n T,\n FormPushOptions<T>\n>;\n"],"mappings":";;;;;;;;AAsBA,MAAA,UAAS;SAIF,qBAAe,OAAA,MAAA;CACpB,IAAA,CAAA,OAAM,OAAmC,CAAA;CACzC,MAAK,SAAM,CAAA;MACL,MAAK,QAAS,OAAA;EAClB,IAAI,KAAC,SAAU,SAAW;EAC1B,IAAA,CAAA,KAAM,KAAA,WAAgB,IAAK,GAAK;EAChC,MAAM,gBAAY,KAAO,KAAI,QAAA,gBAAe,IAAA;EAC5C,MAAK,QAAO,IAAM,OAAM,IAAA,eAAkB;EAG5C,IAAA,CAAA,OAAA,MAAA,MAAA,MAAA,KAAA,EAAA,IAAA,CAAA,GAAA,OAAA,KAAA,IAAA;CACA;CACF,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoCI,cAAgB,WAAA,SAAe,YAAA,EAAA,OAAA,OAAA,MAAA,UAAA,SAAA,aAAA,mBAAA,MAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAO,+CAAe;CAC5B,MAAM,OAAC,OAAa,QAAA;CAEpB,MAAA,CAAA,aAAgB,kBAAA,SAAA,KAAA;iBACT;EACL,IAAA,CAAA,aAAc;EACd,MAAM,QAAA,qBAAwB,OAAS,SAAI,EAAA,OAAA,IAAA;EAC3C,MAAK,UAAS,QAAA,MAAA,SAAA,IAAA;EACd,IAAA,CAAA,SAAc;EACd,QAAA,MAAA;EACF,eAAG,KAAA;IAAC;EAAO;EAAa;EAAK;CAE7B,CAAA;OAEI,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAgB,MAAA;GAAK;EACjD;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACC;CAGH,GAAA,CAAA,MAAM,WAAc,CAAA;CAEpB,MAAM,cAAU,MAAU;OACxB,UAAc,UAAK,UAAA;EACnB,cAAU,KAAA;EACV,IAAA,MAAO,kBAAqB;EAC5B,OAAK,UAAA,MAAkB,KAAA;EACvB,IAAA,CAAA,kBAAmB;EACpB,eAAA,IAAA;CAED,CAAA;SACK;EACH,GAAA;EACF;CAEA;CACA,QAAQ,UAAA,KAAA;SAA6B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAE/D,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAsCE,WAAO,WAAc,SADH,SAAY,OACS;CACxC,OAAA,cAAA,SAAA,YAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-push.js","names":[],"sources":["../../src/form/form-push.tsx"],"sourcesContent":["import type { StringLike } from \"@ariakit/components/form/types\";\nimport {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ElementType, MouseEvent } from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport type { ButtonOptions } from \"../button/button.tsx\";\nimport { useButton } from \"../button/button.tsx\";\nimport type { CollectionItemOptions } from \"../collection/collection-item.tsx\";\nimport { useCollectionItem } from \"../collection/collection-item.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormStore, FormStoreState } from \"./form-store.ts\";\n\nconst TagName = \"button\" satisfies ElementType;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\nfunction getFirstFieldsByName(\n items: FormStoreState[\"items\"] | undefined,\n name: string,\n) {\n if (!items) return [];\n const fields: FormStoreState[\"items\"] = [];\n for (const item of items) {\n if (item.type !== \"field\") continue;\n if (!item.name.startsWith(name)) continue;\n const nameWithIndex = item.name.replace(/(\\.\\d+)\\..+$/, \"$1\");\n const regex = new RegExp(`^${nameWithIndex}`);\n if (!fields.some((i) => regex.test(i.name))) {\n fields.push(item);\n }\n }\n return fields;\n}\n\n/**\n * Returns props to create a `FormPush` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({\n * defaultValues: {\n * languages: [\"JavaScript\", \"PHP\"],\n * },\n * });\n * const props = useFormPush({\n * store,\n * name: store.names.languages,\n * value: \"\",\n * });\n * const values = useStoreState(store, \"values\");\n *\n * <Form store={store}>\n * {values.languages.map((_, i) => (\n * <FormInput key={i} name={store.names.languages[i]} />\n * ))}\n * <Role {...props}>Add new language</Role>\n * </Form>\n * ```\n */\nexport const useFormPush = createHook<TagName, FormPushOptions>(\n function useFormPush({\n store,\n value,\n name: nameProp,\n getItem: getItemProp,\n autoFocusOnClick = true,\n ...props\n }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormPush must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const [shouldFocus, setShouldFocus] = useState(false);\n\n useEffect(() => {\n if (!shouldFocus) return;\n const items = getFirstFieldsByName(store?.getState().items, name);\n const element = items?.[items.length - 1]?.element;\n if (!element) return;\n element.focus();\n setShouldFocus(false);\n }, [store, shouldFocus, name]);\n\n const getItem = useCallback<NonNullable<CollectionItemOptions[\"getItem\"]>>(\n (item) => {\n const nextItem = { ...item, type: \"button\", name };\n if (getItemProp) {\n return getItemProp(nextItem);\n }\n return nextItem;\n },\n [name, getItemProp],\n );\n\n const onClickProp = props.onClick;\n\n const onClick = useEvent((event: MouseEvent<HTMLType>) => {\n onClickProp?.(event);\n if (event.defaultPrevented) return;\n store?.pushValue(name, value);\n if (!autoFocusOnClick) return;\n setShouldFocus(true);\n });\n\n props = {\n ...props,\n onClick,\n };\n\n props = useButton(props);\n props = useCollectionItem<TagName>({ store, ...props, getItem });\n\n return props;\n },\n);\n\n/**\n * Renders a button that will push items to an array value in the form store\n * when clicked.\n *\n * The [`name`](https://ariakit.com/reference/form-push#name) prop needs to be\n * provided to identify the array field. The\n * [`value`](https://ariakit.com/reference/form-push#value) prop is required to\n * define the value that will be added to the array.\n *\n * By default, the newly added input will be automatically focused when the\n * button is clicked unless the\n * [`autoFocusOnClick`](https://ariakit.com/reference/form-push#autofocusonclick)\n * prop is set to `false`.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {13-15}\n * const form = useFormStore({\n * defaultValues: {\n * languages: [\"JavaScript\", \"PHP\"],\n * },\n * });\n *\n * const values = useStoreState(form, \"values\");\n *\n * <Form store={form}>\n * {values.languages.map((_, i) => (\n * <FormInput key={i} name={form.names.languages[i]} />\n * ))}\n * <FormPush name={form.names.languages} value=\"\">\n * Add new language\n * </FormPush>\n * </Form>\n * ```\n */\nexport const FormPush = forwardRef(function FormPush(props: FormPushProps) {\n const htmlProps = useFormPush(props);\n return createElement(TagName, htmlProps);\n});\n\nexport interface FormPushOptions<T extends ElementType = TagName>\n extends ButtonOptions<T>, CollectionItemOptions<T> {\n /**\n * Object returned by the\n * [`useFormStore`](https://ariakit.com/reference/use-form-store) hook. If not\n * provided, the closest [`Form`](https://ariakit.com/reference/form) or\n * [`FormProvider`](https://ariakit.com/reference/form-provider) components'\n * context will be used.\n */\n store?: FormStore;\n /**\n * Name of the array field. This can either be a string or a reference to a\n * field name from the\n * [`names`](https://ariakit.com/reference/use-form-store#names) object in the\n * store, for type safety.\n */\n name: StringLike;\n /**\n * Value that will initially be assigned to the array item when it's pushed.\n */\n value: unknown;\n /**\n * Whether the newly added input should be automatically focused when the\n * button is clicked.\n * @default true\n */\n autoFocusOnClick?: boolean;\n}\n\nexport type FormPushProps<T extends ElementType = TagName> = Props<\n T,\n FormPushOptions<T>\n>;\n"],"mappings":";;;;;;;;AAsBA,MAAA,UAAS;SAIF,qBAAe,OAAA,MAAA;CACpB,IAAA,CAAA,OAAM,OAAmC,CAAA;CACzC,MAAK,SAAM,CAAA;MACL,MAAK,QAAS,OAAA;EAClB,IAAI,KAAC,SAAU,SAAW;EAC1B,IAAA,CAAA,KAAM,KAAA,WAAgB,IAAK,GAAK;EAChC,MAAM,gBAAY,KAAO,KAAI,QAAA,gBAAe,IAAA;EAC5C,MAAK,QAAO,IAAM,OAAM,IAAA,eAAkB;EAG5C,IAAA,CAAA,OAAA,MAAA,MAAA,MAAA,KAAA,EAAA,IAAA,CAAA,GAAA,OAAA,KAAA,IAAA;CACA;CACF,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoCI,cAAgB,WAAA,SAAe,YAAA,EAAA,OAAA,OAAA,MAAA,UAAA,SAAA,aAAA,mBAAA,MAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAO,QAAO,IAAQ,aAAA,gBAAA,+CAAA;CAC5B,MAAM,OAAC,OAAa,QAAA;CAEpB,MAAA,CAAA,aAAgB,kBAAA,SAAA,KAAA;iBACT;EACL,IAAA,CAAA,aAAc;EACd,MAAM,QAAA,qBAAwB,OAAS,SAAI,EAAA,OAAA,IAAA;EAC3C,MAAK,UAAS,QAAA,MAAA,SAAA,IAAA;EACd,IAAA,CAAA,SAAc;EACd,QAAA,MAAA;EACF,eAAG,KAAA;IAAC;EAAO;EAAa;EAAK;CAE7B,CAAA;OAEI,UAAM,aAAW,SAAA;QAAK,WAAA;GAAM,GAAA;GAAgB,MAAA;GAAK;EACjD;EAGA,IAAA,aAAO,OAAA,YAAA,QAAA;EACT,OACC;CAGH,GAAA,CAAA,MAAM,WAAc,CAAA;CAEpB,MAAM,cAAU,MAAU;OACxB,UAAc,UAAK,UAAA;EACnB,cAAU,KAAA;EACV,IAAA,MAAO,kBAAqB;EAC5B,OAAK,UAAA,MAAkB,KAAA;EACvB,IAAA,CAAA,kBAAmB;EACpB,eAAA,IAAA;CAED,CAAA;SACK;EACH,GAAA;EACF;CAEA;CACA,QAAQ,UAAA,KAAA;SAA6B,kBAAA;EAAO;EAAU,GAAA;EAAS;CAE/D,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAsCE,WAAO,WAAc,SADH,SAAY,OACS;CACxC,OAAA,cAAA,SAAA,YAAA,KAAA,CAAA"}
@@ -48,7 +48,7 @@ declare const useFormRadioGroup: import("@ariakit/react-utils").Hook<"div", Form
48
48
  * </Form>
49
49
  * ```
50
50
  */
51
- declare const FormRadioGroup: (props: FormRadioGroupProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
51
+ declare const FormRadioGroup: (props: FormRadioGroupProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
52
52
  type FormRadioGroupOptions<T extends ElementType = TagName> = FormGroupOptions<T>;
53
53
  type FormRadioGroupProps<T extends ElementType = TagName> = Props<T, FormRadioGroupOptions<T>>;
54
54
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"form-radio-group.d.ts","names":["Props","ElementType","FormGroupOptions","TagName","useFormRadioGroup","FormRadioGroupOptions","Hook","FormRadioGroup","FormRadioGroupProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-radio-group.d.ts"],"mappings":";;;;;cAGcG,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAF4B;;;;AACpC;AAAA;;;;AACQ;AAkB7B;;;;AAAwG;AA0BxG;;AA9CyD,cAoBpCC,iBAAAA,iCAAkDE,IAAAA,QAAYD,qBAAqB;;;;;;;AA0B6C;AACrJ;;;;;;;;;;;;;;;AAAuF;AACvF;;cAFqBE,cAAAA,GAAiBE,KAAAA,EAAOD,mBAAmB,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,KACpHN,qBAAAA,WAAgCJ,WAAAA,GAAcE,OAAAA,IAAWD,gBAAAA,CAAiBU,CAAAA;AAAAA,KAC1EJ,mBAAAA,WAA8BP,WAAAA,GAAcE,OAAAA,IAAWH,KAAAA,CAAMY,CAAAA,EAAGP,qBAAAA,CAAsBO,CAAAA"}
1
+ {"version":3,"file":"form-radio-group.d.ts","names":["Props","ElementType","FormGroupOptions","TagName","useFormRadioGroup","FormRadioGroupOptions","Hook","FormRadioGroup","FormRadioGroupProps","props","ReactElement","JSXElementConstructor","T"],"sources":["../../src/form/form-radio-group.d.ts"],"mappings":";;;;;cAGcG,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAF4B;;;;AACpC;AAAA;;;;AACQ;AAkB7B;;;;AAAwG;AA0BxG;;AA9CyD,cAoBpCC,iBAAAA,iCAAkDE,IAAAA,QAAYD,qBAAqB;;;;;;;AA0BiD;AACzJ;;;;;;;;;;;;;;;AAAuF;AACvF;;cAFqBE,cAAAA,GAAiBE,KAAAA,EAAOD,mBAAmB,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,KACxHN,qBAAAA,WAAgCJ,WAAAA,GAAcE,OAAAA,IAAWD,gBAAAA,CAAiBU,CAAAA;AAAAA,KAC1EJ,mBAAAA,WAA8BP,WAAAA,GAAcE,OAAAA,IAAWH,KAAAA,CAAMY,CAAAA,EAAGP,qBAAAA,CAAsBO,CAAAA"}
@@ -50,7 +50,7 @@ declare const useFormRadio: import("@ariakit/react-utils").Hook<"input", FormRad
50
50
  * </Form>
51
51
  * ```
52
52
  */
53
- declare const FormRadio: (props: FormRadioProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
53
+ declare const FormRadio: (props: FormRadioProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
54
54
  interface FormRadioOptions<T extends ElementType = TagName> extends FormControlOptions<T>, Omit<RadioOptions<T>, "store" | "name"> {}
55
55
  type FormRadioProps<T extends ElementType = TagName> = Props<T, FormRadioOptions<T>>;
56
56
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"form-radio.d.ts","names":["Props","ElementType","RadioOptions","FormControlOptions","TagName","useFormRadio","FormRadioOptions","Hook","FormRadio","FormRadioProps","props","ReactElement","JSXElementConstructor","T","Omit"],"sources":["../../src/form/form-radio.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAoB7B;;;;AAAgG;AAyBhG;;;;AA/C6D,cAsBxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;AAyB2C;AAC3I;;;;;;;;;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,+BAA2CC,qBAAAA;AAAAA,UACrGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA,GAAIC,IAAAA,CAAKZ,YAAAA,CAAaW,CAAAA;AAAAA,KAExGJ,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
1
+ {"version":3,"file":"form-radio.d.ts","names":["Props","ElementType","RadioOptions","FormControlOptions","TagName","useFormRadio","FormRadioOptions","Hook","FormRadio","FormRadioProps","props","ReactElement","JSXElementConstructor","T","Omit"],"sources":["../../src/form/form-radio.d.ts"],"mappings":";;;;;;cAIcI,OAAAA;AAAAA,KACTA,OAAAA,UAAiBA,OAAO;AAFgC;;;;AACxC;AAAA;;;;AACQ;AAoB7B;;;;AAAgG;AAyBhG;;;;AA/C6D,cAsBxCC,YAAAA,iCAA6CE,IAAAA,UAAcD,gBAAgB;;;;;AAyB+C;AAC/I;;;;;;;;;;;;;;;;;;;cADqBE,SAAAA,GAAYE,KAAAA,EAAOD,cAAc,qBAAqBE,YAAAA,mCAA+CC,qBAAAA;AAAAA,UACzGN,gBAAAA,WAA2BL,WAAAA,GAAcG,OAAAA,UAAiBD,kBAAAA,CAAmBU,CAAAA,GAAIC,IAAAA,CAAKZ,YAAAA,CAAaW,CAAAA;AAAAA,KAExGJ,cAAAA,WAAyBR,WAAAA,GAAcG,OAAAA,IAAWJ,KAAAA,CAAMa,CAAAA,EAAGP,gBAAAA,CAAiBO,CAAAA"}
@@ -29,7 +29,7 @@ const TagName = "input";
29
29
  const useFormRadio = createHook(function useFormRadio({ store, name: nameProp, value, ...props }) {
30
30
  const context = useFormContext();
31
31
  store = store || context;
32
- invariant(store, "FormRadio must be wrapped in a Form component.");
32
+ invariant(store, process.env.NODE_ENV !== "production" && "FormRadio must be wrapped in a Form component.");
33
33
  const name = String(nameProp);
34
34
  const onChangeProp = props.onChange;
35
35
  const onChange = useEvent((event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"form-radio.js","names":[],"sources":["../../src/form/form-radio.tsx"],"sourcesContent":["import { useStoreState } from \"@ariakit/react-store\";\nimport {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ChangeEvent, ElementType } from \"react\";\nimport type { RadioOptions } from \"../radio/radio.tsx\";\nimport { useRadio } from \"../radio/radio.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormControlOptions } from \"./form-control.tsx\";\nimport { useFormControl } from \"./form-control.tsx\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `FormRadio` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { char: \"a\" } });\n * const a = useFormRadio({ store, name: store.names.char, value: \"a\" });\n * const b = useFormRadio({ store, name: store.names.char, value: \"b\" });\n * const c = useFormRadio({ store, name: store.names.char, value: \"c\" });\n * <Form store={store}>\n * <FormRadioGroup>\n * <FormGroupLabel>Favorite character</FormGroupLabel>\n * <Role {...a} />\n * <Role {...b} />\n * <Role {...c} />\n * </FormRadioGroup>\n * </Form>\n * ```\n */\nexport const useFormRadio = createHook<TagName, FormRadioOptions>(\n function useFormRadio({ store, name: nameProp, value, ...props }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormRadio must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const onChangeProp = props.onChange;\n\n const onChange = useEvent((event: ChangeEvent<HTMLInputElement>) => {\n onChangeProp?.(event);\n if (event.defaultPrevented) return;\n store?.setValue(name, value);\n });\n\n const checkedProp = props.checked;\n const checked = useStoreState(\n store,\n () => checkedProp ?? store?.getValue(name) === value,\n );\n\n props = {\n ...props,\n checked,\n onChange,\n };\n\n props = useRadio({ name, value, ...props });\n\n props = useFormControl({\n store,\n name,\n \"aria-labelledby\": undefined,\n ...props,\n });\n\n return props;\n },\n);\n\n/**\n * Renders a radio button as a form control. This component must be wrapped in a\n * [`FormRadioGroup`](https://ariakit.com/reference/form-radio-group) along with\n * other radio buttons sharing the same\n * [`name`](https://ariakit.com/reference/form-radio#name).\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {10-12}\n * const form = useFormStore({\n * defaultValues: {\n * char: \"a\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormRadioGroup>\n * <FormGroupLabel>Favorite character</FormGroupLabel>\n * <FormRadio name={form.names.char} value=\"a\" />\n * <FormRadio name={form.names.char} value=\"b\" />\n * <FormRadio name={form.names.char} value=\"c\" />\n * </FormRadioGroup>\n * </Form>\n * ```\n */\nexport const FormRadio = memo(\n forwardRef(function FormRadio(props: FormRadioProps) {\n const htmlProps = useFormRadio(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormRadioOptions<T extends ElementType = TagName>\n extends FormControlOptions<T>, Omit<RadioOptions<T>, \"store\" | \"name\"> {}\n\nexport type FormRadioProps<T extends ElementType = TagName> = Props<\n T,\n FormRadioOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyCI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,OAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAGI;CAGJ,UAAM,OAAO,gDAAe;CAC5B,MAAM,OAAA,OAAA,QAAqB;CAE3B,MAAM,eAAW,MAAU;OACzB,WAAe,UAAK,UAAA;EACpB,eAAU,KAAA;EACV,IAAA,MAAO,kBAAoB;EAC5B,OAAA,SAAA,MAAA,KAAA;CAED,CAAA;CACA,MAAM,cAAU,MAAA;CAKhB,MAAA,UAAQ,cAAA,aAAA,eAAA,OAAA,SAAA,IAAA,MAAA,KAAA;SACH;EACH,GAAA;EACA;EACF;CAEA;SAAmB,SAAA;EAAM;EAAO;EAAU,GAAA;CAE1C,CAAA;SACE,eAAA;EACA;EACA;EACA,mBAAG,KAAA;EACJ,GAAA;CAED,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"form-radio.js","names":[],"sources":["../../src/form/form-radio.tsx"],"sourcesContent":["import { useStoreState } from \"@ariakit/react-store\";\nimport {\n useEvent,\n createElement,\n createHook,\n forwardRef,\n memo,\n} from \"@ariakit/react-utils\";\nimport type { Props } from \"@ariakit/react-utils\";\nimport { invariant } from \"@ariakit/utils\";\nimport type { ChangeEvent, ElementType } from \"react\";\nimport type { RadioOptions } from \"../radio/radio.tsx\";\nimport { useRadio } from \"../radio/radio.tsx\";\nimport { useFormContext } from \"./form-context.tsx\";\nimport type { FormControlOptions } from \"./form-control.tsx\";\nimport { useFormControl } from \"./form-control.tsx\";\n\nconst TagName = \"input\" satisfies ElementType;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `FormRadio` component.\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx\n * const store = useFormStore({ defaultValues: { char: \"a\" } });\n * const a = useFormRadio({ store, name: store.names.char, value: \"a\" });\n * const b = useFormRadio({ store, name: store.names.char, value: \"b\" });\n * const c = useFormRadio({ store, name: store.names.char, value: \"c\" });\n * <Form store={store}>\n * <FormRadioGroup>\n * <FormGroupLabel>Favorite character</FormGroupLabel>\n * <Role {...a} />\n * <Role {...b} />\n * <Role {...c} />\n * </FormRadioGroup>\n * </Form>\n * ```\n */\nexport const useFormRadio = createHook<TagName, FormRadioOptions>(\n function useFormRadio({ store, name: nameProp, value, ...props }) {\n const context = useFormContext();\n store = store || context;\n\n invariant(\n store,\n process.env.NODE_ENV !== \"production\" &&\n \"FormRadio must be wrapped in a Form component.\",\n );\n\n const name = String(nameProp);\n const onChangeProp = props.onChange;\n\n const onChange = useEvent((event: ChangeEvent<HTMLInputElement>) => {\n onChangeProp?.(event);\n if (event.defaultPrevented) return;\n store?.setValue(name, value);\n });\n\n const checkedProp = props.checked;\n const checked = useStoreState(\n store,\n () => checkedProp ?? store?.getValue(name) === value,\n );\n\n props = {\n ...props,\n checked,\n onChange,\n };\n\n props = useRadio({ name, value, ...props });\n\n props = useFormControl({\n store,\n name,\n \"aria-labelledby\": undefined,\n ...props,\n });\n\n return props;\n },\n);\n\n/**\n * Renders a radio button as a form control. This component must be wrapped in a\n * [`FormRadioGroup`](https://ariakit.com/reference/form-radio-group) along with\n * other radio buttons sharing the same\n * [`name`](https://ariakit.com/reference/form-radio#name).\n * @see https://ariakit.com/components/form\n * @example\n * ```jsx {10-12}\n * const form = useFormStore({\n * defaultValues: {\n * char: \"a\",\n * },\n * });\n *\n * <Form store={form}>\n * <FormRadioGroup>\n * <FormGroupLabel>Favorite character</FormGroupLabel>\n * <FormRadio name={form.names.char} value=\"a\" />\n * <FormRadio name={form.names.char} value=\"b\" />\n * <FormRadio name={form.names.char} value=\"c\" />\n * </FormRadioGroup>\n * </Form>\n * ```\n */\nexport const FormRadio = memo(\n forwardRef(function FormRadio(props: FormRadioProps) {\n const htmlProps = useFormRadio(props);\n return createElement(TagName, htmlProps);\n }),\n);\n\nexport interface FormRadioOptions<T extends ElementType = TagName>\n extends FormControlOptions<T>, Omit<RadioOptions<T>, \"store\" | \"name\"> {}\n\nexport type FormRadioProps<T extends ElementType = TagName> = Props<\n T,\n FormRadioOptions<T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyCI,eAAgB,WAAe,SAAA,aAAA,EAAA,OAAA,MAAA,UAAA,OAAA,GAAA,SAAA;CAC/B,MAAA,UAAQ,eAAS;CAEjB,QAAA,SAEE;CAIF,UAAM,OAAO,QAAO,IAAQ,aAAA,gBAAA,gDAAA;CAC5B,MAAM,OAAA,OAAA,QAAqB;CAE3B,MAAM,eAAW,MAAU;OACzB,WAAe,UAAK,UAAA;EACpB,eAAU,KAAA;EACV,IAAA,MAAO,kBAAoB;EAC5B,OAAA,SAAA,MAAA,KAAA;CAED,CAAA;CACA,MAAM,cAAU,MAAA;CAKhB,MAAA,UAAQ,cAAA,aAAA,eAAA,OAAA,SAAA,IAAA,MAAA,KAAA;SACH;EACH,GAAA;EACA;EACF;CAEA;SAAmB,SAAA;EAAM;EAAO;EAAU,GAAA;CAE1C,CAAA;SACE,eAAA;EACA;EACA;EACA,mBAAG,KAAA;EACJ,GAAA;CAED,CAAA;CAEJ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;MA6BI,YAAO,KAAc,WADH,SAAA,UACqB,OAAA;CACxC,OACH,cAAA,SAAA,aAAA,KAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { n as ButtonOptions } from "../button-Cp853csH.js";
1
+ import { n as ButtonOptions } from "../button-CVWcOgxs.js";
2
2
  import { t as FormStore } from "../form-store-C4Kf5QHm.js";
3
3
  import { Props } from "@ariakit/react-utils";
4
4
  import { ElementType } from "react";
@@ -25,9 +25,10 @@ type TagName = typeof TagName;
25
25
  * const values = useStoreState(store, "values");
26
26
  *
27
27
  * <Form store={store}>
28
- * {values.languages.map((_, i) => (
29
- * <FormInput key={i} name={store.names.languages[i]} />
30
- * ))}
28
+ * {values.languages.map((language, i) => {
29
+ * if (language == null) return null;
30
+ * return <FormInput key={i} name={store.names.languages[i]} />;
31
+ * })}
31
32
  * <Role {...props}>Remove first language</Role>
32
33
  * </Form>
33
34
  * ```
@@ -49,7 +50,7 @@ declare const useFormRemove: import("@ariakit/react-utils").Hook<"button", FormR
49
50
  * prop to `false`.
50
51
  * @see https://ariakit.com/components/form
51
52
  * @example
52
- * ```jsx {13}
53
+ * ```jsx {15}
53
54
  * const form = useFormStore({
54
55
  * defaultValues: {
55
56
  * languages: ["JavaScript", "PHP"],
@@ -59,16 +60,19 @@ declare const useFormRemove: import("@ariakit/react-utils").Hook<"button", FormR
59
60
  * const values = useStoreState(form, "values");
60
61
  *
61
62
  * <Form store={form}>
62
- * {values.languages.map((_, i) => (
63
- * <div key={i}>
64
- * <FormInput name={form.names.languages[i]} />
65
- * <FormRemove name={form.names.languages} index={i} />
66
- * </div>
67
- * ))}
63
+ * {values.languages.map((language, i) => {
64
+ * if (language == null) return null;
65
+ * return (
66
+ * <div key={i}>
67
+ * <FormInput name={form.names.languages[i]} />
68
+ * <FormRemove name={form.names.languages} index={i} />
69
+ * </div>
70
+ * );
71
+ * })}
68
72
  * </Form>
69
73
  * ```
70
74
  */
71
- declare const FormRemove: (props: FormRemoveProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
75
+ declare const FormRemove: (props: FormRemoveProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
72
76
  interface FormRemoveOptions<T extends ElementType = TagName> extends ButtonOptions<T> {
73
77
  /**
74
78
  * Object returned by the