@fuf-stack/uniform 1.14.0 → 1.15.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-D-vR7oCb.js → FieldArray-Bnv1_-Rl.js} +3 -3
- package/dist/{FieldArray-D-vR7oCb.js.map → FieldArray-Bnv1_-Rl.js.map} +1 -1
- package/dist/{FieldArray-CWxV0Q6O.cjs → FieldArray-DgJgrLOY.cjs} +3 -3
- package/dist/{FieldArray-CWxV0Q6O.cjs.map → FieldArray-DgJgrLOY.cjs.map} +1 -1
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/FieldCard/index.d.cts +1 -1
- package/dist/FieldCard/index.d.ts +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/{FieldCard-CKEeknzL.js → FieldCard-CLd4PaoX.js} +2 -2
- package/dist/{FieldCard-CKEeknzL.js.map → FieldCard-CLd4PaoX.js.map} +1 -1
- package/dist/{FieldCard-DiaY4qXt.cjs → FieldCard-CeEnVxiB.cjs} +2 -2
- package/dist/{FieldCard-DiaY4qXt.cjs.map → FieldCard-CeEnVxiB.cjs.map} +1 -1
- package/dist/Form/index.d.cts +1 -1
- package/dist/Form/index.d.ts +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/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +2 -2
- package/dist/hooks/useUniformField/index.js +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.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-BOgOCyFF.d.cts → index-BGQrBRyF.d.cts} +4 -4
- package/dist/{index-BOgOCyFF.d.cts.map → index-BGQrBRyF.d.cts.map} +1 -1
- package/dist/{index-6eckRMZA.d.cts → index-BHMwBAFH.d.cts} +3 -3
- package/dist/{index-6eckRMZA.d.cts.map → index-BHMwBAFH.d.cts.map} +1 -1
- package/dist/{index-CPE2gcz3.d.ts → index-BM5ClMN4.d.ts} +15 -1
- package/dist/index-BM5ClMN4.d.ts.map +1 -0
- package/dist/{index-CJcgEkPo.d.ts → index-BQDEnYTq.d.ts} +3 -3
- package/dist/{index-CJcgEkPo.d.ts.map → index-BQDEnYTq.d.ts.map} +1 -1
- package/dist/{index-5Hp_MzN_.d.cts → index-BSZJQBCK.d.ts} +6 -6
- package/dist/{index-ByQXPNeM.d.ts.map → index-BSZJQBCK.d.ts.map} +1 -1
- package/dist/{index-DElTYKk8.d.ts → index-BTTo_ufh.d.ts} +3 -3
- package/dist/{index-DElTYKk8.d.ts.map → index-BTTo_ufh.d.ts.map} +1 -1
- package/dist/{index-nE7tTo2d.d.cts → index-BapBrgmV.d.cts} +16 -16
- package/dist/{index-nE7tTo2d.d.cts.map → index-BapBrgmV.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-aHcGnXHf.d.ts → index-Bd-E0JM1.d.ts} +3 -3
- package/dist/{index-aHcGnXHf.d.ts.map → index-Bd-E0JM1.d.ts.map} +1 -1
- package/dist/{index-Cb0AgRRa.d.cts → index-Bfk32Dl3.d.cts} +3 -3
- package/dist/{index-Cb0AgRRa.d.cts.map → index-Bfk32Dl3.d.cts.map} +1 -1
- package/dist/{index-BbAjuXqS.d.cts → index-Bs-1Pwc6.d.cts} +6 -6
- package/dist/{index-BbAjuXqS.d.cts.map → index-Bs-1Pwc6.d.cts.map} +1 -1
- package/dist/{index-CbK-kEVY.d.cts → index-BxV89x6q.d.cts} +21 -21
- package/dist/index-BxV89x6q.d.cts.map +1 -0
- package/dist/{index-BeinxTzw.d.cts → index-C3yzuYLc.d.cts} +21 -21
- package/dist/{index-BeinxTzw.d.cts.map → index-C3yzuYLc.d.cts.map} +1 -1
- package/dist/{index-C0--RHyE.d.cts → index-CCUQ-2Ic.d.cts} +34 -34
- package/dist/index-CCUQ-2Ic.d.cts.map +1 -0
- package/dist/{index-DamFEDHU.d.cts → index-CJse-RZf.d.cts} +34 -34
- package/dist/{index-DamFEDHU.d.cts.map → index-CJse-RZf.d.cts.map} +1 -1
- package/dist/{index-CkhVD2Pw.d.ts → index-CODzh0zX.d.ts} +6 -6
- package/dist/{index-CkhVD2Pw.d.ts.map → index-CODzh0zX.d.ts.map} +1 -1
- package/dist/{index-CusdoJv3.d.ts → index-CnIrK5L3.d.cts} +35 -36
- package/dist/{index-BZ9HvBM6.d.cts.map → index-CnIrK5L3.d.cts.map} +1 -1
- package/dist/{index-DsQabhNC.d.cts → index-CuTHt_2o.d.cts} +6 -6
- package/dist/{index-DsQabhNC.d.cts.map → index-CuTHt_2o.d.cts.map} +1 -1
- package/dist/{index-CEzwxdlZ.d.ts → index-DGryaZXZ.d.ts} +21 -21
- package/dist/{index-CEzwxdlZ.d.ts.map → index-DGryaZXZ.d.ts.map} +1 -1
- package/dist/{index-DS54nHWk.d.cts → index-DLJiYqVE.d.cts} +4 -4
- package/dist/{index-DS54nHWk.d.cts.map → index-DLJiYqVE.d.cts.map} +1 -1
- package/dist/{index-ClQFLoqX.d.ts → index-DMphDWRk.d.ts} +34 -34
- package/dist/{index-ClQFLoqX.d.ts.map → index-DMphDWRk.d.ts.map} +1 -1
- package/dist/{index-ByQXPNeM.d.ts → index-DN9Ke6Y8.d.cts} +6 -6
- package/dist/{index-5Hp_MzN_.d.cts.map → index-DN9Ke6Y8.d.cts.map} +1 -1
- package/dist/{index-BZ9HvBM6.d.cts → index-DoGBvZ4J.d.ts} +35 -34
- package/dist/{index-CusdoJv3.d.ts.map → index-DoGBvZ4J.d.ts.map} +1 -1
- package/dist/{index-qNwZcAWj.d.ts → index-DsSuY_wP.d.ts} +6 -6
- package/dist/{index-qNwZcAWj.d.ts.map → index-DsSuY_wP.d.ts.map} +1 -1
- package/dist/{index-ecrJ75NW.d.ts → index-DvAmzIEe.d.ts} +4 -4
- package/dist/{index-ecrJ75NW.d.ts.map → index-DvAmzIEe.d.ts.map} +1 -1
- package/dist/{index-BHklv3dW.d.ts → index-RiAo6yCB.d.ts} +48 -48
- package/dist/index-RiAo6yCB.d.ts.map +1 -0
- package/dist/{index-BNu0EV5x.d.cts → index-U0Jx25HO.d.cts} +3 -3
- package/dist/{index-BNu0EV5x.d.cts.map → index-U0Jx25HO.d.cts.map} +1 -1
- package/dist/{index-CYdvpGJF.d.cts → index-_mq7cbF5.d.cts} +3 -3
- package/dist/{index-CYdvpGJF.d.cts.map → index-_mq7cbF5.d.cts.map} +1 -1
- package/dist/{index-Cb8jQhHS.d.ts → index-drMNLgtV.d.ts} +34 -34
- package/dist/index-drMNLgtV.d.ts.map +1 -0
- package/dist/index-eJFvyVyS.d.cts +278 -0
- package/dist/index-eJFvyVyS.d.cts.map +1 -0
- package/dist/{index-DMOAkVG4.d.ts → index-hK6woeqR.d.ts} +6 -6
- package/dist/{index-DMOAkVG4.d.ts.map → index-hK6woeqR.d.ts.map} +1 -1
- package/dist/{index-B5BDC8Al.d.ts → index-pE9osud2.d.ts} +3 -3
- package/dist/{index-B5BDC8Al.d.ts.map → index-pE9osud2.d.ts.map} +1 -1
- package/dist/{index-DeHDOwxr.d.ts → index-uNWK5Vb5.d.ts} +21 -21
- package/dist/{index-DeHDOwxr.d.ts.map → index-uNWK5Vb5.d.ts.map} +1 -1
- package/dist/{index-BuaPmiMt.d.ts → index-y2jgEqoM.d.ts} +3 -3
- package/dist/{index-BuaPmiMt.d.ts.map → index-y2jgEqoM.d.ts.map} +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.d.cts +21 -21
- 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/{useUniformField-Dz_-tPrO.d.cts → useUniformField-8ODkBNpn.d.cts} +2 -2
- package/dist/{useUniformField-Dz_-tPrO.d.cts.map → useUniformField-8ODkBNpn.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-giYkUMG_.d.ts → useUniformField-CJX0u3Ou.d.ts} +2 -2
- package/dist/{useUniformField-giYkUMG_.d.ts.map → useUniformField-CJX0u3Ou.d.ts.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/{useUniformFieldArray-N5uHlvRy.cjs → useUniformFieldArray-D93AUZI4.cjs} +2 -2
- package/dist/{useUniformFieldArray-N5uHlvRy.cjs.map → useUniformFieldArray-D93AUZI4.cjs.map} +1 -1
- package/dist/{useUniformFieldArray-BMBc3o7P.d.cts → useUniformFieldArray-DF83iIC1.d.cts} +2 -2
- package/dist/{useUniformFieldArray-BMBc3o7P.d.cts.map → useUniformFieldArray-DF83iIC1.d.cts.map} +1 -1
- package/dist/{useUniformFieldArray-COp7qAwf.d.ts → useUniformFieldArray-DFGgYtxz.d.ts} +2 -2
- package/dist/{useUniformFieldArray-COp7qAwf.d.ts.map → useUniformFieldArray-DFGgYtxz.d.ts.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/Select-C5mS7WZC.cjs.map +0 -1
- package/dist/Select-D_LJBu0p.js.map +0 -1
- package/dist/index-BHklv3dW.d.ts.map +0 -1
- package/dist/index-C0--RHyE.d.cts.map +0 -1
- package/dist/index-CPE2gcz3.d.ts.map +0 -1
- package/dist/index-Cb8jQhHS.d.ts.map +0 -1
- package/dist/index-CbK-kEVY.d.cts.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-DNrmEXLg.js","names":["useRHFFieldArray","useFormContext"],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformFieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport { useUniformField } from '../useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content */\n label?: ReactNode;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useUniformFieldArray';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,MAAa,wBAEX,EACA,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,OAC1B,UACA,QAAQ,gBACR,YAC6C;CAE7C,MAAM,eAAe,gBAA8B;EAC3C;EACN;EACA,QAAQ;EACR;EACD,CAAC;CAEF,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,SAASA,cAAiB;EAChE;EACA;EACD,CAAC;CAEF,MAAM,EAAE,SAAS,aAAaC,kBAA8B;CAQ5D,MAAM,kBAAkB,cAAc;AACpC,SAAO,2BAA2B,OAAO,WAAW;IACnD,CAAC,yBAAyB,OAAO,OAAO,CAAC;CAS5C,MAAM,iBAAiB,OAAO,CAAC,gBAAgB;AAK/C,iBAAgB;AACd,MAAI,gBACF,gBAAe,UAAU;IAE1B,CAAC,gBAAgB,CAAC;AAOrB,iBAAgB;AACd,MAAI,eAAe,QACjB,kBAAiB;AACf,WAAQ,KAA2B;KAClC,IAAI;IAGR,CAAC,OAAO,OAAO,CAAC;CAInB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,KAAK;CAI9D,MAAM,uBAAuB,kBAAkB;AAC/C,iBAAgB;AACd,MAAI,eAAe,QACjB,qBAAoB,CAAC,CAAC,qBAAqB;IAE5C,CAAC,qBAAqB,CAAC;CAK1B,MAAM,sBAAsB,cAAc;AACxC,SAAO,OACH,GAAG,eAAe,wBAAwB,MAAM,GAC/C,wBAAwB,EAAE;IAC9B,CAAC,MAAM,qBAAqB,CAAC;AAUhC,iBACQ;AACJ,MAAI,iBAAiB;AAGnB,YAAS,MAA4B,CAAC,oBAAoB,EAAS;IACjE,aAAa;IACb,aAAa;IACd,CAAC;AAGF,kBAAe,UAAU;AAKzB,OAAI,CAAC,wBAAwB,iBAC3B,kBAAiB;AACf,wBAAoB,MAAM;MACzB,EAAE;;IAUX,CAAC,gBAAgB,CAClB;AAED,QAAO;EAEL;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,GAAG;EACJ"}
|
|
@@ -19,6 +19,8 @@ interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {
|
|
|
19
19
|
*
|
|
20
20
|
* Only triggers on manual user input (typing, clicking, selecting),
|
|
21
21
|
* NOT on programmatic changes like form.reset() or form.setValue().
|
|
22
|
+
* Also does NOT trigger when selecting the same value (e.g., clicking
|
|
23
|
+
* an already-selected option in a Select).
|
|
22
24
|
*
|
|
23
25
|
* This hook subscribes to field changes at the source (useController),
|
|
24
26
|
* ensuring immediate and accurate detection of user interactions.
|
|
@@ -75,4 +77,4 @@ declare const useWatchUserChange: <TFieldValues extends FieldValues = FieldValue
|
|
|
75
77
|
}: UseWatchUserChangeOptions<TFieldValues>) => void;
|
|
76
78
|
//#endregion
|
|
77
79
|
export { useWatchUserChange as n, UseWatchUserChangeOptions as t };
|
|
78
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
80
|
+
//# sourceMappingURL=useWatchUserChange-DahNCPDG.d.cts.map
|
package/dist/{useWatchUserChange-COVdHmki.d.cts.map → useWatchUserChange-DahNCPDG.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-DahNCPDG.d.cts","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":[],"mappings":";;;UAYiB,+CAA+C;;EAA/C,KAAA,EAER,IAFQ,CAEH,YAFG,CAAA;EAA+C;;;;EAUhD,QAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,OAAA,EAAA;IACoB,QAAA,EADpB,eACoB,CADJ,YACI,CAAA;IAAlB,UAAA,EAAA,iBAAA,CAAkB,YAAlB,CAAA;IACQ,KAAA,EAAb,YAAa,CAAA,YAAA,CAAA;EAAb,CAAA,EAAA,GAAA,IAAA;;AA8Db;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,0CACU,cAAc;SACnC;;GAGC,0BAA0B"}
|
|
@@ -7,6 +7,8 @@ import { useEffect } from "react";
|
|
|
7
7
|
*
|
|
8
8
|
* Only triggers on manual user input (typing, clicking, selecting),
|
|
9
9
|
* NOT on programmatic changes like form.reset() or form.setValue().
|
|
10
|
+
* Also does NOT trigger when selecting the same value (e.g., clicking
|
|
11
|
+
* an already-selected option in a Select).
|
|
10
12
|
*
|
|
11
13
|
* This hook subscribes to field changes at the source (useController),
|
|
12
14
|
* ensuring immediate and accurate detection of user interactions.
|
|
@@ -80,4 +82,4 @@ const useWatchUserChange = ({ watch: watchField, onChange }) => {
|
|
|
80
82
|
|
|
81
83
|
//#endregion
|
|
82
84
|
export { useWatchUserChange as t };
|
|
83
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
85
|
+
//# sourceMappingURL=useWatchUserChange-DyhUYlrN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-DyhUYlrN.js","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n * Also does NOT trigger when selecting the same value (e.g., clicking\n * an already-selected option in a Select).\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnC,gBAA8B;AAEhC,iBAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
|
@@ -19,6 +19,8 @@ interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {
|
|
|
19
19
|
*
|
|
20
20
|
* Only triggers on manual user input (typing, clicking, selecting),
|
|
21
21
|
* NOT on programmatic changes like form.reset() or form.setValue().
|
|
22
|
+
* Also does NOT trigger when selecting the same value (e.g., clicking
|
|
23
|
+
* an already-selected option in a Select).
|
|
22
24
|
*
|
|
23
25
|
* This hook subscribes to field changes at the source (useController),
|
|
24
26
|
* ensuring immediate and accurate detection of user interactions.
|
|
@@ -75,4 +77,4 @@ declare const useWatchUserChange: <TFieldValues extends FieldValues = FieldValue
|
|
|
75
77
|
}: UseWatchUserChangeOptions<TFieldValues>) => void;
|
|
76
78
|
//#endregion
|
|
77
79
|
export { useWatchUserChange as n, UseWatchUserChangeOptions as t };
|
|
78
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
80
|
+
//# sourceMappingURL=useWatchUserChange-JMU-vN92.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-JMU-vN92.d.ts","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":[],"mappings":";;;UAYiB,+CAA+C;;EAA/C,KAAA,EAER,IAFQ,CAEH,YAFG,CAAA;EAA+C;;;;EAUhD,QAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,OAAA,EAAA;IACoB,QAAA,EADpB,eACoB,CADJ,YACI,CAAA;IAAlB,UAAA,EAAA,iBAAA,CAAkB,YAAlB,CAAA;IACQ,KAAA,EAAb,YAAa,CAAA,YAAA,CAAA;EAAb,CAAA,EAAA,GAAA,IAAA;;AA8Db;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,0CACU,cAAc;SACnC;;GAGC,0BAA0B"}
|
|
@@ -8,6 +8,8 @@ let react = require("react");
|
|
|
8
8
|
*
|
|
9
9
|
* Only triggers on manual user input (typing, clicking, selecting),
|
|
10
10
|
* NOT on programmatic changes like form.reset() or form.setValue().
|
|
11
|
+
* Also does NOT trigger when selecting the same value (e.g., clicking
|
|
12
|
+
* an already-selected option in a Select).
|
|
11
13
|
*
|
|
12
14
|
* This hook subscribes to field changes at the source (useController),
|
|
13
15
|
* ensuring immediate and accurate detection of user interactions.
|
|
@@ -86,4 +88,4 @@ Object.defineProperty(exports, 'useWatchUserChange', {
|
|
|
86
88
|
return useWatchUserChange;
|
|
87
89
|
}
|
|
88
90
|
});
|
|
89
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
91
|
+
//# sourceMappingURL=useWatchUserChange-jivI5KIB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-jivI5KIB.cjs","names":["useFormContext"],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n * Also does NOT trigger when selecting the same value (e.g., clicking\n * an already-selected option in a Select).\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnCA,uCAA8B;AAEhC,4BAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -181,5 +181,5 @@
|
|
|
181
181
|
"react": "19.2.3",
|
|
182
182
|
"react-dom": "19.2.3"
|
|
183
183
|
},
|
|
184
|
-
"gitHead": "
|
|
184
|
+
"gitHead": "edcb8213fa4fd0a61031845f1078f697c321c4f4"
|
|
185
185
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Select-C5mS7WZC.cjs","names":["components","useUniformField","useFormContext","createOptionValueConverter","ReactSelect","Select"],"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { MultiValue, Props, SingleValue } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'duration-150! rounded-lg border-2 border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\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 'pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased text-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: 'rounded-sm p-2 text-foreground-500',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface SelectOption {\n /** option label */\n label?: ReactNode;\n /** option value */\n value: string | number;\n}\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps 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; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Get getFieldState to check isTouched in onChange callback\n const { getFieldState } = useFormContext();\n\n // Track if the select is focused\n const [isFocused, setIsFocused] = useState(false);\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // React-select classNames configuration\n const reactSelectClassNames = {\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n input: () => {\n return classNames.input;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(classNames.multiValueLabel, `${getValueProps().className}`);\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }: {\n isFocused: boolean;\n isSelected: boolean;\n }) => {\n return cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n };\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute selected option(s) for react-select\n // Compare as strings to handle both string and number values\n // Use null fallback to properly clear react-select when no value is selected\n const selectedOptions = multiSelect\n ? options.filter((option) => {\n if (!Array.isArray(value)) {\n return false;\n }\n return value.some((v) => {\n return String(option.value) === String(v);\n });\n })\n : (options.find((option) => {\n return String(option.value) === String(value);\n }) ?? null);\n\n // Handle selection change\n const handleChange = (\n option: MultiValue<SelectOption> | SingleValue<SelectOption>,\n ) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return convertToOriginalType(_option.value);\n }),\n );\n } else {\n const newValue = (option as SelectOption)?.value;\n onChange(newValue != null ? convertToOriginalType(newValue) : newValue);\n }\n // Mark field as touched immediately when a selection is made if not already touched\n // This ensures validation errors show right away (isTouched becomes true)\n // For Select components, selecting an option is a complete user action\n // (unlike text inputs where typing is ongoing), so we mark as touched immediately\n const { isTouched: currentIsTouched } = getFieldState(name, testId);\n if (!currentIsTouched) {\n onBlur();\n }\n };\n\n // Handle blur event\n const handleBlur = () => {\n setIsFocused(false);\n onBlur();\n };\n\n // Handle focus event\n const handleFocus = () => {\n setIsFocused(true);\n };\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\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-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // set aria-labelledby to the label id so that the select is accessible\n aria-label={ariaLabel}\n classNames={reactSelectClassNames}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n name={name}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n value={selectedOptions}\n // set aria-labelledby to the label id so that the select is accessible\n aria-labelledby={\n label\n ? getTriggerProps()['aria-labelledby']?.split(' ')[1]\n : undefined\n }\n components={{\n Control: ControlComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Input: InputComponent,\n Option: OptionComponent,\n }}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,gDAAoB,EAC/B,OAAO;CACL,MAAM;CACN,gBACE;CACF,SACE;CACF,iBAAiB;CACjB,WAAW;CACX,aAAa;CACb,mBACE;CACF,OAAO;CACP,cAAc;CACd,qBAAqB;CACrB,oBAAoB;CACpB,OAAO;CAGP,OACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,qBAAqB;CACrB,iBAAiB;CACjB,kBACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,iBAAiB;CACjB,QAAQ;CACR,aAAa;CACb,iBAAiB;CACjB,aAAa;CACb,gBAAgB;CACjB,EACF,CAAC;AA+CF,MAAM,kBAA2C,UAAU;CAGzD,MAAM,SAAS,GAAG,MAAM,YAAY;AAEpC,QAAO,2CAACA,wBAAW;EAAM,eAAa;EAAQ,GAAI;GAAS;;AAG7D,MAAM,oBAA+C,UAAU;CAG7D,MAAM,SAAS,GAAG,MAAM,YAAY,eAAe;AACnD,QACE,2CAAC;EAAI,eAAa;YAEhB,2CAACA,wBAAW,WAAQ,GAAI,QAAS;GAC7B;;AAIV,MAAM,mBAA6C,UAAU;CAG3D,MAAM,SAAS,GAAG,MAAM,YAAY,eAAe,qDAAyB,OAAO,OAAO,MAAM,UAAU,OAAO,MAAM,MAAM,EAAE,EAAE,aAAa,MAAM,CAAC;AACrJ,QACE,2CAAC;EAAI,eAAa;YAEhB,2CAACA,wBAAW,UAAO,GAAI,QAAS;GAC5B;;AAIV,MAAM,8BACJ,UACG;CAGH,MAAM,SAAS,OAAO,YAAY;AAClC,QACE,2CAAC;EAAI,eAAa,GAAG,OAAO;YAE1B,2CAACA,wBAAW,qBAAkB,GAA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cAAY;IACZ,YAAY;IAEZ,eAAa;IACC;IACd,mBAAmB;IACP;IACZ,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,WAAW;IACX,SAAS;IAIT,cAAa;IACP;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACM;IACN;IACI;IACb,OAAO;IAEP,mBACE,QACI,iBAAiB,CAAC,oBAAoB,MAAM,IAAI,CAAC,KACjD;IAEN,YAAY;KACV,SAAS;KACT,mBAAmB;KACnB,OAAO;KACP,QAAQ;KACT;KACD;GACD,UACC,2CAAC;IAAI,GAAI,uBAAuB;cAC9B,2CAAC;KAAI,GAAI,sBAAsB;eAAG;MAAmB;KACjD,GACJ;;GACA;;AAIV,uBAAe;;;;AC/Yf,qBAAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Select-D_LJBu0p.js","names":["Select"],"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { MultiValue, Props, SingleValue } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter } from '../helpers';\nimport { useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'duration-150! rounded-lg border-2 border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\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 'pointer-events-auto relative bottom-1.5 ml-1 subpixel-antialiased text-small group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: 'rounded-sm p-2 text-foreground-500',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ninterface SelectOption {\n /** option label */\n label?: ReactNode;\n /** option value */\n value: string | number;\n}\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps 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; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n {}\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;\n return (\n <div data-testid={testId}>\n {}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n {}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Get getFieldState to check isTouched in onChange callback\n const { getFieldState } = useFormContext();\n\n // Track if the select is focused\n const [isFocused, setIsFocused] = useState(false);\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // React-select classNames configuration\n const reactSelectClassNames = {\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n input: () => {\n return classNames.input;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(classNames.multiValueLabel, `${getValueProps().className}`);\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }: {\n isFocused: boolean;\n isSelected: boolean;\n }) => {\n return cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n };\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // Compute selected option(s) for react-select\n // Compare as strings to handle both string and number values\n // Use null fallback to properly clear react-select when no value is selected\n const selectedOptions = multiSelect\n ? options.filter((option) => {\n if (!Array.isArray(value)) {\n return false;\n }\n return value.some((v) => {\n return String(option.value) === String(v);\n });\n })\n : (options.find((option) => {\n return String(option.value) === String(value);\n }) ?? null);\n\n // Handle selection change\n const handleChange = (\n option: MultiValue<SelectOption> | SingleValue<SelectOption>,\n ) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return convertToOriginalType(_option.value);\n }),\n );\n } else {\n const newValue = (option as SelectOption)?.value;\n onChange(newValue != null ? convertToOriginalType(newValue) : newValue);\n }\n // Mark field as touched immediately when a selection is made if not already touched\n // This ensures validation errors show right away (isTouched becomes true)\n // For Select components, selecting an option is a complete user action\n // (unlike text inputs where typing is ongoing), so we mark as touched immediately\n const { isTouched: currentIsTouched } = getFieldState(name, testId);\n if (!currentIsTouched) {\n onBlur();\n }\n };\n\n // Handle blur event\n const handleBlur = () => {\n setIsFocused(false);\n onBlur();\n };\n\n // Handle focus event\n const handleFocus = () => {\n setIsFocused(true);\n };\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\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-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n menuShouldBlockScroll\n unstyled\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // set aria-labelledby to the label id so that the select is accessible\n aria-label={ariaLabel}\n classNames={reactSelectClassNames}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n name={name}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n onInputChange={onInputChange}\n options={options}\n placeholder={placeholder}\n value={selectedOptions}\n // set aria-labelledby to the label id so that the select is accessible\n aria-labelledby={\n label\n ? getTriggerProps()['aria-labelledby']?.split(' ')[1]\n : undefined\n }\n components={{\n Control: ControlComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Input: InputComponent,\n Option: OptionComponent,\n }}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iBAAiB,GAAG,EAC/B,OAAO;CACL,MAAM;CACN,gBACE;CACF,SACE;CACF,iBAAiB;CACjB,WAAW;CACX,aAAa;CACb,mBACE;CACF,OAAO;CACP,cAAc;CACd,qBAAqB;CACrB,oBAAoB;CACpB,OAAO;CAGP,OACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,qBAAqB;CACrB,iBAAiB;CACjB,kBACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,iBAAiB;CACjB,QAA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|
|
1
|
-
{"version":3,"file":"index-BHklv3dW.d.ts","names":[],"sources":["../src/Slider/Slider.tsx"],"sourcesContent":[],"mappings":";;;;;;cAYa,oCAAc;;mBAmBzB,mBAAA,CAAA,UAAA;;MAnBW,KAAA,CAAA,gCAmBX;MAAA,KAAA,CAAA,gCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAnByB;EAAA,KAAA,EAAA,MAAA;AAmBxB,CAAA,EAAA,SAEE,EAAA;EACA,CAAA,GAAA,EAAA,MAAS,CAAA,EAAA;IAEG,CAAA,GAAA,EAAA,MAAY,CAAA,mCAAA;MAIf,IAAA,CAAA,gCAAA;MAIC,KAAA,CAAA,gCAAA;MAkBE,KAAA,CAAA,gCAAA;MA1BoB,UAAA,CAAA,gCAAA;MAAY,YAAA,CAAA,gCAAA;MAiD3C,MAwHL,CAAA,gCAAA;MAxHe,YAAA,CAAA,gCAAA;MAAA,IAAA,CAAA,gCAAA;MAAA,YAAA,CAAA,gCAAA;MAAA,IAAA,CAAA,gCAAA;MAAA,KAAA,CAAA,gCAAA;MAAA,KAAA,CAAA,gCAAA;MAAA,YAAA,CAAA,gCAAA;IAAA,CAAA;EAAA,CAAA;CAAA,GAAA,CAAA,CAAA,EAAA;EAYb,IAAA,EAAA,MAAA;EAAW,UAAA,EAAA,MAAA;EA4Gb,YAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA5KI,YAAA,GAAe,eAAe;KAC9B,SAAA,GAAY,mBAAmB;UAEnB,WAAA,SAAoB;;;;cAIvB;;;;eAIC;;;;;;;;;;;;;;;;;;iBAkBE;;;;;;;;;;;;;;;;;;;;;;cAuBX;;;;;;;;;;;;GAYH,gBAAW,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-C0--RHyE.d.cts","names":[],"sources":["../src/Radios/Radios.tsx"],"sourcesContent":[],"mappings":";;;;;cAaa,oCAAc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;MA5BsB,KAAA,CAAA,iCAAA;MAAY,WAAA,CAAA,iCAAA;MAyK/C,YAAA,CAAA,iCAAA;IArIc,CAAA;EAAA,CAAA;CAAA,GAAA,CAAA,CAAA,EAAA;EAAA;EAAA,IAAA,EAAA,MAAA;EAAA;EAAA,WAAA,EAAA,MAAA;EAAA;EAAA,KAAA,EAAA,MAAA;EAAA;EAYZ,YAAA,EAAA,MAAA;CAAU,mCAAA,CAAA,OAAA,EAAA;EAyHZ;;;;;;;;;KA5KI,YAAA,GAAe,eAAe;KAC9B,SAAA,GAAY,mBAAmB;UAEnB,UAAA,SAAmB;;;;cAItB;;;;;;;;eAQC;;UAEL;;;;;;;;;;iBAUO;;;;cAIH;;;;;;;cAQR;aAAS;;;;;;;;;;;GAYZ,eAAU,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import * as tailwind_variants182 from "tailwind-variants";
|
|
2
|
-
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
3
|
-
import { TVClassName, TVProps } from "@fuf-stack/pixel-utils";
|
|
4
|
-
import { ReactNode } from "react";
|
|
5
|
-
import { Props } from "react-select";
|
|
6
|
-
|
|
7
|
-
//#region src/Select/Select.d.ts
|
|
8
|
-
declare const selectVariants: tailwind_variants182.TVReturnType<{
|
|
9
|
-
[key: string]: {
|
|
10
|
-
[key: string]: tailwind_variants182.ClassValue | {
|
|
11
|
-
base?: tailwind_variants182.ClassValue;
|
|
12
|
-
clearIndicator?: tailwind_variants182.ClassValue;
|
|
13
|
-
control?: tailwind_variants182.ClassValue;
|
|
14
|
-
control_focused?: tailwind_variants182.ClassValue;
|
|
15
|
-
crossIcon?: tailwind_variants182.ClassValue;
|
|
16
|
-
downChevron?: tailwind_variants182.ClassValue;
|
|
17
|
-
dropdownIndicator?: tailwind_variants182.ClassValue;
|
|
18
|
-
group?: tailwind_variants182.ClassValue;
|
|
19
|
-
groupHeading?: tailwind_variants182.ClassValue;
|
|
20
|
-
indicatorsContainer?: tailwind_variants182.ClassValue;
|
|
21
|
-
indicatorSeparator?: tailwind_variants182.ClassValue;
|
|
22
|
-
input?: tailwind_variants182.ClassValue;
|
|
23
|
-
label?: tailwind_variants182.ClassValue;
|
|
24
|
-
loadingIndicator?: tailwind_variants182.ClassValue;
|
|
25
|
-
loadingMessage?: tailwind_variants182.ClassValue;
|
|
26
|
-
menu?: tailwind_variants182.ClassValue;
|
|
27
|
-
menuList?: tailwind_variants182.ClassValue;
|
|
28
|
-
menuPortal?: tailwind_variants182.ClassValue;
|
|
29
|
-
multiValue?: tailwind_variants182.ClassValue;
|
|
30
|
-
multiValueContainer?: tailwind_variants182.ClassValue;
|
|
31
|
-
multiValueLabel?: tailwind_variants182.ClassValue;
|
|
32
|
-
multiValueRemove?: tailwind_variants182.ClassValue;
|
|
33
|
-
noOptionsMessage?: tailwind_variants182.ClassValue;
|
|
34
|
-
option_focused?: tailwind_variants182.ClassValue;
|
|
35
|
-
option_selected?: tailwind_variants182.ClassValue;
|
|
36
|
-
option?: tailwind_variants182.ClassValue;
|
|
37
|
-
placeholder?: tailwind_variants182.ClassValue;
|
|
38
|
-
selectContainer?: tailwind_variants182.ClassValue;
|
|
39
|
-
singleValue?: tailwind_variants182.ClassValue;
|
|
40
|
-
valueContainer?: tailwind_variants182.ClassValue;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
} | {
|
|
44
|
-
[x: string]: {
|
|
45
|
-
[x: string]: tailwind_variants182.ClassValue | {
|
|
46
|
-
base?: tailwind_variants182.ClassValue;
|
|
47
|
-
clearIndicator?: tailwind_variants182.ClassValue;
|
|
48
|
-
control?: tailwind_variants182.ClassValue;
|
|
49
|
-
control_focused?: tailwind_variants182.ClassValue;
|
|
50
|
-
crossIcon?: tailwind_variants182.ClassValue;
|
|
51
|
-
downChevron?: tailwind_variants182.ClassValue;
|
|
52
|
-
dropdownIndicator?: tailwind_variants182.ClassValue;
|
|
53
|
-
group?: tailwind_variants182.ClassValue;
|
|
54
|
-
groupHeading?: tailwind_variants182.ClassValue;
|
|
55
|
-
indicatorsContainer?: tailwind_variants182.ClassValue;
|
|
56
|
-
indicatorSeparator?: tailwind_variants182.ClassValue;
|
|
57
|
-
input?: tailwind_variants182.ClassValue;
|
|
58
|
-
label?: tailwind_variants182.ClassValue;
|
|
59
|
-
loadingIndicator?: tailwind_variants182.ClassValue;
|
|
60
|
-
loadingMessage?: tailwind_variants182.ClassValue;
|
|
61
|
-
menu?: tailwind_variants182.ClassValue;
|
|
62
|
-
menuList?: tailwind_variants182.ClassValue;
|
|
63
|
-
menuPortal?: tailwind_variants182.ClassValue;
|
|
64
|
-
multiValue?: tailwind_variants182.ClassValue;
|
|
65
|
-
multiValueContainer?: tailwind_variants182.ClassValue;
|
|
66
|
-
multiValueLabel?: tailwind_variants182.ClassValue;
|
|
67
|
-
multiValueRemove?: tailwind_variants182.ClassValue;
|
|
68
|
-
noOptionsMessage?: tailwind_variants182.ClassValue;
|
|
69
|
-
option_focused?: tailwind_variants182.ClassValue;
|
|
70
|
-
option_selected?: tailwind_variants182.ClassValue;
|
|
71
|
-
option?: tailwind_variants182.ClassValue;
|
|
72
|
-
placeholder?: tailwind_variants182.ClassValue;
|
|
73
|
-
selectContainer?: tailwind_variants182.ClassValue;
|
|
74
|
-
singleValue?: tailwind_variants182.ClassValue;
|
|
75
|
-
valueContainer?: tailwind_variants182.ClassValue;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
} | {}, {
|
|
79
|
-
base: string;
|
|
80
|
-
clearIndicator: string;
|
|
81
|
-
control: string;
|
|
82
|
-
control_focused: string;
|
|
83
|
-
crossIcon: string;
|
|
84
|
-
downChevron: string;
|
|
85
|
-
dropdownIndicator: string;
|
|
86
|
-
group: string;
|
|
87
|
-
groupHeading: string;
|
|
88
|
-
indicatorsContainer: string;
|
|
89
|
-
indicatorSeparator: string;
|
|
90
|
-
input: string;
|
|
91
|
-
label: string;
|
|
92
|
-
loadingIndicator: string;
|
|
93
|
-
loadingMessage: string;
|
|
94
|
-
menu: string;
|
|
95
|
-
menuList: string;
|
|
96
|
-
menuPortal: string;
|
|
97
|
-
multiValue: string;
|
|
98
|
-
multiValueContainer: string;
|
|
99
|
-
multiValueLabel: string;
|
|
100
|
-
multiValueRemove: string;
|
|
101
|
-
noOptionsMessage: string;
|
|
102
|
-
option_focused: string;
|
|
103
|
-
option_selected: string;
|
|
104
|
-
option: string;
|
|
105
|
-
placeholder: string;
|
|
106
|
-
selectContainer: string;
|
|
107
|
-
singleValue: string;
|
|
108
|
-
valueContainer: string;
|
|
109
|
-
}, undefined, {
|
|
110
|
-
[key: string]: {
|
|
111
|
-
[key: string]: tailwind_variants182.ClassValue | {
|
|
112
|
-
base?: tailwind_variants182.ClassValue;
|
|
113
|
-
clearIndicator?: tailwind_variants182.ClassValue;
|
|
114
|
-
control?: tailwind_variants182.ClassValue;
|
|
115
|
-
control_focused?: tailwind_variants182.ClassValue;
|
|
116
|
-
crossIcon?: tailwind_variants182.ClassValue;
|
|
117
|
-
downChevron?: tailwind_variants182.ClassValue;
|
|
118
|
-
dropdownIndicator?: tailwind_variants182.ClassValue;
|
|
119
|
-
group?: tailwind_variants182.ClassValue;
|
|
120
|
-
groupHeading?: tailwind_variants182.ClassValue;
|
|
121
|
-
indicatorsContainer?: tailwind_variants182.ClassValue;
|
|
122
|
-
indicatorSeparator?: tailwind_variants182.ClassValue;
|
|
123
|
-
input?: tailwind_variants182.ClassValue;
|
|
124
|
-
label?: tailwind_variants182.ClassValue;
|
|
125
|
-
loadingIndicator?: tailwind_variants182.ClassValue;
|
|
126
|
-
loadingMessage?: tailwind_variants182.ClassValue;
|
|
127
|
-
menu?: tailwind_variants182.ClassValue;
|
|
128
|
-
menuList?: tailwind_variants182.ClassValue;
|
|
129
|
-
menuPortal?: tailwind_variants182.ClassValue;
|
|
130
|
-
multiValue?: tailwind_variants182.ClassValue;
|
|
131
|
-
multiValueContainer?: tailwind_variants182.ClassValue;
|
|
132
|
-
multiValueLabel?: tailwind_variants182.ClassValue;
|
|
133
|
-
multiValueRemove?: tailwind_variants182.ClassValue;
|
|
134
|
-
noOptionsMessage?: tailwind_variants182.ClassValue;
|
|
135
|
-
option_focused?: tailwind_variants182.ClassValue;
|
|
136
|
-
option_selected?: tailwind_variants182.ClassValue;
|
|
137
|
-
option?: tailwind_variants182.ClassValue;
|
|
138
|
-
placeholder?: tailwind_variants182.ClassValue;
|
|
139
|
-
selectContainer?: tailwind_variants182.ClassValue;
|
|
140
|
-
singleValue?: tailwind_variants182.ClassValue;
|
|
141
|
-
valueContainer?: tailwind_variants182.ClassValue;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
} | {}, {
|
|
145
|
-
base: string;
|
|
146
|
-
clearIndicator: string;
|
|
147
|
-
control: string;
|
|
148
|
-
control_focused: string;
|
|
149
|
-
crossIcon: string;
|
|
150
|
-
downChevron: string;
|
|
151
|
-
dropdownIndicator: string;
|
|
152
|
-
group: string;
|
|
153
|
-
groupHeading: string;
|
|
154
|
-
indicatorsContainer: string;
|
|
155
|
-
indicatorSeparator: string;
|
|
156
|
-
input: string;
|
|
157
|
-
label: string;
|
|
158
|
-
loadingIndicator: string;
|
|
159
|
-
loadingMessage: string;
|
|
160
|
-
menu: string;
|
|
161
|
-
menuList: string;
|
|
162
|
-
menuPortal: string;
|
|
163
|
-
multiValue: string;
|
|
164
|
-
multiValueContainer: string;
|
|
165
|
-
multiValueLabel: string;
|
|
166
|
-
multiValueRemove: string;
|
|
167
|
-
noOptionsMessage: string;
|
|
168
|
-
option_focused: string;
|
|
169
|
-
option_selected: string;
|
|
170
|
-
option: string;
|
|
171
|
-
placeholder: string;
|
|
172
|
-
selectContainer: string;
|
|
173
|
-
singleValue: string;
|
|
174
|
-
valueContainer: string;
|
|
175
|
-
}, tailwind_variants182.TVReturnType<unknown, {
|
|
176
|
-
base: string;
|
|
177
|
-
clearIndicator: string;
|
|
178
|
-
control: string;
|
|
179
|
-
control_focused: string;
|
|
180
|
-
crossIcon: string;
|
|
181
|
-
downChevron: string;
|
|
182
|
-
dropdownIndicator: string;
|
|
183
|
-
group: string;
|
|
184
|
-
groupHeading: string;
|
|
185
|
-
indicatorsContainer: string;
|
|
186
|
-
indicatorSeparator: string;
|
|
187
|
-
input: string;
|
|
188
|
-
label: string;
|
|
189
|
-
loadingIndicator: string;
|
|
190
|
-
loadingMessage: string;
|
|
191
|
-
menu: string;
|
|
192
|
-
menuList: string;
|
|
193
|
-
menuPortal: string;
|
|
194
|
-
multiValue: string;
|
|
195
|
-
multiValueContainer: string;
|
|
196
|
-
multiValueLabel: string;
|
|
197
|
-
multiValueRemove: string;
|
|
198
|
-
noOptionsMessage: string;
|
|
199
|
-
option_focused: string;
|
|
200
|
-
option_selected: string;
|
|
201
|
-
option: string;
|
|
202
|
-
placeholder: string;
|
|
203
|
-
selectContainer: string;
|
|
204
|
-
singleValue: string;
|
|
205
|
-
valueContainer: string;
|
|
206
|
-
}, undefined, unknown, unknown, undefined>>;
|
|
207
|
-
interface SelectOption {
|
|
208
|
-
/** option label */
|
|
209
|
-
label?: ReactNode;
|
|
210
|
-
/** option value */
|
|
211
|
-
value: string | number;
|
|
212
|
-
}
|
|
213
|
-
type VariantProps = TVProps<typeof selectVariants>;
|
|
214
|
-
type ClassName = TVClassName<typeof selectVariants>;
|
|
215
|
-
interface SelectProps extends VariantProps {
|
|
216
|
-
/** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */
|
|
217
|
-
ariaLabel?: string;
|
|
218
|
-
/** CSS class name */
|
|
219
|
-
className?: ClassName;
|
|
220
|
-
/** Determine if the */
|
|
221
|
-
clearable?: boolean;
|
|
222
|
-
/** Set the select to disabled state. */
|
|
223
|
-
disabled?: boolean;
|
|
224
|
-
/** Filter Select Options */
|
|
225
|
-
filterOption?: undefined | ((option?: SelectOption, inputValue?: string) => boolean);
|
|
226
|
-
/** Format the label of the option */
|
|
227
|
-
renderOptionLabel?: undefined | Props['formatOptionLabel'];
|
|
228
|
-
/** The value of the search input */
|
|
229
|
-
inputValue?: string;
|
|
230
|
-
/** Label that should be associated with the select. */
|
|
231
|
-
label?: ReactNode;
|
|
232
|
-
/** Set the select to a loading state. */
|
|
233
|
-
loading?: boolean;
|
|
234
|
-
/** switch between single and multi select mode. */
|
|
235
|
-
multiSelect?: boolean;
|
|
236
|
-
/** The name for the Select component, used by react-hook-form */
|
|
237
|
-
name: string;
|
|
238
|
-
/** Placeholder that is displayed when nothing is selected */
|
|
239
|
-
placeholder?: string;
|
|
240
|
-
/** The options for the Select component */
|
|
241
|
-
options: SelectOption[];
|
|
242
|
-
/** Handle change events on the input */
|
|
243
|
-
onInputChange?: Props['onInputChange'];
|
|
244
|
-
/** HTML data-testid attribute used in e2e tests */
|
|
245
|
-
testId?: string;
|
|
246
|
-
}
|
|
247
|
-
/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */
|
|
248
|
-
declare const Select: ({
|
|
249
|
-
className,
|
|
250
|
-
clearable,
|
|
251
|
-
filterOption,
|
|
252
|
-
renderOptionLabel,
|
|
253
|
-
inputValue,
|
|
254
|
-
loading,
|
|
255
|
-
multiSelect,
|
|
256
|
-
name,
|
|
257
|
-
onInputChange,
|
|
258
|
-
options,
|
|
259
|
-
placeholder,
|
|
260
|
-
...uniformFieldProps
|
|
261
|
-
}: SelectProps) => react_jsx_runtime13.JSX.Element;
|
|
262
|
-
//#endregion
|
|
263
|
-
export { SelectProps as n, Select as t };
|
|
264
|
-
//# sourceMappingURL=index-jeFGTign.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-jeFGTign.d.cts","names":[],"sources":["../src/Select/Select.tsx"],"sourcesContent":[],"mappings":";;;;;;;cAea,qCAAc;;mBA0CzB,oBAAA,CAAA,UAAA;;MA1CW,cA0CX,CAAA,iCAAA;MAAA,OAAA,CAAA,iCAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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String","fromNullishString"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\n}\n\n/**\n * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's useController\n * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n // NOTE: We notify with the original value (not formattedValue) so that\n // listeners receive the actual value (false, 0, null) instead of marker\n // strings like '__FALSE__', '__ZERO__', '__NULL__'\n userChange?.notify(field.name, value);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,iBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,kDAAgC,MAAM;CAChE,MAAM,EAAE,qCAA0BA,mCAAe;AAEjD,QAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,IAAI,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAKC,gCAAgB,MAAM;AAGjE,UAAM,SAAS,eAAe;AAQ9B,gBAAY,OAAO,MAAM,MAAM,MAAM;;GAGvC,OAAOC,kCAAkB,MAAM,MAAM;GACtC;EACD;EACA;EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useController-Dleq15tG.js","names":["useController","useRHFController"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\n}\n\n/**\n * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's useController\n * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n // NOTE: We notify with the original value (not formattedValue) so that\n // listeners receive the actual value (false, 0, null) instead of marker\n // strings like '__FALSE__', '__ZERO__', '__NULL__'\n userChange?.notify(field.name, value);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0CA,MAAaA,mBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,eAAeC,cAAiB,MAAM;CAChE,MAAM,EAAE,eAAe,WAAW,eAAe;AAEjD,QAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,IAAI,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAK,gBAAgB,MAAM;AAGjE,UAAM,SAAS,eAAe;AAQ9B,gBAAY,OAAO,MAAM,MAAM,MAAM;;GAGvC,OAAO,kBAAkB,MAAM,MAAM;GACtC;EACD;EACA;EACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-1ELFYX_F.js","names":[],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnC,gBAA8B;AAEhC,iBAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-C1zOvSSU.cjs","names":["useFormContext"],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnCA,uCAA8B;AAEhC,4BAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|