hrm_ui_lib 2.5.9 → 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.
@@ -16,9 +16,9 @@ export const FilePreview = ({ preview, type }) => {
16
16
  setLoading(false);
17
17
  };
18
18
  if (type === 'image') {
19
- return (_jsxs(_Fragment, { children: [loading && _jsx(Progress, { size: "small", loop: true, noText: true, percent: 30, type: "circle", dimension: 20 }), _jsx("img", { src: hasError ? filePreviewSVG : preview, alt: "Preview", onLoad: handleImageOnLoad, onError: handleImageOnError, className: classnames('dz-file-upload__files--item__preview--image', {
19
+ return (_jsxs(_Fragment, { children: [loading && _jsx(Progress, { size: "small", loop: true, noText: true, percent: 30, type: "circle", dimension: 20 }), _jsx("img", { src: hasError ? filePreviewSVG : preview, alt: "Preview", fetchPriority: "low", onLoad: handleImageOnLoad, onError: handleImageOnError, className: classnames('dz-file-upload__files--item__preview--image', {
20
20
  'dz-file-upload__files--item__preview--image--loading': loading
21
21
  }) })] }));
22
22
  }
23
- return (_jsx("img", { src: filePreviewSVG, alt: "Preview", className: "dnd-file-upload__files--item__preview--image dnd-file-upload__files--item__preview--image_default" }));
23
+ return (_jsx("img", { src: filePreviewSVG, alt: "Preview", fetchPriority: "low", className: "dnd-file-upload__files--item__preview--image dnd-file-upload__files--item__preview--image_default" }));
24
24
  };
@@ -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
  }
@@ -6,15 +6,15 @@ import { FormContext } from '../../context';
6
6
  import { Controller } from 'react-hook-form';
7
7
  import classnames from 'classnames';
8
8
  export const FormField = (props) => {
9
- const { As, name, className = '', dataId = '', hideErrorMessage = false, errorMessageIcon } = props;
9
+ const { As, name, className = '', dataId = '', hideErrorMessage = false, errorMessageIcon, defaultValue } = props;
10
10
  const { register, errors, setValue, control } = useContext(FormContext);
11
11
  if (!register) {
12
12
  return null;
13
13
  }
14
14
  const registerOptions = register(name);
15
- return (_jsx("div", { className: classnames('form-container__field', className, name), children: _jsx(Controller, { control: control, name: name, render: ({ field, fieldState }) => {
15
+ return (_jsx("div", { className: classnames('form-container__field', className, name), children: _jsx(Controller, Object.assign({ control: control, name: name }, (defaultValue ? { defaultValue } : {}), { render: ({ field, fieldState }) => {
16
16
  return (_jsxs(_Fragment, { children: [As(Object.assign(Object.assign(Object.assign({ hasError: !!fieldState.error, isValid: fieldState.isTouched && fieldState.isDirty && !fieldState.invalid, dataId }, registerOptions), { setFieldValue: (data, name, options) => setValue(data, name, Object.assign({ shouldValidate: true, shouldDirty: true, shouldTouch: true }, options)) }), field)), !hideErrorMessage ? (_jsx(ReactHookFormErrorMessage, { name: name, errors: errors, render: ({ message }) => {
17
17
  return (_jsx(ErrorMessage, { dataId: dataId, message: message || '', className: "full-width", icon: errorMessageIcon }));
18
18
  } })) : null] }));
19
- } }) }));
19
+ } })) }));
20
20
  };
@@ -5,4 +5,5 @@ export interface TFormFieldPropTypes {
5
5
  dataId?: string;
6
6
  hideErrorMessage?: boolean;
7
7
  errorMessageIcon?: string;
8
+ defaultValue?: any;
8
9
  }
@@ -5,7 +5,7 @@ export const Image = (props) => {
5
5
  backgroundImage: `${imagePath ? `url(${imagePath})` : ''}`,
6
6
  backgroundSize: backgroundSize,
7
7
  aspectRatio: ratio
8
- } })) : (_jsx("img", { className: `image ${className}`, src: imagePath, alt: name, style: {
8
+ } })) : (_jsx("img", { className: `image ${className}`, src: imagePath, alt: name, fetchPriority: "low", style: {
9
9
  aspectRatio: ratio,
10
10
  width: isFullWidth ? '100%' : '',
11
11
  height: isFullHeight ? '100%' : ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "2.5.9",
3
+ "version": "2.5.11",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",