tosijs-ui 1.5.11 → 1.5.13

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/icons.js CHANGED
@@ -616,10 +616,34 @@ export const iconRules = [
616
616
  apply: (baseName) => `search80s30x30y$${baseName}50o`,
617
617
  },
618
618
  ];
619
+ let iconIdCounter = 0;
619
620
  function makeIcon(spec, parts) {
620
621
  const div = elements.div();
621
622
  div.innerHTML = spec;
622
623
  const sourceSvg = div.querySelector('svg');
624
+ // Uniquify IDs (clipPath, mask, gradient, etc.) to prevent collisions
625
+ const idEls = sourceSvg.querySelectorAll('[id]');
626
+ if (idEls.length > 0) {
627
+ const idMap = new Map();
628
+ for (const el of idEls) {
629
+ const oldId = el.id;
630
+ const newId = `tosi_svg_id_${++iconIdCounter}`;
631
+ idMap.set(oldId, newId);
632
+ el.id = newId;
633
+ }
634
+ // Update all url(#...) and href references
635
+ const html = sourceSvg.innerHTML;
636
+ let updated = html;
637
+ for (const [oldId, newId] of idMap) {
638
+ const escaped = oldId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
639
+ updated = updated
640
+ .replace(new RegExp(`url\\(#${escaped}\\)`, 'g'), `url(#${newId})`)
641
+ .replace(new RegExp(`href="#${escaped}"`, 'g'), `href="#${newId}"`);
642
+ }
643
+ if (updated !== html) {
644
+ sourceSvg.innerHTML = updated;
645
+ }
646
+ }
623
647
  const classes = new Set(sourceSvg.classList);
624
648
  classes.add('tosi-icon');
625
649
  const svg = svgElements.svg({
@@ -742,11 +766,7 @@ function parseStyleSuffixes(name) {
742
766
  const suffixes = match[0].match(/_?\d+[osxyr]|[01]f|_[a-zA-Z0-9]+[FS]|\d+W/g);
743
767
  if (!suffixes)
744
768
  return null;
745
- let tx = '';
746
- let ty = '';
747
- let scale = '';
748
- let rotate = '';
749
- let flip = '';
769
+ const transforms = [];
750
770
  for (const s of suffixes) {
751
771
  const code = s[s.length - 1];
752
772
  if (code === 'F' || code === 'S') {
@@ -770,26 +790,25 @@ function parseStyleSuffixes(name) {
770
790
  style.opacity = String(val / 100);
771
791
  break;
772
792
  case 's':
773
- scale = `scale(${val / 100})`;
793
+ transforms.push(`scale(${val / 100})`);
774
794
  break;
775
795
  case 'x':
776
- tx = `translateX(${val}%)`;
796
+ transforms.push(`translateX(${val}%)`);
777
797
  break;
778
798
  case 'y':
779
- ty = `translateY(${val}%)`;
799
+ transforms.push(`translateY(${val}%)`);
780
800
  break;
781
801
  case 'r':
782
- rotate = `rotate(${val}deg)`;
802
+ transforms.push(`rotate(${val}deg)`);
783
803
  break;
784
804
  case 'f':
785
- flip = val === 0 ? 'scaleX(-1)' : 'scaleY(-1)';
805
+ transforms.push(val === 0 ? 'scaleX(-1)' : 'scaleY(-1)');
786
806
  break;
787
807
  }
788
808
  }
789
809
  }
790
- const transform = [rotate, flip, scale, tx, ty].filter(Boolean).join(' ');
791
- if (transform) {
792
- style.transform = transform;
810
+ if (transforms.length > 0) {
811
+ style.transform = transforms.join(' ');
793
812
  style.transformOrigin = '50% 50%';
794
813
  }
795
814
  return { baseName, style };
@@ -825,7 +844,10 @@ export function resolveIcon(prop, parts) {
825
844
  const segments = prop.split('$');
826
845
  // Last segment is the base (sets the size), rest are overlays
827
846
  const base = resolveIcon(segments[segments.length - 1], []);
828
- const overlays = segments.slice(0, -1).map((name) => {
847
+ const overlays = segments
848
+ .slice(0, -1)
849
+ .reverse()
850
+ .map((name) => {
829
851
  const icon = resolveIcon(name, []);
830
852
  Object.assign(icon.style, {
831
853
  position: 'absolute',