@svgflex/angular 0.1.1 → 0.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/fesm2022/svgflex-angular.mjs +32 -13
- package/fesm2022/svgflex-angular.mjs.map +1 -1
- package/index.d.ts +9 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, HostBinding, Input, Component } from '@angular/core';
|
|
2
|
+
import { Injectable, inject, ChangeDetectorRef, HostBinding, Input, Component } from '@angular/core';
|
|
3
3
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { of } from 'rxjs';
|
|
@@ -19,21 +19,28 @@ class SvgLoaderService {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Loads SVG content from a URL with caching
|
|
22
|
+
* @param url - URL to load the SVG from
|
|
23
|
+
* @param replaceColors - Whether to replace hardcoded colors with currentColor (default: true)
|
|
22
24
|
*/
|
|
23
|
-
loadSvg(url) {
|
|
24
|
-
console.log('[SvgLoaderService] Loading SVG from:', url);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
loadSvg(url, replaceColors = true) {
|
|
26
|
+
console.log('[SvgLoaderService] Loading SVG from:', url, 'replaceColors:', replaceColors);
|
|
27
|
+
// Check cache with both url and replaceColors as key
|
|
28
|
+
if (!this.cache.has(url)) {
|
|
29
|
+
this.cache.set(url, new Map());
|
|
30
|
+
}
|
|
31
|
+
const urlCache = this.cache.get(url);
|
|
32
|
+
if (urlCache.has(replaceColors)) {
|
|
33
|
+
console.log('[SvgLoaderService] Returning cached SVG for:', url, 'replaceColors:', replaceColors);
|
|
34
|
+
return urlCache.get(replaceColors);
|
|
28
35
|
}
|
|
29
36
|
const svg$ = this.http.get(url, { responseType: 'text' }).pipe(map(svgContent => {
|
|
30
37
|
console.log('[SvgLoaderService] Successfully loaded SVG from:', url, 'Length:', svgContent.length);
|
|
31
|
-
return sanitizeSvg(svgContent);
|
|
38
|
+
return sanitizeSvg(svgContent, replaceColors);
|
|
32
39
|
}), catchError(error => {
|
|
33
40
|
console.error(`[SvgLoaderService] Failed to load SVG from ${url}:`, error);
|
|
34
41
|
return of('');
|
|
35
42
|
}), shareReplay(1));
|
|
36
|
-
|
|
43
|
+
urlCache.set(replaceColors, svg$);
|
|
37
44
|
return svg$;
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
@@ -57,6 +64,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
57
64
|
*
|
|
58
65
|
* Renders SVG icons with customizable color and size.
|
|
59
66
|
* Supports both inline SVG (for full style control) and external references.
|
|
67
|
+
* Compatible with both Zone.js and Zoneless Angular applications.
|
|
60
68
|
*
|
|
61
69
|
* @example
|
|
62
70
|
* <svgflex src="assets/icons/home.svg" color="red" size="32"></svgflex>
|
|
@@ -65,6 +73,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
65
73
|
class SvgflexComponent {
|
|
66
74
|
svgLoader = inject(SvgLoaderService);
|
|
67
75
|
sanitizer = inject(DomSanitizer);
|
|
76
|
+
cdr = inject(ChangeDetectorRef);
|
|
68
77
|
/** Path or URL to the SVG file */
|
|
69
78
|
src;
|
|
70
79
|
/** Color for the SVG (defaults to 'currentColor') */
|
|
@@ -79,10 +88,13 @@ class SvgflexComponent {
|
|
|
79
88
|
alt;
|
|
80
89
|
/** Whether to inline the SVG (default: true) */
|
|
81
90
|
inline = true;
|
|
91
|
+
/** Whether to replace hardcoded colors with currentColor (default: true) */
|
|
92
|
+
replaceColors = true;
|
|
82
93
|
// Processed values
|
|
83
94
|
width = '24px';
|
|
84
95
|
height = '24px';
|
|
85
96
|
processedColor = 'currentColor';
|
|
97
|
+
processedReplaceColors = true;
|
|
86
98
|
svgContent = null;
|
|
87
99
|
// Apply CSS classes to :host element
|
|
88
100
|
get hostClasses() {
|
|
@@ -102,32 +114,35 @@ class SvgflexComponent {
|
|
|
102
114
|
size: this.size,
|
|
103
115
|
class: this.class,
|
|
104
116
|
ariaLabel: this.ariaLabel || this.alt,
|
|
105
|
-
inline: this.inline
|
|
117
|
+
inline: this.inline,
|
|
118
|
+
replaceColors: this.replaceColors
|
|
106
119
|
};
|
|
107
120
|
const processed = processSvgConfig(config);
|
|
108
121
|
this.width = processed.width;
|
|
109
122
|
this.height = processed.height;
|
|
110
123
|
this.processedColor = processed.color;
|
|
124
|
+
this.processedReplaceColors = processed.replaceColors;
|
|
111
125
|
this.ariaLabel = processed.ariaLabel;
|
|
112
126
|
console.log('[SvgflexComponent] Processed config:', {
|
|
113
127
|
width: this.width,
|
|
114
128
|
height: this.height,
|
|
115
129
|
color: this.processedColor,
|
|
130
|
+
replaceColors: this.processedReplaceColors,
|
|
116
131
|
src: this.src
|
|
117
132
|
});
|
|
118
133
|
// Load SVG content if inline mode is enabled
|
|
119
134
|
// Check if src or inline changed, or if it's the first change (firstChange)
|
|
120
|
-
if (this.inline && (changes['src'] || changes['inline'] || Object.keys(changes).length > 0)) {
|
|
135
|
+
if (this.inline && (changes['src'] || changes['inline'] || changes['replaceColors'] || Object.keys(changes).length > 0)) {
|
|
121
136
|
this.loadSvgContent();
|
|
122
137
|
}
|
|
123
138
|
}
|
|
124
139
|
loadSvgContent() {
|
|
125
|
-
console.log('[SvgflexComponent] loadSvgContent called, src:', this.src, 'inline:', this.inline);
|
|
140
|
+
console.log('[SvgflexComponent] loadSvgContent called, src:', this.src, 'inline:', this.inline, 'replaceColors:', this.processedReplaceColors);
|
|
126
141
|
if (!this.src) {
|
|
127
142
|
console.log('[SvgflexComponent] No src provided, skipping load');
|
|
128
143
|
return;
|
|
129
144
|
}
|
|
130
|
-
this.svgLoader.loadSvg(this.src).subscribe((content) => {
|
|
145
|
+
this.svgLoader.loadSvg(this.src, this.processedReplaceColors).subscribe((content) => {
|
|
131
146
|
console.log('[SvgflexComponent] Received SVG content, length:', content.length);
|
|
132
147
|
if (content) {
|
|
133
148
|
// SVG is already sanitized by SvgLoaderService
|
|
@@ -138,10 +153,12 @@ class SvgflexComponent {
|
|
|
138
153
|
else {
|
|
139
154
|
console.log('[SvgflexComponent] Received empty content');
|
|
140
155
|
}
|
|
156
|
+
// Manually trigger change detection for Zoneless compatibility
|
|
157
|
+
this.cdr.markForCheck();
|
|
141
158
|
});
|
|
142
159
|
}
|
|
143
160
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SvgflexComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
144
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: SvgflexComponent, isStandalone: true, selector: "svgflex", inputs: { src: "src", color: "color", size: "size", class: "class", ariaLabel: "ariaLabel", alt: "alt", inline: "inline" }, host: { properties: { "class": "this.hostClasses", "style.width": "this.hostWidth", "style.height": "this.hostHeight" } }, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"svgflex-container\"\n [style.color]=\"processedColor\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.role]=\"ariaLabel ? 'img' : null\"\n [attr.title]=\"ariaLabel\"\n>\n @if (inline && svgContent) {\n <div [innerHTML]=\"svgContent\" class=\"svgflex-inline\"></div>\n } @else if (!inline) {\n <img\n [src]=\"src\"\n [alt]=\"ariaLabel || ''\"\n [title]=\"ariaLabel\"\n [style.width]=\"width\"\n [style.height]=\"height\"\n />\n } @else {\n <div class=\"svgflex-loading\"></div>\n }\n</div>\n", styles: [":host{display:inline-block}:host.block{display:block}:host.flex{display:flex}.svgflex-container{display:flex;align-items:center;justify-content:center;width:100%;height:100%;color:inherit}.svgflex-inline{display:contents}.svgflex-inline ::ng-deep svg{width:100%;height:100%;fill:currentColor}.svgflex-inline ::ng-deep svg path,.svgflex-inline ::ng-deep svg circle,.svgflex-inline ::ng-deep svg rect,.svgflex-inline ::ng-deep svg polygon,.svgflex-inline ::ng-deep svg polyline,.svgflex-inline ::ng-deep svg ellipse,.svgflex-inline ::ng-deep svg line{fill:currentColor}.svgflex-inline ::ng-deep svg[stroke]{stroke:currentColor}.svgflex-inline ::ng-deep svg[stroke] path,.svgflex-inline ::ng-deep svg[stroke] circle,.svgflex-inline ::ng-deep svg[stroke] rect,.svgflex-inline ::ng-deep svg[stroke] polygon,.svgflex-inline ::ng-deep svg[stroke] polyline,.svgflex-inline ::ng-deep svg[stroke] ellipse,.svgflex-inline ::ng-deep svg[stroke] line{stroke:currentColor}.svgflex-loading{width:100%;height:100%;background-color:currentColor;opacity:.1;border-radius:2px}img{display:block;max-width:100%;max-height:100%}:host.icon-sm{width:16px;height:16px}:host.icon-md{width:24px;height:24px}:host.icon-lg{width:32px;height:32px}:host.icon-xl{width:48px;height:48px}:host.icon-2xl{width:64px;height:64px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
161
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: SvgflexComponent, isStandalone: true, selector: "svgflex", inputs: { src: "src", color: "color", size: "size", class: "class", ariaLabel: "ariaLabel", alt: "alt", inline: "inline", replaceColors: "replaceColors" }, host: { properties: { "class": "this.hostClasses", "style.width": "this.hostWidth", "style.height": "this.hostHeight" } }, usesOnChanges: true, ngImport: i0, template: "<div\n class=\"svgflex-container\"\n [style.color]=\"processedColor\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.role]=\"ariaLabel ? 'img' : null\"\n [attr.title]=\"ariaLabel\"\n>\n @if (inline && svgContent) {\n <div [innerHTML]=\"svgContent\" class=\"svgflex-inline\"></div>\n } @else if (!inline) {\n <img\n [src]=\"src\"\n [alt]=\"ariaLabel || ''\"\n [title]=\"ariaLabel\"\n [style.width]=\"width\"\n [style.height]=\"height\"\n />\n } @else {\n <div class=\"svgflex-loading\"></div>\n }\n</div>\n", styles: [":host{display:inline-block}:host.block{display:block}:host.flex{display:flex}.svgflex-container{display:flex;align-items:center;justify-content:center;width:100%;height:100%;color:inherit}.svgflex-inline{display:contents}.svgflex-inline ::ng-deep svg{width:100%;height:100%;fill:currentColor}.svgflex-inline ::ng-deep svg path,.svgflex-inline ::ng-deep svg circle,.svgflex-inline ::ng-deep svg rect,.svgflex-inline ::ng-deep svg polygon,.svgflex-inline ::ng-deep svg polyline,.svgflex-inline ::ng-deep svg ellipse,.svgflex-inline ::ng-deep svg line{fill:currentColor}.svgflex-inline ::ng-deep svg[stroke]{stroke:currentColor}.svgflex-inline ::ng-deep svg[stroke] path,.svgflex-inline ::ng-deep svg[stroke] circle,.svgflex-inline ::ng-deep svg[stroke] rect,.svgflex-inline ::ng-deep svg[stroke] polygon,.svgflex-inline ::ng-deep svg[stroke] polyline,.svgflex-inline ::ng-deep svg[stroke] ellipse,.svgflex-inline ::ng-deep svg[stroke] line{stroke:currentColor}.svgflex-loading{width:100%;height:100%;background-color:currentColor;opacity:.1;border-radius:2px}img{display:block;max-width:100%;max-height:100%}:host.icon-sm{width:16px;height:16px}:host.icon-md{width:24px;height:24px}:host.icon-lg{width:32px;height:32px}:host.icon-xl{width:48px;height:48px}:host.icon-2xl{width:64px;height:64px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
145
162
|
}
|
|
146
163
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: SvgflexComponent, decorators: [{
|
|
147
164
|
type: Component,
|
|
@@ -161,6 +178,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
161
178
|
type: Input
|
|
162
179
|
}], inline: [{
|
|
163
180
|
type: Input
|
|
181
|
+
}], replaceColors: [{
|
|
182
|
+
type: Input
|
|
164
183
|
}], hostClasses: [{
|
|
165
184
|
type: HostBinding,
|
|
166
185
|
args: ['class']
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svgflex-angular.mjs","sources":["../../../packages/angular/src/lib/services/svg-loader.service.ts","../../../packages/angular/src/lib/components/svgflex.component.ts","../../../packages/angular/src/lib/components/svgflex.component.html","../../../packages/angular/src/public-api.ts","../../../packages/angular/src/svgflex-angular.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\nimport { map, catchError, shareReplay } from 'rxjs/operators';\nimport { sanitizeSvg } from '@svgflex/core';\n\n/**\n * Service for loading and caching SVG content\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class SvgLoaderService {\n private cache = new Map<string, Observable<string>>();\n\n constructor(private http: HttpClient) {}\n\n /**\n * Loads SVG content from a URL with caching\n */\n loadSvg(url: string): Observable<string> {\n console.log('[SvgLoaderService] Loading SVG from:', url);\n\n if (this.cache.has(url)) {\n console.log('[SvgLoaderService] Returning cached SVG for:', url);\n return this.cache.get(url)!;\n }\n\n const svg$ = this.http.get(url, { responseType: 'text' }).pipe(\n map(svgContent => {\n console.log('[SvgLoaderService] Successfully loaded SVG from:', url, 'Length:', svgContent.length);\n return sanitizeSvg(svgContent);\n }),\n catchError(error => {\n console.error(`[SvgLoaderService] Failed to load SVG from ${url}:`, error);\n return of('');\n }),\n shareReplay(1)\n );\n\n this.cache.set(url, svg$);\n return svg$;\n }\n\n /**\n * Clears the SVG cache\n */\n clearCache(): void {\n this.cache.clear();\n }\n}\n","import {\n Component,\n Input,\n OnChanges,\n SimpleChanges,\n HostBinding,\n inject\n} from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { CommonModule } from '@angular/common';\nimport { SvgLoaderService } from '../services/svg-loader.service';\nimport { processSvgConfig, SvgFlexConfig, SvgSize, SvgColor } from '@svgflex/core';\n\n/**\n * SVGFlex Component\n *\n * Renders SVG icons with customizable color and size.\n * Supports both inline SVG (for full style control) and external references.\n *\n * @example\n * <svgflex src=\"assets/icons/home.svg\" color=\"red\" size=\"32\"></svgflex>\n * <svgflex src=\"assets/icons/user.svg\" color=\"currentColor\" [size]=\"{width: '2rem', height: '2rem'}\"></svgflex>\n */\n@Component({\n selector: 'svgflex',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './svgflex.component.html',\n styleUrl: './svgflex.component.scss'\n})\nexport class SvgflexComponent implements OnChanges {\n private svgLoader = inject(SvgLoaderService);\n private sanitizer = inject(DomSanitizer);\n\n /** Path or URL to the SVG file */\n @Input({ required: true }) src!: string;\n\n /** Color for the SVG (defaults to 'currentColor') */\n @Input() color?: SvgColor;\n\n /** Size for the SVG (number in px, string with units, or {width, height} object) */\n @Input() size?: SvgSize;\n\n /** Additional CSS classes */\n @Input() class?: string;\n\n /** Accessibility label */\n @Input() ariaLabel?: string;\n\n /** Alternative text / Accessibility label (alias for ariaLabel) */\n @Input() alt?: string;\n\n /** Whether to inline the SVG (default: true) */\n @Input() inline: boolean = true;\n\n // Processed values\n protected width: string = '24px';\n protected height: string = '24px';\n protected processedColor: string = 'currentColor';\n protected svgContent: any = null;\n\n // Apply CSS classes to :host element\n @HostBinding('class')\n get hostClasses(): string {\n return this.class || '';\n }\n\n // Apply inline styles to :host element when size is specified\n @HostBinding('style.width')\n get hostWidth(): string | null {\n return this.size ? this.width : null;\n }\n\n @HostBinding('style.height')\n get hostHeight(): string | null {\n return this.size ? this.height : null;\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n const config: SvgFlexConfig = {\n src: this.src,\n color: this.color,\n size: this.size,\n class: this.class,\n ariaLabel: this.ariaLabel || this.alt,\n inline: this.inline\n };\n\n const processed = processSvgConfig(config);\n\n this.width = processed.width;\n this.height = processed.height;\n this.processedColor = processed.color;\n this.ariaLabel = processed.ariaLabel;\n\n console.log('[SvgflexComponent] Processed config:', {\n width: this.width,\n height: this.height,\n color: this.processedColor,\n src: this.src\n });\n\n // Load SVG content if inline mode is enabled\n // Check if src or inline changed, or if it's the first change (firstChange)\n if (this.inline && (changes['src'] || changes['inline'] || Object.keys(changes).length > 0)) {\n this.loadSvgContent();\n }\n }\n\n private loadSvgContent(): void {\n console.log('[SvgflexComponent] loadSvgContent called, src:', this.src, 'inline:', this.inline);\n\n if (!this.src) {\n console.log('[SvgflexComponent] No src provided, skipping load');\n return;\n }\n\n this.svgLoader.loadSvg(this.src).subscribe((content: string) => {\n console.log('[SvgflexComponent] Received SVG content, length:', content.length);\n if (content) {\n // SVG is already sanitized by SvgLoaderService\n // Directly bypass security and trust the HTML\n this.svgContent = this.sanitizer.bypassSecurityTrustHtml(content);\n console.log('[SvgflexComponent] SVG content set successfully');\n } else {\n console.log('[SvgflexComponent] Received empty content');\n }\n });\n }\n}\n","<div\n class=\"svgflex-container\"\n [style.color]=\"processedColor\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.role]=\"ariaLabel ? 'img' : null\"\n [attr.title]=\"ariaLabel\"\n>\n @if (inline && svgContent) {\n <div [innerHTML]=\"svgContent\" class=\"svgflex-inline\"></div>\n } @else if (!inline) {\n <img\n [src]=\"src\"\n [alt]=\"ariaLabel || ''\"\n [title]=\"ariaLabel\"\n [style.width]=\"width\"\n [style.height]=\"height\"\n />\n } @else {\n <div class=\"svgflex-loading\"></div>\n }\n</div>\n","/*\n * Public API Surface of @svgflex/angular\n */\n\n// Components\nexport * from './lib/components/svgflex.component';\n\n// Services\nexport * from './lib/services/svg-loader.service';\n\n// Re-export core types and utils for convenience\nexport * from '@svgflex/core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAMA;;AAEG;MAIU,gBAAgB,CAAA;AAGP,IAAA,IAAA;AAFZ,IAAA,KAAK,GAAG,IAAI,GAAG,EAA8B;AAErD,IAAA,WAAA,CAAoB,IAAgB,EAAA;QAAhB,IAAA,CAAA,IAAI,GAAJ,IAAI;IAAe;AAEvC;;AAEG;AACH,IAAA,OAAO,CAAC,GAAW,EAAA;AACjB,QAAA,OAAO,CAAC,GAAG,CAAC,sCAAsC,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"version":3,"file":"svgflex-angular.mjs","sources":["../../../packages/angular/src/lib/services/svg-loader.service.ts","../../../packages/angular/src/lib/components/svgflex.component.ts","../../../packages/angular/src/lib/components/svgflex.component.html","../../../packages/angular/src/public-api.ts","../../../packages/angular/src/svgflex-angular.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\nimport { map, catchError, shareReplay } from 'rxjs/operators';\nimport { sanitizeSvg } from '@svgflex/core';\n\n/**\n * Service for loading and caching SVG content\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class SvgLoaderService {\n private cache = new Map<string, Map<boolean, Observable<string>>>();\n\n constructor(private http: HttpClient) {}\n\n /**\n * Loads SVG content from a URL with caching\n * @param url - URL to load the SVG from\n * @param replaceColors - Whether to replace hardcoded colors with currentColor (default: true)\n */\n loadSvg(url: string, replaceColors: boolean = true): Observable<string> {\n console.log('[SvgLoaderService] Loading SVG from:', url, 'replaceColors:', replaceColors);\n\n // Check cache with both url and replaceColors as key\n if (!this.cache.has(url)) {\n this.cache.set(url, new Map());\n }\n\n const urlCache = this.cache.get(url)!;\n if (urlCache.has(replaceColors)) {\n console.log('[SvgLoaderService] Returning cached SVG for:', url, 'replaceColors:', replaceColors);\n return urlCache.get(replaceColors)!;\n }\n\n const svg$ = this.http.get(url, { responseType: 'text' }).pipe(\n map(svgContent => {\n console.log('[SvgLoaderService] Successfully loaded SVG from:', url, 'Length:', svgContent.length);\n return sanitizeSvg(svgContent, replaceColors);\n }),\n catchError(error => {\n console.error(`[SvgLoaderService] Failed to load SVG from ${url}:`, error);\n return of('');\n }),\n shareReplay(1)\n );\n\n urlCache.set(replaceColors, svg$);\n return svg$;\n }\n\n /**\n * Clears the SVG cache\n */\n clearCache(): void {\n this.cache.clear();\n }\n}\n","import {\n Component,\n Input,\n OnChanges,\n SimpleChanges,\n HostBinding,\n inject,\n ChangeDetectorRef\n} from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { CommonModule } from '@angular/common';\nimport { SvgLoaderService } from '../services/svg-loader.service';\nimport { processSvgConfig, SvgFlexConfig, SvgSize, SvgColor } from '@svgflex/core';\n\n/**\n * SVGFlex Component\n *\n * Renders SVG icons with customizable color and size.\n * Supports both inline SVG (for full style control) and external references.\n * Compatible with both Zone.js and Zoneless Angular applications.\n *\n * @example\n * <svgflex src=\"assets/icons/home.svg\" color=\"red\" size=\"32\"></svgflex>\n * <svgflex src=\"assets/icons/user.svg\" color=\"currentColor\" [size]=\"{width: '2rem', height: '2rem'}\"></svgflex>\n */\n@Component({\n selector: 'svgflex',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './svgflex.component.html',\n styleUrl: './svgflex.component.scss'\n})\nexport class SvgflexComponent implements OnChanges {\n private svgLoader = inject(SvgLoaderService);\n private sanitizer = inject(DomSanitizer);\n private cdr = inject(ChangeDetectorRef);\n\n /** Path or URL to the SVG file */\n @Input({ required: true }) src!: string;\n\n /** Color for the SVG (defaults to 'currentColor') */\n @Input() color?: SvgColor;\n\n /** Size for the SVG (number in px, string with units, or {width, height} object) */\n @Input() size?: SvgSize;\n\n /** Additional CSS classes */\n @Input() class?: string;\n\n /** Accessibility label */\n @Input() ariaLabel?: string;\n\n /** Alternative text / Accessibility label (alias for ariaLabel) */\n @Input() alt?: string;\n\n /** Whether to inline the SVG (default: true) */\n @Input() inline: boolean = true;\n\n /** Whether to replace hardcoded colors with currentColor (default: true) */\n @Input() replaceColors: boolean = true;\n\n // Processed values\n protected width: string = '24px';\n protected height: string = '24px';\n protected processedColor: string = 'currentColor';\n protected processedReplaceColors: boolean = true;\n protected svgContent: any = null;\n\n // Apply CSS classes to :host element\n @HostBinding('class')\n get hostClasses(): string {\n return this.class || '';\n }\n\n // Apply inline styles to :host element when size is specified\n @HostBinding('style.width')\n get hostWidth(): string | null {\n return this.size ? this.width : null;\n }\n\n @HostBinding('style.height')\n get hostHeight(): string | null {\n return this.size ? this.height : null;\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n const config: SvgFlexConfig = {\n src: this.src,\n color: this.color,\n size: this.size,\n class: this.class,\n ariaLabel: this.ariaLabel || this.alt,\n inline: this.inline,\n replaceColors: this.replaceColors\n };\n\n const processed = processSvgConfig(config);\n\n this.width = processed.width;\n this.height = processed.height;\n this.processedColor = processed.color;\n this.processedReplaceColors = processed.replaceColors;\n this.ariaLabel = processed.ariaLabel;\n\n console.log('[SvgflexComponent] Processed config:', {\n width: this.width,\n height: this.height,\n color: this.processedColor,\n replaceColors: this.processedReplaceColors,\n src: this.src\n });\n\n // Load SVG content if inline mode is enabled\n // Check if src or inline changed, or if it's the first change (firstChange)\n if (this.inline && (changes['src'] || changes['inline'] || changes['replaceColors'] || Object.keys(changes).length > 0)) {\n this.loadSvgContent();\n }\n }\n\n private loadSvgContent(): void {\n console.log('[SvgflexComponent] loadSvgContent called, src:', this.src, 'inline:', this.inline, 'replaceColors:', this.processedReplaceColors);\n\n if (!this.src) {\n console.log('[SvgflexComponent] No src provided, skipping load');\n return;\n }\n\n this.svgLoader.loadSvg(this.src, this.processedReplaceColors).subscribe((content: string) => {\n console.log('[SvgflexComponent] Received SVG content, length:', content.length);\n if (content) {\n // SVG is already sanitized by SvgLoaderService\n // Directly bypass security and trust the HTML\n this.svgContent = this.sanitizer.bypassSecurityTrustHtml(content);\n console.log('[SvgflexComponent] SVG content set successfully');\n } else {\n console.log('[SvgflexComponent] Received empty content');\n }\n // Manually trigger change detection for Zoneless compatibility\n this.cdr.markForCheck();\n });\n }\n}\n","<div\n class=\"svgflex-container\"\n [style.color]=\"processedColor\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.role]=\"ariaLabel ? 'img' : null\"\n [attr.title]=\"ariaLabel\"\n>\n @if (inline && svgContent) {\n <div [innerHTML]=\"svgContent\" class=\"svgflex-inline\"></div>\n } @else if (!inline) {\n <img\n [src]=\"src\"\n [alt]=\"ariaLabel || ''\"\n [title]=\"ariaLabel\"\n [style.width]=\"width\"\n [style.height]=\"height\"\n />\n } @else {\n <div class=\"svgflex-loading\"></div>\n }\n</div>\n","/*\n * Public API Surface of @svgflex/angular\n */\n\n// Components\nexport * from './lib/components/svgflex.component';\n\n// Services\nexport * from './lib/services/svg-loader.service';\n\n// Re-export core types and utils for convenience\nexport * from '@svgflex/core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAMA;;AAEG;MAIU,gBAAgB,CAAA;AAGP,IAAA,IAAA;AAFZ,IAAA,KAAK,GAAG,IAAI,GAAG,EAA4C;AAEnE,IAAA,WAAA,CAAoB,IAAgB,EAAA;QAAhB,IAAA,CAAA,IAAI,GAAJ,IAAI;IAAe;AAEvC;;;;AAIG;AACH,IAAA,OAAO,CAAC,GAAW,EAAE,aAAA,GAAyB,IAAI,EAAA;QAChD,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,GAAG,EAAE,gBAAgB,EAAE,aAAa,CAAC;;QAGzF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC;QAChC;QAEA,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE;AACrC,QAAA,IAAI,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,8CAA8C,EAAE,GAAG,EAAE,gBAAgB,EAAE,aAAa,CAAC;AACjG,YAAA,OAAO,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAE;QACrC;QAEA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAC5D,GAAG,CAAC,UAAU,IAAG;AACf,YAAA,OAAO,CAAC,GAAG,CAAC,kDAAk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AEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Observable } from 'rxjs';
|
|
|
10
10
|
*
|
|
11
11
|
* Renders SVG icons with customizable color and size.
|
|
12
12
|
* Supports both inline SVG (for full style control) and external references.
|
|
13
|
+
* Compatible with both Zone.js and Zoneless Angular applications.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* <svgflex src="assets/icons/home.svg" color="red" size="32"></svgflex>
|
|
@@ -18,6 +19,7 @@ import { Observable } from 'rxjs';
|
|
|
18
19
|
declare class SvgflexComponent implements OnChanges {
|
|
19
20
|
private svgLoader;
|
|
20
21
|
private sanitizer;
|
|
22
|
+
private cdr;
|
|
21
23
|
/** Path or URL to the SVG file */
|
|
22
24
|
src: string;
|
|
23
25
|
/** Color for the SVG (defaults to 'currentColor') */
|
|
@@ -32,9 +34,12 @@ declare class SvgflexComponent implements OnChanges {
|
|
|
32
34
|
alt?: string;
|
|
33
35
|
/** Whether to inline the SVG (default: true) */
|
|
34
36
|
inline: boolean;
|
|
37
|
+
/** Whether to replace hardcoded colors with currentColor (default: true) */
|
|
38
|
+
replaceColors: boolean;
|
|
35
39
|
protected width: string;
|
|
36
40
|
protected height: string;
|
|
37
41
|
protected processedColor: string;
|
|
42
|
+
protected processedReplaceColors: boolean;
|
|
38
43
|
protected svgContent: any;
|
|
39
44
|
get hostClasses(): string;
|
|
40
45
|
get hostWidth(): string | null;
|
|
@@ -42,7 +47,7 @@ declare class SvgflexComponent implements OnChanges {
|
|
|
42
47
|
ngOnChanges(changes: SimpleChanges): void;
|
|
43
48
|
private loadSvgContent;
|
|
44
49
|
static ɵfac: i0.ɵɵFactoryDeclaration<SvgflexComponent, never>;
|
|
45
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SvgflexComponent, "svgflex", never, { "src": { "alias": "src"; "required": true; }; "color": { "alias": "color"; "required": false; }; "size": { "alias": "size"; "required": false; }; "class": { "alias": "class"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "alt": { "alias": "alt"; "required": false; }; "inline": { "alias": "inline"; "required": false; }; }, {}, never, never, true, never>;
|
|
50
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SvgflexComponent, "svgflex", never, { "src": { "alias": "src"; "required": true; }; "color": { "alias": "color"; "required": false; }; "size": { "alias": "size"; "required": false; }; "class": { "alias": "class"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "alt": { "alias": "alt"; "required": false; }; "inline": { "alias": "inline"; "required": false; }; "replaceColors": { "alias": "replaceColors"; "required": false; }; }, {}, never, never, true, never>;
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
/**
|
|
@@ -54,8 +59,10 @@ declare class SvgLoaderService {
|
|
|
54
59
|
constructor(http: HttpClient);
|
|
55
60
|
/**
|
|
56
61
|
* Loads SVG content from a URL with caching
|
|
62
|
+
* @param url - URL to load the SVG from
|
|
63
|
+
* @param replaceColors - Whether to replace hardcoded colors with currentColor (default: true)
|
|
57
64
|
*/
|
|
58
|
-
loadSvg(url: string): Observable<string>;
|
|
65
|
+
loadSvg(url: string, replaceColors?: boolean): Observable<string>;
|
|
59
66
|
/**
|
|
60
67
|
* Clears the SVG cache
|
|
61
68
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svgflex/angular",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Angular library for SVG icons with easy color and size customization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svg",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@angular/common": "^20.0.0",
|
|
30
30
|
"@angular/core": "^20.0.0",
|
|
31
|
-
"@svgflex/core": "^0.1.
|
|
31
|
+
"@svgflex/core": "^0.1.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"tslib": "^2.3.0"
|