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.

99 lines 4.02 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; }; import { html, LitElement } from 'lit'; import { property, state } from 'lit/decorators.js'; import { unsafeSVG } from 'lit/directives/unsafe-svg.js'; import { addThemingController } from '../../theming/theming-controller.js'; import { addInternalsController } from '../common/controllers/internals.js'; import { blazorInclude } from '../common/decorators/blazorInclude.js'; import { registerComponent } from '../common/definitions/register.js'; import { getIconRegistry, registerIcon as registerIcon_impl, registerIconFromText as registerIconFromText_impl, setIconRef as setIconRef_impl, } from './icon.registry.js'; import { styles } from './themes/icon.base.css.js'; import { styles as shared } from './themes/shared/icon.common.css.js'; import { all } from './themes/themes.js'; export default class IgcIconComponent extends LitElement { constructor() { super(...arguments); this._internals = addInternalsController(this, { initialARIA: { role: 'img' }, }); this._theming = addThemingController(this, all, { themeChange: this._getIcon, }); this._svg = ''; this.name = ''; this.collection = 'default'; this.mirrored = false; } static { this.tagName = 'igc-icon'; } static { this.styles = [styles, shared]; } static register() { registerComponent(IgcIconComponent); } connectedCallback() { super.connectedCallback(); this._boundIconLoaded = this._iconLoaded.bind(this); getIconRegistry().subscribe(this._boundIconLoaded); } disconnectedCallback() { if (this._boundIconLoaded) { getIconRegistry().unsubscribe(this._boundIconLoaded); } super.disconnectedCallback(); } update(props) { if (props.has('name') || props.has('collection')) { this._getIcon(); } super.update(props); } _iconLoaded(name, collection) { if (this.name === name && this.collection === collection) { this._getIcon(); } } _getIcon() { const { name, collection } = getIconRegistry().getIconRef(this.name, this.collection, this._theming.theme); const { svg = '', title = null } = getIconRegistry().get(name, collection) ?? {}; this._svg = svg; this._internals.setARIA({ ariaLabel: title }); } render() { return html `${unsafeSVG(this._svg)}`; } async registerIcon(name, url, collection = 'default') { await registerIcon_impl(name, url, collection); } registerIconFromText(name, iconText, collection = 'default') { registerIconFromText_impl(name, iconText, collection); } setIconRef(name, collection, icon) { setIconRef_impl(name, collection, icon); } } __decorate([ state() ], IgcIconComponent.prototype, "_svg", void 0); __decorate([ property() ], IgcIconComponent.prototype, "name", void 0); __decorate([ property() ], IgcIconComponent.prototype, "collection", void 0); __decorate([ property({ type: Boolean, reflect: true }) ], IgcIconComponent.prototype, "mirrored", void 0); __decorate([ blazorInclude() ], IgcIconComponent.prototype, "registerIcon", null); __decorate([ blazorInclude() ], IgcIconComponent.prototype, "registerIconFromText", null); __decorate([ blazorInclude() ], IgcIconComponent.prototype, "setIconRef", null); //# sourceMappingURL=icon.js.map