@fuf-stack/uniform 1.20.16 → 1.20.18

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 (208) hide show
  1. package/dist/Checkboxes/index.cjs +1 -1
  2. package/dist/{Checkboxes-CqlbSLHi.cjs → Checkboxes-Ce7gp6L_.cjs} +3 -3
  3. package/dist/{Checkboxes-CqlbSLHi.cjs.map → Checkboxes-Ce7gp6L_.cjs.map} +1 -1
  4. package/dist/FieldArray/index.cjs +1 -1
  5. package/dist/{FieldArray-DtlFSbHK.cjs → FieldArray-DoQWRu2l.cjs} +4 -4
  6. package/dist/{FieldArray-DtlFSbHK.cjs.map → FieldArray-DoQWRu2l.cjs.map} +1 -1
  7. package/dist/FieldCard/index.cjs +1 -1
  8. package/dist/FieldCard/index.js +1 -1
  9. package/dist/{FieldCard-BuUT2zKN.js → FieldCard-B0q2ozHB.js} +2 -2
  10. package/dist/{FieldCard-BuUT2zKN.js.map → FieldCard-B0q2ozHB.js.map} +1 -1
  11. package/dist/{FieldCard-BNsMMgh3.cjs → FieldCard-mmhQQw-O.cjs} +4 -4
  12. package/dist/{FieldCard-BNsMMgh3.cjs.map → FieldCard-mmhQQw-O.cjs.map} +1 -1
  13. package/dist/{FieldCopyTestIdButton-_5kpA4ii.cjs → FieldCopyTestIdButton-slAdYh6I.cjs} +2 -2
  14. package/dist/{FieldCopyTestIdButton-_5kpA4ii.cjs.map → FieldCopyTestIdButton-slAdYh6I.cjs.map} +1 -1
  15. package/dist/{FieldValidationError-D40HtO_l.cjs → FieldValidationError-BWrQN-Im.cjs} +2 -2
  16. package/dist/{FieldValidationError-D40HtO_l.cjs.map → FieldValidationError-BWrQN-Im.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-CMNpqbIM.cjs} +3 -3
  20. package/dist/{Form-BQbwyvPX.cjs.map → Form-CMNpqbIM.cjs.map} +1 -1
  21. package/dist/{Form-BodvG3wG.js → Form-DFN-rkO9.js} +3 -3
  22. package/dist/{Form-BodvG3wG.js.map → Form-DFN-rkO9.js.map} +1 -1
  23. package/dist/{FormContext-Djp8wTG8.cjs → FormContext-CjDd8Zej.cjs} +41 -18
  24. package/dist/FormContext-CjDd8Zej.cjs.map +1 -0
  25. package/dist/{FormContext-DMaTuTAr.js → FormContext-Fwnjz-qH.js} +41 -18
  26. package/dist/FormContext-Fwnjz-qH.js.map +1 -0
  27. package/dist/Grid/index.cjs +1 -1
  28. package/dist/{Grid-BPOumLUp.cjs → Grid-BWKp1Yh_.cjs} +2 -2
  29. package/dist/{Grid-BPOumLUp.cjs.map → Grid-BWKp1Yh_.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-DGhyRiMM.cjs} +2 -2
  34. package/dist/{Input-D64GjrZJ.cjs.map → Input-DGhyRiMM.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-DtDsfytJ.cjs} +2 -2
  39. package/dist/{RadioBoxes-DpBv9exN.cjs.map → RadioBoxes-DtDsfytJ.cjs.map} +1 -1
  40. package/dist/RadioTabs/index.cjs +1 -1
  41. package/dist/{RadioTabs-CPsErN1U.cjs → RadioTabs-yo3ASUWR.cjs} +2 -2
  42. package/dist/{RadioTabs-CPsErN1U.cjs.map → RadioTabs-yo3ASUWR.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-hrf-19X9.cjs} +2 -2
  47. package/dist/{Radios-LA38MXVt.cjs.map → Radios-hrf-19X9.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-np0WO9nP.js → Select-DaNyxmXo.js} +2 -2
  53. package/dist/{Select-np0WO9nP.js.map → Select-DaNyxmXo.js.map} +1 -1
  54. package/dist/{Select-DsSdFeWq.cjs → Select-DclJqWpM.cjs} +3 -3
  55. package/dist/{Select-DsSdFeWq.cjs.map → Select-DclJqWpM.cjs.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-xbjMc6HR.cjs} +2 -2
  60. package/dist/{Slider-BXPgYL-o.cjs.map → Slider-xbjMc6HR.cjs.map} +1 -1
  61. package/dist/SubmitButton/index.cjs +1 -1
  62. package/dist/SubmitButton/index.js +1 -1
  63. package/dist/{SubmitButton-DgEHHy3N.cjs → SubmitButton-B1qXzbep.cjs} +3 -3
  64. package/dist/{SubmitButton-DgEHHy3N.cjs.map → SubmitButton-B1qXzbep.cjs.map} +1 -1
  65. package/dist/{SubmitButton-QWpHBvg9.js → SubmitButton-DzNSPC99.js} +2 -2
  66. package/dist/{SubmitButton-QWpHBvg9.js.map → SubmitButton-DzNSPC99.js.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-D_g-eGfF.cjs} +2 -2
  71. package/dist/{Switch-B_R9hdxd.cjs.map → Switch-D_g-eGfF.cjs.map} +1 -1
  72. package/dist/SwitchBox/index.cjs +1 -1
  73. package/dist/{SwitchBox-DZXIJjgl.cjs → SwitchBox-WNEmMraH.cjs} +2 -2
  74. package/dist/{SwitchBox-DZXIJjgl.cjs.map → SwitchBox-WNEmMraH.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-CY9PRp27.cjs} +2 -2
  79. package/dist/{TextArea-CsNyG6DY.cjs.map → TextArea-CY9PRp27.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 +13 -13
  100. package/dist/hooks/useUniformField/index.cjs.map +1 -1
  101. package/dist/hooks/useUniformField/index.d.cts +1 -1
  102. package/dist/hooks/useUniformField/index.d.ts +1 -1
  103. package/dist/hooks/useUniformField/index.js +9 -9
  104. package/dist/hooks/useUniformField/index.js.map +1 -1
  105. package/dist/hooks/useUniformFieldArray/index.cjs +2 -2
  106. package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
  107. package/dist/hooks/useUniformFieldArray/index.d.ts +1 -1
  108. package/dist/hooks/useUniformFieldArray/index.js +1 -1
  109. package/dist/hooks/useWatchUserChange/index.cjs +1 -1
  110. package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
  111. package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
  112. package/dist/hooks/useWatchUserChange/index.js +1 -1
  113. package/dist/{index-D6QbkuWC.d.ts → index--LtIs0zN.d.ts} +4 -4
  114. package/dist/{index-D6QbkuWC.d.ts.map → index--LtIs0zN.d.ts.map} +1 -1
  115. package/dist/{index-C_3x4Vph.d.cts → index-9nJkzuEx.d.cts} +4 -4
  116. package/dist/{index-C_3x4Vph.d.cts.map → index-9nJkzuEx.d.cts.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-Cj3P2Pmf.d.ts → index-BmR6MFmN.d.ts} +4 -4
  122. package/dist/{index-Cj3P2Pmf.d.ts.map → index-BmR6MFmN.d.ts.map} +1 -1
  123. package/dist/{index-RavMgGrt.d.ts → index-BqiVSpJW.d.cts} +1 -1
  124. package/dist/{index-BLbC1_g_.d.cts.map → index-BqiVSpJW.d.cts.map} +1 -1
  125. package/dist/{index-5_7F4o-d.d.ts → index-C4Qex3mx.d.ts} +4 -4
  126. package/dist/{index-5_7F4o-d.d.ts.map → index-C4Qex3mx.d.ts.map} +1 -1
  127. package/dist/{index-Ck9KE5Pj2.d.ts → index-CqyMqRhI.d.cts} +1 -1
  128. package/dist/{index-BlVK355b.d.cts.map → index-CqyMqRhI.d.cts.map} +1 -1
  129. package/dist/{index-CD9w4hqS.d.cts → index-DS4Uwz_8.d.cts} +7 -7
  130. package/dist/{index-CD9w4hqS.d.cts.map → index-DS4Uwz_8.d.cts.map} +1 -1
  131. package/dist/{index-eEJp36Ma.d.cts → index-DjlWsl17.d.cts} +7 -7
  132. package/dist/{index-eEJp36Ma.d.cts.map → index-DjlWsl17.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-CsDbfwLQ.d.cts → index-DyM6HUzl.d.cts} +13 -13
  137. package/dist/{index-CsDbfwLQ.d.cts.map → index-DyM6HUzl.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-VmEFGBxN.d.cts +1 -0
  141. package/dist/{index-CjB9iCSm.d.ts → index-WUp_s0O6.d.ts} +13 -13
  142. package/dist/{index-CjB9iCSm.d.ts.map → index-WUp_s0O6.d.ts.map} +1 -1
  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-DTwIpIWh.d.ts → index-cfS-Xcuy.d.ts} +7 -7
  146. package/dist/{index-DTwIpIWh.d.ts.map → index-cfS-Xcuy.d.ts.map} +1 -1
  147. package/dist/{index-Dz1C3MeK.d.cts → index-cxajYZel.d.cts} +4 -4
  148. package/dist/{index-Dz1C3MeK.d.cts.map → index-cxajYZel.d.cts.map} +1 -1
  149. package/dist/{index-RCXYx5Yp.d.ts → index-rfWwEWWF.d.ts} +7 -7
  150. package/dist/{index-RCXYx5Yp.d.ts.map → index-rfWwEWWF.d.ts.map} +1 -1
  151. package/dist/index.cjs +23 -23
  152. package/dist/index.d.cts +15 -15
  153. package/dist/index.d.ts +15 -15
  154. package/dist/index.js +8 -8
  155. package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
  156. package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
  157. package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
  158. package/dist/partials/FieldValidationError/index.cjs +1 -1
  159. package/dist/partials/FieldValidationError/index.d.cts +1 -1
  160. package/dist/partials/FieldValidationError/index.d.ts +1 -1
  161. package/dist/{useClientValidation-DtnfCE5T.d.cts → useClientValidation-BMzOi3DZ.d.cts} +1 -1
  162. package/dist/{useClientValidation-DtnfCE5T.d.cts.map → useClientValidation-BMzOi3DZ.d.cts.map} +1 -1
  163. package/dist/{useClientValidation-BWElhQ91.d.ts → useClientValidation-BTbGUViN.d.ts} +1 -1
  164. package/dist/{useClientValidation-BWElhQ91.d.ts.map → useClientValidation-BTbGUViN.d.ts.map} +1 -1
  165. package/dist/{useClientValidation-_GEt49og.cjs → useClientValidation-BdchY9gA.cjs} +3 -3
  166. package/dist/{useClientValidation-_GEt49og.cjs.map → useClientValidation-BdchY9gA.cjs.map} +1 -1
  167. package/dist/{useClientValidation-7iy9lEfO.js → useClientValidation-yI5G3jqT.js} +2 -2
  168. package/dist/{useClientValidation-7iy9lEfO.js.map → useClientValidation-yI5G3jqT.js.map} +1 -1
  169. package/dist/{useController-lNSzBL-i.cjs → useController-BCvnjoe0.cjs} +2 -2
  170. package/dist/{useController-lNSzBL-i.cjs.map → useController-BCvnjoe0.cjs.map} +1 -1
  171. package/dist/{useController-Cc0UNQMm.d.ts → useController-BK2AeY9L.d.ts} +1 -1
  172. package/dist/{useController-Cc0UNQMm.d.ts.map → useController-BK2AeY9L.d.ts.map} +1 -1
  173. package/dist/{useController-BQ4LoFBd.js → useController-DVF2y3O3.js} +2 -2
  174. package/dist/{useController-BQ4LoFBd.js.map → useController-DVF2y3O3.js.map} +1 -1
  175. package/dist/{useController-CNiqy_2D.d.cts → useController-kxcnnsXy.d.cts} +1 -1
  176. package/dist/{useController-CNiqy_2D.d.cts.map → useController-kxcnnsXy.d.cts.map} +1 -1
  177. package/dist/{useFormContext-CNGE9heQ.cjs → useFormContext-C_EQr8dV.cjs} +2 -2
  178. package/dist/{useFormContext-CNGE9heQ.cjs.map → useFormContext-C_EQr8dV.cjs.map} +1 -1
  179. package/dist/{useFormContext-2vyVWpUJ.js → useFormContext-DJ-9hs8X.js} +2 -2
  180. package/dist/{useFormContext-2vyVWpUJ.js.map → useFormContext-DJ-9hs8X.js.map} +1 -1
  181. package/dist/{useInputValueTransform-5jjQVowe.cjs → useInputValueTransform-f50WxOkF.cjs} +2 -2
  182. package/dist/{useInputValueTransform-5jjQVowe.cjs.map → useInputValueTransform-f50WxOkF.cjs.map} +1 -1
  183. package/dist/{useUniformField-CMb5EZ7Y.d.ts → useUniformField-B3Dj8K5J.d.ts} +2 -2
  184. package/dist/{useUniformField-CMb5EZ7Y.d.ts.map → useUniformField-B3Dj8K5J.d.ts.map} +1 -1
  185. package/dist/{useUniformField-D-Klu-sM.d.cts → useUniformField-BWKBsUEX.d.cts} +2 -2
  186. package/dist/{useUniformField-D-Klu-sM.d.cts.map → useUniformField-BWKBsUEX.d.cts.map} +1 -1
  187. package/dist/{useUniformFieldArray-eDkxErv8.d.ts → useUniformFieldArray-C0U3eBr7.d.ts} +2 -2
  188. package/dist/useUniformFieldArray-C0U3eBr7.d.ts.map +1 -0
  189. package/dist/{useUniformFieldArray-KClEBFyP.d.cts → useUniformFieldArray-RvOYml8h.d.cts} +2 -2
  190. package/dist/useUniformFieldArray-RvOYml8h.d.cts.map +1 -0
  191. package/dist/{useWatchUserChange-CZu_ZZ38.d.cts → useWatchUserChange-26IF7Ikq.d.cts} +1 -1
  192. package/dist/{useWatchUserChange-CZu_ZZ38.d.cts.map → useWatchUserChange-26IF7Ikq.d.cts.map} +1 -1
  193. package/dist/{useWatchUserChange-CH4x16_r.d.ts → useWatchUserChange-BjRKMix1.d.ts} +1 -1
  194. package/dist/{useWatchUserChange-CH4x16_r.d.ts.map → useWatchUserChange-BjRKMix1.d.ts.map} +1 -1
  195. package/dist/{useWatchUserChange-BSfuusTZ.cjs → useWatchUserChange-CzaVGB74.cjs} +3 -3
  196. package/dist/{useWatchUserChange-BSfuusTZ.cjs.map → useWatchUserChange-CzaVGB74.cjs.map} +1 -1
  197. package/dist/{useWatchUserChange-DdmIHIkf.js → useWatchUserChange-aFYR-oaQ.js} +2 -2
  198. package/dist/{useWatchUserChange-DdmIHIkf.js.map → useWatchUserChange-aFYR-oaQ.js.map} +1 -1
  199. package/package.json +5 -5
  200. package/dist/FormContext-DMaTuTAr.js.map +0 -1
  201. package/dist/FormContext-Djp8wTG8.cjs.map +0 -1
  202. package/dist/index-0zgyvkAF.d.cts +0 -224
  203. package/dist/index-0zgyvkAF.d.cts.map +0 -1
  204. package/dist/index-DVGo3QuA.d.ts +0 -224
  205. package/dist/index-DVGo3QuA.d.ts.map +0 -1
  206. package/dist/index-RavMgGrt.d.ts.map +0 -1
  207. package/dist/useUniformFieldArray-KClEBFyP.d.cts.map +0 -1
  208. package/dist/useUniformFieldArray-eDkxErv8.d.ts.map +0 -1
@@ -1,2 +1,224 @@
1
- import { a as toFormFormat, c as toValidationFormat, i as nameToTestId, l as createOptionValueConverter, n as fromNullishString, o as toNullishString, r as isValueEmpty, s as toSubmitFormat, t as flatArrayKey } from "../index-DVGo3QuA.js";
2
- export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
1
+ //#region src/helpers/createOptionValueConverter/createOptionValueConverter.d.ts
2
+ /**
3
+ * Creates a converter function that preserves the original type (string, number, or boolean)
4
+ * of option values when converting from string keys back to their original type.
5
+ *
6
+ * This is useful for radio/select components where the underlying UI library
7
+ * uses string keys internally, but we want to preserve number/boolean values in the form state.
8
+ *
9
+ * @param options - Array of options with a value property that can be string, number, or boolean
10
+ * @returns An object with:
11
+ * - `convertToOriginalType`: Function to convert a string key back to its original type
12
+ * - `numberValueKeys`: Set of string representations of number values (for internal use)
13
+ * - `booleanValueKeys`: Map of string representations to boolean values (for internal use)
14
+ */
15
+ declare const createOptionValueConverter: <T extends {
16
+ value: string | number | boolean;
17
+ }>(options: T[]) => {
18
+ booleanValueKeys: Map<string, boolean>;
19
+ convertToOriginalType: (key: string | number | boolean) => string | number | boolean;
20
+ numberValueKeys: Set<string>;
21
+ };
22
+ //#endregion
23
+ //#region src/helpers/nullishFields/nullishFields.d.ts
24
+ /** Key used to wrap flat array elements when converting to form format */
25
+ declare const flatArrayKey = "__FLAT__";
26
+ /**
27
+ * Checks if a value is considered "empty" for validation display purposes.
28
+ *
29
+ * Used by useUniformField to determine when to show validation errors.
30
+ * Empty values don't trigger immediate error display (user must interact first).
31
+ *
32
+ * Handles:
33
+ * - Primitives: null, undefined, ''
34
+ * - Marker strings: __NULL__, __FALSE__, __ZERO__ (converted via fromNullishString)
35
+ * - Empty arrays: []
36
+ * - Objects with all empty values: {a: null, b: ''}
37
+ * - Flat array wrappers: {__FLAT__: null} or {__FLAT__: ''}
38
+ *
39
+ * @param value - The value to check (will be converted via fromNullishString first)
40
+ * @returns true if the value is empty
41
+ *
42
+ * @example
43
+ * isValueEmpty(null) // true
44
+ * isValueEmpty('') // true
45
+ * isValueEmpty('__NULL__') // true (marker string)
46
+ * isValueEmpty([]) // true (empty array)
47
+ * isValueEmpty({a: null}) // true (object with all empty values)
48
+ * isValueEmpty({__FLAT__: null}) // true (flat array wrapper with empty value)
49
+ * isValueEmpty({__FLAT__: ''}) // true
50
+ * isValueEmpty('hello') // false
51
+ * isValueEmpty([1, 2]) // false
52
+ * isValueEmpty({a: 'value'}) // false
53
+ * isValueEmpty({__FLAT__: 'value'}) // false
54
+ */
55
+ declare const isValueEmpty: (value: unknown) => boolean;
56
+ /**
57
+ * Converts marker strings back to their original values when processing arrays
58
+ */
59
+ declare const fromNullishString: (value: unknown) => unknown;
60
+ /**
61
+ * Converts null/falsy values to marker strings for JSON processing
62
+ */
63
+ declare const toNullishString: (value: unknown) => unknown;
64
+ /**
65
+ * Converts field values to a format suitable for forms by:
66
+ * - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`
67
+ * to satisfy RHF's requirement that array fields contain objects
68
+ * - Removing empty strings and null values from objects
69
+ *
70
+ * This conversion is required because React Hook Form does not support arrays with
71
+ * flat values (string, number, boolean, null). Array fields must contain objects.
72
+ * We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.
73
+ *
74
+ * @example
75
+ * const fields = {
76
+ * name: 'John',
77
+ * scores: [0, null, 75, false],
78
+ * scoresDetailed: [
79
+ * { score: 1 },
80
+ * { score: null },
81
+ * { score: 0 },
82
+ * { score: false },
83
+ * { score: '' },
84
+ * ],
85
+ * contact: {
86
+ * email: '',
87
+ * phone: null,
88
+ * address: '123 Main St'
89
+ * }
90
+ * };
91
+ *
92
+ * // Result:
93
+ * {
94
+ * name: 'John',
95
+ * scores: [
96
+ * { __FLAT__: 0 },
97
+ * { __FLAT__: null },
98
+ * { __FLAT__: 75 },
99
+ * { __FLAT__: false }
100
+ * ],
101
+ * // Arrays of objects are left as objects; empty/null properties are removed
102
+ * scoresDetailed: [
103
+ * { score: 1 },
104
+ * {}, // null score removed
105
+ * { score: 0 },
106
+ * { score: false },
107
+ * {}, // empty string removed
108
+ * ],
109
+ * contact: {
110
+ * address: '123 Main St'
111
+ * }
112
+ * }
113
+ */
114
+ declare const toFormFormat: (fields: Record<string, unknown>) => Record<string, unknown>;
115
+ /**
116
+ * Converts form state to a format suitable for validation by:
117
+ * - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives
118
+ * - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values
119
+ * - Removing fields whose converted value is empty string or null
120
+ * - Removing empty arrays
121
+ *
122
+ * @example
123
+ * const formState = {
124
+ * name: 'John',
125
+ * scores: [
126
+ * { __FLAT__: 75 },
127
+ * { __FLAT__: 0 },
128
+ * { __FLAT__: null },
129
+ * { __FLAT__: false }
130
+ * ],
131
+ * emptyArray: [],
132
+ * scoresDetailed: [
133
+ * { score: 1 },
134
+ * {},
135
+ * { score: 0 },
136
+ * { score: false },
137
+ * {},
138
+ * ],
139
+ * contact: {
140
+ * address: '123 Main St',
141
+ * fax: null
142
+ * }
143
+ * };
144
+ *
145
+ * // Result:
146
+ * {
147
+ * name: 'John',
148
+ * scores: [75, 0, null, false],
149
+ * // emptyArray is removed
150
+ * // Objects inside arrays remain objects; empty entries remain empty objects
151
+ * scoresDetailed: [
152
+ * { score: 1 },
153
+ * {},
154
+ * { score: 0 },
155
+ * { score: false },
156
+ * {},
157
+ * ],
158
+ * contact: {
159
+ * address: '123 Main St'
160
+ * }
161
+ * }
162
+ */
163
+ declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
164
+ /**
165
+ * Converts form state to a format suitable for submission by:
166
+ * - Applying all transformations from toValidationFormat
167
+ * - Additionally removing empty objects from the result
168
+ * - Filtering empty objects from arrays
169
+ * - Recursively cleaning nested structures
170
+ *
171
+ * **Why separate from toValidationFormat?**
172
+ *
173
+ * Empty objects must be preserved during validation so that custom refinements
174
+ * can run. For example, a FieldCard with "at least email or phone required"
175
+ * validation needs the object to exist (even if empty) for the refine to execute.
176
+ *
177
+ * However, for submission, empty objects are meaningless and should be removed
178
+ * to produce clean data for APIs.
179
+ *
180
+ * @example
181
+ * const formState = {
182
+ * name: 'John',
183
+ * contact: {}, // Empty FieldCard - will be removed
184
+ * tags: [{}, {}, {}], // All empty - array will be removed
185
+ * items: [
186
+ * { value: 'a' },
187
+ * {}, // Empty entry - will be filtered out
188
+ * { value: 'b' }
189
+ * ],
190
+ * nested: {
191
+ * deep: {} // Nested empty - will be removed recursively
192
+ * }
193
+ * };
194
+ *
195
+ * // Result:
196
+ * {
197
+ * name: 'John',
198
+ * items: [{ value: 'a' }, { value: 'b' }]
199
+ * }
200
+ */
201
+ declare const toSubmitFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
202
+ /**
203
+ * Converts a field name to a testId by removing flat array key segments and slugifying.
204
+ * Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
205
+ *
206
+ * This is used to generate stable testIds for form fields that don't include
207
+ * the internal `__FLAT__` marker used for flat arrays.
208
+ *
209
+ * @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])
210
+ * @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * nameToTestId('tags.0.__FLAT__') // => 'tags_0'
215
+ * nameToTestId('array.0.__FLAT__') // => 'array_0'
216
+ * nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'
217
+ * nameToTestId('simple.field') // => 'simple_field'
218
+ * nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'
219
+ * ```
220
+ */
221
+ declare const nameToTestId: (name: string | readonly string[]) => string;
222
+ //#endregion
223
+ export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
224
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../../src/helpers/nullishFields/nullishFields.ts"],"mappings":";;AAeA;;;;;;;;;;;;cAAa,0BAAA;EACC,KAAA;AAAA,GAEZ,OAAA,EAAS,CAAA;;;;;;;;cCfE,YAAA;;;;;;;;;;;;;;;;;;;;;;;AAAb;;;;AAAyB;AAsCzB;;cAAa,YAAA,GAAgB,KAAc;;AAAA;AA0B3C;cAAa,iBAAA,GAAqB,KAAc;;;AAAA;cAsCnC,eAAA,GAAmB,KAAc;;;;AAAA;AA6E9C;;;;;;;;AAwB6C;AAmD7C;;;;;;;;AAES;AAuKT;;;;;;;;AAES;AA2BT;;;;AAA6D;;;;;;;;;;;;;;;cAjRhD,YAAA,GAAgB,MAAA,EAAQ,MAAA,sBAwBE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmDhC,kBAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuKI,cAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAM;;;;;;;;;;;;;;;;;;;;cA2BI,YAAA,GAAgB,IAAgC"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useClientValidation = require("../../useClientValidation-_GEt49og.cjs");
2
+ const require_useClientValidation = require("../../useClientValidation-BdchY9gA.cjs");
3
3
  //#region src/hooks/useClientValidation/index.ts
4
4
  /* v8 ignore stop */
5
5
  //#endregion
@@ -1,2 +1,2 @@
1
- import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-DtnfCE5T.cjs";
1
+ import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-BMzOi3DZ.cjs";
2
2
  export { clientValidationSchemaByName, useClientValidation };
@@ -1,2 +1,2 @@
1
- import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-BWElhQ91.js";
1
+ import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-BTbGUViN.js";
2
2
  export { clientValidationSchemaByName, useClientValidation };
@@ -1,4 +1,4 @@
1
- import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-7iy9lEfO.js";
1
+ import { n as useClientValidation, t as clientValidationSchemaByName } from "../../useClientValidation-yI5G3jqT.js";
2
2
  //#region src/hooks/useClientValidation/index.ts
3
3
  /* v8 ignore stop */
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useController = require("../../useController-lNSzBL-i.cjs");
2
+ const require_useController = require("../../useController-BCvnjoe0.cjs");
3
3
  //#region src/hooks/useController/index.ts
4
4
  /* v8 ignore stop */
5
5
  //#endregion
@@ -1,2 +1,2 @@
1
- import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-CNiqy_2D.cjs";
1
+ import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-kxcnnsXy.cjs";
2
2
  export { UseControllerProps, UseControllerReturn, useController };
@@ -1,2 +1,2 @@
1
- import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-Cc0UNQMm.js";
1
+ import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-BK2AeY9L.js";
2
2
  export { UseControllerProps, UseControllerReturn, useController };
@@ -1,4 +1,4 @@
1
- import { t as useController } from "../../useController-BQ4LoFBd.js";
1
+ import { t as useController } from "../../useController-DVF2y3O3.js";
2
2
  //#region src/hooks/useController/index.ts
3
3
  /* v8 ignore stop */
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useFormContext = require("../../useFormContext-CNGE9heQ.cjs");
2
+ const require_useFormContext = require("../../useFormContext-C_EQr8dV.cjs");
3
3
  //#region src/hooks/useFormContext/index.ts
4
4
  /* v8 ignore stop */
5
5
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-2vyVWpUJ.js";
1
+ import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-DJ-9hs8X.js";
2
2
  //#region src/hooks/useFormContext/index.ts
3
3
  /* v8 ignore stop */
4
4
  //#endregion
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../../FormContext-Djp8wTG8.cjs");
2
+ require("../../FormContext-CjDd8Zej.cjs");
3
3
  let _heroui_input = require("@heroui/input");
4
4
  //#region src/hooks/useInput/index.ts
5
5
  /* v8 ignore stop */
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../../FormContext-Djp8wTG8.cjs");
3
- const require_useFormContext = require("../../useFormContext-CNGE9heQ.cjs");
2
+ require("../../FormContext-CjDd8Zej.cjs");
3
+ const require_useFormContext = require("../../useFormContext-C_EQr8dV.cjs");
4
4
  let react = require("react");
5
5
  //#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { n as useFormContext } from "../../useFormContext-2vyVWpUJ.js";
1
+ import { n as useFormContext } from "../../useFormContext-DJ-9hs8X.js";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  //#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useInputValueTransform = require("../../useInputValueTransform-5jjQVowe.cjs");
2
+ const require_useInputValueTransform = require("../../useInputValueTransform-f50WxOkF.cjs");
3
3
  //#region src/hooks/useInputValueTransform/index.ts
4
4
  /* v8 ignore stop */
5
5
  //#endregion
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_FormContext = require("../../FormContext-Djp8wTG8.cjs");
2
+ const require_FormContext = require("../../FormContext-CjDd8Zej.cjs");
3
3
  const require_helpers_index = require("../../helpers/index.cjs");
4
- const require_FieldCopyTestIdButton = require("../../FieldCopyTestIdButton-_5kpA4ii.cjs");
5
- const require_FieldValidationError = require("../../FieldValidationError-D40HtO_l.cjs");
6
- const require_useController = require("../../useController-lNSzBL-i.cjs");
7
- const require_useFormContext = require("../../useFormContext-CNGE9heQ.cjs");
8
- const require_useInputValueTransform = require("../../useInputValueTransform-5jjQVowe.cjs");
4
+ const require_FieldCopyTestIdButton = require("../../FieldCopyTestIdButton-slAdYh6I.cjs");
5
+ const require_FieldValidationError = require("../../FieldValidationError-BWrQN-Im.cjs");
6
+ const require_useController = require("../../useController-BCvnjoe0.cjs");
7
+ const require_useFormContext = require("../../useFormContext-C_EQr8dV.cjs");
8
+ const require_useInputValueTransform = require("../../useInputValueTransform-f50WxOkF.cjs");
9
9
  let react = require("react");
10
10
  react = require_FormContext.__toESM(react);
11
11
  let _fuf_stack_pixels = require("@fuf-stack/pixels");
@@ -43,7 +43,7 @@ let _heroui_input = require("@heroui/input");
43
43
  const useUniformField = (params) => {
44
44
  const { name, ariaLabel: customAriaLabel, disabled = false, testId: explicitTestId, label, type, transform } = params;
45
45
  const { control, debugMode, formState: { submitCount }, getFieldState, getValues, resetField } = require_useFormContext.useFormContext();
46
- const { error, invalid: rawInvalid, isTouched, required, testId } = getFieldState(name, explicitTestId);
46
+ const { error, invalid: rawInvalid, isDirty, isTouched, required, testId } = getFieldState(name, explicitTestId);
47
47
  const { field } = require_useController.useController({
48
48
  control,
49
49
  disabled,
@@ -63,14 +63,14 @@ const useUniformField = (params) => {
63
63
  * Determine when to show the invalid state to the user.
64
64
  *
65
65
  * Show errors when the field is invalid AND any of these conditions are met:
66
- * - Field has a value (show validation errors like format/length while typing)
66
+ * - Field has a user-entered value (show validation errors like format/length while typing)
67
67
  * - Field is touched (focused and blurred) - good for text inputs
68
68
  * - Form has been submitted - shows all errors after submit attempt
69
69
  *
70
- * Note: We intentionally don't use isDirty because:
71
- * - Newly added array elements are marked "dirty" by RHF, causing immediate errors
72
- * - Field Cards with empty initial values show errors immediately
73
- * - hasValue + isTouched covers the same use cases more reliably
70
+ * Note: `hasValue` is gated by `isDirty` so invalid initial values do not
71
+ * show errors just because resolver-backed validation state is available.
72
+ * Newly added empty array elements can be dirty, but stay hidden until blur
73
+ * because they do not have a value yet.
74
74
  *
75
75
  * This prevents showing errors on pristine/untouched/empty fields for better UX.
76
76
  * Examples:
@@ -84,7 +84,7 @@ const useUniformField = (params) => {
84
84
  * The entire condition is debounced to prevent flickering and allow smooth animations.
85
85
  */
86
86
  const hasValue = !require_helpers_index.isValueEmpty(fieldValue);
87
- const invalid = (0, _fuf_stack_pixels.useDebounce)(rawInvalid && (hasValue || isTouched || submitCount > 0), 200);
87
+ const invalid = (0, _fuf_stack_pixels.useDebounce)(rawInvalid && (isDirty && hasValue || isTouched || submitCount > 0), 200);
88
88
  const showTestIdCopyButton = debugMode === "debug-testids";
89
89
  const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [label !== false ? label : null, showTestIdCopyButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldCopyTestIdButton.FieldCopyTestIdButton, { testId }) : null] }) : null;
90
90
  const errorMessage = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldValidationError.FieldValidationError, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useFormContext","useController","useInputValueTransform","isValueEmpty","FieldCopyTestIdButton","FieldValidationError"],"sources":["../../../src/hooks/useUniformField/useUniformField.tsx","../../../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || isTouched || submitCount > 0);\n // Debounce to prevent flickering during rapid state changes\n const invalid = useDebounce(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACEA,uBAAAA,eAA6B;CAEjC,MAAM,EACJ,OACA,SAAS,YACT,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAEtC,MAAM,EAAE,UAAUC,sBAAAA,cAA4B;EAC5C;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgBC,+BAAAA,uBAAiC;EACvE;EACA;CACF,CAAC;CAGD,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAM1E,cADkB,YAFf,cAAsD,QAAQ,SAC/D,YAEoB,CAAsB;CAC9C;CAEA,MAAM,eAAgB,UAAU,IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAACC,sBAAAA,aAAa,UAAU;CAGzC,MAAM,WAAA,GAAA,kBAAA,aAFc,eAAe,YAAY,aAAa,cAAc,IAEjC,GAAG;CAM5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAIN,MAAM,eAAe,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;EAA6B;EAAe;CAAS,CAAA;CAK1E,MAAM,EAAE,sBAAsB,eAAe,2BAAA,GAAA,cAAA,UAClC;EACP;EACA,YAAY,EAEV,eAAe,MACjB;EACA,cAAc,KAAK,UAAU,KAAK;EAClC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;CAClB,CAAC;CAQH,OAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["useFormContext","useController","useInputValueTransform","isValueEmpty","FieldCopyTestIdButton","FieldValidationError"],"sources":["../../../src/hooks/useUniformField/useUniformField.tsx","../../../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field has a user-entered value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: `hasValue` is gated by `isDirty` so invalid initial values do not\n * show errors just because resolver-backed validation state is available.\n * Newly added empty array elements can be dirty, but stay hidden until blur\n * because they do not have a value yet.\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid =\n rawInvalid && ((isDirty && hasValue) || isTouched || submitCount > 0);\n // Debounce to prevent flickering during rapid state changes\n const invalid = useDebounce(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACEA,uBAAAA,eAA6B;CAEjC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAEtC,MAAM,EAAE,UAAUC,sBAAAA,cAA4B;EAC5C;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgBC,+BAAAA,uBAAiC;EACvE;EACA;CACF,CAAC;CAGD,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAM1E,cADkB,YAFf,cAAsD,QAAQ,SAC/D,YAEoB,CAAC;CACzB;CAEA,MAAM,eAAgB,UAAU,IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAACC,sBAAAA,aAAa,UAAU;CAIzC,MAAM,WAAA,GAAA,kBAAA,aAFJ,eAAgB,WAAW,YAAa,aAAa,cAAc,IAE5B,GAAG;CAM5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,uBAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAIN,MAAM,eAAe,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,sBAAD;EAA6B;EAAe;CAAS,CAAA;CAK1E,MAAM,EAAE,sBAAsB,eAAe,2BAAA,GAAA,cAAA,UAClC;EACP;EACA,YAAY,EAEV,eAAe,MACjB;EACA,cAAc,KAAK,UAAU,KAAK;EAClC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;CAClB,CAAC;CAQH,OAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF"}
@@ -1,2 +1,2 @@
1
- import { n as UseUniformFieldReturn, r as useUniformField, t as UseUniformFieldParams } from "../../useUniformField-D-Klu-sM.cjs";
1
+ import { n as UseUniformFieldReturn, r as useUniformField, t as UseUniformFieldParams } from "../../useUniformField-BWKBsUEX.cjs";
2
2
  export { UseUniformFieldParams, UseUniformFieldReturn, useUniformField };
@@ -1,2 +1,2 @@
1
- import { n as UseUniformFieldReturn, r as useUniformField, t as UseUniformFieldParams } from "../../useUniformField-CMb5EZ7Y.js";
1
+ import { n as UseUniformFieldReturn, r as useUniformField, t as UseUniformFieldParams } from "../../useUniformField-B3Dj8K5J.js";
2
2
  export { UseUniformFieldParams, UseUniformFieldReturn, useUniformField };
@@ -1,8 +1,8 @@
1
1
  import { isValueEmpty } from "../../helpers/index.js";
2
2
  import { n as FieldCopyTestIdButton } from "../../FieldCopyTestIdButton-Dpmo0uBV.js";
3
3
  import { n as FieldValidationError } from "../../FieldValidationError-ktTyyyip.js";
4
- import { t as useController } from "../../useController-BQ4LoFBd.js";
5
- import { n as useFormContext } from "../../useFormContext-2vyVWpUJ.js";
4
+ import { t as useController } from "../../useController-DVF2y3O3.js";
5
+ import { n as useFormContext } from "../../useFormContext-DJ-9hs8X.js";
6
6
  import { t as useInput } from "../../useInput-CVm3tP78.js";
7
7
  import { t as useInputValueTransform } from "../../useInputValueTransform-CXdmtc0Q.js";
8
8
  import "react";
@@ -40,7 +40,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
40
40
  const useUniformField = (params) => {
41
41
  const { name, ariaLabel: customAriaLabel, disabled = false, testId: explicitTestId, label, type, transform } = params;
42
42
  const { control, debugMode, formState: { submitCount }, getFieldState, getValues, resetField } = useFormContext();
43
- const { error, invalid: rawInvalid, isTouched, required, testId } = getFieldState(name, explicitTestId);
43
+ const { error, invalid: rawInvalid, isDirty, isTouched, required, testId } = getFieldState(name, explicitTestId);
44
44
  const { field } = useController({
45
45
  control,
46
46
  disabled,
@@ -60,14 +60,14 @@ const useUniformField = (params) => {
60
60
  * Determine when to show the invalid state to the user.
61
61
  *
62
62
  * Show errors when the field is invalid AND any of these conditions are met:
63
- * - Field has a value (show validation errors like format/length while typing)
63
+ * - Field has a user-entered value (show validation errors like format/length while typing)
64
64
  * - Field is touched (focused and blurred) - good for text inputs
65
65
  * - Form has been submitted - shows all errors after submit attempt
66
66
  *
67
- * Note: We intentionally don't use isDirty because:
68
- * - Newly added array elements are marked "dirty" by RHF, causing immediate errors
69
- * - Field Cards with empty initial values show errors immediately
70
- * - hasValue + isTouched covers the same use cases more reliably
67
+ * Note: `hasValue` is gated by `isDirty` so invalid initial values do not
68
+ * show errors just because resolver-backed validation state is available.
69
+ * Newly added empty array elements can be dirty, but stay hidden until blur
70
+ * because they do not have a value yet.
71
71
  *
72
72
  * This prevents showing errors on pristine/untouched/empty fields for better UX.
73
73
  * Examples:
@@ -81,7 +81,7 @@ const useUniformField = (params) => {
81
81
  * The entire condition is debounced to prevent flickering and allow smooth animations.
82
82
  */
83
83
  const hasValue = !isValueEmpty(fieldValue);
84
- const invalid = useDebounce(rawInvalid && (hasValue || isTouched || submitCount > 0), 200);
84
+ const invalid = useDebounce(rawInvalid && (isDirty && hasValue || isTouched || submitCount > 0), 200);
85
85
  const showTestIdCopyButton = debugMode === "debug-testids";
86
86
  const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ jsxs(Fragment, { children: [label !== false ? label : null, showTestIdCopyButton ? /* @__PURE__ */ jsx(FieldCopyTestIdButton, { testId }) : null] }) : null;
87
87
  const errorMessage = /* @__PURE__ */ jsx(FieldValidationError, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useUniformField/useUniformField.tsx","../../../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || isTouched || submitCount > 0);\n // Debounce to prevent flickering during rapid state changes\n const invalid = useDebounce(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACE,eAA6B;CAEjC,MAAM,EACJ,OACA,SAAS,YACT,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAEtC,MAAM,EAAE,UAAU,cAA4B;EAC5C;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;CACF,CAAC;CAGD,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAM1E,cADkB,YAFf,cAAsD,QAAQ,SAC/D,YAEoB,CAAsB;CAC9C;CAEA,MAAM,eAAgB,UAAU,IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAAC,aAAa,UAAU;CAGzC,MAAM,UAAU,YAFI,eAAe,YAAY,aAAa,cAAc,IAEjC,GAAG;CAM5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,qBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAAC,uBAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAIN,MAAM,eAAe,oBAAC,sBAAD;EAA6B;EAAe;CAAS,CAAA;CAK1E,MAAM,EAAE,sBAAsB,eAAe,0BAC3C,SAAS;EACP;EACA,YAAY,EAEV,eAAe,MACjB;EACA,cAAc,KAAK,UAAU,KAAK;EAClC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;CAClB,CAAC;CAQH,OAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useUniformField/useUniformField.tsx","../../../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field has a user-entered value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: `hasValue` is gated by `isDirty` so invalid initial values do not\n * show errors just because resolver-backed validation state is available.\n * Newly added empty array elements can be dirty, but stay hidden until blur\n * because they do not have a value yet.\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid =\n rawInvalid && ((isDirty && hasValue) || isTouched || submitCount > 0);\n // Debounce to prevent flickering during rapid state changes\n const invalid = useDebounce(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACE,eAA6B;CAEjC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAEtC,MAAM,EAAE,UAAU,cAA4B;EAC5C;EACA;EACA;CACF,CAAC;CACD,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;CACF,CAAC;CAGD,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAM1E,cADkB,YAFf,cAAsD,QAAQ,SAC/D,YAEoB,CAAC;CACzB;CAEA,MAAM,eAAgB,UAAU,IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAAC,aAAa,UAAU;CAIzC,MAAM,UAAU,YAFd,eAAgB,WAAW,YAAa,aAAa,cAAc,IAE5B,GAAG;CAM5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,qBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAAC,uBAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAIN,MAAM,eAAe,oBAAC,sBAAD;EAA6B;EAAe;CAAS,CAAA;CAK1E,MAAM,EAAE,sBAAsB,eAAe,0BAC3C,SAAS;EACP;EACA,YAAY,EAEV,eAAe,MACjB;EACA,cAAc,KAAK,UAAU,KAAK;EAClC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;CAClB,CAAC;CAQH,OAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;EACZ;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../../FormContext-Djp8wTG8.cjs");
2
+ require("../../FormContext-CjDd8Zej.cjs");
3
3
  const require_helpers_index = require("../../helpers/index.cjs");
4
- const require_useFormContext = require("../../useFormContext-CNGE9heQ.cjs");
4
+ const require_useFormContext = require("../../useFormContext-C_EQr8dV.cjs");
5
5
  const require_hooks_useUniformField_index = require("../useUniformField/index.cjs");
6
6
  let react = require("react");
7
7
  let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
@@ -1,2 +1,2 @@
1
- import { n as useUniformFieldArray, t as UseUniformFieldArrayProps } from "../../useUniformFieldArray-KClEBFyP.cjs";
1
+ import { n as useUniformFieldArray, t as UseUniformFieldArrayProps } from "../../useUniformFieldArray-RvOYml8h.cjs";
2
2
  export { UseUniformFieldArrayProps, useUniformFieldArray };
@@ -1,2 +1,2 @@
1
- import { n as useUniformFieldArray, t as UseUniformFieldArrayProps } from "../../useUniformFieldArray-eDkxErv8.js";
1
+ import { n as useUniformFieldArray, t as UseUniformFieldArrayProps } from "../../useUniformFieldArray-C0U3eBr7.js";
2
2
  export { UseUniformFieldArrayProps, useUniformFieldArray };
@@ -1,5 +1,5 @@
1
1
  import { flatArrayKey } from "../../helpers/index.js";
2
- import { n as useFormContext$1 } from "../../useFormContext-2vyVWpUJ.js";
2
+ import { n as useFormContext$1 } from "../../useFormContext-DJ-9hs8X.js";
3
3
  import { useUniformField } from "../useUniformField/index.js";
4
4
  import { useEffect, useMemo, useRef, useState } from "react";
5
5
  import { useReducedMotion } from "@fuf-stack/pixel-motion";