@fuf-stack/uniform 1.11.2 → 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-BY4UK0Xf.js → Checkboxes-BEW0I_YR.js} +3 -3
- package/dist/{Checkboxes-BY4UK0Xf.js.map → Checkboxes-BEW0I_YR.js.map} +1 -1
- package/dist/{Checkboxes-DgCK-Wq-.cjs → Checkboxes-DC-7EBOm.cjs} +4 -4
- package/dist/{Checkboxes-DgCK-Wq-.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-DBsyUQkU.cjs → FieldArray-BA0jdPi-.cjs} +7 -7
- package/dist/{FieldArray-DBsyUQkU.cjs.map → FieldArray-BA0jdPi-.cjs.map} +1 -1
- package/dist/{FieldArray-CDLaGvNj.js → FieldArray-BBRdAk7J.js} +5 -5
- package/dist/{FieldArray-CDLaGvNj.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-C1MCSbPW.js → FieldCard-24ogRnQc.js} +3 -3
- package/dist/{FieldCard-C1MCSbPW.js.map → FieldCard-24ogRnQc.js.map} +1 -1
- package/dist/{FieldCard-NKF358fO.cjs → FieldCard-DxOqqbwN.cjs} +4 -4
- package/dist/{FieldCard-NKF358fO.cjs.map → FieldCard-DxOqqbwN.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-DWPCDJ-s.js → FieldCopyTestIdButton-D9f1B-VS.js} +1 -1
- package/dist/{FieldCopyTestIdButton-DWPCDJ-s.js.map → FieldCopyTestIdButton-D9f1B-VS.js.map} +1 -1
- package/dist/{FieldCopyTestIdButton-BSYcSo2o.cjs → FieldCopyTestIdButton-Dx3A8L6t.cjs} +2 -2
- package/dist/{FieldCopyTestIdButton-BSYcSo2o.cjs.map → FieldCopyTestIdButton-Dx3A8L6t.cjs.map} +1 -1
- package/dist/{FieldValidationError-1hiDEFew.js → FieldValidationError-BYwitb_B.js} +1 -1
- package/dist/{FieldValidationError-1hiDEFew.js.map → FieldValidationError-BYwitb_B.js.map} +1 -1
- package/dist/{FieldValidationError-CE8R8qry.cjs → FieldValidationError-CY4sogEN.cjs} +2 -2
- package/dist/{FieldValidationError-CE8R8qry.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-BsD69fql.cjs → Form-CT6qXH_3.cjs} +3 -3
- package/dist/{Form-BsD69fql.cjs.map → Form-CT6qXH_3.cjs.map} +1 -1
- package/dist/{Form-DRNEwHsi.js → Form-GahmtDWp.js} +3 -3
- package/dist/{Form-DRNEwHsi.js.map → Form-GahmtDWp.js.map} +1 -1
- package/dist/{FormContext-Bb6d8hdG.cjs → FormContext-CwP_2mvE.cjs} +2 -2
- package/dist/{FormContext-Bb6d8hdG.cjs.map → FormContext-CwP_2mvE.cjs.map} +1 -1
- package/dist/{FormContext-CN9n_KdE.js → FormContext-FJzj6Lel.js} +2 -2
- package/dist/{FormContext-CN9n_KdE.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-D84e76CE.cjs → Grid-DMdEI2za.cjs} +2 -2
- package/dist/{Grid-D84e76CE.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-DXMWGTBh.js → Input-CjujXjtF.js} +4 -3
- package/dist/Input-CjujXjtF.js.map +1 -0
- package/dist/{Input-DeTpxiK_.cjs → Input-Df23py1O.cjs} +5 -4
- package/dist/Input-Df23py1O.cjs.map +1 -0
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.d.cts +1 -1
- package/dist/RadioBoxes/index.d.ts +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/{RadioBoxes-gsQGqQCd.cjs → RadioBoxes-Bh1D-orY.cjs} +11 -7
- package/dist/RadioBoxes-Bh1D-orY.cjs.map +1 -0
- package/dist/{RadioBoxes-BEln4a-B.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-DLr9QiXI.js → RadioTabs-CF2zlZWy.js} +10 -6
- package/dist/RadioTabs-CF2zlZWy.js.map +1 -0
- package/dist/{RadioTabs-BYpP0tKA.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-DCXI2kMf.js → Radios-23CQE6rR.js} +10 -6
- package/dist/Radios-23CQE6rR.js.map +1 -0
- package/dist/{Radios-BCOfnTke.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-CyfEmWiD.js → Select-BrRJc9SK.js} +12 -7
- package/dist/Select-BrRJc9SK.js.map +1 -0
- package/dist/{Select-KnPGOO27.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-Dlhb-9hC.js → Slider-BZ5DWUeo.js} +2 -2
- package/dist/{Slider-Dlhb-9hC.js.map → Slider-BZ5DWUeo.js.map} +1 -1
- package/dist/{Slider-C7xxYPgR.cjs → Slider-DKHLwbvB.cjs} +3 -3
- package/dist/{Slider-C7xxYPgR.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-C5f6j0N4.js → SubmitButton-C6vkNIyu.js} +2 -2
- package/dist/{SubmitButton-C5f6j0N4.js.map → SubmitButton-C6vkNIyu.js.map} +1 -1
- package/dist/{SubmitButton-CUBItcBn.cjs → SubmitButton-iKyzl3i2.cjs} +3 -3
- package/dist/{SubmitButton-CUBItcBn.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-6LyeZHJh.cjs → Switch-B9RAUjZC.cjs} +3 -3
- package/dist/{Switch-6LyeZHJh.cjs.map → Switch-B9RAUjZC.cjs.map} +1 -1
- package/dist/{Switch--m02Xcq8.js → Switch-DDgV6_QU.js} +2 -2
- package/dist/{Switch--m02Xcq8.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-D0-e-pbM.js → SwitchBox-72dpXO8I.js} +2 -2
- package/dist/{SwitchBox-D0-e-pbM.js.map → SwitchBox-72dpXO8I.js.map} +1 -1
- package/dist/{SwitchBox-CtGiQdys.cjs → SwitchBox-fNbronFu.cjs} +3 -3
- package/dist/{SwitchBox-CtGiQdys.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-BiSnvJ69.js → TextArea-BuOCICXv.js} +4 -3
- package/dist/{TextArea-BiSnvJ69.js.map → TextArea-BuOCICXv.js.map} +1 -1
- package/dist/{TextArea-PtdSABZS.cjs → TextArea-Cluaop2Y.cjs} +5 -4
- package/dist/{TextArea-PtdSABZS.cjs.map → TextArea-Cluaop2Y.cjs.map} +1 -1
- package/dist/helpers/index.cjs +3 -1
- package/dist/helpers/index.d.cts +184 -2
- package/dist/helpers/index.d.cts.map +1 -0
- package/dist/helpers/index.d.ts +184 -2
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +2 -2
- package/dist/{helpers-B-CJOBt3.js → helpers-DPGeUbNW.js} +77 -2
- package/dist/helpers-DPGeUbNW.js.map +1 -0
- package/dist/{helpers-B84E9vHd.cjs → helpers-Dat6eNFF.cjs} +89 -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.d.cts +1 -1
- package/dist/hooks/useController/index.d.ts +2 -1
- package/dist/hooks/useController/index.js +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +1 -1
- package/dist/hooks/useFormContext/index.js +1 -1
- package/dist/hooks/useInput/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.ts +1 -1
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +1 -1
- package/dist/hooks/useInputValueTransform/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +3 -3
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.ts +4 -24
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
- package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
- package/dist/hooks/useWatchUserChange/index.js +1 -1
- package/dist/{index-BWNJdLDV.d.ts → index-2fccMklK.d.ts} +48 -48
- package/dist/index-2fccMklK.d.ts.map +1 -0
- package/dist/{index-oyX8xu0F.d.cts → index-AaFOsx_O.d.cts} +6 -6
- package/dist/{index-oyX8xu0F.d.cts.map → index-AaFOsx_O.d.cts.map} +1 -1
- package/dist/{index-DG9C0kHA.d.ts → index-B2mcCRjV.d.ts} +36 -36
- package/dist/{index-DG9C0kHA.d.ts.map → index-B2mcCRjV.d.ts.map} +1 -1
- package/dist/{index-Cb0AgRRa.d.cts → index-B5BDC8Al.d.ts} +2 -2
- package/dist/{index-BL0DnIzh.d.ts.map → index-B5BDC8Al.d.ts.map} +1 -1
- package/dist/{index-C-2nxT8D.d.ts → index-BFQqVEJv.d.ts} +22 -22
- package/dist/{index-C-2nxT8D.d.ts.map → index-BFQqVEJv.d.ts.map} +1 -1
- package/dist/{index-CYdvpGJF.d.cts → index-BGprebgQ.d.cts} +3 -3
- package/dist/{index-CYdvpGJF.d.cts.map → index-BGprebgQ.d.cts.map} +1 -1
- package/dist/{index-DoS0lVRe.d.cts → index-BJtPrrAd.d.cts} +36 -36
- package/dist/index-BJtPrrAd.d.cts.map +1 -0
- package/dist/{index-BxA_pJWn.d.cts → index-BMbsKHMJ.d.cts} +22 -22
- package/dist/index-BMbsKHMJ.d.cts.map +1 -0
- package/dist/{index-jmQP58tO.d.cts → index-BNu0EV5x.d.cts} +3 -3
- package/dist/{index-jmQP58tO.d.cts.map → index-BNu0EV5x.d.cts.map} +1 -1
- package/dist/{index-BTTo_ufh.d.ts → index-BSOZdqA8.d.ts} +3 -3
- package/dist/{index-BTTo_ufh.d.ts.map → index-BSOZdqA8.d.ts.map} +1 -1
- package/dist/{index-BL0DnIzh.d.ts → index-Bfk32Dl3.d.cts} +3 -3
- package/dist/{index-Cb0AgRRa.d.cts.map → index-Bfk32Dl3.d.cts.map} +1 -1
- package/dist/{index-WogV9uVV.d.cts → index-BmrMk93O.d.ts} +7 -7
- package/dist/index-BmrMk93O.d.ts.map +1 -0
- package/dist/index-CA-MZNg5.d.cts +264 -0
- package/dist/index-CA-MZNg5.d.cts.map +1 -0
- package/dist/index-CFBmva_r.d.ts +1 -0
- package/dist/{index-C0L7GvgN.d.cts → index-CawMnF16.d.ts} +9 -9
- package/dist/index-CawMnF16.d.ts.map +1 -0
- package/dist/{index-DxdaxM3o.d.cts → index-CfvrvY5j.d.ts} +3 -3
- package/dist/{index-Edx7MxXu.d.ts.map → index-CfvrvY5j.d.ts.map} +1 -1
- package/dist/{index-CGnr_e53.d.ts → index-CurPwWL9.d.ts} +36 -36
- package/dist/index-CurPwWL9.d.ts.map +1 -0
- package/dist/{index-DvB46QAb.d.ts → index-CvB1zKX7.d.ts} +3 -3
- package/dist/{index-DvB46QAb.d.ts.map → index-CvB1zKX7.d.ts.map} +1 -1
- package/dist/{index-CSBE6Et0.d.cts → index-DFx0ltJF.d.cts} +6 -6
- package/dist/{index-CSBE6Et0.d.cts.map → index-DFx0ltJF.d.cts.map} +1 -1
- package/dist/{index-D38wOL-M.d.ts → 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-DQwjOFsY.d.ts.map +1 -0
- package/dist/{index-Bj_lpc5r.d.cts → index-DVJ2qfsk.d.cts} +21 -21
- package/dist/{index-Bj_lpc5r.d.cts.map → index-DVJ2qfsk.d.cts.map} +1 -1
- package/dist/{index-BQDEnYTq.d.ts → index-DVRtBywt.d.ts} +1 -1
- package/dist/{index-BQDEnYTq.d.ts.map → index-DVRtBywt.d.ts.map} +1 -1
- package/dist/{index-C1PUx1tH.d.ts → index-DX1z52ZR.d.cts} +7 -7
- package/dist/{index-WogV9uVV.d.cts.map → index-DX1z52ZR.d.cts.map} +1 -1
- package/dist/{index-DmMenZfj.d.ts → index-DifBpRFc.d.ts} +6 -6
- package/dist/{index-DmMenZfj.d.ts.map → index-DifBpRFc.d.ts.map} +1 -1
- package/dist/{index-Edx7MxXu.d.ts → index-DipaiXC4.d.cts} +3 -3
- package/dist/{index-DxdaxM3o.d.cts.map → index-DipaiXC4.d.cts.map} +1 -1
- package/dist/{index-BITJ-CZL.d.cts → index-Dq4f0wmg.d.cts} +5 -5
- package/dist/index-Dq4f0wmg.d.cts.map +1 -0
- package/dist/{index--E2ZsMya.d.ts → index-DvA48Kfg.d.ts} +4 -4
- package/dist/{index--E2ZsMya.d.ts.map → index-DvA48Kfg.d.ts.map} +1 -1
- package/dist/{index-DnzC0GCS.d.ts → index-DwPObwro.d.ts} +21 -21
- package/dist/{index-DnzC0GCS.d.ts.map → index-DwPObwro.d.ts.map} +1 -1
- package/dist/{index-PU5WNOH9.d.cts → index-JBgZs7KT.d.cts} +3 -3
- package/dist/{index-PU5WNOH9.d.cts.map → index-JBgZs7KT.d.cts.map} +1 -1
- package/dist/{index-DNkZrb7P.d.cts → index-RvltC2WQ.d.cts} +36 -36
- package/dist/{index-DNkZrb7P.d.cts.map → index-RvltC2WQ.d.cts.map} +1 -1
- package/dist/{index-F11geOHD.d.ts → index-WX68Ezjt.d.ts} +6 -6
- package/dist/{index-F11geOHD.d.ts.map → index-WX68Ezjt.d.ts.map} +1 -1
- package/dist/{index-Bo_n9sse.d.cts → index-bxPth2J0.d.cts} +48 -48
- package/dist/index-bxPth2J0.d.cts.map +1 -0
- package/dist/index-lQ_hGQ08.d.cts +1 -0
- package/dist/{index-DRij_w43.d.cts → index-m2jmMTo-.d.cts} +6 -6
- package/dist/{index-DRij_w43.d.cts.map → index-m2jmMTo-.d.cts.map} +1 -1
- package/dist/{index-CVnn6mEI.d.ts → index-xU5kPQOI.d.ts} +5 -5
- package/dist/{index-BITJ-CZL.d.cts.map → index-xU5kPQOI.d.ts.map} +1 -1
- package/dist/index.cjs +29 -27
- package/dist/index.d.cts +27 -27
- package/dist/index.d.ts +28 -27
- package/dist/index.js +26 -26
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +1 -1
- package/dist/partials/FieldValidationError/index.d.ts +1 -1
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/dist/{useClientValidation-BnnscAEe.js → useClientValidation-BBxyf66y.js} +3 -3
- package/dist/{useClientValidation-BnnscAEe.js.map → useClientValidation-BBxyf66y.js.map} +1 -1
- package/dist/{useClientValidation-DJ4JuN_9.d.ts → useClientValidation-BIn3RG5V.d.ts} +3 -3
- package/dist/{useClientValidation-DJ4JuN_9.d.ts.map → useClientValidation-BIn3RG5V.d.ts.map} +1 -1
- package/dist/{useClientValidation-BQqwz628.d.cts → useClientValidation-BkXLclZB.d.cts} +3 -3
- package/dist/{useClientValidation-BQqwz628.d.cts.map → useClientValidation-BkXLclZB.d.cts.map} +1 -1
- package/dist/{useClientValidation-CmYVGlLr.cjs → useClientValidation-DoQNMmK_.cjs} +4 -4
- package/dist/{useClientValidation-CmYVGlLr.cjs.map → useClientValidation-DoQNMmK_.cjs.map} +1 -1
- package/dist/{useController-CkmO5CLh.cjs → useController-3PySjxD_.cjs} +3 -3
- package/dist/{useController-CkmO5CLh.cjs.map → useController-3PySjxD_.cjs.map} +1 -1
- package/dist/{useController-C_MZLZIp.d.cts → useController-BArZd2Vp.d.cts} +1 -1
- package/dist/{useController-C_MZLZIp.d.cts.map → useController-BArZd2Vp.d.cts.map} +1 -1
- package/dist/{useController-CumIERks.js → useController-BfVh3zWN.js} +3 -3
- package/dist/{useController-CumIERks.js.map → useController-BfVh3zWN.js.map} +1 -1
- package/dist/{useController-hjpJQf0w.d.ts → useController-MVHJ7WFp.d.ts} +1 -1
- package/dist/{useController-hjpJQf0w.d.ts.map → useController-MVHJ7WFp.d.ts.map} +1 -1
- package/dist/{useFormContext-B083Y-kw.d.cts → useFormContext--yod5xzQ.d.cts} +3 -3
- package/dist/useFormContext--yod5xzQ.d.cts.map +1 -0
- package/dist/{useFormContext-JCm1UR_e.js → useFormContext-5JLVGxh-.js} +3 -3
- package/dist/{useFormContext-JCm1UR_e.js.map → useFormContext-5JLVGxh-.js.map} +1 -1
- package/dist/{useFormContext-Bp0EODoO.cjs → useFormContext-C8zLji1t.cjs} +3 -3
- package/dist/{useFormContext-Bp0EODoO.cjs.map → useFormContext-C8zLji1t.cjs.map} +1 -1
- package/dist/{useFormContext-B2TS6xq0.d.ts → useFormContext-Dmo4sBPy.d.ts} +19 -19
- package/dist/useFormContext-Dmo4sBPy.d.ts.map +1 -0
- package/dist/{useInputValueDebounce-DaH5ONlQ.js → useInputValueDebounce-Bbi6GTsR.js} +12 -3
- package/dist/useInputValueDebounce-Bbi6GTsR.js.map +1 -0
- package/dist/{useInputValueDebounce-BcUyaS94.cjs → useInputValueDebounce-D1JOnwFh.cjs} +13 -4
- package/dist/useInputValueDebounce-D1JOnwFh.cjs.map +1 -0
- package/dist/{useInputValueDebounce-DoRuSF6R.d.ts → useInputValueDebounce-DI1C6oaU.d.cts} +5 -1
- package/dist/useInputValueDebounce-DI1C6oaU.d.cts.map +1 -0
- package/dist/{useInputValueDebounce-B5b-v8Hc.d.cts → useInputValueDebounce-fhmVn1aO.d.ts} +5 -1
- package/dist/useInputValueDebounce-fhmVn1aO.d.ts.map +1 -0
- package/dist/{useInputValueTransform-D7LfyYRe.d.ts → useInputValueTransform-BV8o0PMI.d.cts} +3 -2
- package/dist/useInputValueTransform-BV8o0PMI.d.cts.map +1 -0
- package/dist/{useInputValueTransform-aiIf8lq5.js → useInputValueTransform-CMNC21vX.js} +3 -2
- package/dist/{useInputValueTransform-aiIf8lq5.js.map → useInputValueTransform-CMNC21vX.js.map} +1 -1
- package/dist/{useInputValueTransform-BID-CQ-y.d.cts → useInputValueTransform-Cc0qEsnS.d.ts} +3 -2
- package/dist/useInputValueTransform-Cc0qEsnS.d.ts.map +1 -0
- package/dist/{useInputValueTransform-DFPA3KVy.cjs → useInputValueTransform-n2XFRAUN.cjs} +4 -3
- package/dist/{useInputValueTransform-DFPA3KVy.cjs.map → useInputValueTransform-n2XFRAUN.cjs.map} +1 -1
- package/dist/{useUniformField-B2OZ-Z1G.d.cts → useUniformField-B2zQtEbr.d.cts} +4 -4
- package/dist/{useUniformField-B2OZ-Z1G.d.cts.map → useUniformField-B2zQtEbr.d.cts.map} +1 -1
- package/dist/{useUniformField-CwEHonNe.d.ts → useUniformField-BWlrKyG6.d.ts} +4 -4
- package/dist/{useUniformField-CwEHonNe.d.ts.map → useUniformField-BWlrKyG6.d.ts.map} +1 -1
- package/dist/{useUniformField-Bj23Kvbs.cjs → useUniformField-BrYZavNt.cjs} +35 -9
- package/dist/useUniformField-BrYZavNt.cjs.map +1 -0
- package/dist/{useUniformField-gU4qYUwL.js → useUniformField-Cp0JL74c.js} +34 -8
- package/dist/useUniformField-Cp0JL74c.js.map +1 -0
- package/dist/{useUniformFieldArray-CXoWvu6m.d.ts → useUniformFieldArray-D7ra7ZCk.d.ts} +14 -14
- package/dist/useUniformFieldArray-D7ra7ZCk.d.ts.map +1 -0
- package/dist/{useUniformFieldArray-G1lokW7x.cjs → useUniformFieldArray-DkkIoDVL.cjs} +5 -5
- package/dist/useUniformFieldArray-DkkIoDVL.cjs.map +1 -0
- package/dist/{useUniformFieldArray-qtJMEosJ.d.cts → useUniformFieldArray-WRuIMhw6.d.cts} +4 -4
- package/dist/useUniformFieldArray-WRuIMhw6.d.cts.map +1 -0
- package/dist/{useUniformFieldArray-B5PyxL1P.js → useUniformFieldArray-c08sO9Th.js} +4 -4
- package/dist/useUniformFieldArray-c08sO9Th.js.map +1 -0
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts → useWatchUserChange-Bf5JKDJJ.d.ts} +1 -1
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts.map → useWatchUserChange-Bf5JKDJJ.d.ts.map} +1 -1
- package/dist/{useWatchUserChange-C1ezpj0t.js → useWatchUserChange-BkUA1oym.js} +2 -2
- package/dist/{useWatchUserChange-C1ezpj0t.js.map → useWatchUserChange-BkUA1oym.js.map} +1 -1
- package/dist/{useWatchUserChange-COVdHmki.d.cts → useWatchUserChange-Br4Q7syM.d.cts} +1 -1
- package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-Br4Q7syM.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-BnxYE-0b.cjs → useWatchUserChange-cfuw7hi4.cjs} +3 -3
- package/dist/{useWatchUserChange-BnxYE-0b.cjs.map → useWatchUserChange-cfuw7hi4.cjs.map} +1 -1
- package/package.json +3 -3
- package/dist/Input-DXMWGTBh.js.map +0 -1
- package/dist/Input-DeTpxiK_.cjs.map +0 -1
- package/dist/RadioBoxes-BEln4a-B.js.map +0 -1
- package/dist/RadioBoxes-gsQGqQCd.cjs.map +0 -1
- package/dist/RadioTabs-BYpP0tKA.cjs.map +0 -1
- package/dist/RadioTabs-DLr9QiXI.js.map +0 -1
- package/dist/Radios-BCOfnTke.cjs.map +0 -1
- package/dist/Radios-DCXI2kMf.js.map +0 -1
- package/dist/Select-CyfEmWiD.js.map +0 -1
- package/dist/Select-KnPGOO27.cjs.map +0 -1
- package/dist/helpers-B-CJOBt3.js.map +0 -1
- package/dist/helpers-B84E9vHd.cjs.map +0 -1
- package/dist/index-BWNJdLDV.d.ts.map +0 -1
- package/dist/index-Bo_n9sse.d.cts.map +0 -1
- package/dist/index-BxA_pJWn.d.cts.map +0 -1
- package/dist/index-C0L7GvgN.d.cts.map +0 -1
- package/dist/index-C1PUx1tH.d.ts.map +0 -1
- package/dist/index-CADnFWHq.d.ts +0 -264
- package/dist/index-CADnFWHq.d.ts.map +0 -1
- package/dist/index-CGnr_e53.d.ts.map +0 -1
- package/dist/index-CVnn6mEI.d.ts.map +0 -1
- package/dist/index-D38wOL-M.d.ts.map +0 -1
- package/dist/index-DoS0lVRe.d.cts.map +0 -1
- package/dist/index-G0IgQWoU.d.cts +0 -134
- package/dist/index-G0IgQWoU.d.cts.map +0 -1
- package/dist/index-UjKqRe-8.d.ts +0 -134
- package/dist/index-UjKqRe-8.d.ts.map +0 -1
- package/dist/index-sJZ434Sg.d.cts +0 -264
- package/dist/index-sJZ434Sg.d.cts.map +0 -1
- package/dist/useFormContext-B083Y-kw.d.cts.map +0 -1
- package/dist/useFormContext-B2TS6xq0.d.ts.map +0 -1
- package/dist/useInputValueDebounce-B5b-v8Hc.d.cts.map +0 -1
- package/dist/useInputValueDebounce-BcUyaS94.cjs.map +0 -1
- package/dist/useInputValueDebounce-DaH5ONlQ.js.map +0 -1
- package/dist/useInputValueDebounce-DoRuSF6R.d.ts.map +0 -1
- package/dist/useInputValueTransform-BID-CQ-y.d.cts.map +0 -1
- package/dist/useInputValueTransform-D7LfyYRe.d.ts.map +0 -1
- package/dist/useUniformField-Bj23Kvbs.cjs.map +0 -1
- package/dist/useUniformField-gU4qYUwL.js.map +0 -1
- package/dist/useUniformFieldArray-B5PyxL1P.js.map +0 -1
- package/dist/useUniformFieldArray-CXoWvu6m.d.ts.map +0 -1
- package/dist/useUniformFieldArray-G1lokW7x.cjs.map +0 -1
- package/dist/useUniformFieldArray-qtJMEosJ.d.cts.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { r as isValueEmpty } from "./helpers-DPGeUbNW.js";
|
|
2
|
+
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-D9f1B-VS.js";
|
|
3
|
+
import { n as FieldValidationError_default } from "./FieldValidationError-BYwitb_B.js";
|
|
4
|
+
import { t as useController } from "./useController-BfVh3zWN.js";
|
|
5
|
+
import { n as useFormContext } from "./useFormContext-5JLVGxh-.js";
|
|
5
6
|
import { t as useInput } from "./useInput-DZ6KGBxw.js";
|
|
6
|
-
import { t as useInputValueTransform } from "./useInputValueTransform-
|
|
7
|
+
import { t as useInputValueTransform } from "./useInputValueTransform-CMNC21vX.js";
|
|
7
8
|
import { isTestEnvironment } from "@fuf-stack/pixel-utils";
|
|
8
9
|
import React from "react";
|
|
9
10
|
import { useDebounce } from "@fuf-stack/pixels";
|
|
@@ -60,7 +61,7 @@ const useDebouncedInvalid = (invalid, delayMs) => {
|
|
|
60
61
|
const useUniformField = (params) => {
|
|
61
62
|
const { name, ariaLabel: customAriaLabel, disabled = false, testId: explicitTestId, label, type, transform } = params;
|
|
62
63
|
const { control, debugMode, formState: { submitCount }, getFieldState, getValues, resetField } = useFormContext();
|
|
63
|
-
const { error, invalid: rawInvalid,
|
|
64
|
+
const { error, invalid: rawInvalid, isTouched, required, testId } = getFieldState(name, explicitTestId);
|
|
64
65
|
const { field } = useController({
|
|
65
66
|
control,
|
|
66
67
|
disabled,
|
|
@@ -76,7 +77,32 @@ const useUniformField = (params) => {
|
|
|
76
77
|
fieldOnChange(toFormValue(eventOrValue?.target?.value ?? eventOrValue));
|
|
77
78
|
};
|
|
78
79
|
const defaultValue = getValues()?.[name];
|
|
79
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Determine when to show the invalid state to the user.
|
|
82
|
+
*
|
|
83
|
+
* Show errors when the field is invalid AND any of these conditions are met:
|
|
84
|
+
* - Field has a value (show validation errors like format/length while typing)
|
|
85
|
+
* - Field is touched (focused and blurred) - good for text inputs
|
|
86
|
+
* - Form has been submitted - shows all errors after submit attempt
|
|
87
|
+
*
|
|
88
|
+
* Note: We intentionally don't use isDirty because:
|
|
89
|
+
* - Newly added array elements are marked "dirty" by RHF, causing immediate errors
|
|
90
|
+
* - Field Cards with empty initial values show errors immediately
|
|
91
|
+
* - hasValue + isTouched covers the same use cases more reliably
|
|
92
|
+
*
|
|
93
|
+
* This prevents showing errors on pristine/untouched/empty fields for better UX.
|
|
94
|
+
* Examples:
|
|
95
|
+
* - Text input: User loads form with empty required field → no error shown yet
|
|
96
|
+
* - Text input: User types invalid content → error shows immediately (has value)
|
|
97
|
+
* - Text input: User focuses and blurs without typing → error shows (via isTouched)
|
|
98
|
+
* - Checkbox/radio: User selects option → error shows immediately (has value)
|
|
99
|
+
* - Field array: User adds element → no error yet; after blur → error shows
|
|
100
|
+
* - Any field: User submits form → all errors show (via submitCount)
|
|
101
|
+
*
|
|
102
|
+
* The entire condition is debounced to prevent flickering and allow smooth animations.
|
|
103
|
+
*/
|
|
104
|
+
const hasValue = !isValueEmpty(fieldValue);
|
|
105
|
+
const invalid = useDebouncedInvalid(rawInvalid && (hasValue || isTouched || submitCount > 0), 200);
|
|
80
106
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
81
107
|
const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ jsxs(Fragment, { children: [label !== false ? label : null, showTestIdCopyButton ? /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId }) : null] }) : null;
|
|
82
108
|
const errorMessage = /* @__PURE__ */ jsx(FieldValidationError_default, {
|
|
@@ -126,4 +152,4 @@ const useUniformField = (params) => {
|
|
|
126
152
|
|
|
127
153
|
//#endregion
|
|
128
154
|
export { useUniformField as t };
|
|
129
|
-
//# sourceMappingURL=useUniformField-
|
|
155
|
+
//# sourceMappingURL=useUniformField-Cp0JL74c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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
|
-
import { r as useController$1 } from "./useController-
|
|
2
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
1
|
+
import { r as useController$1 } from "./useController-MVHJ7WFp.js";
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { r as useController } from "./useController-
|
|
2
|
-
import { n as useFormContext } from "./useFormContext
|
|
1
|
+
import { r as useController } from "./useController-BArZd2Vp.cjs";
|
|
2
|
+
import { n as useFormContext } from "./useFormContext--yod5xzQ.cjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as react_hook_form14 from "react-hook-form";
|
|
5
5
|
import { ArrayPath, FieldValues } from "react-hook-form";
|
|
@@ -50,7 +50,7 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
50
50
|
disabled: boolean | undefined;
|
|
51
51
|
error: react_hook_form14.FieldError[] | undefined;
|
|
52
52
|
errorMessage: ReactNode | null;
|
|
53
|
-
field: Omit<react_hook_form14.ControllerRenderProps<TFieldValues>, "
|
|
53
|
+
field: Omit<react_hook_form14.ControllerRenderProps<TFieldValues>, "value" | "onChange"> & {
|
|
54
54
|
onChange: (...event: any[]) => void;
|
|
55
55
|
value: string;
|
|
56
56
|
};
|
|
@@ -76,4 +76,4 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
78
|
export { useUniformFieldArray as n, UseUniformFieldArrayProps as t };
|
|
79
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
79
|
+
//# sourceMappingURL=useUniformFieldArray-WRuIMhw6.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-WRuIMhw6.d.cts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,+CACM,cAAc;;QAG7B,UAAU;;;EAJD;EACM,mBAAA,CAAA,EAAA,OAAA;EAAc;EAGnB,uBAAA,CAAA,EAAA,OAAA;EAAV;EAYE,QAAA,CAAA,EAAA,OAAA;EAAS;EAeN,MAAA,CAAA,EAAA,MAAA;EACU;EAAc,KAAA,CAAA,EAhB3B,SAgB2B;;;;;;;;;;;;;;cADxB,4CACU,cAAc;;;uBACnC;;;UAAA;;GAQC,0BAA0B;;;;;;;;;;;;;;;;;EAuDpB,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,oBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EAKwC,QAAA,EAAA,UAAA,CAAA,OALxC,aAKwC,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EACyB,UADzB,CAAA,OAAA,aAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EACyB,QAAA,EAAA,OAAA"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-c08sO9Th.js","names":["useRHFFieldArray","useFormContext"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // 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,eAAe,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,SAASA,cAAiB;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,kBAA8B;CAQ5D,MAAM,kBAAkB,cAAc;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,iBAAiB,OAAO,CAAC,gBAAgB;AAK/C,iBAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAOrB,iBAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AACf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAI9D,MAAM,uBAAuB,kBAAkB;AAC/C,iBAAgB;AACd,MAAI,eAAe,QACjB,qBAAoB,CAAC,CAAC,qBAAqB;IAE5C,CAAC,qBAAqB,CAAC;CAK1B,MAAM,sBAAsB,cAAc;AACxC,SAAO,OACH,GAAG,eAAe,wBAAwB,MAAM,GAC/C,wBAAwB,EAAE;IAC9B,CAAC,MAAM,qBAAqB,CAAC;AAUhC,iBACQ;AACJ,MAAI,iBAAiB;AAGnB,YAAS,MAA4B,CAAC,oBAAoB,EAAS;IACjE,aAAa;IACb,aAAa;IACd,CAAC;AAGF,kBAAe,UAAU;AAKzB,OAAI,CAAC,wBAAwB,iBAC3B,kBAAiB;AACf,wBAAoB,MAAM;MACzB,EAAE;;IAUX,CAAC,gBAAgB,CAClB;AAED,QAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;EACJ"}
|
|
@@ -75,4 +75,4 @@ declare const useWatchUserChange: <TFieldValues extends FieldValues = FieldValue
|
|
|
75
75
|
}: UseWatchUserChangeOptions<TFieldValues>) => void;
|
|
76
76
|
//#endregion
|
|
77
77
|
export { useWatchUserChange as n, UseWatchUserChangeOptions as t };
|
|
78
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
78
|
+
//# sourceMappingURL=useWatchUserChange-Bf5JKDJJ.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-Bf5JKDJJ.d.ts","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":[],"mappings":";;;UAYiB,+CAA+C;;EAA/C,KAAA,EAER,IAFQ,CAEH,YAFG,CAAA;EAA+C;;;;EAUhD,QAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,OAAA,EAAA;IACoB,QAAA,EADpB,eACoB,CADJ,YACI,CAAA;IAAlB,UAAA,EAAA,iBAAA,CAAkB,YAAlB,CAAA;IACQ,KAAA,EAAb,YAAa,CAAA,YAAA,CAAA;EAAb,CAAA,EAAA,GAAA,IAAA;;AA4Db;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,0CACU,cAAc;SACnC;;GAGC,0BAA0B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as useFormContext } from "./useFormContext-
|
|
1
|
+
import { n as useFormContext } from "./useFormContext-5JLVGxh-.js";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/hooks/useWatchUserChange/useWatchUserChange.ts
|
|
@@ -80,4 +80,4 @@ const useWatchUserChange = ({ watch: watchField, onChange }) => {
|
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
export { useWatchUserChange as t };
|
|
83
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
83
|
+
//# sourceMappingURL=useWatchUserChange-BkUA1oym.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-BkUA1oym.js","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnC,gBAA8B;AAEhC,iBAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
|
@@ -75,4 +75,4 @@ declare const useWatchUserChange: <TFieldValues extends FieldValues = FieldValue
|
|
|
75
75
|
}: UseWatchUserChangeOptions<TFieldValues>) => void;
|
|
76
76
|
//#endregion
|
|
77
77
|
export { useWatchUserChange as n, UseWatchUserChangeOptions as t };
|
|
78
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
78
|
+
//# sourceMappingURL=useWatchUserChange-Br4Q7syM.d.cts.map
|
package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-Br4Q7syM.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-Br4Q7syM.d.cts","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":[],"mappings":";;;UAYiB,+CAA+C;;EAA/C,KAAA,EAER,IAFQ,CAEH,YAFG,CAAA;EAA+C;;;;EAUhD,QAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,OAAA,EAAA;IACoB,QAAA,EADpB,eACoB,CADJ,YACI,CAAA;IAAlB,UAAA,EAAA,iBAAA,CAAkB,YAAlB,CAAA;IACQ,KAAA,EAAb,YAAa,CAAA,YAAA,CAAA;EAAb,CAAA,EAAA,GAAA,IAAA;;AA4Db;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,0CACU,cAAc;SACnC;;GAGC,0BAA0B"}
|
|
@@ -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/useWatchUserChange/useWatchUserChange.ts
|
|
@@ -86,4 +86,4 @@ Object.defineProperty(exports, 'useWatchUserChange', {
|
|
|
86
86
|
return useWatchUserChange;
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
89
|
+
//# sourceMappingURL=useWatchUserChange-cfuw7hi4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-cfuw7hi4.cjs","names":["useFormContext"],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnCA,uCAA8B;AAEhC,4BAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"@react-aria/visually-hidden": "3.8.29",
|
|
171
171
|
"debug": "4.4.3",
|
|
172
172
|
"framer-motion": "12.26.2",
|
|
173
|
-
"react-hook-form": "7.71.
|
|
173
|
+
"react-hook-form": "7.71.1",
|
|
174
174
|
"react-icons": "5.5.0",
|
|
175
175
|
"react-select": "5.10.2"
|
|
176
176
|
},
|
|
@@ -181,5 +181,5 @@
|
|
|
181
181
|
"react": "19.2.3",
|
|
182
182
|
"react-dom": "19.2.3"
|
|
183
183
|
},
|
|
184
|
-
"gitHead": "
|
|
184
|
+
"gitHead": "6f29e74c34e865a95c3b2647317f863d06e86c54"
|
|
185
185
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input-DXMWGTBh.js","names":["Input","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;AAcA,MAAa,gBAAgB,GAAG,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAMA,WAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACE,gBAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAU,sBAAsB;EACxD;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,aAAa,qBADF,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,oBAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,oBAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAeF;;;;AClMf,oBAAeG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Input-DeTpxiK_.cjs","names":["useUniformField","useInputValueDebounce","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;;AAcA,MAAa,+CAAmB,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAM,SAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACEA,wCAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAUC,oDAAsB;EACxD;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,8DADW,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,2CAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,2CAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAe;;;;AClMf,oBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioBoxes-BEln4a-B.js","names":["HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,MAAwB;CAOrC,MAAM,aAAa,qBAJF,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,qBAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,oBAAC,4BACC,oBAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBAAiB;KACrB,WAAW,GAAG,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,oBAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,qBAAC;IACC,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA,WACC,oBAAC;KACC,GAAI,eAAe;KACnB,WAAW,GAAG,eAAe,CAAC,WAAW,WAAW,MAAM;KAEzD;MACI,GACL,MACH,cACC,oBAAC;KAAI,WAAW,WAAW;eAAc;MAAkB,GACzD;KACA;GACL,OACC,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBAAiB;KACrB,WAAW,GAAG,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;;GACM;;;;;ACvGhB,MAAa,qBAAqB,GAAG,EACnC,OAAO;CACL,MAAM;CACN,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU;CACV,iBAAiB;CAGjB,OACE;CACF,SAAS;CACV,EACF,CAAC;;;;AA0CF,MAAM,cAAc,EAClB,YAAY,QACZ,SAAS,OACT,MACA,SACA,GAAG,wBACkB;CACrB,MAAM,EACJ,WACA,cACA,cACA,SACA,UACA,OACA,QACA,UACA,KACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAIF,MAAM,aAAa,qBADF,oBAAoB,EACa,WAAW,OAAO;CACpE,MAAM,gBAA6C;EACjD,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;EAC1B;AAED,QACE,oBAACA;EACM;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACA;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,oBAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACR,eAAe;EACf,aAAa,SAAS,eAAe;YAEpC,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,eAAe,QACnB,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,oBAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OATnB,OAAO,MAUH;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioBoxes-gsQGqQCd.cjs","names":["VisuallyHidden","useUniformField","HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;AASA,MAAa,kDAAsB;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,2CACW,MAAwB;CAOrC,MAAM,8DAJW,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,4CAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,2CAACA,wDACC,2CAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,2CAAC;IAAK,GAAI,iBAAiB;cACzB,2CAAC;KACC,GAAI,iBAAiB;KACrB,0CAAc,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,2CAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,4CAAC;IACC,GAAI,sBAAsB;IAC1B,0CACE,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA,WACC,2CAAC;KACC,GAAI,eAAe;KACnB,0CAAc,eAAe,CAAC,WAAW,WAAW,MAAM;KAEzD;MACI,GACL,MACH,cACC,2CAAC;KAAI,WAAW,WAAW;eAAc;MAAkB,GACzD;KACA;GACL,OACC,2CAAC;IAAK,GAAI,iBAAiB;cACzB,2CAAC;KACC,GAAI,iBAAiB;KACrB,0CAAc,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;;GACM;;;;;ACvGhB,MAAa,oDAAwB,EACnC,OAAO;CACL,MAAM;CACN,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,UAAU;CACV,iBAAiB;CAGjB,OACE;CACF,SAAS;CACV,EACF,CAAC;;;;AA0CF,MAAM,cAAc,EAClB,YAAY,QACZ,SAAS,OACT,MACA,SACA,GAAG,wBACkB;CACrB,MAAM,EACJ,WACA,cACA,cACA,SACA,UACA,OACA,QACA,UACA,KACA,UACA,WACEC,wCAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAIF,MAAM,8DADW,oBAAoB,EACa,WAAW,OAAO;CACpE,MAAM,gBAA6C;EACjD,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;EAC1B;AAED,QACE,2CAACC;EACM;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACA;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACR,eAAe;EACf,aAAa,SAAS,eAAe;YAEpC,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,mDACJ,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,2CAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OATnB,OAAO,MAUH;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;AChJf,yBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioTabs-BYpP0tKA.cjs","names":["useUniformField","VisuallyHidden","HeroRadioGroup","Tabs","RadioTabs"],"sources":["../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n cursor: '',\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n tab: '',\n tabBase: '',\n tabContent: '',\n tabList: '',\n tabPanel: 'p-3',\n tabWrapper: '',\n wrapper: '',\n },\n variants: {\n hasContent: {\n true: {\n base: '',\n tabBase: 'p-1',\n tabWrapper: [\n // border style\n 'rounded-medium border border-divider',\n // full width\n 'w-full',\n ],\n },\n },\n fullWidth: {\n true: {\n tabWrapper: 'w-full',\n },\n },\n isInvalid: {\n true: {\n tabWrapper: 'rounded-medium border-2 !border-danger',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** Whether tabs should take up full container width */\n fullWidth?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n fullWidth = false,\n inline = false,\n name,\n options,\n variant = undefined,\n ...uniformFieldProps\n}: RadioTabsProps): ReactElement => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create a ref for the visual radio group to forward focus\n const visualRadioGroupRef = useRef<HTMLDivElement>(null);\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n // check if any option has content\n // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async\n const hasContent = options.some((option) => {\n return option.content;\n });\n\n // classNames from slots\n const variants = radioTabsVariants({\n fullWidth,\n hasContent,\n isInvalid: invalid,\n });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n return (\n <>\n {/* Visually hidden input for React Hook Form focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n name={name}\n onBlur={onBlur}\n value={value ?? ''}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n onFocus={() => {\n // Forward focus to the first tab when RHF focuses this input\n const firstTab = visualRadioGroupRef.current?.querySelector(\n '[role=\"tab\"]',\n ) as HTMLElement;\n firstTab?.focus();\n }}\n />\n </VisuallyHidden>\n\n <HeroRadioGroup\n ref={visualRadioGroupRef}\n aria-label={ariaLabel}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={`${name}_radiotabs`}\n orientation={inline ? 'horizontal' : 'vertical'}\n classNames={{\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n }}\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n className={{\n base: classNames.tabBase,\n cursor: classNames.cursor,\n panel: classNames.tabPanel,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n tabList: classNames.tabList,\n tabWrapper: classNames.tabWrapper,\n }}\n />\n </HeroRadioGroup>\n </>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { RadioTabsProps } from './RadioTabs';\n\nexport { RadioTabs };\n\nexport default RadioTabs;\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,mDAAuB;CAClC,OAAO;EACL,MAAM;EACN,QAAQ;EACR,OACE;EACF,KAAK;EACL,SAAS;EACT,YAAY;EACZ,SAAS;EACT,UAAU;EACV,YAAY;EACZ,SAAS;EACV;CACD,UAAU;EACR,YAAY,EACV,MAAM;GACJ,MAAM;GACN,SAAS;GACT,YAAY,CAEV,wCAEA,SACD;GACF,EACF;EACD,WAAW,EACT,MAAM,EACJ,YAAY,UACb,EACF;EACD,WAAW,EACT,MAAM,EACJ,YAAY,0CACb,EACF;EACF;CACF,CAAC;;;;;AA+CF,MAAM,aAAa,EACjB,YAAY,QACZ,YAAY,OACZ,SAAS,OACT,MACA,SACA,UAAU,QACV,GAAG,wBAC+B;CAClC,MAAM,EACJ,WACA,UACA,cACA,OAAO,EAAE,QAAQ,UAAU,KAAK,SAChC,SACA,OACA,UACA,WACEA,wCAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAGF,MAAM,wCAA6C,KAAK;CAExD,MAAM,aAAa,QAAQ,KAAe,WAAW;AACnD,SAAO;GACL,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB,KAAK,OAAO;GACZ,OAAO,QAAQ,SAAS,QAAQ;GAChC,4CAAgB,UAAU,QAAQ,UAAU,QAAQ,SAAS,EAC3D,aAAa,MACd,CAAC;GACH;GACD;CAEF,MAAM,kBAAwC,YAAY,KAAK,WAAW;AACxE,SAAO,OAAO;GACd;CAcF,MAAM,8DALW,kBAAkB;EACjC;EACA,YAPiB,QAAQ,MAAM,WAAW;AAC1C,UAAO,OAAO;IACd;EAMA,WAAW;EACZ,CAAC,EACgD,WAAW,OAAO;AAEpE,QACE,qFAEE,2CAACC,wDACC,2CAAC;EACM;EACL,cAAY;EACN;EACE;EACR,OAAO,SAAS;EAChB,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;;EAE1B,eAAe;AAKb,IAHiB,oBAAoB,SAAS,cAC5C,iBACD,GACS,OAAO;;GAEnB,GACa,EAEjB,2CAACC;EACC,KAAK;EACL,cAAY;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EAC1C,MAAM,GAAG,KAAK;EACd,aAAa,SAAS,eAAe;EACrC,YAAY;GACV,MAAM,WAAW;GACjB,OAAO,WAAW;GAClB,SAAS,WAAW;GACrB;YAED,2CAACC;GACC,cAAc,WAAW,kBAAkB;GAC3C,mBAAmB;GAEnB,aAAa,SAAS;GACtB,MAAM;GACE;GACC;GACT,WAAW;IACT,MAAM,WAAW;IACjB,QAAQ,WAAW;IACnB,OAAO,WAAW;IAClB,KAAK,WAAW;IAChB,YAAY,WAAW;IACvB,SAAS,WAAW;IACpB,YAAY,WAAW;IACxB;IACD;GACa,IAChB;;AAIP,0BAAe;;;;ACzNf,wBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioTabs-DLr9QiXI.js","names":["HeroRadioGroup","RadioTabs"],"sources":["../src/RadioTabs/RadioTabs.tsx","../src/RadioTabs/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { TabsProps } from '@fuf-stack/pixels';\nimport type { TabProps } from '@fuf-stack/pixels/Tabs';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\nimport Tabs from '@fuf-stack/pixels/Tabs';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const radioTabsVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n cursor: '',\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n tab: '',\n tabBase: '',\n tabContent: '',\n tabList: '',\n tabPanel: 'p-3',\n tabWrapper: '',\n wrapper: '',\n },\n variants: {\n hasContent: {\n true: {\n base: '',\n tabBase: 'p-1',\n tabWrapper: [\n // border style\n 'rounded-medium border border-divider',\n // full width\n 'w-full',\n ],\n },\n },\n fullWidth: {\n true: {\n tabWrapper: 'w-full',\n },\n },\n isInvalid: {\n true: {\n tabWrapper: 'rounded-medium border-2 !border-danger',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof radioTabsVariants>;\ntype ClassName = TVClassName<typeof radioTabsVariants>;\n\nexport interface RadioTabsOption {\n /** Optional content inside of the tab */\n content?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioTabsProps extends Omit<VariantProps, 'hasContent'> {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** Whether tabs should take up full container width */\n fullWidth?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioTabsOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioTabs should look like. */\n variant?: TabsProps['variant'];\n}\n\n/**\n * RadioTabs component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n * and [HeroUI Tabs](https://www.heroui.com//docs/components/tabs)\n */\nconst RadioTabs = ({\n className = undefined,\n fullWidth = false,\n inline = false,\n name,\n options,\n variant = undefined,\n ...uniformFieldProps\n}: RadioTabsProps): ReactElement => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create a ref for the visual radio group to forward focus\n const visualRadioGroupRef = useRef<HTMLDivElement>(null);\n\n const tabOptions = options.map<TabProps>((option) => {\n return {\n content: option?.content,\n disabled: option?.disabled,\n key: option.value,\n label: option?.label ?? option?.value,\n testId: slugify(`option_${option?.testId ?? option?.value}`, {\n replaceDots: true,\n }),\n };\n });\n\n const disabledAllKeys: string[] | undefined = tabOptions?.map((option) => {\n return option.key as string;\n });\n\n // check if any option has content\n // eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/promise-function-async\n const hasContent = options.some((option) => {\n return option.content;\n });\n\n // classNames from slots\n const variants = radioTabsVariants({\n fullWidth,\n hasContent,\n isInvalid: invalid,\n });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n return (\n <>\n {/* Visually hidden input for React Hook Form focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n name={name}\n onBlur={onBlur}\n value={value ?? ''}\n onChange={(e) => {\n onChange(e.target.value);\n }}\n onFocus={() => {\n // Forward focus to the first tab when RHF focuses this input\n const firstTab = visualRadioGroupRef.current?.querySelector(\n '[role=\"tab\"]',\n ) as HTMLElement;\n firstTab?.focus();\n }}\n />\n </VisuallyHidden>\n\n <HeroRadioGroup\n ref={visualRadioGroupRef}\n aria-label={ariaLabel}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={`${name}_radiotabs`}\n orientation={inline ? 'horizontal' : 'vertical'}\n classNames={{\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n }}\n >\n <Tabs\n disabledKeys={disabled ? disabledAllKeys : undefined}\n onSelectionChange={onChange}\n // make sure component is controlled\n selectedKey={value ?? ''}\n tabs={tabOptions}\n testId={testId}\n variant={variant}\n className={{\n base: classNames.tabBase,\n cursor: classNames.cursor,\n panel: classNames.tabPanel,\n tab: classNames.tab,\n tabContent: classNames.tabContent,\n tabList: classNames.tabList,\n tabWrapper: classNames.tabWrapper,\n }}\n />\n </HeroRadioGroup>\n </>\n );\n};\n\nexport default RadioTabs;\n","import RadioTabs from './RadioTabs';\n\nexport type { RadioTabsProps } from './RadioTabs';\n\nexport { RadioTabs };\n\nexport default RadioTabs;\n"],"mappings":";;;;;;;;;AAeA,MAAa,oBAAoB,GAAG;CAClC,OAAO;EACL,MAAM;EACN,QAAQ;EACR,OACE;EACF,KAAK;EACL,SAAS;EACT,YAAY;EACZ,SAAS;EACT,UAAU;EACV,YAAY;EACZ,SAAS;EACV;CACD,UAAU;EACR,YAAY,EACV,MAAM;GACJ,MAAM;GACN,SAAS;GACT,YAAY,CAEV,wCAEA,SACD;GACF,EACF;EACD,WAAW,EACT,MAAM,EACJ,YAAY,UACb,EACF;EACD,WAAW,EACT,MAAM,EACJ,YAAY,0CACb,EACF;EACF;CACF,CAAC;;;;;AA+CF,MAAM,aAAa,EACjB,YAAY,QACZ,YAAY,OACZ,SAAS,OACT,MACA,SACA,UAAU,QACV,GAAG,wBAC+B;CAClC,MAAM,EACJ,WACA,UACA,cACA,OAAO,EAAE,QAAQ,UAAU,KAAK,SAChC,SACA,OACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAGF,MAAM,sBAAsB,OAAuB,KAAK;CAExD,MAAM,aAAa,QAAQ,KAAe,WAAW;AACnD,SAAO;GACL,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB,KAAK,OAAO;GACZ,OAAO,QAAQ,SAAS,QAAQ;GAChC,QAAQ,QAAQ,UAAU,QAAQ,UAAU,QAAQ,SAAS,EAC3D,aAAa,MACd,CAAC;GACH;GACD;CAEF,MAAM,kBAAwC,YAAY,KAAK,WAAW;AACxE,SAAO,OAAO;GACd;CAcF,MAAM,aAAa,qBALF,kBAAkB;EACjC;EACA,YAPiB,QAAQ,MAAM,WAAW;AAC1C,UAAO,OAAO;IACd;EAMA,WAAW;EACZ,CAAC,EACgD,WAAW,OAAO;AAEpE,QACE,4CAEE,oBAAC,4BACC,oBAAC;EACM;EACL,cAAY;EACN;EACE;EACR,OAAO,SAAS;EAChB,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;;EAE1B,eAAe;AAKb,IAHiB,oBAAoB,SAAS,cAC5C,iBACD,GACS,OAAO;;GAEnB,GACa,EAEjB,oBAACA;EACC,KAAK;EACL,cAAY;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,oBAAC,sBAAQ,QAAe,GAAG;EAC1C,MAAM,GAAG,KAAK;EACd,aAAa,SAAS,eAAe;EACrC,YAAY;GACV,MAAM,WAAW;GACjB,OAAO,WAAW;GAClB,SAAS,WAAW;GACrB;YAED,oBAAC;GACC,cAAc,WAAW,kBAAkB;GAC3C,mBAAmB;GAEnB,aAAa,SAAS;GACtB,MAAM;GACE;GACC;GACT,WAAW;IACT,MAAM,WAAW;IACjB,QAAQ,WAAW;IACnB,OAAO,WAAW;IAClB,KAAK,WAAW;IAChB,YAAY,WAAW;IACvB,SAAS,WAAW;IACpB,YAAY,WAAW;IACxB;IACD;GACa,IAChB;;AAIP,0BAAe;;;;ACzNf,wBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Radios-BCOfnTke.cjs","names":["useUniformField","HeroRadioGroup","HeroRadio","Radios"],"sources":["../src/Radios/Radios.tsx","../src/Radios/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:border-danger! [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus',\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadiosProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string | undefined}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"],"mappings":";;;;;;;AAYA,MAAa,gDAAoB,EAC/B,OAAO;CAEL,MAAM;CACN,UAAU;CACV,aAAa;CACb,iBAAiB;CACjB,WAAW;CACX,kBAAkB;CAClB,aACE;CAEF,OACE;CACF,SAAS;CACV,EACF,CAAC;;;;AAwCF,MAAM,UAAU,EACd,YAAY,QACZ,SAAS,OACT,MACA,SACA,GAAG,wBAC4B;CAC/B,MAAM,EACJ,WACA,UACA,cACA,OAAO,EAAE,QAAQ,UAAU,OAC3B,SACA,OACA,UACA,cACA,WACEA,wCAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAIF,MAAM,8DADW,gBAAgB,EACiB,WAAW,OAAO;CAEpE,MAAM,iBAAiB;EACrB,MAAM,WAAW;EACjB,SAAS,WAAW;EACpB,aAAa,WAAW;EACxB,OAAO,WAAW;EAClB,cAAc,WAAW;EACzB,SAAS,WAAW;EACrB;AAED,QACE,2CAACC;EACM;EACL,cAAY;EACA;EAGZ,gBAAc;EACd,iBAAe;EACf,eAAa;EACC;EACA;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACR,aAAa,SAAS,eAAe;YAEpC,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,mDACJ,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,2CAACC;KAEC,YAAY;KACZ,eAAa;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACvB;KACV,OAAO,OAAO;eAEb,OAAO,SAAS,OAAO;OAPnB,OAAO,MAQF;;AAGhB,UAAO;IACP;GACa;;AAIrB,uBAAe;;;;AC9If,qBAAeC"}
|