UNPKG

@dotglitch/ngx-common

Version:

Angular components and utilities that are commonly used.

151 lines (150 loc) 4.93 kB
import { ViewContainerRef, ComponentRef, EventEmitter, AfterViewInit } from '@angular/core'; import { DialogRef } from '@angular/cdk/dialog'; import { LazyLoaderService } from './lazy-loader.service'; import { NgxLazyLoaderConfig } from './types'; import * as i0 from "@angular/core"; export declare class LazyLoaderComponent implements AfterViewInit { private service; private viewContainerRef; dialog: DialogRef; dialogArguments: any; targetContainer: ViewContainerRef; /** * ! Here be dragons. * Only the bravest of Adventurers can survive the battles below, * and they must be trained and ready for the gruelling journey ahead. * Many a soul has tried to best these Dragons, yet only one has * succeeded since our founding. * * TL;DR -- Don't mess with this unless you know what you're doing. * This is central to a ton of moving parts -- breaking it will * cause more collateral damage than you may realize. */ private _id; private originalId; /** * The id of the component that will be lazy loaded */ set id(data: string); private _group; private originalGroup; set group(data: string); get group(): string; private _matchGroups; private _inputs; /** * A map of inputs to bind to the child. * Supports change detection. (May fail on deep JSON changes) * * ```html * <lazy-loader component="MyLazyComponent" * [inputs]="{ * prop1: true, * prop2: false, * complex: { * a: true, * b: 0 * } * }" * > * </lazy-loader> * ``` */ set inputs(data: { [key: string]: any; }); private outputSubscriptions; private _outputs; /** * A map of outputs to bind from the child. * Should support change detection. * ```html * <lazy-loader component="MyLazyComponent" * [outputs]="{ * prop3: onOutputFire * }" * > * </lazy-loader> * ``` */ set outputs(data: { [key: string]: Function; }); /** * Emits errors encountered when loading components */ componentLoadError: EventEmitter<any>; /** * Emits when the component is fully constructed * and had it's inputs and outputs bound * > before `OnInit` * * Returns the active class instance of the lazy-loaded component */ componentLoaded: EventEmitter<any>; /** * This is an instance of the component that is currently loaded. */ instance: any; /** * Container that provides the component data */ private targetModule; /** * Component definition */ private targetComponentFactory; /** * Active component container reference */ private targetComponentContainerRef; private targetRef; /** * Reference to the component class instance */ private targetComponentInstance; /** * Subscription with true/false state on whether the distractor should be */ private distractorSubscription; config: NgxLazyLoaderConfig; private err; private warn; private log; private clearEmitter; private clearLoader$; private showEmitter; private showLoader$; private subscriptions; renderSpinner: boolean; isClearingLoader: boolean; constructor(service: LazyLoaderService, viewContainerRef: ViewContainerRef, dialog: DialogRef, dialogArguments: any); private initialized; ngAfterViewInit(): Promise<void | ComponentRef<any>>; ngOnDestroy(clearAll?: boolean): void; /** * Bind the input values to the child component. */ private bindInputs; /** * Bind the output handlers to the loaded child component */ private bindOutputs; /** * Load the "Default" component (404) screen normally. * This is shown when the component id isn't in the * registry or otherwise doesn't match * * This */ private loadDefault; /** * Load the "Error" component. * This is shown when we are able to resolve the component * in the registry, but have some issue boostrapping the * component into the viewContainer */ private loadError; static ɵfac: i0.ɵɵFactoryDeclaration<LazyLoaderComponent, [null, { optional: true; }, { optional: true; }, { optional: true; }]>; static ɵcmp: i0.ɵɵComponentDeclaration<LazyLoaderComponent, "ngx-lazy-loader", never, { "id": { "alias": "component"; "required": false; }; "group": { "alias": "group"; "required": false; }; "inputs": { "alias": "inputs"; "required": false; }; "outputs": { "alias": "outputs"; "required": false; }; }, { "componentLoadError": "componentLoadError"; "componentLoaded": "componentLoaded"; }, never, never, true, never>; }