@ssplib/react-components 0.0.37 → 0.0.38
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.
|
@@ -3,7 +3,7 @@ import { FieldValues } from 'react-hook-form';
|
|
|
3
3
|
import type { FilesID } from '../../types/form';
|
|
4
4
|
export default function FormProvider({ children, onSubmit, formMethod, submiting, }: {
|
|
5
5
|
children: ReactElement | ReactElement[];
|
|
6
|
-
onSubmit: (data: FieldValues, filesUid
|
|
6
|
+
onSubmit: (data: FieldValues, filesUid: FilesID) => void;
|
|
7
7
|
formMethod?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'UPDATE';
|
|
8
8
|
submiting?: boolean;
|
|
9
9
|
}): JSX.Element;
|
|
@@ -28,7 +28,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
28
28
|
const form_1 = require("../../context/form");
|
|
29
29
|
function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = false, }) {
|
|
30
30
|
const { register, handleSubmit, formState: { errors }, reset, watch, trigger, setValue, unregister, getValues, } = (0, react_hook_form_1.useForm)();
|
|
31
|
-
const [
|
|
31
|
+
const [filesUid, setFilesUid] = (0, react_1.useState)([]);
|
|
32
32
|
return (react_1.default.createElement(form_1.FormContext.Provider, { value: {
|
|
33
33
|
formRegister: register,
|
|
34
34
|
formWatch: watch,
|
|
@@ -42,6 +42,6 @@ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = fals
|
|
|
42
42
|
errors: errors,
|
|
43
43
|
submiting: submiting,
|
|
44
44
|
} },
|
|
45
|
-
react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d,
|
|
45
|
+
react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d, filesUid)) }, children)));
|
|
46
46
|
}
|
|
47
47
|
exports.default = FormProvider;
|