@ssplib/react-components 0.0.87 → 0.0.89
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.
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function FileUpload({ name, tipoArquivo, title, required, multiple, apiURL, xs, sm, md,
|
|
2
|
+
export default function FileUpload({ name, tipoArquivo, title, required, multiple, apiURL, xs, sm, md, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
tipoArquivo: string;
|
|
5
|
-
clientDelete?: boolean;
|
|
6
5
|
title: string;
|
|
7
6
|
apiURL: string;
|
|
8
7
|
required?: boolean;
|
|
@@ -38,7 +38,7 @@ const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const auth_1 = require("../../../context/auth");
|
|
40
40
|
const form_1 = require("../../../context/form");
|
|
41
|
-
function FileUpload({ name, tipoArquivo, title, required = false, multiple = false, apiURL, xs = 12, sm, md,
|
|
41
|
+
function FileUpload({ name, tipoArquivo, title, required = false, multiple = false, apiURL, xs = 12, sm, md, }) {
|
|
42
42
|
const context = (0, react_1.useContext)(form_1.FormContext);
|
|
43
43
|
const { user } = (0, react_1.useContext)(auth_1.AuthContext);
|
|
44
44
|
const [files, setFiles] = (0, react_1.useState)([]);
|
|
@@ -88,8 +88,8 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
88
88
|
}),
|
|
89
89
|
]);
|
|
90
90
|
}, [files, context]);
|
|
91
|
-
const deleteFile = (
|
|
92
|
-
if (
|
|
91
|
+
const deleteFile = (e, id) => {
|
|
92
|
+
if (filesError.includes(id)) {
|
|
93
93
|
setFiles(files.filter((x) => x.id !== id));
|
|
94
94
|
context.setFilesUid((fId) => fId.filter((idd) => idd.CO_SEQ_ARQUIVO !== id));
|
|
95
95
|
return;
|
|
@@ -107,7 +107,7 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
}
|
|
110
|
+
};
|
|
111
111
|
(0, react_1.useEffect)(() => {
|
|
112
112
|
const dt = new DataTransfer();
|
|
113
113
|
files.forEach((x) => {
|
|
@@ -27,12 +27,13 @@ const react_1 = __importStar(require("react"));
|
|
|
27
27
|
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
|
-
const { register, handleSubmit, formState: { errors }, reset, watch, trigger, setValue, unregister, getValues, } = (0, react_hook_form_1.useForm)();
|
|
30
|
+
const { register, handleSubmit, control, formState: { errors }, reset, watch, trigger, setValue, unregister, getValues, } = (0, react_hook_form_1.useForm)();
|
|
31
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,
|
|
35
35
|
formReset: reset,
|
|
36
|
+
formControl: control,
|
|
36
37
|
formSetValue: setValue,
|
|
37
38
|
formTrigger: trigger,
|
|
38
39
|
formUnregister: unregister,
|
package/context/form.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { FieldErrors, FieldValues, UseFormRegister, UseFormReset, UseFormSetValue, UseFormTrigger, UseFormWatch } from 'react-hook-form';
|
|
3
|
-
import { UseFormGetValues, UseFormHandleSubmit, UseFormUnregister } from 'react-hook-form/dist/types';
|
|
3
|
+
import { Control, UseFormGetValues, UseFormHandleSubmit, UseFormUnregister } from 'react-hook-form/dist/types';
|
|
4
4
|
export declare const FormContext: import("react").Context<{
|
|
5
5
|
formRegister: UseFormRegister<FieldValues>;
|
|
6
6
|
formWatch: UseFormWatch<FieldValues>;
|
|
7
7
|
formReset: UseFormReset<FieldValues>;
|
|
8
8
|
formSetValue: UseFormSetValue<FieldValues>;
|
|
9
|
+
formControl: Control<FieldValues, any>;
|
|
9
10
|
formTrigger: UseFormTrigger<FieldValues>;
|
|
10
11
|
formUnregister: UseFormUnregister<FieldValues>;
|
|
11
12
|
formHandleSubmit: UseFormHandleSubmit<FieldValues>;
|
package/package.json
CHANGED
package/types/form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { FieldErrors, FieldValues, UseFormGetValues, UseFormRegister, UseFormReset, UseFormSetValue, UseFormTrigger, UseFormUnregister, UseFormWatch } from 'react-hook-form';
|
|
2
|
+
import { Control, FieldErrors, FieldValues, UseFormGetValues, UseFormRegister, UseFormReset, UseFormSetValue, UseFormTrigger, UseFormUnregister, UseFormWatch } from 'react-hook-form';
|
|
3
3
|
export declare enum FieldType {
|
|
4
4
|
INPUT = 0,
|
|
5
5
|
MULT_INPUT = 1,
|
|
@@ -46,6 +46,7 @@ export interface FormContextType {
|
|
|
46
46
|
formRegister: UseFormRegister<FieldValues>;
|
|
47
47
|
formWatch: UseFormWatch<FieldValues>;
|
|
48
48
|
formReset: UseFormReset<FieldValues>;
|
|
49
|
+
formControl: Control<FieldValues, any>;
|
|
49
50
|
formSetValue: UseFormSetValue<FieldValues>;
|
|
50
51
|
formTrigger: UseFormTrigger<FieldValues>;
|
|
51
52
|
formUnregister: UseFormUnregister<FieldValues>;
|