@marciocamello/react-sortable-tree
Version:
Drag-and-drop sortable component for nested data and hierarchies
37 lines (36 loc) • 1.14 kB
TypeScript
import { ReactNode } from 'react';
export interface GetTreeItemChildren {
done: (children: TreeItem[]) => void;
node: TreeItem;
path: number[];
lowerSiblingCounts: number[];
treeIndex: number;
}
export type GetTreeItemChildrenFn = (data: GetTreeItemChildren) => void;
export type GetNodeKeyFunction = (data: TreeIndex & TreeNode) => string | number;
export interface TreeItem {
title?: ReactNode | undefined;
subtitle?: ReactNode | undefined;
expanded?: boolean | undefined;
children?: TreeItem[] | GetTreeItemChildrenFn | undefined;
[x: string]: any;
}
export interface TreeNode {
node: TreeItem;
}
export interface TreePath {
path: number[];
}
export interface TreeIndex {
treeIndex: number;
}
export interface FullTree {
treeData: TreeItem[] | undefined;
}
export interface NodeData extends TreeNode, TreePath, TreeIndex {
}
export interface SearchData extends NodeData {
searchQuery: string;
}
export declare const defaultGetNodeKey: ({ treeIndex }: TreeIndex) => number;
export declare const defaultSearchMethod: ({ node, path, treeIndex, searchQuery, }: SearchData) => boolean;