@ngxi/simple-icons 0.12.23 → 0.12.25

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
@@ -1,6 +1,6 @@
1
1
  import * as i0 from "@angular/core";
2
- import { inject, input, computed, Directive } from "@angular/core";
3
- import { DomSanitizer } from "@angular/platform-browser";
2
+ import { inject, ElementRef, PLATFORM_ID, input, numberAttribute, effect, Directive } from "@angular/core";
3
+ import { isPlatformBrowser } from "@angular/common";
4
4
  const simpleIcons42 = {
5
5
  "body": '<path fill="currentColor" d="M19.581 16.851H24v-4.439ZM24 3.574h-4.419v4.42l-4.419 4.418v4.44h4.419v-4.44L24 7.993Zm-4.419 0h-4.419v4.42zm-6.324 8.838H4.419l8.838-8.838H8.838L0 12.412v3.595h8.838v4.419h4.419z"/>',
6
6
  "width": 24,
@@ -21579,37 +21579,47 @@ const simpleIconsWindows11 = {
21579
21579
  };
21580
21580
  class Ngxi {
21581
21581
  constructor() {
21582
- this.sanitizer = inject(DomSanitizer);
21583
- this.icon = input(...[]);
21584
- this.width = input(...[]);
21585
- this.height = input(...[]);
21582
+ this.el = inject(ElementRef);
21583
+ this.platformId = inject(PLATFORM_ID);
21584
+ this.icon = input.required(...[]);
21585
+ this.width = input(void 0, ...[{
21586
+ transform: numberAttribute
21587
+ }]);
21588
+ this.height = input(void 0, ...[{
21589
+ transform: numberAttribute
21590
+ }]);
21586
21591
  this.viewBox = input(...[]);
21587
- this.resolvedWidth = computed(() => this.width() ?? this.icon()?.width, ...[]);
21588
- this.resolvedHeight = computed(() => this.height() ?? this.icon()?.height, ...[]);
21589
- this.resolvedViewBox = computed(() => this.viewBox() ?? this.icon()?.viewBox, ...[]);
21590
- this.safeSVG = computed(() => this.sanitizer.bypassSecurityTrustHtml(this.icon()?.body ?? ""), ...[]);
21592
+ effect(() => {
21593
+ this.updateSvg();
21594
+ });
21595
+ }
21596
+ updateSvg() {
21597
+ if (isPlatformBrowser(this.platformId)) {
21598
+ const svg = this.el.nativeElement;
21599
+ svg.innerHTML = "";
21600
+ if (!this.icon) {
21601
+ return;
21602
+ }
21603
+ svg.innerHTML = this.icon().body;
21604
+ svg.setAttribute("width", (this.width() ?? this.icon()?.width ?? "").toString());
21605
+ svg.setAttribute("height", (this.height() ?? this.icon()?.height ?? "").toString());
21606
+ svg.setAttribute("viewBox", this.viewBox() ?? this.icon()?.viewBox ?? "");
21607
+ }
21591
21608
  }
21592
21609
  static {
21593
21610
  this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: Ngxi, deps: [], target: i0.ɵɵFactoryTarget.Directive });
21594
21611
  }
21595
21612
  static {
21596
- this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.2", type: Ngxi, isStandalone: true, selector: "svg[ngxi]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, viewBox: { classPropertyName: "viewBox", publicName: "viewBox", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.width": "resolvedWidth()", "attr.height": "resolvedHeight()", "attr.viewBox": "resolvedViewBox()", "innerHTML": "safeSVG()" } }, ngImport: i0 });
21613
+ this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.2", type: Ngxi, isStandalone: true, selector: "svg[ngxi]", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, viewBox: { classPropertyName: "viewBox", publicName: "viewBox", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
21597
21614
  }
21598
21615
  }
21599
21616
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: Ngxi, decorators: [{
21600
21617
  type: Directive,
21601
21618
  args: [{
21602
- standalone: true,
21603
21619
  selector: "svg[ngxi]",
21604
- host: {
21605
- "role": "img",
21606
- "[attr.width]": "resolvedWidth()",
21607
- "[attr.height]": "resolvedHeight()",
21608
- "[attr.viewBox]": "resolvedViewBox()",
21609
- "[innerHTML]": "safeSVG()"
21610
- }
21620
+ standalone: true
21611
21621
  }]
21612
- }] });
21622
+ }], ctorParameters: () => [] });
21613
21623
  class NgxiSimpleIcons {
21614
21624
  constructor() {
21615
21625
  this.ngxiSimpleIcons = input.required(...[]);