import type { Node } from "./branch"; import { Branch } from "./branch"; import { Leaf } from "./leaf"; export declare class Tree { protected loadingBranches: Map, Promise>; private getNodes; comparator?: (a: Node, b: Node) => number; flatView: import("./subject").Subject; root: Branch; nodesById: Node[]; constructor({ getNodes, root, comparator, }: { getNodes: GetNodes; root: Branch; comparator?: (a: Node, b: Node) => number; }); get visibleNodes(): number[]; getSnapshot: () => number[]; getById(id: number): Node | undefined; /** * Ensures that the children of any given branch have been loaded and ready to be worked with. * * Call this method without any arguments to check if the root branch is loaded. * * ⚠ "Loaded" doesn't mean expanded, it just means the contents are "ready". Except when no arguments are given, the * branch being checked is root, and root is always expanded. * * @param branch - The branch to check */ ensureLoaded(branch?: Branch): Promise; expand(branch: Branch, options?: { ensureVisible?: boolean; recursive?: boolean; }): Promise; collapse(branch: Branch): void; protected _produce(branch: Branch, produceFn: (context: { get draft(): Node[]; insert>(node: NodeType, insertionIndex?: number): NodeType; revert(): void; }) => void | Node[]): void; remove(nodeToRemove: Node): void; move(node: Node, to: Branch): Promise; /** * Invalidate the list of visible nodes. This is useful for re-rendering your tree * when node data changes. */ invalidate(): void; /** * A more accurate and real-time representation of whether a branch is expanded. * * `Branch#expanded` represents the "optimistic" expansion state of the branch in * question not the actual status, because the child nodes might still need to be * loaded before the change can be seen in the tree. * * @param branch - The branch to check */ isExpanded(branch: Branch): boolean; /** * Returns `true` if the node and its parents are visible in the tree. * * @param node - The node to check */ isVisible(node: Node): boolean; /** * You can use this method to manually trigger a reload of a branch in the tree. * * @param branch - The branch to load nodes for */ loadNodes(branch: Branch): Promise; protected setNodes(branch: Branch, nodeIds: number[] | Node[]): void; private createVisibleNodes; dispose(): void; } export declare function isLeaf(node: Node | undefined): node is Leaf; export declare function isBranch(node: Node | undefined): node is Branch; export declare type GetNodes = { (parent: Branch): Node[] | Promise[]>; };