UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

32 lines (31 loc) 1.55 kB
import type { AggregationFn, GroupFn, GroupIdFn, RowGroup, RowLeaf } from "@1771technologies/lytenyte-shared"; import type { HavingFilterFn, LabelFilter } from "../../use-client-data-source.js"; export interface RootNode<T> { readonly kind: "root"; readonly children: RootMap<T>; readonly groupLookup: Map<string, GroupNode<T>>; readonly maxDepth: number; } export interface LeafNode<T> { readonly parent: GroupNode<T> | RootNode<T>; readonly kind: "leaf"; readonly key: string | null | number; readonly row: RowLeaf<T>; } export interface GroupNode<T> { readonly kind: "branch"; readonly id: string; readonly row: RowGroup & { __children: Map<string | null | number, GroupNode<T> | LeafNode<T>>; __invalidate: boolean; }; readonly last: boolean; readonly key: string | null | number; readonly children: Map<string | null | number, GroupNode<T> | LeafNode<T>>; readonly path: (string | null)[]; readonly leafs: number[]; leafIds: Set<string>; readonly parent: GroupNode<T> | RootNode<T>; } export type RootMap<T> = Map<string | null | number, GroupNode<T> | LeafNode<T>>; export declare function useGroupTree<T>(leafs: RowLeaf<T>[], workingSet: number[], group: GroupFn<T> | undefined | null, groupIdFn: GroupIdFn, rowGroupCollapseBehavior: "no-collapse" | "last-only" | "full-tree", labelFilter: (LabelFilter | null)[] | null | undefined, having: (HavingFilterFn | null)[] | null | undefined, agg: AggregationFn<T> | undefined | null): RootNode<T> | null;