UNPKG

reblendjs

Version:

ReblendJs uses Reactjs pradigm to build UI components, with isolated state for each components.

97 lines (96 loc) 5.16 kB
import { IAny } from '../interface/IAny'; import { ChildrenPropsUpdateType, EffectType } from 'reblend-typing'; import * as ReblendTyping from 'reblend-typing'; import { IReblendAppConfig } from './ConfigUtil'; export interface BaseComponent<P, S> extends HTMLElement { nearestStandardParent?: HTMLElement; onStateChangeRunning: boolean | undefined; elementChildren: Set<ReblendTyping.Component<P, S>> | null; reactElementChildrenWrapper: ReblendTyping.Component<any, any> | null; directParent: ReblendTyping.Component<any, any>; childrenInitialize: boolean; dataIdQuerySelector: string; props: Readonly<P>; reactDomCreateRoot_root: import('react-dom/client').Root | null; renderingError: ReblendTyping.ReblendRenderingException<P, S>; displayName: string; renderingErrorHandler: (e: ReblendTyping.ReblendRenderingException<P, S>) => void; removePlaceholder: () => Promise<void>; attached: boolean; isPlaceholder: boolean; isRootComponent: boolean; placeholderAttached: boolean; ReactClass: any; ReblendPlaceholder?: ReblendTyping.ReblendNode; defaultReblendPlaceholderStyle: ReblendTyping.CSSProperties | string; ref: ReblendTyping.Ref<HTMLElement> | ((node: HTMLElement) => any); effectsState: Map<string, ReblendTyping.EffectState>; hookDisconnectedEffects?: Set<() => void>; checkPropsChange(): Promise<void>; addHookDisconnectedEffect(destructor: () => void): void; hasDisconnected: boolean; htmlElements: ReblendTyping.Component<P, S>[]; childrenPropsUpdate: Set<ChildrenPropsUpdateType>; numAwaitingUpdates: number; stateEffectRunning: boolean; forceEffects: boolean; mountingEffects: boolean; mountingAfterEffects: boolean; initStateRunning: boolean; awaitingInitState: boolean; awaitingReRender: boolean; state: S; reactReblendMount: undefined | ((afterNode?: HTMLElement) => any); } export declare class BaseComponent<P = Record<string, never>, S extends { renderingErrorHandler?: (error: Error) => void; } = Record<string, never>> implements ReblendTyping.Component<P, S> { [reblendComponent: symbol]: boolean; static ELEMENT_NAME: string; static props: IAny; static config?: ReblendTyping.ReblendComponentConfig; static wrapChildrenToReact(components: JSX.Element | ReblendTyping.JSXElementConstructor<Record<string, never>>): Promise<any>; static construct(displayName: ReblendTyping.ReblendNode, props: IAny, ...children: ReblendTyping.VNodeChildren): ReblendTyping.VNode | ReblendTyping.VNodeChildren; static renderToString(ui: ReblendTyping.ReblendNode, props?: IAny): Promise<string>; static mountOn(elementOrElementId: string | HTMLElement, app: ReblendTyping.ReblendNode, options?: IReblendAppConfig): Promise<ReblendTyping.Component<any, any>[]>; /** * Hook to create a mutable reference object within a Reblend component. * * @template T - The type of the ref value. * @param {T} [_initial] - The initial ref value. * @returns {ReblendTyping.Ref<T>} - Returns a reference object with the current value. */ static createRef<T>(_initial?: T): ReblendTyping.Ref<unknown>; createInnerHtmlElements(): Promise<ReblendTyping.Component<P, S>[]>; populateHtmlElements(): Promise<ReblendTyping.Component<P, S>[]>; connectedCallback(): Promise<void>; addStyle(style: string[] | IAny | string): void; initState<ExpectedReturn = any>(): Promise<ExpectedReturn>; initProps(props: P): Promise<void>; componentDidMount(): void; setState(value: S): void; applyEffects(type: EffectType): Promise<void>; handleError(error: Error): void; onStateChange(): Promise<void>; html(): Promise<ReblendTyping.ReblendNode>; mountEffects(): Promise<void>; disconnectedCallback(fromCleanUp?: boolean): Promise<void>; cleanUp(): void; componentWillUnmount(): void; dependenciesChanged(currentDependencies: Array<any> | undefined, previousDependencies: Array<any> | undefined): boolean; generateId(): any; getCacher(dependencies: undefined | (() => any)): () => any; useState<T>(initial: ReblendTyping.StateFunctionValue<T>, stateKey: string): [T, ReblendTyping.StateFunction<T>]; useEffect<T>(fn: ReblendTyping.StateEffectiveFunction<T>, dependencies?: () => any): void; useEffectAfter<T>(fn: ReblendTyping.StateEffectiveFunction<T>, dependencies?: () => any): void; useProps<T>(fn: ReblendTyping.StateEffectiveFunction<T>): void; useReducer<T, I>(reducer: ReblendTyping.StateReducerFunction<T, I>, initial: ReblendTyping.StateFunctionValue<T>, stateKey: string): [T, ReblendTyping.StateFunction<I>]; useMemo<T, E>(fn: ReblendTyping.StateEffectiveMemoFunction<T, E>, stateKey: string, dependencies?: () => any): T; useRef<T>(initial?: T): ReblendTyping.Ref<T>; useCallback<T extends (...args: any[]) => any>(fn: T): T; /** * Initializes the component, preparing effect management. * For compatibility in case a standard element inherits this prototype; can manually execute this constructor. */ _constructor(): void; }