import type { AggregationFn, Aggregator, Dimension, DimensionAgg, DimensionSort, FilterFn, GroupFn, GroupIdFn, LeafIdFn, RowGroup, RowLeaf, RowNode, RowSelectionState, RowSource, SortFn } from "@1771technologies/lytenyte-shared"; import type { PivotState } from "./hooks/use-pivot/use-pivot-columns.js"; import type { Column, Field, GridSpec, Props } from "../types.js"; export type PivotField = { field?: Field; }; export type HavingFilterFn = (node: RowGroup) => boolean; export interface RowSourceClient extends RowSource { readonly usePivotProps: () => { readonly columns?: Column[]; readonly onColumnsChange: Props["onColumnsChange"]; readonly columnGroupExpansions: Props["columnGroupExpansions"]; readonly onColumnGroupExpansionChange: Props["onColumnGroupExpansionChange"]; }; readonly rowUpdate: (rows: Map, Spec["data"]>) => void; readonly rowDelete: (rows: RowNode[]) => void; readonly rowAdd: (rows: Spec["data"][], placement?: "start" | "end" | number) => void; } export type LabelFilter = (s: string | null) => boolean; export interface PivotModel { readonly columns?: (Column | PivotField)[]; readonly rows?: (Column | PivotField)[]; readonly measures?: { dim: Column; fn: Aggregator | string; }[]; readonly sort?: SortFn | DimensionSort[] | null; readonly filter?: (HavingFilterFn | null)[]; readonly rowLabelFilter?: (LabelFilter | null)[]; readonly colLabelFilter?: (LabelFilter | null)[]; } export interface UseClientDataSourceParams { readonly data: T[]; readonly topData?: T[]; readonly botData?: T[]; readonly pivotMode?: boolean; readonly pivotModel?: PivotModel; readonly pivotGrandTotals?: "top" | "bottom" | null; readonly pivotColumnProcessor?: (columns: Column[]) => Column[]; readonly pivotState?: PivotState; readonly onPivotStateChange?: (p: PivotState) => void; readonly pivotApplyExistingFilter?: boolean; readonly rowGroupExpansions?: { [rowId: string]: boolean | undefined; }; readonly rowGroupDefaultExpansion?: boolean | number; readonly rowGroupCollapseBehavior?: "no-collapse" | "last-only" | "full-tree"; readonly rowGroupSuppressLeafExpansion?: boolean; readonly onRowGroupExpansionChange?: (state: Record) => void; readonly sort?: SortFn | DimensionSort[] | null; readonly group?: GroupFn | Dimension[]; readonly filter?: FilterFn | FilterFn[] | null; readonly aggregate?: AggregationFn | DimensionAgg[]; readonly aggregateFns?: Record>; readonly having?: (HavingFilterFn | null)[] | null; readonly labelFilter?: (LabelFilter | null)[] | null; readonly leafIdFn?: LeafIdFn; readonly groupIdFn?: GroupIdFn; readonly rowsIsolatedSelection?: boolean; readonly rowSelectKey?: unknown[]; readonly rowSelection?: RowSelectionState; readonly rowSelectionIdUniverseAdditions?: { readonly id: string; readonly root: boolean; }[]; readonly rowSelectionIdUniverseSubtractions?: Set; readonly onRowSelectionChange?: (state: RowSelectionState) => void; readonly onRowsAdded?: (params: { newData: T[]; placement: "start" | "end" | number; top: T[]; center: T[]; bottom: T[]; }) => void; readonly onRowsDeleted?: (params: { rows: RowLeaf[]; sourceIndices: number[]; top: T[]; center: T[]; bottom: T[]; }) => void; readonly onRowDataChange?: (params: { readonly rows: Map, T>; readonly top: Map; readonly bottom: Map; readonly center: Map; }) => void; } export declare function useClientDataSource(props: UseClientDataSourceParams): RowSourceClient;