@ngneat/overview
Version:
The Template for Success in Template Management
147 lines (137 loc) • 6.65 kB
TypeScript
import * as i0 from '@angular/core';
import { ComponentRef, Type, Injector, EnvironmentInjector, ViewContainerRef, ApplicationRef, WritableSignal, Binding, DirectiveWithBindings, EmbeddedViewRef, TemplateRef, InputSignal, InputSignalWithTransform, OnInit, OnChanges, SimpleChanges, Signal } from '@angular/core';
declare class TeleportDirective {
readonly teleportTo: i0.ModelSignal<string>;
private viewRef;
private tpl;
private service;
constructor();
static ɵfac: i0.ɵɵFactoryDeclaration<TeleportDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<TeleportDirective, "[teleportTo]", never, { "teleportTo": { "alias": "teleportTo"; "required": false; "isSignal": true; }; }, { "teleportTo": "teleportToChange"; }, never, never, true, never>;
}
declare class TeleportOutletDirective {
readonly teleportOutlet: i0.InputSignal<string>;
private vcr;
private service;
constructor();
static ɵfac: i0.ɵɵFactoryDeclaration<TeleportOutletDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<TeleportOutletDirective, "[teleportOutlet]", never, { "teleportOutlet": { "alias": "teleportOutlet"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}
interface Options<Comp, Context> {
component: Type<Comp>;
injector: Injector;
environmentInjector: EnvironmentInjector;
vcr: ViewContainerRef | undefined;
appRef: ApplicationRef | undefined;
contextSignal?: WritableSignal<Context>;
bindings?: Binding[];
directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
}
declare class CompRef<Comp, Context = any> implements ViewRef {
private options;
ref: ComponentRef<Comp>;
constructor(options: Options<Comp, Context>);
setInput<K extends keyof ExcludeFunctions<Comp>>(input: K, value: InferInputSignalType<Comp[K]>): this;
setInputs(inputs: Partial<ExtractInputTypes<ExcludeFunctions<Comp>>>): this;
detectChanges(): this;
updateContext(context: Context): this;
appendTo(container: Element): this;
removeFrom(container: Element): this;
getRawContent(): string;
getElement<T extends Element>(): T;
destroy(): void;
}
declare class StringRef implements ViewRef {
private value;
constructor(value: string);
getElement(): string;
detectChanges(): this;
updateContext(): this;
destroy(): void;
}
interface Args<C> {
tpl: TemplateRef<C>;
context: C;
vcr: ViewContainerRef | undefined;
appRef: ApplicationRef | undefined;
injector: Injector | undefined;
}
declare class TplRef<C> implements ViewRef {
private args;
ref: EmbeddedViewRef<{}>;
private element;
constructor(args: Args<C>);
detectChanges(): this;
getElement(): Element;
destroy(): void;
updateContext(context: C): this;
}
interface ViewRef {
getElement(): Element | string;
detectChanges(): ViewRef;
updateContext(context: any): ViewRef;
destroy(): void;
}
type ExcludeFunctionPropertyNames<T> = {
[Key in keyof T]: T[Key] extends InputSignal<any> ? Key : T[Key] extends Function ? never : Key;
}[keyof T];
type InferInputSignalType<T> = T extends InputSignalWithTransform<unknown, infer R> ? R : T extends InputSignal<infer R> ? R : T;
type ExtractInputTypes<T> = {
[Key in keyof T]: InferInputSignalType<T[Key]>;
};
type ExcludeFunctions<T> = Pick<T, ExcludeFunctionPropertyNames<T>>;
type Content = string | number | TemplateRef<any> | Type<any>;
type ResolveViewRef<T> = T extends Type<infer Instance> ? CompRef<Instance> : T extends TemplateRef<infer Context> ? TplRef<Context> : StringRef;
declare function isTemplateRef(value: any): value is TemplateRef<any>;
declare function isComponent(value: any): value is Type<any>;
declare function isString(value: any): value is string;
declare function getViewRef<T>(value: CompRef<T> | TplRef<T>): i0.ViewRef;
declare class DynamicViewDirective implements OnInit, OnChanges {
readonly view: i0.InputSignal<Content>;
readonly injector: i0.InputSignal<Injector>;
readonly context: i0.InputSignal<any>;
readonly inputs: i0.InputSignal<Record<any, any>>;
private viewRef;
private defaultTpl;
private vcr;
private viewService;
constructor();
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
resolveContentType(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicViewDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<DynamicViewDirective, "[dynamicView]", never, { "view": { "alias": "dynamicView"; "required": false; "isSignal": true; }; "injector": { "alias": "dynamicViewInjector"; "required": false; "isSignal": true; }; "context": { "alias": "dynamicViewContext"; "required": false; "isSignal": true; }; "inputs": { "alias": "dynamicViewInputs"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}
interface _ViewOptions {
vcr?: ViewContainerRef | undefined;
injector?: Injector | undefined;
}
interface TemplateViewOptions extends _ViewOptions {
context?: Record<string, any> | undefined;
}
interface CompViewOptions<Context = any> extends _ViewOptions {
environmentInjector?: EnvironmentInjector | undefined;
context?: Context | undefined;
bindings?: Binding[];
directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
}
type ViewOptions<Context = any> = _ViewOptions & CompViewOptions<Context> & TemplateViewOptions;
declare class ViewUnsupportedContentTypeError extends Error {
constructor();
}
declare class ViewService {
private injector;
private appRef;
private environmentInjector;
createComponent<Comp, Context>(component: Type<Comp>, options?: CompViewOptions<Context>): CompRef<Comp, Context>;
createTemplate<Context>(tpl: TemplateRef<Context>, options?: TemplateViewOptions): TplRef<Record<string, any>>;
createView<Comp, Context>(content: Type<Comp>, viewOptions: CompViewOptions<Context>): CompRef<Comp, Context>;
createView<T>(content: TemplateRef<T>, viewOptions: TemplateViewOptions): TplRef<T>;
createView(content: string): StringRef;
createView(content: Content, viewOptions?: ViewOptions): ViewRef;
static ɵfac: i0.ɵɵFactoryDeclaration<ViewService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ViewService>;
}
declare function injectViewContext<T>(): Signal<T>;
export { CompRef, DynamicViewDirective, StringRef, TeleportDirective, TeleportOutletDirective, TplRef, ViewService, ViewUnsupportedContentTypeError, getViewRef, injectViewContext, isComponent, isString, isTemplateRef };
export type { Content, ResolveViewRef, ViewOptions, ViewRef };