hrm_ui_lib 2.5.8 → 2.5.10

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
  };
@@ -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
  }
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { ISVGIconProps } from '../SVGIcons/types';
3
- import type { TIconName } from '../SVGIcons/icon-names';
3
+ import { TIconName } from '../SVGIcons/icon-names';
4
4
  interface IconDynamicComponentProps extends ISVGIconProps {
5
5
  componentName: TIconName;
6
6
  }
@@ -10,12 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { lazy, Suspense } from 'react';
13
+ import { lazy, Suspense, useMemo } from 'react';
14
14
  export const IconDynamicComponent = (_a) => {
15
15
  var { componentName } = _a, rest = __rest(_a, ["componentName"]);
16
- if (!componentName) {
17
- return null;
18
- }
19
16
  const toPascalCase = (value) => value
20
17
  .replace(/^[a-z]/, (m) => m.toUpperCase())
21
18
  .replace(/[A-Z]/g, (m) => ` ${m}`)
@@ -23,14 +20,22 @@ export const IconDynamicComponent = (_a) => {
23
20
  .split(/\s|_|-/)
24
21
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
25
22
  .join('');
26
- const resolvedName = toPascalCase(componentName);
27
- const exportName = `Icon${resolvedName}`;
28
- // Dynamically load the component based on the componentName prop
29
- const Component = lazy(() => import('../../components/SVGIcons').then((mod) => {
30
- var _a;
31
- return ({
32
- default: (_a = mod[exportName]) !== null && _a !== void 0 ? _a : (() => null)
33
- });
34
- }));
23
+ const exportName = useMemo(() => {
24
+ if (!componentName)
25
+ return null;
26
+ return `Icon${toPascalCase(componentName)}`;
27
+ }, [componentName]);
28
+ const Component = useMemo(() => {
29
+ if (!exportName)
30
+ return null;
31
+ return lazy(() => import('../../components/SVGIcons').then((mod) => {
32
+ var _a;
33
+ return ({
34
+ default: (_a = mod[exportName]) !== null && _a !== void 0 ? _a : (() => null)
35
+ });
36
+ }));
37
+ }, [exportName]);
38
+ if (!Component)
39
+ return null;
35
40
  return (_jsx(Suspense, { fallback: null, children: _jsx(Component, Object.assign({}, rest)) }));
36
41
  };
@@ -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.8",
3
+ "version": "2.5.10",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",