@koalarx/ui
Version:
Koala UI is a Design System developed in Angular whose objective is to facilitate and make your development faster and simpler, making this framework your greatest ally.
87 lines (80 loc) • 5 kB
JavaScript
import * as i0 from '@angular/core';
import { Directive, Component, Input, ViewChild, NgModule } from '@angular/core';
class KoalaDynamicComponentDirective {
constructor(viewContainerRef) {
this.viewContainerRef = viewContainerRef;
}
}
KoalaDynamicComponentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
KoalaDynamicComponentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: KoalaDynamicComponentDirective, selector: "[koalaDynamicComponent]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentDirective, decorators: [{
type: Directive,
args: [{
selector: '[koalaDynamicComponent]',
}]
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
class KoalaDynamicComponentFactory {
constructor(componentFactoryResolver) {
this.componentFactoryResolver = componentFactoryResolver;
}
ngOnInit() {
this.loadComponent();
}
loadComponent() {
const dynamicComponent = this.dynamicComponent;
if (dynamicComponent) {
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(dynamicComponent.component);
const viewContainerRef = this.koalaDynamicComponentDirective?.viewContainerRef;
viewContainerRef?.clear();
const componentRef = viewContainerRef?.createComponent(componentFactory);
const instance = componentRef?.instance;
if (instance)
instance.data = dynamicComponent.data;
}
}
}
KoalaDynamicComponentFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentFactory, deps: [{ token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
KoalaDynamicComponentFactory.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: KoalaDynamicComponentFactory, selector: "koala-dynamic-component", inputs: { dynamicComponent: "dynamicComponent" }, viewQueries: [{ propertyName: "koalaDynamicComponentDirective", first: true, predicate: KoalaDynamicComponentDirective, descendants: true, static: true }], ngImport: i0, template: `
<ng-template koalaDynamicComponent></ng-template>`, isInline: true, dependencies: [{ kind: "directive", type: KoalaDynamicComponentDirective, selector: "[koalaDynamicComponent]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentFactory, decorators: [{
type: Component,
args: [{
selector: 'koala-dynamic-component',
template: `
<ng-template koalaDynamicComponent></ng-template>`
}]
}], ctorParameters: function () { return [{ type: i0.ComponentFactoryResolver }]; }, propDecorators: { dynamicComponent: [{
type: Input
}], koalaDynamicComponentDirective: [{
type: ViewChild,
args: [KoalaDynamicComponentDirective, { static: true }]
}] } });
class KoalaDynamicComponentModule {
}
KoalaDynamicComponentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
KoalaDynamicComponentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentModule, declarations: [KoalaDynamicComponentDirective,
KoalaDynamicComponentFactory], exports: [KoalaDynamicComponentFactory] });
KoalaDynamicComponentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaDynamicComponentModule, decorators: [{
type: NgModule,
args: [{
exports: [
KoalaDynamicComponentFactory
],
declarations: [
KoalaDynamicComponentDirective,
KoalaDynamicComponentFactory
]
}]
}] });
class KoalaDynamicComponent {
constructor(component, data) {
this.component = component;
this.data = data;
}
}
/**
* Generated bundle index. Do not edit.
*/
export { KoalaDynamicComponent, KoalaDynamicComponentDirective, KoalaDynamicComponentFactory, KoalaDynamicComponentModule };
//# sourceMappingURL=koalarx-ui-dynamic-component.mjs.map