UNPKG

reblendjs

Version:

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

97 lines (96 loc) 5.12 kB
import * as ReblendTyping from 'reblend-typing'; /** * Detaches the given node from the DOM. * If the node is a primitive, the function returns immediately. * If the node has a `disconnectedCallback`, it will be invoked. * Otherwise, it will be removed from the DOM. * * @param {ReblendTyping.Component<P, S> | HTMLElement} node - The node to detach. */ export declare function detach<P, S>(node: ReblendTyping.Component<P, S> | HTMLElement): Promise<void>; /** * Detaches all child nodes and HTML elements from the given `HTMLElement/Component`. * If the node is a primitive, the function returns immediately. * * @param {HTMLElement} node - The parent node from which children will be detached. */ export declare function detachChildren<P, S>(node: HTMLElement): Promise<void>; /** * Calls `connectedCallback` on the node if it exists, signaling that the node has been connected to the DOM. * * @template T * @param {T | undefined} node - The node to connect. */ export declare function connected<P, S, T extends ReblendTyping.Component<P, S> | HTMLElement>(node: T | undefined): Promise<void>; /** * Replaces the old node with a new node or nodes. * Handles scenarios where old and new nodes may be React-based or standard HTML. * * @param {ReblendTyping.Component<P, S> | ReblendTyping.Component<P, S>[]} newNode - The new node(s) to replace the old node. * @param {ReblendTyping.Component<P, S>} oldNode - The old node to be replaced. */ export declare function replaceOldNode<P, S>(newNode: ReblendTyping.Component<P, S> | ReblendTyping.Component<P, S>[], oldNode: ReblendTyping.Component<P, S>): Promise<void>; /** * Creates patches to create or remove nodes by comparing oldNode and newNode. * * @param {ReblendTyping.Component<P, S>} parent - The parent node. * @param {ReblendTyping.DomNodeChild} oldNode - The old node. * @param {ReblendTyping.VNodeChild} newNode - The new node. * @returns {ReblendTyping.Patch[]} - The array of patches. */ export declare function diffCreateOrRemove<P, S>(parent: ReblendTyping.Component<P, S>, oldNode: ReblendTyping.DomNodeChild<P, S>, newNode: ReblendTyping.VNodeChild): ReblendTyping.Patch<P, S>[]; /** * Diffs oldNode and newNode to generate patches that represent the changes between them. * * @param {ReblendTyping.Component<P, S>} parent - The parent node. * @param {ReblendTyping.DomNodeChild} oldNode - The old node. * @param {ReblendTyping.VNodeChild} newNode - The new node. * @returns {ReblendTyping.Patch[]} - The array of patches. */ export declare function diff<P, S>(parent: ReblendTyping.Component<P, S>, oldNode: ReblendTyping.DomNodeChild<P, S>, newNode: ReblendTyping.VNodeChild): ReblendTyping.Patch<P, S>[]; /** * Diffs the props of the newNode and oldNode to generate a list of prop changes. * * @param {VNode} newNode - The new virtual node. * @param {ReblendTyping.Component<P, S>} oldNode - The old base component node. * @returns {any[]} - The array of property differences. */ export declare function diffProps<P, S>(newNode: ReblendTyping.VNode, oldNode: ReblendTyping.Component<P, S>): ReblendTyping.PropPatch<P, S>[]; /** * Diffs the children of the old and new virtual nodes and returns the patches required to update them. * * @param {ReblendTyping.Component<P, S>} parent - The parent component containing the children. * @param {ReblendTyping.Component<P, S>} oldNode - The old component node. * @param {VNode} newNode - The new virtual node. * @returns {Patch[]} - An array of patches representing the differences between the old and new children. */ export declare function diffChildren<P, S>(parent: ReblendTyping.Component<P, S>, oldNode: ReblendTyping.Component<P, S>, newNode: ReblendTyping.VNode): ReblendTyping.Patch<P, S>[]; /** * Applies an array of patches to the component. * * @param {Patch[]} patches - The array of patches to apply. */ export declare function applyPatches<P, S>(patches: ReblendTyping.Patch<P, S>[]): Promise<void>; /** * Asynchronously applies property patches to nodes. * * @param {PropPatch[]} [patches] - The property patches to apply. */ export declare function applyProps<P, S>(patches?: ReblendTyping.PropPatch<P, S>[][]): Promise<void>; /** * Performs a replacement operation on an old node. * * @param {ReblendTyping.Component<P, S>} oldNode - The old node to replace. * @param {() => void} operation - The operation to execute for the replacement. */ export declare function replaceOperation<P, S>(oldNode: ReblendTyping.Component<P, S>, operation: () => Promise<void>, isRemoveOperation?: boolean): Promise<void>; /** * Callback invoked when the component is connected to the DOM. */ export declare function connectedCallback<P, S>(thiz: ReblendTyping.Component<P, S>): Promise<void>; /** * Lifecycle method called when the component is disconnected from the DOM. * Cleans up resources and removes the component from its parent. * Uses bruteforce approach insuring that there is not memory leakage */ export declare function disconnectedCallback<P, S>(thiz: ReblendTyping.Component<P, S>, fromCleanUp?: boolean): Promise<void>;