@fuf-stack/uniform 1.20.16 → 1.20.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/dist/Checkboxes/index.cjs +1 -1
  2. package/dist/{Checkboxes-CqlbSLHi.cjs → Checkboxes-DHhU9eNR.cjs} +3 -3
  3. package/dist/{Checkboxes-CqlbSLHi.cjs.map → Checkboxes-DHhU9eNR.cjs.map} +1 -1
  4. package/dist/FieldArray/index.cjs +1 -1
  5. package/dist/{FieldArray-DtlFSbHK.cjs → FieldArray-ueGKvwY7.cjs} +4 -4
  6. package/dist/{FieldArray-DtlFSbHK.cjs.map → FieldArray-ueGKvwY7.cjs.map} +1 -1
  7. package/dist/FieldCard/index.cjs +1 -1
  8. package/dist/FieldCard/index.js +1 -1
  9. package/dist/{FieldCard-BNsMMgh3.cjs → FieldCard-CRAMlsLQ.cjs} +4 -4
  10. package/dist/{FieldCard-BNsMMgh3.cjs.map → FieldCard-CRAMlsLQ.cjs.map} +1 -1
  11. package/dist/{FieldCard-BuUT2zKN.js → FieldCard-axA3lKFh.js} +2 -2
  12. package/dist/{FieldCard-BuUT2zKN.js.map → FieldCard-axA3lKFh.js.map} +1 -1
  13. package/dist/{FieldCopyTestIdButton-_5kpA4ii.cjs → FieldCopyTestIdButton-Df9sS2Ba.cjs} +2 -2
  14. package/dist/{FieldCopyTestIdButton-_5kpA4ii.cjs.map → FieldCopyTestIdButton-Df9sS2Ba.cjs.map} +1 -1
  15. package/dist/{FieldValidationError-D40HtO_l.cjs → FieldValidationError-8XFABn8N.cjs} +2 -2
  16. package/dist/{FieldValidationError-D40HtO_l.cjs.map → FieldValidationError-8XFABn8N.cjs.map} +1 -1
  17. package/dist/Form/index.cjs +1 -1
  18. package/dist/Form/index.js +1 -1
  19. package/dist/{Form-BQbwyvPX.cjs → Form-B0SxszqY.cjs} +3 -3
  20. package/dist/{Form-BQbwyvPX.cjs.map → Form-B0SxszqY.cjs.map} +1 -1
  21. package/dist/{Form-BodvG3wG.js → Form-CEeNi0iG.js} +3 -3
  22. package/dist/{Form-BodvG3wG.js.map → Form-CEeNi0iG.js.map} +1 -1
  23. package/dist/{FormContext-DMaTuTAr.js → FormContext-C-CnF8V4.js} +36 -19
  24. package/dist/FormContext-C-CnF8V4.js.map +1 -0
  25. package/dist/{FormContext-Djp8wTG8.cjs → FormContext-DwCicmnH.cjs} +36 -19
  26. package/dist/FormContext-DwCicmnH.cjs.map +1 -0
  27. package/dist/Grid/index.cjs +1 -1
  28. package/dist/{Grid-BPOumLUp.cjs → Grid-DIe8WII9.cjs} +2 -2
  29. package/dist/{Grid-BPOumLUp.cjs.map → Grid-DIe8WII9.cjs.map} +1 -1
  30. package/dist/Input/index.cjs +1 -1
  31. package/dist/Input/index.d.cts +1 -1
  32. package/dist/Input/index.d.ts +1 -1
  33. package/dist/{Input-D64GjrZJ.cjs → Input-Bi75-PA6.cjs} +2 -2
  34. package/dist/{Input-D64GjrZJ.cjs.map → Input-Bi75-PA6.cjs.map} +1 -1
  35. package/dist/RadioBoxes/index.cjs +1 -1
  36. package/dist/RadioBoxes/index.d.cts +1 -1
  37. package/dist/RadioBoxes/index.d.ts +1 -1
  38. package/dist/{RadioBoxes-DpBv9exN.cjs → RadioBoxes-D9cMQ9hJ.cjs} +2 -2
  39. package/dist/{RadioBoxes-DpBv9exN.cjs.map → RadioBoxes-D9cMQ9hJ.cjs.map} +1 -1
  40. package/dist/RadioTabs/index.cjs +1 -1
  41. package/dist/{RadioTabs-CPsErN1U.cjs → RadioTabs-DLNfmgw-.cjs} +2 -2
  42. package/dist/{RadioTabs-CPsErN1U.cjs.map → RadioTabs-DLNfmgw-.cjs.map} +1 -1
  43. package/dist/Radios/index.cjs +1 -1
  44. package/dist/Radios/index.d.cts +1 -1
  45. package/dist/Radios/index.d.ts +1 -1
  46. package/dist/{Radios-LA38MXVt.cjs → Radios-B7EPCExa.cjs} +2 -2
  47. package/dist/{Radios-LA38MXVt.cjs.map → Radios-B7EPCExa.cjs.map} +1 -1
  48. package/dist/Select/index.cjs +1 -1
  49. package/dist/Select/index.d.cts +1 -1
  50. package/dist/Select/index.d.ts +1 -1
  51. package/dist/Select/index.js +1 -1
  52. package/dist/{Select-DsSdFeWq.cjs → Select-CTPYDpU_.cjs} +3 -3
  53. package/dist/{Select-DsSdFeWq.cjs.map → Select-CTPYDpU_.cjs.map} +1 -1
  54. package/dist/{Select-np0WO9nP.js → Select-_4zQsG1p.js} +2 -2
  55. package/dist/{Select-np0WO9nP.js.map → Select-_4zQsG1p.js.map} +1 -1
  56. package/dist/Slider/index.cjs +1 -1
  57. package/dist/Slider/index.d.cts +1 -1
  58. package/dist/Slider/index.d.ts +1 -1
  59. package/dist/{Slider-BXPgYL-o.cjs → Slider-uX0s4Mgc.cjs} +2 -2
  60. package/dist/{Slider-BXPgYL-o.cjs.map → Slider-uX0s4Mgc.cjs.map} +1 -1
  61. package/dist/SubmitButton/index.cjs +1 -1
  62. package/dist/SubmitButton/index.js +1 -1
  63. package/dist/{SubmitButton-QWpHBvg9.js → SubmitButton-DXD-DnJW.js} +2 -2
  64. package/dist/{SubmitButton-QWpHBvg9.js.map → SubmitButton-DXD-DnJW.js.map} +1 -1
  65. package/dist/{SubmitButton-DgEHHy3N.cjs → SubmitButton-DoulRmLh.cjs} +3 -3
  66. package/dist/{SubmitButton-DgEHHy3N.cjs.map → SubmitButton-DoulRmLh.cjs.map} +1 -1
  67. package/dist/Switch/index.cjs +1 -1
  68. package/dist/Switch/index.d.cts +1 -1
  69. package/dist/Switch/index.d.ts +1 -1
  70. package/dist/{Switch-B_R9hdxd.cjs → Switch-BrqJcAHX.cjs} +2 -2
  71. package/dist/{Switch-B_R9hdxd.cjs.map → Switch-BrqJcAHX.cjs.map} +1 -1
  72. package/dist/SwitchBox/index.cjs +1 -1
  73. package/dist/{SwitchBox-DZXIJjgl.cjs → SwitchBox-haeHmIyQ.cjs} +2 -2
  74. package/dist/{SwitchBox-DZXIJjgl.cjs.map → SwitchBox-haeHmIyQ.cjs.map} +1 -1
  75. package/dist/TextArea/index.cjs +1 -1
  76. package/dist/TextArea/index.d.cts +1 -1
  77. package/dist/TextArea/index.d.ts +1 -1
  78. package/dist/{TextArea-CsNyG6DY.cjs → TextArea-C8ENlNiR.cjs} +2 -2
  79. package/dist/{TextArea-CsNyG6DY.cjs.map → TextArea-C8ENlNiR.cjs.map} +1 -1
  80. package/dist/helpers/index.cjs +1 -1
  81. package/dist/helpers/index.d.cts +224 -2
  82. package/dist/helpers/index.d.cts.map +1 -0
  83. package/dist/helpers/index.d.ts +224 -2
  84. package/dist/helpers/index.d.ts.map +1 -0
  85. package/dist/hooks/useClientValidation/index.cjs +1 -1
  86. package/dist/hooks/useClientValidation/index.d.cts +1 -1
  87. package/dist/hooks/useClientValidation/index.d.ts +1 -1
  88. package/dist/hooks/useClientValidation/index.js +1 -1
  89. package/dist/hooks/useController/index.cjs +1 -1
  90. package/dist/hooks/useController/index.d.cts +1 -1
  91. package/dist/hooks/useController/index.d.ts +1 -1
  92. package/dist/hooks/useController/index.js +1 -1
  93. package/dist/hooks/useFormContext/index.cjs +1 -1
  94. package/dist/hooks/useFormContext/index.js +1 -1
  95. package/dist/hooks/useInput/index.cjs +1 -1
  96. package/dist/hooks/useInputValueDebounce/index.cjs +2 -2
  97. package/dist/hooks/useInputValueDebounce/index.js +1 -1
  98. package/dist/hooks/useInputValueTransform/index.cjs +1 -1
  99. package/dist/hooks/useUniformField/index.cjs +6 -6
  100. package/dist/hooks/useUniformField/index.d.cts +1 -1
  101. package/dist/hooks/useUniformField/index.d.ts +1 -1
  102. package/dist/hooks/useUniformField/index.js +2 -2
  103. package/dist/hooks/useUniformFieldArray/index.cjs +2 -2
  104. package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
  105. package/dist/hooks/useUniformFieldArray/index.d.ts +1 -1
  106. package/dist/hooks/useUniformFieldArray/index.js +1 -1
  107. package/dist/hooks/useWatchUserChange/index.cjs +1 -1
  108. package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
  109. package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
  110. package/dist/hooks/useWatchUserChange/index.js +1 -1
  111. package/dist/{index-D6QbkuWC.d.ts → index--LtIs0zN.d.ts} +4 -4
  112. package/dist/{index-D6QbkuWC.d.ts.map → index--LtIs0zN.d.ts.map} +1 -1
  113. package/dist/{index-C_3x4Vph.d.cts → index-9nJkzuEx.d.cts} +4 -4
  114. package/dist/{index-C_3x4Vph.d.cts.map → index-9nJkzuEx.d.cts.map} +1 -1
  115. package/dist/{index-DTwIpIWh.d.ts → index-9wnJP0-_.d.ts} +4 -4
  116. package/dist/{index-DTwIpIWh.d.ts.map → index-9wnJP0-_.d.ts.map} +1 -1
  117. package/dist/{index-D-UGVdC1.d.ts → index-B682jKQ_.d.ts} +4 -4
  118. package/dist/{index-D-UGVdC1.d.ts.map → index-B682jKQ_.d.ts.map} +1 -1
  119. package/dist/{index-A88y8cpH.d.cts → index-BUYJsYOF.d.cts} +4 -4
  120. package/dist/{index-A88y8cpH.d.cts.map → index-BUYJsYOF.d.cts.map} +1 -1
  121. package/dist/{index-CsDbfwLQ.d.cts → index-BVkXdUIk.d.cts} +10 -10
  122. package/dist/{index-CsDbfwLQ.d.cts.map → index-BVkXdUIk.d.cts.map} +1 -1
  123. package/dist/{index-CjB9iCSm.d.ts → index-Bf61CKYX.d.ts} +10 -10
  124. package/dist/{index-CjB9iCSm.d.ts.map → index-Bf61CKYX.d.ts.map} +1 -1
  125. package/dist/{index-Cj3P2Pmf.d.ts → index-BmR6MFmN.d.ts} +4 -4
  126. package/dist/{index-Cj3P2Pmf.d.ts.map → index-BmR6MFmN.d.ts.map} +1 -1
  127. package/dist/{index-RavMgGrt.d.ts → index-BqiVSpJW.d.cts} +1 -1
  128. package/dist/{index-BLbC1_g_.d.cts.map → index-BqiVSpJW.d.cts.map} +1 -1
  129. package/dist/{index-5_7F4o-d.d.ts → index-C4Qex3mx.d.ts} +4 -4
  130. package/dist/{index-5_7F4o-d.d.ts.map → index-C4Qex3mx.d.ts.map} +1 -1
  131. package/dist/{index-Ck9KE5Pj2.d.ts → index-CqyMqRhI.d.cts} +1 -1
  132. package/dist/{index-BlVK355b.d.cts.map → index-CqyMqRhI.d.cts.map} +1 -1
  133. package/dist/index-Dw5cCt-A.d.ts +1 -0
  134. package/dist/{index-A8Jhitar.d.cts → index-DxXdHxyY.d.cts} +4 -4
  135. package/dist/{index-A8Jhitar.d.cts.map → index-DxXdHxyY.d.cts.map} +1 -1
  136. package/dist/{index-CD9w4hqS.d.cts → index-GedeCgoX.d.cts} +10 -10
  137. package/dist/{index-CD9w4hqS.d.cts.map → index-GedeCgoX.d.cts.map} +1 -1
  138. package/dist/{index-BlVK355b.d.cts → index-K42ASvjk2.d.ts} +1 -1
  139. package/dist/{index-Ck9KE5Pj2.d.ts.map → index-K42ASvjk2.d.ts.map} +1 -1
  140. package/dist/{index-eEJp36Ma.d.cts → index-LwJL1Zry.d.cts} +4 -4
  141. package/dist/{index-eEJp36Ma.d.cts.map → index-LwJL1Zry.d.cts.map} +1 -1
  142. package/dist/index-VmEFGBxN.d.cts +1 -0
  143. package/dist/{index-BLbC1_g_.d.cts → index-ZRXr-4Rb2.d.ts} +1 -1
  144. package/dist/index-ZRXr-4Rb2.d.ts.map +1 -0
  145. package/dist/{index-Dz1C3MeK.d.cts → index-cxajYZel.d.cts} +4 -4
  146. package/dist/{index-Dz1C3MeK.d.cts.map → index-cxajYZel.d.cts.map} +1 -1
  147. package/dist/{index-RCXYx5Yp.d.ts → index-uGStRmJo.d.ts} +10 -10
  148. package/dist/{index-RCXYx5Yp.d.ts.map → index-uGStRmJo.d.ts.map} +1 -1
  149. package/dist/index.cjs +23 -23
  150. package/dist/index.d.cts +15 -15
  151. package/dist/index.d.ts +15 -15
  152. package/dist/index.js +8 -8
  153. package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
  154. package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
  155. package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
  156. package/dist/partials/FieldValidationError/index.cjs +1 -1
  157. package/dist/partials/FieldValidationError/index.d.cts +1 -1
  158. package/dist/partials/FieldValidationError/index.d.ts +1 -1
  159. package/dist/{useClientValidation-DtnfCE5T.d.cts → useClientValidation-BMzOi3DZ.d.cts} +1 -1
  160. package/dist/{useClientValidation-DtnfCE5T.d.cts.map → useClientValidation-BMzOi3DZ.d.cts.map} +1 -1
  161. package/dist/{useClientValidation-BWElhQ91.d.ts → useClientValidation-BTbGUViN.d.ts} +1 -1
  162. package/dist/{useClientValidation-BWElhQ91.d.ts.map → useClientValidation-BTbGUViN.d.ts.map} +1 -1
  163. package/dist/{useClientValidation-7iy9lEfO.js → useClientValidation-CRiAKKXX.js} +2 -2
  164. package/dist/{useClientValidation-7iy9lEfO.js.map → useClientValidation-CRiAKKXX.js.map} +1 -1
  165. package/dist/{useClientValidation-_GEt49og.cjs → useClientValidation-DNJSguNN.cjs} +3 -3
  166. package/dist/{useClientValidation-_GEt49og.cjs.map → useClientValidation-DNJSguNN.cjs.map} +1 -1
  167. package/dist/{useController-Cc0UNQMm.d.ts → useController-BK2AeY9L.d.ts} +1 -1
  168. package/dist/{useController-Cc0UNQMm.d.ts.map → useController-BK2AeY9L.d.ts.map} +1 -1
  169. package/dist/{useController-BQ4LoFBd.js → useController-CKhJx1rF.js} +2 -2
  170. package/dist/{useController-BQ4LoFBd.js.map → useController-CKhJx1rF.js.map} +1 -1
  171. package/dist/{useController-lNSzBL-i.cjs → useController-DBLYBDT1.cjs} +2 -2
  172. package/dist/{useController-lNSzBL-i.cjs.map → useController-DBLYBDT1.cjs.map} +1 -1
  173. package/dist/{useController-CNiqy_2D.d.cts → useController-kxcnnsXy.d.cts} +1 -1
  174. package/dist/{useController-CNiqy_2D.d.cts.map → useController-kxcnnsXy.d.cts.map} +1 -1
  175. package/dist/{useFormContext-2vyVWpUJ.js → useFormContext-C-THOgmB.js} +2 -2
  176. package/dist/{useFormContext-2vyVWpUJ.js.map → useFormContext-C-THOgmB.js.map} +1 -1
  177. package/dist/{useFormContext-CNGE9heQ.cjs → useFormContext-q0hx1SYq.cjs} +2 -2
  178. package/dist/{useFormContext-CNGE9heQ.cjs.map → useFormContext-q0hx1SYq.cjs.map} +1 -1
  179. package/dist/{useInputValueTransform-5jjQVowe.cjs → useInputValueTransform-MHvKpD22.cjs} +2 -2
  180. package/dist/{useInputValueTransform-5jjQVowe.cjs.map → useInputValueTransform-MHvKpD22.cjs.map} +1 -1
  181. package/dist/{useUniformField-CMb5EZ7Y.d.ts → useUniformField-B3Dj8K5J.d.ts} +2 -2
  182. package/dist/{useUniformField-CMb5EZ7Y.d.ts.map → useUniformField-B3Dj8K5J.d.ts.map} +1 -1
  183. package/dist/{useUniformField-D-Klu-sM.d.cts → useUniformField-BWKBsUEX.d.cts} +2 -2
  184. package/dist/{useUniformField-D-Klu-sM.d.cts.map → useUniformField-BWKBsUEX.d.cts.map} +1 -1
  185. package/dist/{useUniformFieldArray-eDkxErv8.d.ts → useUniformFieldArray-C0U3eBr7.d.ts} +2 -2
  186. package/dist/useUniformFieldArray-C0U3eBr7.d.ts.map +1 -0
  187. package/dist/{useUniformFieldArray-KClEBFyP.d.cts → useUniformFieldArray-RvOYml8h.d.cts} +2 -2
  188. package/dist/useUniformFieldArray-RvOYml8h.d.cts.map +1 -0
  189. package/dist/{useWatchUserChange-CZu_ZZ38.d.cts → useWatchUserChange-26IF7Ikq.d.cts} +1 -1
  190. package/dist/{useWatchUserChange-CZu_ZZ38.d.cts.map → useWatchUserChange-26IF7Ikq.d.cts.map} +1 -1
  191. package/dist/{useWatchUserChange-CH4x16_r.d.ts → useWatchUserChange-BjRKMix1.d.ts} +1 -1
  192. package/dist/{useWatchUserChange-CH4x16_r.d.ts.map → useWatchUserChange-BjRKMix1.d.ts.map} +1 -1
  193. package/dist/{useWatchUserChange-DdmIHIkf.js → useWatchUserChange-C6MCw8ql.js} +2 -2
  194. package/dist/{useWatchUserChange-DdmIHIkf.js.map → useWatchUserChange-C6MCw8ql.js.map} +1 -1
  195. package/dist/{useWatchUserChange-BSfuusTZ.cjs → useWatchUserChange-HDuOydMZ.cjs} +3 -3
  196. package/dist/{useWatchUserChange-BSfuusTZ.cjs.map → useWatchUserChange-HDuOydMZ.cjs.map} +1 -1
  197. package/package.json +5 -5
  198. package/dist/FormContext-DMaTuTAr.js.map +0 -1
  199. package/dist/FormContext-Djp8wTG8.cjs.map +0 -1
  200. package/dist/index-0zgyvkAF.d.cts +0 -224
  201. package/dist/index-0zgyvkAF.d.cts.map +0 -1
  202. package/dist/index-DVGo3QuA.d.ts +0 -224
  203. package/dist/index-DVGo3QuA.d.ts.map +0 -1
  204. package/dist/index-RavMgGrt.d.ts.map +0 -1
  205. package/dist/useUniformFieldArray-KClEBFyP.d.cts.map +0 -1
  206. package/dist/useUniformFieldArray-eDkxErv8.d.ts.map +0 -1
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Form = require("../Form-BQbwyvPX.cjs");
5
+ const require_Form = require("../Form-B0SxszqY.cjs");
6
6
  exports.Form = require_Form.Form;
