viconic-react-icons 1.0.6 → 1.0.8
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/index.js +21 -6
- package/dist/index.mjs +21 -6
- package/index.d.ts +6 -0
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +20 -4
- package/src/index.jsx +9 -3
package/dist/index.js
CHANGED
|
@@ -758,9 +758,19 @@ var import_react = __toESM(require("react"));
|
|
|
758
758
|
});
|
|
759
759
|
}
|
|
760
760
|
if (scopedContent.includes("id=")) {
|
|
761
|
-
|
|
762
|
-
scopedContent
|
|
763
|
-
|
|
761
|
+
const ids = [];
|
|
762
|
+
scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
|
|
763
|
+
ids.push(id);
|
|
764
|
+
return m;
|
|
765
|
+
});
|
|
766
|
+
scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
|
|
767
|
+
scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
|
|
768
|
+
scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
|
|
769
|
+
if (ids.length > 0) {
|
|
770
|
+
const escapedIds = ids.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
771
|
+
const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, "g");
|
|
772
|
+
scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
|
|
773
|
+
}
|
|
764
774
|
}
|
|
765
775
|
}
|
|
766
776
|
element.innerHTML = scopedContent;
|
|
@@ -1934,20 +1944,25 @@ var import_react = __toESM(require("react"));
|
|
|
1934
1944
|
})();
|
|
1935
1945
|
|
|
1936
1946
|
// src/index.jsx
|
|
1937
|
-
var ViconicIcon = ({ name, className, style, ...props }) => {
|
|
1947
|
+
var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
1938
1948
|
const iconRef = (0, import_react.useRef)(null);
|
|
1939
1949
|
(0, import_react.useEffect)(() => {
|
|
1940
1950
|
if (window.CopyIcons && iconRef.current) {
|
|
1941
1951
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
1942
1952
|
}
|
|
1943
|
-
}, [name, className]);
|
|
1953
|
+
}, [name, className, size, color, style]);
|
|
1954
|
+
const combinedStyle = {
|
|
1955
|
+
...size ? { fontSize: size } : {},
|
|
1956
|
+
...color ? { color } : {},
|
|
1957
|
+
...style
|
|
1958
|
+
};
|
|
1944
1959
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
1945
1960
|
"viconic-icon",
|
|
1946
1961
|
{
|
|
1947
1962
|
ref: iconRef,
|
|
1948
1963
|
icon: name,
|
|
1949
1964
|
class: className,
|
|
1950
|
-
style,
|
|
1965
|
+
style: combinedStyle,
|
|
1951
1966
|
...props
|
|
1952
1967
|
}
|
|
1953
1968
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -724,9 +724,19 @@ import React, { useEffect, useRef } from "react";
|
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
if (scopedContent.includes("id=")) {
|
|
727
|
-
|
|
728
|
-
scopedContent
|
|
729
|
-
|
|
727
|
+
const ids = [];
|
|
728
|
+
scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
|
|
729
|
+
ids.push(id);
|
|
730
|
+
return m;
|
|
731
|
+
});
|
|
732
|
+
scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
|
|
733
|
+
scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
|
|
734
|
+
scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
|
|
735
|
+
if (ids.length > 0) {
|
|
736
|
+
const escapedIds = ids.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
737
|
+
const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, "g");
|
|
738
|
+
scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
|
|
739
|
+
}
|
|
730
740
|
}
|
|
731
741
|
}
|
|
732
742
|
element.innerHTML = scopedContent;
|
|
@@ -1900,20 +1910,25 @@ import React, { useEffect, useRef } from "react";
|
|
|
1900
1910
|
})();
|
|
1901
1911
|
|
|
1902
1912
|
// src/index.jsx
|
|
1903
|
-
var ViconicIcon = ({ name, className, style, ...props }) => {
|
|
1913
|
+
var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
1904
1914
|
const iconRef = useRef(null);
|
|
1905
1915
|
useEffect(() => {
|
|
1906
1916
|
if (window.CopyIcons && iconRef.current) {
|
|
1907
1917
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
1908
1918
|
}
|
|
1909
|
-
}, [name, className]);
|
|
1919
|
+
}, [name, className, size, color, style]);
|
|
1920
|
+
const combinedStyle = {
|
|
1921
|
+
...size ? { fontSize: size } : {},
|
|
1922
|
+
...color ? { color } : {},
|
|
1923
|
+
...style
|
|
1924
|
+
};
|
|
1910
1925
|
return /* @__PURE__ */ React.createElement(
|
|
1911
1926
|
"viconic-icon",
|
|
1912
1927
|
{
|
|
1913
1928
|
ref: iconRef,
|
|
1914
1929
|
icon: name,
|
|
1915
1930
|
class: className,
|
|
1916
|
-
style,
|
|
1931
|
+
style: combinedStyle,
|
|
1917
1932
|
...props
|
|
1918
1933
|
}
|
|
1919
1934
|
);
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export interface ViconicIconProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
4
4
|
/** The unique icon ID (e.g., 'lucide:activity', 'h2:0'). Required. */
|
|
5
5
|
name: string;
|
|
6
6
|
|
|
7
|
+
/** Optional icon size, CSS format (e.g., '24px', '1.5rem'). Translates to style.fontSize */
|
|
8
|
+
size?: string | number;
|
|
9
|
+
|
|
10
|
+
/** Optional icon color, CSS color value. Translates to style.color */
|
|
11
|
+
color?: string;
|
|
12
|
+
|
|
7
13
|
style?: React.CSSProperties;
|
|
8
14
|
}
|
|
9
15
|
|
package/package.json
CHANGED
|
@@ -683,11 +683,27 @@
|
|
|
683
683
|
});
|
|
684
684
|
}
|
|
685
685
|
|
|
686
|
-
// 2. Scope generic IDs (clip-paths, gradients, masks)
|
|
686
|
+
// 2. Scope generic IDs (clip-paths, gradients, masks, and animate event references)
|
|
687
687
|
if (scopedContent.includes('id=')) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
scopedContent
|
|
688
|
+
// First extract all IDs defined in this SVG
|
|
689
|
+
const ids = [];
|
|
690
|
+
scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
|
|
691
|
+
ids.push(id);
|
|
692
|
+
return m;
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// Scope definitions & standard hash references
|
|
696
|
+
scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
|
|
697
|
+
scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
|
|
698
|
+
scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
|
|
699
|
+
|
|
700
|
+
// Scope SMIL animation references like begin="id.end", end="0; id.begin+2s"
|
|
701
|
+
if (ids.length > 0) {
|
|
702
|
+
const escapedIds = ids.map(id => id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
|
|
703
|
+
// Matches " or ; or ' or space before the ID, and .eventName after
|
|
704
|
+
const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, 'g');
|
|
705
|
+
scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
|
|
706
|
+
}
|
|
691
707
|
}
|
|
692
708
|
}
|
|
693
709
|
|
package/src/index.jsx
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import './copyicons-smart-loader.js';
|
|
3
3
|
|
|
4
|
-
export const ViconicIcon = ({ name, className, style, ...props }) => {
|
|
4
|
+
export const ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
5
5
|
const iconRef = useRef(null);
|
|
6
6
|
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (window.CopyIcons && iconRef.current) {
|
|
9
9
|
window.CopyIcons.forceProcess(iconRef.current);
|
|
10
10
|
}
|
|
11
|
-
}, [name, className]);
|
|
11
|
+
}, [name, className, size, color, style]);
|
|
12
|
+
|
|
13
|
+
const combinedStyle = {
|
|
14
|
+
...(size ? { fontSize: size } : {}),
|
|
15
|
+
...(color ? { color: color } : {}),
|
|
16
|
+
...style
|
|
17
|
+
};
|
|
12
18
|
|
|
13
19
|
return (
|
|
14
20
|
<viconic-icon
|
|
15
21
|
ref={iconRef}
|
|
16
22
|
icon={name}
|
|
17
23
|
class={className}
|
|
18
|
-
style={
|
|
24
|
+
style={combinedStyle}
|
|
19
25
|
{...props}
|
|
20
26
|
></viconic-icon>
|
|
21
27
|
);
|