@ssplib/react-components 0.0.253 → 0.0.255

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,9 +1,11 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { FieldValues } from 'react-hook-form';
3
3
  import type { FilesID } from '../../types/form';
4
- export default function FormProvider({ children, onSubmit, formMethod, submiting, }: {
4
+ interface FormProviderProps<T extends FieldValues> {
5
5
  children: ReactElement | ReactElement[];
6
- onSubmit: (data: FieldValues, filesUid: FilesID) => void;
6
+ onSubmit: (data: T, filesUid: FilesID) => void;
7
7
  formMethod?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'UPDATE';
8
8
  submiting?: boolean;
9
- }): JSX.Element;
9
+ }
10
+ export default function FormProvider<T extends FieldValues>({ children, onSubmit, formMethod, submiting }: FormProviderProps<T>): JSX.Element;
11
+ export {};
@@ -27,7 +27,7 @@ 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
  const react_toastify_1 = require("react-toastify");
30
- function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = false, }) {
30
+ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = false }) {
31
31
  const { register, handleSubmit, control, formState: { errors }, reset, watch, trigger, setValue, unregister, getValues, } = (0, react_hook_form_1.useForm)();
32
32
  const [filesUid, setFilesUid] = (0, react_1.useState)([]);
33
33
  return (react_1.default.createElement(form_1.FormContext.Provider, { value: {
@@ -44,6 +44,10 @@ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = fals
44
44
  errors: errors,
45
45
  submiting: submiting,
46
46
  } },
47
- react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d, filesUid), (d) => (0, react_toastify_1.toast)('Formulário incompleto! Verifique os campos marcados e tente novamente.', { type: 'warning', position: 'top-right', theme: 'colored' })) }, children)));
47
+ react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((data) => onSubmit(data, filesUid), () => (0, react_toastify_1.toast)('Formulário incompleto! Verifique os campos marcados e tente novamente.', {
48
+ type: 'warning',
49
+ position: 'top-right',
50
+ theme: 'colored',
51
+ })) }, children)));
48
52
  }
49
53
  exports.default = FormProvider;
@@ -71,7 +71,8 @@ function KeycloakAuthProvider({ url, realm, clientId, children, type = 'ad', res
71
71
  }
72
72
  }, () => {
73
73
  console.error('Authenticated Failed');
74
- });
74
+ })
75
+ .catch((err) => console.log(err));
75
76
  const s = router.query['status'];
76
77
  if (!s)
77
78
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.253",
3
+ "version": "0.0.255",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",