viconic-react-icons 1.1.0 → 1.1.1
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 +18 -4
- package/dist/index.mjs +18 -4
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +17 -1
- package/src/index.jsx +6 -4
package/dist/index.js
CHANGED
|
@@ -171,6 +171,17 @@ var import_react = __toESM(require("react"));
|
|
|
171
171
|
}
|
|
172
172
|
function parseViconicIcon(attrValue) {
|
|
173
173
|
if (!attrValue) return null;
|
|
174
|
+
if (attrValue.startsWith("@")) {
|
|
175
|
+
const slashIdx = attrValue.indexOf("/");
|
|
176
|
+
if (slashIdx > 1) {
|
|
177
|
+
const prefix2 = attrValue.slice(1, slashIdx).trim();
|
|
178
|
+
const name = attrValue.slice(slashIdx + 1).trim();
|
|
179
|
+
if (prefix2 && name) {
|
|
180
|
+
return { prefix: prefix2, iconName: camelToKebab(name), isKit: true };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
174
185
|
const colonIdx = attrValue.indexOf(":");
|
|
175
186
|
if (colonIdx < 1) return null;
|
|
176
187
|
const prefix = attrValue.slice(0, colonIdx).trim();
|
|
@@ -815,8 +826,9 @@ var import_react = __toESM(require("react"));
|
|
|
815
826
|
function registerViconicIcon(el) {
|
|
816
827
|
if (!el || el.nodeType !== 1) return;
|
|
817
828
|
if (processedElements.has(el)) return;
|
|
818
|
-
processedElements.add(el);
|
|
819
829
|
const iconAttr = el.getAttribute("icon");
|
|
830
|
+
if (iconAttr && iconAttr.startsWith("@")) return;
|
|
831
|
+
processedElements.add(el);
|
|
820
832
|
const parsed = parseViconicIcon(iconAttr);
|
|
821
833
|
if (!parsed) {
|
|
822
834
|
if (iconAttr) console.warn(`[CopyIcons] \u26A0\uFE0F Cannot parse viconic-icon icon="${iconAttr}"`);
|
|
@@ -1946,7 +1958,8 @@ var import_react = __toESM(require("react"));
|
|
|
1946
1958
|
|
|
1947
1959
|
// src/index.jsx
|
|
1948
1960
|
var _initializedKits = /* @__PURE__ */ new Set();
|
|
1949
|
-
function initViconic(
|
|
1961
|
+
function initViconic(options = {}) {
|
|
1962
|
+
const { kitId, cdnBase = "cdn.viconic.dev" } = options;
|
|
1950
1963
|
if (typeof window === "undefined") return;
|
|
1951
1964
|
if (!kitId) {
|
|
1952
1965
|
console.warn("[Viconic] initViconic requires a kitId");
|
|
@@ -1967,7 +1980,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1967
1980
|
(0, import_react.useEffect)(() => {
|
|
1968
1981
|
const el = iconRef.current;
|
|
1969
1982
|
if (!el) return;
|
|
1970
|
-
|
|
1983
|
+
const isKitIcon = name && name.startsWith("@");
|
|
1984
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1971
1985
|
window.CopyIcons.forceProcess(el);
|
|
1972
1986
|
}
|
|
1973
1987
|
const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
|
|
@@ -1981,7 +1995,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1981
1995
|
return;
|
|
1982
1996
|
}
|
|
1983
1997
|
if (el._u) el._u();
|
|
1984
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
1998
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1985
1999
|
window.CopyIcons.forceProcess(el);
|
|
1986
2000
|
}
|
|
1987
2001
|
if (retries >= maxRetries) clearInterval(timer);
|
package/dist/index.mjs
CHANGED
|
@@ -136,6 +136,17 @@ import React, { useEffect, useRef } from "react";
|
|
|
136
136
|
}
|
|
137
137
|
function parseViconicIcon(attrValue) {
|
|
138
138
|
if (!attrValue) return null;
|
|
139
|
+
if (attrValue.startsWith("@")) {
|
|
140
|
+
const slashIdx = attrValue.indexOf("/");
|
|
141
|
+
if (slashIdx > 1) {
|
|
142
|
+
const prefix2 = attrValue.slice(1, slashIdx).trim();
|
|
143
|
+
const name = attrValue.slice(slashIdx + 1).trim();
|
|
144
|
+
if (prefix2 && name) {
|
|
145
|
+
return { prefix: prefix2, iconName: camelToKebab(name), isKit: true };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
139
150
|
const colonIdx = attrValue.indexOf(":");
|
|
140
151
|
if (colonIdx < 1) return null;
|
|
141
152
|
const prefix = attrValue.slice(0, colonIdx).trim();
|
|
@@ -780,8 +791,9 @@ import React, { useEffect, useRef } from "react";
|
|
|
780
791
|
function registerViconicIcon(el) {
|
|
781
792
|
if (!el || el.nodeType !== 1) return;
|
|
782
793
|
if (processedElements.has(el)) return;
|
|
783
|
-
processedElements.add(el);
|
|
784
794
|
const iconAttr = el.getAttribute("icon");
|
|
795
|
+
if (iconAttr && iconAttr.startsWith("@")) return;
|
|
796
|
+
processedElements.add(el);
|
|
785
797
|
const parsed = parseViconicIcon(iconAttr);
|
|
786
798
|
if (!parsed) {
|
|
787
799
|
if (iconAttr) console.warn(`[CopyIcons] \u26A0\uFE0F Cannot parse viconic-icon icon="${iconAttr}"`);
|
|
@@ -1911,7 +1923,8 @@ import React, { useEffect, useRef } from "react";
|
|
|
1911
1923
|
|
|
1912
1924
|
// src/index.jsx
|
|
1913
1925
|
var _initializedKits = /* @__PURE__ */ new Set();
|
|
1914
|
-
function initViconic(
|
|
1926
|
+
function initViconic(options = {}) {
|
|
1927
|
+
const { kitId, cdnBase = "cdn.viconic.dev" } = options;
|
|
1915
1928
|
if (typeof window === "undefined") return;
|
|
1916
1929
|
if (!kitId) {
|
|
1917
1930
|
console.warn("[Viconic] initViconic requires a kitId");
|
|
@@ -1932,7 +1945,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1932
1945
|
useEffect(() => {
|
|
1933
1946
|
const el = iconRef.current;
|
|
1934
1947
|
if (!el) return;
|
|
1935
|
-
|
|
1948
|
+
const isKitIcon = name && name.startsWith("@");
|
|
1949
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1936
1950
|
window.CopyIcons.forceProcess(el);
|
|
1937
1951
|
}
|
|
1938
1952
|
const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
|
|
@@ -1946,7 +1960,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1946
1960
|
return;
|
|
1947
1961
|
}
|
|
1948
1962
|
if (el._u) el._u();
|
|
1949
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
1963
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1950
1964
|
window.CopyIcons.forceProcess(el);
|
|
1951
1965
|
}
|
|
1952
1966
|
if (retries >= maxRetries) clearInterval(timer);
|
package/package.json
CHANGED
|
@@ -110,6 +110,18 @@
|
|
|
110
110
|
|
|
111
111
|
function parseViconicIcon(attrValue) {
|
|
112
112
|
if (!attrValue) return null;
|
|
113
|
+
// Support @prefix/name format (kit icons)
|
|
114
|
+
if (attrValue.startsWith('@')) {
|
|
115
|
+
const slashIdx = attrValue.indexOf('/');
|
|
116
|
+
if (slashIdx > 1) {
|
|
117
|
+
const prefix = attrValue.slice(1, slashIdx).trim();
|
|
118
|
+
const name = attrValue.slice(slashIdx + 1).trim();
|
|
119
|
+
if (prefix && name) {
|
|
120
|
+
return { prefix, iconName: camelToKebab(name), isKit: true };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
113
125
|
const colonIdx = attrValue.indexOf(':');
|
|
114
126
|
if (colonIdx < 1) return null;
|
|
115
127
|
const prefix = attrValue.slice(0, colonIdx).trim();
|
|
@@ -761,9 +773,13 @@
|
|
|
761
773
|
function registerViconicIcon(el) {
|
|
762
774
|
if (!el || el.nodeType !== 1) return;
|
|
763
775
|
if (processedElements.has(el)) return;
|
|
764
|
-
processedElements.add(el);
|
|
765
776
|
|
|
766
777
|
const iconAttr = el.getAttribute('icon');
|
|
778
|
+
// Skip @prefix/name format — these are kit icons, handled by kit loader CE
|
|
779
|
+
if (iconAttr && iconAttr.startsWith('@')) return;
|
|
780
|
+
|
|
781
|
+
processedElements.add(el);
|
|
782
|
+
|
|
767
783
|
const parsed = parseViconicIcon(iconAttr);
|
|
768
784
|
if (!parsed) {
|
|
769
785
|
if (iconAttr) console.warn(`[CopyIcons] ⚠️ Cannot parse viconic-icon icon="${iconAttr}"`);
|
package/src/index.jsx
CHANGED
|
@@ -22,7 +22,8 @@ const _initializedKits = new Set();
|
|
|
22
22
|
* // Multiple kits:
|
|
23
23
|
* initViconic({ kitId: 'another-kit-uuid' });
|
|
24
24
|
*/
|
|
25
|
-
export function initViconic(
|
|
25
|
+
export function initViconic(options = {}) {
|
|
26
|
+
const { kitId, cdnBase = 'cdn.viconic.dev' } = options;
|
|
26
27
|
if (typeof window === 'undefined') return; // SSR guard
|
|
27
28
|
if (!kitId) {
|
|
28
29
|
console.warn('[Viconic] initViconic requires a kitId');
|
|
@@ -62,7 +63,8 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
62
63
|
if (!el) return;
|
|
63
64
|
|
|
64
65
|
// Path 1: Smart loader (system icons with prefix:name format)
|
|
65
|
-
|
|
66
|
+
const isKitIcon = name && name.startsWith('@');
|
|
67
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
66
68
|
window.CopyIcons.forceProcess(el);
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -82,8 +84,8 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
82
84
|
}
|
|
83
85
|
// Trigger custom element update
|
|
84
86
|
if (el._u) el._u();
|
|
85
|
-
// Also try smart loader
|
|
86
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
87
|
+
// Also try smart loader if it's not a kit icon
|
|
88
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
87
89
|
window.CopyIcons.forceProcess(el);
|
|
88
90
|
}
|
|
89
91
|
if (retries >= maxRetries) clearInterval(timer);
|