@coreui/icons-angular 5.2.21 → 5.2.23
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 +60 -115
- package/esm2022/lib/icon/icon.interface.mjs +1 -1
- package/esm2022/lib/icon/icon.module.mjs +4 -4
- package/esm2022/lib/icon-set/icon-set.module.mjs +4 -4
- 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 +166 -243
- 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 -30
- 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.9", ngImport: i0, type: IconSetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
29
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.9", 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.9", 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.9", 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.9", ngImport: i0, type: IconSetModule }); }
|
|
54
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.9", 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.9", ngImport: i0, type: IconSetModule, decorators: [{
|
|
59
57
|
type: NgModule,
|
|
60
58
|
args: [{
|
|
61
59
|
providers: [IconSetService]
|
|
@@ -76,166 +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(`
|
|
108
|
-
`To use icon by 'name' prop you need to add it to IconSet service. \n`, this.#name());
|
|
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);
|
|
109
123
|
}
|
|
110
124
|
return '';
|
|
111
125
|
});
|
|
112
126
|
this.scale = computed(() => {
|
|
113
|
-
return Array.isArray(this.code()) && this.code()
|
|
127
|
+
return Array.isArray(this.code()) && (this.code()?.length ?? 0) > 1 ? `0 0 ${this.code()?.[0]}` : '0 0 64 64';
|
|
114
128
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
129
|
+
this.computedSize = computed(() => {
|
|
130
|
+
const addCustom = !this.size() && (this.width() || this.height());
|
|
131
|
+
return this.size() === 'custom' || addCustom ? 'custom-size' : this.size();
|
|
119
132
|
});
|
|
120
133
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.#name.set(value);
|
|
127
|
-
}
|
|
128
|
-
get name() {
|
|
129
|
-
return this.#name();
|
|
130
|
-
}
|
|
131
|
-
#name;
|
|
132
|
-
set viewBox(viewBox) {
|
|
133
|
-
this._viewBox = viewBox;
|
|
134
|
-
}
|
|
135
|
-
get viewBox() {
|
|
136
|
-
return this._viewBox ?? this.scale();
|
|
137
|
-
}
|
|
138
|
-
get hostClasses() {
|
|
139
|
-
return this.computedClasses;
|
|
140
|
-
}
|
|
141
|
-
get bindInnerHtml() {
|
|
142
|
-
return this.innerHtml();
|
|
143
|
-
}
|
|
144
|
-
get titleCode() {
|
|
145
|
-
return this.title ? `<title>${this.title}</title>` : '';
|
|
146
|
-
}
|
|
147
|
-
get computedSize() {
|
|
148
|
-
const addCustom = !this.size && (this.width || this.height);
|
|
149
|
-
return this.size === 'custom' || addCustom ? 'custom-size' : this.size;
|
|
150
|
-
}
|
|
151
|
-
get computedClasses() {
|
|
152
|
-
const classes = {
|
|
153
|
-
icon: true,
|
|
154
|
-
[`icon-${this.computedSize}`]: !!this.computedSize
|
|
155
|
-
};
|
|
156
|
-
return this.customClasses ?? classes;
|
|
157
|
-
}
|
|
158
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.8", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
159
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.2.8", 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: { properties: { "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", "innerHtml": "this.bindInnerHtml" } }, exportAs: ["cIcon"], ngImport: i0 }); }
|
|
134
|
+
#sanitizer;
|
|
135
|
+
#iconSet;
|
|
136
|
+
#titleCode;
|
|
137
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
138
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.9", 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 }); }
|
|
160
139
|
}
|
|
161
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconDirective, decorators: [{
|
|
162
141
|
type: Directive,
|
|
163
142
|
args: [{
|
|
164
143
|
exportAs: 'cIcon',
|
|
165
144
|
selector: 'svg[cIcon]',
|
|
166
|
-
standalone: true
|
|
145
|
+
standalone: true,
|
|
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
|
+
}
|
|
167
156
|
}]
|
|
168
|
-
}]
|
|
169
|
-
type: Input,
|
|
170
|
-
args: ['cIcon']
|
|
171
|
-
}], customClasses: [{
|
|
172
|
-
type: Input
|
|
173
|
-
}], size: [{
|
|
174
|
-
type: Input
|
|
175
|
-
}], title: [{
|
|
176
|
-
type: Input
|
|
177
|
-
}], height: [{
|
|
178
|
-
type: Input
|
|
179
|
-
}], width: [{
|
|
180
|
-
type: Input
|
|
181
|
-
}], name: [{
|
|
182
|
-
type: Input,
|
|
183
|
-
args: [{ transform: transformName }]
|
|
184
|
-
}], viewBox: [{
|
|
185
|
-
type: HostBinding,
|
|
186
|
-
args: ['attr.viewBox']
|
|
187
|
-
}, {
|
|
188
|
-
type: Input
|
|
189
|
-
}], ariaHidden: [{
|
|
190
|
-
type: HostBinding,
|
|
191
|
-
args: ['attr.aria-hidden']
|
|
192
|
-
}], xmlns: [{
|
|
193
|
-
type: HostBinding,
|
|
194
|
-
args: ['attr.xmlns']
|
|
195
|
-
}, {
|
|
196
|
-
type: Input
|
|
197
|
-
}], pointerEvents: [{
|
|
198
|
-
type: HostBinding,
|
|
199
|
-
args: ['attr.pointer-events']
|
|
200
|
-
}, {
|
|
201
|
-
type: Input,
|
|
202
|
-
args: ['pointer-events']
|
|
203
|
-
}], role: [{
|
|
204
|
-
type: HostBinding,
|
|
205
|
-
args: ['attr.role']
|
|
206
|
-
}, {
|
|
207
|
-
type: Input
|
|
208
|
-
}], hostClasses: [{
|
|
209
|
-
type: HostBinding,
|
|
210
|
-
args: ['class']
|
|
211
|
-
}], bindInnerHtml: [{
|
|
212
|
-
type: HostBinding,
|
|
213
|
-
args: ['innerHtml']
|
|
214
|
-
}] } });
|
|
157
|
+
}] });
|
|
215
158
|
|
|
216
159
|
class HtmlAttributesDirective {
|
|
217
|
-
constructor(
|
|
218
|
-
this.
|
|
219
|
-
this
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
}
|
|
232
176
|
}
|
|
233
|
-
}
|
|
177
|
+
});
|
|
234
178
|
}
|
|
179
|
+
#renderer;
|
|
180
|
+
#elementRef;
|
|
235
181
|
setStyle(styles) {
|
|
236
182
|
for (const style in styles) {
|
|
237
183
|
if (style) {
|
|
238
|
-
this
|
|
184
|
+
this.#renderer.setStyle(this.#elementRef.nativeElement, style, styles[style]);
|
|
239
185
|
}
|
|
240
186
|
}
|
|
241
187
|
}
|
|
@@ -244,147 +190,124 @@ class HtmlAttributesDirective {
|
|
|
244
190
|
classArray
|
|
245
191
|
.filter((element) => element.length > 0)
|
|
246
192
|
.forEach((element) => {
|
|
247
|
-
this
|
|
193
|
+
this.#renderer.addClass(this.#elementRef.nativeElement, element);
|
|
248
194
|
});
|
|
249
195
|
}
|
|
250
196
|
setAttrib(key, value) {
|
|
251
197
|
value !== null
|
|
252
|
-
? this
|
|
253
|
-
: this
|
|
198
|
+
? this.#renderer.setAttribute(this.#elementRef.nativeElement, key, value)
|
|
199
|
+
: this.#renderer.removeAttribute(this.#elementRef.nativeElement, key);
|
|
254
200
|
}
|
|
255
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
256
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
201
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: HtmlAttributesDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
202
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.9", type: HtmlAttributesDirective, isStandalone: true, selector: "[cHtmlAttr]", inputs: { cHtmlAttr: { classPropertyName: "cHtmlAttr", publicName: "cHtmlAttr", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["cHtmlAttr"], ngImport: i0 }); }
|
|
257
203
|
}
|
|
258
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: HtmlAttributesDirective, decorators: [{
|
|
259
205
|
type: Directive,
|
|
260
206
|
args: [{
|
|
261
207
|
selector: '[cHtmlAttr]',
|
|
262
208
|
exportAs: 'cHtmlAttr',
|
|
263
209
|
standalone: true
|
|
264
210
|
}]
|
|
265
|
-
}]
|
|
266
|
-
type: Input
|
|
267
|
-
}] } });
|
|
211
|
+
}] });
|
|
268
212
|
|
|
269
213
|
class IconComponent {
|
|
270
214
|
#renderer;
|
|
271
215
|
#elementRef;
|
|
272
216
|
#sanitizer;
|
|
273
217
|
#iconSet;
|
|
218
|
+
#hostElement;
|
|
274
219
|
constructor() {
|
|
275
220
|
this.#renderer = inject(Renderer2);
|
|
276
221
|
this.#elementRef = inject(ElementRef);
|
|
277
222
|
this.#sanitizer = inject(DomSanitizer);
|
|
278
223
|
this.#iconSet = inject(IconSetService);
|
|
279
|
-
this.#
|
|
280
|
-
this.
|
|
281
|
-
this.
|
|
282
|
-
this.
|
|
283
|
-
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
|
+
});
|
|
284
252
|
this.innerHtml = computed(() => {
|
|
285
|
-
const
|
|
253
|
+
const codeVal = this.code();
|
|
254
|
+
const code = Array.isArray(codeVal) ? (codeVal?.[1] ?? codeVal?.[0] ?? '') : codeVal || '';
|
|
286
255
|
// todo proper sanitize
|
|
287
256
|
// const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, code);
|
|
288
|
-
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>` : '';
|
|
289
261
|
});
|
|
290
262
|
this.code = computed(() => {
|
|
291
|
-
|
|
292
|
-
|
|
263
|
+
const content = this.content();
|
|
264
|
+
if (content) {
|
|
265
|
+
return content;
|
|
293
266
|
}
|
|
294
|
-
|
|
295
|
-
|
|
267
|
+
const name = this.name();
|
|
268
|
+
if (this.#iconSet && name) {
|
|
269
|
+
return this.#iconSet.getIcon(name);
|
|
296
270
|
}
|
|
297
|
-
if (
|
|
298
|
-
console.warn(`c-icon component:
|
|
299
|
-
`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);
|
|
300
273
|
}
|
|
301
274
|
return '';
|
|
302
275
|
});
|
|
303
276
|
this.scale = computed(() => {
|
|
304
|
-
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';
|
|
305
278
|
});
|
|
306
|
-
this
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
set viewBox(viewBox) {
|
|
320
|
-
this._viewBox = viewBox;
|
|
321
|
-
}
|
|
322
|
-
get viewBox() {
|
|
323
|
-
return this._viewBox ?? this.scale();
|
|
324
|
-
}
|
|
325
|
-
ngAfterViewInit() {
|
|
326
|
-
this.#elementRef.nativeElement.classList.forEach((item) => {
|
|
327
|
-
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);
|
|
328
292
|
});
|
|
329
|
-
const parentElement = this.#renderer.parentNode(this.#elementRef.nativeElement);
|
|
330
|
-
const svgElement = this.svgElementRef.nativeElement;
|
|
331
|
-
this.#renderer.insertBefore(parentElement, svgElement, this.#elementRef.nativeElement);
|
|
332
|
-
this.#renderer.removeChild(parentElement, this.#elementRef.nativeElement);
|
|
333
|
-
}
|
|
334
|
-
get titleCode() {
|
|
335
|
-
return this.title ? `<title>${this.title}</title>` : '';
|
|
336
|
-
}
|
|
337
|
-
get computedSize() {
|
|
338
|
-
const addCustom = !this.size && (this.width || this.height);
|
|
339
|
-
return this.size === 'custom' || addCustom ? 'custom-size' : this.size;
|
|
340
|
-
}
|
|
341
|
-
get computedClasses() {
|
|
342
|
-
const classes = {
|
|
343
|
-
icon: true,
|
|
344
|
-
[`icon-${this.computedSize}`]: !!this.computedSize
|
|
345
|
-
};
|
|
346
|
-
return this.customClasses ?? classes;
|
|
347
293
|
}
|
|
348
|
-
|
|
349
|
-
static { this.ɵ
|
|
294
|
+
#titleCode;
|
|
295
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
296
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.9", 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"] }] }); }
|
|
350
297
|
}
|
|
351
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconComponent, decorators: [{
|
|
352
299
|
type: Component,
|
|
353
|
-
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"] }]
|
|
354
|
-
}], ctorParameters: () => []
|
|
355
|
-
type: Input
|
|
356
|
-
}], attributes: [{
|
|
357
|
-
type: Input
|
|
358
|
-
}], customClasses: [{
|
|
359
|
-
type: Input
|
|
360
|
-
}], size: [{
|
|
361
|
-
type: Input
|
|
362
|
-
}], title: [{
|
|
363
|
-
type: Input
|
|
364
|
-
}], use: [{
|
|
365
|
-
type: Input
|
|
366
|
-
}], height: [{
|
|
367
|
-
type: Input
|
|
368
|
-
}], width: [{
|
|
369
|
-
type: Input
|
|
370
|
-
}], name: [{
|
|
371
|
-
type: Input,
|
|
372
|
-
args: [{ transform: transformName }]
|
|
373
|
-
}], viewBox: [{
|
|
374
|
-
type: Input
|
|
375
|
-
}], svgElementRef: [{
|
|
376
|
-
type: ViewChild,
|
|
377
|
-
args: ['svgElement', { read: ElementRef }]
|
|
378
|
-
}] } });
|
|
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: () => [] });
|
|
379
302
|
|
|
380
303
|
class IconModule {
|
|
381
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
382
|
-
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.9", ngImport: i0, type: IconModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
305
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.9", ngImport: i0, type: IconModule, imports: [IconComponent,
|
|
383
306
|
IconDirective], exports: [IconComponent,
|
|
384
307
|
IconDirective] }); }
|
|
385
|
-
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.9", ngImport: i0, type: IconModule }); }
|
|
386
309
|
}
|
|
387
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: IconModule, decorators: [{
|
|
388
311
|
type: NgModule,
|
|
389
312
|
args: [{
|
|
390
313
|
imports: [
|