1 | import { Component, HostBinding, Input, Optional } from '@angular/core';
|
---|
2 | import { DomSanitizer } from '@angular/platform-browser';
|
---|
3 | import { parse, text, } from '@fortawesome/fontawesome-svg-core';
|
---|
4 | import { faWarnIfParentNotExist } from '../shared/errors/warn-if-parent-not-exist';
|
---|
5 | import { faClassList } from '../shared/utils/classlist.util';
|
---|
6 | import { FaLayersComponent } from './layers.component';
|
---|
7 | export class FaLayersTextComponent {
|
---|
8 | constructor(parent, sanitizer) {
|
---|
9 | this.parent = parent;
|
---|
10 | this.sanitizer = sanitizer;
|
---|
11 | this.classes = [];
|
---|
12 | faWarnIfParentNotExist(this.parent, 'FaLayersComponent', this.constructor.name);
|
---|
13 | }
|
---|
14 | ngOnChanges(changes) {
|
---|
15 | if (changes) {
|
---|
16 | const params = this.buildParams();
|
---|
17 | this.updateContent(params);
|
---|
18 | }
|
---|
19 | }
|
---|
20 | /**
|
---|
21 | * Updating params by component props.
|
---|
22 | */
|
---|
23 | buildParams() {
|
---|
24 | const classOpts = {
|
---|
25 | flip: this.flip,
|
---|
26 | spin: this.spin,
|
---|
27 | pulse: this.pulse,
|
---|
28 | border: this.border,
|
---|
29 | inverse: this.inverse,
|
---|
30 | size: this.size || null,
|
---|
31 | pull: this.pull || null,
|
---|
32 | rotate: this.rotate || null,
|
---|
33 | fixedWidth: this.fixedWidth,
|
---|
34 | };
|
---|
35 | const parsedTransform = typeof this.transform === 'string' ? parse.transform(this.transform) : this.transform;
|
---|
36 | return {
|
---|
37 | transform: parsedTransform,
|
---|
38 | classes: [...faClassList(classOpts), ...this.classes],
|
---|
39 | title: this.title,
|
---|
40 | styles: this.styles,
|
---|
41 | };
|
---|
42 | }
|
---|
43 | updateContent(params) {
|
---|
44 | this.renderedHTML = this.sanitizer.bypassSecurityTrustHtml(text(this.content || '', params).html.join('\n'));
|
---|
45 | }
|
---|
46 | }
|
---|
47 | FaLayersTextComponent.decorators = [
|
---|
48 | { type: Component, args: [{
|
---|
49 | selector: 'fa-layers-text',
|
---|
50 | template: '',
|
---|
51 | host: {
|
---|
52 | class: 'ng-fa-layers-text',
|
---|
53 | }
|
---|
54 | },] }
|
---|
55 | ];
|
---|
56 | FaLayersTextComponent.ctorParameters = () => [
|
---|
57 | { type: FaLayersComponent, decorators: [{ type: Optional }] },
|
---|
58 | { type: DomSanitizer }
|
---|
59 | ];
|
---|
60 | FaLayersTextComponent.propDecorators = {
|
---|
61 | content: [{ type: Input }],
|
---|
62 | title: [{ type: Input }],
|
---|
63 | styles: [{ type: Input }],
|
---|
64 | classes: [{ type: Input }],
|
---|
65 | spin: [{ type: Input }],
|
---|
66 | pulse: [{ type: Input }],
|
---|
67 | flip: [{ type: Input }],
|
---|
68 | size: [{ type: Input }],
|
---|
69 | pull: [{ type: Input }],
|
---|
70 | border: [{ type: Input }],
|
---|
71 | inverse: [{ type: Input }],
|
---|
72 | rotate: [{ type: Input }],
|
---|
73 | fixedWidth: [{ type: Input }],
|
---|
74 | transform: [{ type: Input }],
|
---|
75 | renderedHTML: [{ type: HostBinding, args: ['innerHTML',] }]
|
---|
76 | };
|
---|
77 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF5ZXJzLXRleHQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi9sYXllcnMvbGF5ZXJzLXRleHQuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsV0FBVyxFQUFFLEtBQUssRUFBYSxRQUFRLEVBQWlCLE1BQU0sZUFBZSxDQUFDO0FBQ2xHLE9BQU8sRUFBRSxZQUFZLEVBQVksTUFBTSwyQkFBMkIsQ0FBQztBQUNuRSxPQUFPLEVBRUwsS0FBSyxFQUtMLElBQUksR0FHTCxNQUFNLG1DQUFtQyxDQUFDO0FBQzNDLE9BQU8sRUFBRSxzQkFBc0IsR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