viconic-react-icons 1.1.0 → 1.1.2
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 +24 -5
- package/dist/index.mjs +24 -5
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +17 -1
- package/src/index.jsx +16 -6
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", version } = options;
|
|
1950
1963
|
if (typeof window === "undefined") return;
|
|
1951
1964
|
if (!kitId) {
|
|
1952
1965
|
console.warn("[Viconic] initViconic requires a kitId");
|
|
@@ -1958,7 +1971,12 @@ function initViconic({ kitId, cdnBase = "cdn.viconic.dev" }) {
|
|
|
1958
1971
|
if (document.getElementById(scriptId)) return;
|
|
1959
1972
|
const script = document.createElement("script");
|
|
1960
1973
|
script.id = scriptId;
|
|
1961
|
-
|
|
1974
|
+
let url = `https://${cdnBase}/kits/${kitId}/loader.js`;
|
|
1975
|
+
if (version) {
|
|
1976
|
+
const vQuery = version === "dev" ? Date.now() : version;
|
|
1977
|
+
url += `?v=${vQuery}`;
|
|
1978
|
+
}
|
|
1979
|
+
script.src = url;
|
|
1962
1980
|
script.async = true;
|
|
1963
1981
|
document.head.appendChild(script);
|
|
1964
1982
|
}
|
|
@@ -1967,7 +1985,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1967
1985
|
(0, import_react.useEffect)(() => {
|
|
1968
1986
|
const el = iconRef.current;
|
|
1969
1987
|
if (!el) return;
|
|
1970
|
-
|
|
1988
|
+
const isKitIcon = name && name.startsWith("@");
|
|
1989
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1971
1990
|
window.CopyIcons.forceProcess(el);
|
|
1972
1991
|
}
|
|
1973
1992
|
const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
|
|
@@ -1981,7 +2000,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1981
2000
|
return;
|
|
1982
2001
|
}
|
|
1983
2002
|
if (el._u) el._u();
|
|
1984
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
2003
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1985
2004
|
window.CopyIcons.forceProcess(el);
|
|
1986
2005
|
}
|
|
1987
2006
|
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", version } = options;
|
|
1915
1928
|
if (typeof window === "undefined") return;
|
|
1916
1929
|
if (!kitId) {
|
|
1917
1930
|
console.warn("[Viconic] initViconic requires a kitId");
|
|
@@ -1923,7 +1936,12 @@ function initViconic({ kitId, cdnBase = "cdn.viconic.dev" }) {
|
|
|
1923
1936
|
if (document.getElementById(scriptId)) return;
|
|
1924
1937
|
const script = document.createElement("script");
|
|
1925
1938
|
script.id = scriptId;
|
|
1926
|
-
|
|
1939
|
+
let url = `https://${cdnBase}/kits/${kitId}/loader.js`;
|
|
1940
|
+
if (version) {
|
|
1941
|
+
const vQuery = version === "dev" ? Date.now() : version;
|
|
1942
|
+
url += `?v=${vQuery}`;
|
|
1943
|
+
}
|
|
1944
|
+
script.src = url;
|
|
1927
1945
|
script.async = true;
|
|
1928
1946
|
document.head.appendChild(script);
|
|
1929
1947
|
}
|
|
@@ -1932,7 +1950,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1932
1950
|
useEffect(() => {
|
|
1933
1951
|
const el = iconRef.current;
|
|
1934
1952
|
if (!el) return;
|
|
1935
|
-
|
|
1953
|
+
const isKitIcon = name && name.startsWith("@");
|
|
1954
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1936
1955
|
window.CopyIcons.forceProcess(el);
|
|
1937
1956
|
}
|
|
1938
1957
|
const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
|
|
@@ -1946,7 +1965,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
1946
1965
|
return;
|
|
1947
1966
|
}
|
|
1948
1967
|
if (el._u) el._u();
|
|
1949
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
1968
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
1950
1969
|
window.CopyIcons.forceProcess(el);
|
|
1951
1970
|
}
|
|
1952
1971
|
if (retries >= maxRetries) clearInterval(timer);
|
package/index.d.ts
CHANGED
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
|
@@ -20,9 +20,10 @@ const _initializedKits = new Set();
|
|
|
20
20
|
*
|
|
21
21
|
* initViconic({ kitId: '387a6161-cb39-411f-8f13-29a5813e4efd' });
|
|
22
22
|
* // Multiple kits:
|
|
23
|
-
* initViconic({ kitId: 'another-kit-uuid' });
|
|
23
|
+
* initViconic({ kitId: 'another-kit-uuid', version: '1.0' });
|
|
24
24
|
*/
|
|
25
|
-
export function initViconic(
|
|
25
|
+
export function initViconic(options = {}) {
|
|
26
|
+
const { kitId, cdnBase = 'cdn.viconic.dev', version } = options;
|
|
26
27
|
if (typeof window === 'undefined') return; // SSR guard
|
|
27
28
|
if (!kitId) {
|
|
28
29
|
console.warn('[Viconic] initViconic requires a kitId');
|
|
@@ -36,7 +37,15 @@ export function initViconic({ kitId, cdnBase = 'cdn.viconic.dev' }) {
|
|
|
36
37
|
|
|
37
38
|
const script = document.createElement('script');
|
|
38
39
|
script.id = scriptId;
|
|
39
|
-
|
|
40
|
+
|
|
41
|
+
// Add cache busting for development or specific version updates
|
|
42
|
+
let url = `https://${cdnBase}/kits/${kitId}/loader.js`;
|
|
43
|
+
if (version) {
|
|
44
|
+
const vQuery = version === 'dev' ? Date.now() : version;
|
|
45
|
+
url += `?v=${vQuery}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
script.src = url;
|
|
40
49
|
script.async = true;
|
|
41
50
|
document.head.appendChild(script);
|
|
42
51
|
}
|
|
@@ -62,7 +71,8 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
62
71
|
if (!el) return;
|
|
63
72
|
|
|
64
73
|
// Path 1: Smart loader (system icons with prefix:name format)
|
|
65
|
-
|
|
74
|
+
const isKitIcon = name && name.startsWith('@');
|
|
75
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
66
76
|
window.CopyIcons.forceProcess(el);
|
|
67
77
|
}
|
|
68
78
|
|
|
@@ -82,8 +92,8 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
82
92
|
}
|
|
83
93
|
// Trigger custom element update
|
|
84
94
|
if (el._u) el._u();
|
|
85
|
-
// Also try smart loader
|
|
86
|
-
if (window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
95
|
+
// Also try smart loader if it's not a kit icon
|
|
96
|
+
if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
|
|
87
97
|
window.CopyIcons.forceProcess(el);
|
|
88
98
|
}
|
|
89
99
|
if (retries >= maxRetries) clearInterval(timer);
|