@fuf-stack/uniform 1.11.1 → 1.11.3
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-BvW4D5Nm.js} +6 -6
- package/dist/Checkboxes-BvW4D5Nm.js.map +1 -0
- package/dist/{Checkboxes-Ds6bzl6p.cjs → Checkboxes-Cvdazf25.cjs} +18 -18
- package/dist/Checkboxes-Cvdazf25.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-BexXN9bO.cjs → FieldArray-CJpDgK_t.cjs} +49 -49
- package/dist/FieldArray-CJpDgK_t.cjs.map +1 -0
- package/dist/{FieldArray-D3iUaRLo.js → FieldArray-omRNwxgy.js} +9 -9
- package/dist/FieldArray-omRNwxgy.js.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-pP7aniZU.cjs → FieldCard-Dt6QU7o7.cjs} +13 -13
- package/dist/{FieldCard-pP7aniZU.cjs.map → FieldCard-Dt6QU7o7.cjs.map} +1 -1
- package/dist/{FieldCard-mpmErfDK.js → FieldCard-Dyi-2qr6.js} +3 -3
- package/dist/{FieldCard-mpmErfDK.js.map → FieldCard-Dyi-2qr6.js.map} +1 -1
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs → FieldCopyTestIdButton-By-hEZgA.cjs} +10 -10
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs.map → FieldCopyTestIdButton-By-hEZgA.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js → FieldCopyTestIdButton-D9f1B-VS.js} +4 -4
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js.map → FieldCopyTestIdButton-D9f1B-VS.js.map} +1 -1
- package/dist/{FieldValidationError-D86DPSOH.js → FieldValidationError-BYwitb_B.js} +4 -4
- package/dist/{FieldValidationError-D86DPSOH.js.map → FieldValidationError-BYwitb_B.js.map} +1 -1
- package/dist/{FieldValidationError-Cq6aI0tE.cjs → FieldValidationError-D64j5gnH.cjs} +13 -13
- package/dist/{FieldValidationError-Cq6aI0tE.cjs.map → FieldValidationError-D64j5gnH.cjs.map} +1 -1
- package/dist/Form/index.cjs +1 -1
- package/dist/Form/index.d.cts +1 -1
- package/dist/Form/index.d.ts +1 -1
- package/dist/Form/index.js +1 -1
- package/dist/{Form-CFmCTl60.js → Form-B1fvbnxi.js} +6 -6
- package/dist/{Form-CFmCTl60.js.map → Form-B1fvbnxi.js.map} +1 -1
- package/dist/{Form-FvN3SXfF.cjs → Form-CvnnGF45.cjs} +19 -19
- package/dist/{Form-FvN3SXfF.cjs.map → Form-CvnnGF45.cjs.map} +1 -1
- package/dist/{FormContext-CN9n_KdE.js → FormContext-Dl3k1r_k.js} +2 -2
- package/dist/FormContext-Dl3k1r_k.js.map +1 -0
- package/dist/{FormContext-C3GymQOA.cjs → FormContext-Lw4YL4-B.cjs} +8 -8
- package/dist/FormContext-Lw4YL4-B.cjs.map +1 -0
- 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-DezBAZbx.cjs} +8 -8
- package/dist/{Grid-DG60vYYG.cjs.map → Grid-DezBAZbx.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-DKfFFOpo.cjs → Input-DR0gCf9q.cjs} +16 -15
- package/dist/Input-DR0gCf9q.cjs.map +1 -0
- package/dist/{Input--h5t7Sbl.js → Input-DksaHK1Y.js} +7 -6
- package/dist/Input-DksaHK1Y.js.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-DdIHH6B5.js} +5 -5
- package/dist/RadioBoxes-DdIHH6B5.js.map +1 -0
- package/dist/{RadioBoxes-Bd9ahl4i.cjs → RadioBoxes-h-VLhJ9d.cjs} +22 -22
- package/dist/RadioBoxes-h-VLhJ9d.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-D6yF9jE3.cjs} +18 -18
- package/dist/RadioTabs-D6yF9jE3.cjs.map +1 -0
- package/dist/{RadioTabs-DXs98jng.js → RadioTabs-dLdlF91p.js} +5 -5
- package/dist/RadioTabs-dLdlF91p.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-D8alyG2f.cjs} +14 -14
- package/dist/{Radios-CIPNqPzi.cjs.map → Radios-D8alyG2f.cjs.map} +1 -1
- package/dist/{Radios-BIx06mzU.js → Radios-DiZ0Dfmp.js} +5 -5
- package/dist/{Radios-BIx06mzU.js.map → Radios-DiZ0Dfmp.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-C9otN8uu.js} +6 -6
- package/dist/Select-C9otN8uu.js.map +1 -0
- package/dist/{Select-BsL7qn2v.cjs → Select-DQVskslz.cjs} +19 -19
- package/dist/Select-DQVskslz.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-DwfyCQDM.cjs} +15 -15
- package/dist/{Slider-BDLbD7d5.cjs.map → Slider-DwfyCQDM.cjs.map} +1 -1
- package/dist/{Slider-BHjHSoIk.js → Slider-meuLEC2k.js} +5 -5
- package/dist/{Slider-BHjHSoIk.js.map → Slider-meuLEC2k.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-DhtPJuro.cjs → SubmitButton-B0kvUqkd.cjs} +12 -12
- package/dist/{SubmitButton-DhtPJuro.cjs.map → SubmitButton-B0kvUqkd.cjs.map} +1 -1
- package/dist/{SubmitButton-7iOaKzhB.js → SubmitButton-BHP9J9ml.js} +5 -5
- package/dist/{SubmitButton-7iOaKzhB.js.map → SubmitButton-BHP9J9ml.js.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-DkciIYnD.js} +5 -5
- package/dist/{Switch-DCxAgt_L.js.map → Switch-DkciIYnD.js.map} +1 -1
- package/dist/{Switch-Dczzog3v.cjs → Switch-Ds0gDzjR.cjs} +15 -15
- package/dist/{Switch-Dczzog3v.cjs.map → Switch-Ds0gDzjR.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-DPHryDOM.js → SwitchBox-B6Z4rtWt.js} +5 -5
- package/dist/{SwitchBox-DPHryDOM.js.map → SwitchBox-B6Z4rtWt.js.map} +1 -1
- package/dist/{SwitchBox-DqVmZYId.cjs → SwitchBox-B9JqwDtN.cjs} +19 -19
- package/dist/{SwitchBox-DqVmZYId.cjs.map → SwitchBox-B9JqwDtN.cjs.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-CH-F6_ax.cjs → TextArea-BqQtlPSV.cjs} +14 -13
- package/dist/{TextArea-CH-F6_ax.cjs.map → TextArea-BqQtlPSV.cjs.map} +1 -1
- package/dist/{TextArea-BR6e-Fio.js → TextArea-DAx49KI6.js} +7 -6
- package/dist/{TextArea-BR6e-Fio.js.map → TextArea-DAx49KI6.js.map} +1 -1
- package/dist/helpers/index.cjs +2 -1
- package/dist/helpers/index.d.cts +164 -2
- package/dist/helpers/index.d.cts.map +1 -0
- package/dist/helpers/index.d.ts +164 -2
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +2 -2
- package/dist/{helpers-B-CJOBt3.js → helpers-CCINRgQk.js} +43 -2
- package/dist/helpers-CCINRgQk.js.map +1 -0
- package/dist/{helpers-KTgXi0lA.cjs → helpers-nYTmL2gX.cjs} +51 -4
- package/dist/helpers-nYTmL2gX.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/useClientValidation/index.js +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.cts +1 -1
- package/dist/hooks/useController/index.d.ts +2 -2
- package/dist/hooks/useController/index.js +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +2 -2
- package/dist/hooks/useFormContext/index.js +1 -1
- 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/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +1 -1
- package/dist/hooks/useInputValueTransform/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +4 -4
- 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 +5 -5
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
- package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
- package/dist/hooks/useWatchUserChange/index.js +1 -1
- package/dist/{index-BJ7tmJCw.d.cts → index-0wXxS5M7.d.ts} +6 -6
- package/dist/{index-DJFrZluU.d.ts.map → index-0wXxS5M7.d.ts.map} +1 -1
- package/dist/{index-ATMELmS_.d.ts → index-1Egh73pR.d.ts} +3 -3
- package/dist/{index-ATMELmS_.d.ts.map → index-1Egh73pR.d.ts.map} +1 -1
- package/dist/{index-BO2gua86.d.ts → index-3v_vja2i.d.ts} +6 -6
- package/dist/{index-BO2gua86.d.ts.map → index-3v_vja2i.d.ts.map} +1 -1
- package/dist/{index-DG83pAQU.d.cts → index-7mx-IcDp.d.ts} +1 -1
- package/dist/{index-cvKMShf8.d.ts.map → index-7mx-IcDp.d.ts.map} +1 -1
- package/dist/{index-DJFrZluU.d.ts → index-BDV3JVoX.d.cts} +7 -7
- package/dist/{index-BJ7tmJCw.d.cts.map → index-BDV3JVoX.d.cts.map} +1 -1
- package/dist/{index-BSJlD_z1.d.ts → index-BFLKkqA3.d.ts} +3 -3
- package/dist/{index-BSJlD_z1.d.ts.map → index-BFLKkqA3.d.ts.map} +1 -1
- package/dist/{index-DrAaB1si.d.cts → index-BGXgvZKr.d.ts} +36 -35
- package/dist/{index-BMSwSLB0.d.ts.map → index-BGXgvZKr.d.ts.map} +1 -1
- package/dist/{index-Ce5d5ud1.d.ts → index-BSjUaHEO.d.cts} +4 -4
- package/dist/{index-CuZ0szCF.d.cts.map → index-BSjUaHEO.d.cts.map} +1 -1
- package/dist/{index-BFMNC6rA.d.cts → index-B_aIzCcx.d.cts} +3 -3
- package/dist/{index-BFMNC6rA.d.cts.map → index-B_aIzCcx.d.cts.map} +1 -1
- package/dist/{index-CuZ0szCF.d.cts → index-Bcppi5O7.d.ts} +4 -4
- package/dist/{index-Ce5d5ud1.d.ts.map → index-Bcppi5O7.d.ts.map} +1 -1
- package/dist/{index-C1GCfD5q.d.cts → index-C2A_i57R.d.cts} +21 -21
- package/dist/index-C2A_i57R.d.cts.map +1 -0
- package/dist/{index-DHTrsq8u.d.cts → index-CHNp5R5N.d.cts} +6 -6
- package/dist/{index-DHTrsq8u.d.cts.map → index-CHNp5R5N.d.cts.map} +1 -1
- package/dist/{index-Cb0AgRRa.d.cts → index-CHXv_rNR.d.ts} +3 -3
- package/dist/{index-CQXf1sXV.d.ts.map → index-CHXv_rNR.d.ts.map} +1 -1
- package/dist/{index-t8GMrjmp.d.cts → index-CTp4vdDb.d.ts} +6 -6
- package/dist/{index-B5K7Sos4.d.ts.map → index-CTp4vdDb.d.ts.map} +1 -1
- package/dist/{index-0l1ioOFh.d.cts → index-CUn9q5KD.d.ts} +6 -6
- package/dist/{index-BDBmlcs9.d.ts.map → index-CUn9q5KD.d.ts.map} +1 -1
- package/dist/{index-CpPCHyTk.d.cts → index-CZyNkPDq.d.ts} +22 -22
- package/dist/index-CZyNkPDq.d.ts.map +1 -0
- package/dist/{index-CqIAvXWT.d.ts → index-CeYRsehb.d.cts} +22 -22
- package/dist/index-CeYRsehb.d.cts.map +1 -0
- package/dist/{index-B5K7Sos4.d.ts → index-CiF2KXB7.d.cts} +3 -3
- package/dist/{index-t8GMrjmp.d.cts.map → index-CiF2KXB7.d.cts.map} +1 -1
- package/dist/{index-BMSwSLB0.d.ts → index-CjJHVJwD.d.cts} +35 -36
- package/dist/{index-DrAaB1si.d.cts.map → index-CjJHVJwD.d.cts.map} +1 -1
- package/dist/{index-DUAqAErG.d.cts → index-CnsR8nkm.d.cts} +34 -34
- package/dist/{index-DUAqAErG.d.cts.map → index-CnsR8nkm.d.cts.map} +1 -1
- package/dist/{index-C32OyAvG.d.ts → index-CqGabrzW.d.cts} +37 -37
- package/dist/{index-BIt4xz_x.d.cts.map → index-CqGabrzW.d.cts.map} +1 -1
- package/dist/{index-cvKMShf8.d.ts → index-CuvvZMop.d.cts} +3 -3
- package/dist/{index-DG83pAQU.d.cts.map → index-CuvvZMop.d.cts.map} +1 -1
- package/dist/{index-BmW4khHl.d.cts → index-DNFUttM8.d.ts} +48 -48
- package/dist/index-DNFUttM8.d.ts.map +1 -0
- package/dist/{index-D6qgJDAm.d.ts → index-DVRtBywt.d.ts} +3 -3
- package/dist/{index-D6qgJDAm.d.ts.map → index-DVRtBywt.d.ts.map} +1 -1
- package/dist/{index-BDBmlcs9.d.ts → index-D_WidR7r.d.cts} +6 -6
- package/dist/{index-0l1ioOFh.d.cts.map → index-D_WidR7r.d.cts.map} +1 -1
- package/dist/index-D_egu-QT.d.cts +264 -0
- package/dist/{index-BNdmJR51.d.cts.map → index-D_egu-QT.d.cts.map} +1 -1
- package/dist/index-DajjPPWM.d.ts +264 -0
- package/dist/{index-Da-quK_d.d.ts.map → index-DajjPPWM.d.ts.map} +1 -1
- package/dist/{index-BLmXGxoy.d.ts → index-DcYFLiul.d.cts} +48 -48
- package/dist/index-DcYFLiul.d.cts.map +1 -0
- package/dist/{index-DiC-e6iW.d.ts → index-DnzC0GCS.d.ts} +4 -4
- package/dist/{index-DiC-e6iW.d.ts.map → index-DnzC0GCS.d.ts.map} +1 -1
- package/dist/{index-ByDAUZR8.d.cts → index-DvF_C1Bz.d.cts} +3 -3
- package/dist/{index-ByDAUZR8.d.cts.map → index-DvF_C1Bz.d.cts.map} +1 -1
- package/dist/{index-CQXf1sXV.d.ts → index-cadUZZIY.d.cts} +3 -3
- package/dist/{index-Cb0AgRRa.d.cts.map → index-cadUZZIY.d.cts.map} +1 -1
- package/dist/{index-cda9yEEN.d.cts → index-g9TZhGnE.d.cts} +3 -3
- package/dist/{index-cda9yEEN.d.cts.map → index-g9TZhGnE.d.cts.map} +1 -1
- package/dist/{index-BCXuFO6D.d.ts → index-op7zETAQ.d.ts} +34 -34
- package/dist/{index-BCXuFO6D.d.ts.map → index-op7zETAQ.d.ts.map} +1 -1
- package/dist/{index-BIt4xz_x.d.cts → index-yVkU2v6b.d.ts} +38 -38
- package/dist/index-yVkU2v6b.d.ts.map +1 -0
- package/dist/index.cjs +30 -29
- package/dist/index.d.cts +28 -28
- package/dist/index.d.ts +30 -30
- package/dist/index.js +27 -27
- 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-CbRkwhHc.d.ts → useClientValidation-Bg0q3Axc.d.ts} +3 -3
- package/dist/{useClientValidation-CbRkwhHc.d.ts.map → useClientValidation-Bg0q3Axc.d.ts.map} +1 -1
- package/dist/{useClientValidation-BnnscAEe.js → useClientValidation-BrTtRnqi.js} +3 -3
- package/dist/useClientValidation-BrTtRnqi.js.map +1 -0
- package/dist/{useClientValidation-DdRlhoG1.d.cts → useClientValidation-BvPDQmf6.d.cts} +3 -3
- package/dist/{useClientValidation-DdRlhoG1.d.cts.map → useClientValidation-BvPDQmf6.d.cts.map} +1 -1
- package/dist/{useClientValidation-oZd4_ocQ.cjs → useClientValidation-CdC7lEYP.cjs} +7 -7
- package/dist/useClientValidation-CdC7lEYP.cjs.map +1 -0
- package/dist/{useController-C_MZLZIp.d.cts → useController-BArZd2Vp.d.cts} +1 -1
- package/dist/{useController-C_MZLZIp.d.cts.map → useController-BArZd2Vp.d.cts.map} +1 -1
- package/dist/{useController-BzkCcbSo.cjs → useController-BBxji1nQ.cjs} +3 -3
- package/dist/{useController-BzkCcbSo.cjs.map → useController-BBxji1nQ.cjs.map} +1 -1
- package/dist/{useController-hjpJQf0w.d.ts → useController-MVHJ7WFp.d.ts} +1 -1
- package/dist/{useController-hjpJQf0w.d.ts.map → useController-MVHJ7WFp.d.ts.map} +1 -1
- package/dist/{useController-CumIERks.js → useController-g0AlWM__.js} +3 -3
- package/dist/{useController-CumIERks.js.map → useController-g0AlWM__.js.map} +1 -1
- package/dist/{useFormContext-CFwuH4nn.d.cts → useFormContext--yod5xzQ.d.cts} +3 -3
- package/dist/useFormContext--yod5xzQ.d.cts.map +1 -0
- package/dist/{useFormContext-JCm1UR_e.js → useFormContext-BFoXZNkp.js} +3 -3
- package/dist/useFormContext-BFoXZNkp.js.map +1 -0
- package/dist/{useFormContext-CWuN-_7P.cjs → useFormContext-CEr3zcL6.cjs} +3 -3
- package/dist/useFormContext-CEr3zcL6.cjs.map +1 -0
- package/dist/{useFormContext-3AAPT6eZ.d.ts → useFormContext-Cw6aAhos.d.ts} +3 -3
- package/dist/useFormContext-Cw6aAhos.d.ts.map +1 -0
- package/dist/{useInputValueDebounce-C7_bvNGH.d.ts → useInputValueDebounce-DI1C6oaU.d.cts} +5 -1
- package/dist/useInputValueDebounce-DI1C6oaU.d.cts.map +1 -0
- package/dist/{useInputValueDebounce-DaH5ONlQ.js → useInputValueDebounce-Dop_8_OK.js} +12 -3
- package/dist/useInputValueDebounce-Dop_8_OK.js.map +1 -0
- package/dist/{useInputValueDebounce-tL8maIp8.cjs → useInputValueDebounce-TiNR4jtG.cjs} +13 -4
- package/dist/useInputValueDebounce-TiNR4jtG.cjs.map +1 -0
- package/dist/{useInputValueDebounce-B2RzCWty.d.cts → useInputValueDebounce-fhmVn1aO.d.ts} +5 -1
- package/dist/useInputValueDebounce-fhmVn1aO.d.ts.map +1 -0
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs → useInputValueTransform-BNmfaj5D.cjs} +4 -3
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs.map → useInputValueTransform-BNmfaj5D.cjs.map} +1 -1
- package/dist/{useInputValueTransform-D7LfyYRe.d.ts → useInputValueTransform-BV8o0PMI.d.cts} +3 -2
- package/dist/useInputValueTransform-BV8o0PMI.d.cts.map +1 -0
- package/dist/{useInputValueTransform-aiIf8lq5.js → useInputValueTransform-CMNC21vX.js} +3 -2
- package/dist/{useInputValueTransform-aiIf8lq5.js.map → useInputValueTransform-CMNC21vX.js.map} +1 -1
- package/dist/{useInputValueTransform-BID-CQ-y.d.cts → useInputValueTransform-Cc0qEsnS.d.ts} +3 -2
- package/dist/useInputValueTransform-Cc0qEsnS.d.ts.map +1 -0
- package/dist/{useUniformField-u_7uBpco.d.cts → useUniformField-B2zQtEbr.d.cts} +5 -5
- package/dist/{useUniformField-u_7uBpco.d.cts.map → useUniformField-B2zQtEbr.d.cts.map} +1 -1
- package/dist/{useUniformField-ClprfrES.js → useUniformField-BKVVns0E.js} +34 -8
- package/dist/useUniformField-BKVVns0E.js.map +1 -0
- package/dist/{useUniformField-BMvnRC_r.cjs → useUniformField-D6fwSjrH.cjs} +41 -15
- package/dist/useUniformField-D6fwSjrH.cjs.map +1 -0
- package/dist/{useUniformField-DDHQ5B11.d.ts → useUniformField-RxZqXMuD.d.ts} +5 -5
- package/dist/{useUniformField-DDHQ5B11.d.ts.map → useUniformField-RxZqXMuD.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-BhPi3gPv.d.ts → useUniformFieldArray-B_c55CnX.d.ts} +3 -3
- package/dist/useUniformFieldArray-B_c55CnX.d.ts.map +1 -0
- package/dist/{useUniformFieldArray-C-0OXG3N.js → useUniformFieldArray-BwE634m6.js} +4 -4
- package/dist/useUniformFieldArray-BwE634m6.js.map +1 -0
- package/dist/{useUniformFieldArray-btjvJdZ6.cjs → useUniformFieldArray-Byfmzq97.cjs} +7 -7
- package/dist/useUniformFieldArray-Byfmzq97.cjs.map +1 -0
- package/dist/{useUniformFieldArray-D3lsJvhA.d.cts → useUniformFieldArray-WRuIMhw6.d.cts} +3 -3
- package/dist/useUniformFieldArray-WRuIMhw6.d.cts.map +1 -0
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts → useWatchUserChange-Bf5JKDJJ.d.ts} +1 -1
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts.map → useWatchUserChange-Bf5JKDJJ.d.ts.map} +1 -1
- package/dist/{useWatchUserChange-COVdHmki.d.cts → useWatchUserChange-Br4Q7syM.d.cts} +1 -1
- package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-Br4Q7syM.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-C5dr12By.cjs → useWatchUserChange-TMfaTCcp.cjs} +3 -3
- package/dist/{useWatchUserChange-C5dr12By.cjs.map → useWatchUserChange-TMfaTCcp.cjs.map} +1 -1
- package/dist/{useWatchUserChange-C1ezpj0t.js → useWatchUserChange-fZy6nGtD.js} +2 -2
- package/dist/{useWatchUserChange-C1ezpj0t.js.map → useWatchUserChange-fZy6nGtD.js.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/FormContext-CN9n_KdE.js.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-B-CJOBt3.js.map +0 -1
- package/dist/helpers-KTgXi0lA.cjs.map +0 -1
- package/dist/index-BLmXGxoy.d.ts.map +0 -1
- package/dist/index-BNdmJR51.d.cts +0 -264
- package/dist/index-BmW4khHl.d.cts.map +0 -1
- package/dist/index-C1GCfD5q.d.cts.map +0 -1
- package/dist/index-C32OyAvG.d.ts.map +0 -1
- package/dist/index-CpPCHyTk.d.cts.map +0 -1
- package/dist/index-CqIAvXWT.d.ts.map +0 -1
- package/dist/index-Da-quK_d.d.ts +0 -264
- package/dist/index-G0IgQWoU.d.cts +0 -134
- package/dist/index-G0IgQWoU.d.cts.map +0 -1
- package/dist/index-UjKqRe-8.d.ts +0 -134
- package/dist/index-UjKqRe-8.d.ts.map +0 -1
- package/dist/useClientValidation-BnnscAEe.js.map +0 -1
- package/dist/useClientValidation-oZd4_ocQ.cjs.map +0 -1
- package/dist/useFormContext-3AAPT6eZ.d.ts.map +0 -1
- package/dist/useFormContext-CFwuH4nn.d.cts.map +0 -1
- package/dist/useFormContext-CWuN-_7P.cjs.map +0 -1
- package/dist/useFormContext-JCm1UR_e.js.map +0 -1
- package/dist/useInputValueDebounce-B2RzCWty.d.cts.map +0 -1
- package/dist/useInputValueDebounce-C7_bvNGH.d.ts.map +0 -1
- package/dist/useInputValueDebounce-DaH5ONlQ.js.map +0 -1
- package/dist/useInputValueDebounce-tL8maIp8.cjs.map +0 -1
- package/dist/useInputValueTransform-BID-CQ-y.d.cts.map +0 -1
- package/dist/useInputValueTransform-D7LfyYRe.d.ts.map +0 -1
- package/dist/useUniformField-BMvnRC_r.cjs.map +0 -1
- package/dist/useUniformField-ClprfrES.js.map +0 -1
- package/dist/useUniformFieldArray-BhPi3gPv.d.ts.map +0 -1
- package/dist/useUniformFieldArray-C-0OXG3N.js.map +0 -1
- package/dist/useUniformFieldArray-D3lsJvhA.d.cts.map +0 -1
- package/dist/useUniformFieldArray-btjvJdZ6.cjs.map +0 -1
- /package/dist/{index-B3Z8gdjC.d.ts → index-BRLjimYW.d.ts} +0 -0
- /package/dist/{index-BXpMZvwA.d.cts → index-CFBmva_r.d.ts} +0 -0
- /package/dist/{index-CJNLQVjx.d.ts → index-DpEKQcoR.d.cts} +0 -0
- /package/dist/{index-CwSIy_W-.d.cts → index-lQ_hGQ08.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-UjKqRe-8.d.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
//#region src/helpers/nullishFields/nullishFields.d.ts
|
|
2
|
-
/** Key used to wrap flat array elements when converting to form format */
|
|
3
|
-
declare const flatArrayKey = "__FLAT__";
|
|
4
|
-
/**
|
|
5
|
-
* Converts marker strings back to their original values when processing arrays
|
|
6
|
-
*/
|
|
7
|
-
declare const fromNullishString: (value: unknown) => unknown;
|
|
8
|
-
/**
|
|
9
|
-
* Converts null/falsy values to marker strings for JSON processing
|
|
10
|
-
*/
|
|
11
|
-
declare const toNullishString: (value: unknown) => unknown;
|
|
12
|
-
/**
|
|
13
|
-
* Converts field values to a format suitable for forms by:
|
|
14
|
-
* - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`
|
|
15
|
-
* to satisfy RHF's requirement that array fields contain objects
|
|
16
|
-
* - Removing empty strings and null values from objects
|
|
17
|
-
*
|
|
18
|
-
* This conversion is required because React Hook Form does not support arrays with
|
|
19
|
-
* flat values (string, number, boolean, null). Array fields must contain objects.
|
|
20
|
-
* We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* const fields = {
|
|
24
|
-
* name: 'John',
|
|
25
|
-
* scores: [0, null, 75, false],
|
|
26
|
-
* scoresDetailed: [
|
|
27
|
-
* { score: 1 },
|
|
28
|
-
* { score: null },
|
|
29
|
-
* { score: 0 },
|
|
30
|
-
* { score: false },
|
|
31
|
-
* { score: '' },
|
|
32
|
-
* ],
|
|
33
|
-
* contact: {
|
|
34
|
-
* email: '',
|
|
35
|
-
* phone: null,
|
|
36
|
-
* address: '123 Main St'
|
|
37
|
-
* }
|
|
38
|
-
* };
|
|
39
|
-
*
|
|
40
|
-
* // Result:
|
|
41
|
-
* {
|
|
42
|
-
* name: 'John',
|
|
43
|
-
* scores: [
|
|
44
|
-
* { __FLAT__: 0 },
|
|
45
|
-
* { __FLAT__: null },
|
|
46
|
-
* { __FLAT__: 75 },
|
|
47
|
-
* { __FLAT__: false }
|
|
48
|
-
* ],
|
|
49
|
-
* // Arrays of objects are left as objects; empty/null properties are removed
|
|
50
|
-
* scoresDetailed: [
|
|
51
|
-
* { score: 1 },
|
|
52
|
-
* {}, // null score removed
|
|
53
|
-
* { score: 0 },
|
|
54
|
-
* { score: false },
|
|
55
|
-
* {}, // empty string removed
|
|
56
|
-
* ],
|
|
57
|
-
* contact: {
|
|
58
|
-
* address: '123 Main St'
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
*/
|
|
62
|
-
declare const toFormFormat: (fields: Record<string, unknown>) => Record<string, unknown>;
|
|
63
|
-
/**
|
|
64
|
-
* Converts form state to a format suitable for validation by:
|
|
65
|
-
* - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives
|
|
66
|
-
* - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values
|
|
67
|
-
* - Removing fields whose converted value is empty string or null
|
|
68
|
-
* - Removing empty arrays
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* const formState = {
|
|
72
|
-
* name: 'John',
|
|
73
|
-
* scores: [
|
|
74
|
-
* { __FLAT__: 75 },
|
|
75
|
-
* { __FLAT__: 0 },
|
|
76
|
-
* { __FLAT__: null },
|
|
77
|
-
* { __FLAT__: false }
|
|
78
|
-
* ],
|
|
79
|
-
* emptyArray: [],
|
|
80
|
-
* scoresDetailed: [
|
|
81
|
-
* { score: 1 },
|
|
82
|
-
* {},
|
|
83
|
-
* { score: 0 },
|
|
84
|
-
* { score: false },
|
|
85
|
-
* {},
|
|
86
|
-
* ],
|
|
87
|
-
* contact: {
|
|
88
|
-
* address: '123 Main St',
|
|
89
|
-
* fax: null
|
|
90
|
-
* }
|
|
91
|
-
* };
|
|
92
|
-
*
|
|
93
|
-
* // Result:
|
|
94
|
-
* {
|
|
95
|
-
* name: 'John',
|
|
96
|
-
* scores: [75, 0, null, false],
|
|
97
|
-
* // emptyArray is removed
|
|
98
|
-
* // Objects inside arrays remain objects; empty entries remain empty objects
|
|
99
|
-
* scoresDetailed: [
|
|
100
|
-
* { score: 1 },
|
|
101
|
-
* {},
|
|
102
|
-
* { score: 0 },
|
|
103
|
-
* { score: false },
|
|
104
|
-
* {},
|
|
105
|
-
* ],
|
|
106
|
-
* contact: {
|
|
107
|
-
* address: '123 Main St'
|
|
108
|
-
* }
|
|
109
|
-
* }
|
|
110
|
-
*/
|
|
111
|
-
declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* Converts a field name to a testId by removing flat array key segments and slugifying.
|
|
114
|
-
* Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
|
|
115
|
-
*
|
|
116
|
-
* This is used to generate stable testIds for form fields that don't include
|
|
117
|
-
* the internal `__FLAT__` marker used for flat arrays.
|
|
118
|
-
*
|
|
119
|
-
* @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])
|
|
120
|
-
* @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* nameToTestId('tags.0.__FLAT__') // => 'tags_0'
|
|
125
|
-
* nameToTestId('array.0.__FLAT__') // => 'array_0'
|
|
126
|
-
* nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'
|
|
127
|
-
* nameToTestId('simple.field') // => 'simple_field'
|
|
128
|
-
* nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
declare const nameToTestId: (name: string | readonly string[]) => string;
|
|
132
|
-
//#endregion
|
|
133
|
-
export { toNullishString as a, toFormFormat as i, fromNullishString as n, toValidationFormat as o, nameToTestId as r, flatArrayKey as t };
|
|
134
|
-
//# sourceMappingURL=index-UjKqRe-8.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-UjKqRe-8.d.ts","names":[],"sources":["../src/helpers/nullishFields/nullishFields.ts"],"sourcesContent":[],"mappings":";;AAGa,cAAA,YAAA,GAAY,UAAA;AAYzB;AAsCA;AA6EA;AA2Ea,cA9LA,iBA+LA,EAAA,CAAA,KACV,EAAA,OAAM,EAAA,GAAA,OAAA;AAgGT;;;cA1Pa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6EA,uBAAwB,4BAwBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmD1B,gCACA,+CACV;;;;;;;;;;;;;;;;;;;;cAgGU"}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useClientValidation-oZd4_ocQ.cjs","names":["useFormContext","schema: VetoTypeAny","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,IAAIC,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,sCAAe,OAAO,CAAC,UAAU;OAC5B;GAGL,MAAM,wCAAkB,GACrB,UAAU,QACZ,CAAC;AACF,YAAS,IAAI,IAAI,IAAI,UAAU,GAAG;;;AAItC,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-3AAPT6eZ.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-CFwuH4nn.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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-CWuN-_7P.cjs","names":["flatArrayKey","current: unknown","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,IAAIC,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-JCm1UR_e.js","names":["current: unknown","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,IAAIA,UAAmB;AACvB,MAAK,SAAS,QAAQ;AACpB,MAAI,WAAW,OAAO,YAAY,SAChC,WAAW,QAAoC;MAE/C,WAAU;GAEZ;AACF,QAAO;;;;;;;;;;;;AAaT,MAAaC,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-B2RzCWty.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-C7_bvNGH.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-DaH5ONlQ.js","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,mBAAmB,SAAiB,MAAM;CAE/D,MAAM,aAAa,OAA8B,KAAK;AAGtD,iBAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAoDX,QAAO;EACL,UAlDmB,aAElB,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,QAZiB,kBAAkB;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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-tL8maIp8.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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueTransform-BID-CQ-y.d.cts","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAOA,cAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAA6B,GALR,QAKQ;EAO7B;EAwFJ,WAAA,EAAA,CAAA,KAAA,EAlGU,QA0JtB,EAAA,GAAA,OAAA;;AAxD0D,UA/F1C,6BA+F0C,CAAA,WAAA,OAAA,CAAA,CAAA;EAG1B;EAA9B,IAAA,CAAA,EAAA,MAAA,GAAA,QAAA,GAAA,UAAA;EAAuE;EAA7B,SAAA,CAAA,EA9F/B,mBA8F+B,CA9FX,QA8FW,CAAA;;UA3F5B;;0CAEyB;;8BAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoFjB;;;GAGV,8BAA8B,cAAY,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueTransform-D7LfyYRe.d.ts","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAOA,cAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAA6B,GALR,QAKQ;EAO7B;EAwFJ,WAAA,EAAA,CAAA,KAAA,EAlGU,QA0JtB,EAAA,GAAA,OAAA;;AAxD0D,UA/F1C,6BA+F0C,CAAA,WAAA,OAAA,CAAA,CAAA;EAG1B;EAA9B,IAAA,CAAA,EAAA,MAAA,GAAA,QAAA,GAAA,UAAA;EAAuE;EAA7B,SAAA,CAAA,EA9F/B,mBA8F+B,CA9FX,QA8FW,CAAA;;UA3F5B;;0CAEyB;;8BAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoFjB;;;GAGV,8BAA8B,cAAY,6BAA6B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-BMvnRC_r.cjs","names":["useFormContext","useController","useInputValueTransform","labelNode: ReactNode | null","FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { isTestEnvironment } from '@fuf-stack/pixel-utils';\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Debounce invalid state changes to prevent UI flicker on rapid changes.\n *\n * Primary purpose: Reduce UI flicker when validation state changes rapidly\n * (e.g., during fast typing). Without debouncing, error messages would flash\n * in/out rapidly, creating a poor UX.\n *\n * Secondary benefit: When animations are enabled (default), gives time for\n * enter/exit animations to complete smoothly.\n *\n * Behavior:\n * - Debounces both true → false and false → true transitions by `delayMs`\n * - Disabled in test environments for immediate snapshots\n */\nconst useDebouncedInvalid = (invalid: boolean, delayMs: number) => {\n const debouncedInvalid = useDebounce(invalid, delayMs);\n\n // Disable debouncing in test environments for immediate snapshots\n if (isTestEnvironment()) {\n return invalid;\n }\n\n return debouncedInvalid;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,uDAA+B,SAAS,QAAQ;AAGtD,qDAAuB,CACrB,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGT,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACEA,uCAA8B;CAElC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,eAAe;CAEvC,MAAM,EAAE,UAAUC,oCAA4B;EAC5C;EACA;EACA;EACD,CAAC;CACF,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgBC,sDAAiC;EACvE;EACA;EACD,CAAC;CAGF,MAAM,mBAAmB,eAAe,WAAW;CACnD,MAAM,uBAAuB,iBAA+C;AAM1E,gBADkB,YAFf,cAAsD,QAAQ,SAC/D,aACqD,CACV;;CAG/C,MAAM,eAAgB,WAAW,GAC/B;CAsBF,MAAM,UAAU,oBADI,eAAe,WAAW,aAAa,cAAc,IACxB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAMC,YACJ,CAAC,CAAC,SAAS,uBACT,qFACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,2CAACC,iEAA8B,SAAU,GACvC,QACH,GACD;CAIN,MAAM,eAAe,2CAACC;EAA4B;EAAe;GAAU;CAK3E,MAAM,EAAE,sBAAsB,eAAe,uDAClC;EACP;EACA,YAAY,EAEV,eAAe,OAChB;EACD,cAAc,KAAK,UAAU,MAAM;EACnC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EACjB,CAAC;AAQJ,QAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;GACX;EACD;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-ClprfrES.js","names":["labelNode: ReactNode | null","FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { isTestEnvironment } from '@fuf-stack/pixel-utils';\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Debounce invalid state changes to prevent UI flicker on rapid changes.\n *\n * Primary purpose: Reduce UI flicker when validation state changes rapidly\n * (e.g., during fast typing). Without debouncing, error messages would flash\n * in/out rapidly, creating a poor UX.\n *\n * Secondary benefit: When animations are enabled (default), gives time for\n * enter/exit animations to complete smoothly.\n *\n * Behavior:\n * - Debounces both true → false and false → true transitions by `delayMs`\n * - Disabled in test environments for immediate snapshots\n */\nconst useDebouncedInvalid = (invalid: boolean, delayMs: number) => {\n const debouncedInvalid = useDebounce(invalid, delayMs);\n\n // Disable debouncing in test environments for immediate snapshots\n if (isTestEnvironment()) {\n return invalid;\n }\n\n return debouncedInvalid;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,mBAAmB,YAAY,SAAS,QAAQ;AAGtD,KAAI,mBAAmB,CACrB,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGT,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACE,gBAA8B;CAElC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,eAAe;CAEvC,MAAM,EAAE,UAAU,cAA4B;EAC5C;EACA;EACA;EACD,CAAC;CACF,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;EACD,CAAC;CAGF,MAAM,mBAAmB,eAAe,WAAW;CACnD,MAAM,uBAAuB,iBAA+C;AAM1E,gBADkB,YAFf,cAAsD,QAAQ,SAC/D,aACqD,CACV;;CAG/C,MAAM,eAAgB,WAAW,GAC/B;CAsBF,MAAM,UAAU,oBADI,eAAe,WAAW,aAAa,cAAc,IACxB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAMA,YACJ,CAAC,CAAC,SAAS,uBACT,4CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAACC,iCAA8B,SAAU,GACvC,QACH,GACD;CAIN,MAAM,eAAe,oBAACC;EAA4B;EAAe;GAAU;CAK3E,MAAM,EAAE,sBAAsB,eAAe,0BAC3C,SAAS;EACP;EACA,YAAY,EAEV,eAAe,OAChB;EACD,cAAc,KAAK,UAAU,MAAM;EACnC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EACjB,CAAC;AAQJ,QAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;GACX;EACD;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-BhPi3gPv.d.ts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,+CACM,cAAc;;QAG7B,UAAU;;;EAJD;EACM,mBAAA,CAAA,EAAA,OAAA;EAAc;EAGnB,uBAAA,CAAA,EAAA,OAAA;EAAV;EAYE,QAAA,CAAA,EAAA,OAAA;EAAS;EAeN,MAAA,CAAA,EAAA,MAAA;EACU;EAAc,KAAA,CAAA,EAhB3B,SAgB2B;;;;;;;;;;;;;;cADxB,4CACU,cAAc;;;uBACnC;;;UAAA;;GAQC,0BAA0B;;;;;;;;;;;;;;;;;EA0DF,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,sBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EACiD,QAAA,EAAA,UAAA,CAAA,OADjD,eACiD,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EAGnC,UAHmC,CAAA,OAAA,eAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGnC,QAAA,EAAA,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-C-0OXG3N.js","names":["useRHFFieldArray","useFormContext"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAe,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,SAASA,cAAiB;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,kBAA8B;CAQ5D,MAAM,kBAAkB,cAAc;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,iBAAiB,OAAO,CAAC,gBAAgB;AAK/C,iBAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAIrB,iBAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AAEf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAI9D,MAAM,uBAAuB,kBAAkB;AAC/C,iBAAgB;AACd,MAAI,eAAe,QACjB,qBAAoB,CAAC,CAAC,qBAAqB;IAE5C,CAAC,qBAAqB,CAAC;CAK1B,MAAM,sBAAsB,cAAc;AACxC,SAAO,OACH,GAAG,eAAe,wBAAwB,MAAM,GAC/C,wBAAwB,EAAE;IAC9B,CAAC,MAAM,qBAAqB,CAAC;AAUhC,iBACQ;AACJ,MAAI,iBAAiB;AAGnB,YAAS,MAA4B,CAAC,oBAAoB,EAAS;IACjE,aAAa;IACb,aAAa;IACd,CAAC;AAGF,kBAAe,UAAU;AAKzB,OAAI,CAAC,wBAAwB,iBAC3B,kBAAiB;AACf,wBAAoB,MAAM;MACzB,EAAE;;IAUX,CAAC,gBAAgB,CAClB;AAED,QAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;EACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-D3lsJvhA.d.cts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,+CACM,cAAc;;QAG7B,UAAU;;;EAJD;EACM,mBAAA,CAAA,EAAA,OAAA;EAAc;EAGnB,uBAAA,CAAA,EAAA,OAAA;EAAV;EAYE,QAAA,CAAA,EAAA,OAAA;EAAS;EAeN,MAAA,CAAA,EAAA,MAAA;EACU;EAAc,KAAA,CAAA,EAhB3B,SAgB2B;;;;;;;;;;;;;;cADxB,4CACU,cAAc;;;uBACnC;;;UAAA;;GAQC,0BAA0B;;;;;;;;;;;;;;;;;EA0DF,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,oBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EACiD,QAAA,EAAA,UAAA,CAAA,OADjD,aACiD,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EAGnC,UAHmC,CAAA,OAAA,aAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGnC,QAAA,EAAA,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-btjvJdZ6.cjs","names":["useUniformField","useFormContext","flatArrayKey"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAeA,wCAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,4CAA0B;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,uCAA8B;CAQ5D,MAAM,2CAAgC;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,mCAAwB,CAAC,gBAAgB;AAK/C,4BAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAIrB,4BAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AAEf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,2CAAgC,KAAK;CAI9D,MAAM,uEAAyC;AAC/C,4BAAgB;AACd,MAAI,eAAe,QACjB,qBAAoB,CAAC,CAAC,qBAAqB;IAE5C,CAAC,qBAAqB,CAAC;CAK1B,MAAM,+CAAoC;AACxC,SAAO,OACH,GAAGC,+BAAe,wBAAwB,MAAM,GAC/C,wBAAwB,EAAE;IAC9B,CAAC,MAAM,qBAAqB,CAAC;AAUhC,4BACQ;AACJ,MAAI,iBAAiB;AAGnB,YAAS,MAA4B,CAAC,oBAAoB,EAAS;IACjE,aAAa;IACb,aAAa;IACd,CAAC;AAGF,kBAAe,UAAU;AAKzB,OAAI,CAAC,wBAAwB,iBAC3B,kBAAiB;AACf,wBAAoB,MAAM;MACzB,EAAE;;IAUX,CAAC,gBAAgB,CAClB;AAED,QAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;EACJ"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|