@aatulwork/customform-renderer 1.6.0 → 1.8.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/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1552,9 +1552,11 @@ var FormRenderer = ({
|
|
|
1552
1552
|
control,
|
|
1553
1553
|
handleSubmit,
|
|
1554
1554
|
reset,
|
|
1555
|
+
resetField,
|
|
1555
1556
|
clearErrors,
|
|
1556
1557
|
setValue,
|
|
1557
1558
|
setError,
|
|
1559
|
+
getValues,
|
|
1558
1560
|
formState: { errors }
|
|
1559
1561
|
} = useForm({
|
|
1560
1562
|
defaultValues: initialValues || {}
|
|
@@ -1608,11 +1610,26 @@ var FormRenderer = ({
|
|
|
1608
1610
|
if (onSubmit) {
|
|
1609
1611
|
try {
|
|
1610
1612
|
await onSubmit(transformedData);
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1613
|
+
const resetValues = initialValues || {};
|
|
1614
|
+
const allFields = getAllFields(formSchema);
|
|
1615
|
+
clearErrors();
|
|
1616
|
+
allFields.forEach((field) => {
|
|
1617
|
+
const fieldValue = resetValues[field.name] ?? (field.type === "checkbox" ? false : "");
|
|
1618
|
+
resetField(field.name, {
|
|
1619
|
+
defaultValue: fieldValue,
|
|
1620
|
+
keepError: false,
|
|
1621
|
+
keepDirty: false,
|
|
1622
|
+
keepTouched: false
|
|
1623
|
+
});
|
|
1624
|
+
});
|
|
1625
|
+
reset(resetValues, {
|
|
1626
|
+
keepErrors: false,
|
|
1627
|
+
keepDirty: false,
|
|
1628
|
+
keepTouched: false,
|
|
1629
|
+
keepIsSubmitted: false,
|
|
1630
|
+
keepSubmitCount: false
|
|
1631
|
+
});
|
|
1632
|
+
if (onSuccess) onSuccess();
|
|
1616
1633
|
} catch (error) {
|
|
1617
1634
|
console.error("Form submission error:", error);
|
|
1618
1635
|
let errorMessage = "Form submission failed. Please try again.";
|