@fuf-stack/uniform 1.11.2 → 1.11.3

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 (350) hide show
  1. package/dist/Checkboxes/index.cjs +1 -1
  2. package/dist/Checkboxes/index.d.cts +1 -1
  3. package/dist/Checkboxes/index.d.ts +1 -1
  4. package/dist/Checkboxes/index.js +1 -1
  5. package/dist/{Checkboxes-BY4UK0Xf.js → Checkboxes-BvW4D5Nm.js} +3 -3
  6. package/dist/{Checkboxes-BY4UK0Xf.js.map → Checkboxes-BvW4D5Nm.js.map} +1 -1
  7. package/dist/{Checkboxes-DgCK-Wq-.cjs → Checkboxes-Cvdazf25.cjs} +4 -4
  8. package/dist/{Checkboxes-DgCK-Wq-.cjs.map → Checkboxes-Cvdazf25.cjs.map} +1 -1
  9. package/dist/FieldArray/index.cjs +1 -1
  10. package/dist/FieldArray/index.d.cts +1 -1
  11. package/dist/FieldArray/index.d.ts +1 -1
  12. package/dist/FieldArray/index.js +1 -1
  13. package/dist/{FieldArray-DBsyUQkU.cjs → FieldArray-CJpDgK_t.cjs} +7 -7
  14. package/dist/{FieldArray-DBsyUQkU.cjs.map → FieldArray-CJpDgK_t.cjs.map} +1 -1
  15. package/dist/{FieldArray-CDLaGvNj.js → FieldArray-omRNwxgy.js} +5 -5
  16. package/dist/{FieldArray-CDLaGvNj.js.map → FieldArray-omRNwxgy.js.map} +1 -1
  17. package/dist/FieldCard/index.cjs +1 -1
  18. package/dist/FieldCard/index.d.cts +1 -1
  19. package/dist/FieldCard/index.d.ts +1 -1
  20. package/dist/FieldCard/index.js +1 -1
  21. package/dist/{FieldCard-NKF358fO.cjs → FieldCard-Dt6QU7o7.cjs} +4 -4
  22. package/dist/{FieldCard-NKF358fO.cjs.map → FieldCard-Dt6QU7o7.cjs.map} +1 -1
  23. package/dist/{FieldCard-C1MCSbPW.js → FieldCard-Dyi-2qr6.js} +3 -3
  24. package/dist/{FieldCard-C1MCSbPW.js.map → FieldCard-Dyi-2qr6.js.map} +1 -1
  25. package/dist/{FieldCopyTestIdButton-BSYcSo2o.cjs → FieldCopyTestIdButton-By-hEZgA.cjs} +2 -2
  26. package/dist/{FieldCopyTestIdButton-BSYcSo2o.cjs.map → FieldCopyTestIdButton-By-hEZgA.cjs.map} +1 -1
  27. package/dist/{FieldCopyTestIdButton-DWPCDJ-s.js → FieldCopyTestIdButton-D9f1B-VS.js} +1 -1
  28. package/dist/{FieldCopyTestIdButton-DWPCDJ-s.js.map → FieldCopyTestIdButton-D9f1B-VS.js.map} +1 -1
  29. package/dist/{FieldValidationError-1hiDEFew.js → FieldValidationError-BYwitb_B.js} +1 -1
  30. package/dist/{FieldValidationError-1hiDEFew.js.map → FieldValidationError-BYwitb_B.js.map} +1 -1
  31. package/dist/{FieldValidationError-CE8R8qry.cjs → FieldValidationError-D64j5gnH.cjs} +2 -2
  32. package/dist/{FieldValidationError-CE8R8qry.cjs.map → FieldValidationError-D64j5gnH.cjs.map} +1 -1
  33. package/dist/Form/index.cjs +1 -1
  34. package/dist/Form/index.d.cts +1 -1
  35. package/dist/Form/index.d.ts +1 -1
  36. package/dist/Form/index.js +1 -1
  37. package/dist/{Form-DRNEwHsi.js → Form-B1fvbnxi.js} +3 -3
  38. package/dist/{Form-DRNEwHsi.js.map → Form-B1fvbnxi.js.map} +1 -1
  39. package/dist/{Form-BsD69fql.cjs → Form-CvnnGF45.cjs} +3 -3
  40. package/dist/{Form-BsD69fql.cjs.map → Form-CvnnGF45.cjs.map} +1 -1
  41. package/dist/{FormContext-CN9n_KdE.js → FormContext-Dl3k1r_k.js} +2 -2
  42. package/dist/{FormContext-CN9n_KdE.js.map → FormContext-Dl3k1r_k.js.map} +1 -1
  43. package/dist/{FormContext-Bb6d8hdG.cjs → FormContext-Lw4YL4-B.cjs} +2 -2
  44. package/dist/{FormContext-Bb6d8hdG.cjs.map → FormContext-Lw4YL4-B.cjs.map} +1 -1
  45. package/dist/Grid/index.cjs +1 -1
  46. package/dist/Grid/index.d.cts +1 -1
  47. package/dist/Grid/index.d.ts +1 -1
  48. package/dist/{Grid-D84e76CE.cjs → Grid-DezBAZbx.cjs} +2 -2
  49. package/dist/{Grid-D84e76CE.cjs.map → Grid-DezBAZbx.cjs.map} +1 -1
  50. package/dist/Input/index.cjs +1 -1
  51. package/dist/Input/index.d.cts +1 -1
  52. package/dist/Input/index.d.ts +1 -1
  53. package/dist/Input/index.js +1 -1
  54. package/dist/{Input-DeTpxiK_.cjs → Input-DR0gCf9q.cjs} +5 -4
  55. package/dist/Input-DR0gCf9q.cjs.map +1 -0
  56. package/dist/{Input-DXMWGTBh.js → Input-DksaHK1Y.js} +4 -3
  57. package/dist/Input-DksaHK1Y.js.map +1 -0
  58. package/dist/RadioBoxes/index.cjs +1 -1
  59. package/dist/RadioBoxes/index.d.cts +1 -1
  60. package/dist/RadioBoxes/index.d.ts +1 -1
  61. package/dist/RadioBoxes/index.js +1 -1
  62. package/dist/{RadioBoxes-BEln4a-B.js → RadioBoxes-DdIHH6B5.js} +2 -2
  63. package/dist/{RadioBoxes-BEln4a-B.js.map → RadioBoxes-DdIHH6B5.js.map} +1 -1
  64. package/dist/{RadioBoxes-gsQGqQCd.cjs → RadioBoxes-h-VLhJ9d.cjs} +3 -3
  65. package/dist/{RadioBoxes-gsQGqQCd.cjs.map → RadioBoxes-h-VLhJ9d.cjs.map} +1 -1
  66. package/dist/RadioTabs/index.cjs +1 -1
  67. package/dist/RadioTabs/index.d.cts +1 -1
  68. package/dist/RadioTabs/index.d.ts +1 -1
  69. package/dist/RadioTabs/index.js +1 -1
  70. package/dist/{RadioTabs-BYpP0tKA.cjs → RadioTabs-D6yF9jE3.cjs} +3 -3
  71. package/dist/{RadioTabs-BYpP0tKA.cjs.map → RadioTabs-D6yF9jE3.cjs.map} +1 -1
  72. package/dist/{RadioTabs-DLr9QiXI.js → RadioTabs-dLdlF91p.js} +2 -2
  73. package/dist/{RadioTabs-DLr9QiXI.js.map → RadioTabs-dLdlF91p.js.map} +1 -1
  74. package/dist/Radios/index.cjs +1 -1
  75. package/dist/Radios/index.d.cts +1 -1
  76. package/dist/Radios/index.d.ts +1 -1
  77. package/dist/Radios/index.js +1 -1
  78. package/dist/{Radios-BCOfnTke.cjs → Radios-D8alyG2f.cjs} +3 -3
  79. package/dist/{Radios-BCOfnTke.cjs.map → Radios-D8alyG2f.cjs.map} +1 -1
  80. package/dist/{Radios-DCXI2kMf.js → Radios-DiZ0Dfmp.js} +2 -2
  81. package/dist/{Radios-DCXI2kMf.js.map → Radios-DiZ0Dfmp.js.map} +1 -1
  82. package/dist/Select/index.cjs +1 -1
  83. package/dist/Select/index.d.cts +1 -1
  84. package/dist/Select/index.d.ts +1 -1
  85. package/dist/Select/index.js +1 -1
  86. package/dist/{Select-CyfEmWiD.js → Select-C9otN8uu.js} +3 -3
  87. package/dist/{Select-CyfEmWiD.js.map → Select-C9otN8uu.js.map} +1 -1
  88. package/dist/{Select-KnPGOO27.cjs → Select-DQVskslz.cjs} +4 -4
  89. package/dist/{Select-KnPGOO27.cjs.map → Select-DQVskslz.cjs.map} +1 -1
  90. package/dist/Slider/index.cjs +1 -1
  91. package/dist/Slider/index.d.cts +1 -1
  92. package/dist/Slider/index.d.ts +1 -1
  93. package/dist/Slider/index.js +1 -1
  94. package/dist/{Slider-C7xxYPgR.cjs → Slider-DwfyCQDM.cjs} +3 -3
  95. package/dist/{Slider-C7xxYPgR.cjs.map → Slider-DwfyCQDM.cjs.map} +1 -1
  96. package/dist/{Slider-Dlhb-9hC.js → Slider-meuLEC2k.js} +2 -2
  97. package/dist/{Slider-Dlhb-9hC.js.map → Slider-meuLEC2k.js.map} +1 -1
  98. package/dist/SubmitButton/index.cjs +1 -1
  99. package/dist/SubmitButton/index.d.cts +1 -1
  100. package/dist/SubmitButton/index.d.ts +1 -1
  101. package/dist/SubmitButton/index.js +1 -1
  102. package/dist/{SubmitButton-CUBItcBn.cjs → SubmitButton-B0kvUqkd.cjs} +3 -3
  103. package/dist/{SubmitButton-CUBItcBn.cjs.map → SubmitButton-B0kvUqkd.cjs.map} +1 -1
  104. package/dist/{SubmitButton-C5f6j0N4.js → SubmitButton-BHP9J9ml.js} +2 -2
  105. package/dist/{SubmitButton-C5f6j0N4.js.map → SubmitButton-BHP9J9ml.js.map} +1 -1
  106. package/dist/Switch/index.cjs +1 -1
  107. package/dist/Switch/index.d.cts +1 -1
  108. package/dist/Switch/index.d.ts +1 -1
  109. package/dist/Switch/index.js +1 -1
  110. package/dist/{Switch--m02Xcq8.js → Switch-DkciIYnD.js} +2 -2
  111. package/dist/{Switch--m02Xcq8.js.map → Switch-DkciIYnD.js.map} +1 -1
  112. package/dist/{Switch-6LyeZHJh.cjs → Switch-Ds0gDzjR.cjs} +3 -3
  113. package/dist/{Switch-6LyeZHJh.cjs.map → Switch-Ds0gDzjR.cjs.map} +1 -1
  114. package/dist/SwitchBox/index.cjs +1 -1
  115. package/dist/SwitchBox/index.d.cts +1 -1
  116. package/dist/SwitchBox/index.d.ts +1 -1
  117. package/dist/SwitchBox/index.js +1 -1
  118. package/dist/{SwitchBox-D0-e-pbM.js → SwitchBox-B6Z4rtWt.js} +2 -2
  119. package/dist/{SwitchBox-D0-e-pbM.js.map → SwitchBox-B6Z4rtWt.js.map} +1 -1
  120. package/dist/{SwitchBox-CtGiQdys.cjs → SwitchBox-B9JqwDtN.cjs} +3 -3
  121. package/dist/{SwitchBox-CtGiQdys.cjs.map → SwitchBox-B9JqwDtN.cjs.map} +1 -1
  122. package/dist/TextArea/index.cjs +1 -1
  123. package/dist/TextArea/index.d.cts +1 -1
  124. package/dist/TextArea/index.js +1 -1
  125. package/dist/{TextArea-PtdSABZS.cjs → TextArea-BqQtlPSV.cjs} +5 -4
  126. package/dist/{TextArea-PtdSABZS.cjs.map → TextArea-BqQtlPSV.cjs.map} +1 -1
  127. package/dist/{TextArea-BiSnvJ69.js → TextArea-DAx49KI6.js} +4 -3
  128. package/dist/{TextArea-BiSnvJ69.js.map → TextArea-DAx49KI6.js.map} +1 -1
  129. package/dist/helpers/index.cjs +2 -1
  130. package/dist/helpers/index.d.cts +164 -2
  131. package/dist/helpers/index.d.cts.map +1 -0
  132. package/dist/helpers/index.d.ts +164 -2
  133. package/dist/helpers/index.d.ts.map +1 -0
  134. package/dist/helpers/index.js +2 -2
  135. package/dist/{helpers-B-CJOBt3.js → helpers-CCINRgQk.js} +43 -2
  136. package/dist/helpers-CCINRgQk.js.map +1 -0
  137. package/dist/{helpers-B84E9vHd.cjs → helpers-nYTmL2gX.cjs} +49 -2
  138. package/dist/helpers-nYTmL2gX.cjs.map +1 -0
  139. package/dist/hooks/useClientValidation/index.cjs +1 -1
  140. package/dist/hooks/useClientValidation/index.d.cts +1 -1
  141. package/dist/hooks/useClientValidation/index.d.ts +1 -1
  142. package/dist/hooks/useClientValidation/index.js +1 -1
  143. package/dist/hooks/useController/index.cjs +1 -1
  144. package/dist/hooks/useController/index.d.cts +1 -1
  145. package/dist/hooks/useController/index.d.ts +2 -1
  146. package/dist/hooks/useController/index.js +1 -1
  147. package/dist/hooks/useFormContext/index.cjs +1 -1
  148. package/dist/hooks/useFormContext/index.d.cts +1 -1
  149. package/dist/hooks/useFormContext/index.d.ts +1 -1
  150. package/dist/hooks/useFormContext/index.js +1 -1
  151. package/dist/hooks/useInput/index.cjs +1 -1
  152. package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
  153. package/dist/hooks/useInputValueDebounce/index.d.cts +1 -1
  154. package/dist/hooks/useInputValueDebounce/index.d.ts +1 -1
  155. package/dist/hooks/useInputValueDebounce/index.js +1 -1
  156. package/dist/hooks/useInputValueTransform/index.cjs +1 -1
  157. package/dist/hooks/useInputValueTransform/index.d.cts +1 -1
  158. package/dist/hooks/useInputValueTransform/index.d.ts +1 -1
  159. package/dist/hooks/useInputValueTransform/index.js +1 -1
  160. package/dist/hooks/useUniformField/index.cjs +1 -1
  161. package/dist/hooks/useUniformField/index.d.cts +1 -1
  162. package/dist/hooks/useUniformField/index.d.ts +3 -3
  163. package/dist/hooks/useUniformField/index.js +1 -1
  164. package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
  165. package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
  166. package/dist/hooks/useUniformFieldArray/index.d.ts +4 -24
  167. package/dist/hooks/useUniformFieldArray/index.js +1 -1
  168. package/dist/hooks/useWatchUserChange/index.cjs +1 -1
  169. package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
  170. package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
  171. package/dist/hooks/useWatchUserChange/index.js +1 -1
  172. package/dist/{index-C1PUx1tH.d.ts → index-0wXxS5M7.d.ts} +7 -7
  173. package/dist/index-0wXxS5M7.d.ts.map +1 -0
  174. package/dist/{index-DvB46QAb.d.ts → index-1Egh73pR.d.ts} +3 -3
  175. package/dist/{index-DvB46QAb.d.ts.map → index-1Egh73pR.d.ts.map} +1 -1
  176. package/dist/{index-DmMenZfj.d.ts → index-3v_vja2i.d.ts} +6 -6
  177. package/dist/{index-DmMenZfj.d.ts.map → index-3v_vja2i.d.ts.map} +1 -1
  178. package/dist/{index-BTTo_ufh.d.ts → index-7mx-IcDp.d.ts} +3 -3
  179. package/dist/{index-BTTo_ufh.d.ts.map → index-7mx-IcDp.d.ts.map} +1 -1
  180. package/dist/{index-WogV9uVV.d.cts → index-BDV3JVoX.d.cts} +7 -7
  181. package/dist/{index-WogV9uVV.d.cts.map → index-BDV3JVoX.d.cts.map} +1 -1
  182. package/dist/{index-DxdaxM3o.d.cts → index-BFLKkqA3.d.ts} +2 -2
  183. package/dist/{index-Edx7MxXu.d.ts.map → index-BFLKkqA3.d.ts.map} +1 -1
  184. package/dist/{index-DG9C0kHA.d.ts → index-BGXgvZKr.d.ts} +35 -35
  185. package/dist/{index-DG9C0kHA.d.ts.map → index-BGXgvZKr.d.ts.map} +1 -1
  186. package/dist/{index-CVnn6mEI.d.ts → index-BSjUaHEO.d.cts} +4 -4
  187. package/dist/{index-BITJ-CZL.d.cts.map → index-BSjUaHEO.d.cts.map} +1 -1
  188. package/dist/{index-jmQP58tO.d.cts → index-B_aIzCcx.d.cts} +3 -3
  189. package/dist/{index-jmQP58tO.d.cts.map → index-B_aIzCcx.d.cts.map} +1 -1
  190. package/dist/{index-BITJ-CZL.d.cts → index-Bcppi5O7.d.ts} +4 -4
  191. package/dist/{index-CVnn6mEI.d.ts.map → index-Bcppi5O7.d.ts.map} +1 -1
  192. package/dist/{index-Bj_lpc5r.d.cts → index-C2A_i57R.d.cts} +21 -21
  193. package/dist/index-C2A_i57R.d.cts.map +1 -0
  194. package/dist/index-CFBmva_r.d.ts +1 -0
  195. package/dist/{index-CSBE6Et0.d.cts → index-CHNp5R5N.d.cts} +6 -6
  196. package/dist/{index-CSBE6Et0.d.cts.map → index-CHNp5R5N.d.cts.map} +1 -1
  197. package/dist/{index-BL0DnIzh.d.ts → index-CHXv_rNR.d.ts} +3 -3
  198. package/dist/{index-BL0DnIzh.d.ts.map → index-CHXv_rNR.d.ts.map} +1 -1
  199. package/dist/{index--E2ZsMya.d.ts → index-CTp4vdDb.d.ts} +6 -6
  200. package/dist/{index--E2ZsMya.d.ts.map → index-CTp4vdDb.d.ts.map} +1 -1
  201. package/dist/{index-F11geOHD.d.ts → index-CUn9q5KD.d.ts} +6 -6
  202. package/dist/{index-F11geOHD.d.ts.map → index-CUn9q5KD.d.ts.map} +1 -1
  203. package/dist/{index-BxA_pJWn.d.cts → index-CZyNkPDq.d.ts} +22 -22
  204. package/dist/{index-C-2nxT8D.d.ts.map → index-CZyNkPDq.d.ts.map} +1 -1
  205. package/dist/{index-C-2nxT8D.d.ts → index-CeYRsehb.d.cts} +22 -22
  206. package/dist/index-CeYRsehb.d.cts.map +1 -0
  207. package/dist/{index-DRij_w43.d.cts → index-CiF2KXB7.d.cts} +6 -6
  208. package/dist/{index-DRij_w43.d.cts.map → index-CiF2KXB7.d.cts.map} +1 -1
  209. package/dist/{index-DNkZrb7P.d.cts → index-CjJHVJwD.d.cts} +35 -35
  210. package/dist/{index-DNkZrb7P.d.cts.map → index-CjJHVJwD.d.cts.map} +1 -1
  211. package/dist/{index-D38wOL-M.d.ts → index-CnsR8nkm.d.cts} +34 -34
  212. package/dist/index-CnsR8nkm.d.cts.map +1 -0
  213. package/dist/{index-CGnr_e53.d.ts → index-CqGabrzW.d.cts} +38 -38
  214. package/dist/index-CqGabrzW.d.cts.map +1 -0
  215. package/dist/{index-CYdvpGJF.d.cts → index-CuvvZMop.d.cts} +3 -3
  216. package/dist/{index-CYdvpGJF.d.cts.map → index-CuvvZMop.d.cts.map} +1 -1
  217. package/dist/{index-BWNJdLDV.d.ts → index-DNFUttM8.d.ts} +21 -21
  218. package/dist/{index-BWNJdLDV.d.ts.map → index-DNFUttM8.d.ts.map} +1 -1
  219. package/dist/{index-BQDEnYTq.d.ts → index-DVRtBywt.d.ts} +1 -1
  220. package/dist/{index-BQDEnYTq.d.ts.map → index-DVRtBywt.d.ts.map} +1 -1
  221. package/dist/{index-oyX8xu0F.d.cts → index-D_WidR7r.d.cts} +6 -6
  222. package/dist/{index-oyX8xu0F.d.cts.map → index-D_WidR7r.d.cts.map} +1 -1
  223. package/dist/index-D_egu-QT.d.cts +264 -0
  224. package/dist/index-D_egu-QT.d.cts.map +1 -0
  225. package/dist/index-DajjPPWM.d.ts +264 -0
  226. package/dist/index-DajjPPWM.d.ts.map +1 -0
  227. package/dist/{index-Bo_n9sse.d.cts → index-DcYFLiul.d.cts} +48 -48
  228. package/dist/index-DcYFLiul.d.cts.map +1 -0
  229. package/dist/index-DnzC0GCS.d.ts.map +1 -1
  230. package/dist/{index-Edx7MxXu.d.ts → index-DvF_C1Bz.d.cts} +3 -3
  231. package/dist/{index-DxdaxM3o.d.cts.map → index-DvF_C1Bz.d.cts.map} +1 -1
  232. package/dist/{index-Cb0AgRRa.d.cts → index-cadUZZIY.d.cts} +3 -3
  233. package/dist/{index-Cb0AgRRa.d.cts.map → index-cadUZZIY.d.cts.map} +1 -1
  234. package/dist/{index-PU5WNOH9.d.cts → index-g9TZhGnE.d.cts} +3 -3
  235. package/dist/{index-PU5WNOH9.d.cts.map → index-g9TZhGnE.d.cts.map} +1 -1
  236. package/dist/index-lQ_hGQ08.d.cts +1 -0
  237. package/dist/{index-C0L7GvgN.d.cts → index-op7zETAQ.d.ts} +34 -34
  238. package/dist/index-op7zETAQ.d.ts.map +1 -0
  239. package/dist/{index-DoS0lVRe.d.cts → index-yVkU2v6b.d.ts} +37 -37
  240. package/dist/{index-CGnr_e53.d.ts.map → index-yVkU2v6b.d.ts.map} +1 -1
  241. package/dist/index.cjs +28 -27
  242. package/dist/index.d.cts +27 -27
  243. package/dist/index.d.ts +27 -26
  244. package/dist/index.js +26 -26
  245. package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
  246. package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
  247. package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
  248. package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
  249. package/dist/partials/FieldValidationError/index.cjs +1 -1
  250. package/dist/partials/FieldValidationError/index.d.cts +1 -1
  251. package/dist/partials/FieldValidationError/index.d.ts +1 -1
  252. package/dist/partials/FieldValidationError/index.js +1 -1
  253. package/dist/{useClientValidation-DJ4JuN_9.d.ts → useClientValidation-Bg0q3Axc.d.ts} +3 -3
  254. package/dist/{useClientValidation-DJ4JuN_9.d.ts.map → useClientValidation-Bg0q3Axc.d.ts.map} +1 -1
  255. package/dist/{useClientValidation-BnnscAEe.js → useClientValidation-BrTtRnqi.js} +3 -3
  256. package/dist/{useClientValidation-BnnscAEe.js.map → useClientValidation-BrTtRnqi.js.map} +1 -1
  257. package/dist/{useClientValidation-BQqwz628.d.cts → useClientValidation-BvPDQmf6.d.cts} +3 -3
  258. package/dist/{useClientValidation-BQqwz628.d.cts.map → useClientValidation-BvPDQmf6.d.cts.map} +1 -1
  259. package/dist/{useClientValidation-CmYVGlLr.cjs → useClientValidation-CdC7lEYP.cjs} +4 -4
  260. package/dist/{useClientValidation-CmYVGlLr.cjs.map → useClientValidation-CdC7lEYP.cjs.map} +1 -1
  261. package/dist/{useController-C_MZLZIp.d.cts → useController-BArZd2Vp.d.cts} +1 -1
  262. package/dist/{useController-C_MZLZIp.d.cts.map → useController-BArZd2Vp.d.cts.map} +1 -1
  263. package/dist/{useController-CkmO5CLh.cjs → useController-BBxji1nQ.cjs} +3 -3
  264. package/dist/{useController-CkmO5CLh.cjs.map → useController-BBxji1nQ.cjs.map} +1 -1
  265. package/dist/{useController-hjpJQf0w.d.ts → useController-MVHJ7WFp.d.ts} +1 -1
  266. package/dist/{useController-hjpJQf0w.d.ts.map → useController-MVHJ7WFp.d.ts.map} +1 -1
  267. package/dist/{useController-CumIERks.js → useController-g0AlWM__.js} +3 -3
  268. package/dist/{useController-CumIERks.js.map → useController-g0AlWM__.js.map} +1 -1
  269. package/dist/{useFormContext-B083Y-kw.d.cts → useFormContext--yod5xzQ.d.cts} +3 -3
  270. package/dist/useFormContext--yod5xzQ.d.cts.map +1 -0
  271. package/dist/{useFormContext-JCm1UR_e.js → useFormContext-BFoXZNkp.js} +3 -3
  272. package/dist/{useFormContext-JCm1UR_e.js.map → useFormContext-BFoXZNkp.js.map} +1 -1
  273. package/dist/{useFormContext-Bp0EODoO.cjs → useFormContext-CEr3zcL6.cjs} +3 -3
  274. package/dist/{useFormContext-Bp0EODoO.cjs.map → useFormContext-CEr3zcL6.cjs.map} +1 -1
  275. package/dist/{useFormContext-B2TS6xq0.d.ts → useFormContext-Cw6aAhos.d.ts} +3 -3
  276. package/dist/useFormContext-Cw6aAhos.d.ts.map +1 -0
  277. package/dist/{useInputValueDebounce-B5b-v8Hc.d.cts → useInputValueDebounce-DI1C6oaU.d.cts} +5 -1
  278. package/dist/useInputValueDebounce-DI1C6oaU.d.cts.map +1 -0
  279. package/dist/{useInputValueDebounce-DaH5ONlQ.js → useInputValueDebounce-Dop_8_OK.js} +12 -3
  280. package/dist/useInputValueDebounce-Dop_8_OK.js.map +1 -0
  281. package/dist/{useInputValueDebounce-BcUyaS94.cjs → useInputValueDebounce-TiNR4jtG.cjs} +13 -4
  282. package/dist/useInputValueDebounce-TiNR4jtG.cjs.map +1 -0
  283. package/dist/{useInputValueDebounce-DoRuSF6R.d.ts → useInputValueDebounce-fhmVn1aO.d.ts} +5 -1
  284. package/dist/useInputValueDebounce-fhmVn1aO.d.ts.map +1 -0
  285. package/dist/{useInputValueTransform-DFPA3KVy.cjs → useInputValueTransform-BNmfaj5D.cjs} +4 -3
  286. package/dist/{useInputValueTransform-DFPA3KVy.cjs.map → useInputValueTransform-BNmfaj5D.cjs.map} +1 -1
  287. package/dist/{useInputValueTransform-D7LfyYRe.d.ts → useInputValueTransform-BV8o0PMI.d.cts} +3 -2
  288. package/dist/useInputValueTransform-BV8o0PMI.d.cts.map +1 -0
  289. package/dist/{useInputValueTransform-aiIf8lq5.js → useInputValueTransform-CMNC21vX.js} +3 -2
  290. package/dist/{useInputValueTransform-aiIf8lq5.js.map → useInputValueTransform-CMNC21vX.js.map} +1 -1
  291. package/dist/{useInputValueTransform-BID-CQ-y.d.cts → useInputValueTransform-Cc0qEsnS.d.ts} +3 -2
  292. package/dist/useInputValueTransform-Cc0qEsnS.d.ts.map +1 -0
  293. package/dist/{useUniformField-B2OZ-Z1G.d.cts → useUniformField-B2zQtEbr.d.cts} +4 -4
  294. package/dist/{useUniformField-B2OZ-Z1G.d.cts.map → useUniformField-B2zQtEbr.d.cts.map} +1 -1
  295. package/dist/{useUniformField-gU4qYUwL.js → useUniformField-BKVVns0E.js} +34 -8
  296. package/dist/useUniformField-BKVVns0E.js.map +1 -0
  297. package/dist/{useUniformField-Bj23Kvbs.cjs → useUniformField-D6fwSjrH.cjs} +35 -9
  298. package/dist/useUniformField-D6fwSjrH.cjs.map +1 -0
  299. package/dist/{useUniformField-CwEHonNe.d.ts → useUniformField-RxZqXMuD.d.ts} +4 -4
  300. package/dist/{useUniformField-CwEHonNe.d.ts.map → useUniformField-RxZqXMuD.d.ts.map} +1 -1
  301. package/dist/{useUniformFieldArray-CXoWvu6m.d.ts → useUniformFieldArray-B_c55CnX.d.ts} +4 -4
  302. package/dist/useUniformFieldArray-B_c55CnX.d.ts.map +1 -0
  303. package/dist/{useUniformFieldArray-B5PyxL1P.js → useUniformFieldArray-BwE634m6.js} +4 -4
  304. package/dist/useUniformFieldArray-BwE634m6.js.map +1 -0
  305. package/dist/{useUniformFieldArray-G1lokW7x.cjs → useUniformFieldArray-Byfmzq97.cjs} +5 -5
  306. package/dist/useUniformFieldArray-Byfmzq97.cjs.map +1 -0
  307. package/dist/{useUniformFieldArray-qtJMEosJ.d.cts → useUniformFieldArray-WRuIMhw6.d.cts} +4 -4
  308. package/dist/useUniformFieldArray-WRuIMhw6.d.cts.map +1 -0
  309. package/dist/{useWatchUserChange-BAdiqg2q.d.ts → useWatchUserChange-Bf5JKDJJ.d.ts} +1 -1
  310. package/dist/{useWatchUserChange-BAdiqg2q.d.ts.map → useWatchUserChange-Bf5JKDJJ.d.ts.map} +1 -1
  311. package/dist/{useWatchUserChange-COVdHmki.d.cts → useWatchUserChange-Br4Q7syM.d.cts} +1 -1
  312. package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-Br4Q7syM.d.cts.map} +1 -1
  313. package/dist/{useWatchUserChange-BnxYE-0b.cjs → useWatchUserChange-TMfaTCcp.cjs} +3 -3
  314. package/dist/{useWatchUserChange-BnxYE-0b.cjs.map → useWatchUserChange-TMfaTCcp.cjs.map} +1 -1
  315. package/dist/{useWatchUserChange-C1ezpj0t.js → useWatchUserChange-fZy6nGtD.js} +2 -2
  316. package/dist/{useWatchUserChange-C1ezpj0t.js.map → useWatchUserChange-fZy6nGtD.js.map} +1 -1
  317. package/package.json +3 -3
  318. package/dist/Input-DXMWGTBh.js.map +0 -1
  319. package/dist/Input-DeTpxiK_.cjs.map +0 -1
  320. package/dist/helpers-B-CJOBt3.js.map +0 -1
  321. package/dist/helpers-B84E9vHd.cjs.map +0 -1
  322. package/dist/index-Bj_lpc5r.d.cts.map +0 -1
  323. package/dist/index-Bo_n9sse.d.cts.map +0 -1
  324. package/dist/index-BxA_pJWn.d.cts.map +0 -1
  325. package/dist/index-C0L7GvgN.d.cts.map +0 -1
  326. package/dist/index-C1PUx1tH.d.ts.map +0 -1
  327. package/dist/index-CADnFWHq.d.ts +0 -264
  328. package/dist/index-CADnFWHq.d.ts.map +0 -1
  329. package/dist/index-D38wOL-M.d.ts.map +0 -1
  330. package/dist/index-DoS0lVRe.d.cts.map +0 -1
  331. package/dist/index-G0IgQWoU.d.cts +0 -134
  332. package/dist/index-G0IgQWoU.d.cts.map +0 -1
  333. package/dist/index-UjKqRe-8.d.ts +0 -134
  334. package/dist/index-UjKqRe-8.d.ts.map +0 -1
  335. package/dist/index-sJZ434Sg.d.cts +0 -264
  336. package/dist/index-sJZ434Sg.d.cts.map +0 -1
  337. package/dist/useFormContext-B083Y-kw.d.cts.map +0 -1
  338. package/dist/useFormContext-B2TS6xq0.d.ts.map +0 -1
  339. package/dist/useInputValueDebounce-B5b-v8Hc.d.cts.map +0 -1
  340. package/dist/useInputValueDebounce-BcUyaS94.cjs.map +0 -1
  341. package/dist/useInputValueDebounce-DaH5ONlQ.js.map +0 -1
  342. package/dist/useInputValueDebounce-DoRuSF6R.d.ts.map +0 -1
  343. package/dist/useInputValueTransform-BID-CQ-y.d.cts.map +0 -1
  344. package/dist/useInputValueTransform-D7LfyYRe.d.ts.map +0 -1
  345. package/dist/useUniformField-Bj23Kvbs.cjs.map +0 -1
  346. package/dist/useUniformField-gU4qYUwL.js.map +0 -1
  347. package/dist/useUniformFieldArray-B5PyxL1P.js.map +0 -1
  348. package/dist/useUniformFieldArray-CXoWvu6m.d.ts.map +0 -1
  349. package/dist/useUniformFieldArray-G1lokW7x.cjs.map +0 -1
  350. package/dist/useUniformFieldArray-qtJMEosJ.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FormContext-CN9n_KdE.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 { useMemo, useRef, 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(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\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 = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\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 * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\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 validationErrors.current = 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]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\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, toValidationFormat } 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/**\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 *\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 from debug mode */\n debugModeSettings?: DebugModeSettings;\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 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 FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from 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 * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\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 + get current validation errors\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 // 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 nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(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 to prevent re-renders\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 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,y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,cAAc;IACd,UAAU;IACV,QAAQ;IACR;IACD;GACF;IAGH;EAAC;EAAW,mBAAmB;EAAS;EAAqB,CAC9D;AAED,QACE,oBAAC,eAAe;EAAS,OAAO;YAE9B,oBAACC;GAAiB,GAAI;aACnB,SAAS;IAAE;IAAc;IAAS,CAAC;IACnB;GACK;;AAI9B,0BAAeD"}
