/** * Row-grouping display helpers. Two pure, framework-free transforms: * * - `insertGroupFooters` inserts a footer/total row after each group's children * (and optionally a grand-total row at the end), carrying the group's already * computed aggregate values. Mirrors the server model's footer shape * (`server-group-model.ts`) client-side. * - `buildAutoGroupColumns` decides, for a grouping display mode, which synthetic * "auto group" columns to show and which grouped source columns to hide - the * groundwork for `singleColumn` / `multipleColumns` display types (the current * default `groupRows` renders a full-width banner and needs neither). * * Both are generic over the row / column shape (via small accessor callbacks) so * they are trivially unit-testable and carry no dependency on the grid runtime. */ /** AG-Grid-style grouping display variants. */ export type GroupDisplayType = 'groupRows' | 'singleColumn' | 'multipleColumns'; export type GroupFooterOptions = { /** Depth of a row (group rows and their descendants). */ getDepth: (row: R) => number; /** True when a row is a group (banner) row. */ isGroup: (row: R) => boolean; /** Build a footer row from the group row it closes (carries its aggregates). */ makeFooter: (groupRow: R) => R; /** Insert a footer after each group's children. */ includeGroupFooter?: boolean; /** Append a grand-total footer at the very end. */ includeGrandTotalFooter?: boolean; /** Build the grand-total footer (over the whole set). Return null to skip. */ makeGrandTotal?: () => R | null; }; /** * Insert group footer rows after each group's descendants. A group opened at * depth d closes when a later row appears at depth <= d (a sibling group or an * ancestor-level row); its footer is emitted at that point. Order is otherwise * preserved. No-op when neither footer flag is set. */ export declare function insertGroupFooters(rows: ReadonlyArray, opts: GroupFooterOptions): R[]; export type GroupPaginationOptions = { /** Depth of a row (group rows and their descendants). */ getDepth: (row: R) => number; /** True when a row is a group (banner) row. */ isGroup: (row: R) => boolean; /** * True when a group row is expanded. Defaults to treating every group as * expanded. This matters: an EXPANDED group is a header, reprinted above its * children and costing no page budget, while a COLLAPSED group is the visible * unit itself and must consume a slot - otherwise a fully collapsed grid has * no budget-consuming rows at all and every page comes back empty. */ isExpanded?: (row: R) => boolean; pageIndex: number; pageSize: number; }; export type GroupPaginationResult = { /** The rows to render for this page: the page's budget-consuming rows, each * preceded by whichever ancestor banners have not been printed yet. */ rows: R[]; /** Budget-consuming rows across every page - what the pager divides by. * Data rows plus collapsed group rows; expanded banners do not count. */ dataRowCount: number; }; /** * Paginate a grouped row list by DATA rows, repeating each page's ancestor * group headers. * * Slicing the flat grouped list directly counts group banners against * `pageSize`, so `pageSize: 10` over ten groups of two shows almost no data * (#73). Here only non-group rows consume the page budget, and a page reprints * the group chain its first rows sit under - the same thing a spreadsheet does * when a grouped table breaks across pages. * * Ancestors are tracked with a depth stack rather than parent pointers, so this * works on the already-flattened expanded model and needs nothing from the row * objects but depth and group-ness. */ export declare function paginateGroupedRows(rows: ReadonlyArray, opts: GroupPaginationOptions): GroupPaginationResult; export type AutoGroupColumnSpec = { /** Synthetic column id (e.g. `__autoGroup` or `__group_`). */ id: string; /** The grouped field this auto column stands in for (null for the single * combined auto-group column). */ field: string | null; /** Nesting level this column represents (0-based), for indentation. */ level: number; }; export type AutoGroupResult = { /** Synthetic auto-group column specs to prepend to the visible columns. */ autoColumns: AutoGroupColumnSpec[]; /** Ids of the grouped SOURCE columns to hide (rolled into the auto columns). */ hiddenSourceIds: Set; }; /** * Decide the synthetic auto-group columns for a grouping display mode: * - `groupRows`: none (the banner path handles display) - `{ [], {} }`. * - `singleColumn`: one combined auto-group column; every grouped source column * is hidden. * - `multipleColumns`: one auto column per grouped field; the grouped source * columns are hidden. */ export declare function buildAutoGroupColumns(grouping: ReadonlyArray, displayType: GroupDisplayType): AutoGroupResult;