@fuf-stack/uniform 1.6.0 → 1.6.1

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 (156) hide show
  1. package/dist/Checkboxes/index.cjs +12 -6
  2. package/dist/Checkboxes/index.cjs.map +1 -1
  3. package/dist/Checkboxes/index.js +11 -5
  4. package/dist/FieldArray/index.cjs +12 -6
  5. package/dist/FieldArray/index.cjs.map +1 -1
  6. package/dist/FieldArray/index.js +11 -5
  7. package/dist/Form/index.cjs +12 -6
  8. package/dist/Form/index.cjs.map +1 -1
  9. package/dist/Form/index.js +11 -5
  10. package/dist/Input/index.cjs +12 -6
  11. package/dist/Input/index.cjs.map +1 -1
  12. package/dist/Input/index.js +11 -5
  13. package/dist/RadioBoxes/index.cjs +12 -6
  14. package/dist/RadioBoxes/index.cjs.map +1 -1
  15. package/dist/RadioBoxes/index.js +11 -5
  16. package/dist/RadioTabs/index.cjs +12 -6
  17. package/dist/RadioTabs/index.cjs.map +1 -1
  18. package/dist/RadioTabs/index.js +11 -5
  19. package/dist/Radios/index.cjs +12 -6
  20. package/dist/Radios/index.cjs.map +1 -1
  21. package/dist/Radios/index.js +11 -5
  22. package/dist/Select/index.cjs +12 -6
  23. package/dist/Select/index.cjs.map +1 -1
  24. package/dist/Select/index.js +11 -5
  25. package/dist/SubmitButton/index.cjs +12 -6
  26. package/dist/SubmitButton/index.cjs.map +1 -1
  27. package/dist/SubmitButton/index.js +11 -5
  28. package/dist/Switch/index.cjs +12 -6
  29. package/dist/Switch/index.cjs.map +1 -1
  30. package/dist/Switch/index.js +11 -5
  31. package/dist/TextArea/index.cjs +12 -6
  32. package/dist/TextArea/index.cjs.map +1 -1
  33. package/dist/TextArea/index.js +11 -5
  34. package/dist/{chunk-GBPAALJG.cjs → chunk-345LYO4H.cjs} +3 -3
  35. package/dist/{chunk-GBPAALJG.cjs.map → chunk-345LYO4H.cjs.map} +1 -1
  36. package/dist/chunk-35V726MB.js +1 -0
  37. package/dist/chunk-35V726MB.js.map +1 -0
  38. package/dist/{chunk-SLLZPY7M.js → chunk-6C6YW5TM.js} +2 -2
  39. package/dist/{chunk-ATRA4SVX.cjs → chunk-A5Z75X7M.cjs} +3 -3
  40. package/dist/{chunk-ATRA4SVX.cjs.map → chunk-A5Z75X7M.cjs.map} +1 -1
  41. package/dist/chunk-AACO4OEK.cjs +100 -0
  42. package/dist/chunk-AACO4OEK.cjs.map +1 -0
  43. package/dist/chunk-AHJJIANM.js +7 -0
  44. package/dist/chunk-AHJJIANM.js.map +1 -0
  45. package/dist/{chunk-5OX4LSPF.js → chunk-BXGILW5C.js} +4 -4
  46. package/dist/chunk-CHNYQVWO.js +59 -0
  47. package/dist/chunk-CHNYQVWO.js.map +1 -0
  48. package/dist/chunk-CK362NWK.js +34 -0
  49. package/dist/chunk-CK362NWK.js.map +1 -0
  50. package/dist/chunk-D3NAUOYG.js +122 -0
  51. package/dist/chunk-D3NAUOYG.js.map +1 -0
  52. package/dist/{chunk-MTMVQAN3.cjs → chunk-E4DCVJS5.cjs} +3 -3
  53. package/dist/{chunk-MTMVQAN3.cjs.map → chunk-E4DCVJS5.cjs.map} +1 -1
  54. package/dist/{chunk-D5ZZGT4Z.cjs → chunk-F6JQYB53.cjs} +4 -4
  55. package/dist/{chunk-D5ZZGT4Z.cjs.map → chunk-F6JQYB53.cjs.map} +1 -1
  56. package/dist/{chunk-HW4B6QID.js → chunk-GUPJNFEX.js} +10 -6
  57. package/dist/{chunk-HW4B6QID.js.map → chunk-GUPJNFEX.js.map} +1 -1
  58. package/dist/{chunk-GNBMDY5Q.js → chunk-H24QXVUI.js} +2 -2
  59. package/dist/{chunk-YJE5OZJ5.js → chunk-HQGTCSHK.js} +2 -2
  60. package/dist/{chunk-XCYA4ZBY.cjs → chunk-IYULWK4H.cjs} +7 -5
  61. package/dist/chunk-IYULWK4H.cjs.map +1 -0
  62. package/dist/{chunk-CVSFT7PV.js → chunk-JKWNYLNS.js} +4 -4
  63. package/dist/chunk-JMFDNTVC.cjs +34 -0
  64. package/dist/chunk-JMFDNTVC.cjs.map +1 -0
  65. package/dist/chunk-LTKRK3OS.cjs +1 -0
  66. package/dist/chunk-LTKRK3OS.cjs.map +1 -0
  67. package/dist/{chunk-MVZIOCAW.js → chunk-MXUKW3PZ.js} +2 -2
  68. package/dist/{chunk-3SZ2UKFA.cjs → chunk-NZBO4N3S.cjs} +4 -280
  69. package/dist/chunk-NZBO4N3S.cjs.map +1 -0
  70. package/dist/{chunk-XNAXMUTF.cjs → chunk-NZIAIYPS.cjs} +4 -4
  71. package/dist/{chunk-XNAXMUTF.cjs.map → chunk-NZIAIYPS.cjs.map} +1 -1
  72. package/dist/{chunk-JF437QVX.cjs → chunk-OJHD2XHD.cjs} +3 -3
  73. package/dist/{chunk-JF437QVX.cjs.map → chunk-OJHD2XHD.cjs.map} +1 -1
  74. package/dist/chunk-PCTYJUY7.cjs +7 -0
  75. package/dist/chunk-PCTYJUY7.cjs.map +1 -0
  76. package/dist/{chunk-2K6FWC4H.js → chunk-PO5UQAU6.js} +2 -278
  77. package/dist/chunk-PO5UQAU6.js.map +1 -0
  78. package/dist/{chunk-FNRALO75.js → chunk-QRCV7JVB.js} +2 -2
  79. package/dist/{chunk-3OFR3TO6.cjs → chunk-RMCPVDAC.cjs} +3 -3
  80. package/dist/{chunk-3OFR3TO6.cjs.map → chunk-RMCPVDAC.cjs.map} +1 -1
  81. package/dist/{chunk-NAN6QRAS.js → chunk-SJZ7UUEE.js} +5 -3
  82. package/dist/{chunk-NAN6QRAS.js.map → chunk-SJZ7UUEE.js.map} +1 -1
  83. package/dist/chunk-TEIXBRF5.cjs +59 -0
  84. package/dist/chunk-TEIXBRF5.cjs.map +1 -0
  85. package/dist/chunk-TGJJZEHB.cjs +122 -0
  86. package/dist/chunk-TGJJZEHB.cjs.map +1 -0
  87. package/dist/{chunk-IRWIEND4.js → chunk-TKFODQWI.js} +2 -2
  88. package/dist/{chunk-4HTB52DX.cjs → chunk-VPUMTPD3.cjs} +3 -3
  89. package/dist/{chunk-4HTB52DX.cjs.map → chunk-VPUMTPD3.cjs.map} +1 -1
  90. package/dist/{chunk-D537ZGNE.cjs → chunk-WFO4XPA3.cjs} +4 -4
  91. package/dist/{chunk-D537ZGNE.cjs.map → chunk-WFO4XPA3.cjs.map} +1 -1
  92. package/dist/{chunk-JEXF6TLO.cjs → chunk-XJBGXFVX.cjs} +10 -6
  93. package/dist/chunk-XJBGXFVX.cjs.map +1 -0
  94. package/dist/chunk-Z7FVILDT.js +100 -0
  95. package/dist/chunk-Z7FVILDT.js.map +1 -0
  96. package/dist/{chunk-MLPLWUXZ.js → chunk-Z7NI5347.js} +2 -2
  97. package/dist/hooks/index.cjs +18 -7
  98. package/dist/hooks/index.cjs.map +1 -1
  99. package/dist/hooks/index.d.cts +10 -287
  100. package/dist/hooks/index.d.ts +10 -287
  101. package/dist/hooks/index.js +24 -13
  102. package/dist/hooks/useClientValidation/index.cjs +12 -0
  103. package/dist/hooks/useClientValidation/index.cjs.map +1 -0
  104. package/dist/hooks/useClientValidation/index.d.cts +78 -0
  105. package/dist/hooks/useClientValidation/index.d.ts +78 -0
  106. package/dist/hooks/useClientValidation/index.js +12 -0
  107. package/dist/hooks/useClientValidation/index.js.map +1 -0
  108. package/dist/hooks/useController/index.cjs +9 -0
  109. package/dist/hooks/useController/index.cjs.map +1 -0
  110. package/dist/hooks/useController/index.d.cts +28 -0
  111. package/dist/hooks/useController/index.d.ts +28 -0
  112. package/dist/hooks/useController/index.js +9 -0
  113. package/dist/hooks/useController/index.js.map +1 -0
  114. package/dist/hooks/useFormContext/index.cjs +11 -0
  115. package/dist/hooks/useFormContext/index.cjs.map +1 -0
  116. package/dist/hooks/useFormContext/index.d.cts +50 -0
  117. package/dist/hooks/useFormContext/index.d.ts +50 -0
  118. package/dist/hooks/useFormContext/index.js +11 -0
  119. package/dist/hooks/useFormContext/index.js.map +1 -0
  120. package/dist/hooks/useInput/index.cjs +8 -0
  121. package/dist/hooks/useInput/index.cjs.map +1 -0
  122. package/dist/hooks/useInput/index.d.cts +1 -0
  123. package/dist/hooks/useInput/index.d.ts +1 -0
  124. package/dist/hooks/useInput/index.js +8 -0
  125. package/dist/hooks/useInput/index.js.map +1 -0
  126. package/dist/hooks/useUniformField/index.cjs +14 -0
  127. package/dist/hooks/useUniformField/index.cjs.map +1 -0
  128. package/dist/hooks/useUniformField/index.d.cts +83 -0
  129. package/dist/hooks/useUniformField/index.d.ts +83 -0
  130. package/dist/hooks/useUniformField/index.js +14 -0
  131. package/dist/hooks/useUniformField/index.js.map +1 -0
  132. package/dist/hooks/useUniformFieldArray/index.cjs +15 -0
  133. package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -0
  134. package/dist/hooks/useUniformFieldArray/index.d.cts +70 -0
  135. package/dist/hooks/useUniformFieldArray/index.d.ts +70 -0
  136. package/dist/hooks/useUniformFieldArray/index.js +15 -0
  137. package/dist/hooks/useUniformFieldArray/index.js.map +1 -0
  138. package/dist/index.cjs +28 -17
  139. package/dist/index.cjs.map +1 -1
  140. package/dist/index.d.cts +5 -1
  141. package/dist/index.d.ts +5 -1
  142. package/dist/index.js +38 -27
  143. package/package.json +31 -1
  144. package/dist/chunk-2K6FWC4H.js.map +0 -1
  145. package/dist/chunk-3SZ2UKFA.cjs.map +0 -1
  146. package/dist/chunk-JEXF6TLO.cjs.map +0 -1
  147. package/dist/chunk-XCYA4ZBY.cjs.map +0 -1
  148. /package/dist/{chunk-SLLZPY7M.js.map → chunk-6C6YW5TM.js.map} +0 -0
  149. /package/dist/{chunk-5OX4LSPF.js.map → chunk-BXGILW5C.js.map} +0 -0
  150. /package/dist/{chunk-GNBMDY5Q.js.map → chunk-H24QXVUI.js.map} +0 -0
  151. /package/dist/{chunk-YJE5OZJ5.js.map → chunk-HQGTCSHK.js.map} +0 -0
  152. /package/dist/{chunk-CVSFT7PV.js.map → chunk-JKWNYLNS.js.map} +0 -0
  153. /package/dist/{chunk-MVZIOCAW.js.map → chunk-MXUKW3PZ.js.map} +0 -0
  154. /package/dist/{chunk-FNRALO75.js.map → chunk-QRCV7JVB.js.map} +0 -0
  155. /package/dist/{chunk-IRWIEND4.js.map → chunk-TKFODQWI.js.map} +0 -0
  156. /package/dist/{chunk-MLPLWUXZ.js.map → chunk-Z7NI5347.js.map} +0 -0
