UNPKG

ngx-dynamic-hooks

Version:

Automatically insert live Angular components into a dynamic string of content (based on their selector or any pattern of your choice) and render the result in the DOM.

97 lines (96 loc) 5.04 kB
import { Injector, ApplicationRef, EnvironmentInjector } from '@angular/core'; import { ReplaySubject } from 'rxjs'; import { Hook, HookIndex } from '../../interfacesPublic'; import { DynamicContentChild, ComponentConfig } from '../../interfacesPublic'; import { ComponentUpdater } from './componentUpdater'; import { AutoPlatformService } from '../platform/autoPlatformService'; import { ParseOptions } from '../settings/options'; import { Logger } from '../utils/logger'; import * as i0 from "@angular/core"; /** * The service responsible for dynamically creating components for all found Hooks */ export declare class ComponentCreator { private platformId; private appRef; private componentUpdater; private platformService; private logger; constructor(platformId: string, appRef: ApplicationRef, componentUpdater: ComponentUpdater, platformService: AutoPlatformService, logger: Logger); /** * The main entry function to start the dynamic component initialization process * * @param contentElement - The main content element * @param hookIndex - The current hookIndex * @param token - The current parse token * @param context - The current context object * @param options - The current ParseOptions * @param environmentInjector - The environment injector to use for the dynamically-created components * @param injector - The injector to use for the dynamically-created components */ init(contentElement: any, hookIndex: HookIndex, token: string, context: any, options: ParseOptions, environmentInjector: EnvironmentInjector, injector: Injector): ReplaySubject<boolean>; /** * Replaces a default anchor element with a custom element * * @param anchorElement - The default component anchor element * @param customTagName - The custom tag that should be used instead */ useCustomHostElement(anchorElement: any, customTagName: string): any; /** * Creates a content slot dom element for each ng-content tag of the dynamically loaded component. * * This is to create a direct dom-representation of each entry in the projectableNodes array returned * by parser.loadComponent, so it can be cleanly resolved back into projectableNodes later on. Without these * content slots for separation, you wouldn't know which child nodes go into which ng-content slot. * * @param hostElement - The dom element to create the content slots in * @param hook - The hook of the component * @param token - The current parse token */ createContentSlotElements(hostElement: any, hook: Hook, token: string): void; /** * Returns all previously created content slots for a component element as a projectableNodes[][] array * * @param componentHostElement - The dom element with the content slots * @param token - The current parse token */ extractContentSlotElements(componentHostElement: any, token: string): any[][]; /** * Loads the component class from a ComponentConfig. Returns a subject the emits the class when ready. * * @param componentConfig - The componentConfig from HookData */ loadComponentClass(componentConfig: ComponentConfig): ReplaySubject<new (...args: any[]) => any>; /** * Dynamically creates the component with Angular methods * * @param hook - The hook for this component * @param context - The current context * @param componentHostElement - The hostElement for the component * @param projectableNodes - The nodes to inject as ng-content * @param options - The current ParseOptions * @param compClass - The component class * @param environmentInjector - The default environmentInjector * @param injector - The default injector */ createComponent(hook: Hook, context: any, componentHostElement: any, projectableNodes: any[][], options: ParseOptions, compClass: new (...args: any[]) => any, environmentInjector: EnvironmentInjector, injector: Injector): void; /** * Register DOM events to trigger when component outputs emit * * @param hook - The component hook * @param options - The current ParseOptions */ mapOutputsToHTMLEvents(hook: Hook, options: ParseOptions): void; /** * Find all components that would be the ContentChildren of a dynamic component and returns them in a hierarchical tree object * Important: This function depends on the anchor attributes not being removed yet * * @param node - The HTML node to parse * @param treeLevel - The current tree level of DynamicContentChildren (for recursiveness) * @param hookIndex - The current hookIndex * @param token - The current parseToken */ findContentChildren(node: any, treeLevel: DynamicContentChild[] | undefined, hookIndex: HookIndex, token: string): void; static ɵfac: i0.ɵɵFactoryDeclaration<ComponentCreator, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ComponentCreator>; }