45 lines
5.3 KiB
JavaScript
45 lines
5.3 KiB
JavaScript
|
import { Component, Input, ChangeDetectionStrategy, ViewEncapsulation, booleanAttribute } from '@angular/core';
|
||
|
import { ObjectUtils } from 'primeng/utils';
|
||
|
import * as i0 from "@angular/core";
|
||
|
export class BaseIcon {
|
||
|
label;
|
||
|
spin = false;
|
||
|
styleClass;
|
||
|
role;
|
||
|
ariaLabel;
|
||
|
ariaHidden;
|
||
|
ngOnInit() {
|
||
|
this.getAttributes();
|
||
|
}
|
||
|
getAttributes() {
|
||
|
const isLabelEmpty = ObjectUtils.isEmpty(this.label);
|
||
|
this.role = !isLabelEmpty ? 'img' : undefined;
|
||
|
this.ariaLabel = !isLabelEmpty ? this.label : undefined;
|
||
|
this.ariaHidden = isLabelEmpty;
|
||
|
}
|
||
|
getClassNames() {
|
||
|
return `p-icon ${this.styleClass ? this.styleClass + ' ' : ''}${this.spin ? 'p-icon-spin' : ''}`;
|
||
|
}
|
||
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: BaseIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
||
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: BaseIcon, isStandalone: true, selector: "ng-component", inputs: { label: "label", spin: ["spin", "spin", booleanAttribute], styleClass: "styleClass" }, host: { classAttribute: "p-element p-icon-wrapper" }, ngImport: i0, template: ` <ng-content></ng-content> `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
||
|
}
|
||
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: BaseIcon, decorators: [{
|
||
|
type: Component,
|
||
|
args: [{
|
||
|
template: ` <ng-content></ng-content> `,
|
||
|
standalone: true,
|
||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||
|
encapsulation: ViewEncapsulation.None,
|
||
|
host: {
|
||
|
class: 'p-element p-icon-wrapper'
|
||
|
}
|
||
|
}]
|
||
|
}], propDecorators: { label: [{
|
||
|
type: Input
|
||
|
}], spin: [{
|
||
|
type: Input,
|
||
|
args: [{ transform: booleanAttribute }]
|
||
|
}], styleClass: [{
|
||
|
type: Input
|
||
|
}] } });
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZWljb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvYmFzZWljb24vYmFzZWljb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsaUJBQWlCLEVBQTJCLGdCQUFnQixFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3hJLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxlQUFlLENBQUM7O0FBVzVDLE1BQU0sT0FBTyxRQUFRO0lBQ1IsS0FBSyxDQUFTO0lBRWlCLElBQUksR0FBWSxLQUFLLENBQUM7SUFFckQsVUFBVSxDQUFTO0lBRTVCLElBQUksQ0FBUztJQUViLFNBQVMsQ0FBUztJQUVsQixVQUFVLENBQVU7SUFFcEIsUUFBUTtRQUNKLElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztJQUN6QixDQUFDO0lBRUQsYUFBYTtRQUNULE1BQU0sWUFBWSxHQUFHLFdBQVcsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1FBQ3JELElBQUksQ0FBQyxJQUFJLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsU0FBUyxDQUFDO1FBQzlDLElBQUksQ0FBQyxTQUFTLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLElBQUks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