hrm_ui_lib 2.5.8 → 2.5.9
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,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { ISVGIconProps } from '../SVGIcons/types';
|
|
3
|
-
import
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
};
|