@ncds/ui-admin-icon 0.0.12 → 0.0.13

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 CHANGED
@@ -32,53 +32,21 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  const react_1 = __importStar(require("react"));
40
- const covertToPascalCase = (str) => {
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();
37
+ const map_1 = require("./map");
71
38
  const Icon = ({ name, ...props }) => {
72
39
  const iconRef = (0, react_1.useRef)(null);
73
40
  const [isLoading, setIsLoading] = (0, react_1.useState)(true);
74
41
  (0, react_1.useEffect)(() => {
75
42
  setIsLoading(true);
76
- loadIcon(name)
77
- .then((component) => {
78
- iconRef.current = component;
43
+ (0, map_1.getIcon)(name)
44
+ ?.then((module) => {
45
+ iconRef.current = module.default;
79
46
  setIsLoading(false);
80
47
  })
81
- .catch(() => {
48
+ .catch((error) => {
49
+ console.error(error);
82
50
  setIsLoading(false);
83
51
  });
84
52
  }, [name]);
@@ -88,4 +56,5 @@ const Icon = ({ name, ...props }) => {
88
56
  return react_1.default.createElement(IconComponent, { ...props });
89
57
  };
90
58
  exports.default = Icon;
91
- __exportStar(require("./components"), exports);
59
+ // 모든 컴포넌트를 정적으로 내보내지 않음
60
+ // export * from './components';