1
+ {"version":3,"file":"FormContext-Dl3k1r_k.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 { useMemo, useRef, 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(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\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 = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\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 * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\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 validationErrors.current = 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]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\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, toValidationFormat } 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/**\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 *\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 from debug mode */\n debugModeSettings?: DebugModeSettings;\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 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 FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from 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 * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\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 + get current validation errors\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 // 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 nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(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 to prevent re-renders\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 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,EAAE,CAAC;AAsBL,QAAO;EACL;EACA,2BArBgC,cAAc;AAC9C,WAAQ,KAAa,WAA+B;AAElD,gCAA4B,SAAS;AAEnC,SAAI,CAAC,KAAK,QAAQ,CAAC,OACjB,QAAO;AAGT,SAAI,CAAC,QAAQ;MACX,MAAM,GAAG,MAAM,UAAU,GAAG,SAAS;AACrC,aAAO;;AAGT,YAAO;MAAE,GAAG;OAAO,MAAM;MAAQ;MACjC;;KAEH,EAAE,CAAC;EAKL;;;;;;;;AASH,MAAa,yBAAyB,mBAAkC;CAEtE,MAAM,EAAE,yBAAyB,8BAC/B,4BAA4B;CAG9B,MAAM,qBAAqB,cACnB;AAEJ,SADa,OAAO,KAAK,wBAAwB,CAAC,MAAM,CAErD,KAAK,QAAQ;AACZ,UAAO,wBAAwB;IAC/B,CACD,OAAO,QAAQ;IAGpB,CAAC,wBAAwB,CAC1B;AA4CD,QAAO;EACL,oBA1CyB,cACnB;GACJ,MAAM,oBAAoB,CAAC,CAAC;GAC5B,MAAM,mBAAmB,mBAAmB,SAAS;AAGrD,OAAI,CAAC,qBAAqB,CAAC,iBACzB;AAIF,OAAI,CAAC,iBACH,QAAO;GAIT,MAAM,wBAAwB,mBAAmB,QAE9C,UAAU,iBAAiB;AAC1B,WAAO,WAAW,IAAI,UAAU,aAAa,GAAG;MAElD,KACD;AAGD,OAAI,qBAAqB,sBACvB,QAAO,KAAK,IAAI,eAAe,QAAQ,sBAAsB,CAAC;AAIhE,OAAI,sBACF,QAA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,eAAe,cACb;AACJ,SAAO;GAGL,WAAW,mBAAmB,UAAU,aAAa;GACrD,gBAAgB,YAAqB;AACnC,UAAM,wBAAwB;KAC5B,eAAe;KACf,UAAU;KACV,kBAAkB,QAAQ,UAAU;KACpC,kBAAkB,QAAQ,UAAU;KACrC,CAAC;AACF,qBAAiB,QAAQ;;GAE3B;GACA;GACA,eAAe;GACf,YAAY;IACV,WAAW;IACX,QAAQ;IACT;GACD,YAAY;IACV,cAAc;IACd,UAAU;IACV,QAAQ;IACR;IACD;GACF;IAGH;EAAC;EAAW,mBAAmB;EAAS;EAAqB,CAC9D;AAED,QACE,oBAAC,eAAe;EAAS,OAAO;YAE9B,oBAACC;GAAiB,GAAI;aACnB,SAAS;IAAE;IAAc;IAAS,CAAC;IACnB;GACK;;AAI9B,0BAAeD"}
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_helpers = require('./helpers-B84E9vHd.cjs');
28
+ const require_helpers = require('./helpers-nYTmL2gX.cjs');
29
29
  let react = require("react");