@@ -1,14 +1,18 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
+ var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
4
+
3
5
 
6
+ var _chunkJMFDNTVCcjs = require('./chunk-JMFDNTVC.cjs');
4
7
 
5
- var _chunk3SZ2UKFAcjs = require('./chunk-3SZ2UKFA.cjs');
8
+
9
+ var _chunkPCTYJUY7cjs = require('./chunk-PCTYJUY7.cjs');
6
10
 
7
11
 
8
12
  var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
9
13
 
10
14
 
11
- var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
15
+ var _chunkNZBO4N3Scjs = require('./chunk-NZBO4N3S.cjs');
12
16
 
13
17
 
14
18
 
@@ -44,11 +48,11 @@ var Switch = ({
44
48
  testId: _testId = void 0,
45
49
  thumbIcon = void 0
46
50
  }) => {
47
- const { control, debugMode, getFieldState } = _chunk3SZ2UKFAcjs.useFormContext.call(void 0, );
51
+ const { control, debugMode, getFieldState } = _chunkNZBO4N3Scjs.useFormContext.call(void 0, );
48
52
  const { error, required, testId, invalid } = getFieldState(name, _testId);
49
- const { field } = _chunk3SZ2UKFAcjs.useController.call(void 0, { name, control, disabled });
53
+ const { field } = _chunkJMFDNTVCcjs.useController.call(void 0, { name, control, disabled });
50
54
  const { disabled: isDisabled, value, ref, onBlur, onChange } = field;
51
- const { label, getInputProps, getErrorMessageProps } = _chunk3SZ2UKFAcjs.useInput.call(void 0, {
55
+ const { label, getInputProps, getErrorMessageProps } = _chunkPCTYJUY7cjs.useInput.call(void 0, {
52
56
  errorMessage: JSON.stringify(error),
53
57
  isInvalid: invalid,
54
58
  isRequired: required,
@@ -98,4 +102,4 @@ var Switch_default2 = Switch_default;
98
102
 
99
103
 
100
104
  exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
101
- //# sourceMappingURL=chunk-JEXF6TLO.cjs.map
105
+ //# sourceMappingURL=chunk-XJBGXFVX.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-XJBGXFVX.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":["Switch_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACfA,wCAAqC;AAErC,oDAAyC;AAoFnC,+CAAA;AA9EC,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,UAAA,EAAY,EAAA;AAAA,IACZ,YAAA,EAAc,WAAA;AAAA;AAAA;AAAA,IAGd,KAAA,EACE,yNAAA;AAAA,IACF,YAAA,EAAc,sBAAA;AAAA,IACd,YAAA,EAAc,EAAA;AAAA,IACd,KAAA,EAAO,EAAA;AAAA,IACP,SAAA,EAAW,EAAA;AAAA,IACX,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AA6BD,IAAM,OAAA,EAAS,CAAC;AAAA,EACd,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,WAAA,EAAa,KAAA,CAAA;AAAA,EACb,KAAA,EAAO,OAAA,EAAS,KAAA,CAAA;AAAA,EAChB,IAAA;AAAA,EACA,KAAA,EAAO,KAAA,CAAA;AAAA,EACP,aAAA,EAAe,KAAA,CAAA;AAAA,EACf,MAAA,EAAQ,QAAA,EAAU,KAAA,CAAA;AAAA,EAClB,UAAA,EAAY,KAAA;AACd,CAAA,EAAA,GAAmB;AACjB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,cAAc,EAAA,EAAI,8CAAA,CAAe;AAC7D,EAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,MAAA,EAAQ,QAAQ,EAAA,EAAI,aAAA,CAAc,IAAA,EAAM,OAAO,CAAA;AAExE,EAAA,MAAM,EAAE,MAAM,EAAA,EAAI,6CAAA,EAA6B,IAAA,EAAM,OAAA,EAAS,SAAS,CAAC,CAAA;AACxE,EAAA,MAAM,EAAE,QAAA,EAAU,UAAA,EAAY,KAAA,EAAO,GAAA,EAAK,MAAA,EAAQ,SAAS,EAAA,EAAI,KAAA;AAE/D,EAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAe,qBAAqB,EAAA,EAAI,wCAAA;AAAS,IAC9D,YAAA,EAAc,IAAA,CAAK,SAAA,CAAU,KAAK,CAAA;AAAA,IAClC,SAAA,EAAW,OAAA;AAAA,IACX,UAAA,EAAY,QAAA;AAAA,IACZ,KAAA,EAAO,MAAA;AAAA,IACP,cAAA,EAAgB,SAAA;AAAA,IAChB,WAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAED,EAAA,MAAM,qBAAA,EAAuB,UAAA,IAAc,eAAA;AAG3C,EAAA,MAAM,SAAA,EAAW,cAAA,CAAe,CAAA;AAChC,EAAA,MAAM,WAAA,EAAa,8CAAA,QAAqB,EAAU,SAAA,EAAW,cAAc,CAAA;AAE3E,EAAA,uBACE,8BAAA,KAAC,EAAA,EAAI,SAAA,EAAW,UAAA,CAAW,YAAA,EACzB,QAAA,EAAA;AAAA,oBAAA,8BAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QAGA,kBAAA,EAAkB,aAAA,CAAc,CAAA,CAAE,kBAAkB,CAAA;AAAA,QACpD,UAAA;AAAA,QACA,cAAA,EAAc,OAAA;AAAA,QACd,eAAA,EAAe,QAAA;AAAA,QACf,aAAA,EAAa,MAAA;AAAA,QACb,UAAA;AAAA,QACA,UAAA;AAAA,QACA,UAAA,EAAY,CAAC,CAAC,KAAA;AAAA,QACd,IAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAA,EAAe,QAAA;AAAA,QACf,QAAA;AAAA,QACA,IAAA;AAAA,QACA,YAAA;AAAA,QACA,SAAA;AAAA,QACA,KAAA;AAAA,QAEC,QAAA,EAAA;AAAA,UAAA,KAAA;AAAA,UACA,qBAAA,kBACC,6BAAA,+CAAC,EAAA,EAAsB,OAAA,CAAgB,EAAA,EACrC;AAAA,QAAA;AAAA,MAAA;AAAA,IACN,CAAA;AAAA,IACC,MAAA,kBACC,6BAAA,KAAC,EAAA,EAAI,SAAA,EAAW,UAAA,CAAW,YAAA,EACzB,QAAA,kBAAA,6BAAA,KAAC,EAAA,6CAAA,8CAAA,CAAA,CAAA,EAAQ,oBAAA,CAAqB,CAAA,CAAA,EAA7B,EACC,QAAA,kBAAA,6BAAA,8CAAC,EAAA,EAAqB,KAAA,EAAc,OAAA,CAAgB,EAAA,CAAA,CACtD,EAAA,CACF,EAAA,EACE;AAAA,EAAA,EAAA,CACN,CAAA;AAEJ,CAAA;AAEA,IAAO,eAAA,EAAQ,MAAA;ADhCf;AACA;AE3FA,IAAOA,gBAAAA,EAAQ,cAAA;AF6Ff;AACA;AACE;AACA;AACF,mFAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-XJBGXFVX.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInput } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label: _label = undefined,\n name,\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n thumbIcon = undefined,\n}: SwitchProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { field } = useController<FieldValues>({ name, control, disabled });\n const { disabled: isDisabled, value, ref, onBlur, onChange } = field;\n\n const { label, getInputProps, getErrorMessageProps } = useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n <HeroSwitch\n ref={ref}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n endContent={endContent}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n required={required}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n value={value}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </HeroSwitch>\n {error ? (\n <div className={classNames.errorMessage}>\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
@@ -0,0 +1,100 @@
1
+ import {
2
+ useUniformField
3
+ } from "./chunk-D3NAUOYG.js";
4
+ import {
5
+ useFormContext
6
+ } from "./chunk-PO5UQAU6.js";
7
+ import {
8
+ flatArrayKey
9
+ } from "./chunk-76KOVUDN.js";
10
+ import {
11
+ __spreadValues
12
+ } from "./chunk-K2V4ULA2.js";
13
+
14
+ // src/hooks/useUniformFieldArray/useUniformFieldArray.ts
15
+ import { useEffect, useMemo, useRef, useState } from "react";
16
+ import { useFieldArray as useRHFFieldArray } from "react-hook-form";
17
+ import { useReducedMotion } from "@fuf-stack/pixel-motion";
18
+ var useUniformFieldArray = ({
19
+ name,
20
+ flat = false,
21
+ elementInitialValue: _elementInitialValue = null,
22
+ lastElementNotRemovable = false,
23
+ disabled,
24
+ testId: explicitTestId,
25
+ label
26
+ }) => {
27
+ const uniformField = useUniformField({
28
+ name,
29
+ disabled,
30
+ testId: explicitTestId,
31
+ label
32
+ });
33
+ const { control } = uniformField;
34
+ const { fields, append, remove, insert, move } = useRHFFieldArray({
35
+ control,
36
+ name
37
+ });
38
+ const { trigger, setValue } = useFormContext();
39
+ const needsInitialize = lastElementNotRemovable && fields.length === 0;
40
+ const hasInitialized = useRef(!needsInitialize);
41
+ useEffect(() => {
42
+ if (needsInitialize) {
43
+ hasInitialized.current = false;
44
+ }
45
+ }, [needsInitialize]);
46
+ useEffect(() => {
47
+ if (hasInitialized.current) {
48
+ setTimeout(() => {
49
+ trigger(name);
50
+ }, 200);
51
+ }
52
+ }, [fields.length]);
53
+ const [disableAnimation, setDisableAnimation] = useState(true);
54
+ const prefersReducedMotion = useReducedMotion();
55
+ useEffect(() => {
56
+ if (hasInitialized.current) {
57
+ setDisableAnimation(!!prefersReducedMotion);
58
+ }
59
+ }, [prefersReducedMotion]);
60
+ const elementInitialValue = useMemo(() => {
61
+ return flat ? { [flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
62
+ }, [flat, _elementInitialValue]);
63
+ useEffect(
64
+ () => {
65
+ if (needsInitialize) {
66
+ if (!disableAnimation) {
67
+ setDisableAnimation(true);
68
+ }
69
+ setValue(name, [elementInitialValue], {
70
+ shouldDirty: false,
71
+ shouldTouch: false
72
+ });
73
+ hasInitialized.current = true;
74
+ if (!prefersReducedMotion) {
75
+ setTimeout(() => {
76
+ setDisableAnimation(false);
77
+ }, 1);
78
+ }
79
+ }
80
+ },
81
+ // Run when needsInitialize changes (initial mount or reset)
82
+ // eslint-disable-next-line react-hooks/exhaustive-deps
83
+ [needsInitialize]
84
+ );
85
+ return __spreadValues({
86
+ // Field array methods and state
87
+ fields,
88
+ append,
89
+ remove,
90
+ insert,
91
+ move,
92
+ disableAnimation,
93
+ elementInitialValue
94
+ }, uniformField);
95
+ };
96
+
97
+ export {
98
+ useUniformFieldArray
99
+ };
100
+ //# sourceMappingURL=chunk-Z7FVILDT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,iBAAiB,wBAAwB;AAElD,SAAS,wBAAwB;AAqC1B,IAAM,uBAAuB,CAElC;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,qBAAqB,uBAAuB;AAAA,EAC5C,0BAA0B;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAA+C;AAE7C,QAAM,eAAe,gBAA8B;AAAA,IACjD;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACF,CAAC;AAED,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,IAAI,iBAAiB;AAAA,IAChE;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,EAAE,SAAS,SAAS,IAAI,eAA6B;AAO3D,QAAM,kBAAkB,2BAA2B,OAAO,WAAW;AASrE,QAAM,iBAAiB,OAAO,CAAC,eAAe;AAK9C,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAIpB,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,iBAAW,MAAM;AAEf,gBAAQ,IAA0B;AAAA,MACpC,GAAG,GAAG;AAAA,IACR;AAAA,EAEF,GAAG,CAAC,OAAO,MAAM,CAAC;AAIlB,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,IAAI;AAI7D,QAAM,uBAAuB,iBAAiB;AAC9C,YAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,0BAAoB,CAAC,CAAC,oBAAoB;AAAA,IAC5C;AAAA,EACF,GAAG,CAAC,oBAAoB,CAAC;AAKzB,QAAM,sBAAsB,QAAQ,MAAM;AACxC,WAAO,OACH,EAAE,CAAC,YAAY,GAAG,sDAAwB,KAAK,IAC9C,sDAAwB,CAAC;AAAA,EAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;AAU/B;AAAA,IACE,MAAM;AACJ,UAAI,iBAAiB;AAInB,YAAI,CAAC,kBAAkB;AACrB,8BAAoB,IAAI;AAAA,QAC1B;AAIA,iBAAS,MAA4B,CAAC,mBAAmB,GAAU;AAAA,UACjE,aAAa;AAAA,UACb,aAAa;AAAA,QACf,CAAC;AAGD,uBAAe,UAAU;AAKzB,YAAI,CAAC,sBAAsB;AACzB,qBAAW,MAAM;AACf,gCAAoB,KAAK;AAAA,UAC3B,GAAG,CAAC;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEG;AAEP;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useUniformField
3
- } from "./chunk-2K6FWC4H.js";
3
+ } from "./chunk-D3NAUOYG.js";
4
4
  import {
5
5
  FieldValidationError_default
6
6
  } from "./chunk-ELYGQTXB.js";
@@ -178,4 +178,4 @@ export {
178
178
  Checkboxes_default,
179
179
  Checkboxes_default2
180
180
  };
181
- //# sourceMappingURL=chunk-MLPLWUXZ.js.map
181
+ //# sourceMappingURL=chunk-Z7NI5347.js.map
@@ -1,22 +1,33 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-LTKRK3OS.cjs');
2
2
 
3
3
 
4
+ var _chunkBZ5OMN4Ycjs = require('../chunk-BZ5OMN4Y.cjs');
4
5
 
5
6
 
7
+ var _chunk4WYC2RBEcjs = require('../chunk-4WYC2RBE.cjs');
6
8
 
7
9
 
10
+ var _chunkAACO4OEKcjs = require('../chunk-AACO4OEK.cjs');
8
11
 
9
12
 
10
- var _chunk3SZ2UKFAcjs = require('../chunk-3SZ2UKFA.cjs');
11
- require('../chunk-OE5BOGGX.cjs');
13
+ var _chunkTGJJZEHBcjs = require('../chunk-TGJJZEHB.cjs');
12
14
  require('../chunk-NHEZXA4H.cjs');
13
- require('../chunk-Z353BLWI.cjs');
14
15
 
15
16
 
16
- var _chunkBZ5OMN4Ycjs = require('../chunk-BZ5OMN4Y.cjs');
17
+ var _chunkJMFDNTVCcjs = require('../chunk-JMFDNTVC.cjs');
17
18
 
18
19
 
19
- var _chunk4WYC2RBEcjs = require('../chunk-4WYC2RBE.cjs');
20
+ var _chunkPCTYJUY7cjs = require('../chunk-PCTYJUY7.cjs');
21
+ require('../chunk-OE5BOGGX.cjs');
22
+
23
+
24
+
25
+ var _chunkTEIXBRF5cjs = require('../chunk-TEIXBRF5.cjs');
26
+
27
+
28
+
29
+ var _chunkNZBO4N3Scjs = require('../chunk-NZBO4N3S.cjs');
30
+ require('../chunk-Z353BLWI.cjs');
20
31
  require('../chunk-555JRYCS.cjs');
21
32
 
22
33
 
@@ -29,5 +40,5 @@ require('../chunk-555JRYCS.cjs');
29
40
 
30
41
 
31
42
 
32
- exports.checkFieldIsRequired = _chunk3SZ2UKFAcjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunk3SZ2UKFAcjs.clientValidationSchemaByName; exports.useClientValidation = _chunk3SZ2UKFAcjs.useClientValidation; exports.useController = _chunk3SZ2UKFAcjs.useController; exports.useFormContext = _chunk3SZ2UKFAcjs.useFormContext; exports.useInput = _chunk3SZ2UKFAcjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunk3SZ2UKFAcjs.useUniformField; exports.useUniformFieldArray = _chunk3SZ2UKFAcjs.useUniformFieldArray;
43
+ exports.checkFieldIsRequired = _chunkNZBO4N3Scjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkTEIXBRF5cjs.clientValidationSchemaByName; exports.useClientValidation = _chunkTEIXBRF5cjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunkNZBO4N3Scjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkTGJJZEHBcjs.useUniformField; exports.useUniformFieldArray = _chunkAACO4OEKcjs.useUniformFieldArray;
33
44
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,6pBAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"],"names":[],"mappings":"AAAA,0GAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,6pBAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/hooks/index.cjs"}
@@ -1,290 +1,13 @@
1
- import * as _fuf_stack_veto_dist_types_d_CNPgNK_V from '@fuf-stack/veto/dist/types.d-CNPgNK-V';
2
- import * as _fuf_stack_veto from '@fuf-stack/veto';
3
- import { VetoTypeAny, VetoInstance, VetoFormattedError } from '@fuf-stack/veto';
4
- import * as react_hook_form from 'react-hook-form';
5
- import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState, FieldValues, Path, FieldError, ArrayPath } from 'react-hook-form';
6
- import * as _heroui_input from '@heroui/input';
7
- import { useInput } from '@heroui/input';
1
+ export { clientValidationSchemaByName, useClientValidation } from './useClientValidation/index.cjs';
2
+ export { UseControllerProps, UseControllerReturn, useController } from './useController/index.cjs';
3
+ export { UseUniformFieldArrayProps, useUniformFieldArray } from './useUniformFieldArray/index.cjs';
4
+ export { checkFieldIsRequired, useFormContext } from './useFormContext/index.cjs';
8
5
  export { useInput } from '@heroui/input';
9
- import * as React from 'react';
10
- import { ReactNode } from 'react';
11
- import { D as DebugModeSettings } from '../FormContext-LRho0tno.cjs';
12
6
  export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce } from './useInputValueDebounce/index.cjs';
13
7
  export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform } from './useInputValueTransform/index.cjs';
14
-
15
- /**
16
- * Hook for adding dynamic client-side validation to forms.
17
- *
18
- * Automatically manages validation schema lifecycle: sets schema when data is provided,
19
- * clears schema when data is null/undefined, and cleans up on unmount.
20
- *
21
- * When the client validation schema changes, automatically re-validates all touched
22
- * fields to ensure they are validated against the new schema.
23
- *
24
- * @param data - Data to create validation schema from (or null/undefined to clear validation)
25
- * @param schemaFactory - Function that creates a validation schema from the data.
26
- *
27
- * @example
28
- * ```tsx
29
- * const { data: teamData } = useTeamQuery(teamId);
30
- *
31
- * useClientValidation(teamData, (data) =>
32
- * vt.object({
33
- * username: vt.string().refine(
34
- * (value) => !data.existingUsers.includes(value),
35
- * { message: 'Username already exists' }
36
- * )
37
- * })
38
- * );
39
- * ```
40
- */
41
- declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
42
- /**
43
- * Helper function to create a veto looseObject schema for a single field with nested path support.
44
- *
45
- * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
46
- * All intermediate objects and arrays are marked as optional to allow partial data structures.
47
- * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
48
- *
49
- * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name')
50
- * @param fieldSchema - The veto validation schema for the field
51
- * @returns A nested loose object schema matching the field path structure with proper type inference
52
- *
53
- * @example
54
- * ```tsx
55
- * // Simple field
56
- * clientValidationSchemaByName('username', vt.string())
57
- * // => objectLoose({ username: vt.string() })
58
- * ```
59
- *
60
- * @example
61
- * ```tsx
62
- * // Nested field (with optional intermediate objects)
63
- * clientValidationSchemaByName('user.profile.email', vt.string().email())
64
- * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: vt.string().email() }).optional() }).optional() })
65
- * ```
66
- *
67
- * @example
68
- * ```tsx
69
- * // Array field (with optional array)
70
- * clientValidationSchemaByName('items.0.name', vt.string())
71
- * // => objectLoose({ items: array(objectLoose({ name: vt.string() })).optional() })
72
- * ```
73
- *
74
- * @example
75
- * ```tsx
76
- * // Usage with useClientValidation
77
- * const { data: userData } = useUserQuery(userId);
78
- *
79
- * useClientValidation(userData, (data) =>
80
- * clientValidationSchemaByName('username', vt.string().refine(
81
- * (value) => !data.existingUsernames.includes(value),
82
- * { message: 'Username already taken' }
83
- * ))
84
- * );
85
- * ```
86
- */
87
- declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_CNPgNK_V.Z;
88
-
89
- type UseControllerProps<TFieldValues extends object = object> = UseControllerProps$1<TFieldValues>;
90
- interface UseControllerReturn<TFieldValues extends object = object> {
91
- field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {
92
- onChange: (...event: any[]) => void;
93
- value: string;
94
- };
95
- formState: UseFormStateReturn<TFieldValues>;
96
- fieldState: ControllerFieldState;
97
- }
98
- /**
99
- * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.
100
- *
101
- * Key features:
102
- * 1. Empty strings ('') in the UI are stored as null in form state
103
- * 2. Null/undefined values in form state are displayed as empty strings in the UI
104
- * 3. Handles both direct value changes and React synthetic events
105
- * 4. Maintains the same API as react-hook-form's useController
106
- *
107
- * This enables consistent handling of empty/null values while keeping a clean API
108
- * for form inputs that expect string values.
109
- *
110
- * @see https://react-hook-form.com/docs/usecontroller
111
- */
112
- declare const useController: <TFieldValues extends object = object>(props: UseControllerProps<TFieldValues>) => UseControllerReturn<TFieldValues>;
113
-
114
- /** Schema check whether a field is required or optional */
115
- declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) => boolean;
116
- /**
117
- * Custom hook that extends react-hook-form's useFormContext to add validation and state management.
118
- */
119
- declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
120
- formState: react_hook_form.FormState<TFieldValues>;
121
- getFieldState: (name: Path<TFieldValues>, testId?: string) => {
122
- error: FieldError[] | undefined;
123
- invalid: boolean;
124
- required: boolean;
125
- testId: string;
126
- isDirty: boolean;
127
- isTouched: boolean;
128
- isValidating: boolean;
129
- };
130
- getValues: react_hook_form.UseFormGetValues<TFieldValues>;
131
- subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
132
- watch: react_hook_form.UseFormWatch<TFieldValues>;
133
- debugMode: "debug" | "debug-testids" | "off" | "disabled";
134
- debugModeSettings?: DebugModeSettings;
135
- preventSubmit: (prevent: boolean) => void;
136
- setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
137
- triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
138
- validation: {
139
- instance?: VetoInstance;
140
- errors?: VetoFormattedError;
141
- setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
142
- };
143
- setError: react_hook_form.UseFormSetError<TFieldValues>;
144
- clearErrors: react_hook_form.UseFormClearErrors<TFieldValues>;
145
- setValue: react_hook_form.UseFormSetValue<TFieldValues>;
146
- trigger: react_hook_form.UseFormTrigger<TFieldValues>;
147
- resetField: react_hook_form.UseFormResetField<TFieldValues>;
148
- reset: react_hook_form.UseFormReset<TFieldValues>;
149
- handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
150
- unregister: react_hook_form.UseFormUnregister<TFieldValues>;
151
- control: react_hook_form.Control<TFieldValues, TContext, TTransformedValues>;
152
- register: react_hook_form.UseFormRegister<TFieldValues>;
153
- setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
154
- };
155
-
156
- interface UseUniformFieldArrayProps<TFieldValues extends FieldValues = FieldValues> {
157
- /** Field name for the array */
158
- name: ArrayPath<TFieldValues>;
159
- /** Whether this is a flat array (array of primitives) */
160
- flat?: boolean;
161
- /** Initial value for new array elements */
162
- elementInitialValue?: unknown;
163
- /** Whether the last element cannot be removed (always maintain at least one element) */
164
- lastElementNotRemovable?: boolean;
165
- /** Disable the field */
166
- disabled?: boolean;
167
- /** Optional explicit test id used to build stable test ids */
168
- testId?: string;
169
- /** Optional label content; pass false to suppress label entirely */
170
- label?: ReactNode | false;
171
- }
172
- /**
173
- * Enhanced useFieldArray hook with initialization and animation logic.
174
- * Based on React Hook Form's useFieldArray with additional features:
175
- * - Automatic initialization when lastElementNotRemovable is set
176
- * - Animation control (disabled during initialization)
177
- * - Support for flat arrays (arrays of primitives)
178
- *
179
- * Note: Automatic validation triggering on length change is disabled to prevent
180
- * triggering form-wide validation. Array validation still runs on form submission.
181
- *
182
- * @see https://react-hook-form.com/docs/usefieldarray
183
- */
184
- declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldValues>({ name, flat, elementInitialValue: _elementInitialValue, lastElementNotRemovable, disabled, testId: explicitTestId, label, }: UseUniformFieldArrayProps<TFieldValues>) => {
185
- control: react_hook_form.Control<TFieldValues, any, TFieldValues>;
186
- debugMode: ReturnType<typeof useFormContext<TFieldValues_1>>["debugMode"];
187
- defaultValue: unknown;
188
- disabled: boolean | undefined;
189
- error: react_hook_form.FieldError[] | undefined;
190
- errorMessage: ReactNode | null;
191
- field: Omit<react_hook_form.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
192
- onChange: (... /** Initial value for new array elements */event: any[]) => void;
193
- value: string;
194
- };
195
- getErrorMessageProps: ReturnType<typeof _heroui_input.useInput>["getErrorMessageProps"];
196
- getHelperWrapperProps: ReturnType<typeof _heroui_input.useInput>["getHelperWrapperProps"];
197
- getLabelProps: ReturnType<typeof _heroui_input.useInput>["getLabelProps"];
198
- getValues: react_hook_form.UseFormGetValues<TFieldValues>;
199
- invalid: boolean;
200
- label: ReactNode | null;
201
- onBlur: ReturnType<typeof useController>["field"]["onBlur"];
202
- onChange: ReturnType<typeof useController>["field"]["onChange"];
203
- ref: ReturnType<typeof useController>["field"]["ref"];
204
- required: boolean;
205
- resetField: react_hook_form.UseFormResetField<TFieldValues>;
206
- testId: string;
207
- fields: react_hook_form.FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>, "id">[];
208
- append: react_hook_form.UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
209
- remove: react_hook_form.UseFieldArrayRemove;
210
- insert: react_hook_form.UseFieldArrayInsert<TFieldValues, ArrayPath<TFieldValues>>;
211
- move: react_hook_form.UseFieldArrayMove;
212
- disableAnimation: boolean;
213
- elementInitialValue: {};
214
- };
215
-
216
- interface UseUniformFieldParams<TFieldValues extends FieldValues = FieldValues> {
217
- /** Form field name */
218
- name: Path<TFieldValues> & string;
219
- /** Disable the field */
220
- disabled?: boolean;
221
- /** Optional explicit test id used to build stable test ids */
222
- testId?: string;
223
- /** Optional label content; pass false to suppress label entirely */
224
- label?: ReactNode | false;
225
- }
226
- interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues> {
227
- /** react-hook-form control instance for advanced integrations */
228
- control: ReturnType<typeof useFormContext<TFieldValues>>['control'];
229
- /** Debug mode from Uniform provider */
230
- debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];
231
- /** Current value used to initialize uncontrolled components */
232
- defaultValue: unknown;
233
- /** Whether the field is currently disabled (from RHF) */
234
- disabled: boolean | undefined;
235
- /** Validation error(s) for the field */
236
- error: FieldError[] | undefined;
237
- /** Pre-built errorMessage node to plug into components */
238
- errorMessage: ReactNode | null;
239
- /** RHF controller field with nullish conversions applied */
240
- field: ReturnType<typeof useController<TFieldValues>>['field'];
241
- /** Helper to spread standardized error message props to underlying components */
242
- getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];
243
- /** Helper to spread standardized helper wrapper props (for spacing/animation) */
244
- getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];
245
- /** Helper to spread standardized label props to underlying components */
246
- getLabelProps: ReturnType<typeof useInput>['getLabelProps'];
247
- /** Access current form values (converted to validation-friendly format) */
248
- getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];
249
- /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */
250
- invalid: boolean;
251
- /** Computed label node including optional test id copy button */
252
- label: ReactNode | null;
253
- /** onBlur handler from controller */
254
- onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];
255
- /** onChange handler from controller (with nullish handling) */
256
- onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];
257
- /** Ref to forward to underlying control */
258
- ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];
259
- /** Whether the field is required according to validation schema */
260
- required: boolean;
261
- /** Reset a specific field in the form */
262
- resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];
263
- /** Generated HTML data-testid for the field */
264
- testId: string;
265
- }
266
- /**
267
- * Combines frequently used form field logic into a single hook.
268
- *
269
- * Provides:
270
- * - Enhanced form context (validation-aware state, `testId`, value transforms)
271
- * - Controller field with nullish conversion handling
272
- * - Debounced `invalid` state with smart timing:
273
- * • `true` (field becomes invalid): applies immediately so errors show right away
274
- * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations
275
- * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion
276
- * - Smart `invalid` visibility (via `showInvalid`):
277
- * • Shows errors when field is dirty OR touched OR form has been submitted
278
- * • Prevents showing errors on pristine/untouched fields for better UX
279
- * • Works well for all field types (text inputs, checkboxes, radios, arrays)
280
- * - Prebuilt `errorMessage` React node using `FieldValidationError`
281
- * - Computed `label` node which appends a `FieldCopyTestIdButton` in
282
- * `debug-testids` mode
283
- * - `defaultValue` for uncontrolled defaults and all usual field handlers
284
- * - Access to form utilities: `control`, `getValues`, `resetField`
285
- * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,
286
- * `getHelperWrapperProps` for consistent wiring to underlying UI components
287
- */
288
- declare function useUniformField<TFieldValues extends FieldValues = FieldValues>(params: UseUniformFieldParams<TFieldValues>): UseUniformFieldReturn<TFieldValues>;
289
-
290
- export { type UseControllerProps, type UseControllerReturn, type UseUniformFieldArrayProps, type UseUniformFieldParams, type UseUniformFieldReturn, checkFieldIsRequired, clientValidationSchemaByName, useClientValidation, useController, useFormContext, useUniformField, useUniformFieldArray };
8
+ export { UseUniformFieldParams, UseUniformFieldReturn, useUniformField } from './useUniformField/index.cjs';
9
+ import '@fuf-stack/veto/dist/types.d-CNPgNK-V';
10
+ import '@fuf-stack/veto';
11
+ import 'react-hook-form';
12
+ import 'react';
13
+ import '../FormContext-LRho0tno.cjs';