import { EditResult } from "../types/handlers"; import { Identity, IdObj } from "../types/utils"; import { TreeProps } from "../types/tree-props"; import { MutableRefObject } from "react"; import { Align, FixedSizeList, ListOnItemsRenderedProps, VariableSizeList } from "react-window"; import { DefaultRow } from "../components/default-row"; import { DefaultNode } from "../components/default-node"; import { NodeApi } from "./node-api"; import { Actions, RootState } from "../state/root-reducer"; import { DefaultDragPreview } from "../components/default-drag-preview"; import { DefaultContainer } from "../components/default-container"; import { Cursor } from "../dnd/compute-drop"; import type { DropResult } from "../dnd/drop-hook"; import { Store } from "redux"; export declare class TreeApi { store: Store; props: TreeProps; list: MutableRefObject; listEl: MutableRefObject; static editPromise: null | ((args: EditResult) => void); root: NodeApi; visibleNodes: NodeApi[]; /** Number of nodes matching the current searchTerm (0 when not filtered). * Computed alongside visibleNodes so reading it never re-traverses the tree. * See the filteredCount getter for the consumer-facing contract. */ private matchCount; visibleStartIndex: number; visibleStopIndex: number; idToIndex: { [id: string]: number; }; private rowOffsets; constructor(store: Store, props: TreeProps, list: MutableRefObject, listEl: MutableRefObject); update(props: TreeProps): void; dispatch(action: Actions): { type: "FOCUS"; id: string | null; } | { readonly type: "TREE_BLUR"; } | { type: "EDIT"; id: string | null; } | import("../types/utils").ActionTypes<{ open(id: string, filtered: boolean): { type: "VISIBILITY_OPEN"; id: string; filtered: boolean; }; close(id: string, filtered: boolean): { type: "VISIBILITY_CLOSE"; id: string; filtered: boolean; }; toggle(id: string, filtered: boolean): { type: "VISIBILITY_TOGGLE"; id: string; filtered: boolean; }; clear(filtered: boolean): { type: "VISIBILITY_CLEAR"; filtered: boolean; }; }> | import("../types/utils").ActionTypes<{ clear: () => { type: "SELECTION_CLEAR"; }; only: (id: string) => { type: "SELECTION_ONLY"; id: string; }; add: (id: string | string[]) => { type: "SELECTION_ADD"; ids: string[]; }; remove: (id: string | string[]) => { type: "SELECTION_REMOVE"; ids: string[]; }; set: (args: { ids: Set; anchor: string | null; mostRecent: string | null; }) => { ids: Set; anchor: string | null; mostRecent: string | null; type: "SELECTION_SET"; }; mostRecent: (id: string | null) => { type: "SELECTION_MOST_RECENT"; id: string | null; }; anchor: (id: string | null) => { type: "SELECTION_ANCHOR"; id: string | null; }; }> | import("../types/utils").ActionTypes<{ cursor(cursor: Cursor): { type: "DND_CURSOR"; cursor: Cursor; }; dragStart(id: string, dragIds: string[]): { type: "DND_DRAG_START"; id: string; dragIds: string[]; }; dragEnd(): { type: "DND_DRAG_END"; }; hovering(parentId: string | null, index: number | null): { type: "DND_HOVERING"; parentId: string | null; index: number | null; }; setDestination(parentId: string | null, index: number | null): { type: "DND_DESTINATION"; parentId: string | null; index: number | null; }; }>; get state(): { nodes: { focus: import("../state/focus-slice").FocusState; edit: import("../state/edit-slice").EditState; open: import("../state/open-slice").OpenSlice; selection: import("../state/selection-slice").SelectionState; drag: import("../state/drag-slice").DragSlice; }; dnd: import("../state/dnd-slice").DndState; }; get openState(): import("../state/open-slice").OpenMap; get width(): string | number; get height(): number; get indent(): number; /** * The fixed row height. When a `rowHeight` function is supplied for variable * heights, this returns the default (24); use `rowHeightAt(index)` to get the * height of a specific row. */ get rowHeight(): number; /** * The height of the row at `index`, evaluating the `rowHeight` function if * given. Falls back to the default height for an out-of-range index so this * never feeds an invalid `0` to react-window's `itemSize`. */ rowHeightAt: (index: number) => number; /** The pixel offset of the top of the row at `index` from the top of the list. */ rowTopPosition: (index: number) => number; /** * Tell the underlying virtualized list to recompute row heights at and after * `index`. Call this if a `rowHeight` function's output changes for reasons * the tree can't observe (e.g. external state). */ redrawList: (afterIndex?: number) => void; /** Lazily-built prefix sum where offsets[i] is the top of row i. */ private getRowOffsets; get overscanCount(): number; get searchTerm(): string; get matchFn(): (node: NodeApi) => boolean; accessChildren(data: T): readonly T[] | null; accessId(data: T): string; /** * Resolve an identifier to a node id. Public methods accept an id string, a * NodeApi, or the raw row data; this is the one place that turns any of those * into the string id used internally. Raw data is run through the configured * `idAccessor` so a custom accessor (e.g. `uuid`) is honored everywhere, not * just where nodes were built. A NodeApi already carries its accessor-derived * `id`, so it is used directly rather than re-accessed (the accessor reads the * underlying data, which a NodeApi does not expose under that key). Unlike * `accessId`, an unresolved id comes back as `undefined` rather than throwing, * preserving the previous behavior of the `id`-only lookup. */ identify(identity: string | IdObj | T): string; identifyNull(identity: Identity | T): string | null; get firstNode(): NodeApi; get lastNode(): NodeApi; get focusedNode(): NodeApi | null; get mostRecentNode(): NodeApi | null; get nextNode(): NodeApi | null; get prevNode(): NodeApi | null; get(id: string | null): NodeApi | null; at(index: number): NodeApi | null; nodesBetween(startId: string | null, endId: string | null): NodeApi[]; indexOf(id: Identity | T): number | null; get editingId(): string | null; createInternal(): Promise; createLeaf(): Promise; create(opts?: { type?: "internal" | "leaf"; parentId?: null | string; index?: null | number; }): Promise; delete(node: Identity | T | (string | IdObj | T)[]): Promise; edit(node: string | IdObj | T): Promise; submit(identity: Identity | T, value: string): Promise; reset(): void; activate(id: Identity | T): void; private resolveEdit; get selectedIds(): Set; get selectedNodes(): NodeApi[]; focus(node: Identity | T, opts?: { scroll?: boolean; }): void; pageUp(): void; pageDown(): void; select(node: Identity | T, opts?: { align?: Align; focus?: boolean; }): void; deselect(node: Identity | T): void; selectMulti(identity: Identity | T, opts?: { align?: Align; focus?: boolean; }): void; selectContiguous(identity: Identity | T): void; deselectAll(): void; selectAll(): void; private filterSelectableNodes; setSelection(args: { ids: (IdObj | string | T)[] | null; anchor: Identity | T; mostRecent: Identity | T; }): void; get cursorParentId(): string | null; get cursorOverFolder(): boolean; get dragNodes(): NodeApi[]; get dragNode(): NodeApi | null; get dragDestinationParent(): NodeApi | null; get dragDestinationIndex(): number | null; canDrop(): boolean; hover(drop: DropResult | null, cursor: Cursor | null): void; drop(): void; hideCursor(): void; showCursor(cursor: Cursor): void; open(identity: Identity | T, redraw?: boolean): void; close(identity: Identity | T, redraw?: boolean): void; toggle(identity: Identity | T): void; openParents(identity: Identity | T): void; openSiblings(node: NodeApi): void; openAll(): void; closeAll(): void; scrollTo(identity: Identity | T, align?: Align): Promise | undefined; /** * Horizontally scroll the list so the node's indented content is in view. * A no-op when the list doesn't overflow horizontally (the common case), so * it never disturbs scrolling for trees that fit their width. */ private scrollToNodeHorizontally; /** * Scroll the list vertically to an exact pixel offset from the top. This is * the offset-based counterpart to scrollTo(), handy for saving and restoring * a scroll position (#194). Negative values are clamped to the top; react- * window clamps the upper bound to the scrollable range. */ scrollToOffset(offset: number): void; /** The list's current vertical scroll offset, in pixels from the top. */ get scrollOffset(): number; get isEditing(): boolean; get isFiltered(): boolean; /** The number of nodes matching the current search term, counted across the * whole tree regardless of which folders are open. Returns 0 when there is no * active search. Consumers use this to render match counts or a "no results" * message (#112, #256). Ancestors shown only to keep the tree's structure * intact are not counted. The count is computed once when the visible list is * built (see createList), so reading it never re-traverses the tree. */ get filteredCount(): number; get hasFocus(): boolean; get hasNoSelection(): boolean; get hasOneSelection(): boolean; get hasMultipleSelections(): boolean; isSelected(id?: string): boolean; isOpen(id?: string): boolean; isEditable(data: T): boolean; isDraggable(data: T): boolean; isSelectable(data: T): boolean; private isActionPossible; isDragging(node: Identity | T): boolean; isFocused(id: string): boolean; isMatch(node: NodeApi): boolean; willReceiveDrop(node: Identity | T): boolean; onFocus(): void; onBlur(): void; onItemsRendered(args: ListOnItemsRenderedProps): void; get renderContainer(): import("react").ElementType<{}> | typeof DefaultContainer; get renderRow(): import("react").ElementType> | typeof DefaultRow; get renderNode(): import("react").ElementType> | typeof DefaultNode; get renderDragPreview(): import("react").ElementType | typeof DefaultDragPreview; get renderCursor(): import("react").ElementType | import("react").NamedExoticComponent; }