30
30
  react = __toESM(react);
31
31
  let _fuf_stack_pixels = require("@fuf-stack/pixels");
@@ -272,4 +272,4 @@ Object.defineProperty(exports, '__toESM', {
272
272
  return __toESM;
273
273
  }
274
274
  });
275
- //# sourceMappingURL=FormContext-Bb6d8hdG.cjs.map
275
+ //# sourceMappingURL=FormContext-Lw4YL4-B.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormContext-Bb6d8hdG.cjs","names":["toValidationFormat","debug","React","toFormFormat","toValidationFormat","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 { useMemo, useRef, 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(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\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 = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\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 * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\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 validationErrors.current = 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]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\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, toValidationFormat } 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/**\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 *\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 from debug mode */\n debugModeSettings?: DebugModeSettings;\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 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 FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from 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 * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\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 + get current validation errors\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 // 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 nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(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 to prevent re-renders\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 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,kDAE9B,EAAE,CAAC;AAsBL,QAAO;EACL;EACA,oDArB8C;AAC9C,WAAQ,KAAa,WAA+B;AAElD,gCAA4B,SAAS;AAEnC,SAAI,CAAC,KAAK,QAAQ,CAAC,OACjB,QAAO;AAGT,SAAI,CAAC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ormFormat","toValidationFormat","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 { useMemo, useRef, 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(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\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 = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\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 * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\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 validationErrors.current = 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]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\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, toValidationFormat } 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/**\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 *\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 from debug mode */\n debugModeSettings?: DebugModeSettings;\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 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 FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from 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 * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\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 + get current validation errors\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 // 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 nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(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 to prevent re-renders\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 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":";;;;;;;;;;;;;;;;;;;;;;;;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D;GACF;IAGH;EAAC;EAAW,mBAAmB;EAAS;EAAqB,CAC9D;AAED,QACE,2CAAC,eAAe;EAAS,OAAO;YAE9B,2CAACC;GAAiB,GAAI;aACnB,SAAS;IAAE;IAAc;IAAS,CAAC;IACnB;GACK;;AAI9B,0BAAe"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_Grid = require('../Grid-D84e76CE.cjs');
2
+ const require_Grid = require('../Grid-DezBAZbx.cjs');
3
3
 
