hrm_ui_lib 2.5.10 → 2.5.11

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,12 +1,13 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createElement as _createElement } from "react";
3
+ import { useEffect } from 'react';
3
4
  import { useForm } from 'react-hook-form';
4
5
  import { yupResolver } from '@hookform/resolvers/yup';
5
6
  import classnames from 'classnames';
6
7
  import { FormContext } from '../../context';
7
8
  import { Button } from '../Button';
8
9
  export const FormContainer = (props) => {
9
- const { children, className = '', shouldUnregister, shouldFocusError = true, mode = 'onBlur', initialValues, validationScheme, buttonConfigs, formId, onSubmit } = props;
10
+ const { children, className = '', shouldUnregister, shouldFocusError = true, mode = 'onBlur', initialValues, validationScheme, buttonConfigs, formId, language, onSubmit } = props;
10
11
  const { handleSubmit, register, setValue, control, formState, getValues, watch, reset, clearErrors, setError, trigger, getFieldState, unregister } = useForm({
11
12
  mode: mode,
12
13
  resolver: yupResolver(validationScheme),
@@ -20,6 +21,14 @@ export const FormContainer = (props) => {
20
21
  onSubmit(data, formState, dirtyFields);
21
22
  }
22
23
  };
24
+ useEffect(() => {
25
+ if (formState.isSubmitted) {
26
+ const fieldsWithErrors = Object.keys(formState.errors);
27
+ if (fieldsWithErrors.length > 0) {
28
+ trigger(fieldsWithErrors); // only revalidate fields that have errors
29
+ }
30
+ }
31
+ }, [language]);
23
32
  return (_jsx("form", { onSubmit: handleSubmit(customSubmit), id: formId, className: classnames('form-container', className), children: _jsx(FormContext.Provider, { value: {
24
33
  trigger,
25
34
  register,
@@ -18,4 +18,5 @@ export interface FormPropTypes {
18
18
  mode?: keyof ValidationMode;
19
19
  reValidateMode?: 'onChange' | 'onSubmit' | 'onBlur' | undefined;
20
20
  formId?: string;
21
+ language?: string;
21
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "2.5.10",
3
+ "version": "2.5.11",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",