hrm_ui_lib 2.0.0-alpha.12 → 2.0.0-alpha.14

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,11 +1,10 @@
1
1
  import _extends from '@babel/runtime/helpers/extends';
2
- import React, { useMemo, useEffect } from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  import { useForm } from 'react-hook-form';
4
4
  import { yupResolver } from '@hookform/resolvers/yup';
5
5
  import classNames from 'classnames';
6
6
  import { FormContext } from '../../context/types.js';
7
7
  import { B as Button } from '../../Alert--0rz5XL1.js';
8
- import instance from '../../i18n.js';
9
8
  import '../../utils/helpers.js';
10
9
  import 'dayjs';
11
10
  import '../Alert/consts.js';
@@ -55,8 +54,6 @@ import '../Progress/Progress.js';
55
54
  import '../SVGIcons/IconArrowDownloadFilled.js';
56
55
  import '../../helpers/download-file.js';
57
56
  import '../Button/consts.js';
58
- import '@babel/runtime/helpers/asyncToGenerator';
59
- import '@babel/runtime/regenerator';
60
57
 
61
58
  var FormContainer = function FormContainer(props) {
62
59
  var children = props.children,
@@ -71,16 +68,11 @@ var FormContainer = function FormContainer(props) {
71
68
  validationScheme = props.validationScheme,
72
69
  buttonConfigs = props.buttonConfigs,
73
70
  formId = props.formId,
74
- onSubmit = props.onSubmit;
75
- var schema = useMemo(function () {
76
- return validationScheme;
77
- }, [instance.language, validationScheme]);
78
- var resolver = useMemo(function () {
79
- return yupResolver(schema);
80
- }, [schema]);
71
+ onSubmit = props.onSubmit,
72
+ language = props.language;
81
73
  var _useForm = useForm({
82
74
  mode: mode,
83
- resolver: resolver,
75
+ resolver: yupResolver(validationScheme),
84
76
  defaultValues: initialValues,
85
77
  shouldFocusError: shouldFocusError,
86
78
  shouldUnregister: shouldUnregister
@@ -98,6 +90,9 @@ var FormContainer = function FormContainer(props) {
98
90
  trigger = _useForm.trigger,
99
91
  getFieldState = _useForm.getFieldState,
100
92
  unregister = _useForm.unregister;
93
+ useEffect(function () {
94
+ trigger();
95
+ }, [language]);
101
96
  var errors = formState.errors,
102
97
  isDirty = formState.isDirty,
103
98
  isSubmitted = formState.isSubmitted,
@@ -108,10 +103,6 @@ var FormContainer = function FormContainer(props) {
108
103
  onSubmit(data, formState, dirtyFields);
109
104
  }
110
105
  };
111
- useEffect(function () {
112
- console.log('Language changed, updating validation messages', instance.language);
113
- trigger(); // re-run validation with new messages
114
- }, [instance.language]);
115
106
  return /*#__PURE__*/React.createElement("form", {
116
107
  onSubmit: handleSubmit(customSubmit),
117
108
  id: formId,
@@ -55,6 +55,3 @@ import '../Progress/Progress.js';
55
55
  import '../SVGIcons/IconArrowDownloadFilled.js';
56
56
  import '../../helpers/download-file.js';
57
57
  import '../Button/consts.js';
58
- import '../../i18n.js';
59
- import '@babel/runtime/helpers/asyncToGenerator';
60
- import '@babel/runtime/regenerator';
@@ -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
  }