@fuf-stack/uniform 1.24.12 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/dist/Checkboxes/{index.d.ts → index.d.mts} +112 -119
  2. package/dist/Checkboxes/index.d.mts.map +1 -0
  3. package/dist/Checkboxes/{index.js → index.mjs} +2 -2
  4. package/dist/Checkboxes/index.mjs.map +1 -0
  5. package/dist/DatePicker/{index.d.cts → index.d.mts} +425 -417
  6. package/dist/{Slider/index.d.cts.map → DatePicker/index.d.mts.map} +1 -1
  7. package/dist/DatePicker/{index.js → index.mjs} +2 -2
  8. package/dist/DatePicker/index.mjs.map +1 -0
  9. package/dist/FieldArray/{index.d.cts → index.d.mts} +177 -164
  10. package/dist/FieldArray/index.d.mts.map +1 -0
  11. package/dist/FieldArray/{index.js → index.mjs} +6 -6
  12. package/dist/FieldArray/index.mjs.map +1 -0
  13. package/dist/FieldCard/{index.d.cts → index.d.mts} +84 -80
  14. package/dist/FieldCard/index.d.mts.map +1 -0
  15. package/dist/FieldCard/{index.js → index.mjs} +4 -4
  16. package/dist/FieldCard/index.mjs.map +1 -0
  17. package/dist/{FieldCopyTestIdButton-CRJBix9D.js → FieldCopyTestIdButton-CRJBix9D.mjs} +1 -1
  18. package/dist/FieldCopyTestIdButton-CRJBix9D.mjs.map +1 -0
  19. package/dist/{FieldValidationError-ByRoIxaM.js → FieldValidationError-ByRoIxaM.mjs} +1 -1
  20. package/dist/FieldValidationError-ByRoIxaM.mjs.map +1 -0
  21. package/dist/Form/{index.d.ts → index.d.mts} +3 -14
  22. package/dist/Form/index.d.mts.map +1 -0
  23. package/dist/Form/{index.js → index.mjs} +3 -3
  24. package/dist/Form/index.mjs.map +1 -0
  25. package/dist/{FormContext-LgzrDWu1.d.ts → FormContext-CsFiNvuJ.d.mts} +1 -2
  26. package/dist/FormContext-CsFiNvuJ.d.mts.map +1 -0
  27. package/dist/{FormContext-DjJOJKxj.js → FormContext-gHSwOlcy.mjs} +2 -2
  28. package/dist/FormContext-gHSwOlcy.mjs.map +1 -0
  29. package/dist/Grid/{index.d.ts → index.d.mts} +2 -7
  30. package/dist/Grid/index.d.mts.map +1 -0
  31. package/dist/Grid/index.mjs +2 -0
  32. package/dist/{Grid-CTs-Rb9G.js → Grid-CTs-Rb9G.mjs} +1 -1
  33. package/dist/{Grid-BbqCRkuY.cjs.map → Grid-CTs-Rb9G.mjs.map} +1 -1
  34. package/dist/Input/{index.d.cts → index.d.mts} +178 -183
  35. package/dist/Input/index.d.mts.map +1 -0
  36. package/dist/Input/{index.js → index.mjs} +3 -3
  37. package/dist/Input/index.mjs.map +1 -0
  38. package/dist/RadioBoxes/{index.d.cts → index.d.mts} +366 -371
  39. package/dist/{Switch/index.d.ts.map → RadioBoxes/index.d.mts.map} +1 -1
  40. package/dist/RadioBoxes/{index.js → index.mjs} +3 -3
  41. package/dist/RadioBoxes/{index.cjs.map → index.mjs.map} +1 -1
  42. package/dist/RadioTabs/{index.d.cts → index.d.mts} +116 -125
  43. package/dist/RadioTabs/index.d.mts.map +1 -0
  44. package/dist/RadioTabs/{index.js → index.mjs} +3 -3
  45. package/dist/RadioTabs/index.mjs.map +1 -0
  46. package/dist/Radios/{index.d.cts → index.d.mts} +360 -365
  47. package/dist/{DatePicker/index.d.ts.map → Radios/index.d.mts.map} +1 -1
  48. package/dist/Radios/{index.js → index.mjs} +3 -3
  49. package/dist/Radios/index.mjs.map +1 -0
  50. package/dist/Select/{index.d.cts → index.d.mts} +1028 -1045
  51. package/dist/Select/{index.d.ts.map → index.d.mts.map} +1 -1
  52. package/dist/Select/{index.js → index.mjs} +5 -6
  53. package/dist/Select/index.mjs.map +1 -0
  54. package/dist/Slider/{index.d.cts → index.d.mts} +451 -464
  55. package/dist/Slider/{index.d.ts.map → index.d.mts.map} +1 -1
  56. package/dist/Slider/{index.js → index.mjs} +2 -2
  57. package/dist/Slider/index.mjs.map +1 -0
  58. package/dist/SubmitButton/{index.d.ts → index.d.mts} +2 -12
  59. package/dist/SubmitButton/index.d.mts.map +1 -0
  60. package/dist/SubmitButton/{index.js → index.mjs} +2 -2
  61. package/dist/SubmitButton/index.mjs.map +1 -0
  62. package/dist/Switch/{index.d.cts → index.d.mts} +323 -332
  63. package/dist/Switch/{index.d.cts.map → index.d.mts.map} +1 -1
  64. package/dist/Switch/{index.js → index.mjs} +2 -2
  65. package/dist/Switch/index.mjs.map +1 -0
  66. package/dist/SwitchBox/{index.d.cts → index.d.mts} +115 -124
  67. package/dist/SwitchBox/index.d.mts.map +1 -0
  68. package/dist/SwitchBox/{index.js → index.mjs} +2 -2
  69. package/dist/SwitchBox/index.mjs.map +1 -0
  70. package/dist/TextArea/{index.d.cts → index.d.mts} +177 -177
  71. package/dist/TextArea/index.d.mts.map +1 -0
  72. package/dist/TextArea/{index.js → index.mjs} +3 -3
  73. package/dist/TextArea/index.mjs.map +1 -0
  74. package/dist/Time/{index.d.cts → index.d.mts} +285 -282
  75. package/dist/Time/index.d.mts.map +1 -0
  76. package/dist/Time/{index.js → index.mjs} +2 -2
  77. package/dist/Time/index.mjs.map +1 -0
  78. package/dist/helpers/{index.d.ts → index.d.mts} +1 -2
  79. package/dist/helpers/index.d.mts.map +1 -0
  80. package/dist/helpers/{index.js → index.mjs} +1 -1
  81. package/dist/helpers/{index.cjs.map → index.mjs.map} +1 -1
  82. package/dist/hooks/useClientValidation/{index.d.ts → index.d.mts} +1 -2
  83. package/dist/hooks/useClientValidation/index.d.mts.map +1 -0
  84. package/dist/hooks/useClientValidation/{index.js → index.mjs} +3 -3
  85. package/dist/hooks/useClientValidation/index.mjs.map +1 -0
  86. package/dist/hooks/useController/{index.d.cts → index.d.mts} +2 -1
  87. package/dist/hooks/useController/index.mjs +7 -0
  88. package/dist/hooks/useController/{index.cjs.map → index.mjs.map} +1 -1
  89. package/dist/hooks/useFormContext/index.d.mts +3 -0
  90. package/dist/hooks/useFormContext/{index.js → index.mjs} +2 -2
  91. package/dist/hooks/useFormContext/{index.cjs.map → index.mjs.map} +1 -1
  92. package/dist/hooks/useInput/index.d.mts +2 -0
  93. package/dist/hooks/useInput/index.mjs +7 -0
  94. package/dist/hooks/useInput/{index.cjs.map → index.mjs.map} +1 -1
  95. package/dist/hooks/useInputValueDebounce/{index.d.ts → index.d.mts} +2 -8
  96. package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -0
  97. package/dist/hooks/useInputValueDebounce/{index.js → index.mjs} +2 -2
  98. package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -0
  99. package/dist/hooks/useInputValueTransform/{index.d.cts → index.d.mts} +2 -1
  100. package/dist/hooks/useInputValueTransform/{index.js → index.mjs} +2 -2
  101. package/dist/hooks/useInputValueTransform/{index.cjs.map → index.mjs.map} +1 -1
  102. package/dist/hooks/useUniformField/{index.d.ts → index.d.mts} +5 -6
  103. package/dist/hooks/useUniformField/index.d.mts.map +1 -0
  104. package/dist/hooks/useUniformField/{index.js → index.mjs} +8 -8
  105. package/dist/hooks/useUniformField/index.mjs.map +1 -0
  106. package/dist/hooks/useUniformFieldArray/{index.d.ts → index.d.mts} +6 -13
  107. package/dist/hooks/useUniformFieldArray/index.d.mts.map +1 -0
  108. package/dist/hooks/useUniformFieldArray/{index.js → index.mjs} +5 -5
  109. package/dist/hooks/useUniformFieldArray/index.mjs.map +1 -0
  110. package/dist/hooks/useWatchFormReset/{index.d.ts → index.d.mts} +2 -4
  111. package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -0
  112. package/dist/hooks/useWatchFormReset/{index.js → index.mjs} +2 -2
  113. package/dist/hooks/useWatchFormReset/index.mjs.map +1 -0
  114. package/dist/hooks/useWatchUserChange/{index.d.ts → index.d.mts} +2 -6
  115. package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -0
  116. package/dist/hooks/useWatchUserChange/{index.js → index.mjs} +2 -2
  117. package/dist/hooks/useWatchUserChange/index.mjs.map +1 -0
  118. package/dist/index-CAdGtKE_.d.mts +1 -0
  119. package/dist/index-CwJo1b4Z.d.mts +1 -0
  120. package/dist/partials/FieldCopyTestIdButton/{index.d.ts → index.d.mts} +2 -5
  121. package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -0
  122. package/dist/partials/FieldCopyTestIdButton/{index.js → index.mjs} +1 -1
  123. package/dist/partials/FieldValidationError/{index.d.ts → index.d.mts} +2 -7
  124. package/dist/partials/FieldValidationError/index.d.mts.map +1 -0
  125. package/dist/partials/FieldValidationError/{index.js → index.mjs} +1 -1
  126. package/dist/{useController-DxFS0u7c.js → useController-CK39i6HI.mjs} +3 -3
  127. package/dist/useController-CK39i6HI.mjs.map +1 -0
  128. package/dist/{useController-CvQqCvFJ.d.ts → useController-DcK2YHbw.d.mts} +1 -2
  129. package/dist/useController-DcK2YHbw.d.mts.map +1 -0
  130. package/dist/{useFormContext-CJ9027lh.d.ts → useFormContext-BegmYvGA.d.mts} +4 -5
  131. package/dist/useFormContext-BegmYvGA.d.mts.map +1 -0
  132. package/dist/{useFormContext-BUSoUBUP.js → useFormContext-Bw4LokAf.mjs} +3 -3
  133. package/dist/useFormContext-Bw4LokAf.mjs.map +1 -0
  134. package/dist/{useInputValueTransform-DJ5zkqSy.js → useInputValueTransform-DJ5zkqSy.mjs} +1 -1
  135. package/dist/{useInputValueTransform-P62UUZBl.cjs.map → useInputValueTransform-DJ5zkqSy.mjs.map} +1 -1
  136. package/dist/{useInputValueTransform-DCXXb2Lp.d.ts → useInputValueTransform-LOaEim7k.d.mts} +2 -5
  137. package/dist/useInputValueTransform-LOaEim7k.d.mts.map +1 -0
  138. package/package.json +38 -128
  139. package/dist/Checkboxes/index.cjs +0 -129
  140. package/dist/Checkboxes/index.cjs.map +0 -1
  141. package/dist/Checkboxes/index.d.cts +0 -551
  142. package/dist/Checkboxes/index.d.cts.map +0 -1
  143. package/dist/Checkboxes/index.d.ts.map +0 -1
  144. package/dist/Checkboxes/index.js.map +0 -1
  145. package/dist/DatePicker/index.cjs +0 -202
  146. package/dist/DatePicker/index.cjs.map +0 -1
  147. package/dist/DatePicker/index.d.cts.map +0 -1
  148. package/dist/DatePicker/index.d.ts +0 -1532
  149. package/dist/DatePicker/index.js.map +0 -1
  150. package/dist/FieldArray/index.cjs +0 -499
  151. package/dist/FieldArray/index.cjs.map +0 -1
  152. package/dist/FieldArray/index.d.cts.map +0 -1
  153. package/dist/FieldArray/index.d.ts +0 -539
  154. package/dist/FieldArray/index.d.ts.map +0 -1
  155. package/dist/FieldArray/index.js.map +0 -1
  156. package/dist/FieldCard/index.cjs +0 -231
  157. package/dist/FieldCard/index.cjs.map +0 -1
  158. package/dist/FieldCard/index.d.cts.map +0 -1
  159. package/dist/FieldCard/index.d.ts +0 -314
  160. package/dist/FieldCard/index.d.ts.map +0 -1
  161. package/dist/FieldCard/index.js.map +0 -1
  162. package/dist/FieldCopyTestIdButton-CRJBix9D.js.map +0 -1
  163. package/dist/FieldCopyTestIdButton-D3D_LmJh.cjs +0 -31
  164. package/dist/FieldCopyTestIdButton-D3D_LmJh.cjs.map +0 -1
  165. package/dist/FieldValidationError-ByRoIxaM.js.map +0 -1
  166. package/dist/FieldValidationError-CfYKzl7P.cjs +0 -61
  167. package/dist/FieldValidationError-CfYKzl7P.cjs.map +0 -1
  168. package/dist/Form/index.cjs +0 -120
  169. package/dist/Form/index.cjs.map +0 -1
  170. package/dist/Form/index.d.cts +0 -43
  171. package/dist/Form/index.d.cts.map +0 -1
  172. package/dist/Form/index.d.ts.map +0 -1
  173. package/dist/Form/index.js.map +0 -1
  174. package/dist/FormContext-BLWS7bhO.d.cts +0 -20
  175. package/dist/FormContext-BLWS7bhO.d.cts.map +0 -1
  176. package/dist/FormContext-DjJOJKxj.js.map +0 -1
  177. package/dist/FormContext-LgzrDWu1.d.ts.map +0 -1
  178. package/dist/FormContext-eCnp-y2P.cjs +0 -319
  179. package/dist/FormContext-eCnp-y2P.cjs.map +0 -1
  180. package/dist/Grid/index.cjs +0 -6
  181. package/dist/Grid/index.d.cts +0 -22
  182. package/dist/Grid/index.d.cts.map +0 -1
  183. package/dist/Grid/index.d.ts.map +0 -1
  184. package/dist/Grid/index.js +0 -2
  185. package/dist/Grid-BbqCRkuY.cjs +0 -25
  186. package/dist/Grid-CTs-Rb9G.js.map +0 -1
  187. package/dist/Input/index.cjs +0 -100
  188. package/dist/Input/index.cjs.map +0 -1
  189. package/dist/Input/index.d.cts.map +0 -1
  190. package/dist/Input/index.d.ts +0 -677
  191. package/dist/Input/index.d.ts.map +0 -1
  192. package/dist/Input/index.js.map +0 -1
  193. package/dist/RadioBoxes/index.cjs +0 -147
  194. package/dist/RadioBoxes/index.d.cts.map +0 -1
  195. package/dist/RadioBoxes/index.d.ts +0 -1477
  196. package/dist/RadioBoxes/index.d.ts.map +0 -1
  197. package/dist/RadioBoxes/index.js.map +0 -1
  198. package/dist/RadioTabs/index.cjs +0 -132
  199. package/dist/RadioTabs/index.cjs.map +0 -1
  200. package/dist/RadioTabs/index.d.cts.map +0 -1
  201. package/dist/RadioTabs/index.d.ts +0 -585
  202. package/dist/RadioTabs/index.d.ts.map +0 -1
  203. package/dist/RadioTabs/index.js.map +0 -1
  204. package/dist/Radios/index.cjs +0 -97
  205. package/dist/Radios/index.cjs.map +0 -1
  206. package/dist/Radios/index.d.cts.map +0 -1
  207. package/dist/Radios/index.d.ts +0 -1399
  208. package/dist/Radios/index.d.ts.map +0 -1
  209. package/dist/Radios/index.js.map +0 -1
  210. package/dist/Select/index.cjs +0 -303
  211. package/dist/Select/index.cjs.map +0 -1
  212. package/dist/Select/index.d.cts.map +0 -1
  213. package/dist/Select/index.d.ts +0 -3920
  214. package/dist/Select/index.js.map +0 -1
  215. package/dist/Slider/index.cjs +0 -117
  216. package/dist/Slider/index.cjs.map +0 -1
  217. package/dist/Slider/index.d.ts +0 -1760
  218. package/dist/Slider/index.js.map +0 -1
  219. package/dist/SubmitButton/index.cjs +0 -35
  220. package/dist/SubmitButton/index.cjs.map +0 -1
  221. package/dist/SubmitButton/index.d.cts +0 -38
  222. package/dist/SubmitButton/index.d.cts.map +0 -1
  223. package/dist/SubmitButton/index.d.ts.map +0 -1
  224. package/dist/SubmitButton/index.js.map +0 -1
  225. package/dist/Switch/index.cjs +0 -86
  226. package/dist/Switch/index.cjs.map +0 -1
  227. package/dist/Switch/index.d.ts +0 -1257
  228. package/dist/Switch/index.js.map +0 -1
  229. package/dist/SwitchBox/index.cjs +0 -158
  230. package/dist/SwitchBox/index.cjs.map +0 -1
  231. package/dist/SwitchBox/index.d.cts.map +0 -1
  232. package/dist/SwitchBox/index.d.ts +0 -473
  233. package/dist/SwitchBox/index.d.ts.map +0 -1
  234. package/dist/SwitchBox/index.js.map +0 -1
  235. package/dist/TextArea/index.cjs +0 -70
  236. package/dist/TextArea/index.cjs.map +0 -1
  237. package/dist/TextArea/index.d.cts.map +0 -1
  238. package/dist/TextArea/index.d.ts +0 -659
  239. package/dist/TextArea/index.d.ts.map +0 -1
  240. package/dist/TextArea/index.js.map +0 -1
  241. package/dist/Time/index.cjs +0 -228
  242. package/dist/Time/index.cjs.map +0 -1
  243. package/dist/Time/index.d.cts.map +0 -1
  244. package/dist/Time/index.d.ts +0 -1028
  245. package/dist/Time/index.d.ts.map +0 -1
  246. package/dist/Time/index.js.map +0 -1
  247. package/dist/helpers/index.cjs +0 -430
  248. package/dist/helpers/index.d.cts +0 -238
  249. package/dist/helpers/index.d.cts.map +0 -1
  250. package/dist/helpers/index.d.ts.map +0 -1
  251. package/dist/helpers/index.js.map +0 -1
  252. package/dist/hooks/useClientValidation/index.cjs +0 -185
  253. package/dist/hooks/useClientValidation/index.cjs.map +0 -1
  254. package/dist/hooks/useClientValidation/index.d.cts +0 -148
  255. package/dist/hooks/useClientValidation/index.d.cts.map +0 -1
  256. package/dist/hooks/useClientValidation/index.d.ts.map +0 -1
  257. package/dist/hooks/useClientValidation/index.js.map +0 -1
  258. package/dist/hooks/useController/index.cjs +0 -8
  259. package/dist/hooks/useController/index.d.ts +0 -2
  260. package/dist/hooks/useController/index.js +0 -7
  261. package/dist/hooks/useController/index.js.map +0 -1
  262. package/dist/hooks/useFormContext/index.cjs +0 -9
  263. package/dist/hooks/useFormContext/index.d.cts +0 -2
  264. package/dist/hooks/useFormContext/index.d.ts +0 -2
  265. package/dist/hooks/useFormContext/index.js.map +0 -1
  266. package/dist/hooks/useInput/index.cjs +0 -13
  267. package/dist/hooks/useInput/index.d.cts +0 -2
  268. package/dist/hooks/useInput/index.d.ts +0 -2
  269. package/dist/hooks/useInput/index.js +0 -7
  270. package/dist/hooks/useInput/index.js.map +0 -1
  271. package/dist/hooks/useInputValueDebounce/index.cjs +0 -92
  272. package/dist/hooks/useInputValueDebounce/index.cjs.map +0 -1
  273. package/dist/hooks/useInputValueDebounce/index.d.cts +0 -66
  274. package/dist/hooks/useInputValueDebounce/index.d.cts.map +0 -1
  275. package/dist/hooks/useInputValueDebounce/index.d.ts.map +0 -1
  276. package/dist/hooks/useInputValueDebounce/index.js.map +0 -1
  277. package/dist/hooks/useInputValueTransform/index.cjs +0 -8
  278. package/dist/hooks/useInputValueTransform/index.d.ts +0 -2
  279. package/dist/hooks/useInputValueTransform/index.js.map +0 -1
  280. package/dist/hooks/useUniformField/index.cjs +0 -139
  281. package/dist/hooks/useUniformField/index.cjs.map +0 -1
  282. package/dist/hooks/useUniformField/index.d.cts +0 -100
  283. package/dist/hooks/useUniformField/index.d.cts.map +0 -1
  284. package/dist/hooks/useUniformField/index.d.ts.map +0 -1
  285. package/dist/hooks/useUniformField/index.js.map +0 -1
  286. package/dist/hooks/useUniformFieldArray/index.cjs +0 -102
  287. package/dist/hooks/useUniformFieldArray/index.cjs.map +0 -1
  288. package/dist/hooks/useUniformFieldArray/index.d.cts +0 -81
  289. package/dist/hooks/useUniformFieldArray/index.d.cts.map +0 -1
  290. package/dist/hooks/useUniformFieldArray/index.d.ts.map +0 -1
  291. package/dist/hooks/useUniformFieldArray/index.js.map +0 -1
  292. package/dist/hooks/useWatchFormReset/index.cjs +0 -38
  293. package/dist/hooks/useWatchFormReset/index.cjs.map +0 -1
  294. package/dist/hooks/useWatchFormReset/index.d.cts +0 -38
  295. package/dist/hooks/useWatchFormReset/index.d.cts.map +0 -1
  296. package/dist/hooks/useWatchFormReset/index.d.ts.map +0 -1
  297. package/dist/hooks/useWatchFormReset/index.js.map +0 -1
  298. package/dist/hooks/useWatchUserChange/index.cjs +0 -88
  299. package/dist/hooks/useWatchUserChange/index.cjs.map +0 -1
  300. package/dist/hooks/useWatchUserChange/index.d.cts +0 -80
  301. package/dist/hooks/useWatchUserChange/index.d.cts.map +0 -1
  302. package/dist/hooks/useWatchUserChange/index.d.ts.map +0 -1
  303. package/dist/hooks/useWatchUserChange/index.js.map +0 -1
  304. package/dist/index-BKZ67WMa.d.ts +0 -1
  305. package/dist/index-BVVgDSdq.d.cts +0 -1
  306. package/dist/index-BVVgDSdq.d.ts +0 -1
  307. package/dist/index-DmtQKWjk.d.cts +0 -1
  308. package/dist/index-DmtQKWjk.d.ts +0 -1
  309. package/dist/partials/FieldCopyTestIdButton/index.cjs +0 -6
  310. package/dist/partials/FieldCopyTestIdButton/index.d.cts +0 -14
  311. package/dist/partials/FieldCopyTestIdButton/index.d.cts.map +0 -1
  312. package/dist/partials/FieldCopyTestIdButton/index.d.ts.map +0 -1
  313. package/dist/partials/FieldValidationError/index.cjs +0 -6
  314. package/dist/partials/FieldValidationError/index.d.cts +0 -22
  315. package/dist/partials/FieldValidationError/index.d.cts.map +0 -1
  316. package/dist/partials/FieldValidationError/index.d.ts.map +0 -1
  317. package/dist/useController-CvQqCvFJ.d.ts.map +0 -1
  318. package/dist/useController-D87H3etM.cjs +0 -50
  319. package/dist/useController-D87H3etM.cjs.map +0 -1
  320. package/dist/useController-DxFS0u7c.js.map +0 -1
  321. package/dist/useController-fblEApv_.d.cts +0 -33
  322. package/dist/useController-fblEApv_.d.cts.map +0 -1
  323. package/dist/useFormContext-BSIXyfbo.cjs +0 -146
  324. package/dist/useFormContext-BSIXyfbo.cjs.map +0 -1
  325. package/dist/useFormContext-BUSoUBUP.js.map +0 -1
  326. package/dist/useFormContext-CJ9027lh.d.ts.map +0 -1
  327. package/dist/useFormContext-D84GPAdx.d.cts +0 -67
  328. package/dist/useFormContext-D84GPAdx.d.cts.map +0 -1
  329. package/dist/useInput-ClpHDPdr.d.ts +0 -2
  330. package/dist/useInputValueTransform-DCXXb2Lp.d.cts +0 -108
  331. package/dist/useInputValueTransform-DCXXb2Lp.d.cts.map +0 -1
  332. package/dist/useInputValueTransform-DCXXb2Lp.d.ts.map +0 -1
  333. package/dist/useInputValueTransform-DJ5zkqSy.js.map +0 -1
  334. package/dist/useInputValueTransform-P62UUZBl.cjs +0 -115
  335. /package/dist/{index-BKZ67WMa.d.cts → index-BVVgDSdq.d.mts} +0 -0
  336. /package/dist/{useInput-C0aJaAGe.js → useInput-C0aJaAGe.mjs} +0 -0
  337. /package/dist/{useInput-ClpHDPdr.d.cts → useInput-ClpHDPdr.d.mts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["FieldCopyTestIdButton","FieldValidationError"],"sources":["../../../src/hooks/useUniformField/useUniformField.tsx","../../../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { flattenFieldErrors, isValueEmpty } from '../../helpers';\nimport FieldCopyTestIdButton from '../../partials/FieldCopyTestIdButton';\nimport FieldValidationError from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Normalize nested RHF errors into a flat array for array-like fields */\n isArrayValue?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation errors from form state; flattened only when `isArrayValue` is enabled */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node (with optional array-error normalization via `isArrayValue`)\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n isArrayValue = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error: rawError,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field has a user-entered value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: `hasValue` is gated by `isDirty` so invalid initial values do not\n * show errors just because resolver-backed validation state is available.\n * Newly added empty array elements can be dirty, but stay hidden until blur\n * because they do not have a value yet.\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid =\n rawInvalid && ((isDirty && hasValue) || isTouched || submitCount > 0);\n // Debounce to prevent flickering during rapid state changes\n const invalid = useDebounce(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Array-like fields can receive nested RHF error objects (index keys, _errors).\n // Opt-in flattening keeps backward compatibility for components that rely on\n // object-shaped errors (e.g. FieldCard/FieldArray).\n const error = isArrayValue ? flattenFieldErrors(rawError) : rawError;\n const normalizedError = flattenFieldErrors(rawError);\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = (\n <FieldValidationError error={normalizedError} testId={testId} />\n );\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,eAAe,OACf,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACE,eAA6B;CAEjC,MAAM,EACJ,OAAO,UACP,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAEtC,MAAM,EAAE,UAAU,cAA4B;EAC5C;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;CACF,CAAC;CAGD,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAE1E,MAAM,eACH,cAAsD,QAAQ,SAC/D;EACF,MAAM,YAAY,YAAY,YAAwB;EACtD,cAAc,SAAS;CACzB;CAEA,MAAM,eAAgB,UAAU,CAAC,GAC/B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAAC,aAAa,UAAU;CAIzC,MAAM,UAAU,YAFd,eAAgB,WAAW,YAAa,aAAa,cAAc,IAE5B,GAAG;CAM5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,qBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAACA,+BAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAKN,MAAM,QAAQ,eAAe,mBAAmB,QAAQ,IAAI;CAK5D,MAAM,eACJ,oBAACC,8BAAD;EAAsB,OALA,mBAAmB,QAKE;EAAW;CAAS,CAAA;CAMjE,MAAM,EAAE,sBAAsB,eAAe,0BAC3C,SAAS;EACP;EACA,YAAY,EAEV,eAAe,MACjB;EACA,cAAc,KAAK,UAAU,KAAK;EAClC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;CAClB,CAAC;CAQH,OAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF"}
@@ -1,102 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_helpers_index = require("../../helpers/index.cjs");
3
- const require_useFormContext = require("../../useFormContext-BSIXyfbo.cjs");
4
- const require_hooks_useUniformField_index = require("../useUniformField/index.cjs");
5
- const require_hooks_useWatchFormReset_index = require("../useWatchFormReset/index.cjs");
6
- let react = require("react");
7
- let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
8
- let react_hook_form = require("react-hook-form");
9
- //#region src/hooks/useUniformFieldArray/useUniformFieldArray.ts
10
- /**
11
- * Enhanced useFieldArray hook with initialization and animation logic.
12
- * Based on React Hook Form's useFieldArray with additional features:
13
- * - Automatic initialization when lastElementNotRemovable is set
14
- * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)
15
- * - Animation control (disabled during initialization)
16
- * - Temporary animation disable during reset normalization collapse
17
- * - Support for flat arrays (arrays of primitives)
18
- *
19
- * Note: Automatic validation triggering on length change is disabled to prevent
20
- * triggering form-wide validation. Array validation still runs on form submission.
21
- *
22
- * @see https://react-hook-form.com/docs/usefieldarray
23
- */
24
- const useUniformFieldArray = ({ name, flat = false, elementInitialValue: _elementInitialValue = null, lastElementNotRemovable = false, disabled, testId: explicitTestId, label }) => {
25
- const uniformField = require_hooks_useUniformField_index.useUniformField({
26
- name,
27
- disabled,
28
- testId: explicitTestId,
29
- label
30
- });
31
- const { control } = uniformField;
32
- const { fields, append, remove, insert, move, replace } = (0, react_hook_form.useFieldArray)({
33
- control,
34
- name
35
- });
36
- const { trigger, setValue, getValues } = require_useFormContext.useFormContext();
37
- const needsInitialize = (0, react.useMemo)(() => {
38
- return lastElementNotRemovable && fields.length === 0;
39
- }, [lastElementNotRemovable, fields.length]);
40
- const hasInitialized = (0, react.useRef)(!needsInitialize);
41
- (0, react.useEffect)(() => {
42
- if (needsInitialize) hasInitialized.current = false;
43
- }, [needsInitialize]);
44
- (0, react.useEffect)(() => {
45
- if (hasInitialized.current) setTimeout(() => {
46
- trigger(name);
47
- }, 200);
48
- }, [fields.length]);
49
- const [disableAnimation, setDisableAnimation] = (0, react.useState)(true);
50
- const prefersReducedMotion = (0, _fuf_stack_pixel_motion.useReducedMotion)();
51
- (0, react.useEffect)(() => {
52
- if (hasInitialized.current) setDisableAnimation(!!prefersReducedMotion);
53
- }, [prefersReducedMotion]);
54
- const elementInitialValue = (0, react.useMemo)(() => {
55
- return flat ? { [require_helpers_index.flatArrayKey]: _elementInitialValue ?? null } : _elementInitialValue ?? {};
56
- }, [flat, _elementInitialValue]);
57
- require_hooks_useWatchFormReset_index.useWatchFormReset({ onReset: () => {
58
- const currentValue = getValues(name);
59
- const valueIsArray = Array.isArray(currentValue);
60
- const arrayValue = valueIsArray ? currentValue : [];
61
- const normalizedLength = lastElementNotRemovable ? 1 : 0;
62
- const alreadyNormalized = valueIsArray && arrayValue.length === normalizedLength;
63
- if (!(!valueIsArray || arrayValue.length === 0 || arrayValue.every((entry) => {
64
- return require_helpers_index.isValueEmpty(entry);
65
- }))) return;
66
- if (alreadyNormalized) return;
67
- setDisableAnimation(true);
68
- replace(lastElementNotRemovable ? [elementInitialValue] : []);
69
- if (!prefersReducedMotion) setTimeout(() => {
70
- setDisableAnimation(false);
71
- }, 1);
72
- } });
73
- (0, react.useEffect)(() => {
74
- if (needsInitialize) {
75
- setValue(name, [elementInitialValue], {
76
- shouldDirty: false,
77
- shouldTouch: false
78
- });
79
- hasInitialized.current = true;
80
- if (!prefersReducedMotion && disableAnimation) setTimeout(() => {
81
- setDisableAnimation(false);
82
- }, 1);
83
- }
84
- }, [needsInitialize]);
85
- return {
86
- fields,
87
- append,
88
- remove,
89
- insert,
90
- move,
91
- disableAnimation,
92
- elementInitialValue,
93
- ...uniformField
94
- };
95
- };
96
- //#endregion
97
- //#region src/hooks/useUniformFieldArray/index.ts
98
- /* v8 ignore stop */
99
- //#endregion
100
- exports.useUniformFieldArray = useUniformFieldArray;
101
-
102
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["useUniformField","useFormContext","flatArrayKey","isValueEmpty"],"sources":["../../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAeA,oCAAAA,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;CACF,CAAC;CAED,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,aAAA,GAAA,gBAAA,cAAA,CAA6B;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,uBAAAA,eAA6B;CAStE,MAAM,mBAAA,GAAA,MAAA,QAAA,OAAgC;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,kBAAA,GAAA,MAAA,OAAA,CAAwB,CAAC,eAAe;CAK9C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MAAM,CAAC,kBAAkB,wBAAA,GAAA,MAAA,SAAA,CAAgC,IAAI;CAI7D,MAAM,wBAAA,GAAA,wBAAA,iBAAA,CAAwC;CAC9C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,eAAe,SACjB,oBAAoB,CAAC,CAAC,oBAAoB;CAE9C,GAAG,CAAC,oBAAoB,CAAC;CAKzB,MAAM,uBAAA,GAAA,MAAA,QAAA,OAAoC;EACxC,OAAO,OACH,GAAGC,sBAAAA,eAAe,wBAAwB,KAAK,IAC9C,wBAAwB,CAAC;CAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;CAY/B,sCAAA,kBAAkB,EAChB,eAAe;EACb,MAAM,eAAe,UAAU,IAA0B;EACzD,MAAM,eAAe,MAAM,QAAQ,YAAY;EAC/C,MAAM,aAAa,eAAgB,eAA6B,CAAC;EACjE,MAAM,mBAAmB,0BAA0B,IAAI;EACvD,MAAM,oBACJ,gBAAgB,WAAW,WAAW;EAcxC,IAAI,EAPF,CAAC,gBACD,WAAW,WAAW,KACtB,WAAW,OAAO,UAAU;GAC1B,OAAOC,sBAAAA,aAAa,KAAK;EAC3B,CAAC,IAID;EAIF,IAAI,mBACF;EAIF,oBAAoB,IAAI;EAIxB,QAAS,0BAA0B,CAAC,mBAAmB,IAAI,CAAC,CAAS;EAGrE,IAAI,CAAC,sBACH,iBAAiB;GACf,oBAAoB,KAAK;EAC3B,GAAG,CAAC;CAER,EACF,CAAC;CAiBD,CAAA,GAAA,MAAA,UAAA,OACQ;EACJ,IAAI,iBAAiB;GAGnB,SAAS,MAA4B,CAAC,mBAAmB,GAAU;IACjE,aAAa;IACb,aAAa;GACf,CAAC;GAGD,eAAe,UAAU;GAKzB,IAAI,CAAC,wBAAwB,kBAC3B,iBAAiB;IACf,oBAAoB,KAAK;GAC3B,GAAG,CAAC;EAER;CACF,GAOA,CAAC,eAAe,CAClB;CAEA,OAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;CACL;AACF"}
@@ -1,81 +0,0 @@
1
- import { r as useController } from "../../useController-fblEApv_.cjs";
2
- import { n as useFormContext } from "../../useFormContext-D84GPAdx.cjs";
3
- import { ReactNode } from "react";
4
- import { ArrayPath, FieldValues } from "react-hook-form";
5
-
6
- //#region src/hooks/useUniformFieldArray/useUniformFieldArray.d.ts
7
- interface UseUniformFieldArrayProps<TFieldValues extends FieldValues = FieldValues> {
8
- /** Field name for the array */
9
- name: ArrayPath<TFieldValues>;
10
- /** Whether this is a flat array (array of primitives) */
11
- flat?: boolean;
12
- /** Initial value for new array elements */
13
- elementInitialValue?: unknown;
14
- /** Whether the last element cannot be removed (always maintain at least one element) */
15
- lastElementNotRemovable?: boolean;
16
- /** Disable the field */
17
- disabled?: boolean;
18
- /** Optional explicit test id used to build stable test ids */
19
- testId?: string;
20
- /** Optional label content */
21
- label?: ReactNode;
22
- }
23
- /**
24
- * Enhanced useFieldArray hook with initialization and animation logic.
25
- * Based on React Hook Form's useFieldArray with additional features:
26
- * - Automatic initialization when lastElementNotRemovable is set
27
- * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)
28
- * - Animation control (disabled during initialization)
29
- * - Temporary animation disable during reset normalization collapse
30
- * - Support for flat arrays (arrays of primitives)
31
- *
32
- * Note: Automatic validation triggering on length change is disabled to prevent
33
- * triggering form-wide validation. Array validation still runs on form submission.
34
- *
35
- * @see https://react-hook-form.com/docs/usefieldarray
36
- */
37
- declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldValues>({
38
- name,
39
- flat,
40
- elementInitialValue: _elementInitialValue,
41
- lastElementNotRemovable,
42
- disabled,
43
- testId: explicitTestId,
44
- label
45
- }: UseUniformFieldArrayProps<TFieldValues>) => {
46
- ariaLabel: string | undefined;
47
- control: import("react-hook-form").Control<TFieldValues, any, TFieldValues>;
48
- debugMode: ReturnType<typeof useFormContext<TFieldValues_1>>["debugMode"];
49
- defaultValue: unknown;
50
- disabled: boolean | undefined;
51
- error: import("react-hook-form").FieldError[] | undefined;
52
- errorMessage: ReactNode | null;
53
- field: Omit<import("react-hook-form").ControllerRenderProps<TFieldValues>, "onChange" | "value"> & {
54
- onChange: (...event: any[]) => void;
55
- value: string;
56
- };
57
- getErrorMessageProps: ReturnType<typeof import("@heroui/input").useInput>["getErrorMessageProps"];
58
- getHelperWrapperProps: ReturnType<typeof import("@heroui/input").useInput>["getHelperWrapperProps"];
59
- getLabelProps: ReturnType<typeof import("@heroui/input").useInput>["getLabelProps"];
60
- getValues: import("react-hook-form").UseFormGetValues<TFieldValues>;
61
- invalid: boolean;
62
- label: ReactNode | null;
63
- onBlur: ReturnType<typeof useController>["field"]["onBlur"];
64
- onChange: ReturnType<typeof useController>["field"]["onChange"];
65
- ref: ReturnType<typeof useController>["field"]["ref"];
66
- required: boolean;
67
- resetField: import("react-hook-form").UseFormResetField<TFieldValues>;
68
- testId: string;
69
- fields: (import("react-hook-form").FieldArray<TFieldValues, ArrayPath<TFieldValues>> & Record<"id", string> & {
70
- disabled?: boolean;
71
- })[];
72
- append: import("react-hook-form").UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
73
- remove: import("react-hook-form").UseFieldArrayRemove;
74
- insert: import("react-hook-form").UseFieldArrayInsert<TFieldValues, ArrayPath<TFieldValues>>;
75
- move: import("react-hook-form").UseFieldArrayMove;
76
- disableAnimation: boolean;
77
- elementInitialValue: {};
78
- };
79
- //#endregion
80
- export { UseUniformFieldArrayProps, useUniformFieldArray };
81
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"mappings":";;;;;;UAaiB,yBAAA,sBACM,WAAA,GAAc,WAAA;;EAGnC,IAAA,EAAM,SAAA,CAAU,YAAA;;EAEhB,IAAA;EANe;EAQf,mBAAA;EARwC;EAUxC,uBAAA;EATmC;EAWnC,QAAA;EARM;EAUN,MAAA;EAEiB;EAAjB,KAAA,GAAQ,SAAA;AAAA;;;;;;;;;;;;;;AAAS;cAiBN,oBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,IAAA;EAAA,IAAA;EAAA,mBAAA,EAAA,oBAAA;EAAA,uBAAA;EAAA,QAAA;EAAA,MAAA,EAAA,cAAA;EAAA;AAAA,GAQC,yBAAA,CAA0B,YAAA;;;;;;;;;kBAnCR,KAAA;;;;;;;;;UAsEmC,UAAA;YAIxC,UAAA,QAJwC,aAAA;OAKL,UAAA,QADnC,aAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"mappings":";;;;;;UAaiB,yBAAA,sBACM,WAAA,GAAc,WAAA;;EAGnC,IAAA,EAAM,SAAA,CAAU,YAAA;;EAEhB,IAAA;EANe;EAQf,mBAAA;EARwC;EAUxC,uBAAA;EATmC;EAWnC,QAAA;EARM;EAUN,MAAA;EAEiB;EAAjB,KAAA,GAAQ,SAAA;AAAA;;;;;;;;;;;;;;AAAS;cAiBN,oBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,IAAA;EAAA,IAAA;EAAA,mBAAA,EAAA,oBAAA;EAAA,uBAAA;EAAA,QAAA;EAAA,MAAA,EAAA,cAAA;EAAA;AAAA,GAQC,yBAAA,CAA0B,YAAA;;;;;;;;;kBAnCR,KAAA;;;;;;;;;UAsEmC,UAAA;YAIxC,UAAA,QAJwC,eAAA;OAKL,UAAA,QADnC,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["useRHFFieldArray","useFormContext"],"sources":["../../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAe,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;CACF,CAAC;CAED,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,YAAYA,cAAiB;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,iBAA6B;CAStE,MAAM,kBAAkB,cAAc;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,iBAAiB,OAAO,CAAC,eAAe;CAK9C,gBAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,gBAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,IAAI;CAI7D,MAAM,uBAAuB,iBAAiB;CAC9C,gBAAgB;EACd,IAAI,eAAe,SACjB,oBAAoB,CAAC,CAAC,oBAAoB;CAE9C,GAAG,CAAC,oBAAoB,CAAC;CAKzB,MAAM,sBAAsB,cAAc;EACxC,OAAO,OACH,GAAG,eAAe,wBAAwB,KAAK,IAC9C,wBAAwB,CAAC;CAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;CAY/B,kBAAkB,EAChB,eAAe;EACb,MAAM,eAAe,UAAU,IAA0B;EACzD,MAAM,eAAe,MAAM,QAAQ,YAAY;EAC/C,MAAM,aAAa,eAAgB,eAA6B,CAAC;EACjE,MAAM,mBAAmB,0BAA0B,IAAI;EACvD,MAAM,oBACJ,gBAAgB,WAAW,WAAW;EAcxC,IAAI,EAPF,CAAC,gBACD,WAAW,WAAW,KACtB,WAAW,OAAO,UAAU;GAC1B,OAAO,aAAa,KAAK;EAC3B,CAAC,IAID;EAIF,IAAI,mBACF;EAIF,oBAAoB,IAAI;EAIxB,QAAS,0BAA0B,CAAC,mBAAmB,IAAI,CAAC,CAAS;EAGrE,IAAI,CAAC,sBACH,iBAAiB;GACf,oBAAoB,KAAK;EAC3B,GAAG,CAAC;CAER,EACF,CAAC;CAiBD,gBACQ;EACJ,IAAI,iBAAiB;GAGnB,SAAS,MAA4B,CAAC,mBAAmB,GAAU;IACjE,aAAa;IACb,aAAa;GACf,CAAC;GAGD,eAAe,UAAU;GAKzB,IAAI,CAAC,wBAAwB,kBAC3B,iBAAiB;IACf,oBAAoB,KAAK;GAC3B,GAAG,CAAC;EAER;CACF,GAOA,CAAC,eAAe,CAClB;CAEA,OAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;CACL;AACF"}
@@ -1,38 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useFormContext = require("../../useFormContext-BSIXyfbo.cjs");
3
- let react = require("react");
4
- //#region src/hooks/useWatchFormReset/useWatchFormReset.ts
5
- /**
6
- * Hook that watches for programmatic form reset events.
7
- *
8
- * It lets consumers run a callback when a programmatic form reset is triggered
9
- * through the wrapped `reset()` from `useFormContext`.
10
- *
11
- * Why this exists:
12
- * - Components should not infer "a reset happened" from field values alone.
13
- * Value-based heuristics can conflict with valid user interactions.
14
- * - This hook provides an explicit reset signal so components can run
15
- * reset-only logic safely.
16
- *
17
- * Current usage:
18
- * - `useUniformFieldArray` uses this hook to handle resets when no default
19
- * array value was provided. In that case, RHF can leave stale empty
20
- * placeholder rows. It normalizes only on reset and does not collapse rows
21
- * during normal editing.
22
- */
23
- const useWatchFormReset = ({ onReset }) => {
24
- const { formReset } = require_useFormContext.useFormContext();
25
- (0, react.useEffect)(() => {
26
- const listener = () => {
27
- onReset();
28
- };
29
- return formReset.subscribe(listener);
30
- }, [formReset, onReset]);
31
- };
32
- //#endregion
33
- //#region src/hooks/useWatchFormReset/index.ts
34
- /* v8 ignore stop */
35
- //#endregion
36
- exports.useWatchFormReset = useWatchFormReset;
37
-
38
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["useFormContext"],"sources":["../../../src/hooks/useWatchFormReset/useWatchFormReset.ts","../../../src/hooks/useWatchFormReset/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchFormResetOptions {\n /**\n * Callback that runs whenever a programmatic form reset is observed.\n *\n * Resets are signalled via the uniform `formReset` pub/sub channel. The event\n * is emitted by the wrapped `reset()` method in `useFormContext`.\n *\n * Current primary use case:\n * - `useUniformFieldArray` listens for reset events to normalize stale\n * placeholder rows left by RHF after reset when array defaults are missing.\n */\n onReset: () => void;\n}\n\n/**\n * Hook that watches for programmatic form reset events.\n *\n * It lets consumers run a callback when a programmatic form reset is triggered\n * through the wrapped `reset()` from `useFormContext`.\n *\n * Why this exists:\n * - Components should not infer \"a reset happened\" from field values alone.\n * Value-based heuristics can conflict with valid user interactions.\n * - This hook provides an explicit reset signal so components can run\n * reset-only logic safely.\n *\n * Current usage:\n * - `useUniformFieldArray` uses this hook to handle resets when no default\n * array value was provided. In that case, RHF can leave stale empty\n * placeholder rows. It normalizes only on reset and does not collapse rows\n * during normal editing.\n */\nexport const useWatchFormReset = ({ onReset }: UseWatchFormResetOptions) => {\n const { formReset } = useFormContext();\n\n useEffect(() => {\n const listener = () => {\n onReset();\n };\n\n const unsubscribe = formReset.subscribe(listener);\n return unsubscribe;\n }, [formReset, onReset]);\n};\n","/* v8 ignore start */\n\nexport * from './useWatchFormReset';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB,EAAE,cAAwC;CAC1E,MAAM,EAAE,cAAcA,uBAAAA,eAAe;CAErC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,iBAAiB;GACrB,QAAQ;EACV;EAGA,OADoB,UAAU,UAAU,QACvB;CACnB,GAAG,CAAC,WAAW,OAAO,CAAC;AACzB"}
@@ -1,38 +0,0 @@
1
- //#region src/hooks/useWatchFormReset/useWatchFormReset.d.ts
2
- interface UseWatchFormResetOptions {
3
- /**
4
- * Callback that runs whenever a programmatic form reset is observed.
5
- *
6
- * Resets are signalled via the uniform `formReset` pub/sub channel. The event
7
- * is emitted by the wrapped `reset()` method in `useFormContext`.
8
- *
9
- * Current primary use case:
10
- * - `useUniformFieldArray` listens for reset events to normalize stale
11
- * placeholder rows left by RHF after reset when array defaults are missing.
12
- */
13
- onReset: () => void;
14
- }
15
- /**
16
- * Hook that watches for programmatic form reset events.
17
- *
18
- * It lets consumers run a callback when a programmatic form reset is triggered
19
- * through the wrapped `reset()` from `useFormContext`.
20
- *
21
- * Why this exists:
22
- * - Components should not infer "a reset happened" from field values alone.
23
- * Value-based heuristics can conflict with valid user interactions.
24
- * - This hook provides an explicit reset signal so components can run
25
- * reset-only logic safely.
26
- *
27
- * Current usage:
28
- * - `useUniformFieldArray` uses this hook to handle resets when no default
29
- * array value was provided. In that case, RHF can leave stale empty
30
- * placeholder rows. It normalizes only on reset and does not collapse rows
31
- * during normal editing.
32
- */
33
- declare const useWatchFormReset: ({
34
- onReset
35
- }: UseWatchFormResetOptions) => void;
36
- //#endregion
37
- export { UseWatchFormResetOptions, useWatchFormReset };
38
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/hooks/useWatchFormReset/useWatchFormReset.ts"],"mappings":";UAIiB,wBAAA;EAAA;;;;AAWR;AAqBT;;;;;EArBE,OAAO;AAAA;;AAqB8D;;;;;;;;;;;;;;;;;cAA1D,iBAAA;EAAqB;AAAA,GAAa,wBAAwB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/hooks/useWatchFormReset/useWatchFormReset.ts"],"mappings":";UAIiB,wBAAA;EAAA;;;;AAWR;AAqBT;;;;;EArBE,OAAO;AAAA;;AAqB8D;;;;;;;;;;;;;;;;;cAA1D,iBAAA;EAAqB;AAAA,GAAa,wBAAwB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useWatchFormReset/useWatchFormReset.ts","../../../src/hooks/useWatchFormReset/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchFormResetOptions {\n /**\n * Callback that runs whenever a programmatic form reset is observed.\n *\n * Resets are signalled via the uniform `formReset` pub/sub channel. The event\n * is emitted by the wrapped `reset()` method in `useFormContext`.\n *\n * Current primary use case:\n * - `useUniformFieldArray` listens for reset events to normalize stale\n * placeholder rows left by RHF after reset when array defaults are missing.\n */\n onReset: () => void;\n}\n\n/**\n * Hook that watches for programmatic form reset events.\n *\n * It lets consumers run a callback when a programmatic form reset is triggered\n * through the wrapped `reset()` from `useFormContext`.\n *\n * Why this exists:\n * - Components should not infer \"a reset happened\" from field values alone.\n * Value-based heuristics can conflict with valid user interactions.\n * - This hook provides an explicit reset signal so components can run\n * reset-only logic safely.\n *\n * Current usage:\n * - `useUniformFieldArray` uses this hook to handle resets when no default\n * array value was provided. In that case, RHF can leave stale empty\n * placeholder rows. It normalizes only on reset and does not collapse rows\n * during normal editing.\n */\nexport const useWatchFormReset = ({ onReset }: UseWatchFormResetOptions) => {\n const { formReset } = useFormContext();\n\n useEffect(() => {\n const listener = () => {\n onReset();\n };\n\n const unsubscribe = formReset.subscribe(listener);\n return unsubscribe;\n }, [formReset, onReset]);\n};\n","/* v8 ignore start */\n\nexport * from './useWatchFormReset';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB,EAAE,cAAwC;CAC1E,MAAM,EAAE,cAAc,eAAe;CAErC,gBAAgB;EACd,MAAM,iBAAiB;GACrB,QAAQ;EACV;EAGA,OADoB,UAAU,UAAU,QACvB;CACnB,GAAG,CAAC,WAAW,OAAO,CAAC;AACzB"}
@@ -1,88 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useFormContext = require("../../useFormContext-BSIXyfbo.cjs");
3
- let react = require("react");
4
- //#region src/hooks/useWatchUserChange/useWatchUserChange.ts
5
- /**
6
- * Hook that watches for user changes on a specific form field.
7
- *
8
- * Only triggers on manual user input (typing, clicking, selecting),
9
- * NOT on programmatic changes like form.reset() or form.setValue().
10
- * Also does NOT trigger when selecting the same value (e.g., clicking
11
- * an already-selected option in a Select).
12
- *
13
- * This hook subscribes to field changes at the source (useController),
14
- * ensuring immediate and accurate detection of user interactions.
15
- *
16
- * Use cases:
17
- * - Reset dependent fields when parent field changes
18
- * - Set mode-specific default values when a toggle changes
19
- * - Clear form sections based on user selections
20
- * - Trigger side effects only on user interaction
21
- *
22
- * Note: To watch multiple fields, call this hook multiple times.
23
- *
24
- * @example
25
- * ```tsx
26
- * // Reset city and address when user changes country
27
- * useWatchUserChange({
28
- * watch: 'country',
29
- * onChange: (value, { resetField }) => {
30
- * resetField('city');
31
- * resetField('address');
32
- * },
33
- * });
34
- *
35
- * // Set defaults when user changes payment method
36
- * useWatchUserChange({
37
- * watch: 'paymentMethod',
38
- * onChange: (value, { setValue }) => {
39
- * if (value === 'credit') {
40
- * setValue('installments', 3);
41
- * } else {
42
- * setValue('installments', 1);
43
- * }
44
- * },
45
- * });
46
- *
47
- * // Watch multiple fields by calling the hook multiple times
48
- * useWatchUserChange({
49
- * watch: 'category',
50
- * onChange: (value, { resetField }) => {
51
- * resetField('productId');
52
- * },
53
- * });
54
- * useWatchUserChange({
55
- * watch: 'brand',
56
- * onChange: (value, { resetField }) => {
57
- * resetField('productId');
58
- * },
59
- * });
60
- * ```
61
- */
62
- const useWatchUserChange = ({ watch: watchField, onChange }) => {
63
- const { setValue, resetField, reset, userChange } = require_useFormContext.useFormContext();
64
- (0, react.useEffect)(() => {
65
- const listener = (fieldName, value) => {
66
- if (fieldName === watchField) onChange(value, {
67
- setValue,
68
- resetField,
69
- reset
70
- });
71
- };
72
- return userChange.subscribe(listener);
73
- }, [
74
- watchField,
75
- onChange,
76
- setValue,
77
- resetField,
78
- reset,
79
- userChange
80
- ]);
81
- };
82
- //#endregion
83
- //#region src/hooks/useWatchUserChange/index.ts
84
- /* v8 ignore stop */
85
- //#endregion
86
- exports.useWatchUserChange = useWatchUserChange;
87
-
88
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["useFormContext"],"sources":["../../../src/hooks/useWatchUserChange/useWatchUserChange.ts","../../../src/hooks/useWatchUserChange/index.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n * Also does NOT trigger when selecting the same value (e.g., clicking\n * an already-selected option in a Select).\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n","/* v8 ignore start */\n\nexport * from './useWatchUserChange';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnCA,uBAAAA,eAA6B;CAE/B,CAAA,GAAA,MAAA,UAAA,OAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;GAElE,IAAI,cAAc,YAEhB,SAAS,OAAO;IAAE;IAAU;IAAY;GAAM,CAAC;EAEnD;EAMA,OAHoB,WAAW,UAAU,QAGxB;CACnB,GAAG;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;CAAU,CAAC;AACpE"}
@@ -1,80 +0,0 @@
1
- import { FieldValues, Path, UseFormReset, UseFormResetField, UseFormSetValue } from "react-hook-form";
2
-
3
- //#region src/hooks/useWatchUserChange/useWatchUserChange.d.ts
4
- interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {
5
- /** Field name to watch for user changes */
6
- watch: Path<TFieldValues>;
7
- /**
8
- * Callback when watched field is changed by user input.
9
- * Receives the new value and form helpers (setValue, resetField, reset).
10
- */
11
- onChange: (value: unknown, helpers: {
12
- setValue: UseFormSetValue<TFieldValues>;
13
- resetField: UseFormResetField<TFieldValues>;
14
- reset: UseFormReset<TFieldValues>;
15
- }) => void;
16
- }
17
- /**
18
- * Hook that watches for user changes on a specific form field.
19
- *
20
- * Only triggers on manual user input (typing, clicking, selecting),
21
- * NOT on programmatic changes like form.reset() or form.setValue().
22
- * Also does NOT trigger when selecting the same value (e.g., clicking
23
- * an already-selected option in a Select).
24
- *
25
- * This hook subscribes to field changes at the source (useController),
26
- * ensuring immediate and accurate detection of user interactions.
27
- *
28
- * Use cases:
29
- * - Reset dependent fields when parent field changes
30
- * - Set mode-specific default values when a toggle changes
31
- * - Clear form sections based on user selections
32
- * - Trigger side effects only on user interaction
33
- *
34
- * Note: To watch multiple fields, call this hook multiple times.
35
- *
36
- * @example
37
- * ```tsx
38
- * // Reset city and address when user changes country
39
- * useWatchUserChange({
40
- * watch: 'country',
41
- * onChange: (value, { resetField }) => {
42
- * resetField('city');
43
- * resetField('address');
44
- * },
45
- * });
46
- *
47
- * // Set defaults when user changes payment method
48
- * useWatchUserChange({
49
- * watch: 'paymentMethod',
50
- * onChange: (value, { setValue }) => {
51
- * if (value === 'credit') {
52
- * setValue('installments', 3);
53
- * } else {
54
- * setValue('installments', 1);
55
- * }
56
- * },
57
- * });
58
- *
59
- * // Watch multiple fields by calling the hook multiple times
60
- * useWatchUserChange({
61
- * watch: 'category',
62
- * onChange: (value, { resetField }) => {
63
- * resetField('productId');
64
- * },
65
- * });
66
- * useWatchUserChange({
67
- * watch: 'brand',
68
- * onChange: (value, { resetField }) => {
69
- * resetField('productId');
70
- * },
71
- * });
72
- * ```
73
- */
74
- declare const useWatchUserChange: <TFieldValues extends FieldValues = FieldValues>({
75
- watch: watchField,
76
- onChange
77
- }: UseWatchUserChangeOptions<TFieldValues>) => void;
78
- //#endregion
79
- export { UseWatchUserChangeOptions, useWatchUserChange };
80
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"mappings":";;;UAYiB,yBAAA,sBAA+C,WAAA;;EAE9D,KAAA,EAAO,IAAA,CAAK,YAAA;EAF4B;;;;EAOxC,QAAA,GACE,KAAA,WACA,OAAA;IACE,QAAA,EAAU,eAAA,CAAgB,YAAA;IAC1B,UAAA,EAAY,iBAAA,CAAkB,YAAA;IAC9B,KAAA,EAAO,YAAA,CAAa,YAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;AACrB;AA6DL;;;;;;;;;;;;;;;;;;;;;AAKyC;;;;;;;;;;;;;;cAL5B,kBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,KAAA,EAAA,UAAA;EAAA;AAAA,GAGC,yBAAA,CAA0B,YAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"mappings":";;;UAYiB,yBAAA,sBAA+C,WAAA;;EAE9D,KAAA,EAAO,IAAA,CAAK,YAAA;EAF4B;;;;EAOxC,QAAA,GACE,KAAA,WACA,OAAA;IACE,QAAA,EAAU,eAAA,CAAgB,YAAA;IAC1B,UAAA,EAAY,iBAAA,CAAkB,YAAA;IAC9B,KAAA,EAAO,YAAA,CAAa,YAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;AACrB;AA6DL;;;;;;;;;;;;;;;;;;;;;AAKyC;;;;;;;;;;;;;;cAL5B,kBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,KAAA,EAAA,UAAA;EAAA;AAAA,GAGC,yBAAA,CAA0B,YAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useWatchUserChange/useWatchUserChange.ts","../../../src/hooks/useWatchUserChange/index.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n * Also does NOT trigger when selecting the same value (e.g., clicking\n * an already-selected option in a Select).\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n","/* v8 ignore start */\n\nexport * from './useWatchUserChange';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnC,eAA6B;CAE/B,gBAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;GAElE,IAAI,cAAc,YAEhB,SAAS,OAAO;IAAE;IAAU;IAAY;GAAM,CAAC;EAEnD;EAMA,OAHoB,WAAW,UAAU,QAGxB;CACnB,GAAG;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;CAAU,CAAC;AACpE"}
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,6 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_FieldCopyTestIdButton = require("../../FieldCopyTestIdButton-D3D_LmJh.cjs");
6
- exports.default = require_FieldCopyTestIdButton.FieldCopyTestIdButton_default;
@@ -1,14 +0,0 @@
1
- //#region src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.d.ts
2
- interface FieldCopyTestIdButtonProps {
3
- /** CSS class name */
4
- className?: string;
5
- /** HTML data-testid attribute used in e2e tests */
6
- testId: string;
7
- }
8
- declare const FieldCopyTestIdButton: ({
9
- className,
10
- testId
11
- }: FieldCopyTestIdButtonProps) => import("react").JSX.Element;
12
- //#endregion
13
- export { type FieldCopyTestIdButtonProps, FieldCopyTestIdButton as default };
14
- //# sourceMappingURL=index.d.cts.map