/** * Definition store for the Summary Row feature. * * Owns the *shape* of the summary — which rows exist, where each is anchored, * what scope it aggregates, how tall it is — and nothing about how values are * computed (that is {@link import('./summary-service').SummaryService}) or how * they are painted (that is * {@link import('./summary-row-renderer').SummaryRowRenderer}). * * Definitions arrive from three places, in precedence order: * 1. {@link SummaryModel.setRows} — the runtime API. * 2. {@link SummaryConfig.rows} — the initial `GridOptions.summary.rows`. * 3. Columns declaring `ColumnDef.showSummary` — a derived fallback that makes * the long-standing per-column summary properties work with no extra setup. * * @packageDocumentation */ import type { ColumnDef } from '../types/column.types'; import { SummaryPosition, SummaryScope, type SummaryConfig, type SummaryRowDef, type SummaryRowSnapshot } from './summary.types'; /** Id of the row derived from `ColumnDef.showSummary`. Stable, so it can be patched or removed like any other. */ export declare const DERIVED_SUMMARY_ROW_ID = "pg-summary-derived-total"; /** * A summary row definition with every optional policy resolved against the * grid-wide defaults — what the service and renderer consume, so neither has to * re-implement the fallback chain. */ export interface ResolvedSummaryRow { /** Stable id (supplied or generated). */ readonly id: string; /** The originating definition, for cell lookup and patching. */ readonly def: SummaryRowDef; /** Resolved band. */ readonly position: SummaryPosition; /** Resolved stickiness. */ readonly sticky: boolean; /** Resolved row scope. */ readonly scope: SummaryScope; /** Resolved height in pixels. */ readonly height: number; /** Extra class name(s), or `null`. */ readonly className: string | null; } /** * Holds and normalizes summary row definitions. * * Pure state — no DOM, no event bus, no grid context. One instance per grid. */ export declare class SummaryModel { private readonly config; /** `GridOptions.rowHeight`, used when neither the row nor the config sets a height. */ private readonly gridRowHeight; /** Normalized rows, in declaration order (which is also paint order within a band). */ private resolved; /** Last computed values, keyed by row id. Replaced wholesale on every refresh. */ private snapshots; /** * Bumped whenever the *structure* changes — rows added, removed, reordered, or * any resolved policy altered. The renderer compares this against what it last * painted to decide between a cheap value patch and a full band rebuild. */ private structureVersion; /** * `true` while the rows are derived from `ColumnDef.showSummary` rather than * explicitly configured. Any call to {@link setRows} takes ownership and * switches this off permanently, so a later column change cannot silently * overwrite host-supplied definitions. */ private derived; /** * Column signature the derived row was last built from. Rebuilding is skipped * while it is unchanged, so the common case (columns re-published on every * pipeline run with the same summary settings) costs one string compare. */ private derivedSignature; /** Monotonic counter behind generated row ids. */ private nextGeneratedId; constructor(config: SummaryConfig, /** `GridOptions.rowHeight`, used when neither the row nor the config sets a height. */ gridRowHeight: number | undefined); /** @returns Every resolved row, in declaration order. */ getRows(): readonly ResolvedSummaryRow[]; /** * @param rowId - Id to look up. * @returns The resolved row, or `null`. */ getRow(rowId: string): ResolvedSummaryRow | null; /** * Rows painted in one band, split by stickiness — the exact four buckets the * renderer maintains as separate DOM regions. * * @param position - {@link SummaryPosition.Top} or {@link SummaryPosition.Bottom}. * @param sticky - `true` for the docked band, `false` for the in-content one. */ getRowsForBand(position: SummaryPosition.Top | SummaryPosition.Bottom, sticky: boolean): ResolvedSummaryRow[]; /** @returns `true` when no summary row is defined, so the feature can be skipped wholesale. */ isEmpty(): boolean; /** @returns The current structure version. @see {@link structureVersion} */ getStructureVersion(): number; /** * Stores the freshly computed values. * * @param snapshots - One snapshot per resolved row, in the same order. */ setSnapshots(snapshots: readonly SummaryRowSnapshot[]): void; /** @returns The last computed snapshots, in row declaration order. */ getSnapshots(): readonly SummaryRowSnapshot[]; /** * @param rowId - Id to look up. * @returns That row's last computed snapshot, or `null`. */ getSnapshot(rowId: string): SummaryRowSnapshot | null; /** * Replaces every row definition. Takes permanent ownership of the definitions * away from column-derived mode. * * @param rows - The new definitions. */ setRows(rows: readonly SummaryRowDef[]): void; /** * Shallow-merges a patch into one row, merging `cells` one level deep so a * single column's cell can be replaced without restating the others. * * @param rowId - Id of the row to patch. * @param patch - Properties to overwrite. * @returns `true` when the row existed. */ updateRow(rowId: string, patch: Partial): boolean; /** * Removes one row definition. * * @param rowId - Id of the row to remove. * @returns `true` when the row existed. */ removeRow(rowId: string): boolean; /** * Rebuilds the column-derived total row when in derived mode and the columns' * summary settings changed. * * A no-op once {@link setRows} has been called, and a single string compare * when the derived signature is unchanged — so this is safe to call on every * pipeline run. * * @param columns - The grid's current leaf columns. * @returns `true` when the derived row was rebuilt. */ syncDerivedRows(columns: readonly ColumnDef[]): boolean; /** Normalizes and installs a full row list, bumping the structure version once. */ private replaceRows; /** * Resolves a definition's optional policy against the grid-wide defaults. * Kept in one place so the fallback chain — row → config → grid → constant — * is stated exactly once. */ private resolve; /** * Returns the supplied id when it is present and unused, otherwise generates * one. Duplicate ids would make `updateSummaryRow` / `removeSummaryRow` * ambiguous, so a collision is resolved rather than accepted. */ private ensureUniqueId; } //# sourceMappingURL=summary-model.d.ts.map