@fuf-stack/uniform 1.10.3 → 1.11.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 +4 -18
- package/dist/Checkboxes/index.d.cts +2 -11
- package/dist/Checkboxes/index.d.ts +2 -11
- package/dist/Checkboxes/index.js +3 -19
- package/dist/Checkboxes-CGWhnpBp.js +115 -0
- package/dist/Checkboxes-CGWhnpBp.js.map +1 -0
- package/dist/Checkboxes-Ds6bzl6p.cjs +127 -0
- package/dist/Checkboxes-Ds6bzl6p.cjs.map +1 -0
- package/dist/FieldArray/index.cjs +4 -21
- package/dist/FieldArray/index.d.cts +2 -10
- package/dist/FieldArray/index.d.ts +2 -10
- package/dist/FieldArray/index.js +3 -22
- package/dist/FieldArray-BexXN9bO.cjs +515 -0
- package/dist/FieldArray-BexXN9bO.cjs.map +1 -0
- package/dist/FieldArray-D3iUaRLo.js +503 -0
- package/dist/FieldArray-D3iUaRLo.js.map +1 -0
- package/dist/FieldCard/index.cjs +3 -18
- package/dist/FieldCard/index.d.cts +2 -97
- package/dist/FieldCard/index.d.ts +2 -97
- package/dist/FieldCard/index.js +3 -19
- package/dist/FieldCard-mpmErfDK.js +121 -0
- package/dist/FieldCard-mpmErfDK.js.map +1 -0
- package/dist/FieldCard-pP7aniZU.cjs +133 -0
- package/dist/FieldCard-pP7aniZU.cjs.map +1 -0
- package/dist/FieldCopyTestIdButton-AaLwu_8y.cjs +41 -0
- package/dist/FieldCopyTestIdButton-AaLwu_8y.cjs.map +1 -0
- package/dist/FieldCopyTestIdButton-Cx8AXJhO.js +29 -0
- package/dist/FieldCopyTestIdButton-Cx8AXJhO.js.map +1 -0
- package/dist/FieldValidationError-Cq6aI0tE.cjs +65 -0
- package/dist/FieldValidationError-Cq6aI0tE.cjs.map +1 -0
- package/dist/FieldValidationError-D86DPSOH.js +53 -0
- package/dist/FieldValidationError-D86DPSOH.js.map +1 -0
- package/dist/Form/index.cjs +4 -13
- package/dist/Form/index.d.cts +2 -11
- package/dist/Form/index.d.ts +3 -11
- package/dist/Form/index.js +3 -14
- package/dist/Form-CFmCTl60.js +119 -0
- package/dist/Form-CFmCTl60.js.map +1 -0
- package/dist/Form-FvN3SXfF.cjs +130 -0
- package/dist/Form-FvN3SXfF.cjs.map +1 -0
- package/dist/FormContext-C2_WMi_v.d.ts +18 -0
- package/dist/FormContext-C2_WMi_v.d.ts.map +1 -0
- package/dist/FormContext-C3GymQOA.cjs +275 -0
- package/dist/FormContext-C3GymQOA.cjs.map +1 -0
- package/dist/FormContext-CN9n_KdE.js +229 -0
- package/dist/FormContext-CN9n_KdE.js.map +1 -0
- package/dist/FormContext-Dl7KL_wl.d.cts +18 -0
- package/dist/FormContext-Dl7KL_wl.d.cts.map +1 -0
- package/dist/Grid/index.cjs +4 -9
- package/dist/Grid/index.d.cts +2 -8
- package/dist/Grid/index.d.ts +2 -8
- package/dist/Grid/index.js +3 -10
- package/dist/Grid-DEH7Sezi.js +23 -0
- package/dist/Grid-DEH7Sezi.js.map +1 -0
- package/dist/Grid-DG60vYYG.cjs +35 -0
- package/dist/Grid-DG60vYYG.cjs.map +1 -0
- package/dist/Input/index.cjs +4 -19
- package/dist/Input/index.d.cts +2 -11
- package/dist/Input/index.d.ts +2 -11
- package/dist/Input/index.js +3 -20
- package/dist/Input--h5t7Sbl.js +94 -0
- package/dist/Input--h5t7Sbl.js.map +1 -0
- package/dist/Input-DKfFFOpo.cjs +106 -0
- package/dist/Input-DKfFFOpo.cjs.map +1 -0
- package/dist/RadioBoxes/index.cjs +5 -20
- package/dist/RadioBoxes/index.d.cts +2 -10
- package/dist/RadioBoxes/index.d.ts +2 -10
- package/dist/RadioBoxes/index.js +3 -21
- package/dist/RadioBoxes-7qdHj3ti.js +138 -0
- package/dist/RadioBoxes-7qdHj3ti.js.map +1 -0
- package/dist/RadioBoxes-Bd9ahl4i.cjs +156 -0
- package/dist/RadioBoxes-Bd9ahl4i.cjs.map +1 -0
- package/dist/RadioTabs/index.cjs +4 -18
- package/dist/RadioTabs/index.d.cts +2 -10
- package/dist/RadioTabs/index.d.ts +2 -10
- package/dist/RadioTabs/index.js +3 -19
- package/dist/RadioTabs-DXs98jng.js +119 -0
- package/dist/RadioTabs-DXs98jng.js.map +1 -0
- package/dist/RadioTabs-DcEUdW7r.cjs +132 -0
- package/dist/RadioTabs-DcEUdW7r.cjs.map +1 -0
- package/dist/Radios/index.cjs +4 -18
- package/dist/Radios/index.d.cts +2 -9
- package/dist/Radios/index.d.ts +2 -9
- package/dist/Radios/index.js +3 -19
- package/dist/Radios-BIx06mzU.js +75 -0
- package/dist/Radios-BIx06mzU.js.map +1 -0
- package/dist/Radios-CIPNqPzi.cjs +87 -0
- package/dist/Radios-CIPNqPzi.cjs.map +1 -0
- package/dist/Select/index.cjs +4 -19
- package/dist/Select/index.d.cts +2 -11
- package/dist/Select/index.d.ts +2 -11
- package/dist/Select/index.js +3 -20
- package/dist/Select-BsL7qn2v.cjs +246 -0
- package/dist/Select-BsL7qn2v.cjs.map +1 -0
- package/dist/Select-CBjqYDcs.js +233 -0
- package/dist/Select-CBjqYDcs.js.map +1 -0
- package/dist/Slider/index.cjs +4 -18
- package/dist/Slider/index.d.cts +2 -10
- package/dist/Slider/index.d.ts +2 -10
- package/dist/Slider/index.js +3 -19
- package/dist/Slider-BDLbD7d5.cjs +123 -0
- package/dist/Slider-BDLbD7d5.cjs.map +1 -0
- package/dist/Slider-BHjHSoIk.js +111 -0
- package/dist/Slider-BHjHSoIk.js.map +1 -0
- package/dist/SubmitButton/index.cjs +4 -13
- package/dist/SubmitButton/index.d.cts +2 -9
- package/dist/SubmitButton/index.d.ts +2 -9
- package/dist/SubmitButton/index.js +3 -14
- package/dist/SubmitButton-7iOaKzhB.js +34 -0
- package/dist/SubmitButton-7iOaKzhB.js.map +1 -0
- package/dist/SubmitButton-DhtPJuro.cjs +46 -0
- package/dist/SubmitButton-DhtPJuro.cjs.map +1 -0
- package/dist/Switch/index.cjs +4 -18
- package/dist/Switch/index.d.cts +2 -11
- package/dist/Switch/index.d.ts +2 -11
- package/dist/Switch/index.js +3 -19
- package/dist/Switch-DCxAgt_L.js +84 -0
- package/dist/Switch-DCxAgt_L.js.map +1 -0
- package/dist/Switch-Dczzog3v.cjs +96 -0
- package/dist/Switch-Dczzog3v.cjs.map +1 -0
- package/dist/SwitchBox/index.cjs +5 -20
- package/dist/SwitchBox/index.d.cts +2 -11
- package/dist/SwitchBox/index.d.ts +2 -11
- package/dist/SwitchBox/index.js +3 -21
- package/dist/SwitchBox-DPHryDOM.js +156 -0
- package/dist/SwitchBox-DPHryDOM.js.map +1 -0
- package/dist/SwitchBox-DqVmZYId.cjs +174 -0
- package/dist/SwitchBox-DqVmZYId.cjs.map +1 -0
- package/dist/TextArea/index.cjs +4 -19
- package/dist/TextArea/index.d.cts +2 -10
- package/dist/TextArea/index.d.ts +2 -10
- package/dist/TextArea/index.js +3 -20
- package/dist/TextArea-BR6e-Fio.js +64 -0
- package/dist/TextArea-BR6e-Fio.js.map +1 -0
- package/dist/TextArea-CH-F6_ax.cjs +76 -0
- package/dist/TextArea-CH-F6_ax.cjs.map +1 -0
- package/dist/helpers/index.cjs +8 -18
- package/dist/helpers/index.d.cts +2 -132
- package/dist/helpers/index.d.ts +2 -132
- package/dist/helpers/index.js +3 -18
- package/dist/helpers-B-CJOBt3.js +236 -0
- package/dist/helpers-B-CJOBt3.js.map +1 -0
- package/dist/helpers-KTgXi0lA.cjs +272 -0
- package/dist/helpers-KTgXi0lA.cjs.map +1 -0
- package/dist/hooks/useClientValidation/index.cjs +6 -10
- package/dist/hooks/useClientValidation/index.cjs.map +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +2 -147
- package/dist/hooks/useClientValidation/index.d.ts +2 -147
- package/dist/hooks/useClientValidation/index.js +7 -12
- package/dist/hooks/useClientValidation/index.js.map +1 -1
- package/dist/hooks/useController/index.cjs +5 -7
- package/dist/hooks/useController/index.cjs.map +1 -1
- package/dist/hooks/useController/index.d.cts +2 -29
- package/dist/hooks/useController/index.d.ts +3 -29
- package/dist/hooks/useController/index.js +7 -9
- package/dist/hooks/useController/index.js.map +1 -1
- package/dist/hooks/useFormContext/index.cjs +3 -12
- package/dist/hooks/useFormContext/index.d.cts +2 -62
- package/dist/hooks/useFormContext/index.d.ts +4 -62
- package/dist/hooks/useFormContext/index.js +3 -13
- package/dist/hooks/useInput/index.cjs +11 -5
- package/dist/hooks/useInput/index.cjs.map +1 -1
- package/dist/hooks/useInput/index.d.cts +2 -1
- package/dist/hooks/useInput/index.d.ts +2 -1
- package/dist/hooks/useInput/index.js +7 -7
- package/dist/hooks/useInput/index.js.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -7
- package/dist/hooks/useInputValueDebounce/index.d.cts +2 -55
- package/dist/hooks/useInputValueDebounce/index.d.ts +2 -55
- package/dist/hooks/useInputValueDebounce/index.js +3 -8
- package/dist/hooks/useInputValueTransform/index.cjs +5 -5
- package/dist/hooks/useInputValueTransform/index.cjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.cts +2 -102
- package/dist/hooks/useInputValueTransform/index.d.ts +2 -102
- package/dist/hooks/useInputValueTransform/index.js +7 -7
- package/dist/hooks/useInputValueTransform/index.js.map +1 -1
- package/dist/hooks/useUniformField/index.cjs +2 -15
- package/dist/hooks/useUniformField/index.d.cts +2 -98
- package/dist/hooks/useUniformField/index.d.ts +6 -98
- package/dist/hooks/useUniformField/index.js +3 -16
- package/dist/hooks/useUniformFieldArray/index.cjs +2 -17
- package/dist/hooks/useUniformFieldArray/index.d.cts +2 -71
- package/dist/hooks/useUniformFieldArray/index.d.ts +7 -71
- package/dist/hooks/useUniformFieldArray/index.js +3 -18
- package/dist/hooks/useWatchUserChange/index.cjs +5 -8
- package/dist/hooks/useWatchUserChange/index.cjs.map +1 -1
- package/dist/hooks/useWatchUserChange/index.d.cts +2 -73
- package/dist/hooks/useWatchUserChange/index.d.ts +2 -73
- package/dist/hooks/useWatchUserChange/index.js +7 -10
- package/dist/hooks/useWatchUserChange/index.js.map +1 -1
- package/dist/index-1gPh6Uoh.d.cts +16 -0
- package/dist/index-1gPh6Uoh.d.cts.map +1 -0
- package/dist/index-B3Z8gdjC.d.ts +1 -0
- package/dist/index-B4Wkijem.d.ts +169 -0
- package/dist/index-B4Wkijem.d.ts.map +1 -0
- package/dist/index-B74QlCAy.d.cts +169 -0
- package/dist/index-B74QlCAy.d.cts.map +1 -0
- package/dist/index-BLREDRDJ.d.cts +1 -0
- package/dist/index-BM4XWo1K.d.ts +118 -0
- package/dist/index-BM4XWo1K.d.ts.map +1 -0
- package/dist/index-BMN2XNyT.d.cts +23 -0
- package/dist/index-BMN2XNyT.d.cts.map +1 -0
- package/dist/index-BOI0cy-n.d.cts +118 -0
- package/dist/index-BOI0cy-n.d.cts.map +1 -0
- package/dist/index-BTEsKen4.d.ts +264 -0
- package/dist/index-BTEsKen4.d.ts.map +1 -0
- package/dist/index-BW9EUWZE.d.cts +23 -0
- package/dist/index-BW9EUWZE.d.cts.map +1 -0
- package/dist/index-BXpMZvwA.d.cts +1 -0
- package/dist/index-BYrmFhKl.d.ts +1 -0
- package/dist/index-BaBZGCqS.d.cts +177 -0
- package/dist/index-BaBZGCqS.d.cts.map +1 -0
- package/dist/index-C1fYmoY0.d.ts +123 -0
- package/dist/index-C1fYmoY0.d.ts.map +1 -0
- package/dist/index-C56I3SOi.d.cts +148 -0
- package/dist/index-C56I3SOi.d.cts.map +1 -0
- package/dist/index-CHmS3ri3.d.ts +16 -0
- package/dist/index-CHmS3ri3.d.ts.map +1 -0
- package/dist/index-CI9QBUoM.d.cts +97 -0
- package/dist/index-CI9QBUoM.d.cts.map +1 -0
- package/dist/index-CJNLQVjx.d.ts +1 -0
- package/dist/index-CO-l7RmT.d.cts +181 -0
- package/dist/index-CO-l7RmT.d.cts.map +1 -0
- package/dist/index-CQWoxgWk.d.ts +23 -0
- package/dist/index-CQWoxgWk.d.ts.map +1 -0
- package/dist/index-CVY05bZf.d.ts +39 -0
- package/dist/index-CVY05bZf.d.ts.map +1 -0
- package/dist/index-C_ATGeaX.d.ts +104 -0
- package/dist/index-C_ATGeaX.d.ts.map +1 -0
- package/dist/index-CbAh0Kfo.d.cts +39 -0
- package/dist/index-CbAh0Kfo.d.cts.map +1 -0
- package/dist/index-CqV2Q3da.d.cts +264 -0
- package/dist/index-CqV2Q3da.d.cts.map +1 -0
- package/dist/index-CraZe1qS.d.ts +97 -0
- package/dist/index-CraZe1qS.d.ts.map +1 -0
- package/dist/index-CvA5yKx9.d.ts +177 -0
- package/dist/index-CvA5yKx9.d.ts.map +1 -0
- package/dist/index-CwSIy_W-.d.cts +1 -0
- package/dist/index-CzypMcVS.d.cts +104 -0
- package/dist/index-CzypMcVS.d.cts.map +1 -0
- package/dist/index-D6RB3b5L.d.ts +148 -0
- package/dist/index-D6RB3b5L.d.ts.map +1 -0
- package/dist/index-DA5um0u6.d.cts +123 -0
- package/dist/index-DA5um0u6.d.cts.map +1 -0
- package/dist/index-DHHBSmJb.d.ts +23 -0
- package/dist/index-DHHBSmJb.d.ts.map +1 -0
- package/dist/index-DhMSgdwM.d.ts +156 -0
- package/dist/index-DhMSgdwM.d.ts.map +1 -0
- package/dist/index-Dklb-p_1.d.cts +156 -0
- package/dist/index-Dklb-p_1.d.cts.map +1 -0
- package/dist/index-DpD4MxGD.d.cts +177 -0
- package/dist/index-DpD4MxGD.d.cts.map +1 -0
- package/dist/index-Drl7euco.d.ts +115 -0
- package/dist/index-Drl7euco.d.ts.map +1 -0
- package/dist/index-DzuP5q-2.d.ts +181 -0
- package/dist/index-DzuP5q-2.d.ts.map +1 -0
- package/dist/index-G0IgQWoU.d.cts +134 -0
- package/dist/index-G0IgQWoU.d.cts.map +1 -0
- package/dist/index-RvYO46Vg.d.ts +178 -0
- package/dist/index-RvYO46Vg.d.ts.map +1 -0
- package/dist/index-UjKqRe-8.d.ts +134 -0
- package/dist/index-UjKqRe-8.d.ts.map +1 -0
- package/dist/index-aHcGnXHf.d.ts +44 -0
- package/dist/index-aHcGnXHf.d.ts.map +1 -0
- package/dist/index-iuLEYAix.d.cts +115 -0
- package/dist/index-iuLEYAix.d.cts.map +1 -0
- package/dist/index-jmQP58tO.d.cts +44 -0
- package/dist/index-jmQP58tO.d.cts.map +1 -0
- package/dist/index.cjs +75 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -38
- package/dist/index.d.ts +31 -38
- package/dist/index.js +33 -133
- package/dist/index.js.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.cjs +4 -9
- package/dist/partials/FieldCopyTestIdButton/index.d.cts +2 -7
- package/dist/partials/FieldCopyTestIdButton/index.d.ts +2 -7
- package/dist/partials/FieldCopyTestIdButton/index.js +3 -10
- package/dist/partials/FieldValidationError/index.cjs +4 -9
- package/dist/partials/FieldValidationError/index.d.cts +2 -8
- package/dist/partials/FieldValidationError/index.d.ts +2 -8
- package/dist/partials/FieldValidationError/index.js +3 -10
- package/dist/useClientValidation-BnnscAEe.js +179 -0
- package/dist/useClientValidation-BnnscAEe.js.map +1 -0
- package/dist/useClientValidation-C3Q5UCy9.d.cts +150 -0
- package/dist/useClientValidation-C3Q5UCy9.d.cts.map +1 -0
- package/dist/useClientValidation-CkBtUSco.d.ts +150 -0
- package/dist/useClientValidation-CkBtUSco.d.ts.map +1 -0
- package/dist/useClientValidation-oZd4_ocQ.cjs +191 -0
- package/dist/useClientValidation-oZd4_ocQ.cjs.map +1 -0
- package/dist/useController-BzkCcbSo.cjs +48 -0
- package/dist/useController-BzkCcbSo.cjs.map +1 -0
- package/dist/useController-C_MZLZIp.d.cts +31 -0
- package/dist/useController-C_MZLZIp.d.cts.map +1 -0
- package/dist/useController-CumIERks.js +43 -0
- package/dist/useController-CumIERks.js.map +1 -0
- package/dist/useController-hjpJQf0w.d.ts +31 -0
- package/dist/useController-hjpJQf0w.d.ts.map +1 -0
- package/dist/useFormContext-356X5XAY.js +6 -0
- package/dist/useFormContext-356X5XAY.js.map +1 -0
- package/dist/useFormContext-3AAPT6eZ.d.ts +64 -0
- package/dist/useFormContext-3AAPT6eZ.d.ts.map +1 -0
- package/dist/useFormContext-CWuN-_7P.cjs +134 -0
- package/dist/useFormContext-CWuN-_7P.cjs.map +1 -0
- package/dist/useFormContext-CZh7pv8f.d.cts +64 -0
- package/dist/useFormContext-CZh7pv8f.d.cts.map +1 -0
- package/dist/useFormContext-CkeSOfWD.cjs +6 -0
- package/dist/useFormContext-CkeSOfWD.cjs.map +1 -0
- package/dist/useFormContext-JCm1UR_e.js +123 -0
- package/dist/useFormContext-JCm1UR_e.js.map +1 -0
- package/dist/useInput-DZ6KGBxw.js +3 -0
- package/dist/useInput-IGJqJ2tR.d.ts +2 -0
- package/dist/useInput-NMHJNZ5A.d.cts +2 -0
- package/dist/useInputValueDebounce-B2RzCWty.d.cts +62 -0
- package/dist/useInputValueDebounce-B2RzCWty.d.cts.map +1 -0
- package/dist/useInputValueDebounce-C7_bvNGH.d.ts +62 -0
- package/dist/useInputValueDebounce-C7_bvNGH.d.ts.map +1 -0
- package/dist/useInputValueDebounce-DaH5ONlQ.js +84 -0
- package/dist/useInputValueDebounce-DaH5ONlQ.js.map +1 -0
- package/dist/useInputValueDebounce-tL8maIp8.cjs +90 -0
- package/dist/useInputValueDebounce-tL8maIp8.cjs.map +1 -0
- package/dist/useInputValueTransform-BID-CQ-y.d.cts +107 -0
- package/dist/useInputValueTransform-BID-CQ-y.d.cts.map +1 -0
- package/dist/useInputValueTransform-C-uSW8Y3.cjs +116 -0
- package/dist/useInputValueTransform-C-uSW8Y3.cjs.map +1 -0
- package/dist/useInputValueTransform-D7LfyYRe.d.ts +107 -0
- package/dist/useInputValueTransform-D7LfyYRe.d.ts.map +1 -0
- package/dist/useInputValueTransform-aiIf8lq5.js +110 -0
- package/dist/useInputValueTransform-aiIf8lq5.js.map +1 -0
- package/dist/useUniformField-BMvnRC_r.cjs +136 -0
- package/dist/useUniformField-BMvnRC_r.cjs.map +1 -0
- package/dist/useUniformField-Be3kdnhK.d.cts +98 -0
- package/dist/useUniformField-Be3kdnhK.d.cts.map +1 -0
- package/dist/useUniformField-ClprfrES.js +129 -0
- package/dist/useUniformField-ClprfrES.js.map +1 -0
- package/dist/useUniformField-DDHQ5B11.d.ts +98 -0
- package/dist/useUniformField-DDHQ5B11.d.ts.map +1 -0
- package/dist/useUniformFieldArray-BBFw08qL.d.cts +79 -0
- package/dist/useUniformFieldArray-BBFw08qL.d.cts.map +1 -0
- package/dist/useUniformFieldArray-BhPi3gPv.d.ts +79 -0
- package/dist/useUniformFieldArray-BhPi3gPv.d.ts.map +1 -0
- package/dist/useUniformFieldArray-C-0OXG3N.js +84 -0
- package/dist/useUniformFieldArray-C-0OXG3N.js.map +1 -0
- package/dist/useUniformFieldArray-btjvJdZ6.cjs +90 -0
- package/dist/useUniformFieldArray-btjvJdZ6.cjs.map +1 -0
- package/dist/useWatchUserChange-BAdiqg2q.d.ts +78 -0
- package/dist/useWatchUserChange-BAdiqg2q.d.ts.map +1 -0
- package/dist/useWatchUserChange-C1ezpj0t.js +83 -0
- package/dist/useWatchUserChange-C1ezpj0t.js.map +1 -0
- package/dist/useWatchUserChange-C5dr12By.cjs +89 -0
- package/dist/useWatchUserChange-C5dr12By.cjs.map +1 -0
- package/dist/useWatchUserChange-COVdHmki.d.cts +78 -0
- package/dist/useWatchUserChange-COVdHmki.d.cts.map +1 -0
- package/package.json +73 -100
- package/dist/Checkboxes/index.cjs.map +0 -1
- package/dist/Checkboxes/index.js.map +0 -1
- package/dist/Checkboxes-CBgO9itq.d.cts +0 -171
- package/dist/Checkboxes-CFbsc6zg.d.ts +0 -171
- package/dist/FieldArray/index.cjs.map +0 -1
- package/dist/FieldArray/index.js.map +0 -1
- package/dist/FieldArray-72vn2MG9.d.cts +0 -160
- package/dist/FieldArray-72vn2MG9.d.ts +0 -160
- package/dist/FieldCard/index.cjs.map +0 -1
- package/dist/FieldCard/index.js.map +0 -1
- package/dist/FieldCopyTestIdButton-_TDlmw0L.d.cts +0 -11
- package/dist/FieldCopyTestIdButton-_TDlmw0L.d.ts +0 -11
- package/dist/FieldValidationError-DwtLkGMo.d.cts +0 -17
- package/dist/FieldValidationError-DwtLkGMo.d.ts +0 -17
- package/dist/Form/index.cjs.map +0 -1
- package/dist/Form/index.js.map +0 -1
- package/dist/Form-BZZJPLsi.d.cts +0 -32
- package/dist/Form-zsUjI2yq.d.ts +0 -32
- package/dist/FormContext-9Firwt4k.d.cts +0 -14
- package/dist/FormContext-9Firwt4k.d.ts +0 -14
- package/dist/Grid/index.cjs.map +0 -1
- package/dist/Grid/index.js.map +0 -1
- package/dist/Grid-DF3L9NF3.d.cts +0 -17
- package/dist/Grid-DF3L9NF3.d.ts +0 -17
- package/dist/Input/index.cjs.map +0 -1
- package/dist/Input/index.js.map +0 -1
- package/dist/Input-BGYDOpbo.d.cts +0 -101
- package/dist/Input-__SqMh2n.d.ts +0 -101
- package/dist/RadioBox-DnqCiTR1.d.cts +0 -168
- package/dist/RadioBox-DnqCiTR1.d.ts +0 -168
- package/dist/RadioBoxes/index.cjs.map +0 -1
- package/dist/RadioBoxes/index.js.map +0 -1
- package/dist/RadioTabs/index.cjs.map +0 -1
- package/dist/RadioTabs/index.js.map +0 -1
- package/dist/RadioTabs-DkR5fvl4.d.cts +0 -138
- package/dist/RadioTabs-DkR5fvl4.d.ts +0 -138
- package/dist/Radios/index.cjs.map +0 -1
- package/dist/Radios/index.js.map +0 -1
- package/dist/Radios-lLVlvY_B.d.cts +0 -115
- package/dist/Radios-lLVlvY_B.d.ts +0 -115
- package/dist/Select/index.cjs.map +0 -1
- package/dist/Select/index.js.map +0 -1
- package/dist/Select-DWlnKj5c.d.cts +0 -249
- package/dist/Select-DWlnKj5c.d.ts +0 -249
- package/dist/Slider/index.cjs.map +0 -1
- package/dist/Slider/index.js.map +0 -1
- package/dist/Slider-CxHvafJA.d.cts +0 -155
- package/dist/Slider-CxHvafJA.d.ts +0 -155
- package/dist/SubmitButton/index.cjs.map +0 -1
- package/dist/SubmitButton/index.js.map +0 -1
- package/dist/SubmitButton-DqaxyVpp.d.cts +0 -28
- package/dist/SubmitButton-DqaxyVpp.d.ts +0 -28
- package/dist/Switch/index.cjs.map +0 -1
- package/dist/Switch/index.js.map +0 -1
- package/dist/Switch-B4AuHAMX.d.cts +0 -108
- package/dist/Switch-B4AuHAMX.d.ts +0 -108
- package/dist/SwitchBox/index.cjs.map +0 -1
- package/dist/SwitchBox/index.js.map +0 -1
- package/dist/SwitchBox-q1I7a0NX.d.cts +0 -146
- package/dist/SwitchBox-q1I7a0NX.d.ts +0 -146
- package/dist/TextArea/index.cjs.map +0 -1
- package/dist/TextArea/index.js.map +0 -1
- package/dist/TextArea-CYcFOcun.d.cts +0 -88
- package/dist/TextArea-CYcFOcun.d.ts +0 -88
- package/dist/chunk-264VRHMT.js +0 -105
- package/dist/chunk-264VRHMT.js.map +0 -1
- package/dist/chunk-26VE4IGU.js +0 -68
- package/dist/chunk-26VE4IGU.js.map +0 -1
- package/dist/chunk-2HDXHQOC.js +0 -215
- package/dist/chunk-2HDXHQOC.js.map +0 -1
- package/dist/chunk-2UQCRQEJ.cjs +0 -68
- package/dist/chunk-2UQCRQEJ.cjs.map +0 -1
- package/dist/chunk-36LBVB45.js +0 -1
- package/dist/chunk-36LBVB45.js.map +0 -1
- package/dist/chunk-3JAVQAL5.cjs +0 -1
- package/dist/chunk-3JAVQAL5.cjs.map +0 -1
- package/dist/chunk-3ZQXSGR2.cjs +0 -67
- package/dist/chunk-3ZQXSGR2.cjs.map +0 -1
- package/dist/chunk-4CQWTUQR.js +0 -292
- package/dist/chunk-4CQWTUQR.js.map +0 -1
- package/dist/chunk-4HFPBJ3O.cjs +0 -171
- package/dist/chunk-4HFPBJ3O.cjs.map +0 -1
- package/dist/chunk-4RQJCFM7.js +0 -154
- package/dist/chunk-4RQJCFM7.js.map +0 -1
- package/dist/chunk-555JRYCS.cjs +0 -61
- package/dist/chunk-555JRYCS.cjs.map +0 -1
- package/dist/chunk-55VJM3KD.cjs +0 -118
- package/dist/chunk-55VJM3KD.cjs.map +0 -1
- package/dist/chunk-56TQOKG7.cjs +0 -48
- package/dist/chunk-56TQOKG7.cjs.map +0 -1
- package/dist/chunk-5MTIQ6WD.js +0 -41
- package/dist/chunk-5MTIQ6WD.js.map +0 -1
- package/dist/chunk-6AWHOBNL.cjs +0 -41
- package/dist/chunk-6AWHOBNL.cjs.map +0 -1
- package/dist/chunk-6GN62PBG.cjs +0 -182
- package/dist/chunk-6GN62PBG.cjs.map +0 -1
- package/dist/chunk-7MOAXLQZ.js +0 -103
- package/dist/chunk-7MOAXLQZ.js.map +0 -1
- package/dist/chunk-7OMJ26AT.js +0 -165
- package/dist/chunk-7OMJ26AT.js.map +0 -1
- package/dist/chunk-7ZE7IZ5R.cjs +0 -103
- package/dist/chunk-7ZE7IZ5R.cjs.map +0 -1
- package/dist/chunk-AHJJIANM.js +0 -7
- package/dist/chunk-AHJJIANM.js.map +0 -1
- package/dist/chunk-AQJLKHAE.cjs +0 -277
- package/dist/chunk-AQJLKHAE.cjs.map +0 -1
- package/dist/chunk-B62HKKMS.js +0 -20
- package/dist/chunk-B62HKKMS.js.map +0 -1
- package/dist/chunk-C6WYP35Z.js +0 -219
- package/dist/chunk-C6WYP35Z.js.map +0 -1
- package/dist/chunk-CNTOODUQ.js +0 -48
- package/dist/chunk-CNTOODUQ.js.map +0 -1
- package/dist/chunk-ECUVOZGQ.cjs +0 -148
- package/dist/chunk-ECUVOZGQ.cjs.map +0 -1
- package/dist/chunk-ELYGQTXB.js +0 -47
- package/dist/chunk-ELYGQTXB.js.map +0 -1
- package/dist/chunk-EVASKP6Q.js +0 -148
- package/dist/chunk-EVASKP6Q.js.map +0 -1
- package/dist/chunk-FYN7ZWLW.cjs +0 -115
- package/dist/chunk-FYN7ZWLW.cjs.map +0 -1
- package/dist/chunk-GEC75GNL.js +0 -137
- package/dist/chunk-GEC75GNL.js.map +0 -1
- package/dist/chunk-HEPNEBRF.cjs +0 -26
- package/dist/chunk-HEPNEBRF.cjs.map +0 -1
- package/dist/chunk-IR75YRIZ.js +0 -171
- package/dist/chunk-IR75YRIZ.js.map +0 -1
- package/dist/chunk-IV45K4WU.js +0 -277
- package/dist/chunk-IV45K4WU.js.map +0 -1
- package/dist/chunk-K2V4ULA2.js +0 -61
- package/dist/chunk-K2V4ULA2.js.map +0 -1
- package/dist/chunk-KBKMMDLM.js +0 -118
- package/dist/chunk-KBKMMDLM.js.map +0 -1
- package/dist/chunk-KDNO5YO5.cjs +0 -105
- package/dist/chunk-KDNO5YO5.cjs.map +0 -1
- package/dist/chunk-LEMQGDFE.js +0 -67
- package/dist/chunk-LEMQGDFE.js.map +0 -1
- package/dist/chunk-LO7UKHOS.js +0 -26
- package/dist/chunk-LO7UKHOS.js.map +0 -1
- package/dist/chunk-LWPZZ2AW.cjs +0 -172
- package/dist/chunk-LWPZZ2AW.cjs.map +0 -1
- package/dist/chunk-NG3CJ3UE.js +0 -699
- package/dist/chunk-NG3CJ3UE.js.map +0 -1
- package/dist/chunk-NHEZXA4H.cjs +0 -47
- package/dist/chunk-NHEZXA4H.cjs.map +0 -1
- package/dist/chunk-NTDKZW4E.js +0 -35
- package/dist/chunk-NTDKZW4E.js.map +0 -1
- package/dist/chunk-O2XJNQQK.js +0 -154
- package/dist/chunk-O2XJNQQK.js.map +0 -1
- package/dist/chunk-OE5BOGGX.cjs +0 -35
- package/dist/chunk-OE5BOGGX.cjs.map +0 -1
- package/dist/chunk-OKJWLH7T.cjs +0 -154
- package/dist/chunk-OKJWLH7T.cjs.map +0 -1
- package/dist/chunk-OORASWXL.js +0 -49
- package/dist/chunk-OORASWXL.js.map +0 -1
- package/dist/chunk-OT3A4LEE.cjs +0 -154
- package/dist/chunk-OT3A4LEE.cjs.map +0 -1
- package/dist/chunk-PCTYJUY7.cjs +0 -7
- package/dist/chunk-PCTYJUY7.cjs.map +0 -1
- package/dist/chunk-PRUIH5LI.js +0 -131
- package/dist/chunk-PRUIH5LI.js.map +0 -1
- package/dist/chunk-QLNJZDVF.js +0 -182
- package/dist/chunk-QLNJZDVF.js.map +0 -1
- package/dist/chunk-RVBTLB5G.cjs +0 -131
- package/dist/chunk-RVBTLB5G.cjs.map +0 -1
- package/dist/chunk-SJWL6EMI.js +0 -115
- package/dist/chunk-SJWL6EMI.js.map +0 -1
- package/dist/chunk-SW3NGBCE.cjs +0 -215
- package/dist/chunk-SW3NGBCE.cjs.map +0 -1
- package/dist/chunk-THDHNYP7.cjs +0 -219
- package/dist/chunk-THDHNYP7.cjs.map +0 -1
- package/dist/chunk-TTD3KL6E.cjs +0 -20
- package/dist/chunk-TTD3KL6E.cjs.map +0 -1
- package/dist/chunk-UB7CSOZU.js +0 -172
- package/dist/chunk-UB7CSOZU.js.map +0 -1
- package/dist/chunk-V3M7HL26.cjs +0 -137
- package/dist/chunk-V3M7HL26.cjs.map +0 -1
- package/dist/chunk-WXSISX5Y.cjs +0 -49
- package/dist/chunk-WXSISX5Y.cjs.map +0 -1
- package/dist/chunk-WYM6IAIJ.cjs +0 -292
- package/dist/chunk-WYM6IAIJ.cjs.map +0 -1
- package/dist/chunk-YYR23V5P.cjs +0 -165
- package/dist/chunk-YYR23V5P.cjs.map +0 -1
- package/dist/chunk-Z6QACVK7.cjs +0 -699
- package/dist/chunk-Z6QACVK7.cjs.map +0 -1
- package/dist/helpers/index.cjs.map +0 -1
- package/dist/helpers/index.js.map +0 -1
- package/dist/hooks/useFormContext/index.cjs.map +0 -1
- package/dist/hooks/useFormContext/index.js.map +0 -1
- package/dist/hooks/useInputValueDebounce/index.cjs.map +0 -1
- package/dist/hooks/useInputValueDebounce/index.js.map +0 -1
- package/dist/hooks/useUniformField/index.cjs.map +0 -1
- package/dist/hooks/useUniformField/index.js.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.cjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.js.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +0 -1
- package/dist/partials/FieldCopyTestIdButton/index.js.map +0 -1
- package/dist/partials/FieldValidationError/index.cjs.map +0 -1
- package/dist/partials/FieldValidationError/index.js.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { n as UserChangeListener, t as DebugModeSettings } from "./FormContext-Dl7KL_wl.cjs";
|
|
2
|
+
import * as react0 from "react";
|
|
3
|
+
import * as _fuf_stack_veto0 from "@fuf-stack/veto";
|
|
4
|
+
import { VetoFormattedError, VetoInstance } from "@fuf-stack/veto";
|
|
5
|
+
import * as react_hook_form9 from "react-hook-form";
|
|
6
|
+
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
7
|
+
|
|
8
|
+
//#region src/hooks/useFormContext/useFormContext.d.ts
|
|
9
|
+
/** Schema check whether a field is required or optional */
|
|
10
|
+
declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Custom hook that extends react-hook-form's useFormContext to add validation and state management.
|
|
13
|
+
*
|
|
14
|
+
* Key features:
|
|
15
|
+
* - Enhanced `getFieldState` that includes validation schema-based "required" status and testId generation
|
|
16
|
+
* - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:
|
|
17
|
+
* - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)
|
|
18
|
+
* - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)
|
|
19
|
+
* - Filters out empty/null values
|
|
20
|
+
*/
|
|
21
|
+
declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
|
|
22
|
+
formState: react_hook_form9.FormState<TFieldValues>;
|
|
23
|
+
getFieldState: (name: Path<TFieldValues>, testId?: string) => {
|
|
24
|
+
error: FieldError[] | undefined;
|
|
25
|
+
invalid: boolean;
|
|
26
|
+
required: boolean;
|
|
27
|
+
testId: string;
|
|
28
|
+
isDirty: boolean;
|
|
29
|
+
isTouched: boolean;
|
|
30
|
+
isValidating: boolean;
|
|
31
|
+
};
|
|
32
|
+
getValues: react_hook_form9.UseFormGetValues<TFieldValues>;
|
|
33
|
+
subscribe: react_hook_form9.UseFormSubscribe<TFieldValues>;
|
|
34
|
+
watch: react_hook_form9.UseFormWatch<TFieldValues>;
|
|
35
|
+
debugMode: "disabled" | "debug" | "debug-testids" | "off";
|
|
36
|
+
debugModeSettings?: DebugModeSettings;
|
|
37
|
+
preventSubmit: (prevent: boolean) => void;
|
|
38
|
+
setDebugMode: (debugMode: "disabled" | "debug" | "debug-testids" | "off") => void;
|
|
39
|
+
triggerSubmit: (e?: react0.BaseSyntheticEvent) => Promise<void> | void;
|
|
40
|
+
userChange: {
|
|
41
|
+
subscribe: (listener: UserChangeListener) => () => void;
|
|
42
|
+
notify: (fieldName: string, value: unknown) => void;
|
|
43
|
+
};
|
|
44
|
+
validation: {
|
|
45
|
+
baseInstance?: VetoInstance;
|
|
46
|
+
instance?: VetoInstance;
|
|
47
|
+
errors?: VetoFormattedError;
|
|
48
|
+
setClientValidationSchema: (key: string, schema: _fuf_stack_veto0.VetoTypeAny | null) => void;
|
|
49
|
+
};
|
|
50
|
+
setError: react_hook_form9.UseFormSetError<TFieldValues>;
|
|
51
|
+
clearErrors: react_hook_form9.UseFormClearErrors<TFieldValues>;
|
|
52
|
+
setValue: react_hook_form9.UseFormSetValue<TFieldValues>;
|
|
53
|
+
trigger: react_hook_form9.UseFormTrigger<TFieldValues>;
|
|
54
|
+
resetField: react_hook_form9.UseFormResetField<TFieldValues>;
|
|
55
|
+
reset: react_hook_form9.UseFormReset<TFieldValues>;
|
|
56
|
+
handleSubmit: react_hook_form9.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
|
|
57
|
+
unregister: react_hook_form9.UseFormUnregister<TFieldValues>;
|
|
58
|
+
control: react_hook_form9.Control<TFieldValues, TContext, TTransformedValues>;
|
|
59
|
+
register: react_hook_form9.UseFormRegister<TFieldValues>;
|
|
60
|
+
setFocus: react_hook_form9.UseFormSetFocus<TFieldValues>;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { useFormContext as n, checkFieldIsRequired as t };
|
|
64
|
+
//# sourceMappingURL=useFormContext-CZh7pv8f.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext-CZh7pv8f.d.cts","names":[],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAYa,mCACC;;;;;AADd;AAqEA;;;;;cAAa,sCACU,cAAc,kDAEd;EAwBa,SAAA,4BAAA,aAAA,CAAA;EAAL,aAAA,EAAA,CAAA,IAAA,EAAA,IAAA,CAAK,YAAL,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA,EAAA,GAAA;;;;;;;;;WAWO,mCAAA,aAAA,CAAA;EAAA,SAAA,mCAAA,aAAA,CAAA;EAAA,KAAA,+BAAA,aAAA,CAAA;EAyBpC,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA;EACyB,iBAAA,CAAA,mBAAA;EAAwE,aAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAAA,YAAA,EAAA,CAAA,SAAA,EAAA,UAAA,GAAA,OAAA,GAAA,eAAA,GAAA,KAAA,EAAA,GAAA,IAAA;6BA1B7D,uBAAA;;0BAAA;;;;mBAyBpC;eACyB;aAAwE;qDAAA,gBAAA,CAAA,WAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext-CkeSOfWD.cjs","names":[],"sources":["../src/hooks/useFormContext/index.ts"],"sourcesContent":["/* v8 ignore start */\n\nexport * from './useFormContext';\n\n/* v8 ignore stop */\n"],"mappings":""}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { o as toValidationFormat, r as nameToTestId, t as flatArrayKey } from "./helpers-B-CJOBt3.js";
|
|
2
|
+
import { n as UniformContext } from "./FormContext-CN9n_KdE.js";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useFormContext/useFormContext.ts
|
|
7
|
+
/** Schema check whether a field is required or optional */
|
|
8
|
+
const checkFieldIsRequired = (validation, path) => {
|
|
9
|
+
const checkPath = path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;
|
|
10
|
+
const checkRequired = (schema) => {
|
|
11
|
+
if (schema.type === "array") {
|
|
12
|
+
if (schema.isOptional || schema.isNullable) return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return !schema.isOptional && !schema.isNullable;
|
|
16
|
+
};
|
|
17
|
+
return validation.checkSchemaPath(checkRequired, checkPath);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolve validation errors for a given field path.
|
|
21
|
+
*
|
|
22
|
+
* Traverses a nested `VetoFormattedError` structure using a dotted path
|
|
23
|
+
* (for example: "user.address.0.street") and returns the matching
|
|
24
|
+
* `FieldError[]` if present. If no error exists at the path, returns
|
|
25
|
+
* `undefined`.
|
|
26
|
+
*
|
|
27
|
+
* @param errors - The formatted validation errors from Uniform's context
|
|
28
|
+
* @param name - The dotted field path to resolve
|
|
29
|
+
* @returns An array of `FieldError` entries for the field, or `undefined`
|
|
30
|
+
*/
|
|
31
|
+
const getValidationErrorsByName = (errors, name) => {
|
|
32
|
+
const keys = name.split(".").filter((k) => {
|
|
33
|
+
return k !== flatArrayKey;
|
|
34
|
+
});
|
|
35
|
+
let current = errors;
|
|
36
|
+
keys.forEach((key) => {
|
|
37
|
+
if (current && typeof current === "object") current = current[key];
|
|
38
|
+
else current = void 0;
|
|
39
|
+
});
|
|
40
|
+
return current;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Custom hook that extends react-hook-form's useFormContext to add validation and state management.
|
|
44
|
+
*
|
|
45
|
+
* Key features:
|
|
46
|
+
* - Enhanced `getFieldState` that includes validation schema-based "required" status and testId generation
|
|
47
|
+
* - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:
|
|
48
|
+
* - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)
|
|
49
|
+
* - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)
|
|
50
|
+
* - Filters out empty/null values
|
|
51
|
+
*/
|
|
52
|
+
const useFormContext$1 = () => {
|
|
53
|
+
const { formState, getFieldState: getFieldStateOrig, getValues: getValuesOrig, watch: watchOrig, subscribe: subscribeOrig, ...otherMethods } = useFormContext();
|
|
54
|
+
const uniformContext = useContext(UniformContext);
|
|
55
|
+
/**
|
|
56
|
+
* Updated getFieldState method which returns:
|
|
57
|
+
* - Whether the field is required by checking the validation schema
|
|
58
|
+
* - Existing field state information (errors, etc.)
|
|
59
|
+
* - A testId generated from the field name (with flat array keys removed and slugified)
|
|
60
|
+
*
|
|
61
|
+
* @param name - The field path (string or array)
|
|
62
|
+
* @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.
|
|
63
|
+
*/
|
|
64
|
+
const getFieldState = (name, testId) => {
|
|
65
|
+
const fieldPath = typeof name === "string" ? name.replace(/\[\d+\]/g, "").split(".") : name;
|
|
66
|
+
const validationInstance = uniformContext?.validation.baseInstance ?? uniformContext?.validation.instance;
|
|
67
|
+
const required = validationInstance ? checkFieldIsRequired(validationInstance, fieldPath) : false;
|
|
68
|
+
const error = getValidationErrorsByName(uniformContext?.validation.errors ?? {}, name);
|
|
69
|
+
return {
|
|
70
|
+
...getFieldStateOrig(name, formState),
|
|
71
|
+
error,
|
|
72
|
+
invalid: !!error,
|
|
73
|
+
required,
|
|
74
|
+
testId: nameToTestId(testId ?? name)
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Wrap form value accessor methods to automatically convert from internal storage format
|
|
79
|
+
* to component-friendly format:
|
|
80
|
+
*
|
|
81
|
+
* - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`
|
|
82
|
+
* - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`
|
|
83
|
+
* - Filter out empty/null values: fields with converted null/empty values are removed entirely
|
|
84
|
+
*
|
|
85
|
+
* This ensures components receive clean, predictable data without needing to handle
|
|
86
|
+
* the internal nullish string conversion system or flat array wrapping manually.
|
|
87
|
+
*/
|
|
88
|
+
const getValues = ((...args) => {
|
|
89
|
+
return toValidationFormat(getValuesOrig(...args));
|
|
90
|
+
});
|
|
91
|
+
const watch = ((...args) => {
|
|
92
|
+
return toValidationFormat(watchOrig(...args));
|
|
93
|
+
});
|
|
94
|
+
const subscribe = ((...args) => {
|
|
95
|
+
const [options] = args;
|
|
96
|
+
if (options?.callback) {
|
|
97
|
+
const originalCallback = options.callback;
|
|
98
|
+
return subscribeOrig({
|
|
99
|
+
...options,
|
|
100
|
+
callback: (subscribeFormState) => {
|
|
101
|
+
return originalCallback({
|
|
102
|
+
...subscribeFormState,
|
|
103
|
+
...subscribeFormState.values && { values: toValidationFormat(subscribeFormState.values) }
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return subscribeOrig(...args);
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
...otherMethods,
|
|
112
|
+
...uniformContext,
|
|
113
|
+
formState,
|
|
114
|
+
getFieldState,
|
|
115
|
+
getValues,
|
|
116
|
+
subscribe,
|
|
117
|
+
watch
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { useFormContext$1 as n, checkFieldIsRequired as t };
|
|
123
|
+
//# sourceMappingURL=useFormContext-JCm1UR_e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormContext-JCm1UR_e.js","names":["current: unknown","useFormContext","useHookFormContext"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors as unknown;\n keys.forEach((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n } else {\n current = undefined;\n }\n });\n return current as FieldError[] | undefined;\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>() => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n ) as unknown as FieldError[] | undefined;\n\n // Get everything but the error from the original field state\n const fieldState = getFieldStateOrig(name, formState);\n\n return {\n ...fieldState,\n error,\n invalid: !!error,\n required,\n testId: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;;AAYA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAO,eAAe,KAAK,MAAM,GAAG,GAAG,GAAG;CAE/D,MAAM,iBAAiB,WAAgB;AAErC,MAAI,OAAO,SAAS,SAAS;AAE3B,OAAI,OAAO,cAAc,OAAO,WAC9B,QAAO;AAGT,UAAO;;AAKT,SAAO,CAAC,OAAO,cAAc,CAAC,OAAO;;AAGvC,QAAO,WAAW,gBAAgB,eAAe,UAAU;;;;;;;;;;;;;;AAe7D,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,MAAM;AACzC,SAAO,MAAM;GACb;CACF,IAAIA,UAAmB;AACvB,MAAK,SAAS,QAAQ;AACpB,MAAI,WAAW,OAAO,YAAY,SAChC,WAAW,QAAoC;MAE/C,WAAU;GAEZ;AACF,QAAO;;;;;;;;;;;;AAaT,MAAaC,yBAIN;CACL,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eAEX,GAAG,iBACDC,gBAAgE;CAEpE,MAAM,iBAAiB,WAAW,eAAe;;;;;;;;;;CAWjD,MAAM,iBAAiB,MAA0B,WAAoB;EACnE,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,UAAU,GACnD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,EAAE,EACvC,KACD;AAKD,SAAO;GACL,GAHiB,kBAAkB,MAAM,UAAU;GAInD;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQ,aAAa,UAAU,KAAK;GACrC;;;;;;;;;;;;;CAcH,MAAM,cAAc,GAAG,SAAgB;AAErC,SAAO,mBADS,cAAsB,GAAG,KAAK,CACb;;CAGnC,MAAM,UAAU,GAAG,SAAgB;AAEjC,SAAO,mBADS,UAAkB,GAAG,KAAK,CACT;;CAGnC,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;AAClB,MAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;AAejC,UAAO,cAdgB;IACrB,GAAG;IACH,WAAW,uBAA4B;AASrC,YAAO,iBAPoB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQ,mBAAmB,mBAAmB,OAAO,EACtD;MACF,CAE0C;;IAE9C,CACmC;;AAGtC,SAAQ,cAAsB,GAAG,KAAK;;AAGxC,QAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.d.ts
|
|
2
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
3
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
4
|
+
debounceDelay?: number;
|
|
5
|
+
/** The onBlur function to call after flushing debounced value */
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
/** The onChange function to call with debounced value */
|
|
8
|
+
onChange: (...event: any[]) => void;
|
|
9
|
+
/** The field value */
|
|
10
|
+
value: TValue;
|
|
11
|
+
}
|
|
12
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
13
|
+
/** Enhanced onChange function with debouncing */
|
|
14
|
+
onChange: (...event: any[]) => void;
|
|
15
|
+
/** Enhanced onBlur function that flushes current value immediately */
|
|
16
|
+
onBlur: () => void;
|
|
17
|
+
/** The field value that is displayed - updates immediately */
|
|
18
|
+
value: TValue;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
22
|
+
*
|
|
23
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
24
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
25
|
+
* any pending debounced changes are immediately flushed.
|
|
26
|
+
*
|
|
27
|
+
* **Key Features:**
|
|
28
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
29
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
30
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
31
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
32
|
+
*
|
|
33
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
34
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
35
|
+
*
|
|
36
|
+
* @param options Configuration for debounced value handling
|
|
37
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
38
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
39
|
+
* @param options.onChange Function to call with debounced value
|
|
40
|
+
* @param options.value The field value
|
|
41
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* Basic usage with debouncing:
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
47
|
+
* debounceDelay: 300,
|
|
48
|
+
* onBlur: field.onBlur,
|
|
49
|
+
* onChange: field.onChange,
|
|
50
|
+
* value: field.value,
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const useInputValueDebounce: <TValue = unknown>({
|
|
55
|
+
debounceDelay,
|
|
56
|
+
onBlur,
|
|
57
|
+
onChange,
|
|
58
|
+
value
|
|
59
|
+
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { UseInputValueDebounceReturn as n, useInputValueDebounce as r, UseInputValueDebounceOptions as t };
|
|
62
|
+
//# sourceMappingURL=useInputValueDebounce-B2RzCWty.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-B2RzCWty.d.cts","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAYA,aAAA,CAAA,EAAA,MAAA;EA4CJ;EAA2C,MAAA,EAAA,GAAA,GAAA,IAAA;EAAA;EAAA,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;EAAA;EAKxB,KAAA,EApDvB,MAoDuB;;AAAsC,UAjDrD,2BAiDqD,CAAA,SAAA,OAAA,CAAA,CAAA;EAA5B;EAA2B,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;;;;SA1C5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCI;;;;;GAKV,6BAA6B,YAAU,4BAA4B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.d.ts
|
|
2
|
+
interface UseInputValueDebounceOptions<TValue = unknown> {
|
|
3
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
4
|
+
debounceDelay?: number;
|
|
5
|
+
/** The onBlur function to call after flushing debounced value */
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
/** The onChange function to call with debounced value */
|
|
8
|
+
onChange: (...event: any[]) => void;
|
|
9
|
+
/** The field value */
|
|
10
|
+
value: TValue;
|
|
11
|
+
}
|
|
12
|
+
interface UseInputValueDebounceReturn<TValue = unknown> {
|
|
13
|
+
/** Enhanced onChange function with debouncing */
|
|
14
|
+
onChange: (...event: any[]) => void;
|
|
15
|
+
/** Enhanced onBlur function that flushes current value immediately */
|
|
16
|
+
onBlur: () => void;
|
|
17
|
+
/** The field value that is displayed - updates immediately */
|
|
18
|
+
value: TValue;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
22
|
+
*
|
|
23
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
24
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
25
|
+
* any pending debounced changes are immediately flushed.
|
|
26
|
+
*
|
|
27
|
+
* **Key Features:**
|
|
28
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
29
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
30
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
31
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
32
|
+
*
|
|
33
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
34
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
35
|
+
*
|
|
36
|
+
* @param options Configuration for debounced value handling
|
|
37
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
38
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
39
|
+
* @param options.onChange Function to call with debounced value
|
|
40
|
+
* @param options.value The field value
|
|
41
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* Basic usage with debouncing:
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
47
|
+
* debounceDelay: 300,
|
|
48
|
+
* onBlur: field.onBlur,
|
|
49
|
+
* onChange: field.onChange,
|
|
50
|
+
* value: field.value,
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const useInputValueDebounce: <TValue = unknown>({
|
|
55
|
+
debounceDelay,
|
|
56
|
+
onBlur,
|
|
57
|
+
onChange,
|
|
58
|
+
value
|
|
59
|
+
}: UseInputValueDebounceOptions<TValue>) => UseInputValueDebounceReturn<TValue>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { UseInputValueDebounceReturn as n, useInputValueDebounce as r, UseInputValueDebounceOptions as t };
|
|
62
|
+
//# sourceMappingURL=useInputValueDebounce-C7_bvNGH.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-C7_bvNGH.d.ts","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts"],"sourcesContent":[],"mappings":";UAEiB;EAAA;EAYA,aAAA,CAAA,EAAA,MAAA;EA4CJ;EAA2C,MAAA,EAAA,GAAA,GAAA,IAAA;EAAA;EAAA,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;EAAA;EAKxB,KAAA,EApDvB,MAoDuB;;AAAsC,UAjDrD,2BAiDqD,CAAA,SAAA,OAAA,CAAA,CAAA;EAA5B;EAA2B,QAAA,EAAA,CAAA,GAAA,KAAA,EAAA,GAAA,EAAA,EAAA,GAAA,IAAA;;;;SA1C5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqCI;;;;;GAKV,6BAA6B,YAAU,4BAA4B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
6
|
+
*
|
|
7
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
8
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
9
|
+
* any pending debounced changes are immediately flushed.
|
|
10
|
+
*
|
|
11
|
+
* **Key Features:**
|
|
12
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
13
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
14
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
15
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
16
|
+
*
|
|
17
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
18
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
19
|
+
*
|
|
20
|
+
* @param options Configuration for debounced value handling
|
|
21
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
22
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
23
|
+
* @param options.onChange Function to call with debounced value
|
|
24
|
+
* @param options.value The field value
|
|
25
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* Basic usage with debouncing:
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
31
|
+
* debounceDelay: 300,
|
|
32
|
+
* onBlur: field.onBlur,
|
|
33
|
+
* onChange: field.onChange,
|
|
34
|
+
* value: field.value,
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const useInputValueDebounce = ({ debounceDelay = 300, onBlur, onChange, value }) => {
|
|
39
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
40
|
+
const timeoutRef = useRef(null);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
setCurrentValue(value);
|
|
43
|
+
}, [value]);
|
|
44
|
+
return {
|
|
45
|
+
onChange: useCallback((...event) => {
|
|
46
|
+
const newValue = event[0]?.target?.value ?? event[0];
|
|
47
|
+
setCurrentValue(newValue);
|
|
48
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
49
|
+
const executeOnChange = () => {
|
|
50
|
+
if (event[0]?.target) onChange({
|
|
51
|
+
...event[0],
|
|
52
|
+
target: {
|
|
53
|
+
...event[0].target,
|
|
54
|
+
value: newValue
|
|
55
|
+
}
|
|
56
|
+
}, ...event.slice(1));
|
|
57
|
+
else onChange(newValue);
|
|
58
|
+
};
|
|
59
|
+
if (debounceDelay <= 0) executeOnChange();
|
|
60
|
+
else timeoutRef.current = setTimeout(executeOnChange, debounceDelay);
|
|
61
|
+
}, [onChange, debounceDelay]),
|
|
62
|
+
onBlur: useCallback(() => {
|
|
63
|
+
if (timeoutRef.current) {
|
|
64
|
+
clearTimeout(timeoutRef.current);
|
|
65
|
+
timeoutRef.current = null;
|
|
66
|
+
onChange(currentValue);
|
|
67
|
+
}
|
|
68
|
+
onBlur();
|
|
69
|
+
}, [
|
|
70
|
+
onChange,
|
|
71
|
+
onBlur,
|
|
72
|
+
currentValue
|
|
73
|
+
]),
|
|
74
|
+
value: currentValue
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/hooks/useInputValueDebounce/index.ts
|
|
80
|
+
/* v8 ignore stop */
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { useInputValueDebounce as t };
|
|
84
|
+
//# sourceMappingURL=useInputValueDebounce-DaH5ONlQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-DaH5ONlQ.js","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,QACA,UACA,YAC+E;CAE/E,MAAM,CAAC,cAAc,mBAAmB,SAAiB,MAAM;CAE/D,MAAM,aAAa,OAA8B,KAAK;AAGtD,iBAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAoDX,QAAO;EACL,UAlDmB,aAElB,GAAG,UAAiB;GAEnB,MAAM,WAAY,MAAM,IAAI,QAAQ,SAAS,MAAM;AACnD,mBAAgB,SAAS;AAGzB,OAAI,WAAW,QACb,cAAa,WAAW,QAAQ;GAGlC,MAAM,wBAAwB;AAE5B,QAAI,MAAM,IAAI,OAQZ,UAPuB;KACrB,GAAG,MAAM;KACT,QAAQ;MACN,GAAG,MAAM,GAAG;MACZ,OAAO;MACR;KACF,EACwB,GAAG,MAAM,MAAM,EAAE,CAAC;QAE3C,UAAS,SAAS;;AAKtB,OAAI,iBAAiB,EACnB,kBAAiB;OAEjB,YAAW,UAAU,WAAW,iBAAiB,cAAc;KAGnE,CAAC,UAAU,cAAc,CAC1B;EAeC,QAZiB,kBAAkB;AAEnC,OAAI,WAAW,SAAS;AACtB,iBAAa,WAAW,QAAQ;AAChC,eAAW,UAAU;AACrB,aAAS,aAAa;;AAExB,WAAQ;KACP;GAAC;GAAU;GAAQ;GAAa,CAAC;EAKlC,OAAO;EACR"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const require_FormContext = require('./FormContext-C3GymQOA.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useInputValueDebounce/useInputValueDebounce.ts
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook for debouncing value changes with immediate blur support.
|
|
7
|
+
*
|
|
8
|
+
* Provides immediate visual feedback by updating the value instantly,
|
|
9
|
+
* while debouncing the actual onChange calls. When focus is lost,
|
|
10
|
+
* any pending debounced changes are immediately flushed.
|
|
11
|
+
*
|
|
12
|
+
* **Key Features:**
|
|
13
|
+
* - **Debouncing**: Delays onChange calls until user stops typing
|
|
14
|
+
* - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)
|
|
15
|
+
* - **Immediate value updates**: UI stays responsive during debouncing
|
|
16
|
+
* - **Blur flushing**: Immediately applies pending changes on blur
|
|
17
|
+
*
|
|
18
|
+
* **Note:** Value transformations should be handled at the `useUniformField` level,
|
|
19
|
+
* not in this hook. This hook only handles debouncing timing.
|
|
20
|
+
*
|
|
21
|
+
* @param options Configuration for debounced value handling
|
|
22
|
+
* @param options.debounceDelay Delay in milliseconds (default: 300)
|
|
23
|
+
* @param options.onBlur Function to call after flushing debounced value
|
|
24
|
+
* @param options.onChange Function to call with debounced value
|
|
25
|
+
* @param options.value The field value
|
|
26
|
+
* @returns Object containing enhanced onChange, onBlur, and immediate value
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* Basic usage with debouncing:
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { onChange, onBlur, value } = useInputValueDebounce({
|
|
32
|
+
* debounceDelay: 300,
|
|
33
|
+
* onBlur: field.onBlur,
|
|
34
|
+
* onChange: field.onChange,
|
|
35
|
+
* value: field.value,
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
const useInputValueDebounce = ({ debounceDelay = 300, onBlur, onChange, value }) => {
|
|
40
|
+
const [currentValue, setCurrentValue] = (0, react.useState)(value);
|
|
41
|
+
const timeoutRef = (0, react.useRef)(null);
|
|
42
|
+
(0, react.useEffect)(() => {
|
|
43
|
+
setCurrentValue(value);
|
|
44
|
+
}, [value]);
|
|
45
|
+
return {
|
|
46
|
+
onChange: (0, react.useCallback)((...event) => {
|
|
47
|
+
const newValue = event[0]?.target?.value ?? event[0];
|
|
48
|
+
setCurrentValue(newValue);
|
|
49
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
50
|
+
const executeOnChange = () => {
|
|
51
|
+
if (event[0]?.target) onChange({
|
|
52
|
+
...event[0],
|
|
53
|
+
target: {
|
|
54
|
+
...event[0].target,
|
|
55
|
+
value: newValue
|
|
56
|
+
}
|
|
57
|
+
}, ...event.slice(1));
|
|
58
|
+
else onChange(newValue);
|
|
59
|
+
};
|
|
60
|
+
if (debounceDelay <= 0) executeOnChange();
|
|
61
|
+
else timeoutRef.current = setTimeout(executeOnChange, debounceDelay);
|
|
62
|
+
}, [onChange, debounceDelay]),
|
|
63
|
+
onBlur: (0, react.useCallback)(() => {
|
|
64
|
+
if (timeoutRef.current) {
|
|
65
|
+
clearTimeout(timeoutRef.current);
|
|
66
|
+
timeoutRef.current = null;
|
|
67
|
+
onChange(currentValue);
|
|
68
|
+
}
|
|
69
|
+
onBlur();
|
|
70
|
+
}, [
|
|
71
|
+
onChange,
|
|
72
|
+
onBlur,
|
|
73
|
+
currentValue
|
|
74
|
+
]),
|
|
75
|
+
value: currentValue
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/hooks/useInputValueDebounce/index.ts
|
|
81
|
+
/* v8 ignore stop */
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
Object.defineProperty(exports, 'useInputValueDebounce', {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return useInputValueDebounce;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=useInputValueDebounce-tL8maIp8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputValueDebounce-tL8maIp8.cjs","names":[],"sources":["../src/hooks/useInputValueDebounce/useInputValueDebounce.ts","../src/hooks/useInputValueDebounce/index.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseInputValueDebounceOptions<TValue = unknown> {\n /** Debounce delay in milliseconds (default: 300) */\n debounceDelay?: number;\n /** The onBlur function to call after flushing debounced value */\n onBlur: () => void;\n /** The onChange function to call with debounced value */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** The field value */\n value: TValue;\n}\n\nexport interface UseInputValueDebounceReturn<TValue = unknown> {\n /** Enhanced onChange function with debouncing */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n /** Enhanced onBlur function that flushes current value immediately */\n onBlur: () => void;\n /** The field value that is displayed - updates immediately */\n value: TValue;\n}\n\n/**\n * Custom hook for debouncing value changes with immediate blur support.\n *\n * Provides immediate visual feedback by updating the value instantly,\n * while debouncing the actual onChange calls. When focus is lost,\n * any pending debounced changes are immediately flushed.\n *\n * **Key Features:**\n * - **Debouncing**: Delays onChange calls until user stops typing\n * - **Generic type support**: Works with any data type (strings, numbers, arrays, objects)\n * - **Immediate value updates**: UI stays responsive during debouncing\n * - **Blur flushing**: Immediately applies pending changes on blur\n *\n * **Note:** Value transformations should be handled at the `useUniformField` level,\n * not in this hook. This hook only handles debouncing timing.\n *\n * @param options Configuration for debounced value handling\n * @param options.debounceDelay Delay in milliseconds (default: 300)\n * @param options.onBlur Function to call after flushing debounced value\n * @param options.onChange Function to call with debounced value\n * @param options.value The field value\n * @returns Object containing enhanced onChange, onBlur, and immediate value\n *\n * @example\n * Basic usage with debouncing:\n * ```tsx\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * debounceDelay: 300,\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n * ```\n */\nexport const useInputValueDebounce = <TValue = unknown>({\n debounceDelay = 300,\n onBlur,\n onChange,\n value,\n}: UseInputValueDebounceOptions<TValue>): UseInputValueDebounceReturn<TValue> => {\n // Track value for synchronous updates\n const [currentValue, setCurrentValue] = useState<TValue>(value);\n\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Sync with external value changes\n useEffect(() => {\n setCurrentValue(value);\n }, [value]);\n\n // Enhanced onChange handler with debouncing\n const handleChange = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (...event: any[]) => {\n // Extract the raw value\n const newValue = (event[0]?.target?.value ?? event[0]) as TValue;\n setCurrentValue(newValue);\n\n // Clear existing timeout\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n const executeOnChange = () => {\n // Preserve event structure if original was an event\n if (event[0]?.target) {\n const convertedEvent = {\n ...event[0],\n target: {\n ...event[0].target,\n value: newValue,\n },\n };\n onChange(convertedEvent, ...event.slice(1));\n } else {\n onChange(newValue);\n }\n };\n\n // Execute immediately or after delay\n if (debounceDelay <= 0) {\n executeOnChange();\n } else {\n timeoutRef.current = setTimeout(executeOnChange, debounceDelay);\n }\n },\n [onChange, debounceDelay],\n );\n\n // Enhanced blur handler\n const handleBlur = useCallback(() => {\n // Flush pending changes\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n onChange(currentValue);\n }\n onBlur();\n }, [onChange, onBlur, currentValue]);\n\n return {\n onChange: handleChange,\n onBlur: handleBlur,\n value: currentValue,\n };\n};\n","/* v8 ignore start */\n\nexport * from './useInputValueDebounce';\n\n/* v8 ignore stop */\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,yBAA2C,EACtD,gBAAgB,KAChB,QACA,UACA,YAC+E;CAE/E,MAAM,CAAC,cAAc,uCAAoC,MAAM;CAE/D,MAAM,+BAA2C,KAAK;AAGtD,4BAAgB;AACd,kBAAgB,MAAM;IACrB,CAAC,MAAM,CAAC;AAoDX,QAAO;EACL,kCAhDC,GAAG,UAAiB;GAEnB,MAAM,WAAY,MAAM,IAAI,QAAQ,SAAS,MAAM;AACnD,mBAAgB,SAAS;AAGzB,OAAI,WAAW,QACb,cAAa,WAAW,QAAQ;GAGlC,MAAM,wBAAwB;AAE5B,QAAI,MAAM,IAAI,OAQZ,UAPuB;KACrB,GAAG,MAAM;KACT,QAAQ;MACN,GAAG,MAAM,GAAG;MACZ,OAAO;MACR;KACF,EACwB,GAAG,MAAM,MAAM,EAAE,CAAC;QAE3C,UAAS,SAAS;;AAKtB,OAAI,iBAAiB,EACnB,kBAAiB;OAEjB,YAAW,UAAU,WAAW,iBAAiB,cAAc;KAGnE,CAAC,UAAU,cAAc,CAC1B;EAeC,qCAZmC;AAEnC,OAAI,WAAW,SAAS;AACtB,iBAAa,WAAW,QAAQ;AAChC,eAAW,UAAU;AACrB,aAAS,aAAa;;AAExB,WAAQ;KACP;GAAC;GAAU;GAAQ;GAAa,CAAC;EAKlC,OAAO;EACR"}
|