2021-04-11 15:48:50 +04:30
|
|
|
import { NgModule, ModuleWithProviders, Optional } from '@angular/core';
|
|
|
|
|
import { LucideAngularComponent } from './lucide-angular.component';
|
|
|
|
|
import { Icons } from './icons.provider';
|
2021-04-11 19:04:24 +02:00
|
|
|
import { IconData } from '../icons/types';
|
2021-04-11 15:48:50 +04:30
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
|
declarations: [LucideAngularComponent],
|
|
|
|
|
exports: [LucideAngularComponent]
|
|
|
|
|
})
|
2021-04-14 23:43:47 +02:00
|
|
|
|
2021-04-11 15:48:50 +04:30
|
|
|
export class LucideAngularModule {
|
|
|
|
|
constructor(@Optional() private icons: Icons) {
|
|
|
|
|
if (!this.icons) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`No icon provided. Make sure to use 'LucideAngularModule.pick({ ... })' when importing the module\n`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static pick(icons: { [key: string]: IconData }): ModuleWithProviders<LucideAngularModule> {
|
|
|
|
|
return {
|
|
|
|
|
ngModule: LucideAngularModule,
|
|
|
|
|
providers: [
|
|
|
|
|
{ provide: Icons, multi: true, useValue: icons }
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|