@fuf-stack/uniform 1.11.0 → 1.11.2
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 +1 -1
- package/dist/Checkboxes/index.d.cts +1 -1
- package/dist/Checkboxes/index.d.ts +1 -1
- package/dist/Checkboxes/index.js +1 -1
- package/dist/{Checkboxes-CGWhnpBp.js → Checkboxes-BY4UK0Xf.js} +6 -6
- package/dist/Checkboxes-BY4UK0Xf.js.map +1 -0
- package/dist/{Checkboxes-Ds6bzl6p.cjs → Checkboxes-DgCK-Wq-.cjs} +18 -18
- package/dist/Checkboxes-DgCK-Wq-.cjs.map +1 -0
- package/dist/FieldArray/index.cjs +1 -1
- package/dist/FieldArray/index.d.cts +1 -1
- package/dist/FieldArray/index.d.ts +1 -1
- package/dist/FieldArray/index.js +1 -1
- package/dist/{FieldArray-D3iUaRLo.js → FieldArray-CDLaGvNj.js} +8 -8
- package/dist/FieldArray-CDLaGvNj.js.map +1 -0
- package/dist/{FieldArray-BexXN9bO.cjs → FieldArray-DBsyUQkU.cjs} +49 -49
- package/dist/FieldArray-DBsyUQkU.cjs.map +1 -0
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/FieldCard/index.d.cts +1 -1
- package/dist/FieldCard/index.d.ts +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/{FieldCard-mpmErfDK.js → FieldCard-C1MCSbPW.js} +3 -3
- package/dist/{FieldCard-mpmErfDK.js.map → FieldCard-C1MCSbPW.js.map} +1 -1
- package/dist/{FieldCard-pP7aniZU.cjs → FieldCard-NKF358fO.cjs} +13 -13
- package/dist/{FieldCard-pP7aniZU.cjs.map → FieldCard-NKF358fO.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs → FieldCopyTestIdButton-BSYcSo2o.cjs} +10 -10
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs.map → FieldCopyTestIdButton-BSYcSo2o.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js → FieldCopyTestIdButton-DWPCDJ-s.js} +4 -4
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js.map → FieldCopyTestIdButton-DWPCDJ-s.js.map} +1 -1
- package/dist/{FieldValidationError-D86DPSOH.js → FieldValidationError-1hiDEFew.js} +4 -4
- package/dist/{FieldValidationError-D86DPSOH.js.map → FieldValidationError-1hiDEFew.js.map} +1 -1
- package/dist/{FieldValidationError-Cq6aI0tE.cjs → FieldValidationError-CE8R8qry.cjs} +13 -13
- package/dist/{FieldValidationError-Cq6aI0tE.cjs.map → FieldValidationError-CE8R8qry.cjs.map} +1 -1
- package/dist/Form/index.cjs +1 -1
- package/dist/Form/index.d.ts +1 -1
- package/dist/Form/index.js +1 -1
- package/dist/{Form-FvN3SXfF.cjs → Form-BsD69fql.cjs} +19 -19
- package/dist/{Form-FvN3SXfF.cjs.map → Form-BsD69fql.cjs.map} +1 -1
- package/dist/{Form-CFmCTl60.js → Form-DRNEwHsi.js} +4 -4
- package/dist/{Form-CFmCTl60.js.map → Form-DRNEwHsi.js.map} +1 -1
- package/dist/{FormContext-C3GymQOA.cjs → FormContext-Bb6d8hdG.cjs} +8 -8
- package/dist/FormContext-Bb6d8hdG.cjs.map +1 -0
- package/dist/FormContext-CN9n_KdE.js.map +1 -1
- package/dist/Grid/index.cjs +1 -1
- package/dist/Grid/index.d.cts +1 -1
- package/dist/Grid/index.d.ts +1 -1
- package/dist/Grid/index.js +1 -1
- package/dist/{Grid-DG60vYYG.cjs → Grid-D84e76CE.cjs} +8 -8
- package/dist/{Grid-DG60vYYG.cjs.map → Grid-D84e76CE.cjs.map} +1 -1
- package/dist/{Grid-DEH7Sezi.js → Grid-LRjQlZms.js} +4 -4
- package/dist/{Grid-DEH7Sezi.js.map → Grid-LRjQlZms.js.map} +1 -1
- package/dist/Input/index.cjs +1 -1
- package/dist/Input/index.d.cts +1 -1
- package/dist/Input/index.d.ts +1 -1
- package/dist/Input/index.js +1 -1
- package/dist/{Input--h5t7Sbl.js → Input-DXMWGTBh.js} +5 -5
- package/dist/Input-DXMWGTBh.js.map +1 -0
- package/dist/{Input-DKfFFOpo.cjs → Input-DeTpxiK_.cjs} +15 -15
- package/dist/Input-DeTpxiK_.cjs.map +1 -0
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.d.cts +1 -1
- package/dist/RadioBoxes/index.d.ts +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/{RadioBoxes-7qdHj3ti.js → RadioBoxes-BEln4a-B.js} +5 -5
- package/dist/RadioBoxes-BEln4a-B.js.map +1 -0
- package/dist/{RadioBoxes-Bd9ahl4i.cjs → RadioBoxes-gsQGqQCd.cjs} +22 -22
- package/dist/RadioBoxes-gsQGqQCd.cjs.map +1 -0
- package/dist/RadioTabs/index.cjs +1 -1
- package/dist/RadioTabs/index.d.cts +1 -1
- package/dist/RadioTabs/index.d.ts +1 -1
- package/dist/RadioTabs/index.js +1 -1
- package/dist/{RadioTabs-DcEUdW7r.cjs → RadioTabs-BYpP0tKA.cjs} +18 -18
- package/dist/RadioTabs-BYpP0tKA.cjs.map +1 -0
- package/dist/{RadioTabs-DXs98jng.js → RadioTabs-DLr9QiXI.js} +5 -5
- package/dist/RadioTabs-DLr9QiXI.js.map +1 -0
- package/dist/Radios/index.cjs +1 -1
- package/dist/Radios/index.d.cts +1 -1
- package/dist/Radios/index.d.ts +1 -1
- package/dist/Radios/index.js +1 -1
- package/dist/{Radios-CIPNqPzi.cjs → Radios-BCOfnTke.cjs} +14 -14
- package/dist/{Radios-CIPNqPzi.cjs.map → Radios-BCOfnTke.cjs.map} +1 -1
- package/dist/{Radios-BIx06mzU.js → Radios-DCXI2kMf.js} +5 -5
- package/dist/{Radios-BIx06mzU.js.map → Radios-DCXI2kMf.js.map} +1 -1
- package/dist/Select/index.cjs +1 -1
- package/dist/Select/index.d.cts +1 -1
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/{Select-CBjqYDcs.js → Select-CyfEmWiD.js} +5 -5
- package/dist/Select-CyfEmWiD.js.map +1 -0
- package/dist/{Select-BsL7qn2v.cjs → Select-KnPGOO27.cjs} +19 -19
- package/dist/Select-KnPGOO27.cjs.map +1 -0
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.d.cts +1 -1
- package/dist/Slider/index.d.ts +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-BDLbD7d5.cjs → Slider-C7xxYPgR.cjs} +15 -15
- package/dist/{Slider-BDLbD7d5.cjs.map → Slider-C7xxYPgR.cjs.map} +1 -1
- package/dist/{Slider-BHjHSoIk.js → Slider-Dlhb-9hC.js} +5 -5
- package/dist/{Slider-BHjHSoIk.js.map → Slider-Dlhb-9hC.js.map} +1 -1
- package/dist/SubmitButton/index.cjs +1 -1
- package/dist/SubmitButton/index.d.cts +1 -1
- package/dist/SubmitButton/index.d.ts +1 -1
- package/dist/SubmitButton/index.js +1 -1
- package/dist/{SubmitButton-7iOaKzhB.js → SubmitButton-C5f6j0N4.js} +4 -4
- package/dist/{SubmitButton-7iOaKzhB.js.map → SubmitButton-C5f6j0N4.js.map} +1 -1
- package/dist/{SubmitButton-DhtPJuro.cjs → SubmitButton-CUBItcBn.cjs} +12 -12
- package/dist/{SubmitButton-DhtPJuro.cjs.map → SubmitButton-CUBItcBn.cjs.map} +1 -1
- package/dist/Switch/index.cjs +1 -1
- package/dist/Switch/index.d.cts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DCxAgt_L.js → Switch--m02Xcq8.js} +5 -5
- package/dist/{Switch-DCxAgt_L.js.map → Switch--m02Xcq8.js.map} +1 -1
- package/dist/{Switch-Dczzog3v.cjs → Switch-6LyeZHJh.cjs} +15 -15
- package/dist/{Switch-Dczzog3v.cjs.map → Switch-6LyeZHJh.cjs.map} +1 -1
- package/dist/SwitchBox/index.cjs +1 -1
- package/dist/SwitchBox/index.d.cts +1 -1
- package/dist/SwitchBox/index.d.ts +1 -1
- package/dist/SwitchBox/index.js +1 -1
- package/dist/{SwitchBox-DqVmZYId.cjs → SwitchBox-CtGiQdys.cjs} +19 -19
- package/dist/{SwitchBox-DqVmZYId.cjs.map → SwitchBox-CtGiQdys.cjs.map} +1 -1
- package/dist/{SwitchBox-DPHryDOM.js → SwitchBox-D0-e-pbM.js} +5 -5
- package/dist/{SwitchBox-DPHryDOM.js.map → SwitchBox-D0-e-pbM.js.map} +1 -1
- package/dist/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.d.cts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BR6e-Fio.js → TextArea-BiSnvJ69.js} +5 -5
- package/dist/{TextArea-BR6e-Fio.js.map → TextArea-BiSnvJ69.js.map} +1 -1
- package/dist/{TextArea-CH-F6_ax.cjs → TextArea-PtdSABZS.cjs} +13 -13
- package/dist/{TextArea-CH-F6_ax.cjs.map → TextArea-PtdSABZS.cjs.map} +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers-B-CJOBt3.js.map +1 -1
- package/dist/{helpers-KTgXi0lA.cjs → helpers-B84E9vHd.cjs} +4 -4
- package/dist/helpers-B84E9vHd.cjs.map +1 -0
- package/dist/hooks/useClientValidation/index.cjs +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +1 -1
- package/dist/hooks/useClientValidation/index.d.ts +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.ts +0 -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 +2 -2
- package/dist/hooks/useInput/index.cjs +3 -3
- package/dist/hooks/useInput/index.d.cts +1 -1
- package/dist/hooks/useInput/index.d.ts +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +3 -3
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.ts +24 -4
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/{index-CzypMcVS.d.cts → index--E2ZsMya.d.ts} +6 -6
- package/dist/{index-C_ATGeaX.d.ts.map → index--E2ZsMya.d.ts.map} +1 -1
- package/dist/{index-C56I3SOi.d.cts → index-BITJ-CZL.d.cts} +4 -4
- package/dist/{index-C56I3SOi.d.cts.map → index-BITJ-CZL.d.cts.map} +1 -1
- package/dist/{index-CVY05bZf.d.ts → index-BL0DnIzh.d.ts} +3 -3
- package/dist/{index-CVY05bZf.d.ts.map → index-BL0DnIzh.d.ts.map} +1 -1
- package/dist/{index-CHmS3ri3.d.ts → index-BQDEnYTq.d.ts} +1 -1
- package/dist/{index-CHmS3ri3.d.ts.map → index-BQDEnYTq.d.ts.map} +1 -1
- package/dist/{index-DHHBSmJb.d.ts → index-BTTo_ufh.d.ts} +1 -1
- package/dist/{index-DHHBSmJb.d.ts.map → index-BTTo_ufh.d.ts.map} +1 -1
- package/dist/{index-B74QlCAy.d.cts → index-BWNJdLDV.d.ts} +48 -48
- package/dist/{index-B4Wkijem.d.ts.map → index-BWNJdLDV.d.ts.map} +1 -1
- package/dist/{index-CraZe1qS.d.ts → index-Bj_lpc5r.d.cts} +21 -21
- package/dist/{index-CI9QBUoM.d.cts.map → index-Bj_lpc5r.d.cts.map} +1 -1
- package/dist/{index-B4Wkijem.d.ts → index-Bo_n9sse.d.cts} +47 -47
- package/dist/{index-B74QlCAy.d.cts.map → index-Bo_n9sse.d.cts.map} +1 -1
- package/dist/{index-iuLEYAix.d.cts → index-BxA_pJWn.d.cts} +21 -21
- package/dist/{index-iuLEYAix.d.cts.map → index-BxA_pJWn.d.cts.map} +1 -1
- package/dist/{index-Drl7euco.d.ts → index-C-2nxT8D.d.ts} +21 -21
- package/dist/{index-Drl7euco.d.ts.map → index-C-2nxT8D.d.ts.map} +1 -1
- package/dist/{index-C1fYmoY0.d.ts → index-C0L7GvgN.d.cts} +34 -34
- package/dist/index-C0L7GvgN.d.cts.map +1 -0
- package/dist/{index-DzuP5q-2.d.ts → index-C1PUx1tH.d.ts} +6 -6
- package/dist/index-C1PUx1tH.d.ts.map +1 -0
- package/dist/index-CADnFWHq.d.ts +264 -0
- package/dist/{index-BTEsKen4.d.ts.map → index-CADnFWHq.d.ts.map} +1 -1
- package/dist/{index-BM4XWo1K.d.ts → index-CGnr_e53.d.ts} +36 -36
- package/dist/{index-BM4XWo1K.d.ts.map → index-CGnr_e53.d.ts.map} +1 -1
- package/dist/{index-DhMSgdwM.d.ts → index-CSBE6Et0.d.cts} +6 -6
- package/dist/{index-Dklb-p_1.d.cts.map → index-CSBE6Et0.d.cts.map} +1 -1
- package/dist/{index-D6RB3b5L.d.ts → index-CVnn6mEI.d.ts} +4 -4
- package/dist/{index-D6RB3b5L.d.ts.map → index-CVnn6mEI.d.ts.map} +1 -1
- package/dist/{index-BMN2XNyT.d.cts → index-CYdvpGJF.d.cts} +3 -3
- package/dist/{index-BMN2XNyT.d.cts.map → index-CYdvpGJF.d.cts.map} +1 -1
- package/dist/{index-CbAh0Kfo.d.cts → index-Cb0AgRRa.d.cts} +3 -3
- package/dist/{index-CbAh0Kfo.d.cts.map → index-Cb0AgRRa.d.cts.map} +1 -1
- package/dist/{index-DA5um0u6.d.cts → index-D38wOL-M.d.ts} +34 -34
- package/dist/index-D38wOL-M.d.ts.map +1 -0
- package/dist/{index-DpD4MxGD.d.cts → index-DG9C0kHA.d.ts} +35 -34
- package/dist/{index-RvYO46Vg.d.ts.map → index-DG9C0kHA.d.ts.map} +1 -1
- package/dist/{index-RvYO46Vg.d.ts → index-DNkZrb7P.d.cts} +35 -36
- package/dist/{index-DpD4MxGD.d.cts.map → index-DNkZrb7P.d.cts.map} +1 -1
- package/dist/{index-C_ATGeaX.d.ts → index-DRij_w43.d.cts} +5 -5
- package/dist/{index-CzypMcVS.d.cts.map → index-DRij_w43.d.cts.map} +1 -1
- package/dist/{index-Dklb-p_1.d.cts → index-DmMenZfj.d.ts} +5 -5
- package/dist/{index-DhMSgdwM.d.ts.map → index-DmMenZfj.d.ts.map} +1 -1
- package/dist/{index-CI9QBUoM.d.cts → index-DnzC0GCS.d.ts} +3 -3
- package/dist/index-DnzC0GCS.d.ts.map +1 -0
- package/dist/{index-BOI0cy-n.d.cts → index-DoS0lVRe.d.cts} +34 -34
- package/dist/index-DoS0lVRe.d.cts.map +1 -0
- package/dist/{index-aHcGnXHf.d.ts → index-DvB46QAb.d.ts} +3 -3
- package/dist/{index-aHcGnXHf.d.ts.map → index-DvB46QAb.d.ts.map} +1 -1
- package/dist/{index-BW9EUWZE.d.cts → index-DxdaxM3o.d.cts} +3 -3
- package/dist/{index-BW9EUWZE.d.cts.map → index-DxdaxM3o.d.cts.map} +1 -1
- package/dist/{index-CQWoxgWk.d.ts → index-Edx7MxXu.d.ts} +3 -3
- package/dist/{index-CQWoxgWk.d.ts.map → index-Edx7MxXu.d.ts.map} +1 -1
- package/dist/{index-BaBZGCqS.d.cts → index-F11geOHD.d.ts} +6 -6
- package/dist/{index-CvA5yKx9.d.ts.map → index-F11geOHD.d.ts.map} +1 -1
- package/dist/{index-1gPh6Uoh.d.cts → index-PU5WNOH9.d.cts} +3 -3
- package/dist/{index-1gPh6Uoh.d.cts.map → index-PU5WNOH9.d.cts.map} +1 -1
- package/dist/{index-CO-l7RmT.d.cts → index-WogV9uVV.d.cts} +6 -6
- package/dist/{index-CO-l7RmT.d.cts.map → index-WogV9uVV.d.cts.map} +1 -1
- package/dist/{index-CvA5yKx9.d.ts → index-oyX8xu0F.d.cts} +4 -4
- package/dist/{index-BaBZGCqS.d.cts.map → index-oyX8xu0F.d.cts.map} +1 -1
- package/dist/index-sJZ434Sg.d.cts +264 -0
- package/dist/index-sJZ434Sg.d.cts.map +1 -0
- package/dist/index.cjs +29 -29
- package/dist/index.d.cts +22 -22
- package/dist/index.d.ts +24 -25
- package/dist/index.js +19 -19
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +1 -1
- package/dist/partials/FieldValidationError/index.d.ts +1 -1
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/dist/{useClientValidation-CkBtUSco.d.ts → useClientValidation-BQqwz628.d.cts} +3 -3
- package/dist/{useClientValidation-C3Q5UCy9.d.cts.map → useClientValidation-BQqwz628.d.cts.map} +1 -1
- package/dist/useClientValidation-BnnscAEe.js.map +1 -1
- package/dist/{useClientValidation-oZd4_ocQ.cjs → useClientValidation-CmYVGlLr.cjs} +7 -7
- package/dist/useClientValidation-CmYVGlLr.cjs.map +1 -0
- package/dist/{useClientValidation-C3Q5UCy9.d.cts → useClientValidation-DJ4JuN_9.d.ts} +3 -3
- package/dist/{useClientValidation-CkBtUSco.d.ts.map → useClientValidation-DJ4JuN_9.d.ts.map} +1 -1
- package/dist/{useController-BzkCcbSo.cjs → useController-CkmO5CLh.cjs} +3 -3
- package/dist/{useController-BzkCcbSo.cjs.map → useController-CkmO5CLh.cjs.map} +1 -1
- package/dist/{useFormContext-CZh7pv8f.d.cts → useFormContext-B083Y-kw.d.cts} +17 -17
- package/dist/{useFormContext-CZh7pv8f.d.cts.map → useFormContext-B083Y-kw.d.cts.map} +1 -1
- package/dist/{useFormContext-3AAPT6eZ.d.ts → useFormContext-B2TS6xq0.d.ts} +1 -1
- package/dist/{useFormContext-3AAPT6eZ.d.ts.map → useFormContext-B2TS6xq0.d.ts.map} +1 -1
- package/dist/{useFormContext-CWuN-_7P.cjs → useFormContext-Bp0EODoO.cjs} +3 -3
- package/dist/useFormContext-Bp0EODoO.cjs.map +1 -0
- package/dist/useFormContext-JCm1UR_e.js.map +1 -1
- package/dist/{useInputValueDebounce-B2RzCWty.d.cts → useInputValueDebounce-B5b-v8Hc.d.cts} +1 -1
- package/dist/{useInputValueDebounce-B2RzCWty.d.cts.map → useInputValueDebounce-B5b-v8Hc.d.cts.map} +1 -1
- package/dist/{useInputValueDebounce-tL8maIp8.cjs → useInputValueDebounce-BcUyaS94.cjs} +2 -2
- package/dist/{useInputValueDebounce-tL8maIp8.cjs.map → useInputValueDebounce-BcUyaS94.cjs.map} +1 -1
- package/dist/{useInputValueDebounce-C7_bvNGH.d.ts → useInputValueDebounce-DoRuSF6R.d.ts} +1 -1
- package/dist/{useInputValueDebounce-C7_bvNGH.d.ts.map → useInputValueDebounce-DoRuSF6R.d.ts.map} +1 -1
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs → useInputValueTransform-DFPA3KVy.cjs} +2 -2
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs.map → useInputValueTransform-DFPA3KVy.cjs.map} +1 -1
- package/dist/{useUniformField-Be3kdnhK.d.cts → useUniformField-B2OZ-Z1G.d.cts} +3 -3
- package/dist/{useUniformField-Be3kdnhK.d.cts.map → useUniformField-B2OZ-Z1G.d.cts.map} +1 -1
- package/dist/{useUniformField-BMvnRC_r.cjs → useUniformField-Bj23Kvbs.cjs} +13 -13
- package/dist/useUniformField-Bj23Kvbs.cjs.map +1 -0
- package/dist/{useUniformField-DDHQ5B11.d.ts → useUniformField-CwEHonNe.d.ts} +3 -3
- package/dist/{useUniformField-DDHQ5B11.d.ts.map → useUniformField-CwEHonNe.d.ts.map} +1 -1
- package/dist/{useUniformField-ClprfrES.js → useUniformField-gU4qYUwL.js} +3 -3
- package/dist/useUniformField-gU4qYUwL.js.map +1 -0
- package/dist/{useUniformFieldArray-C-0OXG3N.js → useUniformFieldArray-B5PyxL1P.js} +2 -2
- package/dist/{useUniformFieldArray-C-0OXG3N.js.map → useUniformFieldArray-B5PyxL1P.js.map} +1 -1
- package/dist/{useUniformFieldArray-BhPi3gPv.d.ts → useUniformFieldArray-CXoWvu6m.d.ts} +3 -3
- package/dist/{useUniformFieldArray-BhPi3gPv.d.ts.map → useUniformFieldArray-CXoWvu6m.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-btjvJdZ6.cjs → useUniformFieldArray-G1lokW7x.cjs} +7 -7
- package/dist/{useUniformFieldArray-btjvJdZ6.cjs.map → useUniformFieldArray-G1lokW7x.cjs.map} +1 -1
- package/dist/{useUniformFieldArray-BBFw08qL.d.cts → useUniformFieldArray-qtJMEosJ.d.cts} +13 -13
- package/dist/{useUniformFieldArray-BBFw08qL.d.cts.map → useUniformFieldArray-qtJMEosJ.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-C5dr12By.cjs → useWatchUserChange-BnxYE-0b.cjs} +3 -3
- package/dist/{useWatchUserChange-C5dr12By.cjs.map → useWatchUserChange-BnxYE-0b.cjs.map} +1 -1
- package/package.json +10 -10
- package/dist/Checkboxes-CGWhnpBp.js.map +0 -1
- package/dist/Checkboxes-Ds6bzl6p.cjs.map +0 -1
- package/dist/FieldArray-BexXN9bO.cjs.map +0 -1
- package/dist/FieldArray-D3iUaRLo.js.map +0 -1
- package/dist/FormContext-C3GymQOA.cjs.map +0 -1
- package/dist/Input--h5t7Sbl.js.map +0 -1
- package/dist/Input-DKfFFOpo.cjs.map +0 -1
- package/dist/RadioBoxes-7qdHj3ti.js.map +0 -1
- package/dist/RadioBoxes-Bd9ahl4i.cjs.map +0 -1
- package/dist/RadioTabs-DXs98jng.js.map +0 -1
- package/dist/RadioTabs-DcEUdW7r.cjs.map +0 -1
- package/dist/Select-BsL7qn2v.cjs.map +0 -1
- package/dist/Select-CBjqYDcs.js.map +0 -1
- package/dist/helpers-KTgXi0lA.cjs.map +0 -1
- package/dist/index-BOI0cy-n.d.cts.map +0 -1
- package/dist/index-BTEsKen4.d.ts +0 -264
- package/dist/index-C1fYmoY0.d.ts.map +0 -1
- package/dist/index-CJNLQVjx.d.ts +0 -1
- package/dist/index-CqV2Q3da.d.cts +0 -264
- package/dist/index-CqV2Q3da.d.cts.map +0 -1
- package/dist/index-CraZe1qS.d.ts.map +0 -1
- package/dist/index-CwSIy_W-.d.cts +0 -1
- package/dist/index-DA5um0u6.d.cts.map +0 -1
- package/dist/index-DzuP5q-2.d.ts.map +0 -1
- package/dist/useClientValidation-oZd4_ocQ.cjs.map +0 -1
- package/dist/useFormContext-CWuN-_7P.cjs.map +0 -1
- package/dist/useUniformField-BMvnRC_r.cjs.map +0 -1
- package/dist/useUniformField-ClprfrES.js.map +0 -1
- /package/dist/{index-B3Z8gdjC.d.ts → index-BRLjimYW.d.ts} +0 -0
- /package/dist/{index-BXpMZvwA.d.cts → index-DpEKQcoR.d.cts} +0 -0
- /package/dist/{useInput-IGJqJ2tR.d.ts → useInput--wjwIBc5.d.cts} +0 -0
- /package/dist/{useInput-NMHJNZ5A.d.cts → useInput-BCdeYOOg.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-
|
|
2
|
-
import { n as FieldValidationError_default } from "./FieldValidationError-
|
|
1
|
+
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-DWPCDJ-s.js";
|
|
2
|
+
import { n as FieldValidationError_default } from "./FieldValidationError-1hiDEFew.js";
|
|
3
3
|
import { a as toNullishString, i as toFormFormat, n as fromNullishString, o as toValidationFormat, r as nameToTestId, t as flatArrayKey } from "./helpers-B-CJOBt3.js";
|
|
4
4
|
import { t as useController } from "./useController-CumIERks.js";
|
|
5
5
|
import { n as useFormContext, t as checkFieldIsRequired } from "./useFormContext-JCm1UR_e.js";
|
|
6
6
|
import { t as useInput } from "./useInput-DZ6KGBxw.js";
|
|
7
7
|
import { t as useInputValueTransform } from "./useInputValueTransform-aiIf8lq5.js";
|
|
8
|
-
import { t as useUniformField } from "./useUniformField-
|
|
9
|
-
import { n as Checkboxes_default } from "./Checkboxes-
|
|
10
|
-
import { t as useUniformFieldArray } from "./useUniformFieldArray-
|
|
11
|
-
import { n as FieldArray_default } from "./FieldArray-
|
|
12
|
-
import { n as Grid_default } from "./Grid-
|
|
13
|
-
import { n as fieldCardVariants, t as FieldCard_default } from "./FieldCard-
|
|
14
|
-
import { n as Form_default } from "./Form-
|
|
8
|
+
import { t as useUniformField } from "./useUniformField-gU4qYUwL.js";
|
|
9
|
+
import { n as Checkboxes_default } from "./Checkboxes-BY4UK0Xf.js";
|
|
10
|
+
import { t as useUniformFieldArray } from "./useUniformFieldArray-B5PyxL1P.js";
|
|
11
|
+
import { n as FieldArray_default } from "./FieldArray-CDLaGvNj.js";
|
|
12
|
+
import { n as Grid_default } from "./Grid-LRjQlZms.js";
|
|
13
|
+
import { n as fieldCardVariants, t as FieldCard_default } from "./FieldCard-C1MCSbPW.js";
|
|
14
|
+
import { n as Form_default } from "./Form-DRNEwHsi.js";
|
|
15
15
|
import { t as useInputValueDebounce } from "./useInputValueDebounce-DaH5ONlQ.js";
|
|
16
|
-
import { n as Input_default } from "./Input
|
|
17
|
-
import { n as RadioBoxes_default, r as radioBoxVariants } from "./RadioBoxes-
|
|
18
|
-
import { n as RadioTabs_default } from "./RadioTabs-
|
|
19
|
-
import { n as Radios_default } from "./Radios-
|
|
20
|
-
import { n as Select_default } from "./Select-
|
|
21
|
-
import { n as Slider_default } from "./Slider-
|
|
22
|
-
import { n as SubmitButton_default } from "./SubmitButton-
|
|
23
|
-
import { n as Switch_default } from "./Switch
|
|
24
|
-
import { n as SwitchBox_default, r as switchBoxVariants } from "./SwitchBox-
|
|
25
|
-
import { n as TextArea_default } from "./TextArea-
|
|
16
|
+
import { n as Input_default } from "./Input-DXMWGTBh.js";
|
|
17
|
+
import { n as RadioBoxes_default, r as radioBoxVariants } from "./RadioBoxes-BEln4a-B.js";
|
|
18
|
+
import { n as RadioTabs_default } from "./RadioTabs-DLr9QiXI.js";
|
|
19
|
+
import { n as Radios_default } from "./Radios-DCXI2kMf.js";
|
|
20
|
+
import { n as Select_default } from "./Select-CyfEmWiD.js";
|
|
21
|
+
import { n as Slider_default } from "./Slider-Dlhb-9hC.js";
|
|
22
|
+
import { n as SubmitButton_default } from "./SubmitButton-C5f6j0N4.js";
|
|
23
|
+
import { n as Switch_default } from "./Switch--m02Xcq8.js";
|
|
24
|
+
import { n as SwitchBox_default, r as switchBoxVariants } from "./SwitchBox-D0-e-pbM.js";
|
|
25
|
+
import { n as TextArea_default } from "./TextArea-BiSnvJ69.js";
|
|
26
26
|
import { n as useClientValidation, t as clientValidationSchemaByName } from "./useClientValidation-BnnscAEe.js";
|
|
27
27
|
import { t as useWatchUserChange } from "./useWatchUserChange-C1ezpj0t.js";
|
|
28
28
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_FieldCopyTestIdButton = require('../../FieldCopyTestIdButton-
|
|
2
|
+
const require_FieldCopyTestIdButton = require('../../FieldCopyTestIdButton-BSYcSo2o.cjs');
|
|
3
3
|
|
|
4
4
|
exports.FieldCopyTestIdButton = require_FieldCopyTestIdButton.FieldCopyTestIdButton_default$1;
|
|
5
5
|
exports.default = require_FieldCopyTestIdButton.FieldCopyTestIdButton_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FieldCopyTestIdButtonProps, t as FieldCopyTestIdButton } from "../../index-
|
|
1
|
+
import { n as FieldCopyTestIdButtonProps, t as FieldCopyTestIdButton } from "../../index-PU5WNOH9.cjs";
|
|
2
2
|
export { FieldCopyTestIdButton, FieldCopyTestIdButton as default, FieldCopyTestIdButtonProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FieldCopyTestIdButtonProps, t as FieldCopyTestIdButton } from "../../index-
|
|
1
|
+
import { n as FieldCopyTestIdButtonProps, t as FieldCopyTestIdButton } from "../../index-BQDEnYTq.js";
|
|
2
2
|
export { FieldCopyTestIdButton, FieldCopyTestIdButton as default, FieldCopyTestIdButtonProps };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as FieldCopyTestIdButton_default, t as FieldCopyTestIdButton_default$1 } from "../../FieldCopyTestIdButton-
|
|
1
|
+
import { n as FieldCopyTestIdButton_default, t as FieldCopyTestIdButton_default$1 } from "../../FieldCopyTestIdButton-DWPCDJ-s.js";
|
|
2
2
|
|
|
3
3
|
export { FieldCopyTestIdButton_default as FieldCopyTestIdButton, FieldCopyTestIdButton_default$1 as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_FieldValidationError = require('../../FieldValidationError-
|
|
2
|
+
const require_FieldValidationError = require('../../FieldValidationError-CE8R8qry.cjs');
|
|
3
3
|
|
|
4
4
|
exports.FieldValidationError = require_FieldValidationError.FieldValidationError_default$1;
|
|
5
5
|
exports.default = require_FieldValidationError.FieldValidationError_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-
|
|
1
|
+
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-CYdvpGJF.cjs";
|
|
2
2
|
export { FieldValidationError, FieldValidationError as default, FieldValidationErrorProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-
|
|
1
|
+
import { n as FieldValidationErrorProps, t as FieldValidationError } from "../../index-BTTo_ufh.js";
|
|
2
2
|
export { FieldValidationError, FieldValidationError as default, FieldValidationErrorProps };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as FieldValidationError_default, t as FieldValidationError_default$1 } from "../../FieldValidationError-
|
|
1
|
+
import { n as FieldValidationError_default, t as FieldValidationError_default$1 } from "../../FieldValidationError-1hiDEFew.js";
|
|
2
2
|
|
|
3
3
|
export { FieldValidationError_default as FieldValidationError, FieldValidationError_default$1 as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VetoTypeAny } from "@fuf-stack/veto";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _fuf_stack_veto_dist_types_d_DFjr0b5b0 from "@fuf-stack/veto/dist/types.d-DFjr0b5b";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useClientValidation/useClientValidation.d.ts
|
|
5
5
|
|
|
@@ -144,7 +144,7 @@ declare const useClientValidation: <TData = unknown>(data: TData | null | undefi
|
|
|
144
144
|
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
|
-
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) =>
|
|
147
|
+
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_DFjr0b5b0.Z;
|
|
148
148
|
//#endregion
|
|
149
149
|
export { useClientValidation as n, clientValidationSchemaByName as t };
|
|
150
|
-
//# sourceMappingURL=useClientValidation-
|
|
150
|
+
//# sourceMappingURL=useClientValidation-BQqwz628.d.cts.map
|
package/dist/{useClientValidation-C3Q5UCy9.d.cts.map → useClientValidation-BQqwz628.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClientValidation-
|
|
1
|
+
{"version":3,"file":"useClientValidation-BQqwz628.d.cts","names":[],"sources":["../src/hooks/useClientValidation/useClientValidation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAkEA;;;;;AAkIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAlIa,6CACL,gDACgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgIrB,yCAA0C,wCAExC,MAAC,sCAAA,CAAA"}
|
|
@@ -1 +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"}
|
|
1
|
+
{"version":3,"file":"useClientValidation-BnnscAEe.js","names":[],"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,IAAI,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_helpers = require('./helpers-
|
|
3
|
-
const require_useFormContext = require('./useFormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-B84E9vHd.cjs');
|
|
3
|
+
const require_useFormContext = require('./useFormContext-Bp0EODoO.cjs');
|
|
4
4
|
let react = require("react");
|
|
5
|
-
let
|
|
5
|
+
let _fuf_stack_veto = require("@fuf-stack/veto");
|
|
6
6
|
|
|
7
7
|
//#region src/hooks/useClientValidation/useClientValidation.ts
|
|
8
8
|
/**
|
|
@@ -166,9 +166,9 @@ const clientValidationSchemaByName = (name, fieldSchema) => {
|
|
|
166
166
|
const segment = segments[i];
|
|
167
167
|
const isNumeric = /^\d+$/.test(segment);
|
|
168
168
|
if (segment === require_helpers.flatArrayKey) continue;
|
|
169
|
-
if (isNumeric) schema = (0,
|
|
169
|
+
if (isNumeric) schema = (0, _fuf_stack_veto.array)(schema).optional();
|
|
170
170
|
else {
|
|
171
|
-
const obj = (0,
|
|
171
|
+
const obj = (0, _fuf_stack_veto.objectLoose)({ [segment]: schema });
|
|
172
172
|
schema = i > 0 ? obj.optional() : obj;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -188,4 +188,4 @@ Object.defineProperty(exports, 'useClientValidation', {
|
|
|
188
188
|
return useClientValidation;
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
|
-
//# sourceMappingURL=useClientValidation-
|
|
191
|
+
//# sourceMappingURL=useClientValidation-CmYVGlLr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientValidation-CmYVGlLr.cjs","names":["useFormContext","flatArrayKey"],"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,YACEA,uCAAgB;CAGpB,MAAM,qCAA0B;CAChC,MAAM,MAAM,SAAS,OAAO;AAO5B,4BAAgB;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,IAAI,SAAsB;AAG1B,MAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;EAChD,MAAM,UAAU,SAAS;EAEzB,MAAM,YAAY,QAAQ,KAAK,QAAQ;AAGvC,MAFuB,YAAYC,6BAMjC;AAGF,MAAI,UAEF,qCAAe,OAAO,CAAC,UAAU;OAC5B;GAGL,MAAM,uCAAkB,GACrB,UAAU,QACZ,CAAC;AACF,YAAS,IAAI,IAAI,IAAI,UAAU,GAAG;;;AAItC,QAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VetoTypeAny } from "@fuf-stack/veto";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _fuf_stack_veto_dist_types_d_DFjr0b5b0 from "@fuf-stack/veto/dist/types.d-DFjr0b5b";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useClientValidation/useClientValidation.d.ts
|
|
5
5
|
|
|
@@ -144,7 +144,7 @@ declare const useClientValidation: <TData = unknown>(data: TData | null | undefi
|
|
|
144
144
|
* // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
|
-
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) =>
|
|
147
|
+
declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_DFjr0b5b0.Z;
|
|
148
148
|
//#endregion
|
|
149
149
|
export { useClientValidation as n, clientValidationSchemaByName as t };
|
|
150
|
-
//# sourceMappingURL=useClientValidation-
|
|
150
|
+
//# sourceMappingURL=useClientValidation-DJ4JuN_9.d.ts.map
|
package/dist/{useClientValidation-CkBtUSco.d.ts.map → useClientValidation-DJ4JuN_9.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClientValidation-
|
|
1
|
+
{"version":3,"file":"useClientValidation-DJ4JuN_9.d.ts","names":[],"sources":["../src/hooks/useClientValidation/useClientValidation.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAkEA;;;;;AAkIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAlIa,6CACL,gDACgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgIrB,yCAA0C,wCAExC,MAAC,sCAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_helpers = require('./helpers-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-B84E9vHd.cjs');
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_hook_form = require("react-hook-form");
|
|
5
5
|
|
|
@@ -45,4 +45,4 @@ Object.defineProperty(exports, 'useController', {
|
|
|
45
45
|
return useController;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
//# sourceMappingURL=useController-
|
|
48
|
+
//# sourceMappingURL=useController-CkmO5CLh.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useController-
|
|
1
|
+
{"version":3,"file":"useController-CkmO5CLh.cjs","names":["UniformContext","toNullishString","fromNullishString"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\n}\n\n/**\n * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's useController\n * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n userChange?.notify(field.name, formattedValue);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,iBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,kDAAgC,MAAM;CAChE,MAAM,EAAE,qCAA0BA,mCAAe;AAEjD,QAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,IAAI,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAKC,gCAAgB,MAAM;AAGjE,UAAM,SAAS,eAAe;AAK9B,gBAAY,OAAO,MAAM,MAAM,eAAe;;GAGhD,OAAOC,kCAAkB,MAAM,MAAM;GACtC;EACD;EACA;EACD"}
|
|
@@ -2,7 +2,7 @@ import { n as UserChangeListener, t as DebugModeSettings } from "./FormContext-D
|
|
|
2
2
|
import * as react0 from "react";
|
|
3
3
|
import * as _fuf_stack_veto0 from "@fuf-stack/veto";
|
|
4
4
|
import { VetoFormattedError, VetoInstance } from "@fuf-stack/veto";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react_hook_form0 from "react-hook-form";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
7
7
|
|
|
8
8
|
//#region src/hooks/useFormContext/useFormContext.d.ts
|
|
@@ -19,7 +19,7 @@ declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) =
|
|
|
19
19
|
* - Filters out empty/null values
|
|
20
20
|
*/
|
|
21
21
|
declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
|
|
22
|
-
formState:
|
|
22
|
+
formState: react_hook_form0.FormState<TFieldValues>;
|
|
23
23
|
getFieldState: (name: Path<TFieldValues>, testId?: string) => {
|
|
24
24
|
error: FieldError[] | undefined;
|
|
25
25
|
invalid: boolean;
|
|
@@ -29,9 +29,9 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
29
29
|
isTouched: boolean;
|
|
30
30
|
isValidating: boolean;
|
|
31
31
|
};
|
|
32
|
-
getValues:
|
|
33
|
-
subscribe:
|
|
34
|
-
watch:
|
|
32
|
+
getValues: react_hook_form0.UseFormGetValues<TFieldValues>;
|
|
33
|
+
subscribe: react_hook_form0.UseFormSubscribe<TFieldValues>;
|
|
34
|
+
watch: react_hook_form0.UseFormWatch<TFieldValues>;
|
|
35
35
|
debugMode: "disabled" | "debug" | "debug-testids" | "off";
|
|
36
36
|
debugModeSettings?: DebugModeSettings;
|
|
37
37
|
preventSubmit: (prevent: boolean) => void;
|
|
@@ -47,18 +47,18 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
47
47
|
errors?: VetoFormattedError;
|
|
48
48
|
setClientValidationSchema: (key: string, schema: _fuf_stack_veto0.VetoTypeAny | null) => void;
|
|
49
49
|
};
|
|
50
|
-
setError:
|
|
51
|
-
clearErrors:
|
|
52
|
-
setValue:
|
|
53
|
-
trigger:
|
|
54
|
-
resetField:
|
|
55
|
-
reset:
|
|
56
|
-
handleSubmit:
|
|
57
|
-
unregister:
|
|
58
|
-
control:
|
|
59
|
-
register:
|
|
60
|
-
setFocus:
|
|
50
|
+
setError: react_hook_form0.UseFormSetError<TFieldValues>;
|
|
51
|
+
clearErrors: react_hook_form0.UseFormClearErrors<TFieldValues>;
|
|
52
|
+
setValue: react_hook_form0.UseFormSetValue<TFieldValues>;
|
|
53
|
+
trigger: react_hook_form0.UseFormTrigger<TFieldValues>;
|
|
54
|
+
resetField: react_hook_form0.UseFormResetField<TFieldValues>;
|
|
55
|
+
reset: react_hook_form0.UseFormReset<TFieldValues>;
|
|
56
|
+
handleSubmit: react_hook_form0.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
|
|
57
|
+
unregister: react_hook_form0.UseFormUnregister<TFieldValues>;
|
|
58
|
+
control: react_hook_form0.Control<TFieldValues, TContext, TTransformedValues>;
|
|
59
|
+
register: react_hook_form0.UseFormRegister<TFieldValues>;
|
|
60
|
+
setFocus: react_hook_form0.UseFormSetFocus<TFieldValues>;
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { useFormContext as n, checkFieldIsRequired as t };
|
|
64
|
-
//# sourceMappingURL=useFormContext-
|
|
64
|
+
//# sourceMappingURL=useFormContext-B083Y-kw.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-B083Y-kw.d.cts","names":[],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAYa,mCACC;;;;;AADd;AAqEA;;;;;cAAa,sCACU,cAAc,kDAEd;EAwBa,SAAA,4BAAA,aAAA,CAAA;EAAL,aAAA,EAAA,CAAA,IAAA,EAAA,IAAA,CAAK,YAAL,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA,EAAA,GAAA;;;;;;;;;WAWO,mCAAA,aAAA,CAAA;EAAA,SAAA,mCAAA,aAAA,CAAA;EAAA,KAAA,+BAAA,aAAA,CAAA;EAyBpC,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA;EACyB,iBAAA,CAAA,mBAAA;EAAwE,aAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAA,YAAA,EAAA,CAAA,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA,EAAA,GAAA,IAAA;6BA1B7D,uBAAA;;0BAAA;;;;mBAyBpC;eACyB;aAAwE;qDAAA,gBAAA,CAAA,WAAA"}
|
|
@@ -61,4 +61,4 @@ declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues,
|
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { useFormContext$1 as n, checkFieldIsRequired as t };
|
|
64
|
-
//# sourceMappingURL=useFormContext-
|
|
64
|
+
//# sourceMappingURL=useFormContext-B2TS6xq0.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-B2TS6xq0.d.ts","names":[],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAYa,mCACC;;;;;AADd;AAqEA;;;;;cAAa,wCACU,cAAc,kDAEd;EAwBa,SAAA,4BAAA,aAAA,CAAA;EAAL,aAAA,EAAA,CAAA,IAAA,EAAA,IAAA,CAAK,YAAL,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA,EAAA,GAAA;;;;;;;;;WAWO,mCAAA,aAAA,CAAA;EAAA,SAAA,mCAAA,aAAA,CAAA;EAAA,KAAA,+BAAA,aAAA,CAAA;EAyBpC,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA;EACyB,iBAAA,CAAA,mBAAA;EAAwE,aAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAA,YAAA,EAAA,CAAA,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA,EAAA,GAAA,IAAA;6BA1B7D,uBAAA;;0BAAA;;;;mBAyBpC;eACyB;aAAwE;qDAAA,gBAAA,CAAA,WAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_helpers = require('./helpers-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-B84E9vHd.cjs');
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_hook_form = require("react-hook-form");
|
|
5
5
|
|
|
@@ -131,4 +131,4 @@ Object.defineProperty(exports, 'useFormContext', {
|
|
|
131
131
|
return useFormContext;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
//# sourceMappingURL=useFormContext-
|
|
134
|
+
//# sourceMappingURL=useFormContext-Bp0EODoO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext-Bp0EODoO.cjs","names":["flatArrayKey","UniformContext","nameToTestId","toValidationFormat"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors as unknown;\n keys.forEach((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n } else {\n current = undefined;\n }\n });\n return current as FieldError[] | undefined;\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>() => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n ) as unknown as FieldError[] | undefined;\n\n // Get everything but the error from the original field state\n const fieldState = getFieldStateOrig(name, formState);\n\n return {\n ...fieldState,\n error,\n invalid: !!error,\n required,\n testId: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;;AAYA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAOA,+BAAe,KAAK,MAAM,GAAG,GAAG,GAAG;CAE/D,MAAM,iBAAiB,WAAgB;AAErC,MAAI,OAAO,SAAS,SAAS;AAE3B,OAAI,OAAO,cAAc,OAAO,WAC9B,QAAO;AAGT,UAAO;;AAKT,SAAO,CAAC,OAAO,cAAc,CAAC,OAAO;;AAGvC,QAAO,WAAW,gBAAgB,eAAe,UAAU;;;;;;;;;;;;;;AAe7D,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,MAAM;AACzC,SAAO,MAAMA;GACb;CACF,IAAI,UAAmB;AACvB,MAAK,SAAS,QAAQ;AACpB,MAAI,WAAW,OAAO,YAAY,SAChC,WAAW,QAAoC;MAE/C,WAAU;GAEZ;AACF,QAAO;;;;;;;;;;;;AAaT,MAAa,uBAIN;CACL,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eAEX,GAAG,sDAC+D;CAEpE,MAAM,uCAA4BC,mCAAe;;;;;;;;;;CAWjD,MAAM,iBAAiB,MAA0B,WAAoB;EACnE,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,UAAU,GACnD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,EAAE,EACvC,KACD;AAKD,SAAO;GACL,GAHiB,kBAAkB,MAAM,UAAU;GAInD;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQC,6BAAa,UAAU,KAAK;GACrC;;;;;;;;;;;;;CAcH,MAAM,cAAc,GAAG,SAAgB;AAErC,SAAOC,mCADS,cAAsB,GAAG,KAAK,CACb;;CAGnC,MAAM,UAAU,GAAG,SAAgB;AAEjC,SAAOA,mCADS,UAAkB,GAAG,KAAK,CACT;;CAGnC,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;AAClB,MAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;AAejC,UAAO,cAdgB;IACrB,GAAG;IACH,WAAW,uBAA4B;AASrC,YAAO,iBAPoB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQA,mCAAmB,mBAAmB,OAAO,EACtD;MACF,CAE0C;;IAE9C,CACmC;;AAGtC,SAAQ,cAAsB,GAAG,KAAK;;AAGxC,QAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-JCm1UR_e.js","names":["
|
|
1
|
+
{"version":3,"file":"useFormContext-JCm1UR_e.js","names":["useFormContext","useHookFormContext"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors as unknown;\n keys.forEach((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n } else {\n current = undefined;\n }\n });\n return current as FieldError[] | undefined;\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>() => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n ) as unknown as FieldError[] | undefined;\n\n // Get everything but the error from the original field state\n const fieldState = getFieldStateOrig(name, formState);\n\n return {\n ...fieldState,\n error,\n invalid: !!error,\n required,\n testId: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;;AAYA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAO,eAAe,KAAK,MAAM,GAAG,GAAG,GAAG;CAE/D,MAAM,iBAAiB,WAAgB;AAErC,MAAI,OAAO,SAAS,SAAS;AAE3B,OAAI,OAAO,cAAc,OAAO,WAC9B,QAAO;AAGT,UAAO;;AAKT,SAAO,CAAC,OAAO,cAAc,CAAC,OAAO;;AAGvC,QAAO,WAAW,gBAAgB,eAAe,UAAU;;;;;;;;;;;;;;AAe7D,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,MAAM;AACzC,SAAO,MAAM;GACb;CACF,IAAI,UAAmB;AACvB,MAAK,SAAS,QAAQ;AACpB,MAAI,WAAW,OAAO,YAAY,SAChC,WAAW,QAAoC;MAE/C,WAAU;GAEZ;AACF,QAAO;;;;;;;;;;;;AAaT,MAAaA,yBAIN;CACL,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eAEX,GAAG,iBACDC,gBAAgE;CAEpE,MAAM,iBAAiB,WAAW,eAAe;;;;;;;;;;CAWjD,MAAM,iBAAiB,MAA0B,WAAoB;EACnE,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,UAAU,GACnD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,EAAE,EACvC,KACD;AAKD,SAAO;GACL,GAHiB,kBAAkB,MAAM,UAAU;GAInD;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQ,aAAa,UAAU,KAAK;GACrC;;;;;;;;;;;;;CAcH,MAAM,cAAc,GAAG,SAAgB;AAErC,SAAO,mBADS,cAAsB,GAAG,KAAK,CACb;;CAGnC,MAAM,UAAU,GAAG,SAAgB;AAEjC,SAAO,mBADS,UAAkB,GAAG,KAAK,CACT;;CAGnC,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;AAClB,MAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;AAejC,UAAO,cAdgB;IACrB,GAAG;IACH,WAAW,uBAA4B;AASrC,YAAO,iBAPoB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQ,mBAAmB,mBAAmB,OAAO,EACtD;MACF,CAE0C;;IAE9C,CACmC;;AAGtC,SAAQ,cAAsB,GAAG,KAAK;;AAGxC,QAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -59,4 +59,4 @@ declare const useInputValueDebounce: <TValue = unknown>({
|
|
|
59
59
|
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
60
60
|
//#endregion
|
|
61
61
|
export { UseInputValueDebounceReturn as n, useInputValueDebounce as r, UseInputValueDebounceOptions as t };
|
|
62
|
-
//# sourceMappingURL=useInputValueDebounce-
|
|
62
|
+
//# sourceMappingURL=useInputValueDebounce-B5b-v8Hc.d.cts.map
|
package/dist/{useInputValueDebounce-B2RzCWty.d.cts.map → useInputValueDebounce-B5b-v8Hc.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-B5b-v8Hc.d.cts","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAYA,aAAA,CAAA,EAAA,MAAA;EA4CJ;EAA2C,MAAA,EAAA,GAAA,GAAA,IAAA;EAAA;EAAA,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;EAAA;EAKxB,KAAA,EApDvB,MAoDuB;;AAAsC,UAjDrD,2BAiDqD,CAAA,SAAA,OAAA,CAAA,CAAA;EAA5B;EAA2B,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;;;;SA1C5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCI;;;;;GAKV,6BAA6B,YAAU,4BAA4B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
2
|
let react = require("react");
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
@@ -87,4 +87,4 @@ Object.defineProperty(exports, 'useInputValueDebounce', {
|
|
|
87
87
|
return useInputValueDebounce;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
//# sourceMappingURL=useInputValueDebounce-
|
|
90
|
+
//# sourceMappingURL=useInputValueDebounce-BcUyaS94.cjs.map
|
package/dist/{useInputValueDebounce-tL8maIp8.cjs.map → useInputValueDebounce-BcUyaS94.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-BcUyaS94.cjs","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\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 * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\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 };\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],\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,QACA,UACA,YAC+E;CAE/E,MAAM,CAAC,cAAc,uCAAoC,MAAM;CAE/D,MAAM,+BAA2C,KAAK;AAGtD,4BAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAoDX,QAAO;EACL,kCAhDC,GAAG,UAAiB;GAEnB,MAAM,WAAY,MAAM,IAAI,QAAQ,SAAS,MAAM;AACnD,mBAAgB,SAAS;AAGzB,OAAI,WAAW,QACb,cAAa,WAAW,QAAQ;GAGlC,MAAM,wBAAwB;AAE5B,QAAI,MAAM,IAAI,OAQZ,UAPuB;KACrB,GAAG,MAAM;KACT,QAAQ;MACN,GAAG,MAAM,GAAG;MACZ,OAAO;MACR;KACF,EACwB,GAAG,MAAM,MAAM,EAAE,CAAC;QAE3C,UAAS,SAAS;;AAKtB,OAAI,iBAAiB,EACnB,kBAAiB;OAEjB,YAAW,UAAU,WAAW,iBAAiB,cAAc;KAGnE,CAAC,UAAU,cAAc,CAC1B;EAeC,qCAZmC;AAEnC,OAAI,WAAW,SAAS;AACtB,iBAAa,WAAW,QAAQ;AAChC,eAAW,UAAU;AACrB,aAAS,aAAa;;AAExB,WAAQ;KACP;GAAC;GAAU;GAAQ;GAAa,CAAC;EAKlC,OAAO;EACR"}
|
|
@@ -59,4 +59,4 @@ declare const useInputValueDebounce: <TValue = unknown>({
|
|
|
59
59
|
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
60
60
|
//#endregion
|
|
61
61
|
export { UseInputValueDebounceReturn as n, useInputValueDebounce as r, UseInputValueDebounceOptions as t };
|
|
62
|
-
//# sourceMappingURL=useInputValueDebounce-
|
|
62
|
+
//# sourceMappingURL=useInputValueDebounce-DoRuSF6R.d.ts.map
|
package/dist/{useInputValueDebounce-C7_bvNGH.d.ts.map → useInputValueDebounce-DoRuSF6R.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-DoRuSF6R.d.ts","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAYA,aAAA,CAAA,EAAA,MAAA;EA4CJ;EAA2C,MAAA,EAAA,GAAA,GAAA,IAAA;EAAA;EAAA,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;EAAA;EAKxB,KAAA,EApDvB,MAoDuB;;AAAsC,UAjDrD,2BAiDqD,CAAA,SAAA,OAAA,CAAA,CAAA;EAA5B;EAA2B,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;;;;SA1C5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCI;;;;;GAKV,6BAA6B,YAAU,4BAA4B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
2
|
let react = require("react");
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useInputValueTransform/useInputValueTransform.ts
|
|
@@ -113,4 +113,4 @@ Object.defineProperty(exports, 'useInputValueTransform', {
|
|
|
113
113
|
return useInputValueTransform;
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
-
//# sourceMappingURL=useInputValueTransform-
|
|
116
|
+
//# sourceMappingURL=useInputValueTransform-DFPA3KVy.cjs.map
|
package/dist/{useInputValueTransform-C-uSW8Y3.cjs.map → useInputValueTransform-DFPA3KVy.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueTransform-
|
|
1
|
+
{"version":3,"file":"useInputValueTransform-DFPA3KVy.cjs","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform<TDisplay = unknown> {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\" or 'a' → ['a']) */\n toDisplayValue: (value: unknown) => TDisplay;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000 or ['a'] → 'a') */\n toFormValue: (value: TDisplay) => unknown;\n}\n\nexport interface UseInputValueTransformOptions<TDisplay = unknown> {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform<TDisplay>;\n}\n\nexport interface UseInputValueTransformReturn<TDisplay = unknown> {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: unknown) => TDisplay;\n /** Converts any display value to form value */\n toFormValue: (displayValue: TDisplay) => unknown;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n * - Array/Object transformations (single value ↔ array, nested structures)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Generic support for any data type (strings, numbers, arrays, objects)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Array to single value (for single checkbox)\n * const singleValueTransform = {\n * toDisplayValue: (val: string[]) => val?.[0] || '',\n * toFormValue: (val: string) => val ? [val] : []\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: singleValueTransform\n * });\n *\n * const displayVal = toDisplayValue(['option1']); // \"option1\"\n * const formVal = toFormValue(\"option2\"); // [\"option2\"]\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * initialValue: field.value,\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = <TDisplay = unknown>({\n type,\n transform,\n}: UseInputValueTransformOptions<TDisplay>): UseInputValueTransformReturn<TDisplay> => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: unknown): TDisplay => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue);\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') {\n return '' as TDisplay;\n }\n const numValue = Number(formValue);\n return (Number.isNaN(numValue) ? formValue : numValue) as TDisplay;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return (formValue ?? '') as TDisplay;\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: TDisplay): unknown => {\n if (transform?.toFormValue) {\n return transform.toFormValue(displayValue);\n }\n\n // For number type, convert strings to numbers\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,MAAa,0BAA8C,EACzD,MACA,gBACqF;AAiDrF,QAAO;EACL,wCA7CC,cAAiC;AAChC,OAAI,WAAW,eACb,QAAO,UAAU,eAAe,UAAU;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,cAAc,GAChB,QAAO;IAET,MAAM,WAAW,OAAO,UAAU;AAClC,WAAQ,OAAO,MAAM,SAAS,GAAG,YAAY;;AAI/C,UAAQ,aAAa;KAEvB,CAAC,MAAM,UAAU,CAClB;EA4BC,qCAtBC,iBAAoC;AACnC,OAAI,WAAW,YACb,QAAO,UAAU,YAAY,aAAa;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,iBAAiB,GACnB,QAAO;IAET,MAAM,WAAW,OAAO,aAAa;AACrC,WAAO,OAAO,MAAM,SAAS,GAAG,eAAe;;AAIjD,UAAO;KAET,CAAC,MAAM,UAAU,CAClB;EAKA"}
|