129 lines
13 KiB
JavaScript
129 lines
13 KiB
JavaScript
import { CommonModule } from '@angular/common';
|
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, NgModule, Output, ViewEncapsulation } from '@angular/core';
|
|
import * as i0 from "@angular/core";
|
|
import * as i1 from "@angular/common";
|
|
/**
|
|
* Avatar represents people using icons, labels and images.
|
|
* @group Components
|
|
*/
|
|
export class Avatar {
|
|
/**
|
|
* Defines the text to display.
|
|
* @group Props
|
|
*/
|
|
label;
|
|
/**
|
|
* Defines the icon to display.
|
|
* @group Props
|
|
*/
|
|
icon;
|
|
/**
|
|
* Defines the image to display.
|
|
* @group Props
|
|
*/
|
|
image;
|
|
/**
|
|
* Size of the element.
|
|
* @group Props
|
|
*/
|
|
size = 'normal';
|
|
/**
|
|
* Shape of the element.
|
|
* @group Props
|
|
*/
|
|
shape = 'square';
|
|
/**
|
|
* Inline style of the element.
|
|
* @group Props
|
|
*/
|
|
style;
|
|
/**
|
|
* Class of the element.
|
|
* @group Props
|
|
*/
|
|
styleClass;
|
|
/**
|
|
* Establishes a string value that labels the component.
|
|
* @group Props
|
|
*/
|
|
ariaLabel;
|
|
/**
|
|
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
|
|
* @group Props
|
|
*/
|
|
ariaLabelledBy;
|
|
/**
|
|
* This event is triggered if an error occurs while loading an image file.
|
|
* @param {Event} event - Browser event.
|
|
* @group Emits
|
|
*/
|
|
onImageError = new EventEmitter();
|
|
containerClass() {
|
|
return {
|
|
'p-avatar p-component': true,
|
|
'p-avatar-image': this.image != null,
|
|
'p-avatar-circle': this.shape === 'circle',
|
|
'p-avatar-lg': this.size === 'large',
|
|
'p-avatar-xl': this.size === 'xlarge'
|
|
};
|
|
}
|
|
imageError(event) {
|
|
this.onImageError.emit(event);
|
|
}
|
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Avatar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: Avatar, selector: "p-avatar", inputs: { label: "label", icon: "icon", image: "image", size: "size", shape: "shape", style: "style", styleClass: "styleClass", ariaLabel: "ariaLabel", ariaLabelledBy: "ariaLabelledBy" }, outputs: { onImageError: "onImageError" }, host: { classAttribute: "p-element" }, ngImport: i0, template: `
|
|
<div [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-label]="ariaLabel" [attr.data-pc-name]="'avatar'">
|
|
<ng-content></ng-content>
|
|
<span class="p-avatar-text" *ngIf="label; else iconTemplate">{{ label }}</span>
|
|
<ng-template #iconTemplate><span [class]="icon" [ngClass]="'p-avatar-icon'" *ngIf="icon; else imageTemplate"></span></ng-template>
|
|
<ng-template #imageTemplate><img [src]="image" *ngIf="image" (error)="imageError($event)" [attr.aria-label]="ariaLabel" /></ng-template>
|
|
</div>
|
|
`, isInline: true, styles: ["@layer primeng{.p-avatar{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;font-size:1rem}.p-avatar.p-avatar-image{background-color:transparent}.p-avatar.p-avatar-circle{border-radius:50%;overflow:hidden}.p-avatar .p-avatar-icon{font-size:1rem}.p-avatar img{width:100%;height:100%}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Avatar, decorators: [{
|
|
type: Component,
|
|
args: [{ selector: 'p-avatar', template: `
|
|
<div [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style" [attr.aria-labelledby]="ariaLabelledBy" [attr.aria-label]="ariaLabel" [attr.data-pc-name]="'avatar'">
|
|
<ng-content></ng-content>
|
|
<span class="p-avatar-text" *ngIf="label; else iconTemplate">{{ label }}</span>
|
|
<ng-template #iconTemplate><span [class]="icon" [ngClass]="'p-avatar-icon'" *ngIf="icon; else imageTemplate"></span></ng-template>
|
|
<ng-template #imageTemplate><img [src]="image" *ngIf="image" (error)="imageError($event)" [attr.aria-label]="ariaLabel" /></ng-template>
|
|
</div>
|
|
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
class: 'p-element'
|
|
}, styles: ["@layer primeng{.p-avatar{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;font-size:1rem}.p-avatar.p-avatar-image{background-color:transparent}.p-avatar.p-avatar-circle{border-radius:50%;overflow:hidden}.p-avatar .p-avatar-icon{font-size:1rem}.p-avatar img{width:100%;height:100%}}\n"] }]
|
|
}], propDecorators: { label: [{
|
|
type: Input
|
|
}], icon: [{
|
|
type: Input
|
|
}], image: [{
|
|
type: Input
|
|
}], size: [{
|
|
type: Input
|
|
}], shape: [{
|
|
type: Input
|
|
}], style: [{
|
|
type: Input
|
|
}], styleClass: [{
|
|
type: Input
|
|
}], ariaLabel: [{
|
|
type: Input
|
|
}], ariaLabelledBy: [{
|
|
type: Input
|
|
}], onImageError: [{
|
|
type: Output
|
|
}] } });
|
|
export class AvatarModule {
|
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AvatarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: AvatarModule, declarations: [Avatar], imports: [CommonModule], exports: [Avatar] });
|
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AvatarModule, imports: [CommonModule] });
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: AvatarModule, decorators: [{
|
|
type: NgModule,
|
|
args: [{
|
|
imports: [CommonModule],
|
|
exports: [Avatar],
|
|
declarations: [Avatar]
|
|
}]
|
|
}] });
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXZhdGFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9jb21wb25lbnRzL2F2YXRhci9hdmF0YXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQy9DLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxTQUFTLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxFQUFFLGlCQUFpQixFQUFFLE1BQU0sZUFBZSxDQUFDOzs7QUFDN0g7OztHQUdHO0FBa0JILE1BQU0sT0FBTyxNQUFNO0lBQ2Y7OztPQUdHO0lBQ00sS0FBSyxDQUFxQjtJQUNuQzs7O09BR0c7SUFDTSxJQUFJLENBQXFCO0lBQ2xDOzs7T0FHRztJQUNNLEtBQUssQ0FBcUI7SUFDbkM7OztPQUdHO0lBQ00sSUFBSSxHQUE4QyxRQUFRLENBQUM7SUFDcEU7OztPQUdHO0lBQ00sS0FBSyxHQUFvQyxRQUFRLENBQUM7SUFDM0Q7OztPQUdHO0lBQ00sS0FBSyxDQUE4QztJQUM1RDs7O09BR0c7SUFDTSxVQUFVLENBQXFCO0lBQ3hDOzs7T0FHRztJQUNNLFNBQVMsQ0FBcUI7SUFDdkM7OztPQUdHO0lBQ00sY0FBYyxDQUFxQjtJQUM1Qzs7OztPQUlHO0lBQ08sWUFBWSxHQUF3QixJQUFJLFlBQVksRUFBUyxDQUFDO0lBRXhFLGNBQWM7UUF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