import { type GridFeatureModule, type GridHost, type PresentedRow, type RowPresenter, type RowPresenterContext, type RowTransformer } from 'apex-grid/internal'; import { type ReactiveController } from 'lit'; import { type AggregationConfig, type AggregationResults } from './aggregation.js'; export declare const GROUPING_MODULE_ID = "grouping"; /** Metadata describing a single synthesized group-header row. */ export interface GroupRowMeta { /** Stable, path-joined identity (e.g. `/EMEA/2024`). */ readonly key: string; /** The `groupBy` field this level groups on. */ readonly field: string; /** The shared field value for this group. */ readonly value: unknown; /** Display label for the header (the stringified value). */ readonly label: string; /** 0-based nesting depth. */ readonly depth: number; /** Number of leaf rows under this group. */ readonly count: number; /** The leaf rows under this group (post-filter/sort) — used for aggregation. */ readonly leaves: ReadonlyArray; /** Per-column aggregates computed over {@link leaves}. */ readonly aggregates: AggregationResults; } /** Returns the group metadata if `row` is a synthesized group header, else `undefined`. */ export declare function getGroupMeta(row: T): GroupRowMeta | undefined; /** * Enterprise feature: row grouping. Groups the post-filter/post-sort rows by one * or more column keys (derived grouping, distinct from declared tree data) and * injects expandable, full-width group-header rows showing the group value, leaf * count, and per-group aggregates. * * Wired through the core seam: it implements {@link RowTransformer} (to inject * the header rows into the rendered `dataView`) and {@link RowPresenter} (to * render those headers full-width). Aggregates reuse {@link computeAggregations} * over each group's filtered leaves. */ export declare class GroupingController implements ReactiveController, RowTransformer, RowPresenter { #private; private host; /** Ordered column keys to group by. Empty = grouping off (pass-through). */ groupBy: string[]; /** Default expansion: `true` (all), `false` (none), or a depth threshold. */ defaultExpanded: boolean | number; /** Aggregations computed per group over its leaf rows. */ aggregations: AggregationConfig; constructor(host: GridHost); hostConnected(): void; processRows(rows: ReadonlyArray): T[]; presentRow(row: T, _ctx: RowPresenterContext): PresentedRow | null; /** Whether the group identified by `key` (at `depth`) is currently expanded. */ isExpanded(key: string, depth: number): boolean; toggleGroup(key: string): void; expandGroup(key: string): void; collapseGroup(key: string): void; /** Expand/collapse a single group, firing cancellable `groupExpanding`. */ setGroupExpanded(key: string, expanded: boolean): void; expandAllGroups(): void; collapseAllGroups(): void; /** The group headers built in the most recent pipeline pass. */ getGroups(): GroupRowMeta[]; /** * The explicit per-group collapse overrides (group key → expanded), for state * serialization. Groups using the {@link defaultExpanded} fallback are absent. */ getExpandOverrides(): Record; /** * Restores per-group collapse overrides from a snapshot, replacing any current * ones. Silent: emits no `groupExpanding` / `groupExpanded`; re-runs the * pipeline so the next pass honors them. */ restoreExpandOverrides(overrides: Record): void; } /** Feature module registered on the enterprise grid. */ export declare const groupingModule: GridFeatureModule;