@fuf-stack/uniform 1.17.0 → 1.18.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-BfUtbKe-.js → Checkboxes-BGrK_mwQ.js} +3 -3
- package/dist/{Checkboxes-BfUtbKe-.js.map → Checkboxes-BGrK_mwQ.js.map} +1 -1
- package/dist/{Checkboxes-3Rg0gyfO.cjs → Checkboxes-Dk7yyRVR.cjs} +4 -4
- package/dist/{Checkboxes-3Rg0gyfO.cjs.map → Checkboxes-Dk7yyRVR.cjs.map} +1 -1
- package/dist/FieldArray/index.cjs +1 -1
- package/dist/FieldArray/index.d.cts +1 -1
- package/dist/FieldArray/index.d.ts +1 -1
- package/dist/FieldArray/index.js +1 -1
- package/dist/{FieldArray-BgvSTDWi.cjs → FieldArray-BnZW6fwm.cjs} +7 -7
- package/dist/{FieldArray-BgvSTDWi.cjs.map → FieldArray-BnZW6fwm.cjs.map} +1 -1
- package/dist/{FieldArray-C8Ipn-tM.js → FieldArray-C53ox8yB.js} +6 -6
- package/dist/{FieldArray-C8Ipn-tM.js.map → FieldArray-C53ox8yB.js.map} +1 -1
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/FieldCard/index.d.cts +1 -1
- package/dist/FieldCard/index.d.ts +1 -1
- package/dist/FieldCard/index.js +1 -1
- package/dist/{FieldCard-7XiCb6jZ.js → FieldCard-16yCF83m.js} +6 -5
- package/dist/FieldCard-16yCF83m.js.map +1 -0
- package/dist/{FieldCard-38ZBBWyE.cjs → FieldCard-BxK_IJOR.cjs} +7 -6
- package/dist/FieldCard-BxK_IJOR.cjs.map +1 -0
- package/dist/{FieldCopyTestIdButton-DxJYKqrz.cjs → FieldCopyTestIdButton-4uupFq1U.cjs} +2 -2
- package/dist/{FieldCopyTestIdButton-DxJYKqrz.cjs.map → FieldCopyTestIdButton-4uupFq1U.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-D9f1B-VS.js → FieldCopyTestIdButton-BoEdlzLs.js} +1 -1
- package/dist/{FieldCopyTestIdButton-D9f1B-VS.js.map → FieldCopyTestIdButton-BoEdlzLs.js.map} +1 -1
- package/dist/{FieldValidationError-A384-L3Y.cjs → FieldValidationError-Br6iopZj.cjs} +2 -2
- package/dist/{FieldValidationError-A384-L3Y.cjs.map → FieldValidationError-Br6iopZj.cjs.map} +1 -1
- package/dist/{FieldValidationError-BYwitb_B.js → FieldValidationError-XQaViV52.js} +1 -1
- package/dist/{FieldValidationError-BYwitb_B.js.map → FieldValidationError-XQaViV52.js.map} +1 -1
- package/dist/Form/index.cjs +1 -1
- package/dist/Form/index.d.cts +1 -1
- package/dist/Form/index.d.ts +2 -2
- package/dist/Form/index.js +1 -1
- package/dist/{Form-Ca3RxssB.cjs → Form--SsSvsxl.cjs} +3 -3
- package/dist/{Form-Ca3RxssB.cjs.map → Form--SsSvsxl.cjs.map} +1 -1
- package/dist/{Form-B7bv9fDO.js → Form-ccsEssie.js} +3 -3
- package/dist/{Form-B7bv9fDO.js.map → Form-ccsEssie.js.map} +1 -1
- package/dist/{FormContext-CeFKQmVH.cjs → FormContext-BSLO2-sO.cjs} +3 -3
- package/dist/FormContext-BSLO2-sO.cjs.map +1 -0
- package/dist/{FormContext-C2_WMi_v.d.ts → FormContext-CCe8drkp.d.ts} +1 -1
- package/dist/FormContext-CCe8drkp.d.ts.map +1 -0
- package/dist/{FormContext-Dl7KL_wl.d.cts → FormContext-RSA21aDt.d.cts} +1 -1
- package/dist/FormContext-RSA21aDt.d.cts.map +1 -0
- package/dist/{FormContext-DHYlCZ2u.js → FormContext-kE3YKhp_.js} +3 -3
- package/dist/FormContext-kE3YKhp_.js.map +1 -0
- package/dist/Grid/index.cjs +1 -1
- package/dist/Grid/index.d.cts +1 -1
- package/dist/Grid/index.d.ts +1 -1
- package/dist/Grid/index.js +1 -1
- package/dist/{Grid-CRURvciu.cjs → Grid-CE1fZKmV.cjs} +2 -2
- package/dist/{Grid-CRURvciu.cjs.map → Grid-CE1fZKmV.cjs.map} +1 -1
- package/dist/{Grid-LRjQlZms.js → Grid-CeaybCIF.js} +1 -1
- package/dist/{Grid-LRjQlZms.js.map → Grid-CeaybCIF.js.map} +1 -1
- package/dist/Input/index.cjs +1 -1
- package/dist/Input/index.d.cts +1 -1
- package/dist/Input/index.d.ts +1 -1
- package/dist/Input/index.js +1 -1
- package/dist/{Input-DlyrGFYf.cjs → Input-B3p_4ntD.cjs} +4 -4
- package/dist/{Input-DlyrGFYf.cjs.map → Input-B3p_4ntD.cjs.map} +1 -1
- package/dist/{Input-ChXItabV.js → Input-BCs_eyJ9.js} +3 -3
- package/dist/{Input-ChXItabV.js.map → Input-BCs_eyJ9.js.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-D6ULFGfd.js → RadioBoxes-C3Cwrn2I.js} +3 -3
- package/dist/{RadioBoxes-D6ULFGfd.js.map → RadioBoxes-C3Cwrn2I.js.map} +1 -1
- package/dist/{RadioBoxes-ClDOhQkO.cjs → RadioBoxes-xRvNe5U8.cjs} +4 -4
- package/dist/{RadioBoxes-ClDOhQkO.cjs.map → RadioBoxes-xRvNe5U8.cjs.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-CgB0MmbK.cjs → RadioTabs-BaHvYcd-.cjs} +4 -4
- package/dist/{RadioTabs-CgB0MmbK.cjs.map → RadioTabs-BaHvYcd-.cjs.map} +1 -1
- package/dist/{RadioTabs-eSB6OXD7.js → RadioTabs-DfOGIsEf.js} +3 -3
- package/dist/{RadioTabs-eSB6OXD7.js.map → RadioTabs-DfOGIsEf.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-DWsCLUVl.cjs → Radios-BfA3uL35.cjs} +4 -4
- package/dist/{Radios-DWsCLUVl.cjs.map → Radios-BfA3uL35.cjs.map} +1 -1
- package/dist/{Radios-BXuyREKO.js → Radios-xM-09vB5.js} +3 -3
- package/dist/{Radios-BXuyREKO.js.map → Radios-xM-09vB5.js.map} +1 -1
- package/dist/Select/index.cjs +1 -1
- package/dist/Select/index.d.cts +1 -1
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/{Select-CTbXrAjL.cjs → Select-DH_YaruM.cjs} +5 -5
- package/dist/{Select-CTbXrAjL.cjs.map → Select-DH_YaruM.cjs.map} +1 -1
- package/dist/{Select-Dk_K_Q0F.js → Select-DlEUzYl6.js} +4 -4
- package/dist/{Select-Dk_K_Q0F.js.map → Select-DlEUzYl6.js.map} +1 -1
- 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-ChGkOSJJ.cjs → Slider-C-dMrJZ6.cjs} +3 -3
- package/dist/{Slider-ChGkOSJJ.cjs.map → Slider-C-dMrJZ6.cjs.map} +1 -1
- package/dist/{Slider-DdF0ZBzn.js → Slider-CTFuVrp2.js} +2 -2
- package/dist/{Slider-DdF0ZBzn.js.map → Slider-CTFuVrp2.js.map} +1 -1
- package/dist/SubmitButton/index.cjs +1 -1
- package/dist/SubmitButton/index.d.cts +1 -1
- package/dist/SubmitButton/index.d.ts +1 -1
- package/dist/SubmitButton/index.js +1 -1
- package/dist/{SubmitButton-BrbHJcb4.js → SubmitButton-Bh1RN0F1.js} +2 -2
- package/dist/{SubmitButton-BrbHJcb4.js.map → SubmitButton-Bh1RN0F1.js.map} +1 -1
- package/dist/{SubmitButton-C6sgPR8K.cjs → SubmitButton-CJ6s1mZr.cjs} +3 -3
- package/dist/{SubmitButton-C6sgPR8K.cjs.map → SubmitButton-CJ6s1mZr.cjs.map} +1 -1
- package/dist/Switch/index.cjs +1 -1
- package/dist/Switch/index.d.cts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DW9SOeIv.js → Switch-CXrz-M3V.js} +2 -2
- package/dist/{Switch-DW9SOeIv.js.map → Switch-CXrz-M3V.js.map} +1 -1
- package/dist/{Switch-Lt61rKxf.cjs → Switch-CeUMwheZ.cjs} +3 -3
- package/dist/{Switch-Lt61rKxf.cjs.map → Switch-CeUMwheZ.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-D-EI9Sl-.cjs → SwitchBox-4G_qcERZ.cjs} +3 -3
- package/dist/{SwitchBox-D-EI9Sl-.cjs.map → SwitchBox-4G_qcERZ.cjs.map} +1 -1
- package/dist/{SwitchBox-9KAu4WWd.js → SwitchBox-RfkVRDrE.js} +2 -2
- package/dist/{SwitchBox-9KAu4WWd.js.map → SwitchBox-RfkVRDrE.js.map} +1 -1
- package/dist/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.d.cts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-B0zYpNy-.js → TextArea-BLkVYmHZ.js} +3 -3
- package/dist/{TextArea-B0zYpNy-.js.map → TextArea-BLkVYmHZ.js.map} +1 -1
- package/dist/{TextArea-DRSFdn5v.cjs → TextArea-BYEuk4Ng.cjs} +4 -4
- package/dist/{TextArea-DRSFdn5v.cjs.map → TextArea-BYEuk4Ng.cjs.map} +1 -1
- package/dist/helpers/index.cjs +2 -1
- package/dist/helpers/index.d.cts +39 -1
- package/dist/helpers/index.d.cts.map +1 -1
- package/dist/helpers/index.d.ts +39 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/{helpers-D3A5d3M1.js → helpers-33jajRcN.js} +71 -2
- package/dist/{helpers-D3A5d3M1.js.map → helpers-33jajRcN.js.map} +1 -1
- package/dist/{helpers-CncbgvW_.cjs → helpers-Bd_QpqXg.cjs} +77 -2
- package/dist/{helpers-CncbgvW_.cjs.map → helpers-Bd_QpqXg.cjs.map} +1 -1
- package/dist/hooks/useClientValidation/index.cjs +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +1 -1
- package/dist/hooks/useClientValidation/index.d.ts +1 -1
- package/dist/hooks/useClientValidation/index.js +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useController/index.d.cts +1 -1
- package/dist/hooks/useController/index.d.ts +2 -2
- package/dist/hooks/useController/index.js +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +3 -3
- package/dist/hooks/useFormContext/index.js +1 -1
- package/dist/hooks/useInput/index.cjs +1 -1
- package/dist/hooks/useInput/index.d.cts +1 -1
- package/dist/hooks/useInput/index.d.ts +1 -1
- package/dist/hooks/useInput/index.js +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.cts +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.ts +1 -1
- package/dist/hooks/useInputValueDebounce/index.js +1 -1
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +1 -1
- package/dist/hooks/useInputValueTransform/index.d.ts +1 -1
- package/dist/hooks/useInputValueTransform/index.js +1 -1
- package/dist/hooks/useUniformField/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +5 -5
- 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 +6 -6
- 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-pE9osud2.d.ts → index-ABoI1QMc.d.ts} +1 -1
- package/dist/index-ABoI1QMc.d.ts.map +1 -0
- package/dist/{index-BV_YDI6g.d.ts → index-B0WNiTKF.d.cts} +39 -77
- package/dist/index-B0WNiTKF.d.cts.map +1 -0
- package/dist/{index-BW9EUWZE.d.cts → index-B3DXQvAA.d.cts} +3 -3
- package/dist/index-B3DXQvAA.d.cts.map +1 -0
- package/dist/{index-aHcGnXHf.d.ts → index-BI_rLLgx.d.ts} +4 -4
- package/dist/index-BI_rLLgx.d.ts.map +1 -0
- package/dist/{index-nVYabHcT.d.cts → index-BPc0O2Ds.d.ts} +36 -35
- package/dist/index-BPc0O2Ds.d.ts.map +1 -0
- package/dist/{index-DJbdReTK.d.ts → index-BUbrPNtL.d.ts} +3 -3
- package/dist/index-BUbrPNtL.d.ts.map +1 -0
- package/dist/{index-CUy2EDqc.d.cts → index-B_OYOLtc.d.ts} +40 -78
- package/dist/index-B_OYOLtc.d.ts.map +1 -0
- package/dist/{index-DebErIUS.d.ts → index-BdTKCS0O.d.ts} +48 -48
- package/dist/index-BdTKCS0O.d.ts.map +1 -0
- package/dist/{index-CB00FCyi.d.ts → index-Bi0RH8tW.d.ts} +31 -43
- package/dist/index-Bi0RH8tW.d.ts.map +1 -0
- package/dist/{index-BFLKkqA3.d.ts → index-Box1ZCLh.d.ts} +3 -3
- package/dist/index-Box1ZCLh.d.ts.map +1 -0
- package/dist/{index-CbAh0Kfo.d.cts → index-BuJ4i2G8.d.cts} +3 -3
- package/dist/index-BuJ4i2G8.d.cts.map +1 -0
- package/dist/{index-DjDR6FpI.d.ts → index-BxTjmOVI.d.ts} +36 -36
- package/dist/index-BxTjmOVI.d.ts.map +1 -0
- package/dist/{index-DTURD6sl.d.cts → index-BySLJ5JG.d.ts} +7 -7
- package/dist/index-BySLJ5JG.d.ts.map +1 -0
- package/dist/index-C7t64NIn.d.cts +278 -0
- package/dist/index-C7t64NIn.d.cts.map +1 -0
- package/dist/{index-C3CvgmJw.d.ts → index-CAMcAf2p.d.cts} +4 -4
- package/dist/index-CAMcAf2p.d.cts.map +1 -0
- package/dist/{index-796vjEop.d.ts → index-CDdjrJRs.d.ts} +34 -34
- package/dist/index-CDdjrJRs.d.ts.map +1 -0
- package/dist/index-CELx_Pr_.d.ts +85 -0
- package/dist/index-CELx_Pr_.d.ts.map +1 -0
- package/dist/{index-D3RMbKbP.d.cts → index-CGjAL8dg.d.cts} +36 -36
- package/dist/index-CGjAL8dg.d.cts.map +1 -0
- package/dist/{index-DsyY9X04.d.cts → index-CYMw1FYm.d.cts} +3 -3
- package/dist/index-CYMw1FYm.d.cts.map +1 -0
- package/dist/{index-Cj5CLBt2.d.cts → index-Cbz1wgYP.d.ts} +4 -4
- package/dist/index-Cbz1wgYP.d.ts.map +1 -0
- package/dist/index-ChOoZHFX.d.ts +278 -0
- package/dist/index-ChOoZHFX.d.ts.map +1 -0
- package/dist/{index-Bo79xzb4.d.cts → index-CjbJYNFd.d.cts} +4 -4
- package/dist/index-CjbJYNFd.d.cts.map +1 -0
- package/dist/{index-DxfiwbJb.d.cts → index-CluXcbJV.d.cts} +18 -34
- package/dist/index-CluXcbJV.d.cts.map +1 -0
- package/dist/index-CwtoC1DE.d.cts +85 -0
- package/dist/index-CwtoC1DE.d.cts.map +1 -0
- package/dist/{index-BgXr1v45.d.cts → index-DUbBP1s0.d.cts} +34 -34
- package/dist/index-DUbBP1s0.d.cts.map +1 -0
- package/dist/{index-Cj-PU3Ck.d.ts → index-DWK4jUn6.d.cts} +34 -35
- package/dist/index-DWK4jUn6.d.cts.map +1 -0
- package/dist/{index-B_1td56I.d.ts → index-DYSdHsro.d.cts} +5 -5
- package/dist/index-DYSdHsro.d.cts.map +1 -0
- package/dist/{index-DAeb_8Q4.d.cts → index-Dp-7JoRm.d.cts} +31 -43
- package/dist/index-Dp-7JoRm.d.cts.map +1 -0
- package/dist/{index-Dy0m4FQj.d.ts → index-DrKDlcRp.d.cts} +7 -7
- package/dist/index-DrKDlcRp.d.cts.map +1 -0
- package/dist/{index-BD9y--o2.d.cts → index-MThhiwEy.d.ts} +6 -6
- package/dist/index-MThhiwEy.d.ts.map +1 -0
- package/dist/{index-C4-1V8jn.d.ts → index-Nzma24Py.d.ts} +3 -3
- package/dist/index-Nzma24Py.d.ts.map +1 -0
- package/dist/{index-CrxSEKKb.d.cts → index-RJd0nXDb.d.cts} +48 -48
- package/dist/index-RJd0nXDb.d.cts.map +1 -0
- package/dist/{index-DEJghucW.d.cts → index-SrU5788P.d.cts} +3 -3
- package/dist/index-SrU5788P.d.cts.map +1 -0
- package/dist/{index-gWYaaO6O.d.ts → index-htE4x59X.d.ts} +18 -34
- package/dist/index-htE4x59X.d.ts.map +1 -0
- package/dist/index.cjs +28 -27
- package/dist/index.d.cts +28 -28
- package/dist/index.d.ts +31 -31
- package/dist/index.js +28 -28
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.d.cts +1 -1
- package/dist/partials/FieldValidationError/index.d.ts +1 -1
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/dist/{useClientValidation-C6Daq53C.js → useClientValidation-DksyV18M.js} +3 -3
- package/dist/{useClientValidation-C6Daq53C.js.map → useClientValidation-DksyV18M.js.map} +1 -1
- package/dist/{useClientValidation-DzomULfo.cjs → useClientValidation-Dnj_wuwf.cjs} +4 -4
- package/dist/{useClientValidation-DzomULfo.cjs.map → useClientValidation-Dnj_wuwf.cjs.map} +1 -1
- package/dist/{useClientValidation-Bg0q3Axc.d.ts → useClientValidation-Dw-dmynu.d.cts} +1 -2
- package/dist/useClientValidation-Dw-dmynu.d.cts.map +1 -0
- package/dist/{useClientValidation-BvPDQmf6.d.cts → useClientValidation-DxFgfsEI.d.ts} +1 -2
- package/dist/useClientValidation-DxFgfsEI.d.ts.map +1 -0
- package/dist/{useController-oCYPeezC.cjs → useController-B_SSp5Z5.cjs} +3 -3
- package/dist/{useController-oCYPeezC.cjs.map → useController-B_SSp5Z5.cjs.map} +1 -1
- package/dist/{useController-C6Pg9T_3.d.cts → useController-CvPWE2Sy.d.cts} +1 -1
- package/dist/useController-CvPWE2Sy.d.cts.map +1 -0
- package/dist/{useController-BJ2SBdky.d.ts → useController-DfiNbuEz.d.ts} +1 -1
- package/dist/useController-DfiNbuEz.d.ts.map +1 -0
- package/dist/{useController-QcOl0O0v.js → useController-NjuthTyL.js} +3 -3
- package/dist/{useController-QcOl0O0v.js.map → useController-NjuthTyL.js.map} +1 -1
- package/dist/{useFormContext-B2TS6xq0.d.ts → useFormContext-C6OOtqZ5.d.ts} +18 -18
- package/dist/useFormContext-C6OOtqZ5.d.ts.map +1 -0
- package/dist/{useFormContext-356X5XAY.js → useFormContext-CLymm_7t.js} +1 -1
- package/dist/{useFormContext-356X5XAY.js.map → useFormContext-CLymm_7t.js.map} +1 -1
- package/dist/{useFormContext-n3WYgGkW.d.cts → useFormContext-Dh97YG47.d.cts} +18 -18
- package/dist/useFormContext-Dh97YG47.d.cts.map +1 -0
- package/dist/{useFormContext-UFBqUfOr.js → useFormContext-Di67HIf7.js} +3 -3
- package/dist/{useFormContext-UFBqUfOr.js.map → useFormContext-Di67HIf7.js.map} +1 -1
- package/dist/{useFormContext-DJiJlfGJ.cjs → useFormContext-vdeeDsAs.cjs} +3 -3
- package/dist/{useFormContext-DJiJlfGJ.cjs.map → useFormContext-vdeeDsAs.cjs.map} +1 -1
- package/dist/{useInputValueDebounce-KIKsvSLm.cjs → useInputValueDebounce-CRaM7HEM.cjs} +3 -3
- package/dist/{useInputValueDebounce-KIKsvSLm.cjs.map → useInputValueDebounce-CRaM7HEM.cjs.map} +1 -1
- package/dist/{useInputValueDebounce-D9wArTKz.js → useInputValueDebounce-DJO5uzLb.js} +2 -2
- package/dist/{useInputValueDebounce-D9wArTKz.js.map → useInputValueDebounce-DJO5uzLb.js.map} +1 -1
- package/dist/{useInputValueDebounce-fhmVn1aO.d.ts → useInputValueDebounce-Dhlv1NUY.d.ts} +1 -1
- package/dist/useInputValueDebounce-Dhlv1NUY.d.ts.map +1 -0
- package/dist/{useInputValueDebounce-DI1C6oaU.d.cts → useInputValueDebounce-ZLyAmuXV.d.cts} +1 -1
- package/dist/useInputValueDebounce-ZLyAmuXV.d.cts.map +1 -0
- package/dist/{useInputValueTransform-DuhPVE4L.cjs → useInputValueTransform-BBRvvhDe.cjs} +2 -2
- package/dist/{useInputValueTransform-DuhPVE4L.cjs.map → useInputValueTransform-BBRvvhDe.cjs.map} +1 -1
- package/dist/{useInputValueTransform-CMNC21vX.js → useInputValueTransform-C-fmz3ke.js} +1 -1
- package/dist/{useInputValueTransform-CMNC21vX.js.map → useInputValueTransform-C-fmz3ke.js.map} +1 -1
- package/dist/{useInputValueTransform-BV8o0PMI.d.cts → useInputValueTransform-CNCBU7a9.d.cts} +1 -1
- package/dist/useInputValueTransform-CNCBU7a9.d.cts.map +1 -0
- package/dist/{useInputValueTransform-Cc0qEsnS.d.ts → useInputValueTransform-tsMNM7g_.d.ts} +1 -1
- package/dist/useInputValueTransform-tsMNM7g_.d.ts.map +1 -0
- package/dist/{useUniformField-Dd3AnpgE.cjs → useUniformField-6c4OCAfb.cjs} +9 -29
- package/dist/useUniformField-6c4OCAfb.cjs.map +1 -0
- package/dist/{useUniformField-C6oSAFa3.js → useUniformField-C-Xyu-8v.js} +9 -29
- package/dist/useUniformField-C-Xyu-8v.js.map +1 -0
- package/dist/{useUniformField-CXSaAVTt.d.ts → useUniformField-CqqIJtqo.d.ts} +5 -5
- package/dist/useUniformField-CqqIJtqo.d.ts.map +1 -0
- package/dist/{useUniformField-ETnay_UI.d.cts → useUniformField-DIb__gKK.d.cts} +5 -5
- package/dist/useUniformField-DIb__gKK.d.cts.map +1 -0
- package/dist/{useUniformFieldArray-COtgcAnp.d.ts → useUniformFieldArray-4MOU0xac.d.ts} +14 -14
- package/dist/useUniformFieldArray-4MOU0xac.d.ts.map +1 -0
- package/dist/{useUniformFieldArray-4pUdrWYT.d.cts → useUniformFieldArray-BChcZvc5.d.cts} +14 -14
- package/dist/useUniformFieldArray-BChcZvc5.d.cts.map +1 -0
- package/dist/{useUniformFieldArray-DNrmEXLg.js → useUniformFieldArray-BKvA0FQW.js} +4 -4
- package/dist/{useUniformFieldArray-DNrmEXLg.js.map → useUniformFieldArray-BKvA0FQW.js.map} +1 -1
- package/dist/{useUniformFieldArray-D93AUZI4.cjs → useUniformFieldArray-CRCbV1J2.cjs} +5 -5
- package/dist/{useUniformFieldArray-D93AUZI4.cjs.map → useUniformFieldArray-CRCbV1J2.cjs.map} +1 -1
- package/dist/{useWatchUserChange-jivI5KIB.cjs → useWatchUserChange-C1Kluht2.cjs} +3 -3
- package/dist/{useWatchUserChange-jivI5KIB.cjs.map → useWatchUserChange-C1Kluht2.cjs.map} +1 -1
- package/dist/{useWatchUserChange-DX6gUHvM.d.ts → useWatchUserChange-CYd_8zeN.d.ts} +1 -1
- package/dist/useWatchUserChange-CYd_8zeN.d.ts.map +1 -0
- package/dist/{useWatchUserChange-cI5-j6M4.d.cts → useWatchUserChange-DedTNvGV.d.cts} +1 -1
- package/dist/useWatchUserChange-DedTNvGV.d.cts.map +1 -0
- package/dist/{useWatchUserChange-DyhUYlrN.js → useWatchUserChange-Dj9Imxfi.js} +2 -2
- package/dist/{useWatchUserChange-DyhUYlrN.js.map → useWatchUserChange-Dj9Imxfi.js.map} +1 -1
- package/package.json +8 -8
- package/dist/FieldCard-38ZBBWyE.cjs.map +0 -1
- package/dist/FieldCard-7XiCb6jZ.js.map +0 -1
- package/dist/FormContext-C2_WMi_v.d.ts.map +0 -1
- package/dist/FormContext-CeFKQmVH.cjs.map +0 -1
- package/dist/FormContext-DHYlCZ2u.js.map +0 -1
- package/dist/FormContext-Dl7KL_wl.d.cts.map +0 -1
- package/dist/index-796vjEop.d.ts.map +0 -1
- package/dist/index-B62CWrcm.d.ts +0 -97
- package/dist/index-B62CWrcm.d.ts.map +0 -1
- package/dist/index-BD9y--o2.d.cts.map +0 -1
- package/dist/index-BFLKkqA3.d.ts.map +0 -1
- package/dist/index-BV_YDI6g.d.ts.map +0 -1
- package/dist/index-BW9EUWZE.d.cts.map +0 -1
- package/dist/index-B_1td56I.d.ts.map +0 -1
- package/dist/index-BgXr1v45.d.cts.map +0 -1
- package/dist/index-Bo79xzb4.d.cts.map +0 -1
- package/dist/index-C3CvgmJw.d.ts.map +0 -1
- package/dist/index-C4-1V8jn.d.ts.map +0 -1
- package/dist/index-CB00FCyi.d.ts.map +0 -1
- package/dist/index-COwP53Gx.d.ts +0 -278
- package/dist/index-COwP53Gx.d.ts.map +0 -1
- package/dist/index-CUy2EDqc.d.cts.map +0 -1
- package/dist/index-CbAh0Kfo.d.cts.map +0 -1
- package/dist/index-Cj-PU3Ck.d.ts.map +0 -1
- package/dist/index-Cj5CLBt2.d.cts.map +0 -1
- package/dist/index-CrxSEKKb.d.cts.map +0 -1
- package/dist/index-D3RMbKbP.d.cts.map +0 -1
- package/dist/index-DAeb_8Q4.d.cts.map +0 -1
- package/dist/index-DEJghucW.d.cts.map +0 -1
- package/dist/index-DJbdReTK.d.ts.map +0 -1
- package/dist/index-DTURD6sl.d.cts.map +0 -1
- package/dist/index-DebErIUS.d.ts.map +0 -1
- package/dist/index-DfGCI-K_.d.cts +0 -278
- package/dist/index-DfGCI-K_.d.cts.map +0 -1
- package/dist/index-DjDR6FpI.d.ts.map +0 -1
- package/dist/index-DsyY9X04.d.cts.map +0 -1
- package/dist/index-DxfiwbJb.d.cts.map +0 -1
- package/dist/index-Dy0m4FQj.d.ts.map +0 -1
- package/dist/index-Y8XsRdxS.d.cts +0 -97
- package/dist/index-Y8XsRdxS.d.cts.map +0 -1
- package/dist/index-aHcGnXHf.d.ts.map +0 -1
- package/dist/index-gWYaaO6O.d.ts.map +0 -1
- package/dist/index-nVYabHcT.d.cts.map +0 -1
- package/dist/index-pE9osud2.d.ts.map +0 -1
- package/dist/useClientValidation-Bg0q3Axc.d.ts.map +0 -1
- package/dist/useClientValidation-BvPDQmf6.d.cts.map +0 -1
- package/dist/useController-BJ2SBdky.d.ts.map +0 -1
- package/dist/useController-C6Pg9T_3.d.cts.map +0 -1
- package/dist/useFormContext-B2TS6xq0.d.ts.map +0 -1
- package/dist/useFormContext-n3WYgGkW.d.cts.map +0 -1
- package/dist/useInputValueDebounce-DI1C6oaU.d.cts.map +0 -1
- package/dist/useInputValueDebounce-fhmVn1aO.d.ts.map +0 -1
- package/dist/useInputValueTransform-BV8o0PMI.d.cts.map +0 -1
- package/dist/useInputValueTransform-Cc0qEsnS.d.ts.map +0 -1
- package/dist/useUniformField-C6oSAFa3.js.map +0 -1
- package/dist/useUniformField-CXSaAVTt.d.ts.map +0 -1
- package/dist/useUniformField-Dd3AnpgE.cjs.map +0 -1
- package/dist/useUniformField-ETnay_UI.d.cts.map +0 -1
- package/dist/useUniformFieldArray-4pUdrWYT.d.cts.map +0 -1
- package/dist/useUniformFieldArray-COtgcAnp.d.ts.map +0 -1
- package/dist/useWatchUserChange-DX6gUHvM.d.ts.map +0 -1
- package/dist/useWatchUserChange-cI5-j6M4.d.cts.map +0 -1
- /package/dist/{index-BLREDRDJ.d.cts → index-BMCcWGYS.d.ts} +0 -0
- /package/dist/{index-BRLjimYW.d.ts → index-C8k_zgEm.d.cts} +0 -0
- /package/dist/{index-BYrmFhKl.d.ts → index-D86jXpHS.d.cts} +0 -0
- /package/dist/{index-CFBmva_r.d.ts → index-DDRpa5CJ.d.cts} +0 -0
- /package/dist/{index-DpEKQcoR.d.cts → index-GGHuYh77.d.ts} +0 -0
- /package/dist/{index-lQ_hGQ08.d.cts → index-hIBrhvnj.d.ts} +0 -0
- /package/dist/{useInput--wjwIBc5.d.cts → useInput-BVZvtfNg.d.ts} +0 -0
- /package/dist/{useInput-DZ6KGBxw.js → useInput-BWzvIUpW.js} +0 -0
- /package/dist/{useInput-BCdeYOOg.d.ts → useInput-CKmKH9Ij.d.cts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchBox-
|
|
1
|
+
{"version":3,"file":"SwitchBox-RfkVRDrE.js","names":["SwitchBox"],"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <div>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\nexport { SwitchBox };\n\nexport default SwitchBox;\n"],"mappings":";;;;;;;;AAaA,MAAa,oBAAoB,GAAG;CAClC,OAAO;EACL,KAAK;EACL,aAAa;EACb,MAAM;EACN,OACE;EACF,SAAS;EACT,OAAO;EACP,WAAW;EACZ;CACD,UAAU;EACR,YAAY,EACV,MAAM,EACJ,KAAK,wCACN,EACF;EACD,WAAW,EACT,MAAM;GACJ,KAAK;GACL,OAAO;GACR,EACF;EACD,MAAM;GACJ,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;IACR;GACD,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;IACR;GACD,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;IACR;GACF;EACF;CACD,iBAAiB,EACf,MAAM,MACP;CACF,CAAC;;;;AA8BF,MAAM,aAAa,EACjB,YAAY,QACZ,cAAc,QACd,OAAO,QACP,MACA,OAAO,QACP,YAAY,QACZ,GAAG,wBACiB;CACpB,MAAM,EACJ,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;EACJ,CAAC;CAGF,MAAM,kBAAkB,OAAyB,KAAK;CAGtD,MAAM,EACJ,WACA,OACA,YACA,cACA,eACA,oBACE,UAAU;EACZ,iBAAiB,CAAC,CAAC;EACnB,YAAY;EACZ,YAAY,CAAC,CAAC,MAAM;EACpB,MAAM,GAAG,KAAK;EACd,eAAe;EACf;EACA;EACD,CAAC;CAQF,MAAM,aAAa,qBALF,kBAAkB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CAAC;eAC1D,aAAa,OAAO,cAAc,aAC/B,UAAU;MACR,YAAY,CAAC,CAAC;MACd,WAAW,MAAM,UAAU,EAAE,OAAO,WAAW,WAAW,CAAC;MAC3D,OAAO;MACP,QAAQ;MACR,gBAAgB,aAAa,SAAS;MACvC,CAAC,GACF;MACC;KACF,GACL;;GACM,EACX,UACC,oBAAC;EACC,GAAI,uBAAuB;EAC3B,WAAW,GACT,uBAAuB,EAAE,WAEzB,aACD;YAED,oBAAC;GAAI,GAAI,sBAAsB;aAAG;IAAmB;GACjD,GACJ,QACA;;AAIV,0BAAe;;;;AC3Of,wBAAeA"}
|
package/dist/TextArea/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_TextArea = require('../TextArea-
|
|
2
|
+
const require_TextArea = require('../TextArea-BYEuk4Ng.cjs');
|
|
3
3
|
|
|
4
4
|
exports.TextArea = require_TextArea.TextArea_default$1;
|
|
5
5
|
exports.default = require_TextArea.TextArea_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TextAreaProps, t as TextArea } from "../index-
|
|
1
|
+
import { n as TextAreaProps, t as TextArea } from "../index-CwtoC1DE.cjs";
|
|
2
2
|
export { TextArea, TextArea as default, TextAreaProps };
|
package/dist/TextArea/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TextAreaProps, t as TextArea } from "../index-
|
|
1
|
+
import { n as TextAreaProps, t as TextArea } from "../index-CELx_Pr_.js";
|
|
2
2
|
export { TextArea, TextArea as default, TextAreaProps };
|
package/dist/TextArea/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as useUniformField } from "./useUniformField-
|
|
2
|
-
import { t as useInputValueDebounce } from "./useInputValueDebounce-
|
|
1
|
+
import { t as useUniformField } from "./useUniformField-C-Xyu-8v.js";
|
|
2
|
+
import { t as useInputValueDebounce } from "./useInputValueDebounce-DJO5uzLb.js";
|
|
3
3
|
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Textarea } from "@heroui/input";
|
|
@@ -62,4 +62,4 @@ var TextArea_default = TextArea_default$1;
|
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
64
|
export { TextArea_default$1 as n, TextArea_default as t };
|
|
65
|
-
//# sourceMappingURL=TextArea-
|
|
65
|
+
//# sourceMappingURL=TextArea-BLkVYmHZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea-
|
|
1
|
+
{"version":3,"file":"TextArea-BLkVYmHZ.js","names":["HeroTextArea","TextArea"],"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const textAreaVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof textAreaVariants>;\ntype ClassName = TVClassName<typeof textAreaVariants>;\n\nexport interface TextAreaProps 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 /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className: _className = undefined,\n debounceDelay = 300,\n name,\n placeholder = ' ',\n ...uniformFieldProps\n}: TextAreaProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use debounced handlers for form updates\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // classNames from slots\n const variants = textAreaVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroTextArea\n ref={ref}\n data-testid={testId}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n value={value}\n variant=\"bordered\"\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n aria-label={\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined\n }\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"],"mappings":";;;;;;;AAWA,MAAa,mBAAmB,GAAG,EACjC,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AA6BF,MAAM,YAAY,EAChB,WAAW,MACX,WAAW,aAAa,QACxB,gBAAgB,KAChB,MACA,cAAc,KACd,GAAG,wBACgB;CACnB,MAAM,EACJ,WACA,UACA,cACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,SACA,OACA,UACA,WACE,gBAAgB;EAAE;EAAM,GAAG;EAAmB,CAAC;CAGnD,MAAM,EAAE,UAAU,QAAQ,UAAU,sBAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAIF,MAAM,aAAa,qBADF,kBAAkB,EACe,YAAY,OAAO;AAErE,QACE,oBAACA;EACM;EACL,eAAa;EACC;EACd,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACL;EACP,gBAAe;EACT;EACE;EACE;EACG;EACN;EACP,SAAQ;EAER,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EAEA;GACY;;AAInB,yBAAe;;;;ACrHf,uBAAeC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
2
|
-
const require_useUniformField = require('./useUniformField-
|
|
3
|
-
const require_useInputValueDebounce = require('./useInputValueDebounce-
|
|
1
|
+
const require_FormContext = require('./FormContext-BSLO2-sO.cjs');
|
|
2
|
+
const require_useUniformField = require('./useUniformField-6c4OCAfb.cjs');
|
|
3
|
+
const require_useInputValueDebounce = require('./useInputValueDebounce-CRaM7HEM.cjs');
|
|
4
4
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let _heroui_input = require("@heroui/input");
|
|
@@ -74,4 +74,4 @@ Object.defineProperty(exports, 'TextArea_default$1', {
|
|
|
74
74
|
return TextArea_default$1;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
//# sourceMappingURL=TextArea-
|
|
77
|
+
//# sourceMappingURL=TextArea-BYEuk4Ng.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea-
|
|
1
|
+
{"version":3,"file":"TextArea-BYEuk4Ng.cjs","names":["useUniformField","useInputValueDebounce","HeroTextArea","TextArea"],"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const textAreaVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof textAreaVariants>;\ntype ClassName = TVClassName<typeof textAreaVariants>;\n\nexport interface TextAreaProps 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 /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className: _className = undefined,\n debounceDelay = 300,\n name,\n placeholder = ' ',\n ...uniformFieldProps\n}: TextAreaProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use debounced handlers for form updates\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // classNames from slots\n const variants = textAreaVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroTextArea\n ref={ref}\n data-testid={testId}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n value={value}\n variant=\"bordered\"\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n aria-label={\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined\n }\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"],"mappings":";;;;;;;;AAWA,MAAa,kDAAsB,EACjC,OAAO;CAEL,MAAM;CAEN,aAAa;CAEb,OAAO;CAEP,cAAc;CACf,EACF,CAAC;;;;AA6BF,MAAM,YAAY,EAChB,WAAW,MACX,WAAW,aAAa,QACxB,gBAAgB,KAChB,MACA,cAAc,KACd,GAAG,wBACgB;CACnB,MAAM,EACJ,WACA,UACA,cACA,OAAO,EACL,UAAU,eACV,QAAQ,aACR,OAAO,YACP,OAEF,SACA,OACA,UACA,WACEA,wCAAgB;EAAE;EAAM,GAAG;EAAmB,CAAC;CAGnD,MAAM,EAAE,UAAU,QAAQ,UAAUC,oDAAsB;EACxD;EACA;EACA,QAAQ;EACR,UAAU;EACV,OAAO;EACR,CAAC;CAIF,MAAM,8DADW,kBAAkB,EACe,YAAY,OAAO;AAErE,QACE,2CAACC;EACM;EACL,eAAa;EACC;EACd,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACL;EACP,gBAAe;EACT;EACE;EACE;EACG;EACN;EACP,SAAQ;EAER,cACE,CAAC,eAAe,YAAY,MAAM,KAAK,KAAK,YAAY;EAE1D,YAAY;GACV,MAAM,WAAW;GACjB,aAAa,WAAW;GAExB,eAAe;GACf,OAAO,WAAW;GAClB,cAAc,WAAW;GAC1B;EAEA;GACY;;AAInB,yBAAe;;;;ACrHf,uBAAeC"}
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_helpers = require('../helpers-
|
|
1
|
+
const require_helpers = require('../helpers-Bd_QpqXg.cjs');
|
|
2
2
|
|
|
3
3
|
exports.createOptionValueConverter = require_helpers.createOptionValueConverter;
|
|
4
4
|
exports.flatArrayKey = require_helpers.flatArrayKey;
|
|
@@ -7,4 +7,5 @@ exports.isValueEmpty = require_helpers.isValueEmpty;
|
|
|
7
7
|
exports.nameToTestId = require_helpers.nameToTestId;
|
|
8
8
|
exports.toFormFormat = require_helpers.toFormFormat;
|
|
9
9
|
exports.toNullishString = require_helpers.toNullishString;
|
|
10
|
+
exports.toSubmitFormat = require_helpers.toSubmitFormat;
|
|
10
11
|
exports.toValidationFormat = require_helpers.toValidationFormat;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -161,6 +161,44 @@ declare const toFormFormat: (fields: Record<string, unknown>) => Record<string,
|
|
|
161
161
|
* }
|
|
162
162
|
*/
|
|
163
163
|
declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Converts form state to a format suitable for submission by:
|
|
166
|
+
* - Applying all transformations from toValidationFormat
|
|
167
|
+
* - Additionally removing empty objects from the result
|
|
168
|
+
* - Filtering empty objects from arrays
|
|
169
|
+
* - Recursively cleaning nested structures
|
|
170
|
+
*
|
|
171
|
+
* **Why separate from toValidationFormat?**
|
|
172
|
+
*
|
|
173
|
+
* Empty objects must be preserved during validation so that custom refinements
|
|
174
|
+
* can run. For example, a FieldCard with "at least email or phone required"
|
|
175
|
+
* validation needs the object to exist (even if empty) for the refine to execute.
|
|
176
|
+
*
|
|
177
|
+
* However, for submission, empty objects are meaningless and should be removed
|
|
178
|
+
* to produce clean data for APIs.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* const formState = {
|
|
182
|
+
* name: 'John',
|
|
183
|
+
* contact: {}, // Empty FieldCard - will be removed
|
|
184
|
+
* tags: [{}, {}, {}], // All empty - array will be removed
|
|
185
|
+
* items: [
|
|
186
|
+
* { value: 'a' },
|
|
187
|
+
* {}, // Empty entry - will be filtered out
|
|
188
|
+
* { value: 'b' }
|
|
189
|
+
* ],
|
|
190
|
+
* nested: {
|
|
191
|
+
* deep: {} // Nested empty - will be removed recursively
|
|
192
|
+
* }
|
|
193
|
+
* };
|
|
194
|
+
*
|
|
195
|
+
* // Result:
|
|
196
|
+
* {
|
|
197
|
+
* name: 'John',
|
|
198
|
+
* items: [{ value: 'a' }, { value: 'b' }]
|
|
199
|
+
* }
|
|
200
|
+
*/
|
|
201
|
+
declare const toSubmitFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
|
|
164
202
|
/**
|
|
165
203
|
* Converts a field name to a testId by removing flat array key segments and slugifying.
|
|
166
204
|
* Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
|
|
@@ -182,5 +220,5 @@ declare const toValidationFormat: (formState: Record<string, unknown> | null | u
|
|
|
182
220
|
*/
|
|
183
221
|
declare const nameToTestId: (name: string | readonly string[]) => string;
|
|
184
222
|
//#endregion
|
|
185
|
-
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toValidationFormat };
|
|
223
|
+
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
|
|
186
224
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../../src/helpers/nullishFields/nullishFields.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../../src/helpers/nullishFields/nullishFields.ts"],"mappings":";;AAeA;;;;;;;;;;;;cAAa,0BAAA;EACC,KAAA;AAAA,GAEZ,OAAA,EAAS,CAAA;;;;;;;;cCfE,YAAA;;;;;;;;;;;;;;;;;;;;;;;AAAb;;;;;AAsCA;;cAAa,YAAA,GAAgB,KAAA;;;AA0B7B;cAAa,iBAAA,GAAqB,KAAA;;;;cAsCrB,eAAA,GAAmB,KAAA;;;;;AA6EhC;;;;;;;;;AA2EA;;;;;;;;;AAyKA;;;;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;cAjRa,YAAA,GAAgB,MAAA,EAAQ,MAAA,sBAwBE,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmD1B,kBAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuKU,cAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAA;;;;;;;;;;;;;;;;;;;;cA2BU,YAAA,GAAgB,IAAA"}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -161,6 +161,44 @@ declare const toFormFormat: (fields: Record<string, unknown>) => Record<string,
|
|
|
161
161
|
* }
|
|
162
162
|
*/
|
|
163
163
|
declare const toValidationFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Converts form state to a format suitable for submission by:
|
|
166
|
+
* - Applying all transformations from toValidationFormat
|
|
167
|
+
* - Additionally removing empty objects from the result
|
|
168
|
+
* - Filtering empty objects from arrays
|
|
169
|
+
* - Recursively cleaning nested structures
|
|
170
|
+
*
|
|
171
|
+
* **Why separate from toValidationFormat?**
|
|
172
|
+
*
|
|
173
|
+
* Empty objects must be preserved during validation so that custom refinements
|
|
174
|
+
* can run. For example, a FieldCard with "at least email or phone required"
|
|
175
|
+
* validation needs the object to exist (even if empty) for the refine to execute.
|
|
176
|
+
*
|
|
177
|
+
* However, for submission, empty objects are meaningless and should be removed
|
|
178
|
+
* to produce clean data for APIs.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* const formState = {
|
|
182
|
+
* name: 'John',
|
|
183
|
+
* contact: {}, // Empty FieldCard - will be removed
|
|
184
|
+
* tags: [{}, {}, {}], // All empty - array will be removed
|
|
185
|
+
* items: [
|
|
186
|
+
* { value: 'a' },
|
|
187
|
+
* {}, // Empty entry - will be filtered out
|
|
188
|
+
* { value: 'b' }
|
|
189
|
+
* ],
|
|
190
|
+
* nested: {
|
|
191
|
+
* deep: {} // Nested empty - will be removed recursively
|
|
192
|
+
* }
|
|
193
|
+
* };
|
|
194
|
+
*
|
|
195
|
+
* // Result:
|
|
196
|
+
* {
|
|
197
|
+
* name: 'John',
|
|
198
|
+
* items: [{ value: 'a' }, { value: 'b' }]
|
|
199
|
+
* }
|
|
200
|
+
*/
|
|
201
|
+
declare const toSubmitFormat: (formState: Record<string, unknown> | null | undefined) => Record<string, unknown> | null | undefined;
|
|
164
202
|
/**
|
|
165
203
|
* Converts a field name to a testId by removing flat array key segments and slugifying.
|
|
166
204
|
* Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
|
|
@@ -182,5 +220,5 @@ declare const toValidationFormat: (formState: Record<string, unknown> | null | u
|
|
|
182
220
|
*/
|
|
183
221
|
declare const nameToTestId: (name: string | readonly string[]) => string;
|
|
184
222
|
//#endregion
|
|
185
|
-
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toValidationFormat };
|
|
223
|
+
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
|
|
186
224
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../../src/helpers/nullishFields/nullishFields.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../../src/helpers/nullishFields/nullishFields.ts"],"mappings":";;AAeA;;;;;;;;;;;;cAAa,0BAAA;EACC,KAAA;AAAA,GAEZ,OAAA,EAAS,CAAA;;;;;;;;cCfE,YAAA;;;;;;;;;;;;;;;;;;;;;;;AAAb;;;;;AAsCA;;cAAa,YAAA,GAAgB,KAAA;;;AA0B7B;cAAa,iBAAA,GAAqB,KAAA;;;;cAsCrB,eAAA,GAAmB,KAAA;;;;;AA6EhC;;;;;;;;;AA2EA;;;;;;;;;AAyKA;;;;;;;;;AA6BA;;;;;;;;;;;;;;;;;;;cAjRa,YAAA,GAAgB,MAAA,EAAQ,MAAA,sBAwBE,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmD1B,kBAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuKU,cAAA,GACX,SAAA,EAAW,MAAA,yCACV,MAAA;;;;;;;;;;;;;;;;;;;;cA2BU,YAAA,GAAgB,IAAA"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as toFormFormat, c as
|
|
1
|
+
import { a as toFormFormat, c as toValidationFormat, i as nameToTestId, l as createOptionValueConverter, n as fromNullishString, o as toNullishString, r as isValueEmpty, s as toSubmitFormat, t as flatArrayKey } from "../helpers-33jajRcN.js";
|
|
2
2
|
|
|
3
|
-
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toValidationFormat };
|
|
3
|
+
export { createOptionValueConverter, flatArrayKey, fromNullishString, isValueEmpty, nameToTestId, toFormFormat, toNullishString, toSubmitFormat, toValidationFormat };
|
|
@@ -287,6 +287,75 @@ const toValidationFormat = (formState) => {
|
|
|
287
287
|
return JSON.parse(validationFormatJson);
|
|
288
288
|
};
|
|
289
289
|
/**
|
|
290
|
+
* Helper function to check if a value is an empty object (not an array).
|
|
291
|
+
*/
|
|
292
|
+
const isEmptyObject = (value) => {
|
|
293
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Recursively removes empty objects from a data structure.
|
|
297
|
+
* - Filters empty objects from arrays
|
|
298
|
+
* - Removes properties with empty object values
|
|
299
|
+
* - Removes arrays that become empty after filtering
|
|
300
|
+
*/
|
|
301
|
+
const removeEmptyObjects = (obj) => {
|
|
302
|
+
if (Array.isArray(obj)) return obj.filter((item) => {
|
|
303
|
+
return !isEmptyObject(item);
|
|
304
|
+
}).map((item) => {
|
|
305
|
+
return removeEmptyObjects(item);
|
|
306
|
+
});
|
|
307
|
+
if (obj !== null && typeof obj === "object") return Object.fromEntries(Object.entries(obj).map(([key, value]) => {
|
|
308
|
+
return [key, removeEmptyObjects(value)];
|
|
309
|
+
}).filter(([_, processed]) => {
|
|
310
|
+
if (isEmptyObject(processed)) return false;
|
|
311
|
+
if (Array.isArray(processed) && processed.length === 0) return false;
|
|
312
|
+
return true;
|
|
313
|
+
}));
|
|
314
|
+
return obj;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Converts form state to a format suitable for submission by:
|
|
318
|
+
* - Applying all transformations from toValidationFormat
|
|
319
|
+
* - Additionally removing empty objects from the result
|
|
320
|
+
* - Filtering empty objects from arrays
|
|
321
|
+
* - Recursively cleaning nested structures
|
|
322
|
+
*
|
|
323
|
+
* **Why separate from toValidationFormat?**
|
|
324
|
+
*
|
|
325
|
+
* Empty objects must be preserved during validation so that custom refinements
|
|
326
|
+
* can run. For example, a FieldCard with "at least email or phone required"
|
|
327
|
+
* validation needs the object to exist (even if empty) for the refine to execute.
|
|
328
|
+
*
|
|
329
|
+
* However, for submission, empty objects are meaningless and should be removed
|
|
330
|
+
* to produce clean data for APIs.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* const formState = {
|
|
334
|
+
* name: 'John',
|
|
335
|
+
* contact: {}, // Empty FieldCard - will be removed
|
|
336
|
+
* tags: [{}, {}, {}], // All empty - array will be removed
|
|
337
|
+
* items: [
|
|
338
|
+
* { value: 'a' },
|
|
339
|
+
* {}, // Empty entry - will be filtered out
|
|
340
|
+
* { value: 'b' }
|
|
341
|
+
* ],
|
|
342
|
+
* nested: {
|
|
343
|
+
* deep: {} // Nested empty - will be removed recursively
|
|
344
|
+
* }
|
|
345
|
+
* };
|
|
346
|
+
*
|
|
347
|
+
* // Result:
|
|
348
|
+
* {
|
|
349
|
+
* name: 'John',
|
|
350
|
+
* items: [{ value: 'a' }, { value: 'b' }]
|
|
351
|
+
* }
|
|
352
|
+
*/
|
|
353
|
+
const toSubmitFormat = (formState) => {
|
|
354
|
+
const validated = toValidationFormat(formState);
|
|
355
|
+
if (!validated) return validated;
|
|
356
|
+
return removeEmptyObjects(validated);
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
290
359
|
* Converts a field name to a testId by removing flat array key segments and slugifying.
|
|
291
360
|
* Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
|
|
292
361
|
*
|
|
@@ -317,5 +386,5 @@ const nameToTestId = (name) => {
|
|
|
317
386
|
};
|
|
318
387
|
|
|
319
388
|
//#endregion
|
|
320
|
-
export { toFormFormat as a,
|
|
321
|
-
//# sourceMappingURL=helpers-
|
|
389
|
+
export { toFormFormat as a, toValidationFormat as c, nameToTestId as i, createOptionValueConverter as l, fromNullishString as n, toNullishString as o, isValueEmpty as r, toSubmitFormat as s, flatArrayKey as t };
|
|
390
|
+
//# sourceMappingURL=helpers-33jajRcN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-D3A5d3M1.js","names":[],"sources":["../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../src/helpers/nullishFields/nullishFields.ts"],"sourcesContent":["/* eslint-disable import-x/prefer-default-export */\n\n/**\n * Creates a converter function that preserves the original type (string, number, or boolean)\n * of option values when converting from string keys back to their original type.\n *\n * This is useful for radio/select components where the underlying UI library\n * uses string keys internally, but we want to preserve number/boolean values in the form state.\n *\n * @param options - Array of options with a value property that can be string, number, or boolean\n * @returns An object with:\n * - `convertToOriginalType`: Function to convert a string key back to its original type\n * - `numberValueKeys`: Set of string representations of number values (for internal use)\n * - `booleanValueKeys`: Map of string representations to boolean values (for internal use)\n */\nexport const createOptionValueConverter = <\n T extends { value: string | number | boolean },\n>(\n options: T[],\n) => {\n // Create a set of string keys that represent number values\n const numberValueKeys = new Set(\n options\n .filter((option) => {\n return typeof option.value === 'number';\n })\n .map((option) => {\n return String(option.value);\n }),\n );\n\n // Create a map of string keys to boolean values\n const booleanValueKeys = new Map(\n options\n .filter((option) => {\n return typeof option.value === 'boolean';\n })\n .map((option) => {\n return [String(option.value), option.value as boolean];\n }),\n );\n\n /**\n * Converts a string key back to its original type (string, number, or boolean)\n * based on whether the original option value was a number or boolean\n */\n const convertToOriginalType = (\n key: string | number | boolean,\n ): string | number | boolean => {\n const keyStr = String(key);\n const booleanValue = booleanValueKeys.get(keyStr);\n if (booleanValue !== undefined) {\n return booleanValue;\n }\n if (numberValueKeys.has(keyStr)) {\n return Number(keyStr);\n }\n return keyStr;\n };\n\n return {\n booleanValueKeys,\n convertToOriginalType,\n numberValueKeys,\n };\n};\n","import { slugify } from '@fuf-stack/pixel-utils';\n\n/** Key used to wrap flat array elements when converting to form format */\nexport const flatArrayKey = '__FLAT__';\n\n/**\n * String markers used to preserve null, false, and 0 values during JSON processing\n */\nconst nullString = '__NULL__';\nconst falseString = '__FALSE__';\nconst zeroString = '__ZERO__';\n\n/**\n * Checks if a value is considered \"empty\" for validation display purposes.\n *\n * Used by useUniformField to determine when to show validation errors.\n * Empty values don't trigger immediate error display (user must interact first).\n *\n * Handles:\n * - Primitives: null, undefined, ''\n * - Marker strings: __NULL__, __FALSE__, __ZERO__ (converted via fromNullishString)\n * - Empty arrays: []\n * - Objects with all empty values: {a: null, b: ''}\n * - Flat array wrappers: {__FLAT__: null} or {__FLAT__: ''}\n *\n * @param value - The value to check (will be converted via fromNullishString first)\n * @returns true if the value is empty\n *\n * @example\n * isValueEmpty(null) // true\n * isValueEmpty('') // true\n * isValueEmpty('__NULL__') // true (marker string)\n * isValueEmpty([]) // true (empty array)\n * isValueEmpty({a: null}) // true (object with all empty values)\n * isValueEmpty({__FLAT__: null}) // true (flat array wrapper with empty value)\n * isValueEmpty({__FLAT__: ''}) // true\n * isValueEmpty('hello') // false\n * isValueEmpty([1, 2]) // false\n * isValueEmpty({a: 'value'}) // false\n * isValueEmpty({__FLAT__: 'value'}) // false\n */\nexport const isValueEmpty = (value: unknown): boolean => {\n // Convert marker strings first\n const converted = fromNullishString(value);\n\n if (converted === undefined || converted === null || converted === '') {\n return true;\n }\n if (Array.isArray(converted)) {\n return converted.length === 0;\n }\n if (typeof converted === 'object' && converted !== null) {\n const record = converted as Record<string, unknown>;\n // Handle flat array wrapper: { __FLAT__: innerValue }\n if (flatArrayKey in record) {\n return isValueEmpty(record[flatArrayKey]);\n }\n // For objects (e.g., FieldCard), check if all values are null/undefined/empty\n const values = Object.values(record);\n return values.length === 0 || values.every(isValueEmpty);\n }\n return false;\n};\n\n/**\n * Converts marker strings back to their original values when processing arrays\n */\nexport const fromNullishString = (value: unknown): unknown => {\n // Support arrays: unwrap flat wrappers and convert marker strings per entry\n if (Array.isArray(value)) {\n return (value as unknown[]).map((entry) => {\n if (entry && typeof entry === 'object') {\n const record = entry as Record<string, unknown>;\n if (flatArrayKey in record) {\n const inner = record[flatArrayKey];\n // For arrays, treat empty string as null (placeholder input)\n if (inner === '') {\n return null;\n }\n return fromNullishString(inner);\n }\n }\n return fromNullishString(entry);\n });\n }\n\n if (typeof value !== 'string') {\n return value;\n }\n\n switch (value) {\n case nullString:\n return null;\n case falseString:\n return false;\n case zeroString:\n return 0;\n default:\n return value;\n }\n};\n\n/**\n * Converts null/falsy values to marker strings for JSON processing\n */\nexport const toNullishString = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n // Only wrap arrays of primitives; leave arrays of objects as-is\n const isPrimitive = (v: unknown) => {\n return v === null || ['string', 'number', 'boolean'].includes(typeof v);\n };\n const isPrimitiveArray = (value as unknown[]).every(isPrimitive);\n if (isPrimitiveArray) {\n return (value as unknown[]).map((v) => {\n // Store raw primitive; do not convert to marker strings inside the wrapper\n return { [flatArrayKey]: v } as Record<string, unknown>;\n });\n }\n return value;\n }\n if (value === null || value === '') {\n return nullString;\n }\n if (value === false) {\n return falseString;\n }\n if (value === 0) {\n return zeroString;\n }\n return value;\n};\n\n/**\n * Converts field values to a format suitable for forms by:\n * - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`\n * to satisfy RHF's requirement that array fields contain objects\n * - Removing empty strings and null values from objects\n *\n * This conversion is required because React Hook Form does not support arrays with\n * flat values (string, number, boolean, null). Array fields must contain objects.\n * We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.\n *\n * @example\n * const fields = {\n * name: 'John',\n * scores: [0, null, 75, false],\n * scoresDetailed: [\n * { score: 1 },\n * { score: null },\n * { score: 0 },\n * { score: false },\n * { score: '' },\n * ],\n * contact: {\n * email: '',\n * phone: null,\n * address: '123 Main St'\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: [\n * { __FLAT__: 0 },\n * { __FLAT__: null },\n * { __FLAT__: 75 },\n * { __FLAT__: false }\n * ],\n * // Arrays of objects are left as objects; empty/null properties are removed\n * scoresDetailed: [\n * { score: 1 },\n * {}, // null score removed\n * { score: 0 },\n * { score: false },\n * {}, // empty string removed\n * ],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toFormFormat = (fields: Record<string, unknown>) => {\n const formFormatJson = JSON.stringify(fields, (_, value) => {\n if (Array.isArray(value)) {\n // Delegate to toNullishString to ensure consistent handling\n return toNullishString(value);\n }\n\n if (value && typeof value === 'object') {\n // Preserve flat-array wrappers as-is (do not filter their inner values here)\n const record = value as Record<string, unknown>;\n if (flatArrayKey in record) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n return Object.fromEntries(\n Object.entries(value).filter(([_key, v]) => {\n return v !== '' && v !== null;\n }),\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n\n return JSON.parse(formFormatJson) as Record<string, unknown>;\n};\n\n/**\n * Converts form state to a format suitable for validation by:\n * - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives\n * - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values\n * - Removing fields whose converted value is empty string or null\n * - Removing empty arrays\n *\n * @example\n * const formState = {\n * name: 'John',\n * scores: [\n * { __FLAT__: 75 },\n * { __FLAT__: 0 },\n * { __FLAT__: null },\n * { __FLAT__: false }\n * ],\n * emptyArray: [],\n * scoresDetailed: [\n * { score: 1 },\n * {},\n * { score: 0 },\n * { score: false },\n * {},\n * ],\n * contact: {\n * address: '123 Main St',\n * fax: null\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: [75, 0, null, false],\n * // emptyArray is removed\n * // Objects inside arrays remain objects; empty entries remain empty objects\n * scoresDetailed: [\n * { score: 1 },\n * {},\n * { score: 0 },\n * { score: false },\n * {},\n * ],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toValidationFormat = (\n formState: Record<string, unknown> | null | undefined,\n): Record<string, unknown> | null | undefined => {\n // Handle null or undefined input\n if (formState === undefined || formState === null) {\n return formState;\n }\n\n const validationFormatJson = JSON.stringify(formState, (_, value) => {\n if (Array.isArray(value)) {\n return value.map((v) => {\n // Unwrap new wrapper format { __FLAT__: <value> }\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n const inner = record[flatArrayKey];\n // Treat empty string from forms as null in validation format\n if (inner === '') {\n return null;\n }\n return fromNullishString(inner);\n }\n }\n // Backward compatibility for string markers\n return fromNullishString(v);\n });\n }\n\n if (value && typeof value === 'object') {\n // Object branch: remove keys that resolve to empty/null after marker conversion\n // and unwrap flat-array wrappers if present.\n //\n // Why this shape?\n // - Forms may contain objects with placeholder/empty values that should not\n // be part of the validation payload (e.g. \"\" or __NULL__ markers).\n // - Arrays of primitives are stored as wrapper objects { __FLAT__: <value> }\n // to satisfy RHF structure constraints. When converting back for\n // validation, we need to treat wrappers whose inner value resolves to\n // empty/null as removable, and unwrap non-empty wrappers to the primitive.\n return Object.fromEntries(\n Object.entries(value)\n .filter(([_key, v]) => {\n // If this is a flat-array wrapper, convert the inner value first and\n // drop the key when the inner resolves to empty string or null.\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n const convertedInner = fromNullishString(record[flatArrayKey]);\n return convertedInner !== '' && convertedInner !== null;\n }\n }\n // Drop empty arrays\n if (Array.isArray(v) && v.length === 0) {\n return false;\n }\n // For regular values, convert markers and drop when empty/null.\n const converted = fromNullishString(v);\n return converted !== '' && converted !== null;\n })\n .map(([k, v]) => {\n // Unwrap flat-array wrappers to raw primitives after conversion.\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n return [k, fromNullishString(record[flatArrayKey])];\n }\n }\n // For other values, just convert markers.\n return [k, fromNullishString(v)];\n }),\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n\n return JSON.parse(validationFormatJson) as Record<string, unknown>;\n};\n\n/**\n * Converts a field name to a testId by removing flat array key segments and slugifying.\n * Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.\n *\n * This is used to generate stable testIds for form fields that don't include\n * the internal `__FLAT__` marker used for flat arrays.\n *\n * @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])\n * @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')\n *\n * @example\n * ```ts\n * nameToTestId('tags.0.__FLAT__') // => 'tags_0'\n * nameToTestId('array.0.__FLAT__') // => 'array_0'\n * nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'\n * nameToTestId('simple.field') // => 'simple_field'\n * nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'\n * ```\n */\nexport const nameToTestId = (name: string | readonly string[]): string => {\n let cleanName: string;\n\n // Handle array paths - filter out flatArrayKey and join with dots\n if (Array.isArray(name)) {\n cleanName = name\n .filter((segment: string) => {\n return segment !== flatArrayKey;\n })\n .join('.');\n } else {\n // Handle string paths - split by dots and filter out flatArrayKey segments\n const segments = (name as string).split('.');\n cleanName = segments\n .filter((segment: string) => {\n return segment !== flatArrayKey;\n })\n .join('.');\n }\n\n // Apply slugify transformation\n return slugify(cleanName, { replaceDots: true });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,8BAGX,YACG;CAEH,MAAM,kBAAkB,IAAI,IAC1B,QACG,QAAQ,WAAW;AAClB,SAAO,OAAO,OAAO,UAAU;GAC/B,CACD,KAAK,WAAW;AACf,SAAO,OAAO,OAAO,MAAM;GAC3B,CACL;CAGD,MAAM,mBAAmB,IAAI,IAC3B,QACG,QAAQ,WAAW;AAClB,S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,QAAQ,OAAO;AAErB,SAAI,UAAU,GACZ,QAAO;AAET,YAAO,kBAAkB,MAAM;;;AAInC,UAAO,kBAAkB,EAAE;IAC3B;AAGJ,MAAI,SAAS,OAAO,UAAU,SAW5B,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,MAAM,OAAO;AAGrB,OAAI,KAAK,OAAO,MAAM,UAAU;IAC9B,MAAM,SAAS;AACf,QAAI,gBAAgB,QAAQ;KAC1B,MAAM,iBAAiB,kBAAkB,OAAO,cAAc;AAC9D,YAAO,mBAAmB,MAAM,mBAAmB;;;AAIvD,OAAI,MAAM,QAAQ,EAAE,IAAI,EAAE,WAAW,EACnC,QAAO;GAGT,MAAM,YAAY,kBAAkB,EAAE;AACtC,UAAO,cAAc,MAAM,cAAc;IACzC,CACD,KAAK,CAAC,GAAG,OAAO;AAEf,OAAI,KAAK,OAAO,MAAM,UAAU;IAC9B,MAAM,SAAS;AACf,QAAI,gBAAgB,OAClB,QAAO,CAAC,GAAG,kBAAkB,OAAO,cAAc,CAAC;;AAIvD,UAAO,CAAC,GAAG,kBAAkB,EAAE,CAAC;IAChC,CACL;AAGH,SAAO;GACP;AAEF,QAAO,KAAK,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;AAsBzC,MAAa,gBAAgB,SAA6C;CACxE,IAAI;AAGJ,KAAI,MAAM,QAAQ,KAAK,CACrB,aAAY,KACT,QAAQ,YAAoB;AAC3B,SAAO,YAAY;GACnB,CACD,KAAK,IAAI;KAIZ,aADkB,KAAgB,MAAM,IAAI,CAEzC,QAAQ,YAAoB;AAC3B,SAAO,YAAY;GACnB,CACD,KAAK,IAAI;AAId,QAAO,QAAQ,WAAW,EAAE,aAAa,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers-33jajRcN.js","names":[],"sources":["../src/helpers/createOptionValueConverter/createOptionValueConverter.ts","../src/helpers/nullishFields/nullishFields.ts"],"sourcesContent":["/* eslint-disable import-x/prefer-default-export */\n\n/**\n * Creates a converter function that preserves the original type (string, number, or boolean)\n * of option values when converting from string keys back to their original type.\n *\n * This is useful for radio/select components where the underlying UI library\n * uses string keys internally, but we want to preserve number/boolean values in the form state.\n *\n * @param options - Array of options with a value property that can be string, number, or boolean\n * @returns An object with:\n * - `convertToOriginalType`: Function to convert a string key back to its original type\n * - `numberValueKeys`: Set of string representations of number values (for internal use)\n * - `booleanValueKeys`: Map of string representations to boolean values (for internal use)\n */\nexport const createOptionValueConverter = <\n T extends { value: string | number | boolean },\n>(\n options: T[],\n) => {\n // Create a set of string keys that represent number values\n const numberValueKeys = new Set(\n options\n .filter((option) => {\n return typeof option.value === 'number';\n })\n .map((option) => {\n return String(option.value);\n }),\n );\n\n // Create a map of string keys to boolean values\n const booleanValueKeys = new Map(\n options\n .filter((option) => {\n return typeof option.value === 'boolean';\n })\n .map((option) => {\n return [String(option.value), option.value as boolean];\n }),\n );\n\n /**\n * Converts a string key back to its original type (string, number, or boolean)\n * based on whether the original option value was a number or boolean\n */\n const convertToOriginalType = (\n key: string | number | boolean,\n ): string | number | boolean => {\n const keyStr = String(key);\n const booleanValue = booleanValueKeys.get(keyStr);\n if (booleanValue !== undefined) {\n return booleanValue;\n }\n if (numberValueKeys.has(keyStr)) {\n return Number(keyStr);\n }\n return keyStr;\n };\n\n return {\n booleanValueKeys,\n convertToOriginalType,\n numberValueKeys,\n };\n};\n","import { slugify } from '@fuf-stack/pixel-utils';\n\n/** Key used to wrap flat array elements when converting to form format */\nexport const flatArrayKey = '__FLAT__';\n\n/**\n * String markers used to preserve null, false, and 0 values during JSON processing\n */\nconst nullString = '__NULL__';\nconst falseString = '__FALSE__';\nconst zeroString = '__ZERO__';\n\n/**\n * Checks if a value is considered \"empty\" for validation display purposes.\n *\n * Used by useUniformField to determine when to show validation errors.\n * Empty values don't trigger immediate error display (user must interact first).\n *\n * Handles:\n * - Primitives: null, undefined, ''\n * - Marker strings: __NULL__, __FALSE__, __ZERO__ (converted via fromNullishString)\n * - Empty arrays: []\n * - Objects with all empty values: {a: null, b: ''}\n * - Flat array wrappers: {__FLAT__: null} or {__FLAT__: ''}\n *\n * @param value - The value to check (will be converted via fromNullishString first)\n * @returns true if the value is empty\n *\n * @example\n * isValueEmpty(null) // true\n * isValueEmpty('') // true\n * isValueEmpty('__NULL__') // true (marker string)\n * isValueEmpty([]) // true (empty array)\n * isValueEmpty({a: null}) // true (object with all empty values)\n * isValueEmpty({__FLAT__: null}) // true (flat array wrapper with empty value)\n * isValueEmpty({__FLAT__: ''}) // true\n * isValueEmpty('hello') // false\n * isValueEmpty([1, 2]) // false\n * isValueEmpty({a: 'value'}) // false\n * isValueEmpty({__FLAT__: 'value'}) // false\n */\nexport const isValueEmpty = (value: unknown): boolean => {\n // Convert marker strings first\n const converted = fromNullishString(value);\n\n if (converted === undefined || converted === null || converted === '') {\n return true;\n }\n if (Array.isArray(converted)) {\n return converted.length === 0;\n }\n if (typeof converted === 'object' && converted !== null) {\n const record = converted as Record<string, unknown>;\n // Handle flat array wrapper: { __FLAT__: innerValue }\n if (flatArrayKey in record) {\n return isValueEmpty(record[flatArrayKey]);\n }\n // For objects (e.g., FieldCard), check if all values are null/undefined/empty\n const values = Object.values(record);\n return values.length === 0 || values.every(isValueEmpty);\n }\n return false;\n};\n\n/**\n * Converts marker strings back to their original values when processing arrays\n */\nexport const fromNullishString = (value: unknown): unknown => {\n // Support arrays: unwrap flat wrappers and convert marker strings per entry\n if (Array.isArray(value)) {\n return (value as unknown[]).map((entry) => {\n if (entry && typeof entry === 'object') {\n const record = entry as Record<string, unknown>;\n if (flatArrayKey in record) {\n const inner = record[flatArrayKey];\n // For arrays, treat empty string as null (placeholder input)\n if (inner === '') {\n return null;\n }\n return fromNullishString(inner);\n }\n }\n return fromNullishString(entry);\n });\n }\n\n if (typeof value !== 'string') {\n return value;\n }\n\n switch (value) {\n case nullString:\n return null;\n case falseString:\n return false;\n case zeroString:\n return 0;\n default:\n return value;\n }\n};\n\n/**\n * Converts null/falsy values to marker strings for JSON processing\n */\nexport const toNullishString = (value: unknown): unknown => {\n if (Array.isArray(value)) {\n // Only wrap arrays of primitives; leave arrays of objects as-is\n const isPrimitive = (v: unknown) => {\n return v === null || ['string', 'number', 'boolean'].includes(typeof v);\n };\n const isPrimitiveArray = (value as unknown[]).every(isPrimitive);\n if (isPrimitiveArray) {\n return (value as unknown[]).map((v) => {\n // Store raw primitive; do not convert to marker strings inside the wrapper\n return { [flatArrayKey]: v } as Record<string, unknown>;\n });\n }\n return value;\n }\n if (value === null || value === '') {\n return nullString;\n }\n if (value === false) {\n return falseString;\n }\n if (value === 0) {\n return zeroString;\n }\n return value;\n};\n\n/**\n * Converts field values to a format suitable for forms by:\n * - Wrapping arrays of primitives as objects using the flatArrayKey `__FLAT__`\n * to satisfy RHF's requirement that array fields contain objects\n * - Removing empty strings and null values from objects\n *\n * This conversion is required because React Hook Form does not support arrays with\n * flat values (string, number, boolean, null). Array fields must contain objects.\n * We work around this by wrapping primitive entries: `{ __FLAT__: <value> }`.\n *\n * @example\n * const fields = {\n * name: 'John',\n * scores: [0, null, 75, false],\n * scoresDetailed: [\n * { score: 1 },\n * { score: null },\n * { score: 0 },\n * { score: false },\n * { score: '' },\n * ],\n * contact: {\n * email: '',\n * phone: null,\n * address: '123 Main St'\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: [\n * { __FLAT__: 0 },\n * { __FLAT__: null },\n * { __FLAT__: 75 },\n * { __FLAT__: false }\n * ],\n * // Arrays of objects are left as objects; empty/null properties are removed\n * scoresDetailed: [\n * { score: 1 },\n * {}, // null score removed\n * { score: 0 },\n * { score: false },\n * {}, // empty string removed\n * ],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toFormFormat = (fields: Record<string, unknown>) => {\n const formFormatJson = JSON.stringify(fields, (_, value) => {\n if (Array.isArray(value)) {\n // Delegate to toNullishString to ensure consistent handling\n return toNullishString(value);\n }\n\n if (value && typeof value === 'object') {\n // Preserve flat-array wrappers as-is (do not filter their inner values here)\n const record = value as Record<string, unknown>;\n if (flatArrayKey in record) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n return Object.fromEntries(\n Object.entries(value).filter(([_key, v]) => {\n return v !== '' && v !== null;\n }),\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n\n return JSON.parse(formFormatJson) as Record<string, unknown>;\n};\n\n/**\n * Converts form state to a format suitable for validation by:\n * - Unwrapping flat array wrappers `{ __FLAT__: <value> }` back to primitives\n * - Converting legacy string markers (__NULL__, __FALSE__, __ZERO__) back to their original values\n * - Removing fields whose converted value is empty string or null\n * - Removing empty arrays\n *\n * @example\n * const formState = {\n * name: 'John',\n * scores: [\n * { __FLAT__: 75 },\n * { __FLAT__: 0 },\n * { __FLAT__: null },\n * { __FLAT__: false }\n * ],\n * emptyArray: [],\n * scoresDetailed: [\n * { score: 1 },\n * {},\n * { score: 0 },\n * { score: false },\n * {},\n * ],\n * contact: {\n * address: '123 Main St',\n * fax: null\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * scores: [75, 0, null, false],\n * // emptyArray is removed\n * // Objects inside arrays remain objects; empty entries remain empty objects\n * scoresDetailed: [\n * { score: 1 },\n * {},\n * { score: 0 },\n * { score: false },\n * {},\n * ],\n * contact: {\n * address: '123 Main St'\n * }\n * }\n */\nexport const toValidationFormat = (\n formState: Record<string, unknown> | null | undefined,\n): Record<string, unknown> | null | undefined => {\n // Handle null or undefined input\n if (formState === undefined || formState === null) {\n return formState;\n }\n\n const validationFormatJson = JSON.stringify(formState, (_, value) => {\n if (Array.isArray(value)) {\n return value.map((v) => {\n // Unwrap new wrapper format { __FLAT__: <value> }\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n const inner = record[flatArrayKey];\n // Treat empty string from forms as null in validation format\n if (inner === '') {\n return null;\n }\n return fromNullishString(inner);\n }\n }\n // Backward compatibility for string markers\n return fromNullishString(v);\n });\n }\n\n if (value && typeof value === 'object') {\n // Object branch: remove keys that resolve to empty/null after marker conversion\n // and unwrap flat-array wrappers if present.\n //\n // Why this shape?\n // - Forms may contain objects with placeholder/empty values that should not\n // be part of the validation payload (e.g. \"\" or __NULL__ markers).\n // - Arrays of primitives are stored as wrapper objects { __FLAT__: <value> }\n // to satisfy RHF structure constraints. When converting back for\n // validation, we need to treat wrappers whose inner value resolves to\n // empty/null as removable, and unwrap non-empty wrappers to the primitive.\n return Object.fromEntries(\n Object.entries(value)\n .filter(([_key, v]) => {\n // If this is a flat-array wrapper, convert the inner value first and\n // drop the key when the inner resolves to empty string or null.\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n const convertedInner = fromNullishString(record[flatArrayKey]);\n return convertedInner !== '' && convertedInner !== null;\n }\n }\n // Drop empty arrays\n if (Array.isArray(v) && v.length === 0) {\n return false;\n }\n // For regular values, convert markers and drop when empty/null.\n const converted = fromNullishString(v);\n return converted !== '' && converted !== null;\n })\n .map(([k, v]) => {\n // Unwrap flat-array wrappers to raw primitives after conversion.\n if (v && typeof v === 'object') {\n const record = v as Record<string, unknown>;\n if (flatArrayKey in record) {\n return [k, fromNullishString(record[flatArrayKey])];\n }\n }\n // For other values, just convert markers.\n return [k, fromNullishString(v)];\n }),\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n });\n\n return JSON.parse(validationFormatJson) as Record<string, unknown>;\n};\n\n/**\n * Helper function to check if a value is an empty object (not an array).\n */\nconst isEmptyObject = (value: unknown): boolean => {\n return (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n Object.keys(value as Record<string, unknown>).length === 0\n );\n};\n\n/**\n * Recursively removes empty objects from a data structure.\n * - Filters empty objects from arrays\n * - Removes properties with empty object values\n * - Removes arrays that become empty after filtering\n */\nconst removeEmptyObjects = (obj: unknown): unknown => {\n if (Array.isArray(obj)) {\n // Filter out empty objects from arrays, then recursively process remaining items\n return obj\n .filter((item) => {\n return !isEmptyObject(item);\n })\n .map((item) => {\n return removeEmptyObjects(item);\n });\n }\n\n if (obj !== null && typeof obj === 'object') {\n return Object.fromEntries(\n Object.entries(obj)\n .map(([key, value]) => {\n return [key, removeEmptyObjects(value)] as [string, unknown];\n })\n .filter(([_, processed]) => {\n // Skip empty objects\n if (isEmptyObject(processed)) {\n return false;\n }\n // Skip arrays that are now empty after filtering\n if (Array.isArray(processed) && processed.length === 0) {\n return false;\n }\n return true;\n }),\n );\n }\n\n return obj;\n};\n\n/**\n * Converts form state to a format suitable for submission by:\n * - Applying all transformations from toValidationFormat\n * - Additionally removing empty objects from the result\n * - Filtering empty objects from arrays\n * - Recursively cleaning nested structures\n *\n * **Why separate from toValidationFormat?**\n *\n * Empty objects must be preserved during validation so that custom refinements\n * can run. For example, a FieldCard with \"at least email or phone required\"\n * validation needs the object to exist (even if empty) for the refine to execute.\n *\n * However, for submission, empty objects are meaningless and should be removed\n * to produce clean data for APIs.\n *\n * @example\n * const formState = {\n * name: 'John',\n * contact: {}, // Empty FieldCard - will be removed\n * tags: [{}, {}, {}], // All empty - array will be removed\n * items: [\n * { value: 'a' },\n * {}, // Empty entry - will be filtered out\n * { value: 'b' }\n * ],\n * nested: {\n * deep: {} // Nested empty - will be removed recursively\n * }\n * };\n *\n * // Result:\n * {\n * name: 'John',\n * items: [{ value: 'a' }, { value: 'b' }]\n * }\n */\nexport const toSubmitFormat = (\n formState: Record<string, unknown> | null | undefined,\n): Record<string, unknown> | null | undefined => {\n const validated = toValidationFormat(formState);\n if (!validated) {\n return validated;\n }\n return removeEmptyObjects(validated) as Record<string, unknown>;\n};\n\n/**\n * Converts a field name to a testId by removing flat array key segments and slugifying.\n * Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.\n *\n * This is used to generate stable testIds for form fields that don't include\n * the internal `__FLAT__` marker used for flat arrays.\n *\n * @param name - The field name as a string (e.g., 'tags.0.__FLAT__') or array path (e.g., ['tags', '0', '__FLAT__'])\n * @returns The slugified field name with all flat array key segments removed (e.g., 'tags_0')\n *\n * @example\n * ```ts\n * nameToTestId('tags.0.__FLAT__') // => 'tags_0'\n * nameToTestId('array.0.__FLAT__') // => 'array_0'\n * nameToTestId('nested.array.0.__FLAT__.field') // => 'nested_array_0_field'\n * nameToTestId('simple.field') // => 'simple_field'\n * nameToTestId(['tags', '0', '__FLAT__']) // => 'tags_0'\n * ```\n */\nexport const nameToTestId = (name: string | readonly string[]): string => {\n let cleanName: string;\n\n // Handle array paths - filter out flatArrayKey and join with dots\n if (Array.isArray(name)) {\n cleanName = name\n .filter((segment: string) => {\n return segment !== flatArrayKey;\n })\n .join('.');\n } else {\n // Handle string paths - split by dots and filter out flatArrayKey segments\n const segments = (name as string).split('.');\n cleanName = segments\n .filter((segment: string) => {\n return segment !== flatArrayKey;\n })\n .join('.');\n }\n\n // Apply slugify transformation\n return slugify(cleanName, { replaceDots: true });\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,8BAGX,YACG;CAEH,MAAM,kBAAkB,IAAI,IAC1B,QACG,QAAQ,WAAW;AAClB,SAAO,OAAO,OAAO,UAAU;GAC/B,CACD,KAAK,WAAW;AACf,SAAO,OAAO,OAAO,MAAM;GAC3B,CACL;CAGD,MAAM,mBAAmB,IAAI,IAC3B,QACG,QAAQ,WAAW;AAClB,SAAO,OAAO,OAAO,UAAU;GAC/B,CACD,KAAK,WAAW;AACf,SAAO,CAAC,OAAO,OAAO,MAAM,EAAE,OAAO,MAAiB;GACtD,CACL;;;;;CAMD,MAAM,yBACJ,QAC8B;EAC9B,MAAM,SAAS,OAAO,IAAI;EAC1B,MAAM,eAAe,iBAAiB,IAAI,OAAO;AACjD,MAAI,iBAAiB,OACnB,QAAO;AAET,MAAI,gBAAgB,IAAI,OAAO,CAC7B,QAAO,OAAO,OAAO;AAEvB,SAAO;;AAGT,QAAO;EACL;EACA;EACA;EACD;;;;;;AC7DH,MAAa,eAAe;;;;AAK5B,MAAM,aAAa;AACn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;CACxE,IAAI;AAGJ,KAAI,MAAM,QAAQ,KAAK,CACrB,aAAY,KACT,QAAQ,YAAoB;AAC3B,SAAO,YAAY;GACnB,CACD,KAAK,IAAI;KAIZ,aADkB,KAAgB,MAAM,IAAI,CAEzC,QAAQ,YAAoB;AAC3B,SAAO,YAAY;GACnB,CACD,KAAK,IAAI;AAId,QAAO,QAAQ,WAAW,EAAE,aAAa,MAAM,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_FormContext = require('./FormContext-
|
|
1
|
+
const require_FormContext = require('./FormContext-BSLO2-sO.cjs');
|
|
2
2
|
let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/helpers/createOptionValueConverter/createOptionValueConverter.ts
|
|
@@ -288,6 +288,75 @@ const toValidationFormat = (formState) => {
|
|
|
288
288
|
return JSON.parse(validationFormatJson);
|
|
289
289
|
};
|
|
290
290
|
/**
|
|
291
|
+
* Helper function to check if a value is an empty object (not an array).
|
|
292
|
+
*/
|
|
293
|
+
const isEmptyObject = (value) => {
|
|
294
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Recursively removes empty objects from a data structure.
|
|
298
|
+
* - Filters empty objects from arrays
|
|
299
|
+
* - Removes properties with empty object values
|
|
300
|
+
* - Removes arrays that become empty after filtering
|
|
301
|
+
*/
|
|
302
|
+
const removeEmptyObjects = (obj) => {
|
|
303
|
+
if (Array.isArray(obj)) return obj.filter((item) => {
|
|
304
|
+
return !isEmptyObject(item);
|
|
305
|
+
}).map((item) => {
|
|
306
|
+
return removeEmptyObjects(item);
|
|
307
|
+
});
|
|
308
|
+
if (obj !== null && typeof obj === "object") return Object.fromEntries(Object.entries(obj).map(([key, value]) => {
|
|
309
|
+
return [key, removeEmptyObjects(value)];
|
|
310
|
+
}).filter(([_, processed]) => {
|
|
311
|
+
if (isEmptyObject(processed)) return false;
|
|
312
|
+
if (Array.isArray(processed) && processed.length === 0) return false;
|
|
313
|
+
return true;
|
|
314
|
+
}));
|
|
315
|
+
return obj;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Converts form state to a format suitable for submission by:
|
|
319
|
+
* - Applying all transformations from toValidationFormat
|
|
320
|
+
* - Additionally removing empty objects from the result
|
|
321
|
+
* - Filtering empty objects from arrays
|
|
322
|
+
* - Recursively cleaning nested structures
|
|
323
|
+
*
|
|
324
|
+
* **Why separate from toValidationFormat?**
|
|
325
|
+
*
|
|
326
|
+
* Empty objects must be preserved during validation so that custom refinements
|
|
327
|
+
* can run. For example, a FieldCard with "at least email or phone required"
|
|
328
|
+
* validation needs the object to exist (even if empty) for the refine to execute.
|
|
329
|
+
*
|
|
330
|
+
* However, for submission, empty objects are meaningless and should be removed
|
|
331
|
+
* to produce clean data for APIs.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* const formState = {
|
|
335
|
+
* name: 'John',
|
|
336
|
+
* contact: {}, // Empty FieldCard - will be removed
|
|
337
|
+
* tags: [{}, {}, {}], // All empty - array will be removed
|
|
338
|
+
* items: [
|
|
339
|
+
* { value: 'a' },
|
|
340
|
+
* {}, // Empty entry - will be filtered out
|
|
341
|
+
* { value: 'b' }
|
|
342
|
+
* ],
|
|
343
|
+
* nested: {
|
|
344
|
+
* deep: {} // Nested empty - will be removed recursively
|
|
345
|
+
* }
|
|
346
|
+
* };
|
|
347
|
+
*
|
|
348
|
+
* // Result:
|
|
349
|
+
* {
|
|
350
|
+
* name: 'John',
|
|
351
|
+
* items: [{ value: 'a' }, { value: 'b' }]
|
|
352
|
+
* }
|
|
353
|
+
*/
|
|
354
|
+
const toSubmitFormat = (formState) => {
|
|
355
|
+
const validated = toValidationFormat(formState);
|
|
356
|
+
if (!validated) return validated;
|
|
357
|
+
return removeEmptyObjects(validated);
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
291
360
|
* Converts a field name to a testId by removing flat array key segments and slugifying.
|
|
292
361
|
* Removes all occurrences of `flatArrayKey` from the field name and applies slugify transformation.
|
|
293
362
|
*
|
|
@@ -360,10 +429,16 @@ Object.defineProperty(exports, 'toNullishString', {
|
|
|
360
429
|
return toNullishString;
|
|
361
430
|
}
|
|
362
431
|
});
|
|
432
|
+
Object.defineProperty(exports, 'toSubmitFormat', {
|
|
433
|
+
enumerable: true,
|
|
434
|
+
get: function () {
|
|
435
|
+
return toSubmitFormat;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
363
438
|
Object.defineProperty(exports, 'toValidationFormat', {
|
|
364
439
|
enumerable: true,
|
|
365
440
|
get: function () {
|
|
366
441
|
return toValidationFormat;
|
|
367
442
|
}
|
|
368
443
|
});
|
|
369
|
-
//# sourceMappingURL=helpers-
|
|
444
|
+
//# sourceMappingURL=helpers-Bd_QpqXg.cjs.map
|