UNPKG

angular-feather

Version:

Feather Icons components library for your Angular Applications

91 lines (83 loc) 2.95 kB
import { Component, ElementRef, Inject, ChangeDetectorRef, Input, NgModule, Optional } from '@angular/core'; class Icons { constructor(icons) { this.icons = icons; } } function uppercamelcase(str) { return str.toLowerCase().replace(/(?:^\w|[A-Z]|\b\w)/g, (firstLetter) => { return firstLetter.toUpperCase(); }).replace(/[-_]/g, ''); } class FeatherComponent { constructor(elem, changeDetector, icons) { this.elem = elem; this.changeDetector = changeDetector; this.icons = icons; } ngOnChanges(changes) { // icons are provided as an array of objects because of "multi: true" const icons = Object.assign({}, ...this.icons); const svg = icons[uppercamelcase(changes.name.currentValue)] || ''; if (!svg) { console.warn(`Icon not found: ${changes.name.currentValue}\n` + `Refer to documentation on https://github.com/michaelbazos/angular-feather`); } this.elem.nativeElement.innerHTML = svg; this.changeDetector.markForCheck(); } } FeatherComponent.decorators = [ { type: Component, args: [{ // tslint:disable-next-line:component-selector selector: 'i-feather, feather-icon', template: "<ng-content></ng-content>\n", styles: [":host{display:inline-block;fill:none;height:24px;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;width:24px}"] },] } ]; FeatherComponent.ctorParameters = () => [ { type: ElementRef, decorators: [{ type: Inject, args: [ElementRef,] }] }, { type: ChangeDetectorRef, decorators: [{ type: Inject, args: [ChangeDetectorRef,] }] }, { type: Icons, decorators: [{ type: Inject, args: [Icons,] }] } ]; FeatherComponent.propDecorators = { name: [{ type: Input }] }; class FeatherModule { constructor(icons) { this.icons = icons; if (!this.icons) { throw new Error(`No icon provided. Make sure to use 'FeatherModule.pick({ ... })' when importing the module\n` + `Refer to documentation on https://github.com/michaelbazos/angular-feather`); } } static pick(icons) { return { ngModule: FeatherModule, providers: [ { provide: Icons, multi: true, useValue: icons } ] }; } } FeatherModule.decorators = [ { type: NgModule, args: [{ declarations: [ FeatherComponent ], exports: [ FeatherComponent ] },] } ]; FeatherModule.ctorParameters = () => [ { type: Icons, decorators: [{ type: Optional }] } ]; /* * Public API Surface of angular-feather */ /** * Generated bundle index. Do not edit. */ export { FeatherComponent, FeatherModule, Icons as ɵa }; //# sourceMappingURL=angular-feather.js.map