@dooboostore/dom-render
Version:
html view template engine
148 lines • 6.61 kB
TypeScript
import { OnChangeAttrRender, OtherData } from '../lifecycle/OnChangeAttrRender';
import { OnCreateRenderData, OnCreateRenderDataParams } from '../lifecycle/OnCreateRenderData';
import { RawSet } from '../rawsets/RawSet';
import { ConstructorType } from '@dooboostore/core';
import { OnCreatedThisChild } from '../lifecycle/OnCreatedThisChild';
import { OnInitRender } from '../lifecycle/OnInitRender';
import { OnDestroyRender, OnDestroyRenderParams } from '../lifecycle/OnDestroyRender';
import { OnDrThisUnBind } from '../lifecycle/dr-this/OnDrThisUnBind';
import { OnDrThisBind } from '../lifecycle/dr-this/OnDrThisBind';
import type { Render } from '../rawsets/Render';
import { DomRenderConfig } from '../configs/DomRenderConfig';
import { OnRawSetRendered, OnRawSetRenderedOtherData } from "../lifecycle/OnRawSetRendered";
import { OnChildRawSetRendered } from "../lifecycle/OnChildRawSetRendered";
export declare const ATTRIBUTE_METADATA_KEY: unique symbol;
export declare const QUERY_METADATA_KEY: unique symbol;
export declare const EVENT_METADATA_KEY: unique symbol;
export interface AttributeMetadata {
propertyKey: string | symbol;
name: string;
converter?: (value: any | string | null) => any;
isMethod: boolean;
}
export interface QueryMetadata {
selector: string;
propertyKey: string | symbol;
isMethod: boolean;
convert?: (e: Element) => any;
onDestroy?: (componentInstance: any, element: Element) => void;
refreshTime?: number;
refreshRawSetRendered?: boolean;
}
export interface EventMetadata {
query: string;
eventName: string;
methodName: string | symbol;
onDestroy?: (componentInstance: any, element: Element) => void;
refreshTime?: number;
refreshRawSetRendered?: boolean;
}
export declare function attribute(nameOrOptions?: string | {
name?: string;
converter?: (value: any | string | null) => any;
}): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
export declare function query(selectorOrOptions: string | {
selector: string;
convert?: (e: Element) => any;
onDestroy?: (componentInstance: any, element: Element) => void;
refreshIntervalTime?: number;
refreshRawSetRendered?: boolean;
}): (target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void;
export declare function event(options: {
query: string;
name: string;
onDestroy?: (componentInstance: any, element: Element) => void;
refreshTime?: number;
refreshRawSetRendered?: boolean;
}): MethodDecorator;
export type ComponentBaseConfig = {
onlyParentType?: ConstructorType<any>[] | ConstructorType<any>;
createChildrenDebounce?: number;
onRawSetRenderedOtherDataDebounce?: number;
onChildRawSetRenderedOtherDataDebounce?: number;
};
export type ChildrenSet = {
instance: any;
data: OnCreateRenderDataParams;
};
export declare class ComponentBase<T = any, C extends ComponentBaseConfig = ComponentBaseConfig> implements OnChangeAttrRender, OnCreateRenderData, OnCreatedThisChild, OnDrThisBind, OnDrThisUnBind, OnInitRender, OnDestroyRender, OnRawSetRendered, OnChildRawSetRendered {
private _config?;
private _rawSet?;
private _children;
private _render;
private _attribute?;
private _boundEventListeners;
private _queryBindings;
private _eventBindings;
private _refreshTimers;
private childrenSetSubject;
private createChildrenDebounceSubscription?;
private onRawSetRenderedOtherDataSubject;
private onChildRawSetRenderedOtherDataSubject;
private onRawSetRenderedOtherDataSubjectSubscription?;
private onChildRawSetRenderedOtherDataSubjectSubscription?;
constructor(_config?: C);
get componentConfig(): C | undefined;
get render(): Render | undefined;
get rawSet(): RawSet | undefined;
get domRenderConfig(): DomRenderConfig | undefined;
private _queryElements;
private _cleanupEventListeners;
private _cleanupQueryBindings;
private _cleanupEventBindings;
private _applyQueryBinding;
private _setupQueryDecorators;
private _updateQueryBinding;
private _updateQueryDecorators;
private _arraysEqual;
private _setupRefreshTimer;
private _clearRefreshTimer;
private _clearAllRefreshTimers;
onRawSetRendered(rawSet: RawSet, otherData: OnRawSetRenderedOtherData): Promise<void>;
onChildRawSetRendered(): Promise<void>;
/**
* Manually refresh all query and event decorators
* Useful when DOM elements are dynamically added/removed and you want to update bindings
*/
refreshDecorators(): void;
/**
* Manually refresh specific query decorators by property key
* @param propertyKeys - Array of property keys to refresh, or single property key
*/
refreshQueryDecorators(propertyKeys: (string | symbol) | (string | symbol)[]): void;
/**
* Manually refresh specific event decorators by method name
* @param methodNames - Array of method names to refresh, or single method name
*/
refreshEventDecorators(methodNames: (string | symbol) | (string | symbol)[]): void;
private _applyEventBinding;
private _setupEventDecorators;
private _updateEventBinding;
private _updateEventDecorators;
getAttributeNames(attribute?: T): string[];
getAttribute<K extends keyof T>(name: K, attribute?: T): T[K] | null;
hasAttribute(name: keyof T): boolean;
equalsAttributeName(n: string, name: keyof T): boolean;
get uuid(): string | undefined;
get childrenSet(): ChildrenSet[];
get children(): any[];
getElement<T extends Element>(): T | undefined;
getFirstChild<T>(type: ConstructorType<T>): T | undefined;
getParentThis<P>(): P;
getChildren<C extends ConstructorType<any>>(type: C): InstanceType<C>[];
getChildren<C extends ConstructorType<any>[]>(types: C): InstanceType<C[number]>[];
private setRawSet;
setAttribute(attribute: T): void;
onCreatedThisChild(child: any, data: OnCreateRenderDataParams): void;
onCreatedThisChildDebounce(childrenSet: ChildrenSet[]): void;
onRawSetRenderedDebounce(childrenSet: OnRawSetRenderedOtherData[]): void;
onChildRawSetRenderedDebounce(): void;
onCreateRenderData(data: OnCreateRenderDataParams): void;
onChangeAttrRender(name: string, value: any, other: OtherData): void;
onInitRender(param: any, rawSet: RawSet): Promise<void>;
onDrThisBind(): void;
onDrThisUnBind(): void;
onDestroyRender(data?: OnDestroyRenderParams): void;
onDestroy(): void;
}
//# sourceMappingURL=ComponentBase.d.ts.map