4
4
  exports.Grid = require_Grid.Grid_default$1;
5
5
  exports.default = require_Grid.Grid_default;
@@ -1,2 +1,2 @@
1
- import { n as GridProps, t as Grid } from "../index-DxdaxM3o.cjs";
1
+ import { n as GridProps, t as Grid } from "../index-DvF_C1Bz.cjs";
2
2
  export { Grid, Grid as default, GridProps };
@@ -1,2 +1,2 @@
1
- import { n as GridProps, t as Grid } from "../index-Edx7MxXu.js";
1
+ import { n as GridProps, t as Grid } from "../index-BFLKkqA3.js";
2
2
  export { Grid, Grid as default, GridProps };
@@ -1,4 +1,4 @@
1
- const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
1
+ const require_FormContext = require('./FormContext-Lw4YL4-B.cjs');
2
2
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
3
3
  let react_jsx_runtime = require("react/jsx-runtime");
4
4
 
@@ -32,4 +32,4 @@ Object.defineProperty(exports, 'Grid_default$1', {
32
32
  return Grid_default$1;
33
33
  }
34
34
  });
35
- //# sourceMappingURL=Grid-D84e76CE.cjs.map
35
+ //# sourceMappingURL=Grid-DezBAZbx.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Grid-D84e76CE.cjs","names":["Grid"],"sources":["../src/Grid/Grid.tsx","../src/Grid/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nexport interface GridProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Defines the default grid for form components\n */\nconst Grid = ({\n children = null,\n className = undefined,\n testId = undefined,\n}: GridProps) => {\n return (\n <div className={cn('grid gap-4', className)} data-testid={testId}>\n {children}\n </div>\n );\n};\n\nexport default Grid;\n","import Grid from './Grid';\n\nexport type { GridProps } from './Grid';\n\nexport { Grid };\n\nexport default Grid;\n"],"mappings":";;;;;;;;AAgBA,MAAM,QAAQ,EACZ,WAAW,MACX,YAAY,QACZ,SAAS,aACM;AACf,QACE,2CAAC;EAAI,0CAAc,cAAc,UAAU;EAAE,eAAa;EACvD;GACG;;AAIV,qBAAe;;;;ACtBf,mBAAeA"}
1
+ {"version":3,"file":"Grid-DezBAZbx.cjs","names":["Grid"],"sources":["../src/Grid/Grid.tsx","../src/Grid/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nexport interface GridProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Defines the default grid for form components\n */\nconst Grid = ({\n children = null,\n className = undefined,\n testId = undefined,\n}: GridProps) => {\n return (\n <div className={cn('grid gap-4', className)} data-testid={testId}>\n {children}\n </div>\n );\n};\n\nexport default Grid;\n","import Grid from './Grid';\n\nexport type { GridProps } from './Grid';\n\nexport { Grid };\n\nexport default Grid;\n"],"mappings":";;;;;;;;AAgBA,MAAM,QAAQ,EACZ,WAAW,MACX,YAAY,QACZ,SAAS,aACM;AACf,QACE,2CAAC;EAAI,0CAAc,cAAc,UAAU;EAAE,eAAa;EACvD;GACG;;AAIV,qBAAe;;;;ACtBf,mBAAeA"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_Input = require('../Input-DeTpxiK_.cjs');
2
+ const require_Input = require('../Input-DR0gCf9q.cjs');
3
3
 
4
4
  exports.Input = require_Input.Input_default$1;
5
5
  exports.default = require_Input.Input_default;
@@ -1,2 +1,2 @@
1
- import { n as InputProps, t as Input } from "../index-BxA_pJWn.cjs";
1
+ import { n as InputProps, t as Input } from "../index-CeYRsehb.cjs";
2
2
  export { Input, Input as default, InputProps };
@@ -1,2 +1,2 @@
1
- import { n as InputProps, t as Input } from "../index-C-2nxT8D.js";
1
+ import { n as InputProps, t as Input } from "../index-CZyNkPDq.js";
2
2
  export { Input, Input as default, InputProps };
@@ -1,3 +1,3 @@
1
- import { n as Input_default, t as Input_default$1 } from "../Input-DXMWGTBh.js";
1
+ import { n as Input_default, t as Input_default$1 } from "../Input-DksaHK1Y.js";
2
2
 
3
3
  export { Input_default as Input, Input_default$1 as default };
@@ -1,6 +1,6 @@
1
- const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
2
- const require_useUniformField = require('./useUniformField-Bj23Kvbs.cjs');
3
- const require_useInputValueDebounce = require('./useInputValueDebounce-BcUyaS94.cjs');
1
+ const require_FormContext = require('./FormContext-Lw4YL4-B.cjs');
2
+ const require_useUniformField = require('./useUniformField-D6fwSjrH.cjs');
3
+ const require_useInputValueDebounce = require('./useInputValueDebounce-TiNR4jtG.cjs');
4
4
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
6
  let _heroui_input = require("@heroui/input");
@@ -24,6 +24,7 @@ const Input = ({ className: _className = void 0, clearable = false, debounceDela
24
24
  });
25
25
  const { onChange, onBlur, value } = require_useInputValueDebounce.useInputValueDebounce({
26
26
  debounceDelay,
27
+ name,
27
28
  onBlur: fieldOnBlur,
28
29
  onChange: fieldOnChange,
29
30
  value: fieldValue
@@ -103,4 +104,4 @@ Object.defineProperty(exports, 'Input_default$1', {
103
104
  return Input_default$1;
104
105
  }
105
106
  });
106
- //# sourceMappingURL=Input-DeTpxiK_.cjs.map
107
+ //# sourceMappingURL=Input-DR0gCf9q.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input-DR0gCf9q.cjs","names":["useUniformField","useInputValueDebounce","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;;AAcA,MAAa,+CAAmB,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAM,SAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACEA,wCAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAUC,oDAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,8DADW,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,2CAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,2CAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAe;;;;ACnMf,oBAAeC"}
@@ -1,5 +1,5 @@
1
- import { t as useUniformField } from "./useUniformField-gU4qYUwL.js";
2
- import { t as useInputValueDebounce } from "./useInputValueDebounce-DaH5ONlQ.js";
1
+ import { t as useUniformField } from "./useUniformField-BKVVns0E.js";
2
+ import { t as useInputValueDebounce } from "./useInputValueDebounce-Dop_8_OK.js";
3
3
  import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import { Input } from "@heroui/input";
@@ -23,6 +23,7 @@ const Input$1 = ({ className: _className = void 0, clearable = false, debounceDe
23
23
  });
24
24
  const { onChange, onBlur, value } = useInputValueDebounce({
25
25
  debounceDelay,
26
+ name,
26
27
  onBlur: fieldOnBlur,
27
28
  onChange: fieldOnChange,
28
29
  value: fieldValue
@@ -91,4 +92,4 @@ var Input_default = Input_default$1;
91
92
 
92
93
  //#endregion
93
94
  export { Input_default$1 as n, Input_default as t };
94
- //# sourceMappingURL=Input-DXMWGTBh.js.map
95
+ //# sourceMappingURL=Input-DksaHK1Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input-DksaHK1Y.js","names":["Input","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;AAcA,MAAa,gBAAgB,GAAG,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAMA,WAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACE,gBAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAU,sBAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,aAAa,qBADF,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,oBAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,oBAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAeF;;;;ACnMf,oBAAeG"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_RadioBoxes = require('../RadioBoxes-gsQGqQCd.cjs');
2
+ const require_RadioBoxes = require('../RadioBoxes-h-VLhJ9d.cjs');
3
3
 
4
4
  exports.RadioBoxes = require_RadioBoxes.RadioBoxes_default$1;
5
5
  exports.default = require_RadioBoxes.RadioBoxes_default;
@@ -1,2 +1,2 @@
1
- import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-DNkZrb7P.cjs";
1
+ import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-CjJHVJwD.cjs";
2
2
  export { RadioBoxes, RadioBoxes as default, RadioBoxesProps, radioBoxVariants };
@@ -1,2 +1,2 @@
1
- import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-DG9C0kHA.js";
1
+ import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-BGXgvZKr.js";
2
2
  export { RadioBoxes, RadioBoxes as default, RadioBoxesProps, radioBoxVariants };
@@ -1,3 +1,3 @@
1
- import { n as RadioBoxes_default, r as radioBoxVariants, t as RadioBoxes_default$1 } from "../RadioBoxes-BEln4a-B.js";
1
+ import { n as RadioBoxes_default, r as radioBoxVariants, t as RadioBoxes_default$1 } from "../RadioBoxes-DdIHH6B5.js";
2
2
 
3
3
  export { RadioBoxes_default as RadioBoxes, RadioBoxes_default$1 as default, radioBoxVariants };
@@ -1,4 +1,4 @@
1
- import { t as useUniformField } from "./useUniformField-gU4qYUwL.js";
1
+ import { t as useUniformField } from "./useUniformField-BKVVns0E.js";
2
2
  import { cn, slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { RadioGroup, useRadio } from "@heroui/radio";
@@ -135,4 +135,4 @@ var RadioBoxes_default = RadioBoxes_default$1;
135
135
 
136
136
  //#endregion
137
137
  export { RadioBoxes_default$1 as n, radioBoxVariants as r, RadioBoxes_default as t };
138
- //# sourceMappingURL=RadioBoxes-BEln4a-B.js.map
138
+ //# sourceMappingURL=RadioBoxes-DdIHH6B5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioBoxes-BEln4a-B.js","names":["HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,MAAwB;CAOrC,MAAM,aAAa,qBAJF,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,qBAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,oBAAC,4BACC,oBAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBAAiB;KACrB,WAAW,GAAG,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,oBAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,qBAAC;IACC,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA,WACC,oBAAC;KACC,GAAI,eAAe;KACnB,WAAW,GAAG,eAAe,CAAC,WAAW,WAAW,MAAM;KAEzD;MACI,GACL,MACH,cACC,oBAAC;KAAI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AO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
1
+ {"version":3,"file":"RadioBoxes-DdIHH6B5.js","names":["HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,MAAwB;CAOrC,MAAM,aAAa,qBAJF,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,qBAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,oBAAC,4BACC,oBAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBAAiB;KACrB,WAAW,GAAG,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,oBAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,qBAAC;IACC,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA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;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OATnB,OAAO,MAUH;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
@@ -1,5 +1,5 @@
1
- const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
2
- const require_useUniformField = require('./useUniformField-Bj23Kvbs.cjs');
1
+ const require_FormContext = require('./FormContext-Lw4YL4-B.cjs');
2
+ const require_useUniformField = require('./useUniformField-D6fwSjrH.cjs');
3
3
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let _heroui_radio = require("@heroui/radio");
@@ -153,4 +153,4 @@ Object.defineProperty(exports, 'radioBoxVariants', {
153
153
  return radioBoxVariants;
154
154
  }
155
155
  });
156
- //# sourceMappingURL=RadioBoxes-gsQGqQCd.cjs.map
156
+ //# sourceMappingURL=RadioBoxes-h-VLhJ9d.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioBoxes-gsQGqQCd.cjs","names":["VisuallyHidden","useUniformField","HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;AASA,MAAa,kDAAsB;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,M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MAAM,8DADW,oBAAoB,EACa,WAAW,OAAO;CACpE,MAAM,gBAA6C;EACjD,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;EAC1B;AAED,QACE,2CAACC;EACM;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACA;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACR,eAAe;EACf,aAAa,SAAS,eAAe;YAEpC,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,mDACJ,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,2CAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OATnB,OAAO,MAUH;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
1
+ {"version":3,"file":"RadioBoxes-h-VLhJ9d.cjs","names":["VisuallyHidden","useUniformField","HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;AASA,MAAa,kDAAsB;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EAC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cACA,SACA,UACA,OACA,QACA,UACA,KACA,UACA,WACEC,wCAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAIF,MAAM,8DADW,oBAAoB,EACa,WAAW,OAAO;CACpE,MAAM,gBAA6C;EACjD,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;EAC1B;AAED,QACE,2CAACC;EACM;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACA;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACR,eAAe;EACf,aAAa,SAAS,eAAe;YAEpC,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,mDACJ,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,2CAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OATnB,OAAO,MAUH;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_RadioTabs = require('../RadioTabs-BYpP0tKA.cjs');
2
+ const require_RadioTabs = require('../RadioTabs-D6yF9jE3.cjs');
3
3
 
4
4
  exports.RadioTabs = require_RadioTabs.RadioTabs_default$1;
5
5
  exports.default = require_RadioTabs.RadioTabs_default;
@@ -1,2 +1,2 @@
1
- import { n as RadioTabsProps, t as RadioTabs } from "../index-BITJ-CZL.cjs";
1
+ import { n as RadioTabsProps, t as RadioTabs } from "../index-BSjUaHEO.cjs";
2
2
  export { RadioTabs, RadioTabs as default, RadioTabsProps };
@@ -1,2 +1,2 @@
1
- import { n as RadioTabsProps, t as RadioTabs } from "../index-CVnn6mEI.js";
1
+ import { n as RadioTabsProps, t as RadioTabs } from "../index-Bcppi5O7.js";
2
2
  export { RadioTabs, RadioTabs as default, RadioTabsProps };