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.
101 lines • 4.09 kB
JavaScript
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 IgcIconComponent_1;
import { LitElement, html } from 'lit';
import { property, state } from 'lit/decorators.js';
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
import { getThemeController, themes } from '../../theming/theming-decorator.js';
import { blazorInclude } from '../common/decorators/blazorInclude.js';
import { watch } from '../common/decorators/watch.js';
import { registerComponent } from '../common/definitions/register.js';
import { getIconRegistry, registerIconFromText as registerIconFromText_impl, registerIcon as registerIcon_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';
let IgcIconComponent = IgcIconComponent_1 = class IgcIconComponent extends LitElement {
static register() {
registerComponent(IgcIconComponent_1);
}
constructor() {
super();
this.svg = '';
this.name = '';
this.collection = 'default';
this.mirrored = false;
this.iconLoaded = (name, collection) => {
if (this.name === name && this.collection === collection) {
this.getIcon();
}
};
this.__internals = this.attachInternals();
this.__internals.role = 'img';
getThemeController(this).onThemeChanged = (theme) => getIconRegistry().setRefsByTheme(theme);
}
connectedCallback() {
super.connectedCallback();
getIconRegistry().subscribe(this.iconLoaded);
}
disconnectedCallback() {
getIconRegistry().unsubscribe(this.iconLoaded);
super.disconnectedCallback();
}
iconChanged(prev, curr) {
if (prev !== curr) {
this.getIcon();
}
}
getIcon() {
const { name, collection } = getIconRegistry().getIconRef(this.name, this.collection);
const { svg, title } = getIconRegistry().get(name, collection) ?? {};
this.svg = svg ?? '';
this.__internals.ariaLabel = title ?? null;
}
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);
}
};
IgcIconComponent.tagName = 'igc-icon';
IgcIconComponent.styles = [styles, shared];
__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([
watch('name'),
watch('collection')
], IgcIconComponent.prototype, "iconChanged", null);
__decorate([
blazorInclude()
], IgcIconComponent.prototype, "registerIcon", null);
__decorate([
blazorInclude()
], IgcIconComponent.prototype, "registerIconFromText", null);
__decorate([
blazorInclude()
], IgcIconComponent.prototype, "setIconRef", null);
IgcIconComponent = IgcIconComponent_1 = __decorate([
themes(all, { exposeController: true })
], IgcIconComponent);
export default IgcIconComponent;
//# sourceMappingURL=icon.js.map