@fuf-stack/uniform 1.10.3 → 1.11.0
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 +4 -18
- package/dist/Checkboxes/index.d.cts +2 -11
- package/dist/Checkboxes/index.d.ts +2 -11
- package/dist/Checkboxes/index.js +3 -19
- package/dist/Checkboxes-CGWhnpBp.js +115 -0
- package/dist/Checkboxes-CGWhnpBp.js.map +1 -0
- package/dist/Checkboxes-Ds6bzl6p.cjs +127 -0
- package/dist/Checkboxes-Ds6bzl6p.cjs.map +1 -0
- package/dist/FieldArray/index.cjs +4 -21
- package/dist/FieldArray/index.d.cts +2 -10
- package/dist/FieldArray/index.d.ts +2 -10
- package/dist/FieldArray/index.js +3 -22
- package/dist/FieldArray-BexXN9bO.cjs +515 -0
- package/dist/FieldArray-BexXN9bO.cjs.map +1 -0
- package/dist/FieldArray-D3iUaRLo.js +503 -0
- package/dist/FieldArray-D3iUaRLo.js.map +1 -0
- package/dist/FieldCard/index.cjs +3 -18
- package/dist/FieldCard/index.d.cts +2 -97
- package/dist/FieldCard/index.d.ts +2 -97
- package/dist/FieldCard/index.js +3 -19
- package/dist/FieldCard-mpmErfDK.js +121 -0
- package/dist/FieldCard-mpmErfDK.js.map +1 -0
- package/dist/FieldCard-pP7aniZU.cjs +133 -0
- package/dist/FieldCard-pP7aniZU.cjs.map +1 -0
- package/dist/FieldCopyTestIdButton-AaLwu_8y.cjs +41 -0
- package/dist/FieldCopyTestIdButton-AaLwu_8y.cjs.map +1 -0
- package/dist/FieldCopyTestIdButton-Cx8AXJhO.js +29 -0
- package/dist/FieldCopyTestIdButton-Cx8AXJhO.js.map +1 -0
- package/dist/FieldValidationError-Cq6aI0tE.cjs +65 -0
- package/dist/FieldValidationError-Cq6aI0tE.cjs.map +1 -0
- package/dist/FieldValidationError-D86DPSOH.js +53 -0
- package/dist/FieldValidationError-D86DPSOH.js.map +1 -0
- package/dist/Form/index.cjs +4 -13
- package/dist/Form/index.d.cts +2 -11
- package/dist/Form/index.d.ts +3 -11
- package/dist/Form/index.js +3 -14
- package/dist/Form-CFmCTl60.js +119 -0
- package/dist/Form-CFmCTl60.js.map +1 -0
- package/dist/Form-FvN3SXfF.cjs +130 -0
- package/dist/Form-FvN3SXfF.cjs.map +1 -0
- package/dist/FormContext-C2_WMi_v.d.ts +18 -0
- package/dist/FormContext-C2_WMi_v.d.ts.map +1 -0
- package/dist/FormContext-C3GymQOA.cjs +275 -0
- package/dist/FormContext-C3GymQOA.cjs.map +1 -0
- package/dist/FormContext-CN9n_KdE.js +229 -0
- package/dist/FormContext-CN9n_KdE.js.map +1 -0
- package/dist/FormContext-Dl7KL_wl.d.cts +18 -0
- package/dist/FormContext-Dl7KL_wl.d.cts.map +1 -0
- package/dist/Grid/index.cjs +4 -9
- package/dist/Grid/index.d.cts +2 -8
- package/dist/Grid/index.d.ts +2 -8
- package/dist/Grid/index.js +3 -10
- package/dist/Grid-DEH7Sezi.js +23 -0
- package/dist/Grid-DEH7Sezi.js.map +1 -0
- package/dist/Grid-DG60vYYG.cjs +35 -0
- package/dist/Grid-DG60vYYG.cjs.map +1 -0
- package/dist/Input/index.cjs +4 -19
- package/dist/Input/index.d.cts +2 -11
- package/dist/Input/index.d.ts +2 -11
- package/dist/Input/index.js +3 -20
- package/dist/Input--h5t7Sbl.js +94 -0
- package/dist/Input--h5t7Sbl.js.map +1 -0
- package/dist/Input-DKfFFOpo.cjs +106 -0
- package/dist/Input-DKfFFOpo.cjs.map +1 -0
- package/dist/RadioBoxes/index.cjs +5 -20
- package/dist/RadioBoxes/index.d.cts +2 -10
- package/dist/RadioBoxes/index.d.ts +2 -10
- package/dist/RadioBoxes/index.js +3 -21
- package/dist/RadioBoxes-7qdHj3ti.js +138 -0
- package/dist/RadioBoxes-7qdHj3ti.js.map +1 -0
- package/dist/RadioBoxes-Bd9ahl4i.cjs +156 -0
- package/dist/RadioBoxes-Bd9ahl4i.cjs.map +1 -0
- package/dist/RadioTabs/index.cjs +4 -18
- package/dist/RadioTabs/index.d.cts +2 -10
- package/dist/RadioTabs/index.d.ts +2 -10
- package/dist/RadioTabs/index.js +3 -19
- package/dist/RadioTabs-DXs98jng.js +119 -0
- package/dist/RadioTabs-DXs98jng.js.map +1 -0
- package/dist/RadioTabs-DcEUdW7r.cjs +132 -0
- package/dist/RadioTabs-DcEUdW7r.cjs.map +1 -0
- package/dist/Radios/index.cjs +4 -18
- package/dist/Radios/index.d.cts +2 -9
- package/dist/Radios/index.d.ts +2 -9
- package/dist/Radios/index.js +3 -19
- package/dist/Radios-BIx06mzU.js +75 -0
- package/dist/Radios-BIx06mzU.js.map +1 -0
- package/dist/Radios-CIPNqPzi.cjs +87 -0
- package/dist/Radios-CIPNqPzi.cjs.map +1 -0
- package/dist/Select/index.cjs +4 -19
- package/dist/Select/index.d.cts +2 -11
- package/dist/Select/index.d.ts +2 -11
- package/dist/Select/index.js +3 -20
- package/dist/Select-BsL7qn2v.cjs +246 -0
- package/dist/Select-BsL7qn2v.cjs.map +1 -0
- package/dist/Select-CBjqYDcs.js +233 -0
- package/dist/Select-CBjqYDcs.js.map +1 -0
- package/dist/Slider/index.cjs +4 -18
- package/dist/Slider/index.d.cts +2 -10
- package/dist/Slider/index.d.ts +2 -10
- package/dist/Slider/index.js +3 -19
- package/dist/Slider-BDLbD7d5.cjs +123 -0
- package/dist/Slider-BDLbD7d5.cjs.map +1 -0
- package/dist/Slider-BHjHSoIk.js +111 -0
- package/dist/Slider-BHjHSoIk.js.map +1 -0
- package/dist/SubmitButton/index.cjs +4 -13
- package/dist/SubmitButton/index.d.cts +2 -9
- package/dist/SubmitButton/index.d.ts +2 -9
- package/dist/SubmitButton/index.js +3 -14
- package/dist/SubmitButton-7iOaKzhB.js +34 -0
- package/dist/SubmitButton-7iOaKzhB.js.map +1 -0
- package/dist/SubmitButton-DhtPJuro.cjs +46 -0
- package/dist/SubmitButton-DhtPJuro.cjs.map +1 -0
- package/dist/Switch/index.cjs +4 -18
- package/dist/Switch/index.d.cts +2 -11
- package/dist/Switch/index.d.ts +2 -11
- package/dist/Switch/index.js +3 -19
- package/dist/Switch-DCxAgt_L.js +84 -0
- package/dist/Switch-DCxAgt_L.js.map +1 -0
- package/dist/Switch-Dczzog3v.cjs +96 -0
- package/dist/Switch-Dczzog3v.cjs.map +1 -0
- package/dist/SwitchBox/index.cjs +5 -20
- package/dist/SwitchBox/index.d.cts +2 -11
- package/dist/SwitchBox/index.d.ts +2 -11
- package/dist/SwitchBox/index.js +3 -21
- package/dist/SwitchBox-DPHryDOM.js +156 -0
- package/dist/SwitchBox-DPHryDOM.js.map +1 -0
- package/dist/SwitchBox-DqVmZYId.cjs +174 -0
- package/dist/SwitchBox-DqVmZYId.cjs.map +1 -0
- package/dist/TextArea/index.cjs +4 -19
- package/dist/TextArea/index.d.cts +2 -10
- package/dist/TextArea/index.d.ts +2 -10
- package/dist/TextArea/index.js +3 -20
- package/dist/TextArea-BR6e-Fio.js +64 -0
- package/dist/TextArea-BR6e-Fio.js.map +1 -0
- package/dist/TextArea-CH-F6_ax.cjs +76 -0
- package/dist/TextArea-CH-F6_ax.cjs.map +1 -0
- package/dist/helpers/index.cjs +8 -18
- package/dist/helpers/index.d.cts +2 -132
- package/dist/helpers/index.d.ts +2 -132
- package/dist/helpers/index.js +3 -18
- package/dist/helpers-B-CJOBt3.js +236 -0
- package/dist/helpers-B-CJOBt3.js.map +1 -0
- package/dist/helpers-KTgXi0lA.cjs +272 -0
- package/dist/helpers-KTgXi0lA.cjs.map +1 -0
- package/dist/hooks/useClientValidation/index.cjs +6 -10
- package/dist/hooks/useClientValidation/index.cjs.map +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +2 -147
- package/dist/hooks/useClientValidation/index.d.ts +2 -147
- package/dist/hooks/useClientValidation/index.js +7 -12
- package/dist/hooks/useClientValidation/index.js.map +1 -1
- package/dist/hooks/useController/index.cjs +5 -7
- package/dist/hooks/useController/index.cjs.map +1 -1
- package/dist/hooks/useController/index.d.cts +2 -29
- package/dist/hooks/useController/index.d.ts +3 -29
- package/dist/hooks/useController/index.js +7 -9
- package/dist/hooks/useController/index.js.map +1 -1
- package/dist/hooks/useFormContext/index.cjs +3 -12
- package/dist/hooks/useFormContext/index.d.cts +2 -62
- package/dist/hooks/useFormContext/index.d.ts +4 -62
- package/dist/hooks/useFormContext/index.js +3 -13
- package/dist/hooks/useInput/index.cjs +11 -5
- package/dist/hooks/useInput/index.cjs.map +1 -1
- package/dist/hooks/useInput/index.d.cts +2 -1
- package/dist/hooks/useInput/index.d.ts +2 -1
- package/dist/hooks/useInput/index.js +7 -7
- package/dist/hooks/useInput/index.js.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -7
- package/dist/hooks/useInputValueDebounce/index.d.cts +2 -55
- package/dist/hooks/useInputValueDebounce/index.d.ts +2 -55
- package/dist/hooks/useInputValueDebounce/index.js +3 -8
- package/dist/hooks/useInputValueTransform/index.cjs +5 -5
- package/dist/hooks/useInputValueTransform/index.cjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +2 -102
- package/dist/hooks/useInputValueTransform/index.d.ts +2 -102
- package/dist/hooks/useInputValueTransform/index.js +7 -7
- package/dist/hooks/useInputValueTransform/index.js.map +1 -1
- package/dist/hooks/useUniformField/index.cjs +2 -15
- package/dist/hooks/useUniformField/index.d.cts +2 -98
- package/dist/hooks/useUniformField/index.d.ts +6 -98
- package/dist/hooks/useUniformField/index.js +3 -16
- package/dist/hooks/useUniformFieldArray/index.cjs +2 -17
- package/dist/hooks/useUniformFieldArray/index.d.cts +2 -71
- package/dist/hooks/useUniformFieldArray/index.d.ts +7 -71
- package/dist/hooks/useUniformFieldArray/index.js +3 -18
- package/dist/hooks/useWatchUserChange/index.cjs +5 -8
- package/dist/hooks/useWatchUserChange/index.cjs.map +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +2 -73
- package/dist/hooks/useWatchUserChange/index.d.ts +2 -73
- package/dist/hooks/useWatchUserChange/index.js +7 -10
- package/dist/hooks/useWatchUserChange/index.js.map +1 -1
- package/dist/index-1gPh6Uoh.d.cts +16 -0
- package/dist/index-1gPh6Uoh.d.cts.map +1 -0
- package/dist/index-B3Z8gdjC.d.ts +1 -0
- package/dist/index-B4Wkijem.d.ts +169 -0
- package/dist/index-B4Wkijem.d.ts.map +1 -0
- package/dist/index-B74QlCAy.d.cts +169 -0
- package/dist/index-B74QlCAy.d.cts.map +1 -0
- package/dist/index-BLREDRDJ.d.cts +1 -0
- package/dist/index-BM4XWo1K.d.ts +118 -0
- package/dist/index-BM4XWo1K.d.ts.map +1 -0
- package/dist/index-BMN2XNyT.d.cts +23 -0
- package/dist/index-BMN2XNyT.d.cts.map +1 -0
- package/dist/index-BOI0cy-n.d.cts +118 -0
- package/dist/index-BOI0cy-n.d.cts.map +1 -0
- package/dist/index-BTEsKen4.d.ts +264 -0
- package/dist/index-BTEsKen4.d.ts.map +1 -0
- package/dist/index-BW9EUWZE.d.cts +23 -0
- package/dist/index-BW9EUWZE.d.cts.map +1 -0
- package/dist/index-BXpMZvwA.d.cts +1 -0
- package/dist/index-BYrmFhKl.d.ts +1 -0
- package/dist/index-BaBZGCqS.d.cts +177 -0
- package/dist/index-BaBZGCqS.d.cts.map +1 -0
- package/dist/index-C1fYmoY0.d.ts +123 -0
- package/dist/index-C1fYmoY0.d.ts.map +1 -0
- package/dist/index-C56I3SOi.d.cts +148 -0
- package/dist/index-C56I3SOi.d.cts.map +1 -0
- package/dist/index-CHmS3ri3.d.ts +16 -0
- package/dist/index-CHmS3ri3.d.ts.map +1 -0
- package/dist/index-CI9QBUoM.d.cts +97 -0
- package/dist/index-CI9QBUoM.d.cts.map +1 -0
- package/dist/index-CJNLQVjx.d.ts +1 -0
- package/dist/index-CO-l7RmT.d.cts +181 -0
- package/dist/index-CO-l7RmT.d.cts.map +1 -0
- package/dist/index-CQWoxgWk.d.ts +23 -0
- package/dist/index-CQWoxgWk.d.ts.map +1 -0
- package/dist/index-CVY05bZf.d.ts +39 -0
- package/dist/index-CVY05bZf.d.ts.map +1 -0
- package/dist/index-C_ATGeaX.d.ts +104 -0
- package/dist/index-C_ATGeaX.d.ts.map +1 -0
- package/dist/index-CbAh0Kfo.d.cts +39 -0
- package/dist/index-CbAh0Kfo.d.cts.map +1 -0
- package/dist/index-CqV2Q3da.d.cts +264 -0
- package/dist/index-CqV2Q3da.d.cts.map +1 -0
- package/dist/index-CraZe1qS.d.ts +97 -0
- package/dist/index-CraZe1qS.d.ts.map +1 -0
- package/dist/index-CvA5yKx9.d.ts +177 -0
- package/dist/index-CvA5yKx9.d.ts.map +1 -0
- package/dist/index-CwSIy_W-.d.cts +1 -0
- package/dist/index-CzypMcVS.d.cts +104 -0
- package/dist/index-CzypMcVS.d.cts.map +1 -0
- package/dist/index-D6RB3b5L.d.ts +148 -0
- package/dist/index-D6RB3b5L.d.ts.map +1 -0
- package/dist/index-DA5um0u6.d.cts +123 -0
- package/dist/index-DA5um0u6.d.cts.map +1 -0
- package/dist/index-DHHBSmJb.d.ts +23 -0
- package/dist/index-DHHBSmJb.d.ts.map +1 -0
- package/dist/index-DhMSgdwM.d.ts +156 -0
- package/dist/index-DhMSgdwM.d.ts.map +1 -0
- package/dist/index-Dklb-p_1.d.cts +156 -0
- package/dist/index-Dklb-p_1.d.cts.map +1 -0
- package/dist/index-DpD4MxGD.d.cts +177 -0
- package/dist/index-DpD4MxGD.d.cts.map +1 -0
- package/dist/index-Drl7euco.d.ts +115 -0
- package/dist/index-Drl7euco.d.ts.map +1 -0
- package/dist/index-DzuP5q-2.d.ts +181 -0
- package/dist/index-DzuP5q-2.d.ts.map +1 -0
- package/dist/index-G0IgQWoU.d.cts +134 -0
- package/dist/index-G0IgQWoU.d.cts.map +1 -0
- package/dist/index-RvYO46Vg.d.ts +178 -0
- package/dist/index-RvYO46Vg.d.ts.map +1 -0
- package/dist/index-UjKqRe-8.d.ts +134 -0
- package/dist/index-UjKqRe-8.d.ts.map +1 -0
- package/dist/index-aHcGnXHf.d.ts +44 -0
- package/dist/index-aHcGnXHf.d.ts.map +1 -0
- package/dist/index-iuLEYAix.d.cts +115 -0
- package/dist/index-iuLEYAix.d.cts.map +1 -0
- package/dist/index-jmQP58tO.d.cts +44 -0
- package/dist/index-jmQP58tO.d.cts.map +1 -0
- package/dist/index.cjs +75 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -38
- package/dist/index.d.ts +31 -38
- package/dist/index.js +33 -133
- package/dist/index.js.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.cjs +4 -9
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +2 -7
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +2 -7
- package/dist/partials/FieldCopyTestIdButton/index.js +3 -10
- package/dist/partials/FieldValidationError/index.cjs +4 -9
- package/dist/partials/FieldValidationError/index.d.cts +2 -8
- package/dist/partials/FieldValidationError/index.d.ts +2 -8
- package/dist/partials/FieldValidationError/index.js +3 -10
- package/dist/useClientValidation-BnnscAEe.js +179 -0
- package/dist/useClientValidation-BnnscAEe.js.map +1 -0
- package/dist/useClientValidation-C3Q5UCy9.d.cts +150 -0
- package/dist/useClientValidation-C3Q5UCy9.d.cts.map +1 -0
- package/dist/useClientValidation-CkBtUSco.d.ts +150 -0
- package/dist/useClientValidation-CkBtUSco.d.ts.map +1 -0
- package/dist/useClientValidation-oZd4_ocQ.cjs +191 -0
- package/dist/useClientValidation-oZd4_ocQ.cjs.map +1 -0
- package/dist/useController-BzkCcbSo.cjs +48 -0
- package/dist/useController-BzkCcbSo.cjs.map +1 -0
- package/dist/useController-C_MZLZIp.d.cts +31 -0
- package/dist/useController-C_MZLZIp.d.cts.map +1 -0
- package/dist/useController-CumIERks.js +43 -0
- package/dist/useController-CumIERks.js.map +1 -0
- package/dist/useController-hjpJQf0w.d.ts +31 -0
- package/dist/useController-hjpJQf0w.d.ts.map +1 -0
- package/dist/useFormContext-356X5XAY.js +6 -0
- package/dist/useFormContext-356X5XAY.js.map +1 -0
- package/dist/useFormContext-3AAPT6eZ.d.ts +64 -0
- package/dist/useFormContext-3AAPT6eZ.d.ts.map +1 -0
- package/dist/useFormContext-CWuN-_7P.cjs +134 -0
- package/dist/useFormContext-CWuN-_7P.cjs.map +1 -0
- package/dist/useFormContext-CZh7pv8f.d.cts +64 -0
- package/dist/useFormContext-CZh7pv8f.d.cts.map +1 -0
- package/dist/useFormContext-CkeSOfWD.cjs +6 -0
- package/dist/useFormContext-CkeSOfWD.cjs.map +1 -0
- package/dist/useFormContext-JCm1UR_e.js +123 -0
- package/dist/useFormContext-JCm1UR_e.js.map +1 -0
- package/dist/useInput-DZ6KGBxw.js +3 -0
- package/dist/useInput-IGJqJ2tR.d.ts +2 -0
- package/dist/useInput-NMHJNZ5A.d.cts +2 -0
- package/dist/useInputValueDebounce-B2RzCWty.d.cts +62 -0
- package/dist/useInputValueDebounce-B2RzCWty.d.cts.map +1 -0
- package/dist/useInputValueDebounce-C7_bvNGH.d.ts +62 -0
- package/dist/useInputValueDebounce-C7_bvNGH.d.ts.map +1 -0
- package/dist/useInputValueDebounce-DaH5ONlQ.js +84 -0
- package/dist/useInputValueDebounce-DaH5ONlQ.js.map +1 -0
- package/dist/useInputValueDebounce-tL8maIp8.cjs +90 -0
- package/dist/useInputValueDebounce-tL8maIp8.cjs.map +1 -0
- package/dist/useInputValueTransform-BID-CQ-y.d.cts +107 -0
- package/dist/useInputValueTransform-BID-CQ-y.d.cts.map +1 -0
- package/dist/useInputValueTransform-C-uSW8Y3.cjs +116 -0
- package/dist/useInputValueTransform-C-uSW8Y3.cjs.map +1 -0
- package/dist/useInputValueTransform-D7LfyYRe.d.ts +107 -0
- package/dist/useInputValueTransform-D7LfyYRe.d.ts.map +1 -0
- package/dist/useInputValueTransform-aiIf8lq5.js +110 -0
- package/dist/useInputValueTransform-aiIf8lq5.js.map +1 -0
- package/dist/useUniformField-BMvnRC_r.cjs +136 -0
- package/dist/useUniformField-BMvnRC_r.cjs.map +1 -0
- package/dist/useUniformField-Be3kdnhK.d.cts +98 -0
- package/dist/useUniformField-Be3kdnhK.d.cts.map +1 -0
- package/dist/useUniformField-ClprfrES.js +129 -0
- package/dist/useUniformField-ClprfrES.js.map +1 -0
- package/dist/useUniformField-DDHQ5B11.d.ts +98 -0
- package/dist/useUniformField-DDHQ5B11.d.ts.map +1 -0
- package/dist/useUniformFieldArray-BBFw08qL.d.cts +79 -0
- package/dist/useUniformFieldArray-BBFw08qL.d.cts.map +1 -0
- package/dist/useUniformFieldArray-BhPi3gPv.d.ts +79 -0
- package/dist/useUniformFieldArray-BhPi3gPv.d.ts.map +1 -0
- package/dist/useUniformFieldArray-C-0OXG3N.js +84 -0
- package/dist/useUniformFieldArray-C-0OXG3N.js.map +1 -0
- package/dist/useUniformFieldArray-btjvJdZ6.cjs +90 -0
- package/dist/useUniformFieldArray-btjvJdZ6.cjs.map +1 -0
- package/dist/useWatchUserChange-BAdiqg2q.d.ts +78 -0
- package/dist/useWatchUserChange-BAdiqg2q.d.ts.map +1 -0
- package/dist/useWatchUserChange-C1ezpj0t.js +83 -0
- package/dist/useWatchUserChange-C1ezpj0t.js.map +1 -0
- package/dist/useWatchUserChange-C5dr12By.cjs +89 -0
- package/dist/useWatchUserChange-C5dr12By.cjs.map +1 -0
- package/dist/useWatchUserChange-COVdHmki.d.cts +78 -0
- package/dist/useWatchUserChange-COVdHmki.d.cts.map +1 -0
- package/package.json +73 -100
- package/dist/Checkboxes/index.cjs.map +0 -1
- package/dist/Checkboxes/index.js.map +0 -1
- package/dist/Checkboxes-CBgO9itq.d.cts +0 -171
- package/dist/Checkboxes-CFbsc6zg.d.ts +0 -171
- package/dist/FieldArray/index.cjs.map +0 -1
- package/dist/FieldArray/index.js.map +0 -1
- package/dist/FieldArray-72vn2MG9.d.cts +0 -160
- package/dist/FieldArray-72vn2MG9.d.ts +0 -160
- package/dist/FieldCard/index.cjs.map +0 -1
- package/dist/FieldCard/index.js.map +0 -1
- package/dist/FieldCopyTestIdButton-_TDlmw0L.d.cts +0 -11
- package/dist/FieldCopyTestIdButton-_TDlmw0L.d.ts +0 -11
- package/dist/FieldValidationError-DwtLkGMo.d.cts +0 -17
- package/dist/FieldValidationError-DwtLkGMo.d.ts +0 -17
- package/dist/Form/index.cjs.map +0 -1
- package/dist/Form/index.js.map +0 -1
- package/dist/Form-BZZJPLsi.d.cts +0 -32
- package/dist/Form-zsUjI2yq.d.ts +0 -32
- package/dist/FormContext-9Firwt4k.d.cts +0 -14
- package/dist/FormContext-9Firwt4k.d.ts +0 -14
- package/dist/Grid/index.cjs.map +0 -1
- package/dist/Grid/index.js.map +0 -1
- package/dist/Grid-DF3L9NF3.d.cts +0 -17
- package/dist/Grid-DF3L9NF3.d.ts +0 -17
- package/dist/Input/index.cjs.map +0 -1
- package/dist/Input/index.js.map +0 -1
- package/dist/Input-BGYDOpbo.d.cts +0 -101
- package/dist/Input-__SqMh2n.d.ts +0 -101
- package/dist/RadioBox-DnqCiTR1.d.cts +0 -168
- package/dist/RadioBox-DnqCiTR1.d.ts +0 -168
- package/dist/RadioBoxes/index.cjs.map +0 -1
- package/dist/RadioBoxes/index.js.map +0 -1
- package/dist/RadioTabs/index.cjs.map +0 -1
- package/dist/RadioTabs/index.js.map +0 -1
- package/dist/RadioTabs-DkR5fvl4.d.cts +0 -138
- package/dist/RadioTabs-DkR5fvl4.d.ts +0 -138
- package/dist/Radios/index.cjs.map +0 -1
- package/dist/Radios/index.js.map +0 -1
- package/dist/Radios-lLVlvY_B.d.cts +0 -115
- package/dist/Radios-lLVlvY_B.d.ts +0 -115
- package/dist/Select/index.cjs.map +0 -1
- package/dist/Select/index.js.map +0 -1
- package/dist/Select-DWlnKj5c.d.cts +0 -249
- package/dist/Select-DWlnKj5c.d.ts +0 -249
- package/dist/Slider/index.cjs.map +0 -1
- package/dist/Slider/index.js.map +0 -1
- package/dist/Slider-CxHvafJA.d.cts +0 -155
- package/dist/Slider-CxHvafJA.d.ts +0 -155
- package/dist/SubmitButton/index.cjs.map +0 -1
- package/dist/SubmitButton/index.js.map +0 -1
- package/dist/SubmitButton-DqaxyVpp.d.cts +0 -28
- package/dist/SubmitButton-DqaxyVpp.d.ts +0 -28
- package/dist/Switch/index.cjs.map +0 -1
- package/dist/Switch/index.js.map +0 -1
- package/dist/Switch-B4AuHAMX.d.cts +0 -108
- package/dist/Switch-B4AuHAMX.d.ts +0 -108
- package/dist/SwitchBox/index.cjs.map +0 -1
- package/dist/SwitchBox/index.js.map +0 -1
- package/dist/SwitchBox-q1I7a0NX.d.cts +0 -146
- package/dist/SwitchBox-q1I7a0NX.d.ts +0 -146
- package/dist/TextArea/index.cjs.map +0 -1
- package/dist/TextArea/index.js.map +0 -1
- package/dist/TextArea-CYcFOcun.d.cts +0 -88
- package/dist/TextArea-CYcFOcun.d.ts +0 -88
- package/dist/chunk-264VRHMT.js +0 -105
- package/dist/chunk-264VRHMT.js.map +0 -1
- package/dist/chunk-26VE4IGU.js +0 -68
- package/dist/chunk-26VE4IGU.js.map +0 -1
- package/dist/chunk-2HDXHQOC.js +0 -215
- package/dist/chunk-2HDXHQOC.js.map +0 -1
- package/dist/chunk-2UQCRQEJ.cjs +0 -68
- package/dist/chunk-2UQCRQEJ.cjs.map +0 -1
- package/dist/chunk-36LBVB45.js +0 -1
- package/dist/chunk-36LBVB45.js.map +0 -1
- package/dist/chunk-3JAVQAL5.cjs +0 -1
- package/dist/chunk-3JAVQAL5.cjs.map +0 -1
- package/dist/chunk-3ZQXSGR2.cjs +0 -67
- package/dist/chunk-3ZQXSGR2.cjs.map +0 -1
- package/dist/chunk-4CQWTUQR.js +0 -292
- package/dist/chunk-4CQWTUQR.js.map +0 -1
- package/dist/chunk-4HFPBJ3O.cjs +0 -171
- package/dist/chunk-4HFPBJ3O.cjs.map +0 -1
- package/dist/chunk-4RQJCFM7.js +0 -154
- package/dist/chunk-4RQJCFM7.js.map +0 -1
- package/dist/chunk-555JRYCS.cjs +0 -61
- package/dist/chunk-555JRYCS.cjs.map +0 -1
- package/dist/chunk-55VJM3KD.cjs +0 -118
- package/dist/chunk-55VJM3KD.cjs.map +0 -1
- package/dist/chunk-56TQOKG7.cjs +0 -48
- package/dist/chunk-56TQOKG7.cjs.map +0 -1
- package/dist/chunk-5MTIQ6WD.js +0 -41
- package/dist/chunk-5MTIQ6WD.js.map +0 -1
- package/dist/chunk-6AWHOBNL.cjs +0 -41
- package/dist/chunk-6AWHOBNL.cjs.map +0 -1
- package/dist/chunk-6GN62PBG.cjs +0 -182
- package/dist/chunk-6GN62PBG.cjs.map +0 -1
- package/dist/chunk-7MOAXLQZ.js +0 -103
- package/dist/chunk-7MOAXLQZ.js.map +0 -1
- package/dist/chunk-7OMJ26AT.js +0 -165
- package/dist/chunk-7OMJ26AT.js.map +0 -1
- package/dist/chunk-7ZE7IZ5R.cjs +0 -103
- package/dist/chunk-7ZE7IZ5R.cjs.map +0 -1
- package/dist/chunk-AHJJIANM.js +0 -7
- package/dist/chunk-AHJJIANM.js.map +0 -1
- package/dist/chunk-AQJLKHAE.cjs +0 -277
- package/dist/chunk-AQJLKHAE.cjs.map +0 -1
- package/dist/chunk-B62HKKMS.js +0 -20
- package/dist/chunk-B62HKKMS.js.map +0 -1
- package/dist/chunk-C6WYP35Z.js +0 -219
- package/dist/chunk-C6WYP35Z.js.map +0 -1
- package/dist/chunk-CNTOODUQ.js +0 -48
- package/dist/chunk-CNTOODUQ.js.map +0 -1
- package/dist/chunk-ECUVOZGQ.cjs +0 -148
- package/dist/chunk-ECUVOZGQ.cjs.map +0 -1
- package/dist/chunk-ELYGQTXB.js +0 -47
- package/dist/chunk-ELYGQTXB.js.map +0 -1
- package/dist/chunk-EVASKP6Q.js +0 -148
- package/dist/chunk-EVASKP6Q.js.map +0 -1
- package/dist/chunk-FYN7ZWLW.cjs +0 -115
- package/dist/chunk-FYN7ZWLW.cjs.map +0 -1
- package/dist/chunk-GEC75GNL.js +0 -137
- package/dist/chunk-GEC75GNL.js.map +0 -1
- package/dist/chunk-HEPNEBRF.cjs +0 -26
- package/dist/chunk-HEPNEBRF.cjs.map +0 -1
- package/dist/chunk-IR75YRIZ.js +0 -171
- package/dist/chunk-IR75YRIZ.js.map +0 -1
- package/dist/chunk-IV45K4WU.js +0 -277
- package/dist/chunk-IV45K4WU.js.map +0 -1
- package/dist/chunk-K2V4ULA2.js +0 -61
- package/dist/chunk-K2V4ULA2.js.map +0 -1
- package/dist/chunk-KBKMMDLM.js +0 -118
- package/dist/chunk-KBKMMDLM.js.map +0 -1
- package/dist/chunk-KDNO5YO5.cjs +0 -105
- package/dist/chunk-KDNO5YO5.cjs.map +0 -1
- package/dist/chunk-LEMQGDFE.js +0 -67
- package/dist/chunk-LEMQGDFE.js.map +0 -1
- package/dist/chunk-LO7UKHOS.js +0 -26
- package/dist/chunk-LO7UKHOS.js.map +0 -1
- package/dist/chunk-LWPZZ2AW.cjs +0 -172
- package/dist/chunk-LWPZZ2AW.cjs.map +0 -1
- package/dist/chunk-NG3CJ3UE.js +0 -699
- package/dist/chunk-NG3CJ3UE.js.map +0 -1
- package/dist/chunk-NHEZXA4H.cjs +0 -47
- package/dist/chunk-NHEZXA4H.cjs.map +0 -1
- package/dist/chunk-NTDKZW4E.js +0 -35
- package/dist/chunk-NTDKZW4E.js.map +0 -1
- package/dist/chunk-O2XJNQQK.js +0 -154
- package/dist/chunk-O2XJNQQK.js.map +0 -1
- package/dist/chunk-OE5BOGGX.cjs +0 -35
- package/dist/chunk-OE5BOGGX.cjs.map +0 -1
- package/dist/chunk-OKJWLH7T.cjs +0 -154
- package/dist/chunk-OKJWLH7T.cjs.map +0 -1
- package/dist/chunk-OORASWXL.js +0 -49
- package/dist/chunk-OORASWXL.js.map +0 -1
- package/dist/chunk-OT3A4LEE.cjs +0 -154
- package/dist/chunk-OT3A4LEE.cjs.map +0 -1
- package/dist/chunk-PCTYJUY7.cjs +0 -7
- package/dist/chunk-PCTYJUY7.cjs.map +0 -1
- package/dist/chunk-PRUIH5LI.js +0 -131
- package/dist/chunk-PRUIH5LI.js.map +0 -1
- package/dist/chunk-QLNJZDVF.js +0 -182
- package/dist/chunk-QLNJZDVF.js.map +0 -1
- package/dist/chunk-RVBTLB5G.cjs +0 -131
- package/dist/chunk-RVBTLB5G.cjs.map +0 -1
- package/dist/chunk-SJWL6EMI.js +0 -115
- package/dist/chunk-SJWL6EMI.js.map +0 -1
- package/dist/chunk-SW3NGBCE.cjs +0 -215
- package/dist/chunk-SW3NGBCE.cjs.map +0 -1
- package/dist/chunk-THDHNYP7.cjs +0 -219
- package/dist/chunk-THDHNYP7.cjs.map +0 -1
- package/dist/chunk-TTD3KL6E.cjs +0 -20
- package/dist/chunk-TTD3KL6E.cjs.map +0 -1
- package/dist/chunk-UB7CSOZU.js +0 -172
- package/dist/chunk-UB7CSOZU.js.map +0 -1
- package/dist/chunk-V3M7HL26.cjs +0 -137
- package/dist/chunk-V3M7HL26.cjs.map +0 -1
- package/dist/chunk-WXSISX5Y.cjs +0 -49
- package/dist/chunk-WXSISX5Y.cjs.map +0 -1
- package/dist/chunk-WYM6IAIJ.cjs +0 -292
- package/dist/chunk-WYM6IAIJ.cjs.map +0 -1
- package/dist/chunk-YYR23V5P.cjs +0 -165
- package/dist/chunk-YYR23V5P.cjs.map +0 -1
- package/dist/chunk-Z6QACVK7.cjs +0 -699
- package/dist/chunk-Z6QACVK7.cjs.map +0 -1
- package/dist/helpers/index.cjs.map +0 -1
- package/dist/helpers/index.js.map +0 -1
- package/dist/hooks/useFormContext/index.cjs.map +0 -1
- package/dist/hooks/useFormContext/index.js.map +0 -1
- package/dist/hooks/useInputValueDebounce/index.cjs.map +0 -1
- package/dist/hooks/useInputValueDebounce/index.js.map +0 -1
- package/dist/hooks/useUniformField/index.cjs.map +0 -1
- package/dist/hooks/useUniformField/index.js.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.cjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.js.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/index.js.map +0 -1
- package/dist/partials/FieldValidationError/index.cjs.map +0 -1
- package/dist/partials/FieldValidationError/index.js.map +0 -1
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_FieldValidationError = require('../../FieldValidationError-Cq6aI0tE.cjs');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require('../../chunk-555JRYCS.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.FieldValidationError = _chunkNHEZXA4Hcjs.FieldValidationError_default; exports.default = _chunkNHEZXA4Hcjs.FieldValidationError_default2;
|
|
10
|
-
//# sourceMappingURL=index.cjs.map
|
|
4
|
+
exports.FieldValidationError = require_FieldValidationError.FieldValidationError_default$1;
|
|
5
|
+
exports.default = require_FieldValidationError.FieldValidationError_default;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import 'react/jsx-runtime';
|
|
4
|
-
import 'react-hook-form';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { FieldValidationError, FieldValidationError as default };
|
|
1
|
+
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-BMN2XNyT.cjs";
|
|
2
|
+
export { FieldValidationError, FieldValidationError as default, FieldValidationErrorProps };
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import 'react/jsx-runtime';
|
|
4
|
-
import 'react-hook-form';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { FieldValidationError, FieldValidationError as default };
|
|
1
|
+
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-DHHBSmJb.js";
|
|
2
|
+
export { FieldValidationError, FieldValidationError as default, FieldValidationErrorProps };
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../../chunk-ELYGQTXB.js";
|
|
5
|
-
import "../../chunk-K2V4ULA2.js";
|
|
6
|
-
export {
|
|
7
|
-
FieldValidationError_default as FieldValidationError,
|
|
8
|
-
FieldValidationError_default2 as default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { n as FieldValidationError_default, t as FieldValidationError_default$1 } from "../../FieldValidationError-D86DPSOH.js";
|
|
2
|
+
|
|
3
|
+
export { FieldValidationError_default as FieldValidationError, FieldValidationError_default$1 as default };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { t as flatArrayKey } from "./helpers-B-CJOBt3.js";
|
|
2
|
+
import { n as useFormContext } from "./useFormContext-JCm1UR_e.js";
|
|
3
|
+
import { useEffect, useId } from "react";
|
|
4
|
+
import { array, objectLoose } from "@fuf-stack/veto";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useClientValidation/useClientValidation.ts
|
|
7
|
+
/**
|
|
8
|
+
* Hook for adding dynamic client-side validation to forms.
|
|
9
|
+
*
|
|
10
|
+
* Client validation is used for context-dependent validation rules that require external data
|
|
11
|
+
* (e.g., checking if a username already exists). It complements base validation (passed to Form),
|
|
12
|
+
* which handles static rules like "required", min/max length, format, etc.
|
|
13
|
+
*
|
|
14
|
+
* **Typical pattern:**
|
|
15
|
+
* - Base validation: Static, always-on rules (required, format, length constraints)
|
|
16
|
+
* - Client validation: Dynamic rules based on external data (uniqueness, business logic)
|
|
17
|
+
* - Client schemas should use `.nullish()` to allow empty values (base validation handles "required")
|
|
18
|
+
*
|
|
19
|
+
* Automatically manages validation schema lifecycle: sets schema when data is provided,
|
|
20
|
+
* clears schema when data is null/undefined, and cleans up on unmount. When the client
|
|
21
|
+
* validation schema changes, automatically re-validates all touched fields.
|
|
22
|
+
*
|
|
23
|
+
* @param data - Data to create validation schema from (or null/undefined to clear validation)
|
|
24
|
+
* @param schemaFactory - Function that creates a validation schema from the data. Schemas should typically use `.nullish()`.
|
|
25
|
+
* @param options - Optional configuration object
|
|
26
|
+
* @param options.key - Optional custom key for registration. Useful when multiple instances should share validation (e.g., in field arrays)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Base validation handles "required" and format
|
|
31
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) });
|
|
32
|
+
*
|
|
33
|
+
* // Client validation adds dynamic uniqueness check
|
|
34
|
+
* const { data: teamData } = useTeamQuery(teamId);
|
|
35
|
+
* useClientValidation(teamData, (data) =>
|
|
36
|
+
* vt.objectLoose({
|
|
37
|
+
* username: vt.string()
|
|
38
|
+
* .refine(
|
|
39
|
+
* (value) => !data.existingUsers.includes(value),
|
|
40
|
+
* { message: 'Username already exists' }
|
|
41
|
+
* )
|
|
42
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
43
|
+
* })
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* // Using custom key in a field array to avoid multiple registrations
|
|
50
|
+
* fields.map((field, index) => (
|
|
51
|
+
* useClientValidation(
|
|
52
|
+
* userData,
|
|
53
|
+
* (data) => clientValidationSchemaByName(
|
|
54
|
+
* `items.${index}.name`,
|
|
55
|
+
* vt.string()
|
|
56
|
+
* .refine((val) => !data.forbidden.includes(val), { message: 'Name not allowed' })
|
|
57
|
+
* .nullish()
|
|
58
|
+
* ),
|
|
59
|
+
* { key: 'items-validation' } // All instances share the same key
|
|
60
|
+
* )
|
|
61
|
+
* ));
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
const useClientValidation = (data, schemaFactory, options) => {
|
|
65
|
+
const { formState: { touchedFields }, validation: { setClientValidationSchema }, trigger } = useFormContext();
|
|
66
|
+
const autoGeneratedKey = useId();
|
|
67
|
+
const key = options?.key ?? autoGeneratedKey;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (data != null) setClientValidationSchema(key, schemaFactory(data));
|
|
70
|
+
else setClientValidationSchema(key, null);
|
|
71
|
+
const touchedFieldNames = Object.keys(touchedFields);
|
|
72
|
+
if (touchedFieldNames.length > 0) setTimeout(async () => {
|
|
73
|
+
return trigger(touchedFieldNames);
|
|
74
|
+
}, 1);
|
|
75
|
+
return () => {
|
|
76
|
+
setClientValidationSchema(key, null);
|
|
77
|
+
};
|
|
78
|
+
}, [JSON.stringify(data), key]);
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Helper function to create a veto looseObject schema for a single field with nested path support.
|
|
82
|
+
*
|
|
83
|
+
* Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
|
|
84
|
+
* All intermediate objects and arrays are marked as optional to allow partial data structures.
|
|
85
|
+
* Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
|
|
86
|
+
* Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
|
|
87
|
+
*
|
|
88
|
+
* **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
|
|
89
|
+
* - Base validation (passed to Form) handles "required" constraints
|
|
90
|
+
* - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
|
|
91
|
+
* - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
|
|
92
|
+
* - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
|
|
93
|
+
*
|
|
94
|
+
* This pattern ensures client validation only validates non-empty values, while base validation
|
|
95
|
+
* enforces required fields and basic constraints (min length, format, etc.).
|
|
96
|
+
*
|
|
97
|
+
* @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
|
|
98
|
+
* @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
|
|
99
|
+
* @returns A nested loose object schema matching the field path structure with proper type inference
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* // Typical usage: base validation handles "required", client validation adds dynamic rules
|
|
104
|
+
* // Base validation (in Form component)
|
|
105
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
|
|
106
|
+
*
|
|
107
|
+
* // Client validation (dynamic check for existing usernames)
|
|
108
|
+
* const { data: userData } = useUserQuery(userId);
|
|
109
|
+
* useClientValidation(userData, (data) =>
|
|
110
|
+
* clientValidationSchemaByName(
|
|
111
|
+
* 'username',
|
|
112
|
+
* vt.string()
|
|
113
|
+
* .refine(
|
|
114
|
+
* (value) => !data.existingUsernames.includes(value),
|
|
115
|
+
* { message: 'Username already taken' }
|
|
116
|
+
* )
|
|
117
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
118
|
+
* )
|
|
119
|
+
* );
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* // Nested field path with dynamic validation
|
|
125
|
+
* clientValidationSchemaByName(
|
|
126
|
+
* 'user.profile.email',
|
|
127
|
+
* vt.string()
|
|
128
|
+
* .refine(
|
|
129
|
+
* (value) => !reservedEmails.includes(value),
|
|
130
|
+
* { message: 'This email is reserved' }
|
|
131
|
+
* )
|
|
132
|
+
* .nullish()
|
|
133
|
+
* )
|
|
134
|
+
* // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```tsx
|
|
139
|
+
* // Array of objects with dynamic validation
|
|
140
|
+
* clientValidationSchemaByName(
|
|
141
|
+
* 'items.0.tag',
|
|
142
|
+
* vt.string()
|
|
143
|
+
* .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
|
|
144
|
+
* .nullish()
|
|
145
|
+
* )
|
|
146
|
+
* // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```tsx
|
|
151
|
+
* // Flat array (array of primitives) with dynamic validation
|
|
152
|
+
* clientValidationSchemaByName(
|
|
153
|
+
* 'tags.0.__FLAT__',
|
|
154
|
+
* vt.string()
|
|
155
|
+
* .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
|
|
156
|
+
* .nullish()
|
|
157
|
+
* )
|
|
158
|
+
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
const clientValidationSchemaByName = (name, fieldSchema) => {
|
|
162
|
+
const segments = name.split(".");
|
|
163
|
+
let schema = fieldSchema;
|
|
164
|
+
for (let i = segments.length - 1; i >= 0; i -= 1) {
|
|
165
|
+
const segment = segments[i];
|
|
166
|
+
const isNumeric = /^\d+$/.test(segment);
|
|
167
|
+
if (segment === flatArrayKey) continue;
|
|
168
|
+
if (isNumeric) schema = array(schema).optional();
|
|
169
|
+
else {
|
|
170
|
+
const obj = objectLoose({ [segment]: schema });
|
|
171
|
+
schema = i > 0 ? obj.optional() : obj;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return schema;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
export { useClientValidation as n, clientValidationSchemaByName as t };
|
|
179
|
+
//# sourceMappingURL=useClientValidation-BnnscAEe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientValidation-BnnscAEe.js","names":["schema: VetoTypeAny"],"sources":["../src/hooks/useClientValidation/useClientValidation.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,uBACX,MACA,eACA,YACS;CACT,MAAM,EACJ,WAAW,EAAE,iBACb,YAAY,EAAE,6BACd,YACE,gBAAgB;CAGpB,MAAM,mBAAmB,OAAO;CAChC,MAAM,MAAM,SAAS,OAAO;AAO5B,iBAAgB;AAEd,MAAI,QAAQ,KAEV,2BAA0B,KADD,cAAc,KAAK,CACI;MAGhD,2BAA0B,KAAK,KAAK;EAItC,MAAM,oBAAoB,OAAO,KAAK,cAAc;AACpD,MAAI,kBAAkB,SAAS,EAG7B,YAAW,YAAY;AACrB,UAAO,QAAQ,kBAAkB;KAChC,EAAE;AAIP,eAAa;AACX,6BAA0B,KAAK,KAAK;;IAIrC,CA7Bc,KAAK,UAAU,KAAK,EA6BvB,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFrB,MAAa,gCACX,MACA,gBACG;CACH,MAAM,WAAW,KAAK,MAAM,IAAI;CAGhC,IAAIA,SAAsB;AAG1B,MAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;EAChD,MAAM,UAAU,SAAS;EAEzB,MAAM,YAAY,QAAQ,KAAK,QAAQ;AAGvC,MAFuB,YAAY,aAMjC;AAGF,MAAI,UAEF,UAAS,MAAM,OAAO,CAAC,UAAU;OAC5B;GAGL,MAAM,MAAM,YAAY,GACrB,UAAU,QACZ,CAAC;AACF,YAAS,IAAI,IAAI,IAAI,UAAU,GAAG;;;AAItC,QAAO"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { VetoTypeAny } from "@fuf-stack/veto";
|
|
2
|
+
import * as zod0 from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useClientValidation/useClientValidation.d.ts
|
|
5
|
+
|
|
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
|
+
declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny, options?: {
|
|
64
|
+
key?: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Helper function to create a veto looseObject schema for a single field with nested path support.
|
|
68
|
+
*
|
|
69
|
+
* Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
|
|
70
|
+
* All intermediate objects and arrays are marked as optional to allow partial data structures.
|
|
71
|
+
* Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
|
|
72
|
+
* Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
|
|
73
|
+
*
|
|
74
|
+
* **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
|
|
75
|
+
* - Base validation (passed to Form) handles "required" constraints
|
|
76
|
+
* - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
|
|
77
|
+
* - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
|
|
78
|
+
* - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
|
|
79
|
+
*
|
|
80
|
+
* This pattern ensures client validation only validates non-empty values, while base validation
|
|
81
|
+
* enforces required fields and basic constraints (min length, format, etc.).
|
|
82
|
+
*
|
|
83
|
+
* @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
|
|
84
|
+
* @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
|
|
85
|
+
* @returns A nested loose object schema matching the field path structure with proper type inference
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* // Typical usage: base validation handles "required", client validation adds dynamic rules
|
|
90
|
+
* // Base validation (in Form component)
|
|
91
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
|
|
92
|
+
*
|
|
93
|
+
* // Client validation (dynamic check for existing usernames)
|
|
94
|
+
* const { data: userData } = useUserQuery(userId);
|
|
95
|
+
* useClientValidation(userData, (data) =>
|
|
96
|
+
* clientValidationSchemaByName(
|
|
97
|
+
* 'username',
|
|
98
|
+
* vt.string()
|
|
99
|
+
* .refine(
|
|
100
|
+
* (value) => !data.existingUsernames.includes(value),
|
|
101
|
+
* { message: 'Username already taken' }
|
|
102
|
+
* )
|
|
103
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
104
|
+
* )
|
|
105
|
+
* );
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* // Nested field path with dynamic validation
|
|
111
|
+
* clientValidationSchemaByName(
|
|
112
|
+
* 'user.profile.email',
|
|
113
|
+
* vt.string()
|
|
114
|
+
* .refine(
|
|
115
|
+
* (value) => !reservedEmails.includes(value),
|
|
116
|
+
* { message: 'This email is reserved' }
|
|
117
|
+
* )
|
|
118
|
+
* .nullish()
|
|
119
|
+
* )
|
|
120
|
+
* // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```tsx
|
|
125
|
+
* // Array of objects with dynamic validation
|
|
126
|
+
* clientValidationSchemaByName(
|
|
127
|
+
* 'items.0.tag',
|
|
128
|
+
* vt.string()
|
|
129
|
+
* .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
|
|
130
|
+
* .nullish()
|
|
131
|
+
* )
|
|
132
|
+
* // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```tsx
|
|
137
|
+
* // Flat array (array of primitives) with dynamic validation
|
|
138
|
+
* clientValidationSchemaByName(
|
|
139
|
+
* 'tags.0.__FLAT__',
|
|
140
|
+
* vt.string()
|
|
141
|
+
* .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
|
|
142
|
+
* .nullish()
|
|
143
|
+
* )
|
|
144
|
+
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => zod0.ZodTypeAny;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { useClientValidation as n, clientValidationSchemaByName as t };
|
|
150
|
+
//# sourceMappingURL=useClientValidation-C3Q5UCy9.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientValidation-C3Q5UCy9.d.cts","names":[],"sources":["../src/hooks/useClientValidation/useClientValidation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAkEA;;;;;AAkIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAlIa,6CACL,gDACgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgIrB,yCAA0C,wCAExC,MAAC,IAAA,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { VetoTypeAny } from "@fuf-stack/veto";
|
|
2
|
+
import * as zod0 from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useClientValidation/useClientValidation.d.ts
|
|
5
|
+
|
|
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
|
+
declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny, options?: {
|
|
64
|
+
key?: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Helper function to create a veto looseObject schema for a single field with nested path support.
|
|
68
|
+
*
|
|
69
|
+
* Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
|
|
70
|
+
* All intermediate objects and arrays are marked as optional to allow partial data structures.
|
|
71
|
+
* Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
|
|
72
|
+
* Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
|
|
73
|
+
*
|
|
74
|
+
* **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
|
|
75
|
+
* - Base validation (passed to Form) handles "required" constraints
|
|
76
|
+
* - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
|
|
77
|
+
* - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
|
|
78
|
+
* - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
|
|
79
|
+
*
|
|
80
|
+
* This pattern ensures client validation only validates non-empty values, while base validation
|
|
81
|
+
* enforces required fields and basic constraints (min length, format, etc.).
|
|
82
|
+
*
|
|
83
|
+
* @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
|
|
84
|
+
* @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
|
|
85
|
+
* @returns A nested loose object schema matching the field path structure with proper type inference
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* // Typical usage: base validation handles "required", client validation adds dynamic rules
|
|
90
|
+
* // Base validation (in Form component)
|
|
91
|
+
* const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
|
|
92
|
+
*
|
|
93
|
+
* // Client validation (dynamic check for existing usernames)
|
|
94
|
+
* const { data: userData } = useUserQuery(userId);
|
|
95
|
+
* useClientValidation(userData, (data) =>
|
|
96
|
+
* clientValidationSchemaByName(
|
|
97
|
+
* 'username',
|
|
98
|
+
* vt.string()
|
|
99
|
+
* .refine(
|
|
100
|
+
* (value) => !data.existingUsernames.includes(value),
|
|
101
|
+
* { message: 'Username already taken' }
|
|
102
|
+
* )
|
|
103
|
+
* .nullish() // Allow empty - base validation handles "required"
|
|
104
|
+
* )
|
|
105
|
+
* );
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* // Nested field path with dynamic validation
|
|
111
|
+
* clientValidationSchemaByName(
|
|
112
|
+
* 'user.profile.email',
|
|
113
|
+
* vt.string()
|
|
114
|
+
* .refine(
|
|
115
|
+
* (value) => !reservedEmails.includes(value),
|
|
116
|
+
* { message: 'This email is reserved' }
|
|
117
|
+
* )
|
|
118
|
+
* .nullish()
|
|
119
|
+
* )
|
|
120
|
+
* // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```tsx
|
|
125
|
+
* // Array of objects with dynamic validation
|
|
126
|
+
* clientValidationSchemaByName(
|
|
127
|
+
* 'items.0.tag',
|
|
128
|
+
* vt.string()
|
|
129
|
+
* .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
|
|
130
|
+
* .nullish()
|
|
131
|
+
* )
|
|
132
|
+
* // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```tsx
|
|
137
|
+
* // Flat array (array of primitives) with dynamic validation
|
|
138
|
+
* clientValidationSchemaByName(
|
|
139
|
+
* 'tags.0.__FLAT__',
|
|
140
|
+
* vt.string()
|
|
141
|
+
* .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
|
|
142
|
+
* .nullish()
|
|
143
|
+
* )
|
|
144
|
+
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => zod0.ZodTypeAny;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { useClientValidation as n, clientValidationSchemaByName as t };
|
|
150
|
+
//# sourceMappingURL=useClientValidation-CkBtUSco.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientValidation-CkBtUSco.d.ts","names":[],"sources":["../src/hooks/useClientValidation/useClientValidation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAkEA;;;;;AAkIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAlIa,6CACL,gDACgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgIrB,yCAA0C,wCAExC,MAAC,IAAA,CAAA"}
|