74 lines
8.8 KiB
JavaScript
74 lines
8.8 KiB
JavaScript
import { Component, HostBinding, Input, Optional } from '@angular/core';
|
|
import { counter } from '@fortawesome/fontawesome-svg-core';
|
|
import { faWarnIfParentNotExist } from '../shared/errors/warn-if-parent-not-exist';
|
|
import * as i0 from "@angular/core";
|
|
import * as i1 from "./layers.component";
|
|
import * as i2 from "@angular/platform-browser";
|
|
export class FaLayersCounterComponent {
|
|
constructor(parent, sanitizer) {
|
|
this.parent = parent;
|
|
this.sanitizer = sanitizer;
|
|
/**
|
|
* Set `class` attribute on the SVG element rendered by the component.
|
|
*
|
|
* @deprecated This input breaks view encapsulation and is not recommended.
|
|
* For simple cases (like colors), use `class` on the component itself, for
|
|
* more complex usages, explicitly opt-in to break the view encapsulation.
|
|
* This input is deprecated since 0.12.0 and will be removed in 0.13.0.
|
|
*/
|
|
this.classes = [];
|
|
faWarnIfParentNotExist(this.parent, 'FaLayersComponent', this.constructor.name);
|
|
}
|
|
ngOnChanges(changes) {
|
|
if (changes) {
|
|
const params = this.buildParams();
|
|
this.updateContent(params);
|
|
}
|
|
}
|
|
buildParams() {
|
|
const classes = [];
|
|
if (this.classes != null) {
|
|
classes.push(...this.classes);
|
|
}
|
|
if (this.position != null) {
|
|
classes.push(`fa-layers-${this.position}`);
|
|
}
|
|
return {
|
|
title: this.title,
|
|
classes,
|
|
styles: this.styles,
|
|
};
|
|
}
|
|
updateContent(params) {
|
|
this.renderedHTML = this.sanitizer.bypassSecurityTrustHtml(counter(this.content || '', params).html.join(''));
|
|
}
|
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0", ngImport: i0, type: FaLayersCounterComponent, deps: [{ token: i1.FaLayersComponent, optional: true }, { token: i2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.0", type: FaLayersCounterComponent, isStandalone: true, selector: "fa-layers-counter", inputs: { content: "content", title: "title", styles: "styles", classes: "classes", position: "position" }, host: { properties: { "innerHTML": "this.renderedHTML" }, classAttribute: "ng-fa-layers-counter" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true }); }
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0", ngImport: i0, type: FaLayersCounterComponent, decorators: [{
|
|
type: Component,
|
|
args: [{
|
|
selector: 'fa-layers-counter',
|
|
standalone: true,
|
|
template: '',
|
|
host: {
|
|
class: 'ng-fa-layers-counter',
|
|
},
|
|
}]
|
|
}], ctorParameters: () => [{ type: i1.FaLayersComponent, decorators: [{
|
|
type: Optional
|
|
}] }, { type: i2.DomSanitizer }], propDecorators: { content: [{
|
|
type: Input
|
|
}], title: [{
|
|
type: Input
|
|
}], styles: [{
|
|
type: Input
|
|
}], classes: [{
|
|
type: Input
|
|
}], position: [{
|
|
type: Input
|
|
}], renderedHTML: [{
|
|
type: HostBinding,
|
|
args: ['innerHTML']
|
|
}] } });
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF5ZXJzLWNvdW50ZXIuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2xpYi9sYXllcnMvbGF5ZXJzLWNvdW50ZXIuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsV0FBVyxFQUFFLEtBQUssRUFBYSxRQUFRLEVBQWlCLE1BQU0sZUFBZSxDQUFDO0FBRWxHLE9BQU8sRUFBRSxPQUFPLEVBQXlCLE1BQU0sbUNBQW1DLENBQUM7QUFDbkYsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sMkNBQTJDLENBQUM7Ozs7QUFXbkYsTUFBTSxPQUFPLHdCQUF3QjtJQTJCbkMsWUFDc0IsTUFBeUIsRUFDckMsU0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