firebird-icon-lib 1.0.4 → 1.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../src/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGnD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAC7B,OAAO,GAAG,QAAQ,GAAG,OAAO,CAC7B;IACC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;AAqJD,wBAA+C"}
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../src/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGnD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAC7B,OAAO,GAAG,QAAQ,GAAG,OAAO,CAC7B;IACC,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;AA4LD,wBAA+C"}
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useLayoutEffect, useMemo, useRef } from "react";
1
+ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  var Language_default = (d) => /* @__PURE__ */ jsxs("svg", {
4
4
  width: "1em",
@@ -2099,22 +2099,42 @@ Object.entries(iconModules).forEach(([d, B]) => {
2099
2099
  });
2100
2100
  var applyColorToSVG = (d, B) => {
2101
2101
  d.querySelectorAll("*").forEach((d) => {
2102
- let V = d;
2103
- V.hasAttribute("stroke") && V.getAttribute("stroke") !== "none" && V.setAttribute("stroke", B), V.hasAttribute("fill") && V.getAttribute("fill") !== "none" && V.setAttribute("fill", B);
2104
- }), d.hasAttribute("stroke") && d.getAttribute("stroke") !== "none" && d.setAttribute("stroke", B), d.hasAttribute("fill") && d.getAttribute("fill") !== "none" && d.setAttribute("fill", B);
2102
+ let V = d, H = V.getAttribute("stroke");
2103
+ H && H !== "none" && H !== "transparent" && V.setAttribute("stroke", B);
2104
+ let U = V.getAttribute("fill");
2105
+ U && U !== "none" && U !== "transparent" && V.setAttribute("fill", B);
2106
+ });
2107
+ let V = d.getAttribute("stroke");
2108
+ V && V !== "none" && V !== "transparent" && d.setAttribute("stroke", B);
2109
+ let H = d.getAttribute("fill");
2110
+ H && H !== "none" && H !== "transparent" && d.setAttribute("fill", B);
2105
2111
  }, Icon_default = React.memo(({ name: d, size: W = 24, color: G, className: K, style: q, ...J }) => {
2106
- let Y = useMemo(() => iconMap[d], [d]), X = useRef(null), Z = useCallback(() => {
2107
- G && X.current && applyColorToSVG(X.current, G);
2112
+ let Y = useMemo(() => iconMap[d], [d]), X = useRef(null), Z = useCallback((d) => {
2113
+ X.current = d, G && d && (applyColorToSVG(d, G), requestAnimationFrame(() => {
2114
+ d && X.current === d && applyColorToSVG(d, G);
2115
+ }));
2108
2116
  }, [G]);
2109
2117
  useLayoutEffect(() => {
2110
- Z();
2111
- }, [Z]);
2118
+ G && X.current && applyColorToSVG(X.current, G);
2119
+ }, [G]), useEffect(() => {
2120
+ if (G && X.current) {
2121
+ let d = () => {
2122
+ X.current && applyColorToSVG(X.current, G);
2123
+ };
2124
+ d();
2125
+ let B = requestAnimationFrame(d), V = setTimeout(d, 10);
2126
+ return () => {
2127
+ cancelAnimationFrame(B), clearTimeout(V);
2128
+ };
2129
+ }
2130
+ }, [G]);
2112
2131
  let Q = useMemo(() => ({
2113
2132
  display: "inline-block",
2114
2133
  verticalAlign: "middle",
2134
+ ...G && { "--icon-color": G },
2115
2135
  ...q
2116
- }), [q]), $ = useMemo(() => ({
2117
- ref: X,
2136
+ }), [q, G]), $ = useMemo(() => ({
2137
+ ref: Z,
2118
2138
  width: W,
2119
2139
  height: W,
2120
2140
  className: K,
@@ -2125,6 +2145,7 @@ var applyColorToSVG = (d, B) => {
2125
2145
  W,
2126
2146
  K,
2127
2147
  Q,
2148
+ Z,
2128
2149
  J
2129
2150
  ]);
2130
2151
  return Y ? /* @__PURE__ */ jsx(Y, { ...$ }) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebird-icon-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A lightweight React icon library with TypeScript support, featuring dynamic SVG icon loading",
5
5
  "keywords": [
6
6
  "react",