primeng
Version:
PrimeNG is a premium UI library for Angular featuring a rich set of 90+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBlock,
212 lines (207 loc) • 10.7 kB
JavaScript
export * from 'primeng/types/avatar';
import * as i0 from '@angular/core';
import { Injectable, InjectionToken, inject, input, output, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { SharedModule } from 'primeng/api';
import { BaseComponent, PARENT_INSTANCE } from 'primeng/basecomponent';
import * as i1 from 'primeng/bind';
import { Bind } from 'primeng/bind';
import { style } from '@primeuix/styles/avatar';
import { BaseStyle } from 'primeng/base';
const classes = {
root: ({ instance }) => {
const image = instance.image();
const shape = instance.shape();
const size = instance.size();
return [
'p-avatar p-component',
{
'p-avatar-image': image != null,
'p-avatar-circle': shape === 'circle',
'p-avatar-lg': size === 'large',
'p-avatar-xl': size === 'xlarge'
}
];
},
label: 'p-avatar-label',
icon: 'p-avatar-icon'
};
class AvatarStyle extends BaseStyle {
name = 'avatar';
style = style;
classes = classes;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarStyle, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarStyle });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarStyle, decorators: [{
type: Injectable
}] });
/**
*
* Avatar represents people using icons, labels and images.
*
* - [Live Demo](https://primeng.dev/avatar)
*
* @module avatarstyle
*
*/
var AvatarClasses;
(function (AvatarClasses) {
/**
* Class name of the root element
*/
AvatarClasses["root"] = "p-avatar";
/**
* Class name of the label element
*/
AvatarClasses["label"] = "p-avatar-label";
/**
* Class name of the icon element
*/
AvatarClasses["icon"] = "p-avatar-icon";
/**
* Container element in image mode
*/
AvatarClasses["image"] = "p-avatar-image";
/**
* Container element with a circle shape
*/
AvatarClasses["circle"] = "p-avatar-circle";
/**
* Container element with a large size
*/
AvatarClasses["large"] = "p-avatar-lg";
/**
* Container element with an xlarge size
*/
AvatarClasses["xlarge"] = "p-avatar-xl";
})(AvatarClasses || (AvatarClasses = {}));
const AVATAR_INSTANCE = new InjectionToken('AVATAR_INSTANCE');
/**
* Avatar represents people using icons, labels and images.
* @group Components
*/
class Avatar extends BaseComponent {
componentName = 'Avatar';
$pcAvatar = inject(AVATAR_INSTANCE, { optional: true, skipSelf: true }) ?? undefined;
bindDirectiveInstance = inject(Bind, { self: true });
onAfterViewChecked() {
this.bindDirectiveInstance.setAttrs(this.ptms(['host', 'root']));
}
/**
* Defines the text to display.
* @group Props
*/
label = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
/**
* Defines the icon to display.
* @group Props
*/
icon = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
/**
* Defines the image to display.
* @group Props
*/
image = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "image" }] : /* istanbul ignore next */ []));
/**
* Size of the element.
* @group Props
*/
size = input('normal', /* @ts-ignore */
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
/**
* Shape of the element.
* @group Props
*/
shape = input('square', /* @ts-ignore */
...(ngDevMode ? [{ debugName: "shape" }] : /* istanbul ignore next */ []));
/**
* Establishes a string value that labels the component.
* @group Props
*/
ariaLabel = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
* @group Props
*/
ariaLabelledBy = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
/**
* This event is triggered if an error occurs while loading an image file.
* @param {Event} event - Browser event.
* @group Emits
*/
onImageError = output();
_componentStyle = inject(AvatarStyle);
dataP = computed(() => {
const shape = this.shape();
const size = this.size();
return this.cn({
[shape]: shape,
[size]: size
});
}, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "dataP" }] : /* istanbul ignore next */ []));
imageError(event) {
this.onImageError.emit(event);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Avatar, deps: null, target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: Avatar, isStandalone: true, selector: "p-avatar", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, image: { classPropertyName: "image", publicName: "image", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onImageError: "onImageError" }, host: { properties: { "class": "cx('root')", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.data-p": "dataP()" } }, providers: [AvatarStyle, { provide: AVATAR_INSTANCE, useExisting: Avatar }, { provide: PARENT_INSTANCE, useExisting: Avatar }], usesInheritance: true, hostDirectives: [{ directive: i1.Bind }], ngImport: i0, template: `
<ng-content></ng-content>
(label()) {
<span [pBind]="ptm('label')" [class]="cx('label')" [attr.data-p]="dataP()">{{ label() }}</span>
} if (icon()) {
<span [pBind]="ptm('icon')" [class]="cn(cx('icon'), icon())" [attr.data-p]="dataP()"></span>
} if (image()) {
<img [pBind]="ptm('image')" [src]="image()" (error)="imageError($event)" [attr.aria-label]="ariaLabel()" [attr.data-p]="dataP()" />
}
`, isInline: true, dependencies: [{ kind: "ngmodule", type: SharedModule }, { kind: "directive", type: Bind, selector: "[pBind]", inputs: ["pBind"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: Avatar, decorators: [{
type: Component,
args: [{
selector: 'p-avatar',
standalone: true,
imports: [SharedModule, Bind],
template: `
<ng-content></ng-content>
(label()) {
<span [pBind]="ptm('label')" [class]="cx('label')" [attr.data-p]="dataP()">{{ label() }}</span>
} if (icon()) {
<span [pBind]="ptm('icon')" [class]="cn(cx('icon'), icon())" [attr.data-p]="dataP()"></span>
} if (image()) {
<img [pBind]="ptm('image')" [src]="image()" (error)="imageError($event)" [attr.aria-label]="ariaLabel()" [attr.data-p]="dataP()" />
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[class]': "cx('root')",
'[attr.aria-label]': 'ariaLabel()',
'[attr.aria-labelledby]': 'ariaLabelledBy()',
'[attr.data-p]': 'dataP()'
},
providers: [AvatarStyle, { provide: AVATAR_INSTANCE, useExisting: Avatar }, { provide: PARENT_INSTANCE, useExisting: Avatar }],
hostDirectives: [Bind]
}]
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], image: [{ type: i0.Input, args: [{ isSignal: true, alias: "image", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], onImageError: [{ type: i0.Output, args: ["onImageError"] }] } });
class AvatarModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: AvatarModule, imports: [Avatar, SharedModule], exports: [Avatar, SharedModule] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarModule, imports: [Avatar, SharedModule, SharedModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarModule, decorators: [{
type: NgModule,
args: [{
imports: [Avatar, SharedModule],
exports: [Avatar, SharedModule]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { Avatar, AvatarClasses, AvatarModule, AvatarStyle };
//# sourceMappingURL=primeng-avatar.mjs.map