@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,120 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_FormContext = require("../FormContext-eCnp-y2P.cjs");
6
- const require_useFormContext = require("../useFormContext-BSIXyfbo.cjs");
7
- let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
8
- let react = require("react");
9
- let react_icons_fa6 = require("react-icons/fa6");
10
- let react_jsx_runtime = require("react/jsx-runtime");
11
- let react_icons_fa = require("react-icons/fa");
12
- let _fuf_stack_pixels_Button = require("@fuf-stack/pixels/Button");
13
- let _fuf_stack_pixels_Card = require("@fuf-stack/pixels/Card");
14
- let _fuf_stack_pixels_Json = require("@fuf-stack/pixels/Json");
15
- //#region src/Form/subcomponents/FormDebugViewer.tsx
16
- /** Renders a form debug panel with information about the current form state */
17
- const FormDebugViewer = ({ className = void 0 }) => {
18
- const { debugMode, formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful }, getValues, setDebugMode, validation: { errors }, subscribe } = require_useFormContext.useFormContext();
19
- const showDebugButton = debugMode === "off";
20
- const showDebugCard = debugMode === "debug" || debugMode === "debug-testids";
21
- const showDebugTestIds = debugMode === "debug-testids";
22
- const [values, setValues] = (0, react.useState)(() => {
23
- return getValues() ?? {};
24
- });
25
- (0, react.useEffect)(() => {
26
- if (!showDebugCard) return;
27
- const subscription = subscribe({
28
- formState: { values: true },
29
- callback: (state) => {
30
- setValues(state.values ?? {});
31
- }
32
- });
33
- return () => {
34
- subscription();
35
- };
36
- }, [showDebugCard]);
37
- const handleShowDebugMode = () => {
38
- setValues(getValues() ?? {});
39
- setDebugMode("debug");
40
- };
41
- if (showDebugButton) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Button.Button, {
42
- ariaLabel: "Enable form debug mode",
43
- className: "fixed bottom-2.5 right-2.5 w-5 text-default-400",
44
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa6.FaBug, {}),
45
- onClick: handleShowDebugMode,
46
- variant: "light"
47
- });
48
- if (!showDebugCard) return null;
49
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_fuf_stack_pixels_Card.Card, {
50
- className: (0, _fuf_stack_pixel_utils.cn)(className),
51
- header: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
52
- className: "flex w-full flex-row justify-between",
53
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
54
- className: "text-lg",
55
- children: "Debug Mode"
56
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Button.Button, {
57
- color: "danger",
58
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa.FaTimes, {}),
59
- onClick: () => {
60
- setDebugMode("off");
61
- },
62
- size: "sm",
63
- variant: "light"
64
- })]
65
- }),
66
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Button.Button, {
67
- className: "mb-4 ml-auto mr-auto",
68
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa6.FaBullseye, {}),
69
- onClick: () => {
70
- setDebugMode(debugMode === "debug" ? "debug-testids" : "debug");
71
- },
72
- variant: showDebugTestIds ? "solid" : "light",
73
- children: showDebugTestIds ? "Hide CopyButton" : "Show CopyButton"
74
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Json.Json, { value: {
75
- values,
76
- errors: errors ?? null,
77
- submit: {
78
- isValid,
79
- isSubmitting,
80
- isSubmitSuccessful,
81
- submitCount
82
- }
83
- } })]
84
- });
85
- };
86
- //#endregion
87
- //#region src/Form/Form.tsx
88
- const IS_TEST = process.env.NODE_ENV === "test";
89
- /**
90
- * Form component that has to wrap every uniform
91
- */
92
- const Form = ({ children, className = void 0, debug = void 0, initialValues = void 0, name = void 0, onSubmit, testId = void 0, validation = void 0, validationTrigger = "all" }) => {
93
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormContext.FormProvider, {
94
- debugModeSettings: debug,
95
- initialValues,
96
- onSubmit,
97
- validation,
98
- validationTrigger,
99
- children: ({ handleSubmit, isValid }) => {
100
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
101
- className: "flex w-full flex-row justify-between gap-6",
102
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
103
- className: (0, _fuf_stack_pixel_utils.cn)("grow", className),
104
- "data-form-is-valid": isValid,
105
- "data-testid": (0, _fuf_stack_pixel_utils.slugify)(testId ?? name ?? ""),
106
- name,
107
- onSubmit: handleSubmit,
108
- children
109
- }), !IS_TEST && !debug?.disable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormDebugViewer, { className: "w-96 shrink" })]
110
- });
111
- }
112
- });
113
- };
114
- //#endregion
115
- //#region src/Form/index.ts
116
- var Form_default = Form;
117
- //#endregion
118
- exports.default = Form_default;
119
-
120
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["useFormContext","Button","FaBug","Card","FaTimes","FaBullseye","Json","FormProvider"],"sources":["../../src/Form/subcomponents/FormDebugViewer.tsx","../../src/Form/Form.tsx","../../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // We intentionally keep the local state + subscription approach here.\n // A previous useSyncExternalStore refactor caused unstable runtime behavior\n // in consuming wizard apps (max update depth loops inside react-json-view).\n // Keeping this explicit state bridge is the currently stable baseline.\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>(() => {\n return getValues() ?? {};\n });\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n // handle show debug mode\n const handleShowDebugMode = () => {\n // Seed current values on open from an event handler (not effect body)\n // to avoid cascading-render lint warnings for sync setState in effects.\n setValues(getValues() ?? {});\n // set debug mode to debug\n setDebugMode('debug');\n };\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n onClick={handleShowDebugMode}\n variant=\"light\"\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n onClick={() => {\n setDebugMode('off');\n }}\n size=\"sm\"\n variant=\"light\"\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n variant={showDebugTestIds ? 'solid' : 'light'}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACEA,uBAAAA,eAAe;CAEnB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAQvC,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,OAAqD;EAClE,OAAO,UAAU,KAAK,CAAC;CACzB,CAAC;CAED,CAAA,GAAA,MAAA,UAAA,OAAgB;EAEd,IAAI,CAAC,eACH;EAGF,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa;GACX,aA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,IAAI,aAAa;;;;AA0BzC,MAAM,QAAQ,EACZ,UACA,YAAY,KAAA,GACZ,QAAQ,KAAA,GACR,gBAAgB,KAAA,GAChB,OAAO,KAAA,GACP,UACA,SAAS,KAAA,GACT,aAAa,KAAA,GACb,oBAAoB,YACL;CACf,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,cAAD;EACE,mBAAmB;EACJ;EACL;EACE;EACO;aAEjB,EAAE,cAAc,cAAc;GAC9B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,WAAU;cAAf,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KACE,YAAA,GAAA,uBAAA,GAAA,CAAc,QAAQ,SAAS;KAC/B,sBAAoB;KACpB,gBAAA,GAAA,uBAAA,QAAA,CAAqB,UAAU,QAAQ,EAAE;KACnC;KACN,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAD,EAAiB,WAAU,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACxEA,IAAA,eAAe"}
@@ -1,43 +0,0 @@
1
- import { t as DebugModeSettings } from "../FormContext-BLWS7bhO.cjs";
2
- import { ReactNode } from "react";
3
- import { VetoInstance } from "@fuf-stack/veto";
4
- import { FieldValues, SubmitHandler } from "react-hook-form";
5
-
6
- //#region src/Form/Form.d.ts
7
- interface FormProps {
8
- /** form children */
9
- children: ReactNode | ReactNode[];
10
- /** CSS class name */
11
- className?: string | string[];
12
- /** settings for from debug mode */
13
- debug?: DebugModeSettings;
14
- /** initial form values */
15
- initialValues?: FieldValues;
16
- /** name of the form */
17
- name?: string;
18
- /** form submit handler */
19
- onSubmit: SubmitHandler<FieldValues>;
20
- /** HTML data-testid attribute used in e2e tests */
21
- testId?: string;
22
- /** veto validation schema */
23
- validation?: VetoInstance;
24
- /** when the validation should be triggered */
25
- validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';
26
- }
27
- /**
28
- * Form component that has to wrap every uniform
29
- */
30
- declare const Form: ({
31
- children,
32
- className,
33
- debug,
34
- initialValues,
35
- name,
36
- onSubmit,
37
- testId,
38
- validation,
39
- validationTrigger
40
- }: FormProps) => import("react").JSX.Element;
41
- //#endregion
42
- export { type FormProps, Form as default };
43
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/Form/Form.tsx"],"mappings":";;;;;;UAYiB,SAAA;;EAEf,QAAA,EAAU,SAAA,GAAY,SAAA;EAFE;EAIxB,SAAA;EAFU;EAIV,KAAA,GAAQ,iBAAA;EAAA;EAER,aAAA,GAAgB,WAAA;EAIQ;EAFxB,IAAA;EAMa;EAJb,QAAA,EAAU,aAAA,CAAc,WAAA;EAIC;EAFzB,MAAA;EAZU;EAcV,UAAA,GAAa,YAAA;EAZb;EAcA,iBAAA;AAAA;;;;cAMI,IAAA;EAAQ,QAAA;EAAA,SAAA;EAAA,KAAA;EAAA,aAAA;EAAA,IAAA;EAAA,QAAA;EAAA,MAAA;EAAA,UAAA;EAAA;AAAA,GAUX,SAAA,qBAAS,GAAA,CAAA,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/Form/Form.tsx"],"mappings":";;;;;;UAYiB,SAAA;;EAEf,QAAA,EAAU,SAAA,GAAY,SAAA;EAFE;EAIxB,SAAA;EAFU;EAIV,KAAA,GAAQ,iBAAA;EAAA;EAER,aAAA,GAAgB,WAAA;EAIQ;EAFxB,IAAA;EAMa;EAJb,QAAA,EAAU,aAAA,CAAc,WAAA;EAIC;EAFzB,MAAA;EAZU;EAcV,UAAA,GAAa,YAAA;EAZb;EAcA,iBAAA;AAAA;;;;cAMI,IAAA;EAAQ,QAAA;EAAA,SAAA;EAAA,KAAA;EAAA,aAAA;EAAA,IAAA;EAAA,QAAA;EAAA,MAAA;EAAA,UAAA;EAAA;AAAA,GAUX,SAAA,qBAAS,GAAA,CAAA,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Form/subcomponents/FormDebugViewer.tsx","../../src/Form/Form.tsx","../../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // We intentionally keep the local state + subscription approach here.\n // A previous useSyncExternalStore refactor caused unstable runtime behavior\n // in consuming wizard apps (max update depth loops inside react-json-view).\n // Keeping this explicit state bridge is the currently stable baseline.\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>(() => {\n return getValues() ?? {};\n });\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n // handle show debug mode\n const handleShowDebugMode = () => {\n // Seed current values on open from an event handler (not effect body)\n // to avoid cascading-render lint warnings for sync setState in effects.\n setValues(getValues() ?? {});\n // set debug mode to debug\n setDebugMode('debug');\n };\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n onClick={handleShowDebugMode}\n variant=\"light\"\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n onClick={() => {\n setDebugMode('off');\n }}\n size=\"sm\"\n variant=\"light\"\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n variant={showDebugTestIds ? 'solid' : 'light'}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACE,eAAe;CAEnB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAQvC,MAAM,CAAC,QAAQ,aAAa,eAAwC;EAClE,OAAO,UAAU,KAAK,CAAC;CACzB,CAAC;CAED,gBAAgB;EAEd,IAAI,CAAC,eACH;EAGF,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa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AAG,QAAQ,SAAS;KAC/B,sBAAoB;KACpB,eAAa,QAAQ,UAAU,QAAQ,EAAE;KACnC;KACN,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,oBAAC,iBAAD,EAAiB,WAAU,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACxEA,IAAA,eAAe"}
@@ -1,20 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { VetoFormattedError, VetoInstance, VetoTypeAny } from "@fuf-stack/veto";
3
- import { FieldValues, Path, SubmitHandler } from "react-hook-form";
4
-
5
- //#region src/Form/subcomponents/FormContext.d.ts
6
- interface DebugModeSettings {
7
- /** disable form debug completely */
8
- disable?: boolean;
9
- /** custom localStorage key to save debug mode state */
10
- localStorageKey?: string;
11
- }
12
- /** Listener function that gets called when a form reset is triggered */
13
- type FormResetListener = () => void;
14
- /**
15
- * Listener function that gets called when a field changes due to user input
16
- */
17
- type UserChangeListener<TFieldValues extends object = object> = (fieldName: Path<TFieldValues>, value: unknown) => void;
18
- //#endregion
19
- export { FormResetListener as n, UserChangeListener as r, DebugModeSettings as t };
20
- //# sourceMappingURL=FormContext-BLWS7bhO.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContext-BLWS7bhO.d.cts","names":[],"sources":["../src/Form/subcomponents/FormContext.tsx"],"mappings":";;;;;UAsBiB,iBAAA;EAAiB;EAEhC,OAAA;EAAA;EAEA,eAAe;AAAA;;KAIL,iBAAA;;AAAiB;AAK7B;KAAY,kBAAA,0CACV,SAAA,EAAW,IAAI,CAAC,YAAA,GAChB,KAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContext-DjJOJKxj.js","names":["FormProvider","HookFormProvider"],"sources":["../src/Form/subcomponents/FormResolver.ts","../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { and, veto } from '@fuf-stack/veto';\n\nimport { toValidationFormat } from '../../helpers';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(() => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n }, []);\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo<VetoTypeAny[]>(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter((schema): schema is VetoTypeAny => {\n return Boolean(schema);\n });\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined =\n clientSchemaValues.reduce<VetoTypeAny | null>(\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (baseValidation && clientSchemasCombined) {\n // Put client validation first so dynamic/domain-specific messages\n // are returned before generic base validation errors.\n const baseSchema = baseValidation.schema as VetoTypeAny;\n return veto(and(clientSchemasCombined, baseSchema));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Render state for formatted validation errors produced by the resolver.\n *\n * `errors` is the value exposed through Uniform context. `hash` is the stable\n * comparison key used to avoid re-rendering context consumers when validation\n * returns an equivalent error object with a new identity.\n */\ninterface ValidationErrorsState {\n /** Formatted validation errors exposed to Uniform consumers. */\n errors: VetoFormattedError | undefined;\n /** JSON hash of `errors`, used as a cheap equality signal. */\n hash: string | undefined;\n}\n\n/**\n * Creates a React Hook Form resolver from an extended validation instance and\n * stores its latest formatted Veto errors as React state.\n *\n * Keeping the resolver errors in state lets Uniform context consumers re-render\n * when validation output changes, while the hash prevents repeated validations\n * with equivalent errors from causing unnecessary updates.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Resolver function plus the latest validation errors and their hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Keep the latest resolver errors in React state so Uniform context consumers\n // re-render when validation output changes. The paired hash lets us skip the\n // state update when a resolver run returns equivalent errors.\n const [validationErrorsState, setValidationErrorsState] =\n useState<ValidationErrorsState>({\n errors: undefined,\n hash: undefined,\n });\n\n /**\n * Updates resolver error state only when the formatted validation result\n * actually changes. Veto/RHF may create new error objects for equivalent\n * validation output, so the hash is the guard against avoidable context\n * refreshes.\n */\n const updateValidationErrors = useCallback(\n (errors: VetoFormattedError | undefined): void => {\n const nextHash = JSON.stringify(errors);\n\n setValidationErrorsState((current) => {\n if (current.hash === nextHash) {\n return current;\n }\n\n return {\n errors,\n hash: nextHash,\n };\n });\n },\n [],\n );\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n updateValidationErrors(result.errors ?? undefined);\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation, updateValidationErrors]);\n\n return {\n resolver,\n validationErrors: validationErrorsState.errors,\n validationErrorsHash: validationErrorsState.hash,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, Path, SubmitHandler } from 'react-hook-form';\n\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport createDebug from 'debug';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toSubmitFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\nconst debug = createDebug('uniform:FormContext');\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\n/** Listener function that gets called when a form reset is triggered */\nexport type FormResetListener = () => void;\n\n/**\n * Listener function that gets called when a field changes due to user input\n */\nexport type UserChangeListener<TFieldValues extends object = object> = (\n fieldName: Path<TFieldValues>,\n value: unknown,\n) => void;\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n * 4. **User Change Tracking**: The `userChange` property provides a pub/sub system for tracking\n * user-initiated field changes (typing, clicking, selecting) - NOT programmatic changes like\n * form.reset() or form.setValue(). Used by the `useWatchUserChange` hook to enable reactive\n * field dependencies.\n * 5. **Form Reset Tracking**: The `formReset` property provides a pub/sub system for tracking\n * programmatic form resets triggered via the wrapped `reset()` from `useFormContext`.\n * Used by hooks like `useWatchFormReset` to run reset-specific normalization logic.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n *\n * IMPORTANT: Context Singleton Pattern for HMR (Hot Module Replacement)\n * =====================================================================\n *\n * We use a global window variable to ensure only ONE context instance exists across\n * hot module reloads during development. This is critical because:\n *\n * **The Problem:**\n * When using Vite/Storybook with Fast Refresh (HMR), editing this file causes it to\n * be re-evaluated. Each re-evaluation runs `React.createContext()` again, creating a\n * NEW context instance. This leads to \"context instance mismatch\":\n *\n * 1. FormProvider (provider) loads and uses context instance A\n * 2. File is edited, HMR triggers\n * 3. SubmitButton (consumer) hot-reloads and imports context instance B\n * 4. Provider writes to instance A, Consumer reads from instance B\n * 5. Result: Consumer sees default values (triggerSubmit = () => undefined)\n * 6. Clicking submit does nothing because it calls the empty default function\n *\n * **The Solution:**\n * By storing the context in `window.__UNIFORM_CONTEXT__`, we ensure:\n * - First load: Create context and store in window\n * - Subsequent HMRs: Reuse the same context from window\n * - All components always reference the SAME context instance\n * - Provider and consumers can properly communicate\n *\n * **Why This Is Safe:**\n * - Only affects development (production has no HMR)\n * - Context type never changes (same interface)\n * - React handles cleanup on unmount normally\n * - No memory leaks (context is lightweight)\n *\n * Without this pattern, you'd need to restart the dev server after every edit\n * to FormContext.tsx to ensure all components use the same context instance.\n */\n\n// Define the context type\ninterface UniformContextType {\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for form debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Form reset tracking (programmatic reset calls) */\n formReset: {\n /**\n * Subscribe to programmatic form resets.\n * Returns an unsubscribe function.\n */\n subscribe: (listener: FormResetListener) => () => void;\n /**\n * Notify all subscribers about a programmatic form reset.\n * Called from useFormContext when reset() is invoked.\n */\n notify: () => void;\n };\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** User change tracking (user input only, not programmatic changes) */\n userChange: {\n /**\n * Subscribe to user field changes.\n * Returns an unsubscribe function.\n */\n subscribe: (listener: UserChangeListener) => () => void;\n /**\n * Notify all subscribers about a user field change.\n * Called from useController when user interacts with a field.\n */\n notify: (fieldName: string, value: unknown) => void;\n };\n /** Form validation configuration */\n validation: {\n /** Base validation schema instance (without client validation) */\n baseInstance?: VetoInstance;\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nif (!(window as any).__UNIFORM_CONTEXT__) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).__UNIFORM_CONTEXT__ = React.createContext<UniformContextType>(\n {\n debugMode: 'off',\n formReset: {\n subscribe: () => {\n return () => {\n return undefined;\n };\n },\n notify: () => {\n return undefined;\n },\n },\n preventSubmit: () => {\n return undefined;\n },\n setDebugMode: () => {\n return undefined;\n },\n triggerSubmit: () => {\n return undefined;\n },\n userChange: {\n subscribe: () => {\n return () => {\n return undefined;\n };\n },\n notify: () => {\n return undefined;\n },\n },\n validation: {\n setClientValidationSchema: () => {\n return undefined;\n },\n },\n },\n );\n debug('Creating new UniformContext instance');\n} else {\n debug(\n 'Reusing existing UniformContext instance from window.__UNIFORM_CONTEXT__',\n );\n}\n\n// Export the singleton context instance from window\n// This ensures all imports get the same context, even after HMR\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const UniformContext = (window as any)\n .__UNIFORM_CONTEXT__ as React.Context<UniformContextType>;\n\ndebug('UniformContext exported', {\n contextExists: !!UniformContext,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n windowContextExists: !!(window as any).__UNIFORM_CONTEXT__,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n contextsMatch: UniformContext === (window as any).__UNIFORM_CONTEXT__,\n});\n\n// Define props for the internal FormProvider component\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for form debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Resolver-backed validation error state\n * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\n * - Form reset pub/sub notifications (`formReset`)\n * - User change pub/sub notifications (`userChange`)\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + reactive validation error state\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues ? toFormFormat(initialValues) : initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Form reset listener registry (stored in ref to avoid re-renders)\n const formResetListenersRef = useRef<Set<FormResetListener>>(new Set());\n\n // Subscribe to form reset notifications\n const subscribeFormReset = useCallback(\n (listener: FormResetListener): (() => void) => {\n formResetListenersRef.current.add(listener);\n return () => {\n formResetListenersRef.current.delete(listener);\n };\n },\n [],\n );\n\n // Notify all subscribers about a programmatic form reset\n const notifyFormReset = useCallback((): void => {\n formResetListenersRef.current.forEach((listener) => {\n listener();\n });\n }, []);\n\n // User change listener registry (stored in ref to avoid re-renders)\n const userChangeListenersRef = useRef<Set<UserChangeListener>>(new Set());\n\n // Subscribe to user changes\n const subscribeUserChange = useCallback(\n (listener: UserChangeListener): (() => void) => {\n userChangeListenersRef.current.add(listener);\n // Return cleanup function to unsubscribe\n return () => {\n userChangeListenersRef.current.delete(listener);\n };\n },\n [],\n );\n\n // Notify all subscribers about user change\n const notifyUserChange = useCallback(\n (fieldName: string, value: unknown): void => {\n // Notify all registered listeners\n userChangeListenersRef.current.forEach((listener) => {\n listener(fieldName as Path<object>, value);\n });\n },\n [],\n );\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n debug('handleSubmit called', {\n preventSubmit,\n formStateIsValid: methods.formState.isValid,\n validationErrors: methods.formState.errors,\n validationTrigger,\n formValues: methods.getValues(),\n });\n\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n debug('⛔ Form submit PREVENTED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n });\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n debug('✓ Form submit ALLOWED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n reason: !methods.formState.isValid\n ? 'Form is invalid (will trigger validation and show errors)'\n : 'Form is valid and preventSubmit is false',\n });\n\n // Convert form data to submission format:\n // - Unwrap flat array wrappers and convert markers\n // - Remove empty strings, nulls, empty arrays, and empty objects\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toSubmitFormat(data) ?? {};\n debug('onSubmit callback called', { submitData });\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n\n debug('handleSubmit completed');\n };\n\n // Memoize the context value so consumers only re-render when context-relevant\n // state changes, including resolver-backed validation errors.\n const contextValue = useMemo(\n () => {\n return {\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n debug('preventSubmit called', {\n previousValue: preventSubmit,\n newValue: prevent,\n formStateIsValid: methods.formState.isValid,\n validationErrors: methods.formState.errors,\n });\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n formReset: {\n subscribe: subscribeFormReset,\n notify: notifyFormReset,\n },\n userChange: {\n subscribe: subscribeUserChange,\n notify: notifyUserChange,\n },\n validation: {\n baseInstance: baseValidation,\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAa,mCAAmC;CAE9C,MAAM,CAAC,yBAAyB,8BAA8B,SAE5D,CAAC,CAAC;CAsBJ,OAAO;EACL;EACA,2BArBgC,cAAc;GAC9C,QAAQ,KAAa,WAA+B;IAElD,4BAA4B,SAAS;KAEnC,IAAI,CAAC,KAAK,QAAQ,CAAC,QACjB,OAAO;KAGT,IAAI,CAAC,QAAQ;MACX,MAAM,GAAG,MAAM,UAAU,GAAG,SAAS;MACrC,OAAO;KACT;KAEA,OAAO;MAAE,GAAG;OAAO,MAAM;KAAO;IAClC,CAAC;GACH;EACF,GAAG,CAAC,CAIsB;CAC1B;AACF;;;;;;;AAQA,MAAa,yBAAyB,mBAAkC;CAEtE,MAAM,EAAE,yBAAyB,8BAC/B,2BAA2B;CAG7B,MAAM,qBAAqB,cACnB;EAEJ,OADa,OAAO,KAAK,uBAAuB,CAAC,CAAC,KACxC,CAAC,CACR,KAAK,QAAQ;GACZ,OAAO,wBAAwB;EACjC,CAAC,CAAC,CACD,QAAQ,WAAkC;GACzC,OAAO,QAAQ,MAAM;EACvB,CAAC;CACL,GAEA,CAAC,uBAAuB,CAC1B;CA+CA,OAAO;EACL,oBA7CyB,cACnB;GACJ,MAAM,oBAAoB,CAAC,CAAC;GAC5B,MAAM,mBAAmB,mBAAmB,SAAS;GAGrD,IAAI,CAAC,qBAAqB,CAAC,kBACzB;GAIF,IAAI,CAAC,kBACH,OAAO;GAIT,MAAM,wBACJ,mBAAmB,QAChB,UAAU,iBAAiB;IAC1B,OAAO,WAAW,IAAI,UA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ACF;EACF;CACF,GAEA;EAAC;EAAW,mBAAmB;EAAS;CAAoB,CAC9D;CAEA,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;YAE9B,oBAACC,cAAD;GAAkB,GAAI;aACnB,SAAS;IAAE;IAAc;GAAQ,CAAC;EACnB,CAAA;CACK,CAAA;AAE7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContext-LgzrDWu1.d.ts","names":[],"sources":["../src/Form/subcomponents/FormContext.tsx"],"mappings":";;;;;UAsBiB,iBAAA;EAAiB;EAEhC,OAAA;EAAA;EAEA,eAAe;AAAA;;KAIL,iBAAA;;AAAiB;AAK7B;KAAY,kBAAA,0CACV,SAAA,EAAW,IAAI,CAAC,YAAA,GAChB,KAAA"}
@@ -1,319 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- const require_helpers_index = require("./helpers/index.cjs");
24
- let react = require("react");
25
- react = __toESM(react, 1);
26
- let _fuf_stack_pixels = require("@fuf-stack/pixels");
27
- let react_jsx_runtime = require("react/jsx-runtime");
28
- let react_hook_form = require("react-hook-form");
29
- let debug = require("debug");
30
- debug = __toESM(debug, 1);
31
- let _fuf_stack_veto = require("@fuf-stack/veto");
32
- //#region src/Form/subcomponents/FormResolver.ts
33
- /**
34
- * Hook that manages client validation schemas state.
35
- *
36
- * Provides a centralized way to add/remove dynamic validation schemas
37
- * that can be combined with base form validation.
38
- *
39
- * @returns Object with client validation state and memoized setter function
40
- */
41
- const useClientValidationManager = () => {
42
- const [clientValidationSchemas, setClientValidationSchemas] = (0, react.useState)({});
43
- return {
44
- clientValidationSchemas,
45
- setClientValidationSchema: (0, react.useMemo)(() => {
46
- return (key, schema) => {
47
- setClientValidationSchemas((prev) => {
48
- if (!prev[key] && !schema) return prev;
49
- if (!schema) {
50
- const { [key]: _removed, ...rest } = prev;
51
- return rest;
52
- }
53
- return {
54
- ...prev,
55
- [key]: schema
56
- };
57
- });
58
- };
59
- }, [])
60
- };
61
- };
62
- /**
63
- * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.
64
- *
65
- * @param baseValidation - Optional base Veto validation schema
66
- * @returns Combined validation instance and client schema setter
67
- */
68
- const useExtendedValidation = (baseValidation) => {
69
- const { clientValidationSchemas, setClientValidationSchema } = useClientValidationManager();
70
- const clientSchemaValues = (0, react.useMemo)(() => {
71
- return Object.keys(clientValidationSchemas).sort().map((key) => {
72
- return clientValidationSchemas[key];
73
- }).filter((schema) => {
74
- return Boolean(schema);
75
- });
76
- }, [clientValidationSchemas]);
77
- return {
78
- extendedValidation: (0, react.useMemo)(() => {
79
- const hasBaseValidation = !!baseValidation;
80
- const hasClientSchemas = clientSchemaValues.length > 0;
81
- if (!hasBaseValidation && !hasClientSchemas) return;
82
- if (!hasClientSchemas) return baseValidation;
83
- const clientSchemasCombined = clientSchemaValues.reduce((combined, clientSchema) => {
84
- return combined ? (0, _fuf_stack_veto.and)(combined, clientSchema) : clientSchema;
85
- }, null);
86
- if (baseValidation && clientSchemasCombined) {
87
- const baseSchema = baseValidation.schema;
88
- return (0, _fuf_stack_veto.veto)((0, _fuf_stack_veto.and)(clientSchemasCombined, baseSchema));
89
- }
90
- if (clientSchemasCombined) return (0, _fuf_stack_veto.veto)(clientSchemasCombined);
91
- return baseValidation;
92
- }, [baseValidation, clientSchemaValues]),
93
- setClientValidationSchema
94
- };
95
- };
96
- /**
97
- * Creates a React Hook Form resolver from an extended validation instance and
98
- * stores its latest formatted Veto errors as React state.
99
- *
100
- * Keeping the resolver errors in state lets Uniform context consumers re-render
101
- * when validation output changes, while the hash prevents repeated validations
102
- * with equivalent errors from causing unnecessary updates.
103
- *
104
- * @param extendedValidation - Extended validation instance from useExtendedValidation
105
- * @returns Resolver function plus the latest validation errors and their hash
106
- */
107
- const useFormResolver = (extendedValidation) => {
108
- const [validationErrorsState, setValidationErrorsState] = (0, react.useState)({
109
- errors: void 0,
110
- hash: void 0
111
- });
112
- /**
113
- * Updates resolver error state only when the formatted validation result
114
- * actually changes. Veto/RHF may create new error objects for equivalent
115
- * validation output, so the hash is the guard against avoidable context
116
- * refreshes.
117
- */
118
- const updateValidationErrors = (0, react.useCallback)((errors) => {
119
- const nextHash = JSON.stringify(errors);
120
- setValidationErrorsState((current) => {
121
- if (current.hash === nextHash) return current;
122
- return {
123
- errors,
124
- hash: nextHash
125
- };
126
- });
127
- }, []);
128
- return {
129
- resolver: (0, react.useMemo)(() => {
130
- if (!extendedValidation) return;
131
- return async (values) => {
132
- const validationValues = require_helpers_index.toValidationFormat(values) ?? {};
133
- const result = await extendedValidation.validateAsync(validationValues);
134
- updateValidationErrors(result.errors ?? void 0);
135
- return {
136
- values: result.data ?? {},
137
- errors: result.errors ?? {}
138
- };
139
- };
140
- }, [extendedValidation, updateValidationErrors]),
141
- validationErrors: validationErrorsState.errors,
142
- validationErrorsHash: validationErrorsState.hash
143
- };
144
- };
145
- //#endregion
146
- //#region src/Form/subcomponents/FormContext.tsx
147
- const debug$1 = (0, debug.default)("uniform:FormContext");
148
- const DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = "uniform:debug-mode";
149
- if (!window.__UNIFORM_CONTEXT__) {
150
- window.__UNIFORM_CONTEXT__ = react.default.createContext({
151
- debugMode: "off",
152
- formReset: {
153
- subscribe: () => {
154
- return () => {};
155
- },
156
- notify: () => {}
157
- },
158
- preventSubmit: () => {},
159
- setDebugMode: () => {},
160
- triggerSubmit: () => {},
161
- userChange: {
162
- subscribe: () => {
163
- return () => {};
164
- },
165
- notify: () => {}
166
- },
167
- validation: { setClientValidationSchema: () => {} }
168
- });
169
- debug$1("Creating new UniformContext instance");
170
- } else debug$1("Reusing existing UniformContext instance from window.__UNIFORM_CONTEXT__");
171
- const UniformContext = window.__UNIFORM_CONTEXT__;
172
- debug$1("UniformContext exported", {
173
- contextExists: !!UniformContext,
174
- windowContextExists: !!window.__UNIFORM_CONTEXT__,
175
- contextsMatch: UniformContext === window.__UNIFORM_CONTEXT__
176
- });
177
- /**
178
- * FormProvider component provides:
179
- * - Veto validation schema context
180
- * - Resolver-backed validation error state
181
- * - Client validation schema management
182
- * - Submit handler with automatic data conversion and submission control with preventSubmit
183
- * - Form Debug Mode state
184
- * - Form reset pub/sub notifications (`formReset`)
185
- * - User change pub/sub notifications (`userChange`)
186
- * - React Hook Form context
187
- */
188
- const FormProvider = ({ children, debugModeSettings = void 0, initialValues = void 0, onSubmit, validation: baseValidation = void 0, validationTrigger }) => {
189
- const [debugMode, setDebugMode] = (0, _fuf_stack_pixels.useLocalStorage)(debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT, "off");
190
- const { extendedValidation, setClientValidationSchema } = useExtendedValidation(baseValidation);
191
- const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation);
192
- const methods = (0, react_hook_form.useForm)({
193
- defaultValues: initialValues ? require_helpers_index.toFormFormat(initialValues) : initialValues,
194
- mode: validationTrigger,
195
- resolver
196
- });
197
- const isValid = methods.formState?.isValid;
198
- const [preventSubmit, setPreventSubmit] = (0, react.useState)(false);
199
- const formResetListenersRef = (0, react.useRef)(/* @__PURE__ */ new Set());
200
- const subscribeFormReset = (0, react.useCallback)((listener) => {
201
- formResetListenersRef.current.add(listener);
202
- return () => {
203
- formResetListenersRef.current.delete(listener);
204
- };
205
- }, []);
206
- const notifyFormReset = (0, react.useCallback)(() => {
207
- formResetListenersRef.current.forEach((listener) => {
208
- listener();
209
- });
210
- }, []);
211
- const userChangeListenersRef = (0, react.useRef)(/* @__PURE__ */ new Set());
212
- const subscribeUserChange = (0, react.useCallback)((listener) => {
213
- userChangeListenersRef.current.add(listener);
214
- return () => {
215
- userChangeListenersRef.current.delete(listener);
216
- };
217
- }, []);
218
- const notifyUserChange = (0, react.useCallback)((fieldName, value) => {
219
- userChangeListenersRef.current.forEach((listener) => {
220
- listener(fieldName, value);
221
- });
222
- }, []);
223
- const handleSubmit = async (e) => {
224
- debug$1("handleSubmit called", {
225
- preventSubmit,
226
- formStateIsValid: methods.formState.isValid,
227
- validationErrors: methods.formState.errors,
228
- validationTrigger,
229
- formValues: methods.getValues()
230
- });
231
- if (methods.formState.isValid && preventSubmit) {
232
- debug$1("⛔ Form submit PREVENTED", {
233
- formStateIsValid: methods.formState.isValid,
234
- preventSubmit
235
- });
236
- console.warn("[FormProvider] form submit was prevented because preventSubmit is true...");
237
- e?.preventDefault();
238
- return Promise.resolve();
239
- }
240
- debug$1("✓ Form submit ALLOWED", {
241
- formStateIsValid: methods.formState.isValid,
242
- preventSubmit,
243
- reason: !methods.formState.isValid ? "Form is invalid (will trigger validation and show errors)" : "Form is valid and preventSubmit is false"
244
- });
245
- const wrappedOnSubmit = (data, event) => {
246
- const submitData = require_helpers_index.toSubmitFormat(data) ?? {};
247
- debug$1("onSubmit callback called", { submitData });
248
- return onSubmit(submitData, event);
249
- };
250
- await methods.handleSubmit(wrappedOnSubmit)(e);
251
- debug$1("handleSubmit completed");
252
- };
253
- const contextValue = (0, react.useMemo)(() => {
254
- return {
255
- debugMode: debugModeSettings?.disable ? "disabled" : debugMode,
256
- preventSubmit: (prevent) => {
257
- debug$1("preventSubmit called", {
258
- previousValue: preventSubmit,
259
- newValue: prevent,
260
- formStateIsValid: methods.formState.isValid,
261
- validationErrors: methods.formState.errors
262
- });
263
- setPreventSubmit(prevent);
264
- },
265
- setClientValidationSchema,
266
- setDebugMode,
267
- triggerSubmit: handleSubmit,
268
- formReset: {
269
- subscribe: subscribeFormReset,
270
- notify: notifyFormReset
271
- },
272
- userChange: {
273
- subscribe: subscribeUserChange,
274
- notify: notifyUserChange
275
- },
276
- validation: {
277
- baseInstance: baseValidation,
278
- instance: extendedValidation,
279
- errors: validationErrors,
280
- setClientValidationSchema
281
- }
282
- };
283
- }, [
284
- debugMode,
285
- debugModeSettings?.disable,
286
- validationErrorsHash
287
- ]);
288
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UniformContext.Provider, {
289
- value: contextValue,
290
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_hook_form.FormProvider, {
291
- ...methods,
292
- children: children({
293
- handleSubmit,
294
- isValid
295
- })
296
- })
297
- });
298
- };
299
- //#endregion
300
- Object.defineProperty(exports, "FormProvider", {
301
- enumerable: true,
302
- get: function() {
303
- return FormProvider;
304
- }
305
- });
306
- Object.defineProperty(exports, "UniformContext", {
307
- enumerable: true,
308
- get: function() {
309
- return UniformContext;
310
- }
311
- });
312
- Object.defineProperty(exports, "__toESM", {
313
- enumerable: true,
314
- get: function() {
315
- return __toESM;
316
- }
317
- });
318
-
319
- //# sourceMappingURL=FormContext-eCnp-y2P.cjs.map