@fuf-stack/uniform 1.22.5 → 1.22.6
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.
- package/dist/Checkboxes/index.cjs +113 -4
- package/dist/Checkboxes/index.cjs.map +1 -0
- package/dist/Checkboxes/index.d.cts +534 -2
- package/dist/Checkboxes/index.d.cts.map +1 -0
- package/dist/Checkboxes/index.d.ts +534 -2
- package/dist/Checkboxes/index.d.ts.map +1 -0
- package/dist/Checkboxes/index.js +112 -2
- package/dist/Checkboxes/index.js.map +1 -0
- package/dist/DatePicker/index.cjs +194 -4
- package/dist/DatePicker/index.cjs.map +1 -0
- package/dist/DatePicker/index.d.cts +1413 -2
- package/dist/{index-D7AUghFx.d.ts.map → DatePicker/index.d.cts.map} +1 -1
- package/dist/DatePicker/index.d.ts +1413 -2
- package/dist/{index-CD0Wpla3.d.cts.map → DatePicker/index.d.ts.map} +1 -1
- package/dist/DatePicker/index.js +193 -2
- package/dist/DatePicker/index.js.map +1 -0
- package/dist/FieldArray/index.cjs +495 -4
- package/dist/FieldArray/index.cjs.map +1 -0
- package/dist/FieldArray/index.d.cts +539 -2
- package/dist/{index-B4XExHDi.d.cts.map → FieldArray/index.d.cts.map} +1 -1
- package/dist/FieldArray/index.d.ts +539 -2
- package/dist/{index-yYjVSHlN.d.ts.map → FieldArray/index.d.ts.map} +1 -1
- package/dist/FieldArray/index.js +494 -2
- package/dist/FieldArray/index.js.map +1 -0
- package/dist/FieldCard/index.cjs +226 -4
- package/dist/FieldCard/index.cjs.map +1 -0
- package/dist/FieldCard/index.d.cts +314 -2
- package/dist/FieldCard/index.d.cts.map +1 -0
- package/dist/FieldCard/index.d.ts +314 -2
- package/dist/FieldCard/index.d.ts.map +1 -0
- package/dist/FieldCard/index.js +225 -2
- package/dist/FieldCard/index.js.map +1 -0
- package/dist/{FieldCopyTestIdButton-Dpmo0uBV.js → FieldCopyTestIdButton-CRJBix9D.js} +2 -2
- package/dist/{FieldCopyTestIdButton-Dpmo0uBV.js.map → FieldCopyTestIdButton-CRJBix9D.js.map} +1 -1
- package/dist/{FieldCopyTestIdButton-ptoB1F75.cjs → FieldCopyTestIdButton-D3D_LmJh.cjs} +1 -8
- package/dist/{FieldCopyTestIdButton-ptoB1F75.cjs.map → FieldCopyTestIdButton-D3D_LmJh.cjs.map} +1 -1
- package/dist/{FieldValidationError-ktTyyyip.js → FieldValidationError-ByRoIxaM.js} +5 -5
- package/dist/{FieldValidationError-ktTyyyip.js.map → FieldValidationError-ByRoIxaM.js.map} +1 -1
- package/dist/{FieldValidationError-BQcvvU9i.cjs → FieldValidationError-CfYKzl7P.cjs} +5 -6
- package/dist/{FieldValidationError-BQcvvU9i.cjs.map → FieldValidationError-CfYKzl7P.cjs.map} +1 -1
- package/dist/Form/index.cjs +118 -3
- package/dist/Form/index.cjs.map +1 -0
- package/dist/Form/index.d.cts +43 -2
- package/dist/Form/index.d.cts.map +1 -0
- package/dist/Form/index.d.ts +43 -2
- package/dist/Form/index.d.ts.map +1 -0
- package/dist/Form/index.js +118 -2
- package/dist/Form/index.js.map +1 -0
- package/dist/{FormContext-3kamRn2C.d.cts → FormContext-BLWS7bhO.d.cts} +1 -1
- package/dist/{FormContext-3kamRn2C.d.cts.map → FormContext-BLWS7bhO.d.cts.map} +1 -1
- package/dist/{FormContext-BQeKOV-0.js → FormContext-DjJOJKxj.js} +1 -1
- package/dist/{FormContext-BQeKOV-0.js.map → FormContext-DjJOJKxj.js.map} +1 -1
- package/dist/{FormContext-DsmS_mkO.cjs → FormContext-EGH0cVnH.cjs} +1 -1
- package/dist/{FormContext-DsmS_mkO.cjs.map → FormContext-EGH0cVnH.cjs.map} +1 -1
- package/dist/{FormContext-i66vM5f1.d.ts → FormContext-LgzrDWu1.d.ts} +1 -1
- package/dist/{FormContext-i66vM5f1.d.ts.map → FormContext-LgzrDWu1.d.ts.map} +1 -1
- package/dist/Grid/index.cjs +1 -2
- package/dist/Grid/index.d.cts +22 -2
- package/dist/Grid/index.d.cts.map +1 -0
- package/dist/Grid/index.d.ts +22 -2
- package/dist/Grid/index.d.ts.map +1 -0
- package/dist/Grid/index.js +2 -2
- package/dist/{Grid-D-VcRGi9.cjs → Grid-BbqCRkuY.cjs} +1 -8
- package/dist/{Grid-D-VcRGi9.cjs.map → Grid-BbqCRkuY.cjs.map} +1 -1
- package/dist/{Grid-BQpLOB0G.js → Grid-CTs-Rb9G.js} +2 -2
- package/dist/{Grid-BQpLOB0G.js.map → Grid-CTs-Rb9G.js.map} +1 -1
- package/dist/Input/index.cjs +96 -3
- package/dist/Input/index.cjs.map +1 -0
- package/dist/Input/index.d.cts +677 -2
- package/dist/Input/index.d.cts.map +1 -0
- package/dist/Input/index.d.ts +677 -2
- package/dist/Input/index.d.ts.map +1 -0
- package/dist/Input/index.js +96 -2
- package/dist/Input/index.js.map +1 -0
- package/dist/RadioBoxes/index.cjs +136 -4
- package/dist/RadioBoxes/index.cjs.map +1 -0
- package/dist/RadioBoxes/index.d.cts +1477 -2
- package/dist/RadioBoxes/index.d.cts.map +1 -0
- package/dist/RadioBoxes/index.d.ts +1477 -2
- package/dist/RadioBoxes/index.d.ts.map +1 -0
- package/dist/RadioBoxes/index.js +135 -2
- package/dist/RadioBoxes/index.js.map +1 -0
- package/dist/RadioTabs/index.cjs +123 -4
- package/dist/RadioTabs/index.cjs.map +1 -0
- package/dist/RadioTabs/index.d.cts +585 -2
- package/dist/RadioTabs/index.d.cts.map +1 -0
- package/dist/RadioTabs/index.d.ts +585 -2
- package/dist/RadioTabs/index.d.ts.map +1 -0
- package/dist/RadioTabs/index.js +120 -2
- package/dist/RadioTabs/index.js.map +1 -0
- package/dist/Radios/index.cjs +74 -4
- package/dist/Radios/index.cjs.map +1 -0
- package/dist/Radios/index.d.cts +1263 -2
- package/dist/{index-DCwffq1f.d.ts.map → Radios/index.d.cts.map} +1 -1
- package/dist/Radios/index.d.ts +1263 -2
- package/dist/{index-CqXEYILn.d.cts.map → Radios/index.d.ts.map} +1 -1
- package/dist/Radios/index.js +73 -2
- package/dist/Radios/index.js.map +1 -0
- package/dist/Select/index.cjs +286 -4
- package/dist/Select/index.cjs.map +1 -0
- package/dist/Select/index.d.cts +3917 -2
- package/dist/{index-D1cB3mbB.d.ts.map → Select/index.d.cts.map} +1 -1
- package/dist/Select/index.d.ts +3917 -2
- package/dist/{index-veBM95Gw.d.cts.map → Select/index.d.ts.map} +1 -1
- package/dist/Select/index.js +283 -2
- package/dist/Select/index.js.map +1 -0
- package/dist/Slider/index.cjs +109 -4
- package/dist/Slider/index.cjs.map +1 -0
- package/dist/Slider/index.d.cts +1760 -2
- package/dist/{index-BUZEnZDm.d.ts.map → Slider/index.d.cts.map} +1 -1
- package/dist/Slider/index.d.ts +1760 -2
- package/dist/{index-Bie3CWyW.d.cts.map → Slider/index.d.ts.map} +1 -1
- package/dist/Slider/index.js +108 -2
- package/dist/Slider/index.js.map +1 -0
- package/dist/SubmitButton/index.cjs +31 -3
- package/dist/SubmitButton/index.cjs.map +1 -0
- package/dist/SubmitButton/index.d.cts +38 -2
- package/dist/SubmitButton/index.d.cts.map +1 -0
- package/dist/SubmitButton/index.d.ts +38 -2
- package/dist/SubmitButton/index.d.ts.map +1 -0
- package/dist/SubmitButton/index.js +31 -2
- package/dist/SubmitButton/index.js.map +1 -0
- package/dist/Switch/index.cjs +82 -4
- package/dist/Switch/index.cjs.map +1 -0
- package/dist/Switch/index.d.cts +1257 -2
- package/dist/{index-DqMpHpu7.d.ts.map → Switch/index.d.cts.map} +1 -1
- package/dist/Switch/index.d.ts +1257 -2
- package/dist/{index-19JGtN7H.d.cts.map → Switch/index.d.ts.map} +1 -1
- package/dist/Switch/index.js +81 -2
- package/dist/Switch/index.js.map +1 -0
- package/dist/SwitchBox/index.cjs +154 -4
- package/dist/SwitchBox/index.cjs.map +1 -0
- package/dist/SwitchBox/index.d.cts +473 -2
- package/dist/SwitchBox/index.d.cts.map +1 -0
- package/dist/SwitchBox/index.d.ts +473 -2
- package/dist/SwitchBox/index.d.ts.map +1 -0
- package/dist/SwitchBox/index.js +153 -2
- package/dist/SwitchBox/index.js.map +1 -0
- package/dist/TextArea/index.cjs +66 -3
- package/dist/TextArea/index.cjs.map +1 -0
- package/dist/TextArea/index.d.cts +659 -2
- package/dist/TextArea/index.d.cts.map +1 -0
- package/dist/TextArea/index.d.ts +659 -2
- package/dist/TextArea/index.d.ts.map +1 -0
- package/dist/TextArea/index.js +66 -2
- package/dist/TextArea/index.js.map +1 -0
- package/dist/Time/index.cjs +217 -4
- package/dist/Time/index.cjs.map +1 -0
- package/dist/Time/index.d.cts +1028 -2
- package/dist/Time/index.d.cts.map +1 -0
- package/dist/Time/index.d.ts +1028 -2
- package/dist/Time/index.d.ts.map +1 -0
- package/dist/Time/index.js +216 -2
- package/dist/Time/index.js.map +1 -0
- package/dist/helpers/index.cjs +0 -1
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.js.map +1 -1
- package/dist/hooks/useClientValidation/index.cjs +177 -3
- package/dist/hooks/useClientValidation/index.cjs.map +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +148 -2
- package/dist/hooks/useClientValidation/index.d.cts.map +1 -0
- package/dist/hooks/useClientValidation/index.d.ts +148 -2
- package/dist/hooks/useClientValidation/index.d.ts.map +1 -0
- package/dist/hooks/useClientValidation/index.js +175 -1
- package/dist/hooks/useClientValidation/index.js.map +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.cts +1 -1
- package/dist/hooks/useController/index.d.ts +1 -1
- package/dist/hooks/useController/index.js +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +1 -1
- package/dist/hooks/useFormContext/index.js +1 -1
- package/dist/hooks/useInput/index.cjs +0 -1
- package/dist/hooks/useInput/index.d.cts +1 -1
- package/dist/hooks/useInput/index.d.ts +1 -1
- package/dist/hooks/useInput/index.js +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -2
- package/dist/hooks/useInputValueDebounce/index.cjs.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +66 -2
- package/dist/hooks/useInputValueDebounce/index.d.cts.map +1 -0
- package/dist/hooks/useInputValueDebounce/index.d.ts +66 -2
- package/dist/hooks/useInputValueDebounce/index.d.ts.map +1 -0
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +1 -1
- package/dist/hooks/useInputValueTransform/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +8 -8
- package/dist/hooks/useUniformField/index.cjs.map +1 -1
- package/dist/hooks/useUniformField/index.d.cts +98 -2
- package/dist/hooks/useUniformField/index.d.cts.map +1 -0
- package/dist/hooks/useUniformField/index.d.ts +98 -2
- package/dist/hooks/useUniformField/index.d.ts.map +1 -0
- package/dist/hooks/useUniformField/index.js +8 -8
- package/dist/hooks/useUniformField/index.js.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -2
- package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +79 -2
- package/dist/hooks/useUniformFieldArray/index.d.cts.map +1 -0
- package/dist/hooks/useUniformFieldArray/index.d.ts +79 -2
- package/dist/hooks/useUniformFieldArray/index.d.ts.map +1 -0
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchFormReset/index.cjs +1 -2
- package/dist/hooks/useWatchFormReset/index.cjs.map +1 -1
- package/dist/hooks/useWatchFormReset/index.d.cts +38 -2
- package/dist/hooks/useWatchFormReset/index.d.cts.map +1 -0
- package/dist/hooks/useWatchFormReset/index.d.ts +38 -2
- package/dist/hooks/useWatchFormReset/index.d.ts.map +1 -0
- package/dist/hooks/useWatchFormReset/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +82 -2
- package/dist/hooks/useWatchUserChange/index.cjs.map +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +80 -2
- package/dist/hooks/useWatchUserChange/index.d.cts.map +1 -0
- package/dist/hooks/useWatchUserChange/index.d.ts +80 -2
- package/dist/hooks/useWatchUserChange/index.d.ts.map +1 -0
- package/dist/hooks/useWatchUserChange/index.js +81 -1
- package/dist/hooks/useWatchUserChange/index.js.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -2
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +14 -2
- package/dist/partials/FieldCopyTestIdButton/index.d.cts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +14 -2
- package/dist/partials/FieldCopyTestIdButton/index.d.ts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.js +2 -2
- package/dist/partials/FieldValidationError/index.cjs +1 -2
- package/dist/partials/FieldValidationError/index.d.cts +22 -2
- package/dist/partials/FieldValidationError/index.d.cts.map +1 -0
- package/dist/partials/FieldValidationError/index.d.ts +22 -2
- package/dist/partials/FieldValidationError/index.d.ts.map +1 -0
- package/dist/partials/FieldValidationError/index.js +2 -2
- package/dist/{useController-CzP0aVFC.d.ts → useController-CvQqCvFJ.d.ts} +1 -1
- package/dist/{useController-CzP0aVFC.d.ts.map → useController-CvQqCvFJ.d.ts.map} +1 -1
- package/dist/{useController--lRPWBuD.cjs → useController-Dbe7ADG6.cjs} +2 -2
- package/dist/{useController--lRPWBuD.cjs.map → useController-Dbe7ADG6.cjs.map} +1 -1
- package/dist/{useController-B287flU_.js → useController-DxFS0u7c.js} +2 -2
- package/dist/{useController-B287flU_.js.map → useController-DxFS0u7c.js.map} +1 -1
- package/dist/{useController-BT3Fd0IO.d.cts → useController-fblEApv_.d.cts} +1 -1
- package/dist/{useController-BT3Fd0IO.d.cts.map → useController-fblEApv_.d.cts.map} +1 -1
- package/dist/{useFormContext-Bj1gXLt_.d.ts → useFormContext-B1-deU4Z.d.ts} +2 -2
- package/dist/{useFormContext-Bj1gXLt_.d.ts.map → useFormContext-B1-deU4Z.d.ts.map} +1 -1
- package/dist/{useFormContext-CT8H8xIe.js → useFormContext-BJqa1FoT.js} +2 -2
- package/dist/{useFormContext-CT8H8xIe.js.map → useFormContext-BJqa1FoT.js.map} +1 -1
- package/dist/{useFormContext-M94eQfHm.d.cts → useFormContext-D5vrT2sg.d.cts} +2 -2
- package/dist/{useFormContext-M94eQfHm.d.cts.map → useFormContext-D5vrT2sg.d.cts.map} +1 -1
- package/dist/{useFormContext-CrXwNYiB.cjs → useFormContext-kUHonwgu.cjs} +2 -2
- package/dist/{useFormContext-CrXwNYiB.cjs.map → useFormContext-kUHonwgu.cjs.map} +1 -1
- package/dist/{useInputValueTransform-CNCBU7a9.d.cts → useInputValueTransform-DCXXb2Lp.d.cts} +1 -1
- package/dist/{useInputValueTransform-CNCBU7a9.d.cts.map → useInputValueTransform-DCXXb2Lp.d.cts.map} +1 -1
- package/dist/{useInputValueTransform-dLfFIYW4.d.ts → useInputValueTransform-DCXXb2Lp.d.ts} +1 -1
- package/dist/{useInputValueTransform-dLfFIYW4.d.ts.map → useInputValueTransform-DCXXb2Lp.d.ts.map} +1 -1
- package/dist/{useInputValueTransform-CXdmtc0Q.js → useInputValueTransform-DJ5zkqSy.js} +1 -1
- package/dist/{useInputValueTransform-CXdmtc0Q.js.map → useInputValueTransform-DJ5zkqSy.js.map} +1 -1
- package/dist/{useInputValueTransform-Bm65K8LX.cjs → useInputValueTransform-P62UUZBl.cjs} +1 -2
- package/dist/{useInputValueTransform-Bm65K8LX.cjs.map → useInputValueTransform-P62UUZBl.cjs.map} +1 -1
- package/package.json +5 -12
- package/dist/Checkboxes-DrJqx6O2.cjs +0 -130
- package/dist/Checkboxes-DrJqx6O2.cjs.map +0 -1
- package/dist/Checkboxes-X6FRwI50.js +0 -112
- package/dist/Checkboxes-X6FRwI50.js.map +0 -1
- package/dist/DatePicker-CGIWizz9.js +0 -193
- package/dist/DatePicker-CGIWizz9.js.map +0 -1
- package/dist/DatePicker-CYUuwwsm.cjs +0 -211
- package/dist/DatePicker-CYUuwwsm.cjs.map +0 -1
- package/dist/FieldArray-Dkw6JBnT.js +0 -494
- package/dist/FieldArray-Dkw6JBnT.js.map +0 -1
- package/dist/FieldArray-V66fsvtd.cjs +0 -512
- package/dist/FieldArray-V66fsvtd.cjs.map +0 -1
- package/dist/FieldCard-CAHnM8C0.cjs +0 -243
- package/dist/FieldCard-CAHnM8C0.cjs.map +0 -1
- package/dist/FieldCard-Cg31ce9J.js +0 -225
- package/dist/FieldCard-Cg31ce9J.js.map +0 -1
- package/dist/Form-CYlsIABv.cjs +0 -125
- package/dist/Form-CYlsIABv.cjs.map +0 -1
- package/dist/Form-D3yfDu4L.js +0 -114
- package/dist/Form-D3yfDu4L.js.map +0 -1
- package/dist/Input-B5RxbkNS.js +0 -96
- package/dist/Input-B5RxbkNS.js.map +0 -1
- package/dist/Input-DvVViuWH.cjs +0 -108
- package/dist/Input-DvVViuWH.cjs.map +0 -1
- package/dist/RadioBoxes-BmLrbYXt.cjs +0 -153
- package/dist/RadioBoxes-BmLrbYXt.cjs.map +0 -1
- package/dist/RadioBoxes-DWxJBTKR.js +0 -135
- package/dist/RadioBoxes-DWxJBTKR.js.map +0 -1
- package/dist/RadioTabs-14XTbTJU.cjs +0 -139
- package/dist/RadioTabs-14XTbTJU.cjs.map +0 -1
- package/dist/RadioTabs-DAY6MYJI.js +0 -120
- package/dist/RadioTabs-DAY6MYJI.js.map +0 -1
- package/dist/Radios-C938-msm.js +0 -73
- package/dist/Radios-C938-msm.js.map +0 -1
- package/dist/Radios-D_B9Y8s2.cjs +0 -91
- package/dist/Radios-D_B9Y8s2.cjs.map +0 -1
- package/dist/Select-BL6k_e-D.js +0 -283
- package/dist/Select-BL6k_e-D.js.map +0 -1
- package/dist/Select-D66A-hYm.cjs +0 -302
- package/dist/Select-D66A-hYm.cjs.map +0 -1
- package/dist/Slider-ChC2PZNb.cjs +0 -126
- package/dist/Slider-ChC2PZNb.cjs.map +0 -1
- package/dist/Slider-DmEwhC1T.js +0 -108
- package/dist/Slider-DmEwhC1T.js.map +0 -1
- package/dist/SubmitButton-D-wn1PJV.cjs +0 -43
- package/dist/SubmitButton-D-wn1PJV.cjs.map +0 -1
- package/dist/SubmitButton-D6aU7IgC.js +0 -31
- package/dist/SubmitButton-D6aU7IgC.js.map +0 -1
- package/dist/Switch-Ch6_VInV.cjs +0 -99
- package/dist/Switch-Ch6_VInV.cjs.map +0 -1
- package/dist/Switch-DvKRPFcC.js +0 -81
- package/dist/Switch-DvKRPFcC.js.map +0 -1
- package/dist/SwitchBox-BU1XieaZ.js +0 -153
- package/dist/SwitchBox-BU1XieaZ.js.map +0 -1
- package/dist/SwitchBox-Dl-F5y2m.cjs +0 -171
- package/dist/SwitchBox-Dl-F5y2m.cjs.map +0 -1
- package/dist/TextArea-CMXm-kTK.cjs +0 -78
- package/dist/TextArea-CMXm-kTK.cjs.map +0 -1
- package/dist/TextArea-DAg_K-QP.js +0 -66
- package/dist/TextArea-DAg_K-QP.js.map +0 -1
- package/dist/Time-B_SXrKWK.js +0 -216
- package/dist/Time-B_SXrKWK.js.map +0 -1
- package/dist/Time-CYoWaQsz.cjs +0 -234
- package/dist/Time-CYoWaQsz.cjs.map +0 -1
- package/dist/index-19JGtN7H.d.cts +0 -1257
- package/dist/index-54OZEaUU.d.ts +0 -43
- package/dist/index-54OZEaUU.d.ts.map +0 -1
- package/dist/index-B4XExHDi.d.cts +0 -539
- package/dist/index-BUZEnZDm.d.ts +0 -1760
- package/dist/index-Bbaubtxp.d.cts +0 -677
- package/dist/index-Bbaubtxp.d.cts.map +0 -1
- package/dist/index-BdgFJ-dj.d.ts +0 -1028
- package/dist/index-BdgFJ-dj.d.ts.map +0 -1
- package/dist/index-BiZNkLK3.d.cts +0 -1477
- package/dist/index-BiZNkLK3.d.cts.map +0 -1
- package/dist/index-Bie3CWyW.d.cts +0 -1760
- package/dist/index-BqxDWhNr.d.cts +0 -22
- package/dist/index-BqxDWhNr.d.cts.map +0 -1
- package/dist/index-BsTqcI1C.d.cts +0 -659
- package/dist/index-BsTqcI1C.d.cts.map +0 -1
- package/dist/index-C3-TV4Up.d.cts +0 -43
- package/dist/index-C3-TV4Up.d.cts.map +0 -1
- package/dist/index-C6Y8KybK.d.ts +0 -677
- package/dist/index-C6Y8KybK.d.ts.map +0 -1
- package/dist/index-CD0Wpla3.d.cts +0 -1413
- package/dist/index-CEJxjf5R.d.ts +0 -22
- package/dist/index-CEJxjf5R.d.ts.map +0 -1
- package/dist/index-CHQKk_fN2.d.ts +0 -14
- package/dist/index-CHQKk_fN2.d.ts.map +0 -1
- package/dist/index-CUByIf_d.d.ts +0 -314
- package/dist/index-CUByIf_d.d.ts.map +0 -1
- package/dist/index-CV7wqRev.d.ts +0 -38
- package/dist/index-CV7wqRev.d.ts.map +0 -1
- package/dist/index-CXvUaeCL.d.cts +0 -14
- package/dist/index-CXvUaeCL.d.cts.map +0 -1
- package/dist/index-Cf2B9woY.d.cts +0 -473
- package/dist/index-Cf2B9woY.d.cts.map +0 -1
- package/dist/index-CqXEYILn.d.cts +0 -1263
- package/dist/index-D1cB3mbB.d.ts +0 -3917
- package/dist/index-D7AUghFx.d.ts +0 -1413
- package/dist/index-DCwffq1f.d.ts +0 -1263
- package/dist/index-DFbuWomg.d.ts +0 -534
- package/dist/index-DFbuWomg.d.ts.map +0 -1
- package/dist/index-DXOBPBft.d.ts +0 -659
- package/dist/index-DXOBPBft.d.ts.map +0 -1
- package/dist/index-DY-d4cFe.d.cts +0 -1028
- package/dist/index-DY-d4cFe.d.cts.map +0 -1
- package/dist/index-DpXSZCZe.d.cts +0 -38
- package/dist/index-DpXSZCZe.d.cts.map +0 -1
- package/dist/index-DqMpHpu7.d.ts +0 -1257
- package/dist/index-DwnqyNnX.d.cts +0 -534
- package/dist/index-DwnqyNnX.d.cts.map +0 -1
- package/dist/index-OdNTqjhQ.d.ts +0 -585
- package/dist/index-OdNTqjhQ.d.ts.map +0 -1
- package/dist/index-P30z4VRT.d.cts +0 -22
- package/dist/index-P30z4VRT.d.cts.map +0 -1
- package/dist/index-PWRw2bPH.d.ts +0 -22
- package/dist/index-PWRw2bPH.d.ts.map +0 -1
- package/dist/index-QPDvw5Z5.d.cts +0 -585
- package/dist/index-QPDvw5Z5.d.cts.map +0 -1
- package/dist/index-amMd-sQN.d.ts +0 -473
- package/dist/index-amMd-sQN.d.ts.map +0 -1
- package/dist/index-clztdahp.d.ts +0 -1477
- package/dist/index-clztdahp.d.ts.map +0 -1
- package/dist/index-jK092-MJ.d.cts +0 -314
- package/dist/index-jK092-MJ.d.cts.map +0 -1
- package/dist/index-veBM95Gw.d.cts +0 -3917
- package/dist/index-yYjVSHlN.d.ts +0 -539
- package/dist/index.cjs +0 -94
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -31
- package/dist/index.d.ts +0 -31
- package/dist/index.js +0 -36
- package/dist/index.js.map +0 -1
- package/dist/useClientValidation-BRfhqRom.cjs +0 -190
- package/dist/useClientValidation-BRfhqRom.cjs.map +0 -1
- package/dist/useClientValidation-C2dLJnDI.d.cts +0 -148
- package/dist/useClientValidation-C2dLJnDI.d.cts.map +0 -1
- package/dist/useClientValidation-DpLdzIAb.js +0 -178
- package/dist/useClientValidation-DpLdzIAb.js.map +0 -1
- package/dist/useClientValidation-qRq2_spX.d.ts +0 -148
- package/dist/useClientValidation-qRq2_spX.d.ts.map +0 -1
- package/dist/useInputValueDebounce-CfQDiomI.d.cts +0 -66
- package/dist/useInputValueDebounce-CfQDiomI.d.cts.map +0 -1
- package/dist/useInputValueDebounce-DZgzL7GQ.d.ts +0 -66
- package/dist/useInputValueDebounce-DZgzL7GQ.d.ts.map +0 -1
- package/dist/useUniformField-BE-e3C4Y.d.cts +0 -98
- package/dist/useUniformField-BE-e3C4Y.d.cts.map +0 -1
- package/dist/useUniformField-DUW-svZD.d.ts +0 -98
- package/dist/useUniformField-DUW-svZD.d.ts.map +0 -1
- package/dist/useUniformFieldArray-CdWv1SEk.d.ts +0 -79
- package/dist/useUniformFieldArray-CdWv1SEk.d.ts.map +0 -1
- package/dist/useUniformFieldArray-kkOHxNFF.d.cts +0 -79
- package/dist/useUniformFieldArray-kkOHxNFF.d.cts.map +0 -1
- package/dist/useWatchFormReset-BSd6jMxU.d.cts +0 -38
- package/dist/useWatchFormReset-BSd6jMxU.d.cts.map +0 -1
- package/dist/useWatchFormReset-C7YJ-I3N.d.ts +0 -38
- package/dist/useWatchFormReset-C7YJ-I3N.d.ts.map +0 -1
- package/dist/useWatchUserChange-C1xWHtFG.cjs +0 -90
- package/dist/useWatchUserChange-C1xWHtFG.cjs.map +0 -1
- package/dist/useWatchUserChange-CpyZz2i7.d.ts +0 -80
- package/dist/useWatchUserChange-CpyZz2i7.d.ts.map +0 -1
- package/dist/useWatchUserChange-DSAboNCs.d.cts +0 -80
- package/dist/useWatchUserChange-DSAboNCs.d.cts.map +0 -1
- package/dist/useWatchUserChange-DSQGsl1R.js +0 -84
- package/dist/useWatchUserChange-DSQGsl1R.js.map +0 -1
- /package/dist/{index-BLwMeReG.d.ts → index-BKZ67WMa.d.cts} +0 -0
- /package/dist/{index-C2gUMYkE.d.cts → index-BKZ67WMa.d.ts} +0 -0
- /package/dist/{index-CJgP-E0M.d.cts → index-BVVgDSdq.d.cts} +0 -0
- /package/dist/{index-Cg9utiy0.d.ts → index-BVVgDSdq.d.ts} +0 -0
- /package/dist/{index-CspKFJM1.d.cts → index-DmtQKWjk.d.cts} +0 -0
- /package/dist/{index-h64gcVNJ.d.ts → index-DmtQKWjk.d.ts} +0 -0
- /package/dist/{useInput-CVm3tP78.js → useInput-C0aJaAGe.js} +0 -0
- /package/dist/{useInput-BdH8oftG.d.ts → useInput-ClpHDPdr.d.cts} +0 -0
- /package/dist/{useInput-DZOmMKcp.d.cts → useInput-ClpHDPdr.d.ts} +0 -0
|
@@ -1,4 +1,178 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../helpers/index.js";
|
|
2
|
+
import { n as useFormContext } from "../../useFormContext-BJqa1FoT.js";
|
|
3
|
+
import { useEffect, useId } from "react";
|
|
4
|
+
import { array, objectLoose } from "@fuf-stack/veto";
|
|
5
|
+
//#region src/hooks/useClientValidation/useClientValidation.ts
|
|
6
|
+
/**
|
|
7
|
+
* Hook for adding dynamic client-side validation to forms.
|
|
8
|
+
*
|
|
9
|
+
* Client validation is used for context-dependent validation rules that require external data
|
|
10
|
+
* (e.g., checking if a username already exists). It complements base validation (passed to Form),
|
|
11
|
+
* which handles static rules like "required", min/max length, format, etc.
|
|
12
|
+
*
|
|
13
|
+
* **Typical pattern:**
|
|
14
|
+
* - Base validation: Static, always-on rules (required, format, length constraints)
|
|
15
|
+
* - Client validation: Dynamic rules based on external data (uniqueness, business logic)
|
|
16
|
+
* - Client schemas should use `.nullish()` to allow empty values (base validation handles "required")
|
|
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. When the client
|
|
20
|
+
* validation schema changes, automatically re-validates all touched fields.
|
|
21
|
+
*
|
|
22
|
+
* @param data - Data to create validation schema from (or null/undefined to clear validation)
|
|
23
|
+
* @param schemaFactory - Function that creates a validation schema from the data. Schemas should typically use `.nullish()`.
|
|
24
|
+
* @param options - Optional configuration object
|
|
25
|
+
* @param options.key - Optional custom key for registration. Useful when multiple instances should share validation (e.g., in field arrays)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* // Base validation handles "required" and format
|
|
30
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) });
|
|
31
|
+
*
|
|
32
|
+
* // Client validation adds dynamic uniqueness check
|
|
33
|
+
* const { data: teamData } = useTeamQuery(teamId);
|
|
34
|
+
* useClientValidation(teamData, (data) =>
|
|
35
|
+
* vt.objectLoose({
|
|
36
|
+
* username: vt.string()
|
|
37
|
+
* .refine(
|
|
38
|
+
* (value) => !data.existingUsers.includes(value),
|
|
39
|
+
* { message: 'Username already exists' }
|
|
40
|
+
* )
|
|
41
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
42
|
+
* })
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* // Using custom key in a field array to avoid multiple registrations
|
|
49
|
+
* fields.map((field, index) => (
|
|
50
|
+
* useClientValidation(
|
|
51
|
+
* userData,
|
|
52
|
+
* (data) => clientValidationSchemaByName(
|
|
53
|
+
* `items.${index}.name`,
|
|
54
|
+
* vt.string()
|
|
55
|
+
* .refine((val) => !data.forbidden.includes(val), { message: 'Name not allowed' })
|
|
56
|
+
* .nullish()
|
|
57
|
+
* ),
|
|
58
|
+
* { key: 'items-validation' } // All instances share the same key
|
|
59
|
+
* )
|
|
60
|
+
* ));
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
const useClientValidation = (data, schemaFactory, options) => {
|
|
64
|
+
const { formState: { touchedFields }, validation: { setClientValidationSchema }, trigger } = useFormContext();
|
|
65
|
+
const autoGeneratedKey = useId();
|
|
66
|
+
const key = options?.key ?? autoGeneratedKey;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (data != null) setClientValidationSchema(key, schemaFactory(data));
|
|
69
|
+
else setClientValidationSchema(key, null);
|
|
70
|
+
const touchedFieldNames = Object.keys(touchedFields);
|
|
71
|
+
if (touchedFieldNames.length > 0) setTimeout(async () => {
|
|
72
|
+
return trigger(touchedFieldNames);
|
|
73
|
+
}, 1);
|
|
74
|
+
return () => {
|
|
75
|
+
setClientValidationSchema(key, null);
|
|
76
|
+
};
|
|
77
|
+
}, [JSON.stringify(data), key]);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Helper function to create a veto looseObject schema for a single field with nested path support.
|
|
81
|
+
*
|
|
82
|
+
* Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
|
|
83
|
+
* All intermediate objects and arrays are marked as optional to allow partial data structures.
|
|
84
|
+
* Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
|
|
85
|
+
* Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
|
|
86
|
+
*
|
|
87
|
+
* **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
|
|
88
|
+
* - Base validation (passed to Form) handles "required" constraints
|
|
89
|
+
* - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
|
|
90
|
+
* - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
|
|
91
|
+
* - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
|
|
92
|
+
*
|
|
93
|
+
* This pattern ensures client validation only validates non-empty values, while base validation
|
|
94
|
+
* enforces required fields and basic constraints (min length, format, etc.).
|
|
95
|
+
*
|
|
96
|
+
* @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
|
|
97
|
+
* @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
|
|
98
|
+
* @returns A nested loose object schema matching the field path structure with proper type inference
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* // Typical usage: base validation handles "required", client validation adds dynamic rules
|
|
103
|
+
* // Base validation (in Form component)
|
|
104
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
|
|
105
|
+
*
|
|
106
|
+
* // Client validation (dynamic check for existing usernames)
|
|
107
|
+
* const { data: userData } = useUserQuery(userId);
|
|
108
|
+
* useClientValidation(userData, (data) =>
|
|
109
|
+
* clientValidationSchemaByName(
|
|
110
|
+
* 'username',
|
|
111
|
+
* vt.string()
|
|
112
|
+
* .refine(
|
|
113
|
+
* (value) => !data.existingUsernames.includes(value),
|
|
114
|
+
* { message: 'Username already taken' }
|
|
115
|
+
* )
|
|
116
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
117
|
+
* )
|
|
118
|
+
* );
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* // Nested field path with dynamic validation
|
|
124
|
+
* clientValidationSchemaByName(
|
|
125
|
+
* 'user.profile.email',
|
|
126
|
+
* vt.string()
|
|
127
|
+
* .refine(
|
|
128
|
+
* (value) => !reservedEmails.includes(value),
|
|
129
|
+
* { message: 'This email is reserved' }
|
|
130
|
+
* )
|
|
131
|
+
* .nullish()
|
|
132
|
+
* )
|
|
133
|
+
* // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* // Array of objects with dynamic validation
|
|
139
|
+
* clientValidationSchemaByName(
|
|
140
|
+
* 'items.0.tag',
|
|
141
|
+
* vt.string()
|
|
142
|
+
* .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
|
|
143
|
+
* .nullish()
|
|
144
|
+
* )
|
|
145
|
+
* // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* // Flat array (array of primitives) with dynamic validation
|
|
151
|
+
* clientValidationSchemaByName(
|
|
152
|
+
* 'tags.0.__FLAT__',
|
|
153
|
+
* vt.string()
|
|
154
|
+
* .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
|
|
155
|
+
* .nullish()
|
|
156
|
+
* )
|
|
157
|
+
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
const clientValidationSchemaByName = (name, fieldSchema) => {
|
|
161
|
+
const segments = name.split(".");
|
|
162
|
+
let schema = fieldSchema;
|
|
163
|
+
for (let i = segments.length - 1; i >= 0; i -= 1) {
|
|
164
|
+
const segment = segments[i];
|
|
165
|
+
const isNumeric = /^\d+$/.test(segment);
|
|
166
|
+
if (segment === "__FLAT__") continue;
|
|
167
|
+
if (isNumeric) schema = array(schema).optional();
|
|
168
|
+
else {
|
|
169
|
+
const obj = objectLoose({ [segment]: schema });
|
|
170
|
+
schema = i > 0 ? obj.optional() : obj;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return schema;
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
2
176
|
//#region src/hooks/useClientValidation/index.ts
|
|
3
177
|
/* v8 ignore stop */
|
|
4
178
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useClientValidation/index.ts"],"sourcesContent":["/* v8 ignore start */\n\nexport * from './useClientValidation';\n\n/* v8 ignore stop */\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/useClientValidation/useClientValidation.ts","../../../src/hooks/useClientValidation/index.ts"],"sourcesContent":["import type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { array, objectLoose } from '@fuf-stack/veto';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Client validation is used for context-dependent validation rules that require external data\n * (e.g., checking if a username already exists). It complements base validation (passed to Form),\n * which handles static rules like \"required\", min/max length, format, etc.\n *\n * **Typical pattern:**\n * - Base validation: Static, always-on rules (required, format, length constraints)\n * - Client validation: Dynamic rules based on external data (uniqueness, business logic)\n * - Client schemas should use `.nullish()` to allow empty values (base validation handles \"required\")\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount. When the client\n * validation schema changes, automatically re-validates all touched fields.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data. Schemas should typically use `.nullish()`.\n * @param options - Optional configuration object\n * @param options.key - Optional custom key for registration. Useful when multiple instances should share validation (e.g., in field arrays)\n *\n * @example\n * ```tsx\n * // Base validation handles \"required\" and format\n * const baseSchema = veto({ username: vt.string({ min: 3 }) });\n *\n * // Client validation adds dynamic uniqueness check\n * const { data: teamData } = useTeamQuery(teamId);\n * useClientValidation(teamData, (data) =>\n * vt.objectLoose({\n * username: vt.string()\n * .refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * .nullish() // Allow empty - base validation handles \"required\"\n * })\n * );\n * ```\n *\n * @example\n * ```tsx\n * // Using custom key in a field array to avoid multiple registrations\n * fields.map((field, index) => (\n * useClientValidation(\n * userData,\n * (data) => clientValidationSchemaByName(\n * `items.${index}.name`,\n * vt.string()\n * .refine((val) => !data.forbidden.includes(val), { message: 'Name not allowed' })\n * .nullish()\n * ),\n * { key: 'items-validation' } // All instances share the same key\n * )\n * ));\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n options?: { key?: string },\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Use provided key or auto-generate unique key\n const autoGeneratedKey = useId();\n const key = options?.key ?? autoGeneratedKey;\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(async () => {\n return trigger(touchedFieldNames);\n }, 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n\n/**\n * Helper function to create a veto looseObject schema for a single field with nested path support.\n *\n * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.\n * All intermediate objects and arrays are marked as optional to allow partial data structures.\n * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.\n * Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.\n *\n * **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:\n * - Base validation (passed to Form) handles \"required\" constraints\n * - Client validation adds dynamic, context-dependent rules (e.g., \"username already exists\")\n * - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)\n * - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`\n *\n * This pattern ensures client validation only validates non-empty values, while base validation\n * enforces required fields and basic constraints (min length, format, etc.).\n *\n * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')\n * @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.\n * @returns A nested loose object schema matching the field path structure with proper type inference\n *\n * @example\n * ```tsx\n * // Typical usage: base validation handles \"required\", client validation adds dynamic rules\n * // Base validation (in Form component)\n * const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length\n *\n * // Client validation (dynamic check for existing usernames)\n * const { data: userData } = useUserQuery(userId);\n * useClientValidation(userData, (data) =>\n * clientValidationSchemaByName(\n * 'username',\n * vt.string()\n * .refine(\n * (value) => !data.existingUsernames.includes(value),\n * { message: 'Username already taken' }\n * )\n * .nullish() // Allow empty - base validation handles \"required\"\n * )\n * );\n * ```\n *\n * @example\n * ```tsx\n * // Nested field path with dynamic validation\n * clientValidationSchemaByName(\n * 'user.profile.email',\n * vt.string()\n * .refine(\n * (value) => !reservedEmails.includes(value),\n * { message: 'This email is reserved' }\n * )\n * .nullish()\n * )\n * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })\n * ```\n *\n * @example\n * ```tsx\n * // Array of objects with dynamic validation\n * clientValidationSchemaByName(\n * 'items.0.tag',\n * vt.string()\n * .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })\n * .nullish()\n * )\n * // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })\n * ```\n *\n * @example\n * ```tsx\n * // Flat array (array of primitives) with dynamic validation\n * clientValidationSchemaByName(\n * 'tags.0.__FLAT__',\n * vt.string()\n * .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })\n * .nullish()\n * )\n * // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })\n * ```\n */\nexport const clientValidationSchemaByName = <T extends VetoTypeAny>(\n name: string,\n fieldSchema: T,\n) => {\n const segments = name.split('.');\n\n // Build schema from innermost to outermost\n let schema: VetoTypeAny = fieldSchema;\n\n // Process segments in reverse order to build nested structure\n for (let i = segments.length - 1; i >= 0; i -= 1) {\n const segment = segments[i];\n\n const isNumeric = /^\\d+$/.test(segment);\n const isFlatArrayKey = segment === flatArrayKey;\n\n if (isFlatArrayKey) {\n // Skip the __FLAT__ key - it's just a marker for flat arrays\n // The schema is already correct (primitive type), just continue\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (isNumeric) {\n // Current segment is an array index - wrap current schema in optional array\n schema = array(schema).optional();\n } else {\n // Current segment is a field name - wrap in objectLoose\n // Make it optional if it's an intermediate object (not the root)\n const obj = objectLoose({\n [segment]: schema,\n });\n schema = i > 0 ? obj.optional() : obj;\n }\n }\n\n return schema;\n};\n","/* v8 ignore start */\n\nexport * from './useClientValidation';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,uBACX,MACA,eACA,YACS;CACT,MAAM,EACJ,WAAW,EAAE,iBACb,YAAY,EAAE,6BACd,YACE,eAAe;CAGnB,MAAM,mBAAmB,MAAM;CAC/B,MAAM,MAAM,SAAS,OAAO;CAO5B,gBAAgB;EAEd,IAAI,QAAQ,MAEV,0BAA0B,KADD,cAAc,IACO,CAAC;OAG/C,0BAA0B,KAAK,IAAI;EAIrC,MAAM,oBAAoB,OAAO,KAAK,aAAa;EACnD,IAAI,kBAAkB,SAAS,GAG7B,WAAW,YAAY;GACrB,OAAO,QAAQ,iBAAiB;EAClC,GAAG,CAAC;EAIN,aAAa;GACX,0BAA0B,KAAK,IAAI;EACrC;CAGF,GAAG,CA7Bc,KAAK,UAAU,IA6BrB,GAAG,GAAG,CAAC;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,MAAa,gCACX,MACA,gBACG;CACH,MAAM,WAAW,KAAK,MAAM,GAAG;CAG/B,IAAI,SAAsB;CAG1B,KAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;EAChD,MAAM,UAAU,SAAS;EAEzB,MAAM,YAAY,QAAQ,KAAK,OAAO;EAGtC,IAFuB,YAAA,YAMrB;EAGF,IAAI,WAEF,SAAS,MAAM,MAAM,EAAE,SAAS;OAC3B;GAGL,MAAM,MAAM,YAAY,GACrB,UAAU,OACb,CAAC;GACD,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI;EACpC;CACF;CAEA,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_useController = require("../../useController
|
|
2
|
+
const require_useController = require("../../useController-Dbe7ADG6.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-
|
|
1
|
+
import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-fblEApv_.cjs";
|
|
2
2
|
export { UseControllerProps, UseControllerReturn, useController };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-
|
|
1
|
+
import { n as UseControllerReturn, r as useController, t as UseControllerProps } from "../../useController-CvQqCvFJ.js";
|
|
2
2
|
export { UseControllerProps, UseControllerReturn, useController };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_useFormContext = require("../../useFormContext-
|
|
2
|
+
const require_useFormContext = require("../../useFormContext-kUHonwgu.cjs");
|
|
3
3
|
//#region src/hooks/useFormContext/index.ts
|
|
4
4
|
/* v8 ignore stop */
|
|
5
5
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-
|
|
1
|
+
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-D5vrT2sg.cjs";
|
|
2
2
|
export { checkFieldIsRequired, useFormContext };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-
|
|
1
|
+
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-B1-deU4Z.js";
|
|
2
2
|
export { checkFieldIsRequired, useFormContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-
|
|
1
|
+
import { n as useFormContext, t as checkFieldIsRequired } from "../../useFormContext-BJqa1FoT.js";
|
|
2
2
|
//#region src/hooks/useFormContext/index.ts
|
|
3
3
|
/* v8 ignore stop */
|
|
4
4
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useInput } from "../../useInput-
|
|
1
|
+
import { t as useInput } from "../../useInput-ClpHDPdr.cjs";
|
|
2
2
|
export { useInput };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useInput } from "../../useInput-
|
|
1
|
+
import { t as useInput } from "../../useInput-ClpHDPdr.js";
|
|
2
2
|
export { useInput };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../
|
|
3
|
-
const require_useFormContext = require("../../useFormContext-CrXwNYiB.cjs");
|
|
2
|
+
const require_useFormContext = require("../../useFormContext-kUHonwgu.cjs");
|
|
4
3
|
let react = require("react");
|
|
5
4
|
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
6
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useFormContext"],"sources":["../../../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../../../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useFormContext } from '../useFormContext';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** Field name for triggering validation after debounced value commits */\n name: string;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n name,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n const { trigger } = useFormContext();\n\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n // Trigger validation after debounced value commits\n // This ensures errors are updated immediately when field becomes valid\n trigger(name);\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay, trigger, name],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useFormContext"],"sources":["../../../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../../../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useFormContext } from '../useFormContext';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** Field name for triggering validation after debounced value commits */\n name: string;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n name,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n const { trigger } = useFormContext();\n\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n // Trigger validation after debounced value commits\n // This ensures errors are updated immediately when field becomes valid\n trigger(name);\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay, trigger, name],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,MACA,QACA,UACA,YAC+E;CAC/E,MAAM,EAAE,YAAYA,uBAAAA,eAAe;CAGnC,MAAM,CAAC,cAAc,oBAAA,GAAA,MAAA,UAAoC,KAAK;CAE9D,MAAM,cAAA,GAAA,MAAA,QAA2C,IAAI;CAGrD,CAAA,GAAA,MAAA,iBAAgB;EACd,gBAAgB,KAAK;CACvB,GAAG,CAAC,KAAK,CAAC;CAuDV,OAAO;EACL,WAAA,GAAA,MAAA,cAnDC,GAAG,UAAiB;GAEnB,MAAM,WAAY,MAAM,IAAI,QAAQ,SAAS,MAAM;GACnD,gBAAgB,QAAQ;GAGxB,IAAI,WAAW,SACb,aAAa,WAAW,OAAO;GAGjC,MAAM,wBAAwB;IAE5B,IAAI,MAAM,IAAI,QAQZ,SAAS;KANP,GAAG,MAAM;KACT,QAAQ;MACN,GAAG,MAAM,GAAG;MACZ,OAAO;KACT;IAEoB,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;SAE1C,SAAS,QAAQ;IAInB,QAAQ,IAAI;GACd;GAGA,IAAI,iBAAiB,GACnB,gBAAgB;QAEhB,WAAW,UAAU,WAAW,iBAAiB,aAAa;EAElE,GACA;GAAC;GAAU;GAAe;GAAS;EAAI,CAelB;EACrB,SAAA,GAAA,MAAA,mBAZmC;GAEnC,IAAI,WAAW,SAAS;IACtB,aAAa,WAAW,OAAO;IAC/B,WAAW,UAAU;IACrB,SAAS,YAAY;GACvB;GACA,OAAO;EACT,GAAG;GAAC;GAAU;GAAQ;EAAY,CAIf;EACjB,OAAO;CACT;AACF"}
|
|
@@ -1,2 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.d.ts
|
|
2
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
3
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
4
|
+
debounceDelay?: number;
|
|
5
|
+
/** Field name for triggering validation after debounced value commits */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The onBlur function to call after flushing debounced value */
|
|
8
|
+
onBlur: () => void;
|
|
9
|
+
/** The onChange function to call with debounced value */
|
|
10
|
+
onChange: (...event: any[]) => void;
|
|
11
|
+
/** The field value */
|
|
12
|
+
value: TValue;
|
|
13
|
+
}
|
|
14
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
15
|
+
/** Enhanced onChange function with debouncing */
|
|
16
|
+
onChange: (...event: any[]) => void;
|
|
17
|
+
/** Enhanced onBlur function that flushes current value immediately */
|
|
18
|
+
onBlur: () => void;
|
|
19
|
+
/** The field value that is displayed - updates immediately */
|
|
20
|
+
value: TValue;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
24
|
+
*
|
|
25
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
26
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
27
|
+
* any pending debounced changes are immediately flushed.
|
|
28
|
+
*
|
|
29
|
+
* **Key Features:**
|
|
30
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
31
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
32
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
33
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
34
|
+
*
|
|
35
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
36
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
37
|
+
*
|
|
38
|
+
* @param options Configuration for debounced value handling
|
|
39
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
40
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
41
|
+
* @param options.onChange Function to call with debounced value
|
|
42
|
+
* @param options.value The field value
|
|
43
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* Basic usage with debouncing:
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
49
|
+
* debounceDelay: 300,
|
|
50
|
+
* name: 'fieldName',
|
|
51
|
+
* onBlur: field.onBlur,
|
|
52
|
+
* onChange: field.onChange,
|
|
53
|
+
* value: field.value,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const useInputValueDebounce: <TValue = unknown>({
|
|
58
|
+
debounceDelay,
|
|
59
|
+
name,
|
|
60
|
+
onBlur,
|
|
61
|
+
onChange,
|
|
62
|
+
value
|
|
63
|
+
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce };
|
|
66
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"mappings":";UAIiB,4BAAA;EAAA;EAEf,aAAA;EAF2C;EAI3C,IAAA;EAJ4C;EAM5C,MAAA;EAFA;EAKA,QAAA,MAAc,KAAA;EAAd;EAEA,KAAA,EAAO,MAAM;AAAA;AAAA,UAGE,2BAAA;EAHF;EAMb,QAAA,MAAc,KAAA;EAHC;EAKf,MAAA;EAL0C;EAO1C,KAAA,EAAO,MAAM;AAAA;;;;;;;AAAA;AAsCf;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,qBAAA;EAA2C,aAAA;EAAA,IAAA;EAAA,MAAA;EAAA,QAAA;EAAA;AAAA,GAMrD,4BAAA,CAA6B,MAAA,MAAU,2BAAA,CAA4B,MAAA"}
|
|
@@ -1,2 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.d.ts
|
|
2
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
3
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
4
|
+
debounceDelay?: number;
|
|
5
|
+
/** Field name for triggering validation after debounced value commits */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The onBlur function to call after flushing debounced value */
|
|
8
|
+
onBlur: () => void;
|
|
9
|
+
/** The onChange function to call with debounced value */
|
|
10
|
+
onChange: (...event: any[]) => void;
|
|
11
|
+
/** The field value */
|
|
12
|
+
value: TValue;
|
|
13
|
+
}
|
|
14
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
15
|
+
/** Enhanced onChange function with debouncing */
|
|
16
|
+
onChange: (...event: any[]) => void;
|
|
17
|
+
/** Enhanced onBlur function that flushes current value immediately */
|
|
18
|
+
onBlur: () => void;
|
|
19
|
+
/** The field value that is displayed - updates immediately */
|
|
20
|
+
value: TValue;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
24
|
+
*
|
|
25
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
26
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
27
|
+
* any pending debounced changes are immediately flushed.
|
|
28
|
+
*
|
|
29
|
+
* **Key Features:**
|
|
30
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
31
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
32
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
33
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
34
|
+
*
|
|
35
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
36
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
37
|
+
*
|
|
38
|
+
* @param options Configuration for debounced value handling
|
|
39
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
40
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
41
|
+
* @param options.onChange Function to call with debounced value
|
|
42
|
+
* @param options.value The field value
|
|
43
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* Basic usage with debouncing:
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
49
|
+
* debounceDelay: 300,
|
|
50
|
+
* name: 'fieldName',
|
|
51
|
+
* onBlur: field.onBlur,
|
|
52
|
+
* onChange: field.onChange,
|
|
53
|
+
* value: field.value,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const useInputValueDebounce: <TValue = unknown>({
|
|
58
|
+
debounceDelay,
|
|
59
|
+
name,
|
|
60
|
+
onBlur,
|
|
61
|
+
onChange,
|
|
62
|
+
value
|
|
63
|
+
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
64
|
+
//#endregion
|
|
65
|
+
export { UseInputValueDebounceOptions, UseInputValueDebounceReturn, useInputValueDebounce };
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"mappings":";UAIiB,4BAAA;EAAA;EAEf,aAAA;EAF2C;EAI3C,IAAA;EAJ4C;EAM5C,MAAA;EAFA;EAKA,QAAA,MAAc,KAAA;EAAd;EAEA,KAAA,EAAO,MAAM;AAAA;AAAA,UAGE,2BAAA;EAHF;EAMb,QAAA,MAAc,KAAA;EAHC;EAKf,MAAA;EAL0C;EAO1C,KAAA,EAAO,MAAM;AAAA;;;;;;;AAAA;AAsCf;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,qBAAA;EAA2C,aAAA;EAAA,IAAA;EAAA,MAAA;EAAA,QAAA;EAAA;AAAA,GAMrD,4BAAA,CAA6B,MAAA,MAAU,2BAAA,CAA4B,MAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useFormContext } from "../../useFormContext-
|
|
1
|
+
import { n as useFormContext } from "../../useFormContext-BJqa1FoT.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-
|
|
2
|
+
const require_useInputValueTransform = require("../../useInputValueTransform-P62UUZBl.cjs");
|
|
3
3
|
//#region src/hooks/useInputValueTransform/index.ts
|
|
4
4
|
/* v8 ignore stop */
|
|
5
5
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as useInputValueTransform, n as UseInputValueTransformOptions, r as UseInputValueTransformReturn, t as InputValueTransform } from "../../useInputValueTransform-
|
|
1
|
+
import { i as useInputValueTransform, n as UseInputValueTransformOptions, r as UseInputValueTransformReturn, t as InputValueTransform } from "../../useInputValueTransform-DCXXb2Lp.cjs";
|
|
2
2
|
export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as useInputValueTransform, n as UseInputValueTransformOptions, r as UseInputValueTransformReturn, t as InputValueTransform } from "../../useInputValueTransform-
|
|
1
|
+
import { i as useInputValueTransform, n as UseInputValueTransformOptions, r as UseInputValueTransformReturn, t as InputValueTransform } from "../../useInputValueTransform-DCXXb2Lp.js";
|
|
2
2
|
export { InputValueTransform, UseInputValueTransformOptions, UseInputValueTransformReturn, useInputValueTransform };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_FormContext = require("../../FormContext-
|
|
2
|
+
const require_FormContext = require("../../FormContext-EGH0cVnH.cjs");
|
|
3
3
|
const require_helpers_index = require("../../helpers/index.cjs");
|
|
4
|
-
const require_FieldCopyTestIdButton = require("../../FieldCopyTestIdButton-
|
|
5
|
-
const require_FieldValidationError = require("../../FieldValidationError-
|
|
6
|
-
const require_useController = require("../../useController
|
|
7
|
-
const require_useFormContext = require("../../useFormContext-
|
|
8
|
-
const require_useInputValueTransform = require("../../useInputValueTransform-
|
|
4
|
+
const require_FieldCopyTestIdButton = require("../../FieldCopyTestIdButton-D3D_LmJh.cjs");
|
|
5
|
+
const require_FieldValidationError = require("../../FieldValidationError-CfYKzl7P.cjs");
|
|
6
|
+
const require_useController = require("../../useController-Dbe7ADG6.cjs");
|
|
7
|
+
const require_useFormContext = require("../../useFormContext-kUHonwgu.cjs");
|
|
8
|
+
const require_useInputValueTransform = require("../../useInputValueTransform-P62UUZBl.cjs");
|
|
9
9
|
let react = require("react");
|
|
10
10
|
react = require_FormContext.__toESM(react);
|
|
11
11
|
let _fuf_stack_pixels = require("@fuf-stack/pixels");
|
|
@@ -86,8 +86,8 @@ const useUniformField = (params) => {
|
|
|
86
86
|
const hasValue = !require_helpers_index.isValueEmpty(fieldValue);
|
|
87
87
|
const invalid = (0, _fuf_stack_pixels.useDebounce)(rawInvalid && (isDirty && hasValue || isTouched || submitCount > 0), 200);
|
|
88
88
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
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.
|
|
90
|
-
const errorMessage = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldValidationError.
|
|
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_default, { testId }) : null] }) : null;
|
|
90
|
+
const errorMessage = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldValidationError.FieldValidationError_default, {
|
|
91
91
|
error,
|
|
92
92
|
testId
|
|
93
93
|
});
|
|
@@ -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 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
|
+
{"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,+BAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAIN,MAAM,eAAe,iBAAA,GAAA,kBAAA,KAACC,6BAAAA,8BAAD;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"}
|