viconic-react-icons 1.1.5 → 1.1.6
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 +7 -1
- package/dist/index.mjs +7 -1
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +1 -1
- package/src/index.jsx +10 -0
package/dist/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var import_react = __toESM(require("react"));
|
|
|
45
45
|
}
|
|
46
46
|
if (typeof document !== "undefined") {
|
|
47
47
|
const style = document.createElement("style");
|
|
48
|
-
style.textContent = ":where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; }";
|
|
48
|
+
style.textContent = ":where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; } viconic-icon:not(.vi-ok):not(.svg-loaded) { animation: none !important; background: none !important; }";
|
|
49
49
|
if (document.head.firstChild) {
|
|
50
50
|
document.head.insertBefore(style, document.head.firstChild);
|
|
51
51
|
} else {
|
|
@@ -2003,9 +2003,15 @@ function initViconic(options = {}) {
|
|
|
2003
2003
|
}
|
|
2004
2004
|
var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
2005
2005
|
const iconRef = (0, import_react.useRef)(null);
|
|
2006
|
+
const prevNameRef = (0, import_react.useRef)(name);
|
|
2006
2007
|
(0, import_react.useEffect)(() => {
|
|
2007
2008
|
const el = iconRef.current;
|
|
2008
2009
|
if (!el) return;
|
|
2010
|
+
if (prevNameRef.current !== name) {
|
|
2011
|
+
el.innerHTML = "";
|
|
2012
|
+
el.classList.remove("vi-ok", "svg-loaded", "vi-mono", "ci-multicolor");
|
|
2013
|
+
prevNameRef.current = name;
|
|
2014
|
+
}
|
|
2009
2015
|
const isKitIcon = name && name.startsWith("@");
|
|
2010
2016
|
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
2011
2017
|
window.CopyIcons.forceProcess(el);
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import React, { useEffect, useRef } from "react";
|
|
|
10
10
|
}
|
|
11
11
|
if (typeof document !== "undefined") {
|
|
12
12
|
const style = document.createElement("style");
|
|
13
|
-
style.textContent = ":where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; }";
|
|
13
|
+
style.textContent = ":where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; } viconic-icon:not(.vi-ok):not(.svg-loaded) { animation: none !important; background: none !important; }";
|
|
14
14
|
if (document.head.firstChild) {
|
|
15
15
|
document.head.insertBefore(style, document.head.firstChild);
|
|
16
16
|
} else {
|
|
@@ -1968,9 +1968,15 @@ function initViconic(options = {}) {
|
|
|
1968
1968
|
}
|
|
1969
1969
|
var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
1970
1970
|
const iconRef = useRef(null);
|
|
1971
|
+
const prevNameRef = useRef(name);
|
|
1971
1972
|
useEffect(() => {
|
|
1972
1973
|
const el = iconRef.current;
|
|
1973
1974
|
if (!el) return;
|
|
1975
|
+
if (prevNameRef.current !== name) {
|
|
1976
|
+
el.innerHTML = "";
|
|
1977
|
+
el.classList.remove("vi-ok", "svg-loaded", "vi-mono", "ci-multicolor");
|
|
1978
|
+
prevNameRef.current = name;
|
|
1979
|
+
}
|
|
1974
1980
|
const isKitIcon = name && name.startsWith("@");
|
|
1975
1981
|
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1976
1982
|
window.CopyIcons.forceProcess(el);
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
if (typeof document !== 'undefined') {
|
|
35
35
|
const style = document.createElement('style');
|
|
36
36
|
// Use :where() to set specificity to 0, so user styles can easily override without !important
|
|
37
|
-
style.textContent = ':where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; }';
|
|
37
|
+
style.textContent = ':where(viconic-icon) { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; font-size: inherit; line-height: 1; } :where(viconic-icon):not(.ci-multicolor) svg { width: 100%; height: 100%; display: block; fill: currentColor; } :where(viconic-icon).ci-multicolor svg { width: 100%; height: 100%; display: block; } viconic-icon:not(.vi-ok):not(.svg-loaded) { animation: none !important; background: none !important; }';
|
|
38
38
|
if (document.head.firstChild) {
|
|
39
39
|
document.head.insertBefore(style, document.head.firstChild);
|
|
40
40
|
} else {
|
package/src/index.jsx
CHANGED
|
@@ -65,11 +65,21 @@ export function initViconic(options = {}) {
|
|
|
65
65
|
*/
|
|
66
66
|
export const ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
67
67
|
const iconRef = useRef(null);
|
|
68
|
+
const prevNameRef = useRef(name);
|
|
68
69
|
|
|
69
70
|
useEffect(() => {
|
|
70
71
|
const el = iconRef.current;
|
|
71
72
|
if (!el) return;
|
|
72
73
|
|
|
74
|
+
// --- FIX DOM REUSE (Reconciliation) ---
|
|
75
|
+
// React reuses DOM nodes. If `name` changes, we must wipe the old state
|
|
76
|
+
// because the DOM node might still have 'svg-loaded' or 'vi-ok'.
|
|
77
|
+
if (prevNameRef.current !== name) {
|
|
78
|
+
el.innerHTML = '';
|
|
79
|
+
el.classList.remove('vi-ok', 'svg-loaded', 'vi-mono', 'ci-multicolor');
|
|
80
|
+
prevNameRef.current = name;
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
// Path 1: Smart loader (system icons with prefix:name format)
|
|
74
84
|
const isKitIcon = name && name.startsWith('@');
|
|
75
85
|
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|