@dotglitch/ngx-common
Version:
Angular components and utilities that are commonly used.
143 lines (142 loc) • 3.79 kB
TypeScript
import { ComponentType } from '@angular/cdk/portal';
import { TemplateRef } from '@angular/core';
export declare enum ComponentResolveStrategy {
/**
* Match the fist component we find
* (best used for standalone components)
* @default
*/
PickFirst = 0,
/**
* Perform an Exact ID to Classname of the Component
* case sensitive, zero tolerance.
*/
MatchIdToClassName = 1,
/**
* Perform a fuzzy ID to classname match
* case insensitive, mutes symbols
* ignores "Component" and "Module" postfixes on class
* names
*/
FuzzyIdClassName = 2,
/**
* Use a user-provided component match function
*/
Custom = 3
}
export type NgxLazyLoaderConfig = Partial<{
entries: ComponentRegistration[];
notFoundTemplate: TemplateRef<any>;
notFoundComponent: ComponentType<any>;
errorTemplate: TemplateRef<any>;
errorComponent: ComponentType<any>;
loaderDistractorTemplate: TemplateRef<any>;
loaderDistractorComponent: ComponentType<any>;
logger: {
log: (...args: any) => void;
warn: (...args: any) => void;
err: (...args: any) => void;
};
/**
* What strategy should be used to resolve components
* @default ComponentResolveStrategy.FuzzyIdClassName
*/
componentResolveStrategy: ComponentResolveStrategy;
customResolver: (registry: (CompiledComponent | CompiledModule)[]) => Object;
}>;
type RegistrationConfig = {
/**
* Specify a group to categorize components. If not specified,
* will default to the `default` group.
*/
group?: string;
/**
* load: () => import('./pages/my-page/my-page.component')
*/
load: () => any;
/**
* Called before a component is loaded.
* If it returns `false` the component will not be loaded.
*/
[key: string]: any;
};
export type ComponentRegistration = (({
id: string;
} & RegistrationConfig) | ({
matcher: string[] | RegExp | ((value: string) => boolean);
} & RegistrationConfig));
export type DynamicRegistrationArgs<T = any> = {
id: string;
group?: string;
matcher?: string[] | RegExp | ((val: string) => boolean);
component?: T;
load?: () => any;
};
/**
* This is roughly a compiled component
*/
export type CompiledComponent = {
(): CompiledComponent;
ɵfac: Function;
ɵcmp: {
consts: any;
contentQueries: any;
data: any;
declaredInputs: any;
decls: any;
dependencies: any;
directiveDefs: any;
encapsulation: any;
exportAs: any;
factory: any;
features: any;
findHostDirectiveDefs: any;
getStandaloneInjector: any;
hostAttrs: any;
hostBindings: any;
hostDirectives: any;
hostVars: any;
id: string;
inputs: any;
ngContentSelectors: any;
onPush: boolean;
outputs: any;
pipeDefs: any;
providersResolver: any;
schemas: any;
selectors: string[];
setInput: any;
standalone: boolean;
styles: string[];
tView: any;
template: any;
type: Function;
vars: number;
viewQuery: any;
};
};
/**
* This is roughly a compiled module
*/
export type CompiledModule = {
(): CompiledModule;
ɵfac: Function;
ɵinj: {
providers: any[];
imports: any[];
};
ɵmod: {
bootstrap: any[];
declarations: Function[];
exports: any[];
id: unknown;
imports: any[];
schemas: unknown;
transitiveCompileScopes: unknown;
type: Function;
};
};
export type CompiledBundle = {
[key: string]: CompiledComponent | CompiledModule;
};
export {};