UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

86 lines 3.14 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var IgcAvatarComponent_1; import { LitElement, html, nothing } from 'lit'; import { property, state } from 'lit/decorators.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { themes } from '../../theming/theming-decorator.js'; import { watch } from '../common/decorators/watch.js'; import { registerComponent } from '../common/definitions/register.js'; import { styles } from './themes/avatar.base.css.js'; import { styles as shared } from './themes/shared/avatar.common.css.js'; import { all } from './themes/themes.js'; let IgcAvatarComponent = IgcAvatarComponent_1 = class IgcAvatarComponent extends LitElement { static register() { registerComponent(IgcAvatarComponent_1); } constructor() { super(); this.hasError = false; this.shape = 'square'; this.__internals = this.attachInternals(); this.__internals.role = 'img'; this.__internals.ariaLabel = 'avatar'; } roleDescriptionChange() { this.__internals.ariaRoleDescription = this.alt ?? this.initials; } handleErrorState() { this.hasError = false; } handleError() { this.hasError = true; } render() { return html ` <div part="base"> ${this.initials ? html `<span part="initials">${this.initials}</span>` : html `<slot></slot>`} ${this.src && !this.hasError ? html ` <img part="image" alt=${ifDefined(this.alt)} src=${ifDefined(this.src)} @error=${this.handleError} /> ` : nothing} </div> `; } }; IgcAvatarComponent.tagName = 'igc-avatar'; IgcAvatarComponent.styles = [styles, shared]; __decorate([ state() ], IgcAvatarComponent.prototype, "hasError", void 0); __decorate([ property() ], IgcAvatarComponent.prototype, "src", void 0); __decorate([ property() ], IgcAvatarComponent.prototype, "alt", void 0); __decorate([ property() ], IgcAvatarComponent.prototype, "initials", void 0); __decorate([ property({ reflect: true }) ], IgcAvatarComponent.prototype, "shape", void 0); __decorate([ watch('initials'), watch('alt') ], IgcAvatarComponent.prototype, "roleDescriptionChange", null); __decorate([ watch('src') ], IgcAvatarComponent.prototype, "handleErrorState", null); IgcAvatarComponent = IgcAvatarComponent_1 = __decorate([ themes(all) ], IgcAvatarComponent); export default IgcAvatarComponent; //# sourceMappingURL=avatar.js.map