@ncds/ui-admin-icon 0.0.12 → 0.0.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.
- package/dist/cjs/index.js +5 -35
- package/dist/cjs/map.js +1533 -0
- package/dist/cjs/utils.js +7 -0
- package/dist/esm/index.js +5 -35
- package/dist/esm/map.js +1496 -0
- package/dist/esm/utils.js +3 -0
- package/dist/types/map.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -0
- package/package.json +3 -2
package/dist/cjs/index.js
CHANGED
|
@@ -37,48 +37,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const react_1 = __importStar(require("react"));
|
|
40
|
-
const
|
|
41
|
-
return str.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase()).replace(/^[a-z]/, (char) => char.toUpperCase());
|
|
42
|
-
};
|
|
43
|
-
const viteLoader = (name) => {
|
|
44
|
-
const iconName = covertToPascalCase(name);
|
|
45
|
-
try {
|
|
46
|
-
return Promise.resolve(`${`./components/${iconName}`}`).then(s => __importStar(require(s))).then((module) => module.default);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return Promise.reject(new Error(`Icon ${name} not found`));
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const webpackLoader = (name) => {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
const requireContext = require.context('./components', true, /\.(js|tsx)$/);
|
|
55
|
-
const iconName = covertToPascalCase(name);
|
|
56
|
-
try {
|
|
57
|
-
return Promise.resolve(requireContext(`./${iconName}`).default);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
return Promise.reject(new Error(`Icon ${name} not found`));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const getIconLoader = () => {
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
if (typeof require !== 'undefined' && typeof require.context === 'function') {
|
|
66
|
-
return webpackLoader;
|
|
67
|
-
}
|
|
68
|
-
return viteLoader;
|
|
69
|
-
};
|
|
70
|
-
const loadIcon = getIconLoader();
|
|
40
|
+
const map_1 = require("./map");
|
|
71
41
|
const Icon = ({ name, ...props }) => {
|
|
72
42
|
const iconRef = (0, react_1.useRef)(null);
|
|
73
43
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
74
44
|
(0, react_1.useEffect)(() => {
|
|
75
45
|
setIsLoading(true);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
iconRef.current =
|
|
46
|
+
(0, map_1.getIcon)(name)
|
|
47
|
+
?.then((module) => {
|
|
48
|
+
iconRef.current = module.default;
|
|
79
49
|
setIsLoading(false);
|
|
80
50
|
})
|
|
81
|
-
.catch(() => {
|
|
51
|
+
.catch((error) => {
|
|
82
52
|
setIsLoading(false);
|
|
83
53
|
});
|
|
84
54
|
}, [name]);
|