@fuf-stack/uniform 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checkboxes/index.cjs +1 -1
- package/dist/Checkboxes/index.d.cts +1 -1
- package/dist/Checkboxes/index.d.ts +1 -1
- package/dist/Checkboxes/index.js +1 -1
- package/dist/{Checkboxes-D5sibD6f.cjs → Checkboxes-3Rg0gyfO.cjs} +2 -2
- package/dist/{Checkboxes-D5sibD6f.cjs.map → Checkboxes-3Rg0gyfO.cjs.map} +1 -1
- package/dist/{Checkboxes-C57URc95.js → Checkboxes-BfUtbKe-.js} +2 -2
- package/dist/{Checkboxes-C57URc95.js.map → Checkboxes-BfUtbKe-.js.map} +1 -1
- package/dist/FieldArray/index.cjs +1 -1
- package/dist/FieldArray/index.d.cts +1 -1
- package/dist/FieldArray/index.d.ts +1 -1
- package/dist/FieldArray/index.js +1 -1
- package/dist/{FieldArray-CWxV0Q6O.cjs → FieldArray-BgvSTDWi.cjs} +5 -5
- package/dist/FieldArray-BgvSTDWi.cjs.map +1 -0
- package/dist/{FieldArray-D-vR7oCb.js → FieldArray-C8Ipn-tM.js} +5 -5
- package/dist/FieldArray-C8Ipn-tM.js.map +1 -0
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/FieldCard/index.d.cts +1 -1
- package/dist/FieldCard/index.d.ts +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/{FieldCard-CKEeknzL.js → FieldCard-DZSiMFoO.js} +71 -16
- package/dist/FieldCard-DZSiMFoO.js.map +1 -0
- package/dist/{FieldCard-DiaY4qXt.cjs → FieldCard-DcMORXZR.cjs} +71 -16
- package/dist/FieldCard-DcMORXZR.cjs.map +1 -0
- package/dist/Form/index.d.cts +1 -1
- package/dist/Grid/index.d.cts +1 -1
- package/dist/Grid/index.d.ts +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-CUeTrgO_.js → Input-ChXItabV.js} +2 -2
- package/dist/{Input-CUeTrgO_.js.map → Input-ChXItabV.js.map} +1 -1
- package/dist/{Input-BJkL5IVO.cjs → Input-DlyrGFYf.cjs} +2 -2
- package/dist/{Input-BJkL5IVO.cjs.map → Input-DlyrGFYf.cjs.map} +1 -1
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.d.cts +1 -1
- package/dist/RadioBoxes/index.d.ts +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/{RadioBoxes-BXAo2Nom.cjs → RadioBoxes-ClDOhQkO.cjs} +2 -2
- package/dist/{RadioBoxes-BXAo2Nom.cjs.map → RadioBoxes-ClDOhQkO.cjs.map} +1 -1
- package/dist/{RadioBoxes-B-EbjvDm.js → RadioBoxes-D6ULFGfd.js} +2 -2
- package/dist/{RadioBoxes-B-EbjvDm.js.map → RadioBoxes-D6ULFGfd.js.map} +1 -1
- 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-rDuug93J.cjs → RadioTabs-CgB0MmbK.cjs} +2 -2
- package/dist/{RadioTabs-rDuug93J.cjs.map → RadioTabs-CgB0MmbK.cjs.map} +1 -1
- package/dist/{RadioTabs-C2FIAjx-.js → RadioTabs-eSB6OXD7.js} +2 -2
- package/dist/{RadioTabs-C2FIAjx-.js.map → RadioTabs-eSB6OXD7.js.map} +1 -1
- 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-N5qCQRBU.js → Radios-BXuyREKO.js} +2 -2
- package/dist/{Radios-N5qCQRBU.js.map → Radios-BXuyREKO.js.map} +1 -1
- package/dist/{Radios-LD2USByC.cjs → Radios-DWsCLUVl.cjs} +2 -2
- package/dist/{Radios-LD2USByC.cjs.map → Radios-DWsCLUVl.cjs.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-C5mS7WZC.cjs → Select-CTbXrAjL.cjs} +34 -13
- package/dist/Select-CTbXrAjL.cjs.map +1 -0
- package/dist/{Select-D_LJBu0p.js → Select-Dk_K_Q0F.js} +35 -14
- package/dist/Select-Dk_K_Q0F.js.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-D-bfkzoh.cjs → Slider-ChGkOSJJ.cjs} +2 -2
- package/dist/{Slider-D-bfkzoh.cjs.map → Slider-ChGkOSJJ.cjs.map} +1 -1
- package/dist/{Slider-CNlNpxV-.js → Slider-DdF0ZBzn.js} +2 -2
- package/dist/{Slider-CNlNpxV-.js.map → Slider-DdF0ZBzn.js.map} +1 -1
- package/dist/SubmitButton/index.d.cts +1 -1
- package/dist/SubmitButton/index.d.ts +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-DZptJsFF.js → Switch-DW9SOeIv.js} +2 -2
- package/dist/{Switch-DZptJsFF.js.map → Switch-DW9SOeIv.js.map} +1 -1
- package/dist/{Switch-BBAkWBHA.cjs → Switch-Lt61rKxf.cjs} +2 -2
- package/dist/{Switch-BBAkWBHA.cjs.map → Switch-Lt61rKxf.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-DZQCW3SK.js → SwitchBox-9KAu4WWd.js} +2 -2
- package/dist/{SwitchBox-DZQCW3SK.js.map → SwitchBox-9KAu4WWd.js.map} +1 -1
- package/dist/{SwitchBox-DHAJ_YXU.cjs → SwitchBox-D-EI9Sl-.cjs} +2 -2
- package/dist/{SwitchBox-DHAJ_YXU.cjs.map → SwitchBox-D-EI9Sl-.cjs.map} +1 -1
- package/dist/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.d.cts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-Dg2ZqJm2.js → TextArea-B0zYpNy-.js} +2 -2
- package/dist/{TextArea-Dg2ZqJm2.js.map → TextArea-B0zYpNy-.js.map} +1 -1
- package/dist/{TextArea-BBpGkB5f.cjs → TextArea-DRSFdn5v.cjs} +2 -2
- package/dist/{TextArea-BBpGkB5f.cjs.map → TextArea-DRSFdn5v.cjs.map} +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.cts +1 -1
- package/dist/hooks/useController/index.d.ts +1 -1
- package/dist/hooks/useController/index.js +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +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 +21 -21
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +1 -1
- package/dist/hooks/useWatchUserChange/index.d.ts +1 -1
- package/dist/hooks/useWatchUserChange/index.js +1 -1
- package/dist/{index-CEzwxdlZ.d.ts → index-2SVlCM0Y.d.cts} +21 -21
- package/dist/{index-BeinxTzw.d.cts.map → index-2SVlCM0Y.d.cts.map} +1 -1
- package/dist/{index-CYdvpGJF.d.cts → index-B2IL9Zt7.d.cts} +3 -3
- package/dist/{index-CYdvpGJF.d.cts.map → index-B2IL9Zt7.d.cts.map} +1 -1
- package/dist/{index-BeinxTzw.d.cts → index-BDvr4eaz.d.ts} +21 -21
- package/dist/{index-CEzwxdlZ.d.ts.map → index-BDvr4eaz.d.ts.map} +1 -1
- package/dist/{index-nE7tTo2d.d.cts → index-BKCiuwim.d.cts} +46 -46
- package/dist/{index-nE7tTo2d.d.cts.map → index-BKCiuwim.d.cts.map} +1 -1
- package/dist/index-BTr_gid3.d.cts.map +1 -1
- package/dist/{index-C0--RHyE.d.cts → index-BZrLB2p0.d.cts} +34 -34
- package/dist/{index-C0--RHyE.d.cts.map → index-BZrLB2p0.d.cts.map} +1 -1
- package/dist/{index-P3_aBCSt.d.cts → index-BbA9HcNa.d.cts} +3 -3
- package/dist/{index-P3_aBCSt.d.cts.map → index-BbA9HcNa.d.cts.map} +1 -1
- package/dist/{index-BNu0EV5x.d.cts → index-Bo79xzb4.d.cts} +3 -3
- package/dist/{index-BNu0EV5x.d.cts.map → index-Bo79xzb4.d.cts.map} +1 -1
- package/dist/{index-ByQXPNeM.d.ts → index-BuX42Bbd.d.ts} +7 -6
- package/dist/index-BuX42Bbd.d.ts.map +1 -0
- package/dist/{index-BuaPmiMt.d.ts → index-CCeHSmIe.d.ts} +3 -3
- package/dist/{index-BuaPmiMt.d.ts.map → index-CCeHSmIe.d.ts.map} +1 -1
- package/dist/{index-CkhVD2Pw.d.ts → index-CJ90vm9t.d.ts} +6 -6
- package/dist/{index-CkhVD2Pw.d.ts.map → index-CJ90vm9t.d.ts.map} +1 -1
- package/dist/{index-DElTYKk8.d.ts → index-CPcJGZVS.d.ts} +3 -3
- package/dist/{index-DElTYKk8.d.ts.map → index-CPcJGZVS.d.ts.map} +1 -1
- package/dist/index-CRYEKT3o.d.ts +278 -0
- package/dist/index-CRYEKT3o.d.ts.map +1 -0
- package/dist/{index-B5BDC8Al.d.ts → index-CVY05bZf.d.ts} +3 -3
- package/dist/{index-B5BDC8Al.d.ts.map → index-CVY05bZf.d.ts.map} +1 -1
- package/dist/{index-DS54nHWk.d.cts → index-CZ5EIIjq.d.cts} +6 -6
- package/dist/{index-DS54nHWk.d.cts.map → index-CZ5EIIjq.d.cts.map} +1 -1
- package/dist/{index-BHklv3dW.d.ts → index-CdXOAPMb.d.ts} +48 -48
- package/dist/index-CdXOAPMb.d.ts.map +1 -0
- package/dist/{index-BOgOCyFF.d.cts → index-Cj5CLBt2.d.cts} +4 -4
- package/dist/{index-BOgOCyFF.d.cts.map → index-Cj5CLBt2.d.cts.map} +1 -1
- package/dist/{index-Cb0AgRRa.d.cts → index-CpVfOXNv.d.cts} +3 -3
- package/dist/{index-Cb0AgRRa.d.cts.map → index-CpVfOXNv.d.cts.map} +1 -1
- package/dist/{index-BbAjuXqS.d.cts → index-Ct2YYfiU.d.cts} +6 -6
- package/dist/{index-BbAjuXqS.d.cts.map → index-Ct2YYfiU.d.cts.map} +1 -1
- package/dist/{index-CbK-kEVY.d.cts → index-D-ucmG60.d.ts} +22 -22
- package/dist/index-D-ucmG60.d.ts.map +1 -0
- package/dist/index-D5rTKWm9.d.cts +278 -0
- package/dist/index-D5rTKWm9.d.cts.map +1 -0
- package/dist/{index-DsQabhNC.d.cts → index-DS4AP9pV.d.ts} +6 -6
- package/dist/{index-DMOAkVG4.d.ts.map → index-DS4AP9pV.d.ts.map} +1 -1
- package/dist/{index-5Hp_MzN_.d.cts → index-DW1uBiAf.d.cts} +5 -4
- package/dist/index-DW1uBiAf.d.cts.map +1 -0
- package/dist/{index-DamFEDHU.d.cts → index-DYErnCVV.d.cts} +36 -36
- package/dist/index-DYErnCVV.d.cts.map +1 -0
- package/dist/{index-DeHDOwxr.d.ts → index-DaBgwR1t.d.cts} +7 -7
- package/dist/{index-CbK-kEVY.d.cts.map → index-DaBgwR1t.d.cts.map} +1 -1
- package/dist/{index-Cb8jQhHS.d.ts → index-Djc5tmi3.d.ts} +36 -36
- package/dist/index-Djc5tmi3.d.ts.map +1 -0
- package/dist/{index-qNwZcAWj.d.ts → index-DubKudrE.d.ts} +6 -6
- package/dist/{index-qNwZcAWj.d.ts.map → index-DubKudrE.d.ts.map} +1 -1
- package/dist/{index-DMOAkVG4.d.ts → index-DymdaDrj.d.cts} +6 -6
- package/dist/{index-DsQabhNC.d.cts.map → index-DymdaDrj.d.cts.map} +1 -1
- package/dist/{index-CusdoJv3.d.ts → index-FHPC_VE1.d.ts} +35 -35
- package/dist/{index-CusdoJv3.d.ts.map → index-FHPC_VE1.d.ts.map} +1 -1
- package/dist/{index-6eckRMZA.d.cts → index-PU5WNOH9.d.cts} +3 -3
- package/dist/{index-6eckRMZA.d.cts.map → index-PU5WNOH9.d.cts.map} +1 -1
- package/dist/{index-BZ9HvBM6.d.cts → index-hacHTzh4.d.cts} +35 -35
- package/dist/{index-BZ9HvBM6.d.cts.map → index-hacHTzh4.d.cts.map} +1 -1
- package/dist/{index-CJcgEkPo.d.ts → index-lot50R9R.d.ts} +3 -3
- package/dist/{index-CJcgEkPo.d.ts.map → index-lot50R9R.d.ts.map} +1 -1
- package/dist/{index-ClQFLoqX.d.ts → index-noH6pESQ.d.ts} +34 -34
- package/dist/index-noH6pESQ.d.ts.map +1 -0
- package/dist/{index-ecrJ75NW.d.ts → index-tIGuHSXb.d.ts} +4 -4
- package/dist/{index-ecrJ75NW.d.ts.map → index-tIGuHSXb.d.ts.map} +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +22 -22
- package/dist/index.d.ts +21 -21
- package/dist/index.js +16 -16
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +1 -1
- package/dist/partials/FieldValidationError/index.d.ts +1 -1
- package/dist/{useController-C_MZLZIp.d.cts → useController-B-DhUPpA.d.cts} +3 -1
- package/dist/{useController-C_MZLZIp.d.cts.map → useController-B-DhUPpA.d.cts.map} +1 -1
- package/dist/{useController-hjpJQf0w.d.ts → useController-Co8wbo-Y.d.ts} +3 -1
- package/dist/{useController-hjpJQf0w.d.ts.map → useController-Co8wbo-Y.d.ts.map} +1 -1
- package/dist/{useController-Dleq15tG.js → useController-QcOl0O0v.js} +4 -1
- package/dist/useController-QcOl0O0v.js.map +1 -0
- package/dist/{useController-BySgDIes.cjs → useController-oCYPeezC.cjs} +4 -1
- package/dist/useController-oCYPeezC.cjs.map +1 -0
- package/dist/{useFormContext-B7ooPCfd.d.ts → useFormContext-DDx8LD8e.d.ts} +3 -3
- package/dist/{useFormContext-B7ooPCfd.d.ts.map → useFormContext-DDx8LD8e.d.ts.map} +1 -1
- package/dist/{useFormContext-DihY1N8O.d.cts → useFormContext-oEivkWtB.d.cts} +19 -19
- package/dist/{useFormContext-DihY1N8O.d.cts.map → useFormContext-oEivkWtB.d.cts.map} +1 -1
- package/dist/{useUniformField-Brwxoghf.js → useUniformField-C6oSAFa3.js} +2 -2
- package/dist/{useUniformField-Brwxoghf.js.map → useUniformField-C6oSAFa3.js.map} +1 -1
- package/dist/{useUniformField-Dz_-tPrO.d.cts → useUniformField-DFXQO9dw.d.cts} +3 -3
- package/dist/{useUniformField-Dz_-tPrO.d.cts.map → useUniformField-DFXQO9dw.d.cts.map} +1 -1
- package/dist/{useUniformField-BJTRfqCQ.cjs → useUniformField-Dd3AnpgE.cjs} +2 -2
- package/dist/{useUniformField-BJTRfqCQ.cjs.map → useUniformField-Dd3AnpgE.cjs.map} +1 -1
- package/dist/{useUniformField-giYkUMG_.d.ts → useUniformField-q3GCAV85.d.ts} +3 -3
- package/dist/{useUniformField-giYkUMG_.d.ts.map → useUniformField-q3GCAV85.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-BMBc3o7P.d.cts → useUniformFieldArray-B3smveBW.d.cts} +14 -14
- package/dist/{useUniformFieldArray-BMBc3o7P.d.cts.map → useUniformFieldArray-B3smveBW.d.cts.map} +1 -1
- package/dist/{useUniformFieldArray-COp7qAwf.d.ts → useUniformFieldArray-CmACueEO.d.ts} +4 -4
- package/dist/{useUniformFieldArray-COp7qAwf.d.ts.map → useUniformFieldArray-CmACueEO.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-N5uHlvRy.cjs → useUniformFieldArray-D93AUZI4.cjs} +2 -2
- package/dist/{useUniformFieldArray-N5uHlvRy.cjs.map → useUniformFieldArray-D93AUZI4.cjs.map} +1 -1
- package/dist/{useUniformFieldArray-SlUu--d6.js → useUniformFieldArray-DNrmEXLg.js} +2 -2
- package/dist/{useUniformFieldArray-SlUu--d6.js.map → useUniformFieldArray-DNrmEXLg.js.map} +1 -1
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts → useWatchUserChange-DahNCPDG.d.cts} +3 -1
- package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-DahNCPDG.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-1ELFYX_F.js → useWatchUserChange-DyhUYlrN.js} +3 -1
- package/dist/useWatchUserChange-DyhUYlrN.js.map +1 -0
- package/dist/{useWatchUserChange-COVdHmki.d.cts → useWatchUserChange-JMU-vN92.d.ts} +3 -1
- package/dist/{useWatchUserChange-BAdiqg2q.d.ts.map → useWatchUserChange-JMU-vN92.d.ts.map} +1 -1
- package/dist/{useWatchUserChange-C1zOvSSU.cjs → useWatchUserChange-jivI5KIB.cjs} +3 -1
- package/dist/useWatchUserChange-jivI5KIB.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/FieldArray-CWxV0Q6O.cjs.map +0 -1
- package/dist/FieldArray-D-vR7oCb.js.map +0 -1
- package/dist/FieldCard-CKEeknzL.js.map +0 -1
- package/dist/FieldCard-DiaY4qXt.cjs.map +0 -1
- package/dist/Select-C5mS7WZC.cjs.map +0 -1
- package/dist/Select-D_LJBu0p.js.map +0 -1
- package/dist/index-5Hp_MzN_.d.cts.map +0 -1
- package/dist/index-BHklv3dW.d.ts.map +0 -1
- package/dist/index-ByQXPNeM.d.ts.map +0 -1
- package/dist/index-CPE2gcz3.d.ts +0 -264
- package/dist/index-CPE2gcz3.d.ts.map +0 -1
- package/dist/index-Cb8jQhHS.d.ts.map +0 -1
- package/dist/index-ClQFLoqX.d.ts.map +0 -1
- package/dist/index-DamFEDHU.d.cts.map +0 -1
- package/dist/index-DeHDOwxr.d.ts.map +0 -1
- package/dist/index-jeFGTign.d.cts +0 -264
- package/dist/index-jeFGTign.d.cts.map +0 -1
- package/dist/useController-BySgDIes.cjs.map +0 -1
- package/dist/useController-Dleq15tG.js.map +0 -1
- package/dist/useWatchUserChange-1ELFYX_F.js.map +0 -1
- package/dist/useWatchUserChange-C1zOvSSU.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldCard-DZSiMFoO.js","names":["FieldValidationError","FieldCardValidationError"],"sources":["../src/FieldCard/subcomponents/FieldCardValidationError.tsx","../src/FieldCard/FieldCard.tsx"],"sourcesContent":["import {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\n\nexport interface FieldCardValidationErrorProps {\n /** CSS class name for the error footer wrapper */\n className?: string;\n /** Field name */\n name: string;\n}\n\n/**\n * Renders validation errors in the footer of a FieldCard component.\n *\n * This component handles displaying field-level validation errors with proper\n * accessibility attributes and animates them in/out using Framer Motion.\n */\nconst FieldCardValidationError = ({\n className = undefined,\n name,\n}: FieldCardValidationErrorProps) => {\n const { error, getErrorMessageProps, getHelperWrapperProps, testId } =\n useUniformField({\n name,\n });\n\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n // Always show object-level errors (_errors) as they represent explicit\n // validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = !!error?._errors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-card-errors\"\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n >\n <div\n {...getHelperWrapperProps()}\n className={cn(getHelperWrapperProps()?.className, className)}\n >\n <div {...getErrorMessageProps()}>\n <FieldValidationError\n // @ts-expect-error - error._errors exists but not typed\n error={error._errors}\n testId={testId}\n />\n </div>\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldCardValidationError;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { checkFieldIsRequired, useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\nimport FieldCardValidationError from './subcomponents/FieldCardValidationError';\n\n/**\n * Recursively checks if any child field with an error is also touched.\n * Returns true if at least one touched child has an error.\n */\nexport const hasVisibleChildErrors = (\n errors: Record<string, unknown> | undefined,\n touched: Record<string, unknown> | undefined,\n): boolean => {\n if (!errors || !touched) {\n return false;\n }\n\n return Object.keys(errors)\n .filter((key) => {\n // Skip object-level errors (_errors) - those are handled separately\n return key !== '_errors';\n })\n .some((key) => {\n const errorValue = errors[key];\n const touchedValue = touched[key];\n\n // If this key doesn't exist in both errors and touched, skip\n if (errorValue === undefined || touchedValue === undefined) {\n return false;\n }\n\n // If errorValue is an array, it's a leaf field error\n if (Array.isArray(errorValue)) {\n // touchedValue being truthy means the field is touched\n return !!touchedValue;\n }\n\n // Recursively check nested objects\n if (typeof errorValue === 'object' && errorValue !== null) {\n return hasVisibleChildErrors(\n errorValue as Record<string, unknown>,\n touchedValue as Record<string, unknown>,\n );\n }\n\n return false;\n });\n};\n\nexport const fieldCardVariants = tv({\n slots: {\n /** base class for the field card wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border bg-content1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the label/header */\n label: [\n // override HeroUI label positioning and display\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) for proper header size\n 'rounded-t-small border-b p-3 font-semibold text-medium',\n // animate border and text color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the content */\n content: [\n // same as p-3 of Card component\n 'p-3',\n // default grid for form components (see Grid component)\n 'grid gap-4',\n ],\n /** class for the error footer wrapper */\n errorFooter: [\n 'border-t',\n // force helper to be visible and add padding (pt-1 to compensate for inner content's top padding)\n 'block px-3 pb-2 pt-1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n },\n variants: {\n invalid: {\n true: {\n base: 'border-danger-200',\n label: 'border-danger-200 text-danger',\n errorFooter: 'border-danger-200',\n },\n false: {\n base: 'border-divider',\n label: 'border-divider text-foreground',\n errorFooter: 'border-divider',\n },\n },\n },\n defaultVariants: {\n invalid: false,\n },\n});\n\ntype ClassName = TVClassName<typeof fieldCardVariants>;\n\nexport interface FieldCardProps {\n /** Content to render inside the card */\n children: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Label content for the card header */\n label: ReactNode;\n /** Field name for validation */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * FieldCard component - A card-styled container with label header and error footer\n *\n * Displays form field content in a card layout with:\n * - Label/title in the header\n * - Content in the body\n * - Validation errors in the footer\n * - Danger outline when validation errors exist\n */\nconst FieldCard = ({\n children,\n className: _className = undefined,\n name,\n ...uniformFieldProps\n}: FieldCardProps) => {\n const { error, getLabelProps, label } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n const {\n control,\n formState: { touchedFields, submitCount },\n validation,\n } = useFormContext();\n\n // Check if any registered child field is required\n const validationInstance = validation?.baseInstance ?? validation?.instance;\n const registeredFields: string[] = Array.from(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (control as any)._names?.mount ?? [],\n );\n const childFieldPrefix = `${name}.`;\n const isRequired = validationInstance\n ? registeredFields\n .filter((f) => {\n return f.startsWith(childFieldPrefix);\n })\n .some((f) => {\n return checkFieldIsRequired(\n validationInstance,\n f.split('.').filter((k) => {\n return k !== '';\n }),\n );\n })\n : false;\n\n // Get touched state for this field's children by traversing the path\n const getNestedValue = (\n obj: Record<string, unknown> | undefined,\n path: string,\n ): Record<string, unknown> | undefined => {\n if (!obj) {\n return undefined;\n }\n const keys = path.split('.');\n let current: unknown = obj;\n keys.every((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n return true;\n }\n current = undefined;\n return false;\n });\n return current as Record<string, unknown> | undefined;\n };\n\n const fieldTouched = getNestedValue(\n touchedFields as Record<string, unknown>,\n name,\n );\n\n // Check for object-level errors (_errors) - always show these as they represent\n // explicit object-level validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasObjectErrors = !!error?._errors;\n\n // Check if any child field with an error is also touched\n const hasChildErrors =\n submitCount > 0 ||\n hasVisibleChildErrors(\n error as unknown as Record<string, unknown>,\n fieldTouched,\n );\n\n // Show invalid state if there are object errors or visible child errors\n const showInvalid = hasObjectErrors || hasChildErrors;\n\n // className from slots\n const variants = fieldCardVariants({ invalid: showInvalid });\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base}>\n {/* card header with label */}\n {label ? (\n <div\n {...getLabelProps()}\n aria-level={3}\n // Override getLabelProps className to use our own invalid styling based on hasErrors,\n // not HeroUI's which is based on any child field being invalid\n className={className.label}\n role=\"heading\"\n >\n {label}\n {/* Manual asterisk: getLabelProps uses schema-required for the object itself,\n but FieldCard needs asterisk based on whether any CHILD field is required */}\n {isRequired ? (\n <span aria-hidden=\"true\" className=\"ml-0.5 text-danger\">\n *\n </span>\n ) : null}\n </div>\n ) : null}\n\n {/* card content */}\n <div className={className.content}>{children}</div>\n\n {/* card footer with validation errors */}\n <FieldCardValidationError className={className.errorFooter} name={name} />\n </div>\n );\n};\n\nexport default FieldCard;\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,4BAA4B,EAChC,YAAY,QACZ,WACmC;CACnC,MAAM,EAAE,OAAO,sBAAsB,uBAAuB,WAC1D,gBAAgB,EACd,MACD,CAAC;CAGJ,MAAM,mBAAmB,kBAAkB;CAK3C,MAAM,YAAY,CAAC,CAAC,OAAO;AAE3B,QACE,oBAAC;EAAgB,SAAS,CAAC;YACxB,YACC,oBAAC,OAAO;GAEN,MAAM,mBAAmB,SAAY;IAAE,SAAS;IAAG,QAAQ;IAAG;GAC9D,SAAS,mBAAmB,QAAQ;IAAE,QAAQ;IAAG,SAAS;IAAG;GAC7D,OAAO,EAAE,UAAU,UAAU;GAC7B,YAAY;IAAE,UAAU;IAAK,MAAM;IAAW;GAC9C,SACE,mBAAmB,SAAY;IAAE,SAAS;IAAG,QAAQ;IAAQ;aAG/D,oBAAC;IACC,GAAI,uBAAuB;IAC3B,WAAW,GAAG,uBAAuB,EAAE,WAAW,UAAU;cAE5D,oBAAC;KAAI,GAAI,sBAAsB;eAC7B,oBAACA;MAEC,OAAO,MAAM;MACL;OACR;MACE;KACF;KApBF,oBAqBO,GACX;GACY;;AAItB,uCAAe;;;;;;;;AC1Df,MAAa,yBACX,QACA,YACY;AACZ,KAAI,CAAC,UAAU,CAAC,QACd,QAAO;AAGT,QAAO,OAAO,KAAK,OAAO,CACvB,QAAQ,QAAQ;AAEf,SAAO,QAAQ;GACf,CACD,MAAM,QAAQ;EACb,MAAM,aAAa,OAAO;EAC1B,MAAM,eAAe,QAAQ;AAG7B,MAAI,eAAe,UAAa,iBAAiB,OAC/C,QAAO;AAIT,MAAI,MAA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AACV,UAAO;IACP;AACF,SAAO;;CAGT,MAAM,eAAe,eACnB,eACA,KACD;CAKD,MAAM,kBAAkB,CAAC,CAAC,OAAO;CAGjC,MAAM,iBACJ,cAAc,KACd,sBACE,OACA,aACD;CAOH,MAAM,YAAY,qBADD,kBAAkB,EAAE,SAHjB,mBAAmB,gBAGoB,CAAC,EACX,YAAY,OAAO;AAEpE,QACE,qBAAC;EAAI,WAAW,UAAU;;GAEvB,QACC,qBAAC;IACC,GAAI,eAAe;IACnB,cAAY;IAGZ,WAAW,UAAU;IACrB,MAAK;eAEJ,OAGA,aACC,oBAAC;KAAK,eAAY;KAAO,WAAU;eAAqB;MAEjD,GACL;KACA,GACJ;GAGJ,oBAAC;IAAI,WAAW,UAAU;IAAU;KAAe;GAGnD,oBAACC;IAAyB,WAAW,UAAU;IAAmB;KAAQ;;GACtE;;AAIV,wBAAe"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_FormContext = require('./FormContext-CeFKQmVH.cjs');
|
|
2
2
|
const require_FieldValidationError = require('./FieldValidationError-A384-L3Y.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_useFormContext = require('./useFormContext-DJiJlfGJ.cjs');
|
|
4
|
+
const require_useUniformField = require('./useUniformField-Dd3AnpgE.cjs');
|
|
4
5
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
7
|
let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
|
|
@@ -13,9 +14,9 @@ let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
|
|
|
13
14
|
* accessibility attributes and animates them in/out using Framer Motion.
|
|
14
15
|
*/
|
|
15
16
|
const FieldCardValidationError = ({ className = void 0, name }) => {
|
|
16
|
-
const { error, getErrorMessageProps, getHelperWrapperProps,
|
|
17
|
+
const { error, getErrorMessageProps, getHelperWrapperProps, testId } = require_useUniformField.useUniformField({ name });
|
|
17
18
|
const disableAnimation = (0, _fuf_stack_pixel_motion.useReducedMotion)();
|
|
18
|
-
const hasErrors =
|
|
19
|
+
const hasErrors = !!error?._errors;
|
|
19
20
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixel_motion.AnimatePresence, {
|
|
20
21
|
initial: !disableAnimation,
|
|
21
22
|
children: hasErrors ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixel_motion.motion.div, {
|
|
@@ -29,7 +30,7 @@ const FieldCardValidationError = ({ className = void 0, name }) => {
|
|
|
29
30
|
},
|
|
30
31
|
style: { overflow: "hidden" },
|
|
31
32
|
transition: {
|
|
32
|
-
duration: .
|
|
33
|
+
duration: .4,
|
|
33
34
|
ease: "circOut"
|
|
34
35
|
},
|
|
35
36
|
animate: disableAnimation ? void 0 : {
|
|
@@ -54,22 +55,44 @@ var FieldCardValidationError_default = FieldCardValidationError;
|
|
|
54
55
|
|
|
55
56
|
//#endregion
|
|
56
57
|
//#region src/FieldCard/FieldCard.tsx
|
|
58
|
+
/**
|
|
59
|
+
* Recursively checks if any child field with an error is also touched.
|
|
60
|
+
* Returns true if at least one touched child has an error.
|
|
61
|
+
*/
|
|
62
|
+
const hasVisibleChildErrors = (errors, touched) => {
|
|
63
|
+
if (!errors || !touched) return false;
|
|
64
|
+
return Object.keys(errors).filter((key) => {
|
|
65
|
+
return key !== "_errors";
|
|
66
|
+
}).some((key) => {
|
|
67
|
+
const errorValue = errors[key];
|
|
68
|
+
const touchedValue = touched[key];
|
|
69
|
+
if (errorValue === void 0 || touchedValue === void 0) return false;
|
|
70
|
+
if (Array.isArray(errorValue)) return !!touchedValue;
|
|
71
|
+
if (typeof errorValue === "object" && errorValue !== null) return hasVisibleChildErrors(errorValue, touchedValue);
|
|
72
|
+
return false;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
57
75
|
const fieldCardVariants = (0, _fuf_stack_pixel_utils.tv)({
|
|
58
76
|
slots: {
|
|
59
|
-
base: ["overflow-hidden rounded-small border bg-content1"],
|
|
77
|
+
base: ["overflow-hidden rounded-small border bg-content1", "transition-colors duration-150 motion-reduce:transition-none"],
|
|
60
78
|
label: [
|
|
61
79
|
"pointer-events-auto! static! z-auto! block! w-full!",
|
|
62
80
|
"translate-x-0! translate-y-0! transform-none!",
|
|
63
|
-
"rounded-t-small border-b p-3 font-semibold text-medium"
|
|
81
|
+
"rounded-t-small border-b p-3 font-semibold text-medium",
|
|
82
|
+
"transition-colors duration-150 motion-reduce:transition-none"
|
|
64
83
|
],
|
|
65
84
|
content: ["p-3", "grid gap-4"],
|
|
66
|
-
errorFooter: [
|
|
85
|
+
errorFooter: [
|
|
86
|
+
"border-t",
|
|
87
|
+
"block px-3 pb-2 pt-1",
|
|
88
|
+
"transition-colors duration-150 motion-reduce:transition-none"
|
|
89
|
+
]
|
|
67
90
|
},
|
|
68
91
|
variants: { invalid: {
|
|
69
92
|
true: {
|
|
70
|
-
base: "border-danger",
|
|
71
|
-
label: "border-danger text-danger",
|
|
72
|
-
errorFooter: "border-danger"
|
|
93
|
+
base: "border-danger-200",
|
|
94
|
+
label: "border-danger-200 text-danger",
|
|
95
|
+
errorFooter: "border-danger-200"
|
|
73
96
|
},
|
|
74
97
|
false: {
|
|
75
98
|
base: "border-divider",
|
|
@@ -89,20 +112,52 @@ const fieldCardVariants = (0, _fuf_stack_pixel_utils.tv)({
|
|
|
89
112
|
* - Danger outline when validation errors exist
|
|
90
113
|
*/
|
|
91
114
|
const FieldCard = ({ children, className: _className = void 0, name, ...uniformFieldProps }) => {
|
|
92
|
-
const { error, getLabelProps,
|
|
115
|
+
const { error, getLabelProps, label } = require_useUniformField.useUniformField({
|
|
93
116
|
name,
|
|
94
117
|
...uniformFieldProps
|
|
95
118
|
});
|
|
96
|
-
const
|
|
119
|
+
const { control, formState: { touchedFields, submitCount }, validation } = require_useFormContext.useFormContext();
|
|
120
|
+
const validationInstance = validation?.baseInstance ?? validation?.instance;
|
|
121
|
+
const registeredFields = Array.from(control._names?.mount ?? []);
|
|
122
|
+
const childFieldPrefix = `${name}.`;
|
|
123
|
+
const isRequired = validationInstance ? registeredFields.filter((f) => {
|
|
124
|
+
return f.startsWith(childFieldPrefix);
|
|
125
|
+
}).some((f) => {
|
|
126
|
+
return require_useFormContext.checkFieldIsRequired(validationInstance, f.split(".").filter((k) => {
|
|
127
|
+
return k !== "";
|
|
128
|
+
}));
|
|
129
|
+
}) : false;
|
|
130
|
+
const getNestedValue = (obj, path) => {
|
|
131
|
+
if (!obj) return;
|
|
132
|
+
const keys = path.split(".");
|
|
133
|
+
let current = obj;
|
|
134
|
+
keys.every((key) => {
|
|
135
|
+
if (current && typeof current === "object") {
|
|
136
|
+
current = current[key];
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
current = void 0;
|
|
140
|
+
return false;
|
|
141
|
+
});
|
|
142
|
+
return current;
|
|
143
|
+
};
|
|
144
|
+
const fieldTouched = getNestedValue(touchedFields, name);
|
|
145
|
+
const hasObjectErrors = !!error?._errors;
|
|
146
|
+
const hasChildErrors = submitCount > 0 || hasVisibleChildErrors(error, fieldTouched);
|
|
147
|
+
const className = (0, _fuf_stack_pixel_utils.variantsToClassNames)(fieldCardVariants({ invalid: hasObjectErrors || hasChildErrors }), _className, "base");
|
|
97
148
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
98
149
|
className: className.base,
|
|
99
150
|
children: [
|
|
100
|
-
label ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
151
|
+
label ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
101
152
|
...getLabelProps(),
|
|
102
153
|
"aria-level": 3,
|
|
103
|
-
className:
|
|
154
|
+
className: className.label,
|
|
104
155
|
role: "heading",
|
|
105
|
-
children: label
|
|
156
|
+
children: [label, isRequired ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
className: "ml-0.5 text-danger",
|
|
159
|
+
children: "*"
|
|
160
|
+
}) : null]
|
|
106
161
|
}) : null,
|
|
107
162
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
108
163
|
className: className.content,
|
|
@@ -130,4 +185,4 @@ Object.defineProperty(exports, 'fieldCardVariants', {
|
|
|
130
185
|
return fieldCardVariants;
|
|
131
186
|
}
|
|
132
187
|
});
|
|
133
|
-
//# sourceMappingURL=FieldCard-
|
|
188
|
+
//# sourceMappingURL=FieldCard-DcMORXZR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldCard-DcMORXZR.cjs","names":["useUniformField","AnimatePresence","motion","FieldValidationError","useUniformField","useFormContext","checkFieldIsRequired","FieldCardValidationError"],"sources":["../src/FieldCard/subcomponents/FieldCardValidationError.tsx","../src/FieldCard/FieldCard.tsx"],"sourcesContent":["import {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\n\nexport interface FieldCardValidationErrorProps {\n /** CSS class name for the error footer wrapper */\n className?: string;\n /** Field name */\n name: string;\n}\n\n/**\n * Renders validation errors in the footer of a FieldCard component.\n *\n * This component handles displaying field-level validation errors with proper\n * accessibility attributes and animates them in/out using Framer Motion.\n */\nconst FieldCardValidationError = ({\n className = undefined,\n name,\n}: FieldCardValidationErrorProps) => {\n const { error, getErrorMessageProps, getHelperWrapperProps, testId } =\n useUniformField({\n name,\n });\n\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n // Always show object-level errors (_errors) as they represent explicit\n // validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = !!error?._errors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-card-errors\"\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n >\n <div\n {...getHelperWrapperProps()}\n className={cn(getHelperWrapperProps()?.className, className)}\n >\n <div {...getErrorMessageProps()}>\n <FieldValidationError\n // @ts-expect-error - error._errors exists but not typed\n error={error._errors}\n testId={testId}\n />\n </div>\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldCardValidationError;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { checkFieldIsRequired, useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\nimport FieldCardValidationError from './subcomponents/FieldCardValidationError';\n\n/**\n * Recursively checks if any child field with an error is also touched.\n * Returns true if at least one touched child has an error.\n */\nexport const hasVisibleChildErrors = (\n errors: Record<string, unknown> | undefined,\n touched: Record<string, unknown> | undefined,\n): boolean => {\n if (!errors || !touched) {\n return false;\n }\n\n return Object.keys(errors)\n .filter((key) => {\n // Skip object-level errors (_errors) - those are handled separately\n return key !== '_errors';\n })\n .some((key) => {\n const errorValue = errors[key];\n const touchedValue = touched[key];\n\n // If this key doesn't exist in both errors and touched, skip\n if (errorValue === undefined || touchedValue === undefined) {\n return false;\n }\n\n // If errorValue is an array, it's a leaf field error\n if (Array.isArray(errorValue)) {\n // touchedValue being truthy means the field is touched\n return !!touchedValue;\n }\n\n // Recursively check nested objects\n if (typeof errorValue === 'object' && errorValue !== null) {\n return hasVisibleChildErrors(\n errorValue as Record<string, unknown>,\n touchedValue as Record<string, unknown>,\n );\n }\n\n return false;\n });\n};\n\nexport const fieldCardVariants = tv({\n slots: {\n /** base class for the field card wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border bg-content1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the label/header */\n label: [\n // override HeroUI label positioning and display\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) for proper header size\n 'rounded-t-small border-b p-3 font-semibold text-medium',\n // animate border and text color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the content */\n content: [\n // same as p-3 of Card component\n 'p-3',\n // default grid for form components (see Grid component)\n 'grid gap-4',\n ],\n /** class for the error footer wrapper */\n errorFooter: [\n 'border-t',\n // force helper to be visible and add padding (pt-1 to compensate for inner content's top padding)\n 'block px-3 pb-2 pt-1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n },\n variants: {\n invalid: {\n true: {\n base: 'border-danger-200',\n label: 'border-danger-200 text-danger',\n errorFooter: 'border-danger-200',\n },\n false: {\n base: 'border-divider',\n label: 'border-divider text-foreground',\n errorFooter: 'border-divider',\n },\n },\n },\n defaultVariants: {\n invalid: false,\n },\n});\n\ntype ClassName = TVClassName<typeof fieldCardVariants>;\n\nexport interface FieldCardProps {\n /** Content to render inside the card */\n children: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Label content for the card header */\n label: ReactNode;\n /** Field name for validation */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * FieldCard component - A card-styled container with label header and error footer\n *\n * Displays form field content in a card layout with:\n * - Label/title in the header\n * - Content in the body\n * - Validation errors in the footer\n * - Danger outline when validation errors exist\n */\nconst FieldCard = ({\n children,\n className: _className = undefined,\n name,\n ...uniformFieldProps\n}: FieldCardProps) => {\n const { error, getLabelProps, label } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n const {\n control,\n formState: { touchedFields, submitCount },\n validation,\n } = useFormContext();\n\n // Check if any registered child field is required\n const validationInstance = validation?.baseInstance ?? validation?.instance;\n const registeredFields: string[] = Array.from(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (control as any)._names?.mount ?? [],\n );\n const childFieldPrefix = `${name}.`;\n const isRequired = validationInstance\n ? registeredFields\n .filter((f) => {\n return f.startsWith(childFieldPrefix);\n })\n .some((f) => {\n return checkFieldIsRequired(\n validationInstance,\n f.split('.').filter((k) => {\n return k !== '';\n }),\n );\n })\n : false;\n\n // Get touched state for this field's children by traversing the path\n const getNestedValue = (\n obj: Record<string, unknown> | undefined,\n path: string,\n ): Record<string, unknown> | undefined => {\n if (!obj) {\n return undefined;\n }\n const keys = path.split('.');\n let current: unknown = obj;\n keys.every((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n return true;\n }\n current = undefined;\n return false;\n });\n return current as Record<string, unknown> | undefined;\n };\n\n const fieldTouched = getNestedValue(\n touchedFields as Record<string, unknown>,\n name,\n );\n\n // Check for object-level errors (_errors) - always show these as they represent\n // explicit object-level validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasObjectErrors = !!error?._errors;\n\n // Check if any child field with an error is also touched\n const hasChildErrors =\n submitCount > 0 ||\n hasVisibleChildErrors(\n error as unknown as Record<string, unknown>,\n fieldTouched,\n );\n\n // Show invalid state if there are object errors or visible child errors\n const showInvalid = hasObjectErrors || hasChildErrors;\n\n // className from slots\n const variants = fieldCardVariants({ invalid: showInvalid });\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base}>\n {/* card header with label */}\n {label ? (\n <div\n {...getLabelProps()}\n aria-level={3}\n // Override getLabelProps className to use our own invalid styling based on hasErrors,\n // not HeroUI's which is based on any child field being invalid\n className={className.label}\n role=\"heading\"\n >\n {label}\n {/* Manual asterisk: getLabelProps uses schema-required for the object itself,\n but FieldCard needs asterisk based on whether any CHILD field is required */}\n {isRequired ? (\n <span aria-hidden=\"true\" className=\"ml-0.5 text-danger\">\n *\n </span>\n ) : null}\n </div>\n ) : null}\n\n {/* card content */}\n <div className={className.content}>{children}</div>\n\n {/* card footer with validation errors */}\n <FieldCardValidationError className={className.errorFooter} name={name} />\n </div>\n );\n};\n\nexport default FieldCard;\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,4BAA4B,EAChC,YAAY,QACZ,WACmC;CACnC,MAAM,EAAE,OAAO,sBAAsB,uBAAuB,WAC1DA,wCAAgB,EACd,MACD,CAAC;CAGJ,MAAM,kEAAqC;CAK3C,MAAM,YAAY,CAAC,CAAC,OAAO;AAE3B,QACE,2CAACC;EAAgB,SAAS,CAAC;YACxB,YACC,2CAACC,+BAAO;GAEN,MAAM,mBAAmB,SAAY;IAAE,SAAS;IAAG,QAAQ;IAAG;GAC9D,SAAS,mBAAmB,QAAQ;IAAE,QAAQ;IAAG,SAAS;IAAG;GAC7D,OAAO,EAAE,UAAU,UAAU;GAC7B,YAAY;IAAE,UAAU;IAAK,MAAM;IAAW;GAC9C,SACE,mBAAmB,SAAY;IAAE,SAAS;IAAG,QAAQ;IAAQ;aAG/D,2CAAC;IACC,GAAI,uBAAuB;IAC3B,0CAAc,uBAAuB,EAAE,WAAW,UAAU;cAE5D,2CAAC;KAAI,GAAI,sBAAsB;eAC7B,2CAACC;MAEC,OAAO,MAAM;MACL;OACR;MACE;KACF;KApBF,oBAqBO,GACX;GACY;;AAItB,uCAAe;;;;;;;;AC1Df,MAAa,yBACX,QACA,YACY;AACZ,KAAI,CAAC,UAAU,CAAC,QACd,QAAO;AAGT,QAAO,OAAO,KAAK,OAAO,CACvB,QAAQ,QAAQ;AAEf,SAAO,QAAQ;GACf,CACD,MAAM,QAAQ;EACb,MAAM,aAAa,OAAO;EAC1B,MAAM,eAAe,QAAQ;AAG7B,MAAI,eAAe,UAAa,iBAAiB,OAC/C,QAAO;AAIT,MAAI,MAAM,QAAQ,WAAW,CAE3B,QAAO,CAAC,CAAC;AAIX,MAAI,OAAO,eAAe,YAAY,eAAe,KACnD,QAAO,sBACL,YACA,aACD;AAGH,SAAO;GACP;;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,KACd,sBACE,OACA,aACD;CAOH,MAAM,6DADW,kBAAkB,EAAE,SAHjB,mBAAmB,gBAGoB,CAAC,EACX,YAAY,OAAO;AAEpE,QACE,4CAAC;EAAI,WAAW,UAAU;;GAEvB,QACC,4CAAC;IACC,GAAI,eAAe;IACnB,cAAY;IAGZ,WAAW,UAAU;IACrB,MAAK;eAEJ,OAGA,aACC,2CAAC;KAAK,eAAY;KAAO,WAAU;eAAqB;MAEjD,GACL;KACA,GACJ;GAGJ,2CAAC;IAAI,WAAW,UAAU;IAAU;KAAe;GAGnD,2CAACC;IAAyB,WAAW,UAAU;IAAmB;KAAQ;;GACtE;;AAIV,wBAAe"}
|
package/dist/Form/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FormProps, t as Form } from "../index-
|
|
1
|
+
import { n as FormProps, t as Form } from "../index-Bo79xzb4.cjs";
|
|
2
2
|
export { Form, Form as default, FormProps };
|
package/dist/Grid/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as GridProps, t as Grid } from "../index-
|
|
1
|
+
import { n as GridProps, t as Grid } from "../index-BbA9HcNa.cjs";
|
|
2
2
|
export { Grid, Grid as default, GridProps };
|
package/dist/Grid/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as GridProps, t as Grid } from "../index-
|
|
1
|
+
import { n as GridProps, t as Grid } from "../index-CCeHSmIe.js";
|
|
2
2
|
export { Grid, Grid as default, GridProps };
|
package/dist/Input/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_Input = require('../Input-
|
|
2
|
+
const require_Input = require('../Input-DlyrGFYf.cjs');
|
|
3
3
|
|
|
4
4
|
exports.Input = require_Input.Input_default$1;
|
|
5
5
|
exports.default = require_Input.Input_default;
|
package/dist/Input/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as InputProps, t as Input } from "../index-
|
|
1
|
+
import { n as InputProps, t as Input } from "../index-DaBgwR1t.cjs";
|
|
2
2
|
export { Input, Input as default, InputProps };
|
package/dist/Input/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as InputProps, t as Input } from "../index-
|
|
1
|
+
import { n as InputProps, t as Input } from "../index-D-ucmG60.js";
|
|
2
2
|
export { Input, Input as default, InputProps };
|
package/dist/Input/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as useUniformField } from "./useUniformField-
|
|
1
|
+
import { t as useUniformField } from "./useUniformField-C6oSAFa3.js";
|
|
2
2
|
import { t as useInputValueDebounce } from "./useInputValueDebounce-D9wArTKz.js";
|
|
3
3
|
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -92,4 +92,4 @@ var Input_default = Input_default$1;
|
|
|
92
92
|
|
|
93
93
|
//#endregion
|
|
94
94
|
export { Input_default$1 as n, Input_default as t };
|
|
95
|
-
//# sourceMappingURL=Input-
|
|
95
|
+
//# sourceMappingURL=Input-ChXItabV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input-
|
|
1
|
+
{"version":3,"file":"Input-ChXItabV.js","names":["Input","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;AAcA,MAAa,gBAAgB,GAAG,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAMA,WAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACE,gBAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAU,sBAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,aAAa,qBADF,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,oBAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,oBAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAeF;;;;ACnMf,oBAAeG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_FormContext = require('./FormContext-CeFKQmVH.cjs');
|
|
2
|
-
const require_useUniformField = require('./useUniformField-
|
|
2
|
+
const require_useUniformField = require('./useUniformField-Dd3AnpgE.cjs');
|
|
3
3
|
const require_useInputValueDebounce = require('./useInputValueDebounce-KIKsvSLm.cjs');
|
|
4
4
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -104,4 +104,4 @@ Object.defineProperty(exports, 'Input_default$1', {
|
|
|
104
104
|
return Input_default$1;
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
-
//# sourceMappingURL=Input-
|
|
107
|
+
//# sourceMappingURL=Input-DlyrGFYf.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input-
|
|
1
|
+
{"version":3,"file":"Input-DlyrGFYf.cjs","names":["useUniformField","useInputValueDebounce","HeroNumberInput","HeroInput","Input"],"sources":["../src/Input/Input.tsx","../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n } as React.ChangeEvent<HTMLInputElement>);\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"],"mappings":";;;;;;;;;AAcA,MAAa,+CAAmB,EAC9B,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AAyCF,MAAM,SAAS,EACb,WAAW,aAAa,QACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,QACb,MACA,UAAU,QACV,cAAc,KACd,OAAO,QACP,eAAe,QACf,OAAO,QACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,cACA,SACA,OACA,UACA,QACA,eACEA,wCAAgB;EAAE;EAAM;EAAM,GAAG;EAAmB,CAAC;CAGzD,MAAM,EAAE,UAAU,QAAQ,UAAUC,oDAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAGF,MAAM,iBACJ,YACI;EACE,aAAa;EACb,eAAe;AAGb,cAAW,MAAM,EAAE,cAAc,MAAM,CAAC;AAExC,OAAI,QACF,UAAS;;EAGd,GACD,EAAE;CAIR,MAAM,8DADW,eAAe,EACkB,YAAY,OAAO;CAGrE,MAAM,cAAc;EAClB;EAEA,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,cAAc;EACd,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EACD,eAAe;EACf;EACA;EACA,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACZ;EACA,gBAAgB;EAChB;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,SAAS;EACT,GAAG;EACJ;AAGD,KAAI,SAAS,UAAU;EAErB,MAAM,cACJ,UAAU,MAAM,SAAS,QAAQ,CAAC,OAAO,MAAM,OAAO,MAAM,CAAC,GACzD,OAAO,MAAM,GACb;AAEN,SACE,2CAACC;GACC,GAAI;GAGJ,OAAO;GAEP,eAAe,EACb,aAAa,OACd;GAED,WAAW,MAAoD;AAC7D,QAAI,OAAO,MAAM,SAEf,UAAS,EACP,QAAQ,EAAE,OAAO,OAAO,EAAE,EAAE,EAC7B,CAAwC;QAGzC,UAAS,EAAE;;IAGf;;AAKN,QACE,2CAACC;EAAU,GAAI;EAAuB;EAAgB;EAAa;GAAS;;AAIhF,sBAAe;;;;ACnMf,oBAAeC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_RadioBoxes = require('../RadioBoxes-
|
|
2
|
+
const require_RadioBoxes = require('../RadioBoxes-ClDOhQkO.cjs');
|
|
3
3
|
|
|
4
4
|
exports.RadioBoxes = require_RadioBoxes.RadioBoxes_default$1;
|
|
5
5
|
exports.default = require_RadioBoxes.RadioBoxes_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-
|
|
1
|
+
import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-hacHTzh4.cjs";
|
|
2
2
|
export { RadioBoxes, RadioBoxes as default, RadioBoxesProps, radioBoxVariants };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-
|
|
1
|
+
import { n as RadioBoxes, r as RadioBoxesProps, t as radioBoxVariants } from "../index-FHPC_VE1.js";
|
|
2
2
|
export { RadioBoxes, RadioBoxes as default, RadioBoxesProps, radioBoxVariants };
|
package/dist/RadioBoxes/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as RadioBoxes_default, r as radioBoxVariants, t as RadioBoxes_default$1 } from "../RadioBoxes-
|
|
1
|
+
import { n as RadioBoxes_default, r as radioBoxVariants, t as RadioBoxes_default$1 } from "../RadioBoxes-D6ULFGfd.js";
|
|
2
2
|
|
|
3
3
|
export { RadioBoxes_default as RadioBoxes, RadioBoxes_default$1 as default, radioBoxVariants };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_FormContext = require('./FormContext-CeFKQmVH.cjs');
|
|
2
2
|
const require_helpers = require('./helpers-CncbgvW_.cjs');
|
|
3
|
-
const require_useUniformField = require('./useUniformField-
|
|
3
|
+
const require_useUniformField = require('./useUniformField-Dd3AnpgE.cjs');
|
|
4
4
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let _heroui_radio = require("@heroui/radio");
|
|
@@ -157,4 +157,4 @@ Object.defineProperty(exports, 'radioBoxVariants', {
|
|
|
157
157
|
return radioBoxVariants;
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
|
-
//# sourceMappingURL=RadioBoxes-
|
|
160
|
+
//# sourceMappingURL=RadioBoxes-ClDOhQkO.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioBoxes-BXAo2Nom.cjs","names":["VisuallyHidden","useUniformField","createOptionValueConverter","HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n errorMessage,\n invalid,\n disabled,\n label,\n field: { onBlur, onChange, ref, value },\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value != null ? String(value) : ''}\n onValueChange={(newValue) => {\n onChange(convertToOriginalType(newValue));\n }}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;AASA,MAAa,kDAAsB;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,2CACW,MAAwB;CAOrC,MAAM,8DAJW,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,4CAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,2CAACA,wDACC,2CAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,2CAAC;IAAK,GAAI,iBAAiB;cACzB,2CAAC;KACC,GAAI,iBAAiB;KACrB,0CAAc,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,2CAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,4CAAC;IACC,GAAI,sBAAsB;IAC1B,0CACE,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA,WACC,2CAAC;KACC,GAAI,eAAe;KACnB,0CAAc,eAAe,CAAC,WAAW,WAAW,MAAM;KAEzD;MACI,GACL,MACH,cACC,2CAAC;KAAI,WAAW,WAAW;eAAc;MAAkB,GACzD;KACA;GACL,OACC,2CAAC;IAAK,GAAI,iBAAiB;cACzB,2CAAC;KACC,GAAI,iBAAiB;KACrB,0CAAc,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;;GAC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AAe;;;;ACnJf,yBAAeC"}
|
|
1
|
+
{"version":3,"file":"RadioBoxes-ClDOhQkO.cjs","names":["VisuallyHidden","useUniformField","createOptionValueConverter","HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n errorMessage,\n invalid,\n disabled,\n label,\n field: { onBlur, onChange, ref, value },\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value != null ? String(value) : ''}\n onValueChange={(newValue) => {\n onChange(convertToOriginalType(newValue));\n }}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;;AASA,MAAa,kDAAsB;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,2CACW,MAAwB;CAOrC,MAAM,8DAJW,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,4CAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,2CAACA,wDACC,2CAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,2CAAC;IAAK,GAAI,iBAAiB;cACzB,2CAAC;KACC,GAAI,iBAAiB;KACrB,0CAAc,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,2CAAC;IAAI,WAAW,WAAW;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CAAC;;YAG1C,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,mDACJ,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,2CAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO,OAAO,MAAM;eAE1B,OAAO,SAAS,OAAO;OATnB,OAAO,OAAO,MAAM,CAUhB;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;ACnJf,yBAAeC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as createOptionValueConverter } from "./helpers-D3A5d3M1.js";
|
|
2
|
-
import { t as useUniformField } from "./useUniformField-
|
|
2
|
+
import { t as useUniformField } from "./useUniformField-C6oSAFa3.js";
|
|
3
3
|
import { cn, slugify, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { RadioGroup, useRadio } from "@heroui/radio";
|
|
@@ -139,4 +139,4 @@ var RadioBoxes_default = RadioBoxes_default$1;
|
|
|
139
139
|
|
|
140
140
|
//#endregion
|
|
141
141
|
export { RadioBoxes_default$1 as n, radioBoxVariants as r, RadioBoxes_default as t };
|
|
142
|
-
//# sourceMappingURL=RadioBoxes-
|
|
142
|
+
//# sourceMappingURL=RadioBoxes-D6ULFGfd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioBoxes-B-EbjvDm.js","names":["HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n errorMessage,\n invalid,\n disabled,\n label,\n field: { onBlur, onChange, ref, value },\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value != null ? String(value) : ''}\n onValueChange={(newValue) => {\n onChange(convertToOriginalType(newValue));\n }}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,MAAwB;CAOrC,MAAM,aAAa,qBAJF,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,qBAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,oBAAC,4BACC,oBAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBAAiB;KACrB,WAAW,GAAG,iBAAiB,CAAC,WAAW,WAAW,QAAQ;MAC9D;KACG,GACL;GACH,OAAO,oBAAC;IAAI,WAAW,WAAW;cAAO;KAAW,GAAG;GACxD,qBAAC;IACC,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,CAAC,WACvB,WAAW,aACZ;eAEA,WACC,oBAAC;KACC,GAAI,eAAe;KACnB,WAAW,GAAG,eAAe,CAAC,WAAW,WAAW,MAAM;KAEzD;MACI,GACL,MACH,cACC,oBAAC;KAAI,WAAW,WAAW;eAAc;MAAkB,GACzD;KACA;GACL,OACC,oBAAC;IAAK,GAAI,iBAAi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W;KACX,OAAO,OAAO,OAAO,MAAM;eAE1B,OAAO,SAAS,OAAO;OATnB,OAAO,OAAO,MAAM,CAUhB;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;ACnJf,yBAAeC"}
|
|
1
|
+
{"version":3,"file":"RadioBoxes-D6ULFGfd.js","names":["HeroRadioGroup","RadioBoxes"],"sources":["../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useUniformField } from '../hooks/useUniformField';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string | number;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n ariaLabel,\n errorMessage,\n invalid,\n disabled,\n label,\n field: { onBlur, onChange, ref, value },\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n aria-label={ariaLabel}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n value={value != null ? String(value) : ''}\n onValueChange={(newValue) => {\n onChange(convertToOriginalType(newValue));\n }}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={String(option.value)}\n classNames={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\n value={String(option.value)}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"],"mappings":";;;;;;;;AASA,MAAa,mBAAmB,GAAG;CACjC,OAAO;EACL,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,OAAO;EACP,cAAc;EACf;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,MAAM,wCACP,EACF;EACD,WAAW,EACT,MAAM,EACJ,MAAM,kBACP,EACF;EACF;CACF,CAAC;AAaF,MAAa,YAAY,EACvB,YAAY,cAAc,QAC1B,OAAO,QACP,YAAY,OACZ,GAAG,YACgB;CACnB,MAAM,EACJ,UACA,WACA,aACA,cACA,iBACA,eACA,eACA,sBACA,iBACA,eACE,SAAS,MAAwB;CAOrC,MAAM,aAAa,qBAJF,iBAAiB;EAChC;EACA;EACD,CAAC,EAIA,aACA,OACD;AAED,QACE,qBAAC;EAAU,GAAI,cAAc;EAAE,WAAW,WAAW;;GACnD,oBAAC,4BACC,oBAAC,WAAM,GAAI,eAAe,GAAI,GACf;GAChB,CAAC,OACA,oBAAC;IAAK,GAAI,iBAAiB;cACzB,oBAAC;KACC,GAAI,iBA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Ae,GAAG;EACpC;EACE;EACR,aAAa,SAAS,eAAe;EACrC,OAAO,SAAS,OAAO,OAAO,MAAM,GAAG;EACvC,gBAAgB,aAAa;AAC3B,YAAS,sBAAsB,SAAS,CAAC;;YAG1C,QAAQ,KAAK,WAAW;AACvB,OAAI,WAAW,QAAQ;IACrB,MAAM,eAAe,QACnB,GAAG,OAAO,UAAU,OAAO,UAAU,OAAO,SAC5C,EAAE,aAAa,MAAM,CACtB;AACD,WACE,oBAAC;KAEC,YAAY;KACZ,eAAa;KACb,aAAa,OAAO;KACpB,MAAM,OAAO;KACb,YAAY,CAAC,CAAC,YAAY,OAAO;KACjC,WAAW;KACX,OAAO,OAAO,OAAO,MAAM;eAE1B,OAAO,SAAS,OAAO;OATnB,OAAO,OAAO,MAAM,CAUhB;;AAGf,UAAO;IACP;GACa;;AAIrB,2BAAe;;;;ACnJf,yBAAeC"}
|
package/dist/RadioTabs/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_RadioTabs = require('../RadioTabs-
|
|
2
|
+
const require_RadioTabs = require('../RadioTabs-CgB0MmbK.cjs');
|
|
3
3
|
|
|
4
4
|
exports.RadioTabs = require_RadioTabs.RadioTabs_default$1;
|
|
5
5
|
exports.default = require_RadioTabs.RadioTabs_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RadioTabsProps, t as RadioTabs } from "../index-
|
|
1
|
+
import { n as RadioTabsProps, t as RadioTabs } from "../index-Cj5CLBt2.cjs";
|
|
2
2
|
export { RadioTabs, RadioTabs as default, RadioTabsProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RadioTabsProps, t as RadioTabs } from "../index-
|
|
1
|
+
import { n as RadioTabsProps, t as RadioTabs } from "../index-tIGuHSXb.js";
|
|
2
2
|
export { RadioTabs, RadioTabs as default, RadioTabsProps };
|
package/dist/RadioTabs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_FormContext = require('./FormContext-CeFKQmVH.cjs');
|
|
2
2
|
const require_helpers = require('./helpers-CncbgvW_.cjs');
|
|
3
|
-
const require_useUniformField = require('./useUniformField-
|
|
3
|
+
const require_useUniformField = require('./useUniformField-Dd3AnpgE.cjs');
|
|
4
4
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -133,4 +133,4 @@ Object.defineProperty(exports, 'RadioTabs_default$1', {
|
|
|
133
133
|
return RadioTabs_default$1;
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
-
//# sourceMappingURL=RadioTabs-
|
|
136
|
+
//# sourceMappingURL=RadioTabs-CgB0MmbK.cjs.map
|