@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
42 lines (41 loc) • 1.9 kB
TypeScript
import type { DimensionSort, RowAggregated, RowLeaf, RowNode, RowSelectionState, RowSource, SortFn } from "@1771technologies/lytenyte-shared";
export interface UseTreeDataSourceParams<T = unknown> {
readonly topData?: (RowLeaf<T> | RowAggregated)[];
readonly botData?: (RowLeaf<T> | RowAggregated)[];
readonly data: Record<string, unknown>;
readonly idFn?: (path: string[], data: any) => string;
readonly rowRootFn?: (x: object) => [key: string, child: object][];
readonly rowValueFn?: (x: any, parent: any, key: string) => any;
readonly rowChildrenFn?: (x: any, parent: any, key: string) => [key: string, child: object][];
readonly rowGroupExpansions?: {
[rowId: string]: boolean | undefined;
};
readonly rowGroupDefaultExpansion?: boolean | number;
readonly onRowGroupExpansionChange?: (state: Record<string, boolean | undefined>) => void;
readonly sort?: SortFn<any> | DimensionSort<any>[] | null;
readonly filter?: ((data: any) => boolean) | null;
readonly rowsIsolatedSelection?: boolean;
readonly rowSelectKey?: unknown[];
readonly rowSelection?: RowSelectionState;
readonly rowSelectionIdUniverseAdditions?: {
readonly id: string;
root: boolean;
}[];
readonly rowSelectionIdUniverseSubtractions?: Set<string>;
readonly onRowSelectionChange?: (state: RowSelectionState) => void;
readonly onRowDataChange?: (params: {
readonly changes: {
next: any;
prev: any;
parent: any;
key: string;
path: string[];
}[];
readonly top: Map<number, T>;
readonly bottom: Map<number, T>;
}) => void;
}
export interface RowSourceTree<T> extends RowSource<T> {
readonly rowUpdate: (rows: Map<RowNode<T>, T>) => void;
}
export declare function useTreeDataSource<T>(p: UseTreeDataSourceParams<T>): RowSource;