@coreui/icons-angular 5.2.22 → 5.2.24
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/esm2022/lib/icon/icon.component.mjs +65 -86
- package/esm2022/lib/icon/icon.directive.mjs +58 -107
- package/esm2022/lib/icon/icon.interface.mjs +1 -1
- package/esm2022/lib/icon/icon.module.mjs +5 -5
- package/esm2022/lib/icon-set/icon-set.module.mjs +5 -5
- package/esm2022/lib/icon-set/icon-set.service.mjs +10 -12
- package/esm2022/lib/shared/html-attr.directive.mjs +29 -28
- package/fesm2022/coreui-icons-angular.mjs +164 -235
- package/fesm2022/coreui-icons-angular.mjs.map +1 -1
- package/lib/icon/icon.component.d.ts +19 -27
- package/lib/icon/icon.directive.d.ts +16 -29
- package/lib/icon/icon.interface.d.ts +15 -12
- package/lib/icon-set/icon-set.service.d.ts +2 -5
- package/lib/shared/html-attr.directive.d.ts +5 -10
- package/package.json +1 -1
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, NgModule, Optional, SkipSelf, inject,
|
|
2
|
+
import { Injectable, NgModule, Optional, SkipSelf, inject, input, computed, Directive, Renderer2, ElementRef, effect, signal, viewChild, afterNextRender, Component } from '@angular/core';
|
|
3
3
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
4
|
import { NgClass } from '@angular/common';
|
|
5
5
|
|
|
6
6
|
class IconSetService {
|
|
7
|
-
constructor() {
|
|
8
|
-
this._iconNames = {};
|
|
9
|
-
this._icons = {};
|
|
10
|
-
}
|
|
11
7
|
get iconNames() {
|
|
12
|
-
return this
|
|
8
|
+
return this.#iconNames;
|
|
13
9
|
}
|
|
10
|
+
#iconNames = {};
|
|
14
11
|
get icons() {
|
|
15
|
-
return this
|
|
12
|
+
return this.#icons;
|
|
16
13
|
}
|
|
17
14
|
set icons(iconSet) {
|
|
18
15
|
for (const iconsKey in iconSet) {
|
|
19
|
-
this
|
|
16
|
+
this.#iconNames[iconsKey] = iconsKey;
|
|
20
17
|
}
|
|
21
|
-
this
|
|
18
|
+
this.#icons = iconSet;
|
|
22
19
|
}
|
|
20
|
+
#icons = {};
|
|
23
21
|
getIcon(name) {
|
|
24
22
|
const icon = this.icons[name];
|
|
25
23
|
if (!icon) {
|
|
@@ -27,10 +25,10 @@ class IconSetService {
|
|
|
27
25
|
}
|
|
28
26
|
return this.icons[name];
|
|
29
27
|
}
|
|
30
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
31
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.
|
|
28
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
29
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetService, providedIn: 'root' }); }
|
|
32
30
|
}
|
|
33
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetService, decorators: [{
|
|
34
32
|
type: Injectable,
|
|
35
33
|
args: [{
|
|
36
34
|
providedIn: 'root'
|
|
@@ -51,11 +49,11 @@ class IconSetModule {
|
|
|
51
49
|
]
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
55
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.
|
|
56
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.
|
|
52
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetModule, deps: [{ token: IconSetModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
53
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: IconSetModule }); }
|
|
54
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetModule, providers: [IconSetService] }); }
|
|
57
55
|
}
|
|
58
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
56
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconSetModule, decorators: [{
|
|
59
57
|
type: NgModule,
|
|
60
58
|
args: [{
|
|
61
59
|
providers: [IconSetService]
|
|
@@ -76,160 +74,114 @@ function transformName(value) {
|
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
class IconDirective {
|
|
79
|
-
#elementRef;
|
|
80
|
-
#sanitizer;
|
|
81
|
-
#iconSet;
|
|
82
77
|
constructor() {
|
|
83
|
-
this.#elementRef = inject(ElementRef);
|
|
84
78
|
this.#sanitizer = inject(DomSanitizer);
|
|
85
79
|
this.#iconSet = inject(IconSetService);
|
|
86
|
-
this
|
|
87
|
-
this.
|
|
88
|
-
this
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
80
|
+
this.content = input(undefined, { alias: 'cIcon' });
|
|
81
|
+
this.customClasses = input();
|
|
82
|
+
this.size = input('');
|
|
83
|
+
this.title = input();
|
|
84
|
+
this.height = input();
|
|
85
|
+
this.width = input();
|
|
86
|
+
this.name = input('', { transform: transformName });
|
|
87
|
+
this.viewBoxInput = input(undefined, { alias: 'viewBox' });
|
|
88
|
+
this.xmlns = input('http://www.w3.org/2000/svg');
|
|
89
|
+
this.pointerEvents = input('none', { alias: 'pointer-events' });
|
|
90
|
+
this.role = input('img');
|
|
91
|
+
this.hostClasses = computed(() => {
|
|
92
|
+
const computedSize = this.computedSize();
|
|
93
|
+
const classes = {
|
|
94
|
+
icon: true,
|
|
95
|
+
[`icon-${computedSize}`]: !!computedSize
|
|
96
|
+
};
|
|
97
|
+
return this.customClasses() ?? classes;
|
|
98
|
+
});
|
|
99
|
+
this.viewBox = computed(() => {
|
|
100
|
+
return this.viewBoxInput() ?? this.scale();
|
|
101
|
+
});
|
|
93
102
|
this.innerHtml = computed(() => {
|
|
94
|
-
const
|
|
103
|
+
const codeVal = this.code();
|
|
104
|
+
const code = Array.isArray(codeVal) ? (codeVal?.[1] ?? codeVal?.[0] ?? '') : codeVal || '';
|
|
95
105
|
// todo proper sanitize
|
|
96
106
|
// const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, code);
|
|
97
|
-
return this.#sanitizer.bypassSecurityTrustHtml(this
|
|
107
|
+
return this.#sanitizer.bypassSecurityTrustHtml(this.#titleCode() + code || '');
|
|
108
|
+
});
|
|
109
|
+
this.#titleCode = computed(() => {
|
|
110
|
+
return this.title() ? `<title>${this.title()}</title>` : '';
|
|
98
111
|
});
|
|
99
112
|
this.code = computed(() => {
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
const content = this.content();
|
|
114
|
+
if (content) {
|
|
115
|
+
return content;
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
const name = this.name();
|
|
118
|
+
if (this.#iconSet && name) {
|
|
119
|
+
return this.#iconSet.getIcon(name);
|
|
105
120
|
}
|
|
106
|
-
if (
|
|
107
|
-
console.warn(`cIcon directive: The '${
|
|
121
|
+
if (name && !this.#iconSet?.icons[name]) {
|
|
122
|
+
console.warn(`cIcon directive: The '${name}' icon not found. Add it to the IconSet service for use with the 'name' property. \n`, name);
|
|
108
123
|
}
|
|
109
124
|
return '';
|
|
110
125
|
});
|
|
111
126
|
this.scale = computed(() => {
|
|
112
127
|
return Array.isArray(this.code()) && (this.code()?.length ?? 0) > 1 ? `0 0 ${this.code()?.[0]}` : '0 0 64 64';
|
|
113
128
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
129
|
+
this.computedSize = computed(() => {
|
|
130
|
+
const addCustom = !this.size() && (this.width() || this.height());
|
|
131
|
+
return this.size() === 'custom' || addCustom ? 'custom-size' : this.size();
|
|
118
132
|
});
|
|
119
133
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.#name.set(value);
|
|
126
|
-
}
|
|
127
|
-
get name() {
|
|
128
|
-
return this.#name();
|
|
129
|
-
}
|
|
130
|
-
#name;
|
|
131
|
-
set viewBox(viewBox) {
|
|
132
|
-
this._viewBox = viewBox;
|
|
133
|
-
}
|
|
134
|
-
get viewBox() {
|
|
135
|
-
return this._viewBox ?? this.scale();
|
|
136
|
-
}
|
|
137
|
-
get hostClasses() {
|
|
138
|
-
return this.computedClasses;
|
|
139
|
-
}
|
|
140
|
-
get titleCode() {
|
|
141
|
-
return this.title ? `<title>${this.title}</title>` : '';
|
|
142
|
-
}
|
|
143
|
-
get computedSize() {
|
|
144
|
-
const addCustom = !this.size && (this.width || this.height);
|
|
145
|
-
return this.size === 'custom' || addCustom ? 'custom-size' : this.size;
|
|
146
|
-
}
|
|
147
|
-
get computedClasses() {
|
|
148
|
-
const classes = {
|
|
149
|
-
icon: true,
|
|
150
|
-
[`icon-${this.computedSize}`]: !!this.computedSize
|
|
151
|
-
};
|
|
152
|
-
return this.customClasses ?? classes;
|
|
153
|
-
}
|
|
154
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
155
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.2.9", type: IconDirective, isStandalone: true, selector: "svg[cIcon]", inputs: { content: ["cIcon", "content"], customClasses: "customClasses", size: "size", title: "title", height: "height", width: "width", name: ["name", "name", transformName], viewBox: "viewBox", xmlns: "xmlns", pointerEvents: ["pointer-events", "pointerEvents"], role: "role" }, host: { attributes: { "ngSkipHydration": "true" }, properties: { "innerHtml": "innerHtml()", "attr.viewBox": "this.viewBox", "attr.aria-hidden": "this.ariaHidden", "attr.xmlns": "this.xmlns", "attr.pointer-events": "this.pointerEvents", "attr.role": "this.role", "class": "this.hostClasses" } }, exportAs: ["cIcon"], ngImport: i0 }); }
|
|
134
|
+
#sanitizer;
|
|
135
|
+
#iconSet;
|
|
136
|
+
#titleCode;
|
|
137
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
138
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: IconDirective, isStandalone: true, selector: "svg[cIcon]", inputs: { content: { classPropertyName: "content", publicName: "cIcon", isSignal: true, isRequired: false, transformFunction: null }, customClasses: { classPropertyName: "customClasses", publicName: "customClasses", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, viewBoxInput: { classPropertyName: "viewBoxInput", publicName: "viewBox", isSignal: true, isRequired: false, transformFunction: null }, xmlns: { classPropertyName: "xmlns", publicName: "xmlns", isSignal: true, isRequired: false, transformFunction: null }, pointerEvents: { classPropertyName: "pointerEvents", publicName: "pointer-events", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "ngSkipHydration": "true" }, properties: { "innerHtml": "innerHtml()", "class": "hostClasses()", "attr.viewBox": "viewBox()", "attr.xmlns": "xmlns()", "attr.pointer-events": "pointerEvents()", "attr.role": "role()", "attr.aria-hidden": "true" } }, exportAs: ["cIcon"], ngImport: i0 }); }
|
|
156
139
|
}
|
|
157
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconDirective, decorators: [{
|
|
158
141
|
type: Directive,
|
|
159
142
|
args: [{
|
|
160
143
|
exportAs: 'cIcon',
|
|
161
144
|
selector: 'svg[cIcon]',
|
|
162
145
|
standalone: true,
|
|
163
|
-
host: {
|
|
146
|
+
host: {
|
|
147
|
+
ngSkipHydration: 'true',
|
|
148
|
+
'[innerHtml]': 'innerHtml()',
|
|
149
|
+
'[class]': 'hostClasses()',
|
|
150
|
+
'[attr.viewBox]': 'viewBox()',
|
|
151
|
+
'[attr.xmlns]': 'xmlns()',
|
|
152
|
+
'[attr.pointer-events]': 'pointerEvents()',
|
|
153
|
+
'[attr.role]': 'role()',
|
|
154
|
+
'[attr.aria-hidden]': 'true'
|
|
155
|
+
}
|
|
164
156
|
}]
|
|
165
|
-
}]
|
|
166
|
-
type: Input,
|
|
167
|
-
args: ['cIcon']
|
|
168
|
-
}], customClasses: [{
|
|
169
|
-
type: Input
|
|
170
|
-
}], size: [{
|
|
171
|
-
type: Input
|
|
172
|
-
}], title: [{
|
|
173
|
-
type: Input
|
|
174
|
-
}], height: [{
|
|
175
|
-
type: Input
|
|
176
|
-
}], width: [{
|
|
177
|
-
type: Input
|
|
178
|
-
}], name: [{
|
|
179
|
-
type: Input,
|
|
180
|
-
args: [{ transform: transformName }]
|
|
181
|
-
}], viewBox: [{
|
|
182
|
-
type: HostBinding,
|
|
183
|
-
args: ['attr.viewBox']
|
|
184
|
-
}, {
|
|
185
|
-
type: Input
|
|
186
|
-
}], ariaHidden: [{
|
|
187
|
-
type: HostBinding,
|
|
188
|
-
args: ['attr.aria-hidden']
|
|
189
|
-
}], xmlns: [{
|
|
190
|
-
type: HostBinding,
|
|
191
|
-
args: ['attr.xmlns']
|
|
192
|
-
}, {
|
|
193
|
-
type: Input
|
|
194
|
-
}], pointerEvents: [{
|
|
195
|
-
type: HostBinding,
|
|
196
|
-
args: ['attr.pointer-events']
|
|
197
|
-
}, {
|
|
198
|
-
type: Input,
|
|
199
|
-
args: ['pointer-events']
|
|
200
|
-
}], role: [{
|
|
201
|
-
type: HostBinding,
|
|
202
|
-
args: ['attr.role']
|
|
203
|
-
}, {
|
|
204
|
-
type: Input
|
|
205
|
-
}], hostClasses: [{
|
|
206
|
-
type: HostBinding,
|
|
207
|
-
args: ['class']
|
|
208
|
-
}] } });
|
|
157
|
+
}] });
|
|
209
158
|
|
|
210
159
|
class HtmlAttributesDirective {
|
|
211
|
-
constructor(
|
|
212
|
-
this.
|
|
213
|
-
this
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
160
|
+
constructor() {
|
|
161
|
+
this.cHtmlAttr = input();
|
|
162
|
+
this.#renderer = inject(Renderer2);
|
|
163
|
+
this.#elementRef = inject(ElementRef);
|
|
164
|
+
this.attrEffect = effect(() => {
|
|
165
|
+
const attribs = this.cHtmlAttr();
|
|
166
|
+
for (const attr in attribs) {
|
|
167
|
+
if (attr === 'style' && typeof attribs[attr] === 'object') {
|
|
168
|
+
this.setStyle(attribs[attr]);
|
|
169
|
+
}
|
|
170
|
+
else if (attr === 'class') {
|
|
171
|
+
this.addClass(attribs[attr]);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.setAttrib(attr, attribs[attr]);
|
|
175
|
+
}
|
|
226
176
|
}
|
|
227
|
-
}
|
|
177
|
+
});
|
|
228
178
|
}
|
|
179
|
+
#renderer;
|
|
180
|
+
#elementRef;
|
|
229
181
|
setStyle(styles) {
|
|
230
182
|
for (const style in styles) {
|
|
231
183
|
if (style) {
|
|
232
|
-
this
|
|
184
|
+
this.#renderer.setStyle(this.#elementRef.nativeElement, style, styles[style]);
|
|
233
185
|
}
|
|
234
186
|
}
|
|
235
187
|
}
|
|
@@ -238,147 +190,124 @@ class HtmlAttributesDirective {
|
|
|
238
190
|
classArray
|
|
239
191
|
.filter((element) => element.length > 0)
|
|
240
192
|
.forEach((element) => {
|
|
241
|
-
this
|
|
193
|
+
this.#renderer.addClass(this.#elementRef.nativeElement, element);
|
|
242
194
|
});
|
|
243
195
|
}
|
|
244
196
|
setAttrib(key, value) {
|
|
245
197
|
value !== null
|
|
246
|
-
? this
|
|
247
|
-
: this
|
|
198
|
+
? this.#renderer.setAttribute(this.#elementRef.nativeElement, key, value)
|
|
199
|
+
: this.#renderer.removeAttribute(this.#elementRef.nativeElement, key);
|
|
248
200
|
}
|
|
249
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
250
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
201
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HtmlAttributesDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
202
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: HtmlAttributesDirective, isStandalone: true, selector: "[cHtmlAttr]", inputs: { cHtmlAttr: { classPropertyName: "cHtmlAttr", publicName: "cHtmlAttr", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cHtmlAttr"], ngImport: i0 }); }
|
|
251
203
|
}
|
|
252
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HtmlAttributesDirective, decorators: [{
|
|
253
205
|
type: Directive,
|
|
254
206
|
args: [{
|
|
255
207
|
selector: '[cHtmlAttr]',
|
|
256
208
|
exportAs: 'cHtmlAttr',
|
|
257
209
|
standalone: true
|
|
258
210
|
}]
|
|
259
|
-
}]
|
|
260
|
-
type: Input
|
|
261
|
-
}] } });
|
|
211
|
+
}] });
|
|
262
212
|
|
|
263
213
|
class IconComponent {
|
|
264
214
|
#renderer;
|
|
265
215
|
#elementRef;
|
|
266
216
|
#sanitizer;
|
|
267
217
|
#iconSet;
|
|
218
|
+
#hostElement;
|
|
268
219
|
constructor() {
|
|
269
220
|
this.#renderer = inject(Renderer2);
|
|
270
221
|
this.#elementRef = inject(ElementRef);
|
|
271
222
|
this.#sanitizer = inject(DomSanitizer);
|
|
272
223
|
this.#iconSet = inject(IconSetService);
|
|
273
|
-
this.#
|
|
274
|
-
this.
|
|
275
|
-
this.
|
|
276
|
-
this.
|
|
277
|
-
this
|
|
224
|
+
this.#hostElement = signal(undefined);
|
|
225
|
+
this.content = input();
|
|
226
|
+
this.attributes = input({ role: 'img' });
|
|
227
|
+
this.customClasses = input();
|
|
228
|
+
this.size = input('');
|
|
229
|
+
this.title = input();
|
|
230
|
+
this.use = input('');
|
|
231
|
+
this.height = input();
|
|
232
|
+
this.width = input();
|
|
233
|
+
this.name = input('', { transform: transformName });
|
|
234
|
+
this.viewBoxInput = input(undefined, { alias: 'viewBox' });
|
|
235
|
+
this.svgElementRef = viewChild('svgElement');
|
|
236
|
+
this.svgElementEffect = effect(() => {
|
|
237
|
+
const svgElementRef = this.svgElementRef();
|
|
238
|
+
const hostElement = this.#hostElement()?.nativeElement;
|
|
239
|
+
if (svgElementRef && hostElement) {
|
|
240
|
+
const svgElement = svgElementRef.nativeElement;
|
|
241
|
+
hostElement.classList?.values()?.forEach((item) => {
|
|
242
|
+
this.#renderer.addClass(svgElement, item);
|
|
243
|
+
});
|
|
244
|
+
const parentElement = this.#renderer.parentNode(hostElement);
|
|
245
|
+
this.#renderer.insertBefore(parentElement, svgElement, hostElement);
|
|
246
|
+
this.#renderer.removeChild(parentElement, hostElement);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
this.viewBox = computed(() => {
|
|
250
|
+
return this.viewBoxInput() ?? this.scale();
|
|
251
|
+
});
|
|
278
252
|
this.innerHtml = computed(() => {
|
|
279
|
-
const
|
|
253
|
+
const codeVal = this.code();
|
|
254
|
+
const code = Array.isArray(codeVal) ? (codeVal?.[1] ?? codeVal?.[0] ?? '') : codeVal || '';
|
|
280
255
|
// todo proper sanitize
|
|
281
256
|
// const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, code);
|
|
282
|
-
return this.#sanitizer.bypassSecurityTrustHtml(this
|
|
257
|
+
return this.#sanitizer.bypassSecurityTrustHtml(this.#titleCode() + code || '');
|
|
258
|
+
});
|
|
259
|
+
this.#titleCode = computed(() => {
|
|
260
|
+
return this.title() ? `<title>${this.title()}</title>` : '';
|
|
283
261
|
});
|
|
284
262
|
this.code = computed(() => {
|
|
285
|
-
|
|
286
|
-
|
|
263
|
+
const content = this.content();
|
|
264
|
+
if (content) {
|
|
265
|
+
return content;
|
|
287
266
|
}
|
|
288
|
-
|
|
289
|
-
|
|
267
|
+
const name = this.name();
|
|
268
|
+
if (this.#iconSet && name) {
|
|
269
|
+
return this.#iconSet.getIcon(name);
|
|
290
270
|
}
|
|
291
|
-
if (
|
|
292
|
-
console.warn(`c-icon component:
|
|
293
|
-
`To use icon by 'name' prop you need to add it to IconSet service. \n`, this.#name());
|
|
271
|
+
if (name && !this.#iconSet?.icons[name]) {
|
|
272
|
+
console.warn(`c-icon component: The '${name}' icon not found. Add it to the IconSet service for use with the 'name' property. \n`, name);
|
|
294
273
|
}
|
|
295
274
|
return '';
|
|
296
275
|
});
|
|
297
276
|
this.scale = computed(() => {
|
|
298
|
-
return Array.isArray(this.code()) && this.code()
|
|
277
|
+
return Array.isArray(this.code()) && (this.code()?.length ?? 0) > 1 ? `0 0 ${this.code()?.[0]}` : '0 0 64 64';
|
|
299
278
|
});
|
|
300
|
-
this
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
set viewBox(viewBox) {
|
|
314
|
-
this._viewBox = viewBox;
|
|
315
|
-
}
|
|
316
|
-
get viewBox() {
|
|
317
|
-
return this._viewBox ?? this.scale();
|
|
318
|
-
}
|
|
319
|
-
ngAfterViewInit() {
|
|
320
|
-
this.#elementRef.nativeElement.classList.forEach((item) => {
|
|
321
|
-
this.#renderer.addClass(this.svgElementRef.nativeElement, item);
|
|
279
|
+
this.computedSize = computed(() => {
|
|
280
|
+
const addCustom = !this.size() && (this.width() || this.height());
|
|
281
|
+
return this.size() === 'custom' || addCustom ? 'custom-size' : this.size();
|
|
282
|
+
});
|
|
283
|
+
this.computedClasses = computed(() => {
|
|
284
|
+
const classes = {
|
|
285
|
+
icon: true,
|
|
286
|
+
[`icon-${this.computedSize()}`]: !!this.computedSize()
|
|
287
|
+
};
|
|
288
|
+
return this.customClasses() ?? classes;
|
|
289
|
+
});
|
|
290
|
+
afterNextRender(() => {
|
|
291
|
+
this.#hostElement.set(this.#elementRef);
|
|
322
292
|
});
|
|
323
|
-
const parentElement = this.#renderer.parentNode(this.#elementRef.nativeElement);
|
|
324
|
-
const svgElement = this.svgElementRef.nativeElement;
|
|
325
|
-
this.#renderer.insertBefore(parentElement, svgElement, this.#elementRef.nativeElement);
|
|
326
|
-
this.#renderer.removeChild(parentElement, this.#elementRef.nativeElement);
|
|
327
|
-
}
|
|
328
|
-
get titleCode() {
|
|
329
|
-
return this.title ? `<title>${this.title}</title>` : '';
|
|
330
|
-
}
|
|
331
|
-
get computedSize() {
|
|
332
|
-
const addCustom = !this.size && (this.width || this.height);
|
|
333
|
-
return this.size === 'custom' || addCustom ? 'custom-size' : this.size;
|
|
334
|
-
}
|
|
335
|
-
get computedClasses() {
|
|
336
|
-
const classes = {
|
|
337
|
-
icon: true,
|
|
338
|
-
[`icon-${this.computedSize}`]: !!this.computedSize
|
|
339
|
-
};
|
|
340
|
-
return this.customClasses ?? classes;
|
|
341
293
|
}
|
|
342
|
-
|
|
343
|
-
static { this.ɵ
|
|
294
|
+
#titleCode;
|
|
295
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
296
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.11", type: IconComponent, isStandalone: true, selector: "c-icon", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, attributes: { classPropertyName: "attributes", publicName: "attributes", isSignal: true, isRequired: false, transformFunction: null }, customClasses: { classPropertyName: "customClasses", publicName: "customClasses", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, use: { classPropertyName: "use", publicName: "use", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, viewBoxInput: { classPropertyName: "viewBoxInput", publicName: "viewBox", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "ngSkipHydration": "true" }, styleAttribute: "display: none" }, viewQueries: [{ propertyName: "svgElementRef", first: true, predicate: ["svgElement"], descendants: true, isSignal: true }], exportAs: ["cIconComponent"], ngImport: i0, template: "@if (!use() && !!code()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width()\"\n [attr.height]=\"height() || width()\"\n [attr.viewBox]=\"viewBox() ?? scale()\"\n [innerHtml]=\"innerHtml()\"\n [ngClass]=\"computedClasses()\"\n [cHtmlAttr]=\"attributes()\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n </svg>\n} @else if (use()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width()\"\n [attr.height]=\"height() || width()\"\n [ngClass]=\"computedClasses()\"\n [cHtmlAttr]=\"attributes()\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n <use [attr.href]=\"use()\"></use>\n </svg>\n}\n", styles: [".icon{display:inline-block;color:inherit;text-align:center;vertical-align:-.125rem;fill:currentColor}.icon:not(.icon-c-s):not(.icon-custom-size){width:1rem;height:1rem;font-size:1rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xxl{width:2rem;height:2rem;font-size:2rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xl{width:1.5rem;height:1.5rem;font-size:1.5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-lg{width:1.25rem;height:1.25rem;font-size:1.25rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-sm{width:.875rem;height:.875rem;font-size:.875rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-3xl{width:3rem;height:3rem;font-size:3rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-4xl{width:4rem;height:4rem;font-size:4rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-5xl{width:5rem;height:5rem;font-size:5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-6xl{width:6rem;height:6rem;font-size:6rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-7xl{width:7rem;height:7rem;font-size:7rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-8xl{width:8rem;height:8rem;font-size:8rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-9xl{width:9rem;height:9rem;font-size:9rem}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: HtmlAttributesDirective, selector: "[cHtmlAttr]", inputs: ["cHtmlAttr"], exportAs: ["cHtmlAttr"] }] }); }
|
|
344
297
|
}
|
|
345
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconComponent, decorators: [{
|
|
346
299
|
type: Component,
|
|
347
|
-
args: [{ exportAs: 'cIconComponent', imports: [NgClass, HtmlAttributesDirective], selector: 'c-icon', standalone: true, host: { ngSkipHydration: 'true' }, template: "@if (!use && !!code) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width\"\n [attr.height]=\"height || width\"\n [attr.viewBox]=\"viewBox\"\n [innerHtml]=\"innerHtml()\"\n [ngClass]=\"computedClasses\"\n [cHtmlAttr]=\"attributes\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n </svg>\n} @else if (use) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width\"\n [attr.height]=\"height || width\"\n [ngClass]=\"computedClasses\"\n [cHtmlAttr]=\"attributes\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n <use [attr.href]=\"use\"></use>\n </svg>\n}\n", styles: [".icon{display:inline-block;color:inherit;text-align:center;vertical-align:-.125rem;fill:currentColor}.icon:not(.icon-c-s):not(.icon-custom-size){width:1rem;height:1rem;font-size:1rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xxl{width:2rem;height:2rem;font-size:2rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xl{width:1.5rem;height:1.5rem;font-size:1.5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-lg{width:1.25rem;height:1.25rem;font-size:1.25rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-sm{width:.875rem;height:.875rem;font-size:.875rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-3xl{width:3rem;height:3rem;font-size:3rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-4xl{width:4rem;height:4rem;font-size:4rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-5xl{width:5rem;height:5rem;font-size:5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-6xl{width:6rem;height:6rem;font-size:6rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-7xl{width:7rem;height:7rem;font-size:7rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-8xl{width:8rem;height:8rem;font-size:8rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-9xl{width:9rem;height:9rem;font-size:9rem}\n"] }]
|
|
348
|
-
}], ctorParameters: () => []
|
|
349
|
-
type: Input
|
|
350
|
-
}], attributes: [{
|
|
351
|
-
type: Input
|
|
352
|
-
}], customClasses: [{
|
|
353
|
-
type: Input
|
|
354
|
-
}], size: [{
|
|
355
|
-
type: Input
|
|
356
|
-
}], title: [{
|
|
357
|
-
type: Input
|
|
358
|
-
}], use: [{
|
|
359
|
-
type: Input
|
|
360
|
-
}], height: [{
|
|
361
|
-
type: Input
|
|
362
|
-
}], width: [{
|
|
363
|
-
type: Input
|
|
364
|
-
}], name: [{
|
|
365
|
-
type: Input,
|
|
366
|
-
args: [{ transform: transformName }]
|
|
367
|
-
}], viewBox: [{
|
|
368
|
-
type: Input
|
|
369
|
-
}], svgElementRef: [{
|
|
370
|
-
type: ViewChild,
|
|
371
|
-
args: ['svgElement', { read: ElementRef }]
|
|
372
|
-
}] } });
|
|
300
|
+
args: [{ exportAs: 'cIconComponent', imports: [NgClass, HtmlAttributesDirective], selector: 'c-icon', standalone: true, host: { ngSkipHydration: 'true', style: 'display: none' }, template: "@if (!use() && !!code()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width()\"\n [attr.height]=\"height() || width()\"\n [attr.viewBox]=\"viewBox() ?? scale()\"\n [innerHtml]=\"innerHtml()\"\n [ngClass]=\"computedClasses()\"\n [cHtmlAttr]=\"attributes()\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n </svg>\n} @else if (use()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.width]=\"width()\"\n [attr.height]=\"height() || width()\"\n [ngClass]=\"computedClasses()\"\n [cHtmlAttr]=\"attributes()\"\n aria-hidden=\"true\"\n pointer-events=\"none\"\n role=\"img\"\n #svgElement\n >\n <use [attr.href]=\"use()\"></use>\n </svg>\n}\n", styles: [".icon{display:inline-block;color:inherit;text-align:center;vertical-align:-.125rem;fill:currentColor}.icon:not(.icon-c-s):not(.icon-custom-size){width:1rem;height:1rem;font-size:1rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xxl{width:2rem;height:2rem;font-size:2rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-xl{width:1.5rem;height:1.5rem;font-size:1.5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-lg{width:1.25rem;height:1.25rem;font-size:1.25rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-sm{width:.875rem;height:.875rem;font-size:.875rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-3xl{width:3rem;height:3rem;font-size:3rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-4xl{width:4rem;height:4rem;font-size:4rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-5xl{width:5rem;height:5rem;font-size:5rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-6xl{width:6rem;height:6rem;font-size:6rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-7xl{width:7rem;height:7rem;font-size:7rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-8xl{width:8rem;height:8rem;font-size:8rem}.icon:not(.icon-c-s):not(.icon-custom-size).icon-9xl{width:9rem;height:9rem;font-size:9rem}\n"] }]
|
|
301
|
+
}], ctorParameters: () => [] });
|
|
373
302
|
|
|
374
303
|
class IconModule {
|
|
375
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
376
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.
|
|
304
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
305
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: IconModule, imports: [IconComponent,
|
|
377
306
|
IconDirective], exports: [IconComponent,
|
|
378
307
|
IconDirective] }); }
|
|
379
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.
|
|
308
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconModule }); }
|
|
380
309
|
}
|
|
381
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: IconModule, decorators: [{
|
|
382
311
|
type: NgModule,
|
|
383
312
|
args: [{
|
|
384
313
|
imports: [
|