import type { TreeNode, TreeRenderNode, TreeRow } from './types'; import { type LoadedChildren } from './treeUtils'; export interface UseTreeStateOptions { data: TreeNode[]; expandAll: boolean; collapsible: boolean; accordion: boolean; expandedIds?: string[]; defaultExpandedIds?: string[]; onExpandedIdsChange?: (ids: string[]) => void; onToggle?: (node: TreeNode, expanded: boolean) => void; filterQuery: string; hideFiltered: boolean; autoExpandOnFilter: boolean; loadChildren?: (node: TreeNode) => Promise; /** Branches mid collapse-animation, kept in the render tree until it ends. */ keepMountedIds?: Set; /** * Ids whose ancestors should be opened — the active route, typically. Applied * whenever the resolved ancestor set changes, not on every render, so a branch * the reader collapsed stays collapsed while they move within it. */ expandToIds?: string[]; } export interface TreeStateResult { /** Open branch ids, in insertion order. */ expandedIds: string[]; /** Replace the whole expanded set. Honours controlled mode like any setter. */ setExpanded: (ids: string[]) => void; /** Visible rows, in display order. The single source of truth for rendering, * keyboard navigation, range selection, striping and aria indices. */ rows: TreeRow[]; rowIds: string[]; rowIndexById: Map; /** The same rows nested, for the animated render path. */ renderNodes: TreeRenderNode[]; descendantMap: Record; parentMap: Record; loadedChildren: LoadedChildren; loadingIds: Set; matchedIds: Set; expandedSet: Set; isExpanded: (id: string) => boolean; toggleNode: (node: TreeNode) => void; setNodeExpanded: (node: TreeNode, expanded: boolean) => void; childrenFor: (node: TreeNode) => TreeNode[] | undefined; isBranch: (node: TreeNode) => boolean; } export declare function useTreeState(options: UseTreeStateOptions): TreeStateResult;