import { DefaultTreeProps, DefaultTreeState } from "./utils.js"; import { Align, FixedSizeList, ListChildComponentProps, ListProps, VariableSizeList } from "react-window"; import { Component, ComponentType, PropsWithChildren, PureComponent, ReactElement, ReactNode, Ref, RefObject } from "react"; //#region src/Tree.d.ts type NodeData = Readonly<{ /** * Unique ID of the current node. */ id: string; /** * Default node openness state. If the Tree component performs building a new * Tree and the preservePreviousState prop is not set, this value will be used * to set the openness state of the node. */ isOpenByDefault: boolean; }>; type TreeWalkerValue = Readonly<{ data: TData; } & TMeta>; type OpennessStateUpdateRules> = Readonly<{ open: boolean; subtreeCallback?(node: TNodePublicState, ownerNode: TNodePublicState): void; }>; type NodePublicState = Readonly<{ data: TData; setOpen(state: boolean): Promise; }> & { isOpen: boolean; }; type NodeRecord> = Readonly<{ public: TNodePublicState; }> & { child: NodeRecord | null; isShown: boolean; parent: NodeRecord | null; sibling: NodeRecord | null; visited: boolean; }; type NodeComponentProps> = Readonly & TNodePublicState & { /** * The data provided by user via `itemData` Tree component property. */ treeData?: any; }>; type TreeWalker = () => Generator | undefined, undefined, TreeWalkerValue>; type OpennessState> = Readonly | boolean>>; type TreeComputerProps = Readonly<{ async?: boolean; buildingTaskTimeout?: number; placeholder?: ReactNode; treeWalker: TreeWalker; }>; type TreeComputerState> = Readonly<{ order?: string[]; records: ReadonlyMap>; setState: Component>["setState"]; updateRequest: object; }>; type TreeProps, TListComponent extends FixedSizeList | VariableSizeList> = Readonly> & TreeComputerProps & Readonly<{ children: ComponentType>; listRef?: Ref; rowComponent?: ComponentType; }>; type TreeState, TListComponent extends FixedSizeList | VariableSizeList> = TreeComputerState & Readonly<{ attachRefs: Ref; computeTree: TreeComputer; list: RefObject; recomputeTree(options: OpennessState): Promise; treeWalker: TreeWalker; }>; type TypedListChildComponentData> = Readonly<{ /** * The Node component provided by the user. */ component: ComponentType>; /** * The function that returns public data from visible records by index. * * @param index */ getRecordData(index: number): TNodePublicState; /** * @see NodeComponentProps#treeData */ treeData: any; }>; type TypedListChildComponentProps> = Readonly & { data: TypedListChildComponentData; }>; declare const Row: >({ index, data: { component: Node, getRecordData, treeData }, style, isScrolling }: PropsWithChildren>) => ReactElement | null; type TreeComputerOptions> = Readonly<{ opennessState?: OpennessState; refresh?: boolean; }>; type TreeComputer, TProps extends TreeComputerProps, TState extends TreeComputerState> = (props: TProps, state: TState, options: TreeComputerOptions) => (Pick & Partial>) | null; declare class Tree, TProps extends TreeProps, TState extends TreeState, TListComponent extends FixedSizeList | VariableSizeList> extends PureComponent { static defaultProps: Partial; static getDerivedStateFromProps(props: DefaultTreeProps, state: DefaultTreeState): Partial | null; constructor(props: TProps, context: any); protected getItemData(): TypedListChildComponentData; protected getRecordData(index: number): TNodePublicState; recomputeTree(state: OpennessState): Promise; scrollTo(scrollOffset: number): void; scrollToItem(id: string, align?: Align): void; } //#endregion export { NodeData, NodePublicState, OpennessState, Row, Tree, TreeProps, TreeState, TreeWalker, TreeWalkerValue }; //# sourceMappingURL=Tree.d.ts.map