@fuf-stack/uniform 1.11.0 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checkboxes/index.cjs +1 -1
- package/dist/Checkboxes/index.d.cts +1 -1
- package/dist/Checkboxes/index.d.ts +1 -1
- package/dist/Checkboxes/index.js +1 -1
- package/dist/{Checkboxes-CGWhnpBp.js → Checkboxes-BY4UK0Xf.js} +6 -6
- package/dist/Checkboxes-BY4UK0Xf.js.map +1 -0
- package/dist/{Checkboxes-Ds6bzl6p.cjs → Checkboxes-DgCK-Wq-.cjs} +18 -18
- package/dist/Checkboxes-DgCK-Wq-.cjs.map +1 -0
- package/dist/FieldArray/index.cjs +1 -1
- package/dist/FieldArray/index.d.cts +1 -1
- package/dist/FieldArray/index.d.ts +1 -1
- package/dist/FieldArray/index.js +1 -1
- package/dist/{FieldArray-D3iUaRLo.js → FieldArray-CDLaGvNj.js} +8 -8
- package/dist/FieldArray-CDLaGvNj.js.map +1 -0
- package/dist/{FieldArray-BexXN9bO.cjs → FieldArray-DBsyUQkU.cjs} +49 -49
- package/dist/FieldArray-DBsyUQkU.cjs.map +1 -0
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/FieldCard/index.d.cts +1 -1
- package/dist/FieldCard/index.d.ts +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/{FieldCard-mpmErfDK.js → FieldCard-C1MCSbPW.js} +3 -3
- package/dist/{FieldCard-mpmErfDK.js.map → FieldCard-C1MCSbPW.js.map} +1 -1
- package/dist/{FieldCard-pP7aniZU.cjs → FieldCard-NKF358fO.cjs} +13 -13
- package/dist/{FieldCard-pP7aniZU.cjs.map → FieldCard-NKF358fO.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs → FieldCopyTestIdButton-BSYcSo2o.cjs} +10 -10
- package/dist/{FieldCopyTestIdButton-AaLwu_8y.cjs.map → FieldCopyTestIdButton-BSYcSo2o.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js → FieldCopyTestIdButton-DWPCDJ-s.js} +4 -4
- package/dist/{FieldCopyTestIdButton-Cx8AXJhO.js.map → FieldCopyTestIdButton-DWPCDJ-s.js.map} +1 -1
- package/dist/{FieldValidationError-D86DPSOH.js → FieldValidationError-1hiDEFew.js} +4 -4
- package/dist/{FieldValidationError-D86DPSOH.js.map → FieldValidationError-1hiDEFew.js.map} +1 -1
- package/dist/{FieldValidationError-Cq6aI0tE.cjs → FieldValidationError-CE8R8qry.cjs} +13 -13
- package/dist/{FieldValidationError-Cq6aI0tE.cjs.map → FieldValidationError-CE8R8qry.cjs.map} +1 -1
- package/dist/Form/index.cjs +1 -1
- package/dist/Form/index.d.ts +1 -1
- package/dist/Form/index.js +1 -1
- package/dist/{Form-FvN3SXfF.cjs → Form-BsD69fql.cjs} +19 -19
- package/dist/{Form-FvN3SXfF.cjs.map → Form-BsD69fql.cjs.map} +1 -1
- package/dist/{Form-CFmCTl60.js → Form-DRNEwHsi.js} +4 -4
- package/dist/{Form-CFmCTl60.js.map → Form-DRNEwHsi.js.map} +1 -1
- package/dist/{FormContext-C3GymQOA.cjs → FormContext-Bb6d8hdG.cjs} +8 -8
- package/dist/FormContext-Bb6d8hdG.cjs.map +1 -0
- package/dist/FormContext-CN9n_KdE.js.map +1 -1
- package/dist/Grid/index.cjs +1 -1
- package/dist/Grid/index.d.cts +1 -1
- package/dist/Grid/index.d.ts +1 -1
- package/dist/Grid/index.js +1 -1
- package/dist/{Grid-DG60vYYG.cjs → Grid-D84e76CE.cjs} +8 -8
- package/dist/{Grid-DG60vYYG.cjs.map → Grid-D84e76CE.cjs.map} +1 -1
- package/dist/{Grid-DEH7Sezi.js → Grid-LRjQlZms.js} +4 -4
- package/dist/{Grid-DEH7Sezi.js.map → Grid-LRjQlZms.js.map} +1 -1
- package/dist/Input/index.cjs +1 -1
- package/dist/Input/index.d.cts +1 -1
- package/dist/Input/index.d.ts +1 -1
- package/dist/Input/index.js +1 -1
- package/dist/{Input--h5t7Sbl.js → Input-DXMWGTBh.js} +5 -5
- package/dist/Input-DXMWGTBh.js.map +1 -0
- package/dist/{Input-DKfFFOpo.cjs → Input-DeTpxiK_.cjs} +15 -15
- package/dist/Input-DeTpxiK_.cjs.map +1 -0
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.d.cts +1 -1
- package/dist/RadioBoxes/index.d.ts +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/{RadioBoxes-7qdHj3ti.js → RadioBoxes-BEln4a-B.js} +5 -5
- package/dist/RadioBoxes-BEln4a-B.js.map +1 -0
- package/dist/{RadioBoxes-Bd9ahl4i.cjs → RadioBoxes-gsQGqQCd.cjs} +22 -22
- package/dist/RadioBoxes-gsQGqQCd.cjs.map +1 -0
- package/dist/RadioTabs/index.cjs +1 -1
- package/dist/RadioTabs/index.d.cts +1 -1
- package/dist/RadioTabs/index.d.ts +1 -1
- package/dist/RadioTabs/index.js +1 -1
- package/dist/{RadioTabs-DcEUdW7r.cjs → RadioTabs-BYpP0tKA.cjs} +18 -18
- package/dist/RadioTabs-BYpP0tKA.cjs.map +1 -0
- package/dist/{RadioTabs-DXs98jng.js → RadioTabs-DLr9QiXI.js} +5 -5
- package/dist/RadioTabs-DLr9QiXI.js.map +1 -0
- package/dist/Radios/index.cjs +1 -1
- package/dist/Radios/index.d.cts +1 -1
- package/dist/Radios/index.d.ts +1 -1
- package/dist/Radios/index.js +1 -1
- package/dist/{Radios-CIPNqPzi.cjs → Radios-BCOfnTke.cjs} +14 -14
- package/dist/{Radios-CIPNqPzi.cjs.map → Radios-BCOfnTke.cjs.map} +1 -1
- package/dist/{Radios-BIx06mzU.js → Radios-DCXI2kMf.js} +5 -5
- package/dist/{Radios-BIx06mzU.js.map → Radios-DCXI2kMf.js.map} +1 -1
- package/dist/Select/index.cjs +1 -1
- package/dist/Select/index.d.cts +1 -1
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/{Select-CBjqYDcs.js → Select-CyfEmWiD.js} +5 -5
- package/dist/Select-CyfEmWiD.js.map +1 -0
- package/dist/{Select-BsL7qn2v.cjs → Select-KnPGOO27.cjs} +19 -19
- package/dist/Select-KnPGOO27.cjs.map +1 -0
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.d.cts +1 -1
- package/dist/Slider/index.d.ts +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-BDLbD7d5.cjs → Slider-C7xxYPgR.cjs} +15 -15
- package/dist/{Slider-BDLbD7d5.cjs.map → Slider-C7xxYPgR.cjs.map} +1 -1
- package/dist/{Slider-BHjHSoIk.js → Slider-Dlhb-9hC.js} +5 -5
- package/dist/{Slider-BHjHSoIk.js.map → Slider-Dlhb-9hC.js.map} +1 -1
- package/dist/SubmitButton/index.cjs +1 -1
- package/dist/SubmitButton/index.d.cts +1 -1
- package/dist/SubmitButton/index.d.ts +1 -1
- package/dist/SubmitButton/index.js +1 -1
- package/dist/{SubmitButton-7iOaKzhB.js → SubmitButton-C5f6j0N4.js} +4 -4
- package/dist/{SubmitButton-7iOaKzhB.js.map → SubmitButton-C5f6j0N4.js.map} +1 -1
- package/dist/{SubmitButton-DhtPJuro.cjs → SubmitButton-CUBItcBn.cjs} +12 -12
- package/dist/{SubmitButton-DhtPJuro.cjs.map → SubmitButton-CUBItcBn.cjs.map} +1 -1
- package/dist/Switch/index.cjs +1 -1
- package/dist/Switch/index.d.cts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DCxAgt_L.js → Switch--m02Xcq8.js} +5 -5
- package/dist/{Switch-DCxAgt_L.js.map → Switch--m02Xcq8.js.map} +1 -1
- package/dist/{Switch-Dczzog3v.cjs → Switch-6LyeZHJh.cjs} +15 -15
- package/dist/{Switch-Dczzog3v.cjs.map → Switch-6LyeZHJh.cjs.map} +1 -1
- package/dist/SwitchBox/index.cjs +1 -1
- package/dist/SwitchBox/index.d.cts +1 -1
- package/dist/SwitchBox/index.d.ts +1 -1
- package/dist/SwitchBox/index.js +1 -1
- package/dist/{SwitchBox-DqVmZYId.cjs → SwitchBox-CtGiQdys.cjs} +19 -19
- package/dist/{SwitchBox-DqVmZYId.cjs.map → SwitchBox-CtGiQdys.cjs.map} +1 -1
- package/dist/{SwitchBox-DPHryDOM.js → SwitchBox-D0-e-pbM.js} +5 -5
- package/dist/{SwitchBox-DPHryDOM.js.map → SwitchBox-D0-e-pbM.js.map} +1 -1
- package/dist/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.d.cts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BR6e-Fio.js → TextArea-BiSnvJ69.js} +5 -5
- package/dist/{TextArea-BR6e-Fio.js.map → TextArea-BiSnvJ69.js.map} +1 -1
- package/dist/{TextArea-CH-F6_ax.cjs → TextArea-PtdSABZS.cjs} +13 -13
- package/dist/{TextArea-CH-F6_ax.cjs.map → TextArea-PtdSABZS.cjs.map} +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers-B-CJOBt3.js.map +1 -1
- package/dist/{helpers-KTgXi0lA.cjs → helpers-B84E9vHd.cjs} +4 -4
- package/dist/helpers-B84E9vHd.cjs.map +1 -0
- package/dist/hooks/useClientValidation/index.cjs +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +1 -1
- package/dist/hooks/useClientValidation/index.d.ts +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.ts +0 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +2 -2
- package/dist/hooks/useInput/index.cjs +3 -3
- package/dist/hooks/useInput/index.d.cts +1 -1
- package/dist/hooks/useInput/index.d.ts +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +3 -3
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.ts +24 -4
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/{index-CzypMcVS.d.cts → index--E2ZsMya.d.ts} +6 -6
- package/dist/{index-C_ATGeaX.d.ts.map → index--E2ZsMya.d.ts.map} +1 -1
- package/dist/{index-C56I3SOi.d.cts → index-BITJ-CZL.d.cts} +4 -4
- package/dist/{index-C56I3SOi.d.cts.map → index-BITJ-CZL.d.cts.map} +1 -1
- package/dist/{index-CVY05bZf.d.ts → index-BL0DnIzh.d.ts} +3 -3
- package/dist/{index-CVY05bZf.d.ts.map → index-BL0DnIzh.d.ts.map} +1 -1
- package/dist/{index-CHmS3ri3.d.ts → index-BQDEnYTq.d.ts} +1 -1
- package/dist/{index-CHmS3ri3.d.ts.map → index-BQDEnYTq.d.ts.map} +1 -1
- package/dist/{index-DHHBSmJb.d.ts → index-BTTo_ufh.d.ts} +1 -1
- package/dist/{index-DHHBSmJb.d.ts.map → index-BTTo_ufh.d.ts.map} +1 -1
- package/dist/{index-B74QlCAy.d.cts → index-BWNJdLDV.d.ts} +48 -48
- package/dist/{index-B4Wkijem.d.ts.map → index-BWNJdLDV.d.ts.map} +1 -1
- package/dist/{index-CraZe1qS.d.ts → index-Bj_lpc5r.d.cts} +21 -21
- package/dist/{index-CI9QBUoM.d.cts.map → index-Bj_lpc5r.d.cts.map} +1 -1
- package/dist/{index-B4Wkijem.d.ts → index-Bo_n9sse.d.cts} +47 -47
- package/dist/{index-B74QlCAy.d.cts.map → index-Bo_n9sse.d.cts.map} +1 -1
- package/dist/{index-iuLEYAix.d.cts → index-BxA_pJWn.d.cts} +21 -21
- package/dist/{index-iuLEYAix.d.cts.map → index-BxA_pJWn.d.cts.map} +1 -1
- package/dist/{index-Drl7euco.d.ts → index-C-2nxT8D.d.ts} +21 -21
- package/dist/{index-Drl7euco.d.ts.map → index-C-2nxT8D.d.ts.map} +1 -1
- package/dist/{index-C1fYmoY0.d.ts → index-C0L7GvgN.d.cts} +34 -34
- package/dist/index-C0L7GvgN.d.cts.map +1 -0
- package/dist/{index-DzuP5q-2.d.ts → index-C1PUx1tH.d.ts} +6 -6
- package/dist/index-C1PUx1tH.d.ts.map +1 -0
- package/dist/index-CADnFWHq.d.ts +264 -0
- package/dist/{index-BTEsKen4.d.ts.map → index-CADnFWHq.d.ts.map} +1 -1
- package/dist/{index-BM4XWo1K.d.ts → index-CGnr_e53.d.ts} +36 -36
- package/dist/{index-BM4XWo1K.d.ts.map → index-CGnr_e53.d.ts.map} +1 -1
- package/dist/{index-DhMSgdwM.d.ts → index-CSBE6Et0.d.cts} +6 -6
- package/dist/{index-Dklb-p_1.d.cts.map → index-CSBE6Et0.d.cts.map} +1 -1
- package/dist/{index-D6RB3b5L.d.ts → index-CVnn6mEI.d.ts} +4 -4
- package/dist/{index-D6RB3b5L.d.ts.map → index-CVnn6mEI.d.ts.map} +1 -1
- package/dist/{index-BMN2XNyT.d.cts → index-CYdvpGJF.d.cts} +3 -3
- package/dist/{index-BMN2XNyT.d.cts.map → index-CYdvpGJF.d.cts.map} +1 -1
- package/dist/{index-CbAh0Kfo.d.cts → index-Cb0AgRRa.d.cts} +3 -3
- package/dist/{index-CbAh0Kfo.d.cts.map → index-Cb0AgRRa.d.cts.map} +1 -1
- package/dist/{index-DA5um0u6.d.cts → index-D38wOL-M.d.ts} +34 -34
- package/dist/index-D38wOL-M.d.ts.map +1 -0
- package/dist/{index-DpD4MxGD.d.cts → index-DG9C0kHA.d.ts} +35 -34
- package/dist/{index-RvYO46Vg.d.ts.map → index-DG9C0kHA.d.ts.map} +1 -1
- package/dist/{index-RvYO46Vg.d.ts → index-DNkZrb7P.d.cts} +35 -36
- package/dist/{index-DpD4MxGD.d.cts.map → index-DNkZrb7P.d.cts.map} +1 -1
- package/dist/{index-C_ATGeaX.d.ts → index-DRij_w43.d.cts} +5 -5
- package/dist/{index-CzypMcVS.d.cts.map → index-DRij_w43.d.cts.map} +1 -1
- package/dist/{index-Dklb-p_1.d.cts → index-DmMenZfj.d.ts} +5 -5
- package/dist/{index-DhMSgdwM.d.ts.map → index-DmMenZfj.d.ts.map} +1 -1
- package/dist/{index-CI9QBUoM.d.cts → index-DnzC0GCS.d.ts} +3 -3
- package/dist/index-DnzC0GCS.d.ts.map +1 -0
- package/dist/{index-BOI0cy-n.d.cts → index-DoS0lVRe.d.cts} +34 -34
- package/dist/index-DoS0lVRe.d.cts.map +1 -0
- package/dist/{index-aHcGnXHf.d.ts → index-DvB46QAb.d.ts} +3 -3
- package/dist/{index-aHcGnXHf.d.ts.map → index-DvB46QAb.d.ts.map} +1 -1
- package/dist/{index-BW9EUWZE.d.cts → index-DxdaxM3o.d.cts} +3 -3
- package/dist/{index-BW9EUWZE.d.cts.map → index-DxdaxM3o.d.cts.map} +1 -1
- package/dist/{index-CQWoxgWk.d.ts → index-Edx7MxXu.d.ts} +3 -3
- package/dist/{index-CQWoxgWk.d.ts.map → index-Edx7MxXu.d.ts.map} +1 -1
- package/dist/{index-BaBZGCqS.d.cts → index-F11geOHD.d.ts} +6 -6
- package/dist/{index-CvA5yKx9.d.ts.map → index-F11geOHD.d.ts.map} +1 -1
- package/dist/{index-1gPh6Uoh.d.cts → index-PU5WNOH9.d.cts} +3 -3
- package/dist/{index-1gPh6Uoh.d.cts.map → index-PU5WNOH9.d.cts.map} +1 -1
- package/dist/{index-CO-l7RmT.d.cts → index-WogV9uVV.d.cts} +6 -6
- package/dist/{index-CO-l7RmT.d.cts.map → index-WogV9uVV.d.cts.map} +1 -1
- package/dist/{index-CvA5yKx9.d.ts → index-oyX8xu0F.d.cts} +4 -4
- package/dist/{index-BaBZGCqS.d.cts.map → index-oyX8xu0F.d.cts.map} +1 -1
- package/dist/index-sJZ434Sg.d.cts +264 -0
- package/dist/index-sJZ434Sg.d.cts.map +1 -0
- package/dist/index.cjs +29 -29
- package/dist/index.d.cts +22 -22
- package/dist/index.d.ts +24 -25
- package/dist/index.js +19 -19
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +1 -1
- package/dist/partials/FieldValidationError/index.d.ts +1 -1
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/dist/{useClientValidation-CkBtUSco.d.ts → useClientValidation-BQqwz628.d.cts} +3 -3
- package/dist/{useClientValidation-C3Q5UCy9.d.cts.map → useClientValidation-BQqwz628.d.cts.map} +1 -1
- package/dist/useClientValidation-BnnscAEe.js.map +1 -1
- package/dist/{useClientValidation-oZd4_ocQ.cjs → useClientValidation-CmYVGlLr.cjs} +7 -7
- package/dist/useClientValidation-CmYVGlLr.cjs.map +1 -0
- package/dist/{useClientValidation-C3Q5UCy9.d.cts → useClientValidation-DJ4JuN_9.d.ts} +3 -3
- package/dist/{useClientValidation-CkBtUSco.d.ts.map → useClientValidation-DJ4JuN_9.d.ts.map} +1 -1
- package/dist/{useController-BzkCcbSo.cjs → useController-CkmO5CLh.cjs} +3 -3
- package/dist/{useController-BzkCcbSo.cjs.map → useController-CkmO5CLh.cjs.map} +1 -1
- package/dist/{useFormContext-CZh7pv8f.d.cts → useFormContext-B083Y-kw.d.cts} +17 -17
- package/dist/{useFormContext-CZh7pv8f.d.cts.map → useFormContext-B083Y-kw.d.cts.map} +1 -1
- package/dist/{useFormContext-3AAPT6eZ.d.ts → useFormContext-B2TS6xq0.d.ts} +1 -1
- package/dist/{useFormContext-3AAPT6eZ.d.ts.map → useFormContext-B2TS6xq0.d.ts.map} +1 -1
- package/dist/{useFormContext-CWuN-_7P.cjs → useFormContext-Bp0EODoO.cjs} +3 -3
- package/dist/useFormContext-Bp0EODoO.cjs.map +1 -0
- package/dist/useFormContext-JCm1UR_e.js.map +1 -1
- package/dist/{useInputValueDebounce-B2RzCWty.d.cts → useInputValueDebounce-B5b-v8Hc.d.cts} +1 -1
- package/dist/{useInputValueDebounce-B2RzCWty.d.cts.map → useInputValueDebounce-B5b-v8Hc.d.cts.map} +1 -1
- package/dist/{useInputValueDebounce-tL8maIp8.cjs → useInputValueDebounce-BcUyaS94.cjs} +2 -2
- package/dist/{useInputValueDebounce-tL8maIp8.cjs.map → useInputValueDebounce-BcUyaS94.cjs.map} +1 -1
- package/dist/{useInputValueDebounce-C7_bvNGH.d.ts → useInputValueDebounce-DoRuSF6R.d.ts} +1 -1
- package/dist/{useInputValueDebounce-C7_bvNGH.d.ts.map → useInputValueDebounce-DoRuSF6R.d.ts.map} +1 -1
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs → useInputValueTransform-DFPA3KVy.cjs} +2 -2
- package/dist/{useInputValueTransform-C-uSW8Y3.cjs.map → useInputValueTransform-DFPA3KVy.cjs.map} +1 -1
- package/dist/{useUniformField-Be3kdnhK.d.cts → useUniformField-B2OZ-Z1G.d.cts} +3 -3
- package/dist/{useUniformField-Be3kdnhK.d.cts.map → useUniformField-B2OZ-Z1G.d.cts.map} +1 -1
- package/dist/{useUniformField-BMvnRC_r.cjs → useUniformField-Bj23Kvbs.cjs} +13 -13
- package/dist/useUniformField-Bj23Kvbs.cjs.map +1 -0
- package/dist/{useUniformField-DDHQ5B11.d.ts → useUniformField-CwEHonNe.d.ts} +3 -3
- package/dist/{useUniformField-DDHQ5B11.d.ts.map → useUniformField-CwEHonNe.d.ts.map} +1 -1
- package/dist/{useUniformField-ClprfrES.js → useUniformField-gU4qYUwL.js} +3 -3
- package/dist/useUniformField-gU4qYUwL.js.map +1 -0
- package/dist/{useUniformFieldArray-C-0OXG3N.js → useUniformFieldArray-B5PyxL1P.js} +2 -2
- package/dist/{useUniformFieldArray-C-0OXG3N.js.map → useUniformFieldArray-B5PyxL1P.js.map} +1 -1
- package/dist/{useUniformFieldArray-BhPi3gPv.d.ts → useUniformFieldArray-CXoWvu6m.d.ts} +3 -3
- package/dist/{useUniformFieldArray-BhPi3gPv.d.ts.map → useUniformFieldArray-CXoWvu6m.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-btjvJdZ6.cjs → useUniformFieldArray-G1lokW7x.cjs} +7 -7
- package/dist/{useUniformFieldArray-btjvJdZ6.cjs.map → useUniformFieldArray-G1lokW7x.cjs.map} +1 -1
- package/dist/{useUniformFieldArray-BBFw08qL.d.cts → useUniformFieldArray-qtJMEosJ.d.cts} +13 -13
- package/dist/{useUniformFieldArray-BBFw08qL.d.cts.map → useUniformFieldArray-qtJMEosJ.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-C5dr12By.cjs → useWatchUserChange-BnxYE-0b.cjs} +3 -3
- package/dist/{useWatchUserChange-C5dr12By.cjs.map → useWatchUserChange-BnxYE-0b.cjs.map} +1 -1
- package/package.json +10 -10
- package/dist/Checkboxes-CGWhnpBp.js.map +0 -1
- package/dist/Checkboxes-Ds6bzl6p.cjs.map +0 -1
- package/dist/FieldArray-BexXN9bO.cjs.map +0 -1
- package/dist/FieldArray-D3iUaRLo.js.map +0 -1
- package/dist/FormContext-C3GymQOA.cjs.map +0 -1
- package/dist/Input--h5t7Sbl.js.map +0 -1
- package/dist/Input-DKfFFOpo.cjs.map +0 -1
- package/dist/RadioBoxes-7qdHj3ti.js.map +0 -1
- package/dist/RadioBoxes-Bd9ahl4i.cjs.map +0 -1
- package/dist/RadioTabs-DXs98jng.js.map +0 -1
- package/dist/RadioTabs-DcEUdW7r.cjs.map +0 -1
- package/dist/Select-BsL7qn2v.cjs.map +0 -1
- package/dist/Select-CBjqYDcs.js.map +0 -1
- package/dist/helpers-KTgXi0lA.cjs.map +0 -1
- package/dist/index-BOI0cy-n.d.cts.map +0 -1
- package/dist/index-BTEsKen4.d.ts +0 -264
- package/dist/index-C1fYmoY0.d.ts.map +0 -1
- package/dist/index-CJNLQVjx.d.ts +0 -1
- package/dist/index-CqV2Q3da.d.cts +0 -264
- package/dist/index-CqV2Q3da.d.cts.map +0 -1
- package/dist/index-CraZe1qS.d.ts.map +0 -1
- package/dist/index-CwSIy_W-.d.cts +0 -1
- package/dist/index-DA5um0u6.d.cts.map +0 -1
- package/dist/index-DzuP5q-2.d.ts.map +0 -1
- package/dist/useClientValidation-oZd4_ocQ.cjs.map +0 -1
- package/dist/useFormContext-CWuN-_7P.cjs.map +0 -1
- package/dist/useUniformField-BMvnRC_r.cjs.map +0 -1
- package/dist/useUniformField-ClprfrES.js.map +0 -1
- /package/dist/{index-B3Z8gdjC.d.ts → index-BRLjimYW.d.ts} +0 -0
- /package/dist/{index-BXpMZvwA.d.cts → index-DpEKQcoR.d.cts} +0 -0
- /package/dist/{useInput-IGJqJ2tR.d.ts → useInput--wjwIBc5.d.cts} +0 -0
- /package/dist/{useInput-NMHJNZ5A.d.cts → useInput-BCdeYOOg.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as InputValueTransform } from "./useInputValueTransform-BID-CQ-y.cjs";
|
|
2
2
|
import { r as useController } from "./useController-C_MZLZIp.cjs";
|
|
3
|
-
import { n as useFormContext } from "./useFormContext-
|
|
4
|
-
import { t as useInput } from "./useInput
|
|
3
|
+
import { n as useFormContext } from "./useFormContext-B083Y-kw.cjs";
|
|
4
|
+
import { t as useInput } from "./useInput--wjwIBc5.cjs";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
7
7
|
|
|
@@ -95,4 +95,4 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
95
95
|
declare const useUniformField: <TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>) => UseUniformFieldReturn<TFieldValues>;
|
|
96
96
|
//#endregion
|
|
97
97
|
export { UseUniformFieldReturn as n, useUniformField as r, UseUniformFieldParams as t };
|
|
98
|
-
//# sourceMappingURL=useUniformField-
|
|
98
|
+
//# sourceMappingURL=useUniformField-B2OZ-Z1G.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-
|
|
1
|
+
{"version":3,"file":"useUniformField-B2OZ-Z1G.d.cts","names":[],"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"sourcesContent":[],"mappings":";;;;;;;;UAyCiB,2CACM,cAAc;;EADpB,IAAA,EAKT,IALS,CAKJ,YALI,CAAqB,GAAA,MAAA;EACf;EAAc,SAAA,CAAA,EAAA,MAAA;EAIxB;EAAL,QAAA,CAAA,EAAA,OAAA;EAME;EAIwB,KAAA,CAAA,EAJxB,SAIwB;EAApB;EAAmB,MAAA,CAAA,EAAA,MAAA;EAKhB;EACM,SAAA,CAAA,EANT,mBAMS,CANW,QAMX,CAAA;EAAc;EAKO,IAAA,CAAA,EAAA,MAAA,GAAA,QAAA,GAAA,UAAA;;AAAjC,UANM,qBAMN,CAAA,qBALY,WAKZ,GAL0B,WAK1B,CAAA,CAAA;EAEmC;EAAf,SAAA,EAAA,MAAA,GAAA,SAAA;EAAlB;EAMJ,OAAA,EARE,UAQF,CAAA,OARoB,cAQpB,CARmC,YAQnC,CAAA,CAAA,CAAA,SAAA,CAAA;EAEO;EAEyB,SAAA,EAV5B,UAU4B,CAAA,OAVV,cAUU,CAVK,YAUL,CAAA,CAAA,CAAA,WAAA,CAAA;EAAd;EAAlB,YAAA,EAAA,OAAA;EAEiC;EAAlB,QAAA,EAAA,OAAA,GAAA,SAAA;EAEmB;EAAlB,KAAA,EARhB,UAQgB,EAAA,GAAA,SAAA;EAEU;EAAlB,YAAA,EARD,SAQC,GAAA,IAAA;EAE6B;EAAf,KAAA,EARtB,UAQsB,CAAA,OARJ,aAQI,CARU,YAQV,CAAA,CAAA,CAAA,OAAA,CAAA;EAAlB;EAIJ,oBAAA,EAVe,UAUf,CAAA,OAViC,QAUjC,CAAA,CAAA,sBAAA,CAAA;EAEiC;EAAd,qBAAA,EAVH,UAUG,CAAA,OAVe,QAUf,CAAA,CAAA,uBAAA,CAAA;EAAlB;EAEkC,aAAA,EAV3B,UAU2B,CAAA,OAVT,QAUS,CAAA,CAAA,eAAA,CAAA;EAAd;EAAlB,SAAA,EARC,UAQD,CAAA,OARmB,cAQnB,CARkC,YAQlC,CAAA,CAAA,CAAA,WAAA,CAAA;EAE2B;EAAd,OAAA,EAAA,OAAA;EAAlB;EAIwC,KAAA,EAVtC,SAUsC,GAAA,IAAA;EAAf;EAAlB,MAAA,EARJ,UAQI,CAAA,OARc,aAQd,CAR4B,YAQ5B,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EAAU;EAiCX,QAAA,EAvCD,UAqMX,CAAA,OArM6B,aAqM7B,CArM2C,YAqM3C,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EA7JsB;EAAc,GAAA,EAtC9B,UAsC8B,CAAA,OAtCZ,aAsCY,CAtCE,YAsCF,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGL;EAAc,QAAA,EAAA,OAAA;EAApC;EACe,UAAA,EAtCX,UAsCW,CAAA,OAtCO,cAsCP,CAtCsB,YAsCtB,CAAA,CAAA,CAAA,YAAA,CAAA;EAAtB;EAAqB,MAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cALX,uCACU,cAAc,yCAG3B,sBAAsB,cAAc,cAC3C,sBAAsB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_FieldCopyTestIdButton = require('./FieldCopyTestIdButton-
|
|
3
|
-
const require_FieldValidationError = require('./FieldValidationError-
|
|
4
|
-
const require_useController = require('./useController-
|
|
5
|
-
const require_useFormContext = require('./useFormContext-
|
|
6
|
-
const require_useInputValueTransform = require('./useInputValueTransform-
|
|
7
|
-
let
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
|
+
const require_FieldCopyTestIdButton = require('./FieldCopyTestIdButton-BSYcSo2o.cjs');
|
|
3
|
+
const require_FieldValidationError = require('./FieldValidationError-CE8R8qry.cjs');
|
|
4
|
+
const require_useController = require('./useController-CkmO5CLh.cjs');
|
|
5
|
+
const require_useFormContext = require('./useFormContext-Bp0EODoO.cjs');
|
|
6
|
+
const require_useInputValueTransform = require('./useInputValueTransform-DFPA3KVy.cjs');
|
|
7
|
+
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_FormContext.__toESM(react);
|
|
10
|
-
let
|
|
10
|
+
let _fuf_stack_pixels = require("@fuf-stack/pixels");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
-
let
|
|
12
|
+
let _heroui_input = require("@heroui/input");
|
|
13
13
|
|
|
14
14
|
//#region src/hooks/useUniformField/useUniformField.tsx
|
|
15
15
|
/**
|
|
@@ -27,8 +27,8 @@ let __heroui_input = require("@heroui/input");
|
|
|
27
27
|
* - Disabled in test environments for immediate snapshots
|
|
28
28
|
*/
|
|
29
29
|
const useDebouncedInvalid = (invalid, delayMs) => {
|
|
30
|
-
const debouncedInvalid = (0,
|
|
31
|
-
if ((0,
|
|
30
|
+
const debouncedInvalid = (0, _fuf_stack_pixels.useDebounce)(invalid, delayMs);
|
|
31
|
+
if ((0, _fuf_stack_pixel_utils.isTestEnvironment)()) return invalid;
|
|
32
32
|
return debouncedInvalid;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
@@ -85,7 +85,7 @@ const useUniformField = (params) => {
|
|
|
85
85
|
error,
|
|
86
86
|
testId
|
|
87
87
|
});
|
|
88
|
-
const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } = (0,
|
|
88
|
+
const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } = (0, _heroui_input.useInput)({
|
|
89
89
|
ref,
|
|
90
90
|
classNames: { helperWrapper: "p-0" },
|
|
91
91
|
errorMessage: JSON.stringify(error),
|
|
@@ -133,4 +133,4 @@ Object.defineProperty(exports, 'useUniformField', {
|
|
|
133
133
|
return useUniformField;
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
-
//# sourceMappingURL=useUniformField-
|
|
136
|
+
//# sourceMappingURL=useUniformField-Bj23Kvbs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUniformField-Bj23Kvbs.cjs","names":["useFormContext","useController","useInputValueTransform","FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useUniformField/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\nimport type { InputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\nimport React from 'react';\n\nimport { isTestEnvironment } from '@fuf-stack/pixel-utils';\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Debounce invalid state changes to prevent UI flicker on rapid changes.\n *\n * Primary purpose: Reduce UI flicker when validation state changes rapidly\n * (e.g., during fast typing). Without debouncing, error messages would flash\n * in/out rapidly, creating a poor UX.\n *\n * Secondary benefit: When animations are enabled (default), gives time for\n * enter/exit animations to complete smoothly.\n *\n * Behavior:\n * - Debounces both true → false and false → true transitions by `delayMs`\n * - Disabled in test environments for immediate snapshots\n */\nconst useDebouncedInvalid = (invalid: boolean, delayMs: number) => {\n const debouncedInvalid = useDebounce(invalid, delayMs);\n\n // Disable debouncing in test environments for immediate snapshots\n if (isTestEnvironment()) {\n return invalid;\n }\n\n return debouncedInvalid;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,sDAA+B,SAAS,QAAQ;AAGtD,oDAAuB,CACrB,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGT,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACEA,uCAA8B;CAElC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,eAAe;CAEvC,MAAM,EAAE,UAAUC,oCAA4B;EAC5C;EACA;EACA;EACD,CAAC;CACF,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgBC,sDAAiC;EACvE;EACA;EACD,CAAC;CAGF,MAAM,mBAAmB,eAAe,WAAW;CACnD,MAAM,uBAAuB,iBAA+C;AAM1E,gBADkB,YAFf,cAAsD,QAAQ,SAC/D,aACqD,CACV;;CAG/C,MAAM,eAAgB,WAAW,GAC/B;CAsBF,MAAM,UAAU,oBADI,eAAe,WAAW,aAAa,cAAc,IACxB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,qFACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,2CAACC,iEAA8B,SAAU,GACvC,QACH,GACD;CAIN,MAAM,eAAe,2CAACC;EAA4B;EAAe;GAAU;CAK3E,MAAM,EAAE,sBAAsB,eAAe,sDAClC;EACP;EACA,YAAY,EAEV,eAAe,OAChB;EACD,cAAc,KAAK,UAAU,MAAM;EACnC,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EACjB,CAAC;AAQJ,QAAO;EACL,WAHA,oBAAoB,OAAO,UAAU,WAAW,QAAQ;EAIxD;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,OAAO;GACL,GAAG;GACH,OAAO;GACP,UAAU;GACX;EACD;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,UAAU;EACV;EACA;EACA;EACA;EACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as InputValueTransform } from "./useInputValueTransform-D7LfyYRe.js";
|
|
2
2
|
import { r as useController$1 } from "./useController-hjpJQf0w.js";
|
|
3
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
4
|
-
import { t as useInput } from "./useInput-
|
|
3
|
+
import { n as useFormContext$1 } from "./useFormContext-B2TS6xq0.js";
|
|
4
|
+
import { t as useInput } from "./useInput-BCdeYOOg.js";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
7
7
|
|
|
@@ -95,4 +95,4 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
95
95
|
declare const useUniformField: <TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>) => UseUniformFieldReturn<TFieldValues>;
|
|
96
96
|
//#endregion
|
|
97
97
|
export { UseUniformFieldReturn as n, useUniformField as r, UseUniformFieldParams as t };
|
|
98
|
-
//# sourceMappingURL=useUniformField-
|
|
98
|
+
//# sourceMappingURL=useUniformField-CwEHonNe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-
|
|
1
|
+
{"version":3,"file":"useUniformField-CwEHonNe.d.ts","names":[],"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"sourcesContent":[],"mappings":";;;;;;;;UAyCiB,2CACM,cAAc;;EADpB,IAAA,EAKT,IALS,CAKJ,YALI,CAAqB,GAAA,MAAA;EACf;EAAc,SAAA,CAAA,EAAA,MAAA;EAIxB;EAAL,QAAA,CAAA,EAAA,OAAA;EAME;EAIwB,KAAA,CAAA,EAJxB,SAIwB;EAApB;EAAmB,MAAA,CAAA,EAAA,MAAA;EAKhB;EACM,SAAA,CAAA,EANT,mBAMS,CANW,QAMX,CAAA;EAAc;EAKO,IAAA,CAAA,EAAA,MAAA,GAAA,QAAA,GAAA,UAAA;;AAAjC,UANM,qBAMN,CAAA,qBALY,WAKZ,GAL0B,WAK1B,CAAA,CAAA;EAEmC;EAAf,SAAA,EAAA,MAAA,GAAA,SAAA;EAAlB;EAMJ,OAAA,EARE,UAQF,CAAA,OARoB,gBAQpB,CARmC,YAQnC,CAAA,CAAA,CAAA,SAAA,CAAA;EAEO;EAEyB,SAAA,EAV5B,UAU4B,CAAA,OAVV,gBAUU,CAVK,YAUL,CAAA,CAAA,CAAA,WAAA,CAAA;EAAd;EAAlB,YAAA,EAAA,OAAA;EAEiC;EAAlB,QAAA,EAAA,OAAA,GAAA,SAAA;EAEmB;EAAlB,KAAA,EARhB,UAQgB,EAAA,GAAA,SAAA;EAEU;EAAlB,YAAA,EARD,SAQC,GAAA,IAAA;EAE6B;EAAf,KAAA,EARtB,UAQsB,CAAA,OARJ,eAQI,CARU,YAQV,CAAA,CAAA,CAAA,OAAA,CAAA;EAAlB;EAIJ,oBAAA,EAVe,UAUf,CAAA,OAViC,QAUjC,CAAA,CAAA,sBAAA,CAAA;EAEiC;EAAd,qBAAA,EAVH,UAUG,CAAA,OAVe,QAUf,CAAA,CAAA,uBAAA,CAAA;EAAlB;EAEkC,aAAA,EAV3B,UAU2B,CAAA,OAVT,QAUS,CAAA,CAAA,eAAA,CAAA;EAAd;EAAlB,SAAA,EARC,UAQD,CAAA,OARmB,gBAQnB,CARkC,YAQlC,CAAA,CAAA,CAAA,WAAA,CAAA;EAE2B;EAAd,OAAA,EAAA,OAAA;EAAlB;EAIwC,KAAA,EAVtC,SAUsC,GAAA,IAAA;EAAf;EAAlB,MAAA,EARJ,UAQI,CAAA,OARc,eAQd,CAR4B,YAQ5B,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EAAU;EAiCX,QAAA,EAvCD,UAqMX,CAAA,OArM6B,eAqM7B,CArM2C,YAqM3C,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EA7JsB;EAAc,GAAA,EAtC9B,UAsC8B,CAAA,OAtCZ,eAsCY,CAtCE,YAsCF,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGL;EAAc,QAAA,EAAA,OAAA;EAApC;EACe,UAAA,EAtCX,UAsCW,CAAA,OAtCO,gBAsCP,CAtCsB,YAsCtB,CAAA,CAAA,CAAA,YAAA,CAAA;EAAtB;EAAqB,MAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cALX,uCACU,cAAc,yCAG3B,sBAAsB,cAAc,cAC3C,sBAAsB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-
|
|
2
|
-
import { n as FieldValidationError_default } from "./FieldValidationError-
|
|
1
|
+
import { n as FieldCopyTestIdButton_default } from "./FieldCopyTestIdButton-DWPCDJ-s.js";
|
|
2
|
+
import { n as FieldValidationError_default } from "./FieldValidationError-1hiDEFew.js";
|
|
3
3
|
import { t as useController } from "./useController-CumIERks.js";
|
|
4
4
|
import { n as useFormContext } from "./useFormContext-JCm1UR_e.js";
|
|
5
5
|
import { t as useInput } from "./useInput-DZ6KGBxw.js";
|
|
@@ -126,4 +126,4 @@ const useUniformField = (params) => {
|
|
|
126
126
|
|
|
127
127
|
//#endregion
|
|
128
128
|
export { useUniformField as t };
|
|
129
|
-
//# sourceMappingURL=useUniformField-
|
|
129
|
+
//# sourceMappingURL=useUniformField-gU4qYUwL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUniformField-gU4qYUwL.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 { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Debounce invalid state changes to prevent UI flicker on rapid changes.\n *\n * Primary purpose: Reduce UI flicker when validation state changes rapidly\n * (e.g., during fast typing). Without debouncing, error messages would flash\n * in/out rapidly, creating a poor UX.\n *\n * Secondary benefit: When animations are enabled (default), gives time for\n * enter/exit animations to complete smoothly.\n *\n * Behavior:\n * - Debounces both true → false and false → true transitions by `delayMs`\n * - Disabled in test environments for immediate snapshots\n */\nconst useDebouncedInvalid = (invalid: boolean, delayMs: number) => {\n const debouncedInvalid = useDebounce(invalid, delayMs);\n\n // Disable debouncing in test environments for immediate snapshots\n if (isTestEnvironment()) {\n return invalid;\n }\n\n return debouncedInvalid;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional value transformation between form and display values */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Computed aria-label fallback (field name) when no visible label exists. Components can override based on their accessibility needs (e.g., if placeholder provides sufficient context) */\n ariaLabel: string | undefined;\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with transformed value/onChange (use this for simple components) */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with transform applied) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Value transformation via `transform` prop:\n * • Allows disentangled display and form values (e.g., string ↔ object, boolean ↔ array)\n * • Automatically applies `toDisplayValue` to field value for components\n * • Automatically applies `toFormValue` to display value when onChange is called\n * • Works with `type` prop for automatic number/string conversion\n * • Examples: storing objects while displaying strings, storing booleans as arrays, enriching values with metadata\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport const useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UseUniformFieldReturn<TFieldValues> => {\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n testId: explicitTestId,\n label,\n type,\n transform,\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = field;\n\n // Get transform utilities (but don't apply them automatically)\n // Components can choose how to use them (directly or via useInputValueDebounce)\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n type,\n transform,\n });\n\n // For components without special needs: apply transform to value and onChange\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // Extract value from event or use value directly\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue as typeof fieldValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute aria-label: prefer custom prop, then use string label if available, otherwise field name\n // Components can further override this based on their specific accessibility needs\n // (e.g., Input/TextArea may skip this if they have a meaningful placeholder)\n const ariaLabel =\n customAriaLabel ?? (typeof label === 'string' ? label : name);\n\n return {\n ariaLabel,\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field: {\n ...field,\n value: transformedValue as typeof field.value,\n onChange: transformedOnChange as typeof field.onChange,\n },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange: transformedOnChange as typeof field.onChange,\n ref,\n required,\n resetField,\n testId,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformField';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,SAAkB,YAAoB;CACjE,MAAM,mBAAmB,YAAY,SAAS,QAAQ;AAGtD,KAAI,mBAAmB,CACrB,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGT,MAAa,mBAIX,WACwC;CACxC,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,QAAQ,gBACR,OACA,MACA,cACE;CAEJ,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,eACA,WACA,eACE,gBAA8B;CAElC,MAAM,EACJ,OACA,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,eAAe;CAEvC,MAAM,EAAE,UAAU,cAA4B;EAC5C;EACA;EACA;EACD,CAAC;CACF,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAIJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;EACD,CAAC;CAGF,MAAM,mBAAmB,eAAe,WAAW;CACnD,MAAM,uBAAuB,iBAA+C;AAM1E,gBADkB,YAFf,cAAsD,QAAQ,SAC/D,aACqD,CACV;;CAG/C,MAAM,eAAgB,WAAW,GAC/B;CAsBF,MAAM,UAAU,oBADI,eAAe,WAAW,aAAa,cAAc,IACxB,IAAI;CAMrD,MAAM,uBAAuB,cAAc;CAC3C,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,6 +1,6 @@
|
|
|
1
1
|
import { t as flatArrayKey } from "./helpers-B-CJOBt3.js";
|
|
2
2
|
import { n as useFormContext$1 } from "./useFormContext-JCm1UR_e.js";
|
|
3
|
-
import { t as useUniformField } from "./useUniformField-
|
|
3
|
+
import { t as useUniformField } from "./useUniformField-gU4qYUwL.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-B5PyxL1P.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-B5PyxL1P.js","names":["useRHFFieldArray","useFormContext"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAe,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,SAASA,cAAiB;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,kBAA8B;CAQ5D,MAAM,kBAAkB,cAAc;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,iBAAiB,OAAO,CAAC,gBAAgB;AAK/C,iBAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAIrB,iBAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AAEf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAI9D,MAAM,uBAAuB,kBAAkB;AAC/C,iBAAgB;AACd,MAAI,eAAe,QACjB,qBAAoB,CAAC,CAAC,qBAAqB;IAE5C,CAAC,qBAAqB,CAAC;CAK1B,MAAM,sBAAsB,cAAc;AACxC,SAAO,OACH,GAAG,eAAe,wBAAwB,MAAM,GAC/C,wBAAwB,EAAE;IAC9B,CAAC,MAAM,qBAAqB,CAAC;AAUhC,iBACQ;AACJ,MAAI,iBAAiB;AAGnB,YAAS,MAA4B,CAAC,oBAAoB,EAAS;IACjE,aAAa;IACb,aAAa;IACd,CAAC;AAGF,kBAAe,UAAU;AAKzB,OAAI,CAAC,wBAAwB,iBAC3B,kBAAiB;AACf,wBAAoB,MAAM;MACzB,EAAE;;IAUX,CAAC,gBAAgB,CAClB;AAED,QAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;EACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useController$1 } from "./useController-hjpJQf0w.js";
|
|
2
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
2
|
+
import { n as useFormContext$1 } from "./useFormContext-B2TS6xq0.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as react_hook_form0 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_form0.FieldError[] | undefined;
|
|
52
52
|
errorMessage: ReactNode | null;
|
|
53
|
-
field: Omit<react_hook_form0.ControllerRenderProps<TFieldValues>, "
|
|
53
|
+
field: Omit<react_hook_form0.ControllerRenderProps<TFieldValues>, "onChange" | "value"> & {
|
|
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-CXoWvu6m.d.ts.map
|
package/dist/{useUniformFieldArray-BhPi3gPv.d.ts.map → useUniformFieldArray-CXoWvu6m.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-CXoWvu6m.d.ts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,+CACM,cAAc;;QAG7B,UAAU;;;EAJD;EACM,mBAAA,CAAA,EAAA,OAAA;EAAc;EAGnB,uBAAA,CAAA,EAAA,OAAA;EAAV;EAYE,QAAA,CAAA,EAAA,OAAA;EAAS;EAeN,MAAA,CAAA,EAAA,MAAA;EACU;EAAc,KAAA,CAAA,EAhB3B,SAgB2B;;;;;;;;;;;;;;cADxB,4CACU,cAAc;;;uBACnC;;;UAAA;;GAQC,0BAA0B;;;;;;;;;;;;;;;;;EA0DF,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,sBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EACiD,QAAA,EAAA,UAAA,CAAA,OADjD,eACiD,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EAGnC,UAHmC,CAAA,OAAA,eAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGnC,QAAA,EAAA,OAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
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-Bb6d8hdG.cjs');
|
|
2
|
+
const require_helpers = require('./helpers-B84E9vHd.cjs');
|
|
3
|
+
const require_useFormContext = require('./useFormContext-Bp0EODoO.cjs');
|
|
4
|
+
const require_useUniformField = require('./useUniformField-Bj23Kvbs.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
|
-
let
|
|
6
|
+
let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
|
|
7
7
|
let react_hook_form = require("react-hook-form");
|
|
8
8
|
|
|
9
9
|
//#region src/hooks/useUniformFieldArray/useUniformFieldArray.ts
|
|
@@ -45,7 +45,7 @@ const useUniformFieldArray = ({ name, flat = false, elementInitialValue: _elemen
|
|
|
45
45
|
}, 200);
|
|
46
46
|
}, [fields.length]);
|
|
47
47
|
const [disableAnimation, setDisableAnimation] = (0, react.useState)(true);
|
|
48
|
-
const prefersReducedMotion = (0,
|
|
48
|
+
const prefersReducedMotion = (0, _fuf_stack_pixel_motion.useReducedMotion)();
|
|
49
49
|
(0, react.useEffect)(() => {
|
|
50
50
|
if (hasInitialized.current) setDisableAnimation(!!prefersReducedMotion);
|
|
51
51
|
}, [prefersReducedMotion]);
|
|
@@ -87,4 +87,4 @@ Object.defineProperty(exports, 'useUniformFieldArray', {
|
|
|
87
87
|
return useUniformFieldArray;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
90
|
+
//# sourceMappingURL=useUniformFieldArray-G1lokW7x.cjs.map
|
package/dist/{useUniformFieldArray-btjvJdZ6.cjs.map → useUniformFieldArray-G1lokW7x.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-G1lokW7x.cjs","names":["useUniformField","useFormContext","flatArrayKey"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAeA,wCAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,4CAA0B;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,uCAA8B;CAQ5D,MAAM,2CAAgC;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,mCAAwB,CAAC,gBAAgB;AAK/C,4BAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAIrB,4BAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AAEf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,2CAAgC,KAAK;CAI9D,MAAM,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,7 +1,7 @@
|
|
|
1
1
|
import { r as useController } from "./useController-C_MZLZIp.cjs";
|
|
2
|
-
import { n as useFormContext } from "./useFormContext-
|
|
2
|
+
import { n as useFormContext } from "./useFormContext-B083Y-kw.cjs";
|
|
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<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>, "onChange" | "value"> & {
|
|
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>["field"]["onBlur"];
|
|
64
64
|
onChange: ReturnType<typeof useController>["field"]["onChange"];
|
|
65
65
|
ref: ReturnType<typeof useController>["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-qtJMEosJ.d.cts.map
|
package/dist/{useUniformFieldArray-BBFw08qL.d.cts.map → useUniformFieldArray-qtJMEosJ.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-qtJMEosJ.d.cts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAYiB,+CACM,cAAc;;QAG7B,UAAU;;;EAJD;EACM,mBAAA,CAAA,EAAA,OAAA;EAAc;EAGnB,uBAAA,CAAA,EAAA,OAAA;EAAV;EAYE,QAAA,CAAA,EAAA,OAAA;EAAS;EAeN,MAAA,CAAA,EAAA,MAAA;EACU;EAAc,KAAA,CAAA,EAhB3B,SAgB2B;;;;;;;;;;;;;;cADxB,4CACU,cAAc;;;uBACnC;;;UAAA;;GAQC,0BAA0B;;;;;;;;;;;;;;;;;EA0DF,KAAA,WAAA,GAAA,IAAA;EAAA,MAAA,EAAA,UAAA,CAAA,oBAAA,CAAA,CAAA,OAAA,CAAA,CAAA,QAAA,CAAA;EACiD,QAAA,EAAA,UAAA,CAAA,OADjD,aACiD,CAAA,CAAA,OAAA,CAAA,CAAA,UAAA,CAAA;EAAA,GAAA,EAGnC,UAHmC,CAAA,OAAA,aAAA,CAAA,CAAA,OAAA,CAAA,CAAA,KAAA,CAAA;EAGnC,QAAA,EAAA,OAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_useFormContext = require('./useFormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-Bb6d8hdG.cjs');
|
|
2
|
+
const require_useFormContext = require('./useFormContext-Bp0EODoO.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-BnxYE-0b.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-BnxYE-0b.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.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -153,10 +153,10 @@
|
|
|
153
153
|
"@dnd-kit/modifiers": "9.0.0",
|
|
154
154
|
"@dnd-kit/sortable": "10.0.0",
|
|
155
155
|
"@dnd-kit/utilities": "3.2.2",
|
|
156
|
-
"@fuf-stack/pixel-motion": "1.1.
|
|
157
|
-
"@fuf-stack/pixel-utils": "1.1.
|
|
158
|
-
"@fuf-stack/pixels": "1.7.
|
|
159
|
-
"@fuf-stack/veto": "0.13.
|
|
156
|
+
"@fuf-stack/pixel-motion": "1.1.1",
|
|
157
|
+
"@fuf-stack/pixel-utils": "1.1.1",
|
|
158
|
+
"@fuf-stack/pixels": "1.7.1",
|
|
159
|
+
"@fuf-stack/veto": "0.13.2",
|
|
160
160
|
"@heroui/button": "2.2.24",
|
|
161
161
|
"@heroui/checkbox": "2.3.24",
|
|
162
162
|
"@heroui/input": "2.4.25",
|
|
@@ -167,19 +167,19 @@
|
|
|
167
167
|
"@heroui/switch": "2.2.22",
|
|
168
168
|
"@heroui/system": "2.4.20",
|
|
169
169
|
"@heroui/theme": "2.4.20",
|
|
170
|
-
"@react-aria/visually-hidden": "3.8.
|
|
170
|
+
"@react-aria/visually-hidden": "3.8.29",
|
|
171
171
|
"debug": "4.4.3",
|
|
172
|
-
"framer-motion": "12.
|
|
173
|
-
"react-hook-form": "7.
|
|
172
|
+
"framer-motion": "12.26.2",
|
|
173
|
+
"react-hook-form": "7.71.0",
|
|
174
174
|
"react-icons": "5.5.0",
|
|
175
175
|
"react-select": "5.10.2"
|
|
176
176
|
},
|
|
177
177
|
"devDependencies": {
|
|
178
178
|
"@types/debug": "4.1.12",
|
|
179
|
-
"@types/react": "19.2.
|
|
179
|
+
"@types/react": "19.2.8",
|
|
180
180
|
"@types/react-dom": "19.2.3",
|
|
181
181
|
"react": "19.2.3",
|
|
182
182
|
"react-dom": "19.2.3"
|
|
183
183
|
},
|
|
184
|
-
"gitHead": "
|
|
184
|
+
"gitHead": "e9e39971865a3d4fe137e26b7205ae48ea9c059b"
|
|
185
185
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checkboxes-CGWhnpBp.js","names":["heroCheckboxVariants","FieldValidationError","heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames']","heroCheckboxClassNames: HeroCheckboxProps['classNames']","HeroCheckboxGroup","labelContent: ReactNode","HeroCheckbox","Checkboxes"],"sources":["../src/Checkboxes/Checkboxes.tsx","../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type {\n CheckboxGroupProps as HeroCheckboxGroupProps,\n CheckboxProps as HeroCheckboxProps,\n} from '@heroui/checkbox';\nimport type { ReactNode } from 'react';\nimport type { FieldError } from 'react-hook-form';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport {\n Checkbox as HeroCheckbox,\n CheckboxGroup as HeroCheckboxGroup,\n} from '@heroui/checkbox';\nimport { checkbox as heroCheckboxVariants } from '@heroui/theme';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const checkboxesVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n errorMessage: 'text-tiny',\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 'inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n optionBase: '',\n optionIcon: '',\n optionLabel: '',\n optionLabelSubline: 'text-foreground-400 !text-small',\n optionWrapper: '',\n wrapper: '',\n },\n variants: {\n // see: https://github.com/heroui-inc/heroui/blob/canary/packages/core/theme/src/components/checkbox.ts\n color: {\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n ...heroCheckboxVariants.variants.color,\n } as const,\n lineThrough: {\n true: {\n optionLabel: [\n ...heroCheckboxVariants.variants.lineThrough.true.label,\n // fix stroke position when used with subline and enable animation\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof checkboxesVariants>;\ntype ClassName = TVClassName<typeof checkboxesVariants>;\n\nexport interface CheckboxOption {\n /** option label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n}\n\nexport interface CheckboxesProps 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 /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Sets all checkboxes disabled */\n disabled?: boolean;\n /** Orientation of the checkboxes */\n inline?: boolean;\n /** Label displayed above the checkboxes */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Name the Field is registered on the form */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxOption[];\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}\n\n/**\n * Checkboxes component based on [HeroUI CheckboxGroup](https://www.heroui.com//docs/components/checkbox-group)\n */\nconst Checkboxes = ({\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n options,\n name,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const {\n ariaLabel,\n disabled,\n error: _error,\n field: { onChange, value: fieldValue, ref, onBlur },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ensure value is always an array (checkboxes need arrays)\n const value = Array.isArray(fieldValue) ? fieldValue : [];\n\n // Convert React Hook Form's nested error object structure to a flat array\n // RHF errors can be nested like: checkboxField.0 (individual checkbox errors)\n // and checkboxField._error (global field errors) - this flattens all\n // error values into a single array for rendering with FieldValidationError\n const errorFlat: FieldError[] =\n (_error &&\n Object.values(\n _error as unknown as Record<string, FieldError[]>,\n ).flat()) ??\n [];\n const errorMessage = (\n <FieldValidationError error={errorFlat} testId={testId} />\n );\n\n // classNames from slots\n const variants = checkboxesVariants({ lineThrough });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // map slots to HeroUI class names\n const heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames'] = {\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n };\n const heroCheckboxClassNames: HeroCheckboxProps['classNames'] = {\n base: classNames.optionBase,\n icon: classNames.optionIcon,\n label: classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n };\n\n return (\n <HeroCheckboxGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={heroCheckboxGroupClassNames}\n color={color === 'info' ? 'primary' : color}\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-testid={testId}\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 onChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value}\n >\n {options?.map((option) => {\n const optionTestId = slugify(\n `${testId}_option_${option?.testId ?? option?.value}`,\n { replaceDots: true },\n );\n\n // set content and classes depending option has subline\n const hasSubline = !!option.labelSubline;\n let labelContent: ReactNode;\n let optionClassNames = heroCheckboxClassNames;\n if (hasSubline) {\n labelContent = (\n <div className=\"flex grow flex-col items-start\">\n <span className={classNames.optionLabel}>{option.label}</span>\n <span className={classNames.optionLabelSubline}>\n {option.labelSubline}\n </span>\n </div>\n );\n // remove label classes from outer label when subline is used\n optionClassNames = { ...optionClassNames, label: '' };\n } else {\n labelContent = option.label;\n }\n\n return (\n <HeroCheckbox\n key={`index_${option.value}`}\n classNames={optionClassNames}\n data-invalid={invalid}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n value={option?.value}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n >\n {labelContent}\n </HeroCheckbox>\n );\n })}\n </HeroCheckboxGroup>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { Checkboxes };\n\nexport default Checkboxes;\n"],"mappings":";;;;;;;;AAoBA,MAAa,qBAAqB,GAAG;CACnC,OAAO;EACL,MAAM;EACN,cAAc;EAGd,OACE;EACF,YAAY;EACZ,YAAY;EACZ,aAAa;EACb,oBAAoB;EACpB,eAAe;EACf,SAAS;EACV;CACD,UAAU;EAER,OAAO;GACL,MAAM,EACJ,SACE,iEACH;GACD,GAAGA,SAAqB,SAAS;GAClC;EACD,aAAa,EACX,MAAM;GACJ,aAAa,CACX,GAAGA,SAAqB,SAAS,YAAY,KAAK,OAElD,qDACD;GACD,oBAAoB;GACrB,EACF;EACF;CACF,CAAC;;;;AA8CF,MAAM,cAAc,EAClB,YAAY,QACZ,QAAQ,WACR,SAAS,OACT,cAAc,OACd,SACA,MACA,GAAG,wBACkB;CACrB,MAAM,EACJ,WACA,UACA,OAAO,QACP,OAAO,EAAE,UAAU,OAAO,YAAY,KAAK,UAC3C,SACA,OACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAGF,MAAM,QAAQ,MAAM,QAAQ,WAAW,GAAG,aAAa,EAAE;CAYzD,MAAM,eACJ,oBAACC;EAAqB,QANrB,UACC,OAAO,OACL,OACD,CAAC,MAAM,KACV,EAAE;EAE8C;GAAU;CAK5D,MAAM,aAAa,qBADF,mBAAmB,EAAE,aAAa,CAAC,EACF,WAAW,OAAO;CAGpE,MAAMC,8BAAoE;EACxE,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,SAAS,WAAW;EACrB;CACD,MAAMC,yBAA0D;EAC9D,MAAM,WAAW;EACjB,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,SAAS,WAAW;EACrB;AAED,QACE,oBAACC;EACM;EACL,cAAY;EACZ,YAAY;EACZ,OAAO,UAAU,SAAS,YAAY;EAGtC,gBAAc;EACd,eAAa;EACC;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,oBAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACE;EACV,aAAa,SAAS,eAAe;EAC9B;YAEN,SAAS,KAAK,WAAW;GACxB,MAAM,eAAe,QACnB,GAAG,OAAO,UAAU,QAAQ,UAAU,QAAQ,SAC9C,EAAE,aAAa,MAAM,CACtB;GAGD,MAAM,aAAa,CAAC,CAAC,OAAO;GAC5B,IAAIC;GACJ,IAAI,mBAAmB;AACvB,OAAI,YAAY;AACd,mBACE,qBAAC;KAAI,WAAU;gBACb,oBAAC;MAAK,WAAW,WAAW;gBAAc,OAAO;OAAa,EAC9D,oBAAC;MAAK,WAAW,WAAW;gBACzB,OAAO;OACH;MACH;AAGR,uBAAmB;KAAE,GAAG;KAAkB,OAAO;KAAI;SAErD,gBAAe,OAAO;AAGxB,UACE,oBAACC;IAEC,YAAY;IACZ,gBAAc;IACd,eAAa;IACb,YAAY,CAAC,CAAC,YAAY,OAAO;IACjC,OAAO,QAAQ;IACf,cACE,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,OAAO;cAG1D;MAVI,SAAS,OAAO,QAWR;IAEjB;GACgB;;AAIxB,yBAAe;;;;AC1Nf,2BAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Checkboxes-Ds6bzl6p.cjs","names":["heroCheckboxVariants","useUniformField","FieldValidationError","heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames']","heroCheckboxClassNames: HeroCheckboxProps['classNames']","HeroCheckboxGroup","labelContent: ReactNode","HeroCheckbox","Checkboxes"],"sources":["../src/Checkboxes/Checkboxes.tsx","../src/Checkboxes/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type {\n CheckboxGroupProps as HeroCheckboxGroupProps,\n CheckboxProps as HeroCheckboxProps,\n} from '@heroui/checkbox';\nimport type { ReactNode } from 'react';\nimport type { FieldError } from 'react-hook-form';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport {\n Checkbox as HeroCheckbox,\n CheckboxGroup as HeroCheckboxGroup,\n} from '@heroui/checkbox';\nimport { checkbox as heroCheckboxVariants } from '@heroui/theme';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const checkboxesVariants = tv({\n slots: {\n base: 'group', // Needs group for group-data condition\n errorMessage: 'text-tiny',\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 'inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger',\n optionBase: '',\n optionIcon: '',\n optionLabel: '',\n optionLabelSubline: 'text-foreground-400 !text-small',\n optionWrapper: '',\n wrapper: '',\n },\n variants: {\n // see: https://github.com/heroui-inc/heroui/blob/canary/packages/core/theme/src/components/checkbox.ts\n color: {\n info: {\n wrapper:\n 'text-info-foreground after:bg-info after:text-info-foreground',\n },\n ...heroCheckboxVariants.variants.color,\n } as const,\n lineThrough: {\n true: {\n optionLabel: [\n ...heroCheckboxVariants.variants.lineThrough.true.label,\n // fix stroke position when used with subline and enable animation\n 'relative before:transition-all before:duration-200',\n ],\n optionLabelSubline: 'group-data-[selected=true]:opacity-60',\n },\n },\n },\n});\n\ntype VariantProps = TVProps<typeof checkboxesVariants>;\ntype ClassName = TVClassName<typeof checkboxesVariants>;\n\nexport interface CheckboxOption {\n /** option label */\n label?: ReactNode;\n /** subline displayed below the label */\n labelSubline?: ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n}\n\nexport interface CheckboxesProps 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 /** Color scheme of the checkboxes */\n color?: VariantProps['color'];\n /** Sets all checkboxes disabled */\n disabled?: boolean;\n /** Orientation of the checkboxes */\n inline?: boolean;\n /** Label displayed above the checkboxes */\n label?: ReactNode;\n /** Whether the checkboxes label should be crossed out */\n lineThrough?: boolean;\n /** Name the Field is registered on the form */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxOption[];\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}\n\n/**\n * Checkboxes component based on [HeroUI CheckboxGroup](https://www.heroui.com//docs/components/checkbox-group)\n */\nconst Checkboxes = ({\n className = undefined,\n color = 'primary',\n inline = false,\n lineThrough = false,\n options,\n name,\n ...uniformFieldProps\n}: CheckboxesProps) => {\n const {\n ariaLabel,\n disabled,\n error: _error,\n field: { onChange, value: fieldValue, ref, onBlur },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ensure value is always an array (checkboxes need arrays)\n const value = Array.isArray(fieldValue) ? fieldValue : [];\n\n // Convert React Hook Form's nested error object structure to a flat array\n // RHF errors can be nested like: checkboxField.0 (individual checkbox errors)\n // and checkboxField._error (global field errors) - this flattens all\n // error values into a single array for rendering with FieldValidationError\n const errorFlat: FieldError[] =\n (_error &&\n Object.values(\n _error as unknown as Record<string, FieldError[]>,\n ).flat()) ??\n [];\n const errorMessage = (\n <FieldValidationError error={errorFlat} testId={testId} />\n );\n\n // classNames from slots\n const variants = checkboxesVariants({ lineThrough });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // map slots to HeroUI class names\n const heroCheckboxGroupClassNames: HeroCheckboxGroupProps['classNames'] = {\n base: classNames.base,\n label: classNames.label,\n wrapper: classNames.wrapper,\n };\n const heroCheckboxClassNames: HeroCheckboxProps['classNames'] = {\n base: classNames.optionBase,\n icon: classNames.optionIcon,\n label: classNames.optionLabel,\n wrapper: classNames.optionWrapper,\n };\n\n return (\n <HeroCheckboxGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={heroCheckboxGroupClassNames}\n color={color === 'info' ? 'primary' : color}\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-testid={testId}\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 onChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value}\n >\n {options?.map((option) => {\n const optionTestId = slugify(\n `${testId}_option_${option?.testId ?? option?.value}`,\n { replaceDots: true },\n );\n\n // set content and classes depending option has subline\n const hasSubline = !!option.labelSubline;\n let labelContent: ReactNode;\n let optionClassNames = heroCheckboxClassNames;\n if (hasSubline) {\n labelContent = (\n <div className=\"flex grow flex-col items-start\">\n <span className={classNames.optionLabel}>{option.label}</span>\n <span className={classNames.optionLabelSubline}>\n {option.labelSubline}\n </span>\n </div>\n );\n // remove label classes from outer label when subline is used\n optionClassNames = { ...optionClassNames, label: '' };\n } else {\n labelContent = option.label;\n }\n\n return (\n <HeroCheckbox\n key={`index_${option.value}`}\n classNames={optionClassNames}\n data-invalid={invalid}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n value={option?.value}\n aria-label={\n typeof option.label === 'string' ? option.label : option.value\n }\n >\n {labelContent}\n </HeroCheckbox>\n );\n })}\n </HeroCheckboxGroup>\n );\n};\n\nexport default Checkboxes;\n","import Checkboxes from './Checkboxes';\n\nexport type { CheckboxesProps, CheckboxOption } from './Checkboxes';\n\nexport { Checkboxes };\n\nexport default Checkboxes;\n"],"mappings":";;;;;;;;;AAoBA,MAAa,qDAAwB;CACnC,OAAO;EACL,MAAM;EACN,cAAc;EAGd,OACE;EACF,YAAY;EACZ,YAAY;EACZ,aAAa;EACb,oBAAoB;EACpB,eAAe;EACf,SAAS;EACV;CACD,UAAU;EAER,OAAO;GACL,MAAM,EACJ,SACE,iEACH;GACD,GAAGA,wBAAqB,SAAS;GAClC;EACD,aAAa,EACX,MAAM;GACJ,aAAa,CACX,GAAGA,wBAAqB,SAAS,YAAY,KAAK,OAElD,qDACD;GACD,oBAAoB;GACrB,EACF;EACF;CACF,CAAC;;;;AA8CF,MAAM,cAAc,EAClB,YAAY,QACZ,QAAQ,WACR,SAAS,OACT,cAAc,OACd,SACA,MACA,GAAG,wBACkB;CACrB,MAAM,EACJ,WACA,UACA,OAAO,QACP,OAAO,EAAE,UAAU,OAAO,YAAY,KAAK,UAC3C,SACA,OACA,UACA,WACEC,wCAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAGF,MAAM,QAAQ,MAAM,QAAQ,WAAW,GAAG,aAAa,EAAE;CAYzD,MAAM,eACJ,2CAACC;EAAqB,QANrB,UACC,OAAO,OACL,OACD,CAAC,MAAM,KACV,EAAE;EAE8C;GAAU;CAK5D,MAAM,+DADW,mBAAmB,EAAE,aAAa,CAAC,EACF,WAAW,OAAO;CAGpE,MAAMC,8BAAoE;EACxE,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,SAAS,WAAW;EACrB;CACD,MAAMC,yBAA0D;EAC9D,MAAM,WAAW;EACjB,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,SAAS,WAAW;EACrB;AAED,QACE,2CAACC;EACM;EACL,cAAY;EACZ,YAAY;EACZ,OAAO,UAAU,SAAS,YAAY;EAGtC,gBAAc;EACd,eAAa;EACC;EACd,YAAY;EACZ,WAAW;EACX,YAAY;EACZ,OAAO,QAAQ,2CAAC,sBAAQ,QAAe,GAAG;EACpC;EACE;EACE;EACV,aAAa,SAAS,eAAe;EAC9B;YAEN,SAAS,KAAK,WAAW;GACxB,MAAM,oDACJ,GAAG,OAAO,UAAU,QAAQ,UAAU,QAAQ,SAC9C,EAAE,aAAa,MAAM,CACtB;GAGD,MAAM,aAAa,CAAC,CAAC,OAAO;GAC5B,IAAIC;GACJ,IAAI,mBAAmB;AACvB,OAAI,YAAY;AACd,mBACE,4CAAC;KAAI,WAAU;gBACb,2CAAC;MAAK,WAAW,WAAW;gBAAc,OAAO;OAAa,EAC9D,2CAAC;MAAK,WAAW,WAAW;gBACzB,OAAO;OACH;MACH;AAGR,uBAAmB;KAAE,GAAG;KAAkB,OAAO;KAAI;SAErD,gBAAe,OAAO;AAGxB,UACE,2CAACC;IAEC,YAAY;IACZ,gBAAc;IACd,eAAa;IACb,YAAY,CAAC,CAAC,YAAY,OAAO;IACjC,OAAO,QAAQ;IACf,cACE,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,OAAO;cAG1D;MAVI,SAAS,OAAO,QAWR;IAEjB;GACgB;;AAIxB,yBAAe;;;;AC1Nf,2BAAeC"}
|