@macive/ui 0.0.15 → 0.0.17
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/src/components/Icon/Icon.js +11 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/types/src/components/Icon/Icon.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Scrollable/Scrollable.d.ts +1 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ const Icon_classnames_1 = __importDefault(require("./Icon.classnames"));
|
|
|
11
11
|
const react_1 = require("react");
|
|
12
12
|
const COLORS_WITH_BACKDROPS = ['base', 'critical', 'highlight', 'success', 'warning'];
|
|
13
13
|
function Icon({ source, color, backdrop, accessibilityLabel, size = 20, theme }) {
|
|
14
|
-
var _a;
|
|
14
|
+
var _a, _b;
|
|
15
15
|
let sourceType;
|
|
16
16
|
// Detect source type
|
|
17
17
|
if (source === 'placeholder') {
|
|
@@ -47,7 +47,14 @@ function Icon({ source, color, backdrop, accessibilityLabel, size = 20, theme })
|
|
|
47
47
|
}
|
|
48
48
|
else if (typeof source === 'object' && source !== null) {
|
|
49
49
|
// Handle objects (e.g., raw SVG data or custom icon objects)
|
|
50
|
-
sourceType = 'object'
|
|
50
|
+
// sourceType = 'object'
|
|
51
|
+
const iconToFunction = (IconComponent, props) => {
|
|
52
|
+
const Icon = () => (0, jsx_runtime_1.jsx)(IconComponent, { ...props });
|
|
53
|
+
Icon.displayName = 'Icon';
|
|
54
|
+
return Icon;
|
|
55
|
+
};
|
|
56
|
+
source = iconToFunction(source);
|
|
57
|
+
sourceType = 'function';
|
|
51
58
|
}
|
|
52
59
|
else {
|
|
53
60
|
// Fallback to placeholder for unrecognized types
|
|
@@ -55,7 +62,7 @@ function Icon({ source, color, backdrop, accessibilityLabel, size = 20, theme })
|
|
|
55
62
|
}
|
|
56
63
|
// Warn for unsupported recoloring of external SVGs, URLs, or objects
|
|
57
64
|
if (color &&
|
|
58
|
-
(sourceType === 'external' || sourceType === 'url'
|
|
65
|
+
(sourceType === 'external' || sourceType === 'url') &&
|
|
59
66
|
process.env.NODE_ENV === 'development') {
|
|
60
67
|
console.warn(`Recoloring ${sourceType} sources is not supported. Set the intended color on your icon source instead.`);
|
|
61
68
|
}
|
|
@@ -81,7 +88,7 @@ function Icon({ source, color, backdrop, accessibilityLabel, size = 20, theme })
|
|
|
81
88
|
typeof source.svg === 'string'
|
|
82
89
|
? //@ts-expect-error index
|
|
83
90
|
source.svg
|
|
84
|
-
: JSON.stringify(source).replace(/"/g, "'"),
|
|
91
|
+
: (_b = JSON.stringify(source)) === null || _b === void 0 ? void 0 : _b.replace(/"/g, "'"),
|
|
85
92
|
}, "aria-hidden": 'true' })),
|
|
86
93
|
placeholder: (0, jsx_runtime_1.jsx)("div", { className: Icon_classnames_1.default.Placeholder }),
|
|
87
94
|
external: ((0, jsx_runtime_1.jsx)("img", { className: Icon_classnames_1.default.Img, src: `data:image/svg+xml;utf8,${source}`, alt: '', "aria-hidden": 'true' })),
|