@eightshift/ui-components 5.0.8 → 5.0.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.
- package/dist/icons/jsx-svg.js +16 -2
- package/package.json +1 -1
package/dist/icons/jsx-svg.js
CHANGED
|
@@ -10,6 +10,8 @@ import { s as svgToJsxString, a as source_default } from "../react-jsx-parser.mi
|
|
|
10
10
|
* @param {boolean} [props.ariaHidden] - Set to `true` if the image is decorative.
|
|
11
11
|
* @param {string} [props.customProps] - Custom props to add to the SVG.
|
|
12
12
|
* @param {Object} [props.customPropBindings] - Dynamic bindings for custom props.
|
|
13
|
+
* @param {boolean} [props.noIdRandomization] - If `true`, the SVG will not randomize IDs for defs like gradients, masks, ...
|
|
14
|
+
* @param {string} [props.idRandomizationPrefix] - Sets the prefix for random IDs. Defaults to `icon`.
|
|
13
15
|
*
|
|
14
16
|
* @returns {JSX.Element} The JsxSvg component.
|
|
15
17
|
*
|
|
@@ -22,7 +24,8 @@ import { s as svgToJsxString, a as source_default } from "../react-jsx-parser.mi
|
|
|
22
24
|
* @preserve
|
|
23
25
|
*/
|
|
24
26
|
const JsxSvg = (props) => {
|
|
25
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const { svg, className, customProps, customPropBindings, "aria-hidden": ariaHiddenProp, ariaHidden, noIdRandomization, idRandomizationPrefix = "icon", ...rest } = props;
|
|
26
29
|
if (!svg || typeof svg !== "string") {
|
|
27
30
|
return null;
|
|
28
31
|
}
|
|
@@ -36,12 +39,23 @@ const JsxSvg = (props) => {
|
|
|
36
39
|
if (customProps) {
|
|
37
40
|
jsxString = jsxString.replace("<svg ", `<svg ${customProps} `);
|
|
38
41
|
}
|
|
42
|
+
if (!noIdRandomization) {
|
|
43
|
+
const matches = (_a = Array.from(jsxString == null ? void 0 : jsxString.matchAll(/id=[\'"]([a-zA-Z0-9\-\_]*)[\'"]/g), (m) => m == null ? void 0 : m[1])) == null ? void 0 : _a.filter(Boolean);
|
|
44
|
+
matches.forEach((match) => {
|
|
45
|
+
const newId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
46
|
+
jsxString = jsxString.replaceAll(match, `${idRandomizationPrefix}-${newId}`);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
39
49
|
return /* @__PURE__ */ jsx(
|
|
40
50
|
source_default,
|
|
41
51
|
{
|
|
42
52
|
renderInWrapper: false,
|
|
43
53
|
jsx: jsxString,
|
|
44
|
-
bindings: customPropBindings
|
|
54
|
+
bindings: customPropBindings,
|
|
55
|
+
components: {
|
|
56
|
+
linearGradient: "linearGradient"
|
|
57
|
+
},
|
|
58
|
+
...rest
|
|
45
59
|
}
|
|
46
60
|
);
|
|
47
61
|
};
|