@atooyu/uxto-ui 1.1.2 → 1.1.3

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 CHANGED
@@ -655,29 +655,33 @@ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
655
655
  return !!getIcon(props.name);
656
656
  });
657
657
  const iconSrc = vue.computed(() => {
658
- const svgData = getIcon(props.name);
659
- if (!svgData) return "";
660
- if (props.color && svgData.startsWith("data:image/svg+xml")) {
661
- try {
662
- let svgContent = decodeURIComponent(svgData.replace("data:image/svg+xml,", ""));
663
- if (svgContent.includes('fill="currentColor"')) {
664
- svgContent = svgContent.replace(/fill="currentColor"/g, `fill="${props.color}"`);
665
- } else if (!svgContent.includes("fill=")) {
666
- svgContent = svgContent.replace("<svg", `<svg fill="${props.color}"`);
667
- } else {
668
- svgContent = svgContent.replace(/fill="[^"]*"/g, `fill="${props.color}"`);
669
- }
670
- return "data:image/svg+xml," + encodeURIComponent(svgContent);
671
- } catch (e) {
672
- return svgData;
673
- }
674
- }
675
- return svgData;
658
+ return getIcon(props.name) || "";
676
659
  });
677
660
  const sizePx = vue.computed(() => {
678
661
  const size = typeof props.size === "number" ? props.size : parseInt(props.size);
679
662
  return size + "px";
680
663
  });
664
+ const colorToFilter = (color) => {
665
+ const colorMap = {
666
+ "#ff9500": "invert(58%) sepia(97%) saturate(1833%) hue-rotate(351deg) brightness(101%) contrast(101%)",
667
+ "#12b6af": "invert(47%) sepia(85%) saturate(475%) hue-rotate(131deg) brightness(92%) contrast(92%)",
668
+ "#333333": "invert(20%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)",
669
+ "#666666": "invert(45%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)",
670
+ "#999999": "invert(70%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)",
671
+ "#ffffff": "invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%)",
672
+ "#ff4d4f": "invert(46%) sepia(98%) saturate(1925%) hue-rotate(335deg) brightness(101%) contrast(101%)"
673
+ };
674
+ const lowerColor = color.toLowerCase();
675
+ if (colorMap[lowerColor]) {
676
+ return colorMap[lowerColor];
677
+ }
678
+ const hex = color.replace("#", "");
679
+ const r = parseInt(hex.substring(0, 2), 16);
680
+ const g = parseInt(hex.substring(2, 4), 16);
681
+ const b = parseInt(hex.substring(4, 6), 16);
682
+ const hue = Math.atan2(Math.sqrt(3) * (g - b), 2 * r - g - b) * 180 / Math.PI;
683
+ return `invert(1) sepia(1) saturate(10000%) hue-rotate(${hue}deg)`;
684
+ };
681
685
  const iconStyle = vue.computed(() => {
682
686
  const size = typeof props.size === "number" ? props.size : parseInt(props.size);
683
687
  const style = {
@@ -685,6 +689,9 @@ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
685
689
  width: size + "px",
686
690
  height: size + "px"
687
691
  };
692
+ if (props.color && isSvgIcon.value) {
693
+ style.filter = colorToFilter(props.color);
694
+ }
688
695
  if (props.color && !isSvgIcon.value) {
689
696
  style.color = props.color;
690
697
  }
@@ -713,7 +720,7 @@ const _sfc_main$G = /* @__PURE__ */ vue.defineComponent({
713
720
  };
714
721
  }
715
722
  });
716
- const UIcon = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-632e7780"]]);
723
+ const UIcon = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-535b2661"]]);
717
724
  const __default__$F = {
718
725
  options: {
719
726
  virtualHost: true,