7
7
  exports.default = require_Form.Form_default;
@@ -1,2 +1,2 @@
1
- import { n as Form, t as Form_default } from "../Form-BodvG3wG.js";
1
+ import { n as Form, t as Form_default } from "../Form-CEeNi0iG.js";
2
2
  export { Form, Form_default as default };
@@ -1,5 +1,5 @@
1
- const require_FormContext = require("./FormContext-Djp8wTG8.cjs");
2
- const require_useFormContext = require("./useFormContext-CNGE9heQ.cjs");
1
+ const require_FormContext = require("./FormContext-DwCicmnH.cjs");
2
+ const require_useFormContext = require("./useFormContext-q0hx1SYq.cjs");
3
3
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
4
4
  let react = require("react");
5
5
  let react_icons_fa6 = require("react-icons/fa6");
@@ -122,4 +122,4 @@ Object.defineProperty(exports, "Form_default", {
122
122
  }
123
123
  });
124
124
 
125
- //# sourceMappingURL=Form-BQbwyvPX.cjs.map
125
+ //# sourceMappingURL=Form-B0SxszqY.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form-BQbwyvPX.cjs","names":["useFormContext","Button","FaBug","Card","FaTimes","FaBullseye","Json","FormProvider"],"sources":["../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/Form.tsx","../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACEA,uBAAAA,eAAe;CAEnB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAIvC,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,UAA+C,CAAC,CAAC;CAEhE,CAAA,GAAA,MAAA,iBAAgB;EAEd,IAAI,CAAC,eACH;EAIF,UAAU,UAAU,KAAK,CAAC,CAAC;EAE3B,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa;GACX,aAAa;EACf;CA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A,GACT,aAAa,KAAA,GACb,oBAAoB,YACL;CACf,OACE,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,cAAD;EACE,mBAAmB;EACJ;EACL;EACE;EACO;aAEjB,EAAE,cAAc,cAAc;GAC9B,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;IAAK,WAAU;cAAf,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;KACE,YAAA,GAAA,uBAAA,IAAc,QAAQ,SAAS;KAC/B,sBAAoB;KACpB,gBAAA,GAAA,uBAAA,SAAqB,UAAU,QAAQ,EAAE;KACnC;KACN,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,iBAAA,GAAA,kBAAA,KAAC,iBAAD,EAAiB,WAAU,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACtEA,IAAA,eAAe"}
1
+ {"version":3,"file":"Form-B0SxszqY.cjs","names":["useFormContext","Button","FaBug","Card","FaTimes","FaBullseye","Json","FormProvider"],"sources":["../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/Form.tsx","../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACEA,uBA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,SAAS,mBAAmB,UAAU;GACtC,eAAe;IACb,aAAa,cAAc,UAAU,kBAAkB,OAAO;GAChE;aAEC,mBAAmB,oBAAoB;EAClC,CAAA,GACR,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,MAAD,EACE,OAAO;GACL;GACA,QAAQ,UAAU;GAClB,QAAQ;IACN;IACA;IACA;IACA;GACF;EACF,EACD,CAAA,CACG;;AAEV;;;AC/GA,MAAM,UAAU,QAAQ,IAAI,aAAa;;;;AA0BzC,MAAM,QAAQ,EACZ,UACA,YAAY,KAAA,GACZ,QAAQ,KAAA,GACR,gBAAgB,KAAA,GAChB,OAAO,KAAA,GACP,UACA,SAAS,KAAA,GACT,aAAa,KAAA,GACb,oBAAoB,YACL;CACf,OACE,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,cAAD;EACE,mBAAmB;EACJ;EACL;EACE;EACO;aAEjB,EAAE,cAAc,cAAc;GAC9B,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;IAAK,WAAU;cAAf,CACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;KACE,YAAA,GAAA,uBAAA,IAAc,QAAQ,SAAS;KAC/B,sBAAoB;KACpB,gBAAA,GAAA,uBAAA,SAAqB,UAAU,QAAQ,EAAE;KACnC;KACN,UAAU;KAET;IACG,CAAA,GAEL,CAAC,WAAW,CAAC,OAAO,WACnB,iBAAA,GAAA,kBAAA,KAAC,iBAAD,EAAiB,WAAU,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACtEA,IAAA,eAAe"}
@@ -1,5 +1,5 @@
1
- import { t as FormProvider } from "./FormContext-DMaTuTAr.js";
2
- import { n as useFormContext } from "./useFormContext-2vyVWpUJ.js";
1
+ import { t as FormProvider } from "./FormContext-C-CnF8V4.js";
2
+ import { n as useFormContext } from "./useFormContext-C-THOgmB.js";
3
3
  import { cn, slugify } from "@fuf-stack/pixel-utils";
4
4
  import { useEffect, useState } from "react";
5
5
  import { FaBug, FaBullseye } from "react-icons/fa6";
@@ -111,4 +111,4 @@ var Form_default = Form;
111
111
  //#endregion
112
112
  export { Form as n, Form_default as t };
113
113
 
114
- //# sourceMappingURL=Form-BodvG3wG.js.map
114
+ //# sourceMappingURL=Form-CEeNi0iG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form-BodvG3wG.js","names":[],"sources":["../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/Form.tsx","../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACE,eAAe;CAEnB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAIvC,MAAM,CAAC,QAAQ,aAAa,SAAkC,CAAC,CAAC;CAEhE,gBAAgB;EAEd,IAAI,CAAC,eACH;EAIF,UAAU,UAAU,KAAK,CAAC,CAAC;EAE3B,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa;GACX,aAAa;EACf;CAEF,GAAG,CAAC,aAAa,CAAC;CAElB,I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C,WAAW,CAAC,OAAO,WACnB,oBAAC,iBAAD,EAAiB,WAAU,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACtEA,IAAA,eAAe"}
1
+ {"version":3,"file":"Form-CEeNi0iG.js","names":[],"sources":["../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/Form.tsx","../src/Form/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks/useFormContext';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn, slugify } from '@fuf-stack/pixel-utils';\n\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\n data-testid={slugify(testId ?? name ?? '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,mBAAmB,EAAE,YAAY,KAAA,QAAsC;CAC3E,MAAM,EACJ,WACA,WAAW,EAAE,SAAS,cAAc,aAAa,sBACjD,WACA,cACA,YAAY,EAAE,UACd,cACE,eAAe;CAEnB,MAAM,kBAAkB,cAAc;CACtC,MAAM,gBAAgB,cAAc,WAAW,cAAc;CAC7D,MAAM,mBAAmB,cAAc;CAIvC,MAAM,CAAC,QAAQ,aAAa,SAAkC,CAAC,CAAC;CAEhE,gBAAgB;EAEd,IAAI,CAAC,eACH;EAIF,UAAU,UAAU,KAAK,CAAC,CAAC;EAE3B,MAAM,eAAe,UAAU;GAC7B,WAAW,EAAE,QAAQ,KAAK;GAC1B,WAAW,UAAU;IACnB,UAAU,MAAM,UAAU,CAAC,CAAC;GAC9B;EACF,CAAC;EAED,aAAa;GACX,aAAa;EACf;CAEF,GAAG,CAAC,aAAa,CAAC;CAElB,IAAI,iBACF,OACE,oBAAC,QAAD;EACE,WAAU;EACV,WAAU;E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U,cAAe,CAAA,CAEzC;;EAET;CACY,CAAA;AAElB;;;ACtEA,IAAA,eAAe"}
@@ -75,25 +75,32 @@ const useExtendedValidation = (baseValidation) => {
75
75
  * @param extendedValidation - Extended validation instance from useExtendedValidation
76
76
  * @returns Object containing resolver function, current validation errors, and optimization hash
77
77
  */
78
- const useFormResolver = (extendedValidation) => {
78
+ const useFormResolver = (extendedValidation, onValidationErrorsChange) => {
79
79
  const validationErrors = useRef(void 0);
80
- const resolver = useMemo(() => {
81
- if (!extendedValidation) return;
82
- return async (values) => {
83
- const validationValues = toValidationFormat(values) ?? {};
84
- const result = await extendedValidation.validateAsync(validationValues);
85
- validationErrors.current = result.errors ?? void 0;
86
- return {
87
- values: result.data ?? {},
88
- errors: result.errors ?? {}
89
- };
90
- };
91
- }, [extendedValidation]);
92
- const validationErrorsHash = JSON.stringify(validationErrors.current);
80
+ const validationErrorsHash = useRef(void 0);
81
+ const updateValidationErrors = useCallback((errors) => {
82
+ validationErrors.current = errors;
83
+ const nextHash = JSON.stringify(errors);
84
+ if (validationErrorsHash.current !== nextHash) {
85
+ validationErrorsHash.current = nextHash;
86
+ onValidationErrorsChange?.(nextHash);
87
+ }
88
+ }, [onValidationErrorsChange]);
93
89
  return {
94
- resolver,
90
+ resolver: useMemo(() => {
91
+ if (!extendedValidation) return;
92
+ return async (values) => {
93
+ const validationValues = toValidationFormat(values) ?? {};
94
+ const result = await extendedValidation.validateAsync(validationValues);
95
+ updateValidationErrors(result.errors ?? void 0);
96
+ return {
97
+ values: result.data ?? {},
98
+ errors: result.errors ?? {}
99
+ };
100
+ };
101
+ }, [extendedValidation, updateValidationErrors]),
95
102
  validationErrors: validationErrors.current,
96
- validationErrorsHash
103
+ validationErrorsHash: validationErrorsHash.current
97
104
  };
98
105
  };
99
106
  //#endregion
@@ -133,7 +140,15 @@ debug("UniformContext exported", {
133
140
  const FormProvider$1 = ({ children, debugModeSettings = void 0, initialValues = void 0, onSubmit, validation: baseValidation = void 0, validationTrigger }) => {
134
141
  const [debugMode, setDebugMode] = useLocalStorage(debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT, "off");
135
142
  const { extendedValidation, setClientValidationSchema } = useExtendedValidation(baseValidation);
136
- const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation);
143
+ const hasPendingUserChangeRef = useRef(false);
144
+ const [validationErrorsRefreshVersion, setValidationErrorsRefreshVersion] = useState(0);
145
+ const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation, useCallback(() => {
146
+ if (!hasPendingUserChangeRef.current) return;
147
+ hasPendingUserChangeRef.current = false;
148
+ setValidationErrorsRefreshVersion((prev) => {
149
+ return prev + 1;
150
+ });
151
+ }, []));
137
152
  const methods = useForm({
138
153
  defaultValues: initialValues ? toFormFormat(initialValues) : initialValues,
139
154
  mode: validationTrigger,
@@ -149,6 +164,7 @@ const FormProvider$1 = ({ children, debugModeSettings = void 0, initialValues =
149
164
  };
150
165
  }, []);
151
166
  const notifyUserChange = useCallback((fieldName, value) => {
167
+ hasPendingUserChangeRef.current = true;
152
168
  userChangeListenersRef.current.forEach((listener) => {
153
169
  listener(fieldName, value);
154
170
  });
@@ -212,7 +228,8 @@ const FormProvider$1 = ({ children, debugModeSettings = void 0, initialValues =
212
228
  }, [
213
229
  debugMode,
214
230
  debugModeSettings?.disable,
215
- validationErrorsHash
231
+ validationErrorsHash,
232
+ validationErrorsRefreshVersion
216
233
  ]);
217
234
  return /* @__PURE__ */ jsx(UniformContext.Provider, {
218
235
  value: contextValue,
@@ -228,4 +245,4 @@ const FormProvider$1 = ({ children, debugModeSettings = void 0, initialValues =
228
245
  //#endregion
229
246
  export { UniformContext as n, FormProvider$1 as t };
230
247
 
231
- //# sourceMappingURL=FormContext-DMaTuTAr.js.map
248
+ //# sourceMappingURL=FormContext-C-CnF8V4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormContext-C-CnF8V4.js","names":["FormProvider","HookFormProvider"],"sources":["../src/Form/subcomponents/FormResolver.ts","../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useCallback, useMemo, 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<VetoTypeAny[]>(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter((schema): schema is VetoTypeAny => {\n return Boolean(schema);\n });\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined =\n clientSchemaValues.reduce<VetoTypeAny | null>(\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (baseValidation && clientSchemasCombined) {\n // Put client validation first so dynamic/domain-specific messages\n // are returned before generic base validation errors.\n const baseSchema = baseValidation.schema as VetoTypeAny;\n return veto(and(clientSchemasCombined, baseSchema));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * 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 = (\n extendedValidation?: VetoInstance,\n onValidationErrorsChange?: (validationErrorsHash: string | undefined) => void,\n) => {\n // Keep validation errors in a ref to avoid re-renders on each resolver run.\n // This preserves UX/snapshot behavior where validation updates alone\n // do not force immediate visual error state changes.\n const validationErrors = useRef<VetoFormattedError>(undefined);\n const validationErrorsHash = useRef<string | undefined>(undefined);\n\n const updateValidationErrors = useCallback(\n (errors: VetoFormattedError | undefined): void => {\n // Store the formatted errors in a ref so resolver runs stay cheap and do\n // not automatically repaint every form consumer.\n validationErrors.current = errors;\n\n // The hash is the reactive signal for consumers. Only notify when the\n // actual error output changes, so repeated validations with the same\n // result do not cause avoidable context refreshes.\n const nextHash = JSON.stringify(errors);\n\n if (validationErrorsHash.current !== nextHash) {\n validationErrorsHash.current = nextHash;\n onValidationErrorsChange?.(nextHash);\n }\n },\n [onValidationErrorsChange],\n );\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n updateValidationErrors(result.errors ?? undefined);\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation, updateValidationErrors]);\n\n /* eslint-disable react-hooks/refs -- intentional non-reactive cache reads */\n const currentValidationErrors = validationErrors.current;\n const currentValidationErrorsHash = validationErrorsHash.current;\n\n return {\n resolver,\n validationErrors: currentValidationErrors,\n validationErrorsHash: currentValidationErrorsHash,\n };\n /* eslint-enable react-hooks/refs */\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, Path, SubmitHandler } from 'react-hook-form';\n\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport createDebug from 'debug';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toSubmitFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\nconst debug = createDebug('uniform:FormContext');\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\n/**\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 const hasPendingUserChangeRef = useRef(false);\n const [validationErrorsRefreshVersion, setValidationErrorsRefreshVersion] =\n useState(0);\n\n const handleValidationErrorsChange = useCallback(() => {\n if (!hasPendingUserChangeRef.current) {\n return;\n }\n\n hasPendingUserChangeRef.current = false;\n setValidationErrorsRefreshVersion((prev) => {\n return prev + 1;\n });\n }, []);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } = useFormResolver(\n extendedValidation,\n handleValidationErrorsChange,\n );\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 hasPendingUserChangeRef.current = true;\n\n // Notify all registered listeners\n userChangeListenersRef.current.forEach((listener) => {\n listener(fieldName as Path<object>, value);\n });\n },\n [],\n );\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n debug('handleSubmit called', {\n preventSubmit,\n formStateIsValid: methods.formState.isValid,\n validationErrors: methods.formState.errors,\n validationTrigger,\n formValues: methods.getValues(),\n });\n\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n debug('⛔ Form submit PREVENTED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n });\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n debug('✓ Form submit ALLOWED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n reason: !methods.formState.isValid\n ? 'Form is invalid (will trigger validation and show errors)'\n : 'Form is valid and preventSubmit is false',\n });\n\n // Convert form data to submission format:\n // - Unwrap flat array wrappers and convert markers\n // - Remove empty strings, nulls, empty arrays, and empty objects\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toSubmitFormat(data) ?? {};\n debug('onSubmit callback called', { submitData });\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n\n debug('handleSubmit completed');\n };\n\n // Memoize the context value 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 [\n debugMode,\n debugModeSettings?.disable,\n validationErrorsHash,\n validationErrorsRefreshVersion,\n ],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAa,mCAAmC;CAE9C,MAAM,CAAC,yBAAyB,8BAA8B,SAE5D,CAAC,CAAC;CAsBJ,OAAO;EACL;EACA,2BArBgC,cAAc;GAC9C,QAAQ,KAAa,WAA+B;IAElD,4BAA4B,SAAS;KAEnC,IAAI,CAAC,KAAK,QAAQ,CAAC,QACjB,OAAO;KAGT,IAAI,CAAC,QAAQ;MACX,MAAM,GAAG,MAAM,UAAU,G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CAAC;GAC5C,MAAM,4BAA4B,EAAE,WAAW,CAAC;GAChD,OAAO,SAAS,YAAY,KAAK;EACnC;EAEA,MAAM,QAAQ,aAAa,eAAe,EAAE,CAAC;EAE7C,MAAM,wBAAwB;CAChC;CAGA,MAAM,eAAe,cACb;EACJ,OAAO;GAGL,WAAW,mBAAmB,UAAU,aAAa;GACrD,gBAAgB,YAAqB;IACnC,MAAM,wBAAwB;KAC5B,eAAe;KACf,UAAU;KACV,kBAAkB,QAAQ,UAAU;KACpC,kBAAkB,QAAQ,UAAU;IACtC,CAAC;IACD,iBAAiB,OAAO;GAC1B;GACA;GACA;GACA,eAAe;GACf,YAAY;IACV,WAAW;IACX,QAAQ;GACV;GACA,YAAY;IACV,cAAc;IACd,UAAU;IACV,QAAQ;IACR;GACF;EACF;CACF,GAEA;EACE;EACA,mBAAmB;EACnB;EACA;CACF,CACF;CAEA,OACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;YAE9B,oBAACC,cAAD;GAAkB,GAAI;aACnB,SAAS;IAAE;IAAc;GAAQ,CAAC;EACnB,CAAA;CACK,CAAA;AAE7B"}
@@ -99,25 +99,32 @@ const useExtendedValidation = (baseValidation) => {
99
99
  * @param extendedValidation - Extended validation instance from useExtendedValidation
100
100
  * @returns Object containing resolver function, current validation errors, and optimization hash
101
101
  */
102
- const useFormResolver = (extendedValidation) => {
102
+ const useFormResolver = (extendedValidation, onValidationErrorsChange) => {
103
103
  const validationErrors = (0, react.useRef)(void 0);
104
- const resolver = (0, react.useMemo)(() => {
105
- if (!extendedValidation) return;
106
- return async (values) => {
107
- const validationValues = require_helpers_index.toValidationFormat(values) ?? {};
108
- const result = await extendedValidation.validateAsync(validationValues);
109
- validationErrors.current = result.errors ?? void 0;
110
- return {
111
- values: result.data ?? {},
112
- errors: result.errors ?? {}
113
- };
114
- };
115
- }, [extendedValidation]);
116
- const validationErrorsHash = JSON.stringify(validationErrors.current);
104
+ const validationErrorsHash = (0, react.useRef)(void 0);
105
+ const updateValidationErrors = (0, react.useCallback)((errors) => {
106
+ validationErrors.current = errors;
107
+ const nextHash = JSON.stringify(errors);
108
+ if (validationErrorsHash.current !== nextHash) {
109
+ validationErrorsHash.current = nextHash;
110
+ onValidationErrorsChange?.(nextHash);
111
+ }
112
+ }, [onValidationErrorsChange]);
117
113
  return {
118
- resolver,
114
+ resolver: (0, react.useMemo)(() => {
115
+ if (!extendedValidation) return;
116
+ return async (values) => {
117
+ const validationValues = require_helpers_index.toValidationFormat(values) ?? {};
118
+ const result = await extendedValidation.validateAsync(validationValues);
119
+ updateValidationErrors(result.errors ?? void 0);
120
+ return {
121
+ values: result.data ?? {},
122
+ errors: result.errors ?? {}
123
+ };
124
+ };
125
+ }, [extendedValidation, updateValidationErrors]),
119
126
  validationErrors: validationErrors.current,
120
- validationErrorsHash
127
+ validationErrorsHash: validationErrorsHash.current
121
128
  };
122
129
  };
123
130
  //#endregion
@@ -157,7 +164,15 @@ debug$1("UniformContext exported", {
157
164
  const FormProvider = ({ children, debugModeSettings = void 0, initialValues = void 0, onSubmit, validation: baseValidation = void 0, validationTrigger }) => {
158
165
  const [debugMode, setDebugMode] = (0, _fuf_stack_pixels.useLocalStorage)(debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT, "off");
159
166
  const { extendedValidation, setClientValidationSchema } = useExtendedValidation(baseValidation);
160
- const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation);
167
+ const hasPendingUserChangeRef = (0, react.useRef)(false);
168
+ const [validationErrorsRefreshVersion, setValidationErrorsRefreshVersion] = (0, react.useState)(0);
169
+ const { resolver, validationErrors, validationErrorsHash } = useFormResolver(extendedValidation, (0, react.useCallback)(() => {
170
+ if (!hasPendingUserChangeRef.current) return;
171
+ hasPendingUserChangeRef.current = false;
172
+ setValidationErrorsRefreshVersion((prev) => {
173
+ return prev + 1;
174
+ });
175
+ }, []));
161
176
  const methods = (0, react_hook_form.useForm)({
162
177
  defaultValues: initialValues ? require_helpers_index.toFormFormat(initialValues) : initialValues,
163
178
  mode: validationTrigger,
@@ -173,6 +188,7 @@ const FormProvider = ({ children, debugModeSettings = void 0, initialValues = vo
173
188
  };
174
189
  }, []);
175
190
  const notifyUserChange = (0, react.useCallback)((fieldName, value) => {
191
+ hasPendingUserChangeRef.current = true;
176
192
  userChangeListenersRef.current.forEach((listener) => {
177
193
  listener(fieldName, value);
178
194
  });
@@ -236,7 +252,8 @@ const FormProvider = ({ children, debugModeSettings = void 0, initialValues = vo
236
252
  }, [
237
253
  debugMode,
238
254
  debugModeSettings?.disable,
239
- validationErrorsHash
255
+ validationErrorsHash,
256
+ validationErrorsRefreshVersion
240
257
  ]);
241
258
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UniformContext.Provider, {
242
259
  value: contextValue,
@@ -269,4 +286,4 @@ Object.defineProperty(exports, "__toESM", {
269
286
  }
270
287
  });
271
288
 
272
- //# sourceMappingURL=FormContext-Djp8wTG8.cjs.map
289
+ //# sourceMappingURL=FormContext-DwCicmnH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormContext-DwCicmnH.cjs","names":["toValidationFormat","debug","React","toFormFormat","toSubmitFormat","HookFormProvider"],"sources":["../src/Form/subcomponents/FormResolver.ts","../src/Form/subcomponents/FormContext.tsx"],"sourcesContent":["import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useCallback, useMemo, 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<VetoTypeAny[]>(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter((schema): schema is VetoTypeAny => {\n return Boolean(schema);\n });\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined =\n clientSchemaValues.reduce<VetoTypeAny | null>(\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (baseValidation && clientSchemasCombined) {\n // Put client validation first so dynamic/domain-specific messages\n // are returned before generic base validation errors.\n const baseSchema = baseValidation.schema as VetoTypeAny;\n return veto(and(clientSchemasCombined, baseSchema));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * 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 = (\n extendedValidation?: VetoInstance,\n onValidationErrorsChange?: (validationErrorsHash: string | undefined) => void,\n) => {\n // Keep validation errors in a ref to avoid re-renders on each resolver run.\n // This preserves UX/snapshot behavior where validation updates alone\n // do not force immediate visual error state changes.\n const validationErrors = useRef<VetoFormattedError>(undefined);\n const validationErrorsHash = useRef<string | undefined>(undefined);\n\n const updateValidationErrors = useCallback(\n (errors: VetoFormattedError | undefined): void => {\n // Store the formatted errors in a ref so resolver runs stay cheap and do\n // not automatically repaint every form consumer.\n validationErrors.current = errors;\n\n // The hash is the reactive signal for consumers. Only notify when the\n // actual error output changes, so repeated validations with the same\n // result do not cause avoidable context refreshes.\n const nextHash = JSON.stringify(errors);\n\n if (validationErrorsHash.current !== nextHash) {\n validationErrorsHash.current = nextHash;\n onValidationErrorsChange?.(nextHash);\n }\n },\n [onValidationErrorsChange],\n );\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n updateValidationErrors(result.errors ?? undefined);\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation, updateValidationErrors]);\n\n /* eslint-disable react-hooks/refs -- intentional non-reactive cache reads */\n const currentValidationErrors = validationErrors.current;\n const currentValidationErrorsHash = validationErrorsHash.current;\n\n return {\n resolver,\n validationErrors: currentValidationErrors,\n validationErrorsHash: currentValidationErrorsHash,\n };\n /* eslint-enable react-hooks/refs */\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, Path, SubmitHandler } from 'react-hook-form';\n\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport createDebug from 'debug';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toSubmitFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\nconst debug = createDebug('uniform:FormContext');\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\n/**\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 const hasPendingUserChangeRef = useRef(false);\n const [validationErrorsRefreshVersion, setValidationErrorsRefreshVersion] =\n useState(0);\n\n const handleValidationErrorsChange = useCallback(() => {\n if (!hasPendingUserChangeRef.current) {\n return;\n }\n\n hasPendingUserChangeRef.current = false;\n setValidationErrorsRefreshVersion((prev) => {\n return prev + 1;\n });\n }, []);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } = useFormResolver(\n extendedValidation,\n handleValidationErrorsChange,\n );\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 hasPendingUserChangeRef.current = true;\n\n // Notify all registered listeners\n userChangeListenersRef.current.forEach((listener) => {\n listener(fieldName as Path<object>, value);\n });\n },\n [],\n );\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n debug('handleSubmit called', {\n preventSubmit,\n formStateIsValid: methods.formState.isValid,\n validationErrors: methods.formState.errors,\n validationTrigger,\n formValues: methods.getValues(),\n });\n\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n debug('⛔ Form submit PREVENTED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n });\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n debug('✓ Form submit ALLOWED', {\n formStateIsValid: methods.formState.isValid,\n preventSubmit,\n reason: !methods.formState.isValid\n ? 'Form is invalid (will trigger validation and show errors)'\n : 'Form is valid and preventSubmit is false',\n });\n\n // Convert form data to submission format:\n // - Unwrap flat array wrappers and convert markers\n // - Remove empty strings, nulls, empty arrays, and empty objects\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toSubmitFormat(data) ?? {};\n debug('onSubmit callback called', { submitData });\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n\n debug('handleSubmit completed');\n };\n\n // Memoize the context value 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 [\n debugMode,\n debugModeSettings?.disable,\n validationErrorsHash,\n validationErrorsRefreshVersion,\n ],\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,+BAAA,GAAA,MAAA,UAE9B,CAAC,CAAC;CAsBJ,OAAO;EACL;EACA,4BAAA,GAAA,MAAA,eArB8C;GAC9C,QAAQ,KAAa,WAA+B;IAElD,4BAA4B,SAAS;KAEnC,IAAI,CAAC,KAAK,QAAQ,CAAC,QACjB,OAAO;KAGT,IAAI,CAAC,QAAQ;MACX,MAAM,GAAG,MAAM,UAAU,GAAG,SAAS;MACrC,OAAO;KACT;KAEA,OAAO;MAAE,GAAG;OAAO,MAAM;KAAO;IAClC,CAAC;GACH;EACF,GAAG,CAAC,CAIsB;CAC1B;AACF;;;;;;;AAQA,MAAa,yBAAyB,mBAAkC;CAEtE,MAAM,EAAE,yBAAyB,8BAC/B,2BAA2B;CAG7B,MAAM,sBAAA,GAAA,MAAA,eACE;EAEJ,OADa,OAAO,KAAK,uBAAuB,EAAE,KACxC,EACP,KAAK,QAAQ;GACZ,OAAO,wBAAwB;EACjC,CAAC,EACA,QAAQ,WAAkC;GACzC,OAAO,QAAQ,MAAM;EACvB,CAAC;CACL,GAEA,CAAC,uBAAuB,CAC1B;CA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;CAGA,MAAM,gBAAA,GAAA,MAAA,eACE;EACJ,OAAO;GAGL,WAAW,mBAAmB,UAAU,aAAa;GACrD,gBAAgB,YAAqB;IACnC,QAAM,wBAAwB;KAC5B,eAAe;KACf,UAAU;KACV,kBAAkB,QAAQ,UAAU;KACpC,kBAAkB,QAAQ,UAAU;IACtC,CAAC;IACD,iBAAiB,OAAO;GAC1B;GACA;GACA;GACA,eAAe;GACf,YAAY;IACV,WAAW;IACX,QAAQ;GACV;GACA,YAAY;IACV,cAAc;IACd,UAAU;IACV,QAAQ;IACR;GACF;EACF;CACF,GAEA;EACE;EACA,mBAAmB;EACnB;EACA;CACF,CACF;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAC,eAAe,UAAhB;EAAyB,OAAO;YAE9B,iBAAA,GAAA,kBAAA,KAACC,gBAAAA,cAAD;GAAkB,GAAI;aACnB,SAAS;IAAE;IAAc;GAAQ,CAAC;EACnB,CAAA;CACK,CAAA;AAE7B"}
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Grid = require("../Grid-BPOumLUp.cjs");
5
+ const require_Grid = require("../Grid-DIe8WII9.cjs");
6
6
  exports.Grid = require_Grid.Grid;
7
7
  exports.default = require_Grid.Grid_default;
@@ -1,4 +1,4 @@
1
- require("./FormContext-Djp8wTG8.cjs");
1
+ require("./FormContext-DwCicmnH.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
  //#region src/Grid/Grid.tsx
@@ -29,4 +29,4 @@ Object.defineProperty(exports, "Grid_default", {
29
29
  }
30
30
  });
31
31
 
32
- //# sourceMappingURL=Grid-BPOumLUp.cjs.map
32
+ //# sourceMappingURL=Grid-DIe8WII9.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Grid-BPOumLUp.cjs","names":[],"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-6', 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,KAAA,GACZ,SAAS,KAAA,QACM;CACf,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,YAAA,GAAA,uBAAA,IAAc,cAAc,SAAS;EAAG,eAAa;EACvD;CACE,CAAA;AAET;;;ACpBA,IAAA,eAAe"}
1
+ {"version":3,"file":"Grid-DIe8WII9.cjs","names":[],"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-6', 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,KAAA,GACZ,SAAS,KAAA,QACM;CACf,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,YAAA,GAAA,uBAAA,IAAc,cAAc,SAAS;EAAG,eAAa;EACvD;CACE,CAAA;AAET;;;ACpBA,IAAA,eAAe"}
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Input = require("../Input-D64GjrZJ.cjs");
5
+ const require_Input = require("../Input-Bi75-PA6.cjs");
6
6
  exports.Input = require_Input.Input;
7
7
  exports.default = require_Input.Input_default;
@@ -1,2 +1,2 @@
1
- import { n as InputProps, t as Input } from "../index-A8Jhitar.cjs";
1
+ import { n as InputProps, t as Input } from "../index-DxXdHxyY.cjs";
2
2
  export { Input, Input as default, type InputProps };
@@ -1,2 +1,2 @@
1
- import { n as InputProps, t as Input } from "../index-5_7F4o-d.js";
1
+ import { n as InputProps, t as Input } from "../index-C4Qex3mx.js";
2
2
  export { Input, Input as default, type InputProps };
@@ -1,4 +1,4 @@
1
- require("./FormContext-Djp8wTG8.cjs");
1
+ require("./FormContext-DwCicmnH.cjs");
2
2
  const require_hooks_useUniformField_index = require("./hooks/useUniformField/index.cjs");
3
3
  const require_hooks_useInputValueDebounce_index = require("./hooks/useInputValueDebounce/index.cjs");
4
4
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
@@ -105,4 +105,4 @@ Object.defineProperty(exports, "Input_default", {
105
105
  }
106
106
  });
107
107
 
108
- //# sourceMappingURL=Input-D64GjrZJ.cjs.map
108
+ //# sourceMappingURL=Input-Bi75-PA6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input-D64GjrZJ.cjs","names":["useUniformField","useInputValueDebounce","HeroNumberInput","HeroInput"],"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,iBAAA,GAAA,uBAAA,IAAmB,EAC9B,OAAO;;CAEL,MAAM;;CAEN,aAAa;;CAEb,OAAO;;CAEP,cAAc;AAChB,EACF,CAAC;;;;AAyCD,MAAM,SAAS,EACb,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,KAAA,GACb,MACA,UAAU,KAAA,GACV,cAAc,KACd,OAAO,KAAA,GACP,eAAe,KAAA,GACf,OAAO,KAAA,GACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACEA,oCAAAA,gBAAgB;EAAE;EAAM;EAAM,GAAG;CAAkB,CAAC;CAGxD,MAAM,EAAE,UAAU,QAAQ,UAAUC,0CAAAA,sBAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;CACT,CAAC;CAGD,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;GAGb,WAAW,MAAM,EAAE,cAAc,KAAK,CAAC;GAEvC,IAAI,SACF,QAAQ;EAEZ;CACF,IACA,CAAC;CAIP,MAAM,cAAA,GAAA,uBAAA,sBADW,cAC8B,GAAG,YAAY,MAAM;CAGpE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,KAAK,MAAM,KAAK,YAAY,KAAA;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;EAC3B;EACA,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;CACL;CAGA,IAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,KAAK,CAAC,IACxD,OAAO,KAAK,IACZ;EAEN,OACE,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,aAAD;GACE,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,MACf;GAEA,WAAW,MAAoD;IAC7D,IAAI,OAAO,MAAM,UAEf,SAAS,EACP,QAAQ,EAAE,OAAO,OAAO,CAAC,EAAE,EAC7B,CAAwC;SAGxC,SAAS,CAAC;GAEd;EACD,CAAA;CAEL;CAGA,OACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;EAAW,GAAI;EAAuB;EAAgB;EAAa;CAAQ,CAAA;AAE/E;;;ACjMA,IAAA,gBAAe"}
1
+ {"version":3,"file":"Input-Bi75-PA6.cjs","names":["useUniformField","useInputValueDebounce","HeroNumberInput","HeroInput"],"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,iBAAA,GAAA,uBAAA,IAAmB,EAC9B,OAAO;;CAEL,MAAM;;CAEN,aAAa;;CAEb,OAAO;;CAEP,cAAc;AAChB,EACF,CAAC;;;;AAyCD,MAAM,SAAS,EACb,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,KAAA,GACb,MACA,UAAU,KAAA,GACV,cAAc,KACd,OAAO,KAAA,GACP,eAAe,KAAA,GACf,OAAO,KAAA,GACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACEA,oCAAAA,gBAAgB;EAAE;EAAM;EAAM,GAAG;CAAkB,CAAC;CAGxD,MAAM,EAAE,UAAU,QAAQ,UAAUC,0CAAAA,sBAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;CACT,CAAC;CAGD,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;GAGb,WAAW,MAAM,EAAE,cAAc,KAAK,CAAC;GAEvC,IAAI,SACF,QAAQ;EAEZ;CACF,IACA,CAAC;CAIP,MAAM,cAAA,GAAA,uBAAA,sBADW,cAC8B,GAAG,YAAY,MAAM;CAGpE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,KAAK,MAAM,KAAK,YAAY,KAAA;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;EAC3B;EACA,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;CACL;CAGA,IAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,KAAK,CAAC,IACxD,OAAO,KAAK,IACZ;EAEN,OACE,iBAAA,GAAA,kBAAA,KAACC,qBAAAA,aAAD;GACE,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,MACf;GAEA,WAAW,MAAoD;IAC7D,IAAI,OAAO,MAAM,UAEf,SAAS,EACP,QAAQ,EAAE,OAAO,OAAO,CAAC,EAAE,EAC7B,CAAwC;SAGxC,SAAS,CAAC;GAEd;EACD,CAAA;CAEL;CAGA,OACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,OAAD;EAAW,GAAI;EAAuB;EAAgB;EAAa;CAAQ,CAAA;AAE/E;;;ACjMA,IAAA,gBAAe"}
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_RadioBoxes = require("../RadioBoxes-DpBv9exN.cjs");
5
+ const require_RadioBoxes = require("../RadioBoxes-D9cMQ9hJ.cjs");
6
6
  exports.RadioBoxes = require_RadioBoxes.RadioBoxes;
7
7
  exports.default = require_RadioBoxes.RadioBoxes_default;
8
8
  exports.radioBoxVariants = require_RadioBoxes.radioBoxVariants;
@@ -1,2 +1,2 @@
1
- import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-Dz1C3MeK.cjs";
1
+ import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-cxajYZel.cjs";
2
2
  export { RadioBoxes, RadioBoxes as default, type RadioBoxesProps, radioBoxVariants };
@@ -1,2 +1,2 @@
1
- import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-D-UGVdC1.js";
1
+ import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-B682jKQ_.js";
2
2
  export { RadioBoxes, RadioBoxes as default, type RadioBoxesProps, radioBoxVariants };
@@ -1,4 +1,4 @@
1
- require("./FormContext-Djp8wTG8.cjs");
1
+ require("./FormContext-DwCicmnH.cjs");
2
2
  const require_helpers_index = require("./helpers/index.cjs");
3
3
  const require_hooks_useUniformField_index = require("./hooks/useUniformField/index.cjs");
4
4
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
@@ -150,4 +150,4 @@ Object.defineProperty(exports, "radioBoxVariants", {
150
150
  }
151
151
  });
152
152
 
153
- //# sourceMappingURL=RadioBoxes-DpBv9exN.cjs.map
153
+ //# sourceMappingURL=RadioBoxes-D9cMQ9hJ.cjs.map