@fuf-stack/uniform 1.11.3 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checkboxes/index.cjs +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-BvW4D5Nm.js → Checkboxes-BEW0I_YR.js} +2 -2
- package/dist/{Checkboxes-BvW4D5Nm.js.map → Checkboxes-BEW0I_YR.js.map} +1 -1
- package/dist/{Checkboxes-Cvdazf25.cjs → Checkboxes-DC-7EBOm.cjs} +4 -4
- package/dist/{Checkboxes-Cvdazf25.cjs.map → Checkboxes-DC-7EBOm.cjs.map} +1 -1
- 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-CJpDgK_t.cjs → FieldArray-BA0jdPi-.cjs} +7 -7
- package/dist/{FieldArray-CJpDgK_t.cjs.map → FieldArray-BA0jdPi-.cjs.map} +1 -1
- package/dist/{FieldArray-omRNwxgy.js → FieldArray-BBRdAk7J.js} +4 -4
- package/dist/{FieldArray-omRNwxgy.js.map → FieldArray-BBRdAk7J.js.map} +1 -1
- 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-Dyi-2qr6.js → FieldCard-24ogRnQc.js} +2 -2
- package/dist/{FieldCard-Dyi-2qr6.js.map → FieldCard-24ogRnQc.js.map} +1 -1
- package/dist/{FieldCard-Dt6QU7o7.cjs → FieldCard-DxOqqbwN.cjs} +4 -4
- package/dist/{FieldCard-Dt6QU7o7.cjs.map → FieldCard-DxOqqbwN.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-By-hEZgA.cjs → FieldCopyTestIdButton-Dx3A8L6t.cjs} +2 -2
- package/dist/{FieldCopyTestIdButton-By-hEZgA.cjs.map → FieldCopyTestIdButton-Dx3A8L6t.cjs.map} +1 -1
- package/dist/{FieldValidationError-D64j5gnH.cjs → FieldValidationError-CY4sogEN.cjs} +2 -2
- package/dist/{FieldValidationError-D64j5gnH.cjs.map → FieldValidationError-CY4sogEN.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-CvnnGF45.cjs → Form-CT6qXH_3.cjs} +3 -3
- package/dist/{Form-CvnnGF45.cjs.map → Form-CT6qXH_3.cjs.map} +1 -1
- package/dist/{Form-B1fvbnxi.js → Form-GahmtDWp.js} +3 -3
- package/dist/{Form-B1fvbnxi.js.map → Form-GahmtDWp.js.map} +1 -1
- package/dist/{FormContext-Lw4YL4-B.cjs → FormContext-CwP_2mvE.cjs} +2 -2
- package/dist/{FormContext-Lw4YL4-B.cjs.map → FormContext-CwP_2mvE.cjs.map} +1 -1
- package/dist/{FormContext-Dl3k1r_k.js → FormContext-FJzj6Lel.js} +2 -2
- package/dist/{FormContext-Dl3k1r_k.js.map → FormContext-FJzj6Lel.js.map} +1 -1
- package/dist/Grid/index.cjs +1 -1
- package/dist/Grid/index.d.cts +1 -1
- package/dist/Grid/index.d.ts +1 -1
- package/dist/{Grid-DezBAZbx.cjs → Grid-DMdEI2za.cjs} +2 -2
- package/dist/{Grid-DezBAZbx.cjs.map → Grid-DMdEI2za.cjs.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-DksaHK1Y.js → Input-CjujXjtF.js} +3 -3
- package/dist/{Input-DksaHK1Y.js.map → Input-CjujXjtF.js.map} +1 -1
- package/dist/{Input-DR0gCf9q.cjs → Input-Df23py1O.cjs} +4 -4
- package/dist/{Input-DR0gCf9q.cjs.map → Input-Df23py1O.cjs.map} +1 -1
- 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-h-VLhJ9d.cjs → RadioBoxes-Bh1D-orY.cjs} +11 -7
- package/dist/RadioBoxes-Bh1D-orY.cjs.map +1 -0
- package/dist/{RadioBoxes-DdIHH6B5.js → RadioBoxes-DnQSlCPK.js} +10 -6
- package/dist/RadioBoxes-DnQSlCPK.js.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-dLdlF91p.js → RadioTabs-CF2zlZWy.js} +10 -6
- package/dist/RadioTabs-CF2zlZWy.js.map +1 -0
- package/dist/{RadioTabs-D6yF9jE3.cjs → RadioTabs-asb8ItEc.cjs} +11 -7
- package/dist/RadioTabs-asb8ItEc.cjs.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-DiZ0Dfmp.js → Radios-23CQE6rR.js} +10 -6
- package/dist/Radios-23CQE6rR.js.map +1 -0
- package/dist/{Radios-D8alyG2f.cjs → Radios-DtZT2ul2.cjs} +11 -7
- package/dist/Radios-DtZT2ul2.cjs.map +1 -0
- 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-C9otN8uu.js → Select-BrRJc9SK.js} +12 -7
- package/dist/Select-BrRJc9SK.js.map +1 -0
- package/dist/{Select-DQVskslz.cjs → Select-Ck-_vEPF.cjs} +13 -8
- package/dist/Select-Ck-_vEPF.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-meuLEC2k.js → Slider-BZ5DWUeo.js} +2 -2
- package/dist/{Slider-meuLEC2k.js.map → Slider-BZ5DWUeo.js.map} +1 -1
- package/dist/{Slider-DwfyCQDM.cjs → Slider-DKHLwbvB.cjs} +3 -3
- package/dist/{Slider-DwfyCQDM.cjs.map → Slider-DKHLwbvB.cjs.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-BHP9J9ml.js → SubmitButton-C6vkNIyu.js} +2 -2
- package/dist/{SubmitButton-BHP9J9ml.js.map → SubmitButton-C6vkNIyu.js.map} +1 -1
- package/dist/{SubmitButton-B0kvUqkd.cjs → SubmitButton-iKyzl3i2.cjs} +3 -3
- package/dist/{SubmitButton-B0kvUqkd.cjs.map → SubmitButton-iKyzl3i2.cjs.map} +1 -1
- package/dist/Switch/index.cjs +1 -1
- package/dist/Switch/index.d.cts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-Ds0gDzjR.cjs → Switch-B9RAUjZC.cjs} +3 -3
- package/dist/{Switch-Ds0gDzjR.cjs.map → Switch-B9RAUjZC.cjs.map} +1 -1
- package/dist/{Switch-DkciIYnD.js → Switch-DDgV6_QU.js} +2 -2
- package/dist/{Switch-DkciIYnD.js.map → Switch-DDgV6_QU.js.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-B6Z4rtWt.js → SwitchBox-72dpXO8I.js} +2 -2
- package/dist/{SwitchBox-B6Z4rtWt.js.map → SwitchBox-72dpXO8I.js.map} +1 -1
- package/dist/{SwitchBox-B9JqwDtN.cjs → SwitchBox-fNbronFu.cjs} +3 -3
- package/dist/{SwitchBox-B9JqwDtN.cjs.map → SwitchBox-fNbronFu.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-DAx49KI6.js → TextArea-BuOCICXv.js} +3 -3
- package/dist/{TextArea-DAx49KI6.js.map → TextArea-BuOCICXv.js.map} +1 -1
- package/dist/{TextArea-BqQtlPSV.cjs → TextArea-Cluaop2Y.cjs} +4 -4
- package/dist/{TextArea-BqQtlPSV.cjs.map → TextArea-Cluaop2Y.cjs.map} +1 -1
- package/dist/helpers/index.cjs +2 -1
- package/dist/helpers/index.d.cts +21 -1
- package/dist/helpers/index.d.cts.map +1 -1
- package/dist/helpers/index.d.ts +21 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/{helpers-CCINRgQk.js → helpers-DPGeUbNW.js} +36 -2
- package/dist/helpers-DPGeUbNW.js.map +1 -0
- package/dist/{helpers-nYTmL2gX.cjs → helpers-Dat6eNFF.cjs} +42 -2
- package/dist/helpers-Dat6eNFF.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.js +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.ts +1 -1
- package/dist/hooks/useFormContext/index.js +1 -1
- package/dist/hooks/useInput/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.ts +2 -2
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.ts +2 -2
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/hooks/useWatchUserChange/index.js +1 -1
- package/dist/{index-DNFUttM8.d.ts → index-2fccMklK.d.ts} +46 -46
- package/dist/index-2fccMklK.d.ts.map +1 -0
- package/dist/{index-D_WidR7r.d.cts → index-AaFOsx_O.d.cts} +6 -6
- package/dist/{index-D_WidR7r.d.cts.map → index-AaFOsx_O.d.cts.map} +1 -1
- package/dist/{index-CjJHVJwD.d.cts → index-B2mcCRjV.d.ts} +37 -36
- package/dist/{index-BGXgvZKr.d.ts.map → index-B2mcCRjV.d.ts.map} +1 -1
- package/dist/{index-CHXv_rNR.d.ts → index-B5BDC8Al.d.ts} +3 -3
- package/dist/{index-CHXv_rNR.d.ts.map → index-B5BDC8Al.d.ts.map} +1 -1
- package/dist/{index-CZyNkPDq.d.ts → index-BFQqVEJv.d.ts} +21 -21
- package/dist/{index-CZyNkPDq.d.ts.map → index-BFQqVEJv.d.ts.map} +1 -1
- package/dist/{index-CuvvZMop.d.cts → index-BGprebgQ.d.cts} +3 -3
- package/dist/{index-CuvvZMop.d.cts.map → index-BGprebgQ.d.cts.map} +1 -1
- package/dist/{index-yVkU2v6b.d.ts → index-BJtPrrAd.d.cts} +38 -38
- package/dist/{index-CqGabrzW.d.cts.map → index-BJtPrrAd.d.cts.map} +1 -1
- package/dist/{index-CeYRsehb.d.cts → index-BMbsKHMJ.d.cts} +21 -21
- package/dist/index-BMbsKHMJ.d.cts.map +1 -0
- package/dist/{index-B_aIzCcx.d.cts → index-BNu0EV5x.d.cts} +3 -3
- package/dist/{index-B_aIzCcx.d.cts.map → index-BNu0EV5x.d.cts.map} +1 -1
- package/dist/{index-7mx-IcDp.d.ts → index-BSOZdqA8.d.ts} +3 -3
- package/dist/{index-7mx-IcDp.d.ts.map → index-BSOZdqA8.d.ts.map} +1 -1
- package/dist/{index-cadUZZIY.d.cts → index-Bfk32Dl3.d.cts} +3 -3
- package/dist/{index-cadUZZIY.d.cts.map → index-Bfk32Dl3.d.cts.map} +1 -1
- package/dist/{index-BDV3JVoX.d.cts → index-BmrMk93O.d.ts} +6 -6
- package/dist/{index-0wXxS5M7.d.ts.map → index-BmrMk93O.d.ts.map} +1 -1
- package/dist/index-CA-MZNg5.d.cts +264 -0
- package/dist/index-CA-MZNg5.d.cts.map +1 -0
- package/dist/{index-op7zETAQ.d.ts → index-CawMnF16.d.ts} +35 -35
- package/dist/index-CawMnF16.d.ts.map +1 -0
- package/dist/{index-BFLKkqA3.d.ts → index-CfvrvY5j.d.ts} +3 -3
- package/dist/{index-BFLKkqA3.d.ts.map → index-CfvrvY5j.d.ts.map} +1 -1
- package/dist/{index-CqGabrzW.d.cts → index-CurPwWL9.d.ts} +37 -37
- package/dist/index-CurPwWL9.d.ts.map +1 -0
- package/dist/{index-1Egh73pR.d.ts → index-CvB1zKX7.d.ts} +3 -3
- package/dist/{index-1Egh73pR.d.ts.map → index-CvB1zKX7.d.ts.map} +1 -1
- package/dist/{index-CHNp5R5N.d.cts → index-DFx0ltJF.d.cts} +6 -6
- package/dist/{index-CHNp5R5N.d.cts.map → index-DFx0ltJF.d.cts.map} +1 -1
- package/dist/{index-CnsR8nkm.d.cts → index-DGVD8poH.d.cts} +35 -35
- package/dist/index-DGVD8poH.d.cts.map +1 -0
- package/dist/index-DQwjOFsY.d.ts +264 -0
- package/dist/{index-DajjPPWM.d.ts.map → index-DQwjOFsY.d.ts.map} +1 -1
- package/dist/{index-DnzC0GCS.d.ts → index-DVJ2qfsk.d.cts} +21 -21
- package/dist/{index-C2A_i57R.d.cts.map → index-DVJ2qfsk.d.cts.map} +1 -1
- package/dist/{index-0wXxS5M7.d.ts → index-DX1z52ZR.d.cts} +7 -7
- package/dist/{index-BDV3JVoX.d.cts.map → index-DX1z52ZR.d.cts.map} +1 -1
- package/dist/{index-3v_vja2i.d.ts → index-DifBpRFc.d.ts} +6 -6
- package/dist/{index-3v_vja2i.d.ts.map → index-DifBpRFc.d.ts.map} +1 -1
- package/dist/{index-DvF_C1Bz.d.cts → index-DipaiXC4.d.cts} +3 -3
- package/dist/{index-DvF_C1Bz.d.cts.map → index-DipaiXC4.d.cts.map} +1 -1
- package/dist/{index-Bcppi5O7.d.ts → index-Dq4f0wmg.d.cts} +5 -5
- package/dist/index-Dq4f0wmg.d.cts.map +1 -0
- package/dist/{index-CTp4vdDb.d.ts → index-DvA48Kfg.d.ts} +6 -6
- package/dist/{index-CTp4vdDb.d.ts.map → index-DvA48Kfg.d.ts.map} +1 -1
- package/dist/{index-C2A_i57R.d.cts → index-DwPObwro.d.ts} +21 -21
- package/dist/{index-DnzC0GCS.d.ts.map → index-DwPObwro.d.ts.map} +1 -1
- package/dist/{index-g9TZhGnE.d.cts → index-JBgZs7KT.d.cts} +3 -3
- package/dist/{index-g9TZhGnE.d.cts.map → index-JBgZs7KT.d.cts.map} +1 -1
- package/dist/{index-BGXgvZKr.d.ts → index-RvltC2WQ.d.cts} +35 -36
- package/dist/index-RvltC2WQ.d.cts.map +1 -0
- package/dist/{index-CUn9q5KD.d.ts → index-WX68Ezjt.d.ts} +6 -6
- package/dist/{index-CUn9q5KD.d.ts.map → index-WX68Ezjt.d.ts.map} +1 -1
- package/dist/{index-DcYFLiul.d.cts → index-bxPth2J0.d.cts} +48 -48
- package/dist/{index-DcYFLiul.d.cts.map → index-bxPth2J0.d.cts.map} +1 -1
- package/dist/{index-CiF2KXB7.d.cts → index-m2jmMTo-.d.cts} +6 -6
- package/dist/{index-CiF2KXB7.d.cts.map → index-m2jmMTo-.d.cts.map} +1 -1
- package/dist/{index-BSjUaHEO.d.cts → index-xU5kPQOI.d.ts} +5 -5
- package/dist/{index-BSjUaHEO.d.cts.map → index-xU5kPQOI.d.ts.map} +1 -1
- package/dist/index.cjs +28 -27
- package/dist/index.d.cts +20 -20
- package/dist/index.d.ts +22 -22
- package/dist/index.js +23 -23
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +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/{useClientValidation-BrTtRnqi.js → useClientValidation-BBxyf66y.js} +3 -3
- package/dist/{useClientValidation-BrTtRnqi.js.map → useClientValidation-BBxyf66y.js.map} +1 -1
- package/dist/{useClientValidation-Bg0q3Axc.d.ts → useClientValidation-BIn3RG5V.d.ts} +3 -3
- package/dist/{useClientValidation-Bg0q3Axc.d.ts.map → useClientValidation-BIn3RG5V.d.ts.map} +1 -1
- package/dist/{useClientValidation-BvPDQmf6.d.cts → useClientValidation-BkXLclZB.d.cts} +3 -3
- package/dist/{useClientValidation-BvPDQmf6.d.cts.map → useClientValidation-BkXLclZB.d.cts.map} +1 -1
- package/dist/{useClientValidation-CdC7lEYP.cjs → useClientValidation-DoQNMmK_.cjs} +4 -4
- package/dist/{useClientValidation-CdC7lEYP.cjs.map → useClientValidation-DoQNMmK_.cjs.map} +1 -1
- package/dist/{useController-BBxji1nQ.cjs → useController-3PySjxD_.cjs} +3 -3
- package/dist/{useController-BBxji1nQ.cjs.map → useController-3PySjxD_.cjs.map} +1 -1
- package/dist/useController-BArZd2Vp.d.cts.map +1 -1
- package/dist/{useController-g0AlWM__.js → useController-BfVh3zWN.js} +3 -3
- package/dist/{useController-g0AlWM__.js.map → useController-BfVh3zWN.js.map} +1 -1
- package/dist/{useFormContext-BFoXZNkp.js → useFormContext-5JLVGxh-.js} +3 -3
- package/dist/{useFormContext-BFoXZNkp.js.map → useFormContext-5JLVGxh-.js.map} +1 -1
- package/dist/{useFormContext-CEr3zcL6.cjs → useFormContext-C8zLji1t.cjs} +3 -3
- package/dist/{useFormContext-CEr3zcL6.cjs.map → useFormContext-C8zLji1t.cjs.map} +1 -1
- package/dist/{useFormContext-Cw6aAhos.d.ts → useFormContext-Dmo4sBPy.d.ts} +17 -17
- package/dist/{useFormContext-Cw6aAhos.d.ts.map → useFormContext-Dmo4sBPy.d.ts.map} +1 -1
- package/dist/{useInputValueDebounce-Dop_8_OK.js → useInputValueDebounce-Bbi6GTsR.js} +2 -2
- package/dist/{useInputValueDebounce-Dop_8_OK.js.map → useInputValueDebounce-Bbi6GTsR.js.map} +1 -1
- package/dist/{useInputValueDebounce-TiNR4jtG.cjs → useInputValueDebounce-D1JOnwFh.cjs} +3 -3
- package/dist/{useInputValueDebounce-TiNR4jtG.cjs.map → useInputValueDebounce-D1JOnwFh.cjs.map} +1 -1
- package/dist/{useInputValueTransform-BNmfaj5D.cjs → useInputValueTransform-n2XFRAUN.cjs} +2 -2
- package/dist/{useInputValueTransform-BNmfaj5D.cjs.map → useInputValueTransform-n2XFRAUN.cjs.map} +1 -1
- package/dist/{useUniformField-RxZqXMuD.d.ts → useUniformField-BWlrKyG6.d.ts} +2 -2
- package/dist/{useUniformField-RxZqXMuD.d.ts.map → useUniformField-BWlrKyG6.d.ts.map} +1 -1
- package/dist/{useUniformField-D6fwSjrH.cjs → useUniformField-BrYZavNt.cjs} +8 -8
- package/dist/{useUniformField-D6fwSjrH.cjs.map → useUniformField-BrYZavNt.cjs.map} +1 -1
- package/dist/{useUniformField-BKVVns0E.js → useUniformField-Cp0JL74c.js} +4 -4
- package/dist/{useUniformField-BKVVns0E.js.map → useUniformField-Cp0JL74c.js.map} +1 -1
- package/dist/{useUniformFieldArray-B_c55CnX.d.ts → useUniformFieldArray-D7ra7ZCk.d.ts} +13 -13
- package/dist/{useUniformFieldArray-B_c55CnX.d.ts.map → useUniformFieldArray-D7ra7ZCk.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-Byfmzq97.cjs → useUniformFieldArray-DkkIoDVL.cjs} +5 -5
- package/dist/{useUniformFieldArray-Byfmzq97.cjs.map → useUniformFieldArray-DkkIoDVL.cjs.map} +1 -1
- package/dist/{useUniformFieldArray-BwE634m6.js → useUniformFieldArray-c08sO9Th.js} +4 -4
- package/dist/{useUniformFieldArray-BwE634m6.js.map → useUniformFieldArray-c08sO9Th.js.map} +1 -1
- package/dist/{useWatchUserChange-fZy6nGtD.js → useWatchUserChange-BkUA1oym.js} +2 -2
- package/dist/{useWatchUserChange-fZy6nGtD.js.map → useWatchUserChange-BkUA1oym.js.map} +1 -1
- package/dist/{useWatchUserChange-TMfaTCcp.cjs → useWatchUserChange-cfuw7hi4.cjs} +3 -3
- package/dist/{useWatchUserChange-TMfaTCcp.cjs.map → useWatchUserChange-cfuw7hi4.cjs.map} +1 -1
- package/package.json +2 -2
- package/dist/RadioBoxes-DdIHH6B5.js.map +0 -1
- package/dist/RadioBoxes-h-VLhJ9d.cjs.map +0 -1
- package/dist/RadioTabs-D6yF9jE3.cjs.map +0 -1
- package/dist/RadioTabs-dLdlF91p.js.map +0 -1
- package/dist/Radios-D8alyG2f.cjs.map +0 -1
- package/dist/Radios-DiZ0Dfmp.js.map +0 -1
- package/dist/Select-C9otN8uu.js.map +0 -1
- package/dist/Select-DQVskslz.cjs.map +0 -1
- package/dist/helpers-CCINRgQk.js.map +0 -1
- package/dist/helpers-nYTmL2gX.cjs.map +0 -1
- package/dist/index-Bcppi5O7.d.ts.map +0 -1
- package/dist/index-CeYRsehb.d.cts.map +0 -1
- package/dist/index-CjJHVJwD.d.cts.map +0 -1
- package/dist/index-CnsR8nkm.d.cts.map +0 -1
- package/dist/index-DNFUttM8.d.ts.map +0 -1
- package/dist/index-D_egu-QT.d.cts +0 -264
- package/dist/index-D_egu-QT.d.cts.map +0 -1
- package/dist/index-DajjPPWM.d.ts +0 -264
- package/dist/index-op7zETAQ.d.ts.map +0 -1
- package/dist/index-yVkU2v6b.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as UserChangeListener, t as DebugModeSettings } from "./FormContext-C2_WMi_v.js";
|
|
2
2
|
import * as react0 from "react";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_hook_form0 from "react-hook-form";
|
|
4
4
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
5
5
|
import * as _fuf_stack_veto0 from "@fuf-stack/veto";
|
|
6
6
|
import { VetoFormattedError, VetoInstance } from "@fuf-stack/veto";
|
|
@@ -19,7 +19,7 @@ declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) =
|
|
|
19
19
|
* - Filters out empty/null values
|
|
20
20
|
*/
|
|
21
21
|
declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
|
|
22
|
-
formState:
|
|
22
|
+
formState: react_hook_form0.FormState<TFieldValues>;
|
|
23
23
|
getFieldState: (name: Path<TFieldValues>, testId?: string) => {
|
|
24
24
|
error: FieldError[] | undefined;
|
|
25
25
|
invalid: boolean;
|
|
@@ -29,9 +29,9 @@ declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues,
|
|
|
29
29
|
isTouched: boolean;
|
|
30
30
|
isValidating: boolean;
|
|
31
31
|
};
|
|
32
|
-
getValues:
|
|
33
|
-
subscribe:
|
|
34
|
-
watch:
|
|
32
|
+
getValues: react_hook_form0.UseFormGetValues<TFieldValues>;
|
|
33
|
+
subscribe: react_hook_form0.UseFormSubscribe<TFieldValues>;
|
|
34
|
+
watch: react_hook_form0.UseFormWatch<TFieldValues>;
|
|
35
35
|
debugMode: "debug" | "debug-testids" | "off" | "disabled";
|
|
36
36
|
debugModeSettings?: DebugModeSettings;
|
|
37
37
|
preventSubmit: (prevent: boolean) => void;
|
|
@@ -47,18 +47,18 @@ declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues,
|
|
|
47
47
|
errors?: VetoFormattedError;
|
|
48
48
|
setClientValidationSchema: (key: string, schema: _fuf_stack_veto0.VetoTypeAny | null) => void;
|
|
49
49
|
};
|
|
50
|
-
setError:
|
|
51
|
-
clearErrors:
|
|
52
|
-
setValue:
|
|
53
|
-
trigger:
|
|
54
|
-
resetField:
|
|
55
|
-
reset:
|
|
56
|
-
handleSubmit:
|
|
57
|
-
unregister:
|
|
58
|
-
control:
|
|
59
|
-
register:
|
|
60
|
-
setFocus:
|
|
50
|
+
setError: react_hook_form0.UseFormSetError<TFieldValues>;
|
|
51
|
+
clearErrors: react_hook_form0.UseFormClearErrors<TFieldValues>;
|
|
52
|
+
setValue: react_hook_form0.UseFormSetValue<TFieldValues>;
|
|
53
|
+
trigger: react_hook_form0.UseFormTrigger<TFieldValues>;
|
|
54
|
+
resetField: react_hook_form0.UseFormResetField<TFieldValues>;
|
|
55
|
+
reset: react_hook_form0.UseFormReset<TFieldValues>;
|
|
56
|
+
handleSubmit: react_hook_form0.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
|
|
57
|
+
unregister: react_hook_form0.UseFormUnregister<TFieldValues>;
|
|
58
|
+
control: react_hook_form0.Control<TFieldValues, TContext, TTransformedValues>;
|
|
59
|
+
register: react_hook_form0.UseFormRegister<TFieldValues>;
|
|
60
|
+
setFocus: react_hook_form0.UseFormSetFocus<TFieldValues>;
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { useFormContext$1 as n, checkFieldIsRequired as t };
|
|
64
|
-
//# sourceMappingURL=useFormContext-
|
|
64
|
+
//# sourceMappingURL=useFormContext-Dmo4sBPy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-Dmo4sBPy.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,OAAA,GAAA,eAAA,GAAA,KAAA,GAAA,UAAA;EACyB,iBAAA,CAAA,mBAAA;EAAwE,aAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAA,YAAA,EAAA,CAAA,SAAA,EAAA,OAAA,GAAA,eAAA,GAAA,KAAA,GAAA,UAAA,EAAA,GAAA,IAAA;6BA1B7D,uBAAA;;0BAAA;;;;mBAyBpC;eACyB;aAAwE;qDAAA,gBAAA,CAAA,WAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useFormContext } from "./useFormContext-
|
|
1
|
+
import { n as useFormContext } from "./useFormContext-5JLVGxh-.js";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
@@ -90,4 +90,4 @@ const useInputValueDebounce = ({ debounceDelay = 300, name, onBlur, onChange, va
|
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { useInputValueDebounce as t };
|
|
93
|
-
//# sourceMappingURL=useInputValueDebounce-
|
|
93
|
+
//# sourceMappingURL=useInputValueDebounce-Bbi6GTsR.js.map
|
package/dist/{useInputValueDebounce-Dop_8_OK.js.map → useInputValueDebounce-Bbi6GTsR.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-Bbi6GTsR.js","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useFormContext } from '../useFormContext';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** Field name for triggering validation after debounced value commits */\n name: string;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n name,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n const { trigger } = useFormContext();\n\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n // Trigger validation after debounced value commits\n // This ensures errors are updated immediately when field becomes valid\n trigger(name);\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay, trigger, name],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,MACA,QACA,UACA,YAC+E;CAC/E,MAAM,EAAE,YAAY,gBAAgB;CAGpC,MAAM,CAAC,cAAc,mBAAmB,SAAiB,MAAM;CAE/D,MAAM,aAAa,OAA8B,KAAK;AAGtD,iBAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAuDX,QAAO;EACL,UArDmB,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;AAIpB,YAAQ,KAAK;;AAIf,OAAI,iBAAiB,EACnB,kBAAiB;OAEjB,YAAW,UAAU,WAAW,iBAAiB,cAAc;KAGnE;GAAC;GAAU;GAAe;GAAS;GAAK,CACzC;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,5 +1,5 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_useFormContext = require('./useFormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-CwP_2mvE.cjs');
|
|
2
|
+
const require_useFormContext = require('./useFormContext-C8zLji1t.cjs');
|
|
3
3
|
let react = require("react");
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
@@ -96,4 +96,4 @@ Object.defineProperty(exports, 'useInputValueDebounce', {
|
|
|
96
96
|
return useInputValueDebounce;
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
//# sourceMappingURL=useInputValueDebounce-
|
|
99
|
+
//# sourceMappingURL=useInputValueDebounce-D1JOnwFh.cjs.map
|
package/dist/{useInputValueDebounce-TiNR4jtG.cjs.map → useInputValueDebounce-D1JOnwFh.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueDebounce-
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-D1JOnwFh.cjs","names":["useFormContext"],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { useFormContext } from '../useFormContext';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** Field name for triggering validation after debounced value commits */\n name: string;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n name,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n const { trigger } = useFormContext();\n\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n // Trigger validation after debounced value commits\n // This ensures errors are updated immediately when field becomes valid\n trigger(name);\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay, trigger, name],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,MACA,QACA,UACA,YAC+E;CAC/E,MAAM,EAAE,YAAYA,uCAAgB;CAGpC,MAAM,CAAC,cAAc,uCAAoC,MAAM;CAE/D,MAAM,+BAA2C,KAAK;AAGtD,4BAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAuDX,QAAO;EACL,kCAnDC,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;AAIpB,YAAQ,KAAK;;AAIf,OAAI,iBAAiB,EACnB,kBAAiB;OAEjB,YAAW,UAAU,WAAW,iBAAiB,cAAc;KAGnE;GAAC;GAAU;GAAe;GAAS;GAAK,CACzC;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,4 +1,4 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-CwP_2mvE.cjs');
|
|
2
2
|
let react = require("react");
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useInputValueTransform/useInputValueTransform.ts
|
|
@@ -114,4 +114,4 @@ Object.defineProperty(exports, 'useInputValueTransform', {
|
|
|
114
114
|
return useInputValueTransform;
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
//# sourceMappingURL=useInputValueTransform-
|
|
117
|
+
//# sourceMappingURL=useInputValueTransform-n2XFRAUN.cjs.map
|
package/dist/{useInputValueTransform-BNmfaj5D.cjs.map → useInputValueTransform-n2XFRAUN.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueTransform-
|
|
1
|
+
{"version":3,"file":"useInputValueTransform-n2XFRAUN.cjs","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform<TDisplay = unknown> {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\" or 'a' → ['a']) */\n toDisplayValue: (value: unknown) => TDisplay;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000 or ['a'] → 'a') */\n toFormValue: (value: TDisplay) => unknown;\n}\n\nexport interface UseInputValueTransformOptions<TDisplay = unknown> {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform<TDisplay>;\n}\n\nexport interface UseInputValueTransformReturn<TDisplay = unknown> {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: unknown) => TDisplay;\n /** Converts any display value to form value */\n toFormValue: (displayValue: TDisplay) => unknown;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n * - Array/Object transformations (single value ↔ array, nested structures)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Generic support for any data type (strings, numbers, arrays, objects)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Array to single value (for single checkbox)\n * const singleValueTransform = {\n * toDisplayValue: (val: string[]) => val?.[0] || '',\n * toFormValue: (val: string) => val ? [val] : []\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: singleValueTransform\n * });\n *\n * const displayVal = toDisplayValue(['option1']); // \"option1\"\n * const formVal = toFormValue(\"option2\"); // [\"option2\"]\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = <TDisplay = unknown>({\n type,\n transform,\n}: UseInputValueTransformOptions<TDisplay>): UseInputValueTransformReturn<TDisplay> => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: unknown): TDisplay => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue);\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') {\n return '' as TDisplay;\n }\n const numValue = Number(formValue);\n return (Number.isNaN(numValue) ? formValue : numValue) as TDisplay;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return (formValue ?? '') as TDisplay;\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: TDisplay): unknown => {\n if (transform?.toFormValue) {\n return transform.toFormValue(displayValue);\n }\n\n // For number type, convert strings to numbers\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,MAAa,0BAA8C,EACzD,MACA,gBACqF;AAiDrF,QAAO;EACL,wCA7CC,cAAiC;AAChC,OAAI,WAAW,eACb,QAAO,UAAU,eAAe,UAAU;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,cAAc,GAChB,QAAO;IAET,MAAM,WAAW,OAAO,UAAU;AAClC,WAAQ,OAAO,MAAM,SAAS,GAAG,YAAY;;AAI/C,UAAQ,aAAa;KAEvB,CAAC,MAAM,UAAU,CAClB;EA4BC,qCAtBC,iBAAoC;AACnC,OAAI,WAAW,YACb,QAAO,UAAU,YAAY,aAAa;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,iBAAiB,GACnB,QAAO;IAET,MAAM,WAAW,OAAO,aAAa;AACrC,WAAO,OAAO,MAAM,SAAS,GAAG,eAAe;;AAIjD,UAAO;KAET,CAAC,MAAM,UAAU,CAClB;EAKA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as InputValueTransform } from "./useInputValueTransform-Cc0qEsnS.js";
|
|
2
2
|
import { r as useController$1 } from "./useController-MVHJ7WFp.js";
|
|
3
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
3
|
+
import { n as useFormContext$1 } from "./useFormContext-Dmo4sBPy.js";
|
|
4
4
|
import { t as useInput } from "./useInput-BCdeYOOg.js";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
@@ -95,4 +95,4 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
95
95
|
declare const useUniformField: <TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>) => UseUniformFieldReturn<TFieldValues>;
|
|
96
96
|
//#endregion
|
|
97
97
|
export { UseUniformFieldReturn as n, useUniformField as r, UseUniformFieldParams as t };
|
|
98
|
-
//# sourceMappingURL=useUniformField-
|
|
98
|
+
//# sourceMappingURL=useUniformField-BWlrKyG6.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-
|
|
1
|
+
{"version":3,"file":"useUniformField-BWlrKyG6.d.ts","names":[],"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"sourcesContent":[],"mappings":";;;;;;;;UA0CiB,2CACM,cAAc;;EADpB,IAAA,EAKT,IALS,CAKJ,YALI,CAAqB,GAAA,MAAA;EACf;EAAc,SAAA,CAAA,EAAA,MAAA;EAIxB;EAAL,QAAA,CAAA,EAAA,OAAA;EAME;EAIwB,KAAA,CAAA,EAJxB,SAIwB;EAApB;EAAmB,MAAA,CAAA,EAAA,MAAA;EAKhB;EACM,SAAA,CAAA,EANT,mBAMS,CANW,QAMX,CAAA;EAAc;EAKO,IAAA,CAAA,EAAA,MAAA,GAAA,QAAA,GAAA,UAAA;;AAAjC,UANM,qBAMN,CAAA,qBALY,WAKZ,GAL0B,WAK1B,CAAA,CAAA;EAEmC;EAAf,SAAA,EAAA,MAAA,GAAA,SAAA;EAAlB;EAMJ,OAAA,EARE,UAQF,CAAA,OARoB,gBAQpB,CARmC,YAQnC,CAAA,CAAA,CAAA,SAAA,CAAA;EAEO;EAEyB,SAAA,EAV5B,UAU4B,CAAA,OAVV,gBAUU,CAVK,YAUL,CAAA,CAAA,CAAA,WAAA,CAAA;EAAd;EAAlB,YAAA,EAAA,OAAA;EAEiC;EAAlB,QAAA,EAAA,OAAA,GAAA,SAAA;EAEmB;EAAlB,KAAA,EARhB,UAQgB,EAAA,GAAA,SAAA;EAEU;EAAlB,YAAA,EARD,SAQC,GAAA,IAAA;EAE6B;EAAf,KAAA,EARtB,UAQsB,CAAA,OARJ,eAQI,CARU,YAQV,CAAA,CAAA,CAAA,OAAA,CAAA;EAAlB;EAIJ,oBAAA,EAVe,UAUf,CAAA,OAViC,QAUjC,CAAA,CAAA,sBAAA,CAAA;EAEiC;EAAd,qBAAA,EAVH,UAUG,CAAA,OAVe,QAUf,CAAA,CAAA,uBAAA,CAAA;EAAlB;EAEkC,aAAA,EAV3B,UAU2B,CAAA,OAVT,QAUS,CAAA,CAAA,eAAA,CAAA;EAAd;EAAlB,SAAA,EARC,UAQD,CAAA,OARmB,gBAQnB,CARkC,YAQlC,CAAA,CAAA,CAAA,WAAA,CAAA;EAE2B;EAAd,OAAA,EAAA,OAAA;EAAlB;EAIwC,KAAA,EAVtC,SAUsC,GAAA,IAAA;EAAf;EAAlB,MAAA,EARJ,UAQI,CAAA,OARc,eAQd,CAR4B,YAQ5B,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EAAU;EAiCX,QAAA,EAvCD,UA6MX,CAAA,OA7M6B,eA6M7B,CA7M2C,YA6M3C,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EArKsB;EAAc,GAAA,EAtC9B,UAsC8B,CAAA,OAtCZ,eAsCY,CAtCE,YAsCF,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGL;EAAc,QAAA,EAAA,OAAA;EAApC;EACe,UAAA,EAtCX,UAsCW,CAAA,OAtCO,gBAsCP,CAtCsB,YAsCtB,CAAA,CAAA,CAAA,YAAA,CAAA;EAAtB;EAAqB,MAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cALX,uCACU,cAAc,yCAG3B,sBAAsB,cAAc,cAC3C,sBAAsB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_helpers = require('./helpers-
|
|
3
|
-
const require_FieldCopyTestIdButton = require('./FieldCopyTestIdButton-
|
|
4
|
-
const require_FieldValidationError = require('./FieldValidationError-
|
|
5
|
-
const require_useController = require('./useController-
|
|
6
|
-
const require_useFormContext = require('./useFormContext-
|
|
7
|
-
const require_useInputValueTransform = require('./useInputValueTransform-
|
|
1
|
+
const require_FormContext = require('./FormContext-CwP_2mvE.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-Dat6eNFF.cjs');
|
|
3
|
+
const require_FieldCopyTestIdButton = require('./FieldCopyTestIdButton-Dx3A8L6t.cjs');
|
|
4
|
+
const require_FieldValidationError = require('./FieldValidationError-CY4sogEN.cjs');
|
|
5
|
+
const require_useController = require('./useController-3PySjxD_.cjs');
|
|
6
|
+
const require_useFormContext = require('./useFormContext-C8zLji1t.cjs');
|
|
7
|
+
const require_useInputValueTransform = require('./useInputValueTransform-n2XFRAUN.cjs');
|
|
8
8
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
9
9
|
let react = require("react");
|
|
10
10
|
react = require_FormContext.__toESM(react);
|
|
@@ -159,4 +159,4 @@ Object.defineProperty(exports, 'useUniformField', {
|
|
|
159
159
|
return useUniformField;
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
-
//# sourceMappingURL=useUniformField-
|
|
162
|
+
//# sourceMappingURL=useUniformField-BrYZavNt.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-D6fwSjrH.cjs","names":["useFormContext","useController","useInputValueTransform","isValueEmpty","FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { isTestEnvironment } from '@fuf-stack/pixel-utils';\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\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 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 has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,sDAA+B,SAAS,QAAQ;AAGtD,oDAAuB,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,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;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAACC,6BAAa,WAAW;CAE1C,MAAM,UAAU,oBADI,eAAe,YAAY,aAAa,cAAc,IACzB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAM,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,sDAClC;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
|
+
{"version":3,"file":"useUniformField-BrYZavNt.cjs","names":["useFormContext","useController","useInputValueTransform","isValueEmpty","FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { isTestEnvironment } from '@fuf-stack/pixel-utils';\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\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 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 has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,sDAA+B,SAAS,QAAQ;AAGtD,oDAAuB,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,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;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAACC,6BAAa,WAAW;CAE1C,MAAM,UAAU,oBADI,eAAe,YAAY,aAAa,cAAc,IACzB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAM,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,sDAClC;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,8 +1,8 @@
|
|
|
1
|
-
import { r as isValueEmpty } from "./helpers-
|
|
1
|
+
import { r as isValueEmpty } from "./helpers-DPGeUbNW.js";
|
|
2
2
|
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-D9f1B-VS.js";
|
|
3
3
|
import { n as FieldValidationError_default } from "./FieldValidationError-BYwitb_B.js";
|
|
4
|
-
import { t as useController } from "./useController-
|
|
5
|
-
import { n as useFormContext } from "./useFormContext-
|
|
4
|
+
import { t as useController } from "./useController-BfVh3zWN.js";
|
|
5
|
+
import { n as useFormContext } from "./useFormContext-5JLVGxh-.js";
|
|
6
6
|
import { t as useInput } from "./useInput-DZ6KGBxw.js";
|
|
7
7
|
import { t as useInputValueTransform } from "./useInputValueTransform-CMNC21vX.js";
|
|
8
8
|
import { isTestEnvironment } from "@fuf-stack/pixel-utils";
|
|
@@ -152,4 +152,4 @@ const useUniformField = (params) => {
|
|
|
152
152
|
|
|
153
153
|
//#endregion
|
|
154
154
|
export { useUniformField as t };
|
|
155
|
-
//# sourceMappingURL=useUniformField-
|
|
155
|
+
//# sourceMappingURL=useUniformField-Cp0JL74c.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-BKVVns0E.js","names":["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 { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\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 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 has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,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;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAAC,aAAa,WAAW;CAE1C,MAAM,UAAU,oBADI,eAAe,YAAY,aAAa,cAAc,IACzB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,4CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAACA,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
|
+
{"version":3,"file":"useUniformField-Cp0JL74c.js","names":["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 { isValueEmpty } from '../../helpers';\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\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 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 has a value (show validation errors like format/length while typing)\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * Note: We intentionally don't use isDirty because:\n * - Newly added array elements are marked \"dirty\" by RHF, causing immediate errors\n * - Field Cards with empty initial values show errors immediately\n * - hasValue + isTouched covers the same use cases more reliably\n *\n * This prevents showing errors on pristine/untouched/empty fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User types invalid content → error shows immediately (has value)\n * - Text input: User focuses and blurs without typing → error shows (via isTouched)\n * - Checkbox/radio: User selects option → error shows immediately (has value)\n * - Field array: User adds element → no error yet; after blur → error shows\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations.\n */\n\n // isValueEmpty handles marker strings, flat array wrappers, empty arrays, and empty objects\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid = rawInvalid && (hasValue || 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,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;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,MAAM,WAAW,CAAC,aAAa,WAAW;CAE1C,MAAM,UAAU,oBADI,eAAe,YAAY,aAAa,cAAc,IACzB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,4CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAACA,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,7 +1,7 @@
|
|
|
1
1
|
import { r as useController$1 } from "./useController-MVHJ7WFp.js";
|
|
2
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
2
|
+
import { n as useFormContext$1 } from "./useFormContext-Dmo4sBPy.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as react_hook_form14 from "react-hook-form";
|
|
5
5
|
import { ArrayPath, FieldValues } from "react-hook-form";
|
|
6
6
|
import * as _heroui_input0 from "@heroui/input";
|
|
7
7
|
|
|
@@ -44,36 +44,36 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
44
44
|
label
|
|
45
45
|
}: UseUniformFieldArrayProps<TFieldValues>) => {
|
|
46
46
|
ariaLabel: string | undefined;
|
|
47
|
-
control:
|
|
47
|
+
control: react_hook_form14.Control<TFieldValues, any, TFieldValues>;
|
|
48
48
|
debugMode: ReturnType<typeof useFormContext$1<TFieldValues_1>>["debugMode"];
|
|
49
49
|
defaultValue: unknown;
|
|
50
50
|
disabled: boolean | undefined;
|
|
51
|
-
error:
|
|
51
|
+
error: react_hook_form14.FieldError[] | undefined;
|
|
52
52
|
errorMessage: ReactNode | null;
|
|
53
|
-
field: Omit<
|
|
53
|
+
field: Omit<react_hook_form14.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
|
|
54
54
|
onChange: (...event: any[]) => void;
|
|
55
55
|
value: string;
|
|
56
56
|
};
|
|
57
57
|
getErrorMessageProps: ReturnType<typeof _heroui_input0.useInput>["getErrorMessageProps"];
|
|
58
58
|
getHelperWrapperProps: ReturnType<typeof _heroui_input0.useInput>["getHelperWrapperProps"];
|
|
59
59
|
getLabelProps: ReturnType<typeof _heroui_input0.useInput>["getLabelProps"];
|
|
60
|
-
getValues:
|
|
60
|
+
getValues: react_hook_form14.UseFormGetValues<TFieldValues>;
|
|
61
61
|
invalid: boolean;
|
|
62
62
|
label: ReactNode | null;
|
|
63
63
|
onBlur: ReturnType<typeof useController$1>["field"]["onBlur"];
|
|
64
64
|
onChange: ReturnType<typeof useController$1>["field"]["onChange"];
|
|
65
65
|
ref: ReturnType<typeof useController$1>["field"]["ref"];
|
|
66
66
|
required: boolean;
|
|
67
|
-
resetField:
|
|
67
|
+
resetField: react_hook_form14.UseFormResetField<TFieldValues>;
|
|
68
68
|
testId: string;
|
|
69
|
-
fields:
|
|
70
|
-
append:
|
|
71
|
-
remove:
|
|
72
|
-
insert:
|
|
73
|
-
move:
|
|
69
|
+
fields: react_hook_form14.FieldArrayWithId<TFieldValues, ArrayPath<TFieldValues>, "id">[];
|
|
70
|
+
append: react_hook_form14.UseFieldArrayAppend<TFieldValues, ArrayPath<TFieldValues>>;
|
|
71
|
+
remove: react_hook_form14.UseFieldArrayRemove;
|
|
72
|
+
insert: react_hook_form14.UseFieldArrayInsert<TFieldValues, ArrayPath<TFieldValues>>;
|
|
73
|
+
move: react_hook_form14.UseFieldArrayMove;
|
|
74
74
|
disableAnimation: boolean;
|
|
75
75
|
elementInitialValue: {};
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
78
|
export { useUniformFieldArray as n, UseUniformFieldArrayProps as t };
|
|
79
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
79
|
+
//# sourceMappingURL=useUniformFieldArray-D7ra7ZCk.d.ts.map
|
package/dist/{useUniformFieldArray-B_c55CnX.d.ts.map → useUniformFieldArray-D7ra7ZCk.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-D7ra7ZCk.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;;;;;;;;;;;;;;;;;EAuDpB,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,sBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EAKwC,QAAA,EAAA,UAAA,CAAA,OALxC,eAKwC,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EACyB,UADzB,CAAA,OAAA,eAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EACyB,QAAA,EAAA,OAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_helpers = require('./helpers-
|
|
3
|
-
const require_useFormContext = require('./useFormContext-
|
|
4
|
-
const require_useUniformField = require('./useUniformField-
|
|
1
|
+
const require_FormContext = require('./FormContext-CwP_2mvE.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-Dat6eNFF.cjs');
|
|
3
|
+
const require_useFormContext = require('./useFormContext-C8zLji1t.cjs');
|
|
4
|
+
const require_useUniformField = require('./useUniformField-BrYZavNt.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
|
|
7
7
|
let react_hook_form = require("react-hook-form");
|
|
@@ -87,4 +87,4 @@ Object.defineProperty(exports, 'useUniformFieldArray', {
|
|
|
87
87
|
return useUniformFieldArray;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
90
|
+
//# sourceMappingURL=useUniformFieldArray-DkkIoDVL.cjs.map
|
package/dist/{useUniformFieldArray-Byfmzq97.cjs.map → useUniformFieldArray-DkkIoDVL.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-DkkIoDVL.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 // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\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;AAOrB,4BAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AACf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,2CAAgC,KAAK;CAI9D,MAAM,sEAAyC;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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as flatArrayKey } from "./helpers-
|
|
2
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
3
|
-
import { t as useUniformField } from "./useUniformField-
|
|
1
|
+
import { t as flatArrayKey } from "./helpers-DPGeUbNW.js";
|
|
2
|
+
import { n as useFormContext$1 } from "./useFormContext-5JLVGxh-.js";
|
|
3
|
+
import { t as useUniformField } from "./useUniformField-Cp0JL74c.js";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { useReducedMotion } from "@fuf-stack/pixel-motion";
|
|
6
6
|
import { useFieldArray } from "react-hook-form";
|
|
@@ -81,4 +81,4 @@ const useUniformFieldArray = ({ name, flat = false, elementInitialValue: _elemen
|
|
|
81
81
|
|
|
82
82
|
//#endregion
|
|
83
83
|
export { useUniformFieldArray as t };
|
|
84
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
84
|
+
//# sourceMappingURL=useUniformFieldArray-c08sO9Th.js.map
|