import type { TreeDropPosition, TreeDropTarget, TreeFieldNames, TreeFilterMethodFn, TreeMoveDetail, TreeModelValue, TreeOption, TreeOptions, TreeRemoteFilterFn, TreeSelectableFn } from '../../components/tree/types'; import type { ComponentValue } from '../../types/shared/props'; import type { MaybeElementRef, MaybeRefOrGetter } from '../../types/shared/utils'; import type { ComputedRef, ShallowRef } from 'vue'; export interface TreeFlatNode { key: ComponentValue; node: TreeOption; depth: number; index: number; parentValue?: ComponentValue; hasChildren: boolean; expanded: boolean; } export interface TreeNodeMeta { node: TreeOptions[number]; children: TreeNodeMeta[]; parentValue?: ComponentValue; depth: number; /** Exclusive index in `list` right after this subtree. */ end: number; } export interface TreeIndex { list: TreeNodeMeta[]; byValue: Map; } export interface ResolvedTreeFieldNames { value: string; label: string; children: string; disabled: string; isLeaf: string; } export declare function resolveTreeFieldNames(fieldNames: TreeFieldNames | undefined): ResolvedTreeFieldNames; export declare function createTreeIndex(data: readonly TreeOption[], fieldNames?: TreeFieldNames): TreeIndex; export declare function useTreeIndex(data: MaybeRefOrGetter, fieldNames: MaybeRefOrGetter): ComputedRef; /** Children in `data` win over a cached request, and an untouched node keeps its identity. */ export declare function graftLoadedChildren(data: readonly TreeOption[], loaded: Map, fieldNames?: TreeFieldNames): readonly TreeOption[]; /** Only a non-empty array marks a parent: `children: []` is a leaf unless `isLeaf` says otherwise. */ export declare function hasTreeChildren(node: TreeOption, fieldNames?: TreeFieldNames): boolean; /** * `isLeaf` first, then the data, then a lazy node still waiting. `loadable` means a request would * start now, so a node whose request resolved with nothing becomes a leaf. */ export declare function isTreeLeaf(node: TreeOption, fieldNames: TreeFieldNames | undefined, loadable: boolean): boolean; export interface TreeMatched { /** Every hit plus its ancestors: ancestor-closed, so the row walk can prune whole subtrees. */ visible: ReadonlySet; /** The hits alone. */ exact: ReadonlySet; } export declare function useTreeMatched(index: MaybeRefOrGetter, query: MaybeRefOrGetter, filter: MaybeRefOrGetter, fieldNames?: MaybeRefOrGetter): ComputedRef; export interface UseTreeSearchOptions { query: MaybeRefOrGetter; remoteFilter?: MaybeRefOrGetter; } export interface UseTreeSearchReturn { /** The forest the query last settled on, absent before the first answer. */ matches: ShallowRef; remote: ComputedRef; /** Whether a request is in flight, the debounce window included. */ pending: ShallowRef; active: ComputedRef; } export declare function useTreeSearch(options: UseTreeSearchOptions): UseTreeSearchReturn; export interface UseTreeRowsOptions { query: MaybeRefOrGetter; expanded: MaybeRefOrGetter>; matched: MaybeRefOrGetter>; /** The hits without their ancestors; only read when `matchesOnly` is on. */ exactMatched?: MaybeRefOrGetter | undefined>; matchesOnly?: MaybeRefOrGetter; canLoad?: MaybeRefOrGetter<((value: ComponentValue) => boolean) | undefined>; fieldNames?: MaybeRefOrGetter; } /** * Selection state is deliberately absent: it changes on every click, and putting it here would * rebuild all N rows for a change that touches two of them. Read the sets at render time instead. */ export declare function useTreeRows(index: MaybeRefOrGetter, options: UseTreeRowsOptions): ComputedRef; export interface UseTreeSelectionOptions { index: MaybeRefOrGetter; modelValue: MaybeRefOrGetter; multiple: MaybeRefOrGetter; checkStrictly?: MaybeRefOrGetter; selectable?: MaybeRefOrGetter; fieldNames?: MaybeRefOrGetter; } export interface TreeToggleResult { value: TreeModelValue; halfCheckedValues: ComponentValue[]; } export interface UseTreeSelectionReturn { checked: ComputedRef>; indeterminate: ComputedRef>; toggle: (value: ComponentValue) => TreeToggleResult; /** The span between the anchor and `value`, both ends included; toggles without an anchor. */ extend: (value: ComponentValue) => TreeToggleResult; isSelectable: (value: ComponentValue) => boolean; } export declare function useTreeSelection(options: UseTreeSelectionOptions): UseTreeSelectionReturn; /** Walks up instead of scanning `index.list`: the hit test runs this on every pointer move. */ export declare function isTreeDescendant(index: TreeIndex, ancestorValue: ComponentValue, value: ComponentValue): boolean; export interface TreeMoveResult { data: TreeOptions; detail: TreeMoveDetail; } /** * The node is detached before the target is looked up, which rejects the whole family of invalid * drops for free: it and its descendant are no longer in the tree to be found. */ export declare function moveTreeNode(data: readonly TreeOption[], fieldNames: TreeFieldNames | undefined, value: ComponentValue, target: TreeDropTarget): TreeMoveResult | undefined; export interface UseTreeDragOptions { container: MaybeElementRef; rows: MaybeRefOrGetter; enabled: MaybeRefOrGetter; dropInsideLeaf: MaybeRefOrGetter; /** Rejects a position the tree will refuse, so no indicator is ever painted for it. */ canDrop: (value: ComponentValue, targetValue: ComponentValue, position: TreeDropPosition) => boolean; onExpand: (value: ComponentValue) => void; onCommit: (value: ComponentValue, target: TreeDropTarget) => void; } export declare function useTreeDrag(options: UseTreeDragOptions): { value: ShallowRef; target: ShallowRef; x: ShallowRef; y: ShallowRef; onPointerDown: (nodeValue: ComponentValue, event: PointerEvent) => void; didDrag: () => boolean; };