viconic-react-icons 1.0.7 → 1.0.8

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
@@ -758,9 +758,19 @@ var import_react = __toESM(require("react"));
758
758
  });
759
759
  }
760
760
  if (scopedContent.includes("id=")) {
761
- scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}-$1"`);
762
- scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}-$1)`);
763
- scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}-$1"`);
761
+ const ids = [];
762
+ scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
763
+ ids.push(id);
764
+ return m;
765
+ });
766
+ scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
767
+ scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
768
+ scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
769
+ if (ids.length > 0) {
770
+ const escapedIds = ids.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
771
+ const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, "g");
772
+ scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
773
+ }
764
774
  }
765
775
  }
766
776
  element.innerHTML = scopedContent;
package/dist/index.mjs CHANGED
@@ -724,9 +724,19 @@ import React, { useEffect, useRef } from "react";
724
724
  });
725
725
  }
726
726
  if (scopedContent.includes("id=")) {
727
- scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}-$1"`);
728
- scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}-$1)`);
729
- scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}-$1"`);
727
+ const ids = [];
728
+ scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
729
+ ids.push(id);
730
+ return m;
731
+ });
732
+ scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
733
+ scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
734
+ scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
735
+ if (ids.length > 0) {
736
+ const escapedIds = ids.map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
737
+ const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, "g");
738
+ scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
739
+ }
730
740
  }
731
741
  }
732
742
  element.innerHTML = scopedContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viconic-react-icons",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Viconic Smart Icons loader for React",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -683,11 +683,27 @@
683
683
  });
684
684
  }
685
685
 
686
- // 2. Scope generic IDs (clip-paths, gradients, masks)
686
+ // 2. Scope generic IDs (clip-paths, gradients, masks, and animate event references)
687
687
  if (scopedContent.includes('id=')) {
688
- scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}-$1"`);
689
- scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}-$1)`);
690
- scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}-$1"`);
688
+ // First extract all IDs defined in this SVG
689
+ const ids = [];
690
+ scopedContent.replace(/id="([^"]+)"/gi, (m, id) => {
691
+ ids.push(id);
692
+ return m;
693
+ });
694
+
695
+ // Scope definitions & standard hash references
696
+ scopedContent = scopedContent.replace(/id="([^"]+)"/gi, `id="${uid}_$1"`);
697
+ scopedContent = scopedContent.replace(/url\(['"]?#([^'"\)]+)['"]?\)/gi, `url(#${uid}_$1)`);
698
+ scopedContent = scopedContent.replace(/href="#([^"]+)"/gi, `href="#${uid}_$1"`);
699
+
700
+ // Scope SMIL animation references like begin="id.end", end="0; id.begin+2s"
701
+ if (ids.length > 0) {
702
+ const escapedIds = ids.map(id => id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
703
+ // Matches " or ; or ' or space before the ID, and .eventName after
704
+ const eventRe = new RegExp(`(["';\\s])(${escapedIds})\\.([a-zA-Z]+)`, 'g');
705
+ scopedContent = scopedContent.replace(eventRe, `$1${uid}_$2.$3`);
706
+ }
691
707
  }
692
708
  }
693
709