import { o as ColumnDef, x as TableLabels } from "./types-Cqk1_BXq.cjs"; import { S as PIVOT_GRAND_TOTAL_KEY, _ as PivotOptions, a as assignField, b as PivotRowKind, c as measureLabel, d as setMeasureAgg, f as PIVOT_BLANK, g as PivotMeasure, h as PivotConfig, i as PivotZone, l as moveField, m as PivotColumnNode, n as PIVOT_ZONES, o as availableFields, p as PivotColumnLeaf, r as PivotField, s as isPivotReady, t as EMPTY_PIVOT_CONFIG, u as removeField, v as PivotResult, x as pivot, y as PivotRow } from "./pivotConfigModel-B6393SaL.cjs"; import { t as UrlStateAdapter } from "./adapter-BD3RX3cl.cjs"; import { ReactNode } from "react"; //#region src/pivot/pivotTableModel.d.ts /** * The key of the row-header column — the one down the side, holding each * line's label. Stable, so a host can style or address it. */ declare const PIVOT_ROW_COLUMN_KEY = "pivot-row"; /** Options for {@link pivotTableModel}. */ interface PivotTableModelOptions { /** * The fields the pivot was configured from, for the measure captions — the * same list the configuration panel takes. Without it a measure column is * captioned from its key. */ fields?: readonly PivotField[]; /** * Localized labels. Only the pivot captions are read: the grand-total * column's group header, the grand-total footer's caption, and the * row-header column's own header when {@link rowHeader} is absent. */ labels?: TableLabels; /** * The row-header column's header — the cell in the corner. Defaults to the * localized "Rows"; pass the row dimensions' own captions to name them. */ rowHeader?: ReactNode; /** * One body line's row-header content. Defaults to the line's own label. This * is where a fold control belongs: the line's `kind` says whether it is * foldable and its `key` is the collapse key. * * The grand-total footer keeps its localized caption either way — there is * nothing to fold on a total, and a renderer that assumed a label would * leave the footer blank. */ renderRowHeader?: (row: PivotRow) => ReactNode; /** * Pixels of indent per nesting level in the row-header column, so a nested * pivot reads as nested. Defaults to 16; `0` turns it off. */ indent?: number; } /** A pivot as table props. Spread the parts a `DataTable` takes. */ interface PivotTableModel { /** The row-header column, then one column per entry of `columnLeaves`. */ columns: ColumnDef[]; /** Every line except the grand total, which is the footer instead. */ rows: readonly PivotRow[]; /** Row identity — the engine's own line key. */ rowKey: (row: PivotRow) => string; /** * The grand-total line as the table's footer row, or `undefined` when the * pivot has no grand total (`grandTotals: false`). */ summaryRow?: (rows: readonly PivotRow[]) => Partial>; } /** * Render a pivot with the table you already have. * * @param result - What `pivot` (or `serverPivotResult`) returned. * @param options - Captions, labels and the row-header renderer. * @returns Columns, rows, `rowKey` and the `summaryRow` for a `DataTable`. * * ```tsx * const result = pivot(rows, config, { collapsed }); * const model = pivotTableModel(result, { fields, labels }); * * ; * ``` */ declare function pivotTableModel(result: PivotResult, options?: PivotTableModelOptions): PivotTableModel; //#endregion //#region src/pivot/pivotUrlCodec.d.ts /** Everything the pivot parameter carries. */ interface PivotUrlState { /** What to pivot, and how. */ config: PivotConfig; /** * The keys of the folded subtotal lines — a `PivotRow.key`, which is what * `pivot`'s `collapsed` option matches against. */ collapsed: readonly string[]; } /** * Write the whole pivot state as a URL parameter value. * * @param state - The configuration, and which groups are folded. * @returns The parameter value, or `""` when there is nothing to say. */ declare function serializePivotState(state: PivotUrlState): string; /** * Read the whole pivot state back from a URL parameter value. * * Unknown segments are ignored rather than throwing: a URL is user input, * and a hand-edited one should degrade to a simpler pivot instead of an * error page. * * @param raw - The parameter value. * @returns The configuration it describes, and which groups are folded. */ declare function deserializePivotState(raw: string | null): PivotUrlState; /** * Write a configuration as a URL parameter value. * * @param config - The configuration to serialize. * @returns The parameter value, or `""` when there is nothing to say. */ declare function serializePivot(config: PivotConfig): string; /** * Read a configuration back from a URL parameter value. * * @param raw - The parameter value. * @returns The configuration it describes. */ declare function deserializePivot(raw: string | null): PivotConfig; //#endregion //#region src/pivot/pivotUrlState.d.ts /** What {@link usePivotUrlState} needs. */ interface UsePivotUrlStateOptions { urlAdapter?: UrlStateAdapter; urlSync?: boolean; urlKey?: string; /** The pivot before anyone has built one. Defaults to empty. */ defaultConfig?: PivotConfig; } /** The controlled state to hand the panel and the engine. */ interface UsePivotUrlStateResult { /** What to pivot, and how. Give it to the panel and to `pivot`. */ config: PivotConfig; /** Persist a new configuration. Wire to the panel's `onChange`. */ onConfigChange: (next: PivotConfig) => void; /** * The folded subtotal lines, by key — `pivot`'s `collapsed` option, so the * link and the rendering agree without the host holding a second copy. */ collapsed: ReadonlySet; /** Persist a new folded set. Wire to whatever folds a subtotal line. */ onCollapsedChange: (next: ReadonlySet) => void; } /** * Keep the pivot state in the URL. * * @param options - See {@link UsePivotUrlStateOptions}. * @returns The configuration, the folded set, and the setters for both. */ declare function usePivotUrlState(options?: UsePivotUrlStateOptions): UsePivotUrlStateResult; //#endregion //#region src/pivot/serverPivot.d.ts /** One line of a server-computed pivot. */ interface QueryPivotRow { /** * The row-dimension values, outermost first, as the server labelled them. * An empty path is the grand total. */ path: readonly string[]; /** * The computed values, in column-path order and within that in measure * order — the same order the table renders its columns. A missing entry is * an empty cell. */ cells: readonly unknown[]; /** * This line's values for the grand-total **column**, one per measure in * measure order. * * That column exists whenever the configuration asks for grand totals and * something splits the columns — the local engine's rule, so a table moving * from one engine to the other keeps the same columns. What core cannot do is * compute it: summing sums is not how an average or a minimum totals. So a * server that does not send this leaves the column empty, exactly as an * omitted cell is empty, and a configuration with `grandTotals: false` does * not ask for it at all. */ totals?: readonly unknown[]; /** How many source rows this line covers, when the server counts. */ count?: number; /** Whether this line totals the lines beneath it rather than being one. */ subtotal?: boolean; } /** A page of server-computed pivot results. */ interface QueryPivotPage { /** * The column-dimension paths, outermost value first, in the order the * server wants them shown. One entry per path, NOT per rendered column — * the measures multiply them here, the way they do locally. */ columns: readonly (readonly string[])[]; /** The body lines, in display order. */ rows: readonly QueryPivotRow[]; /** The grand-total line, when the server computed one. */ total?: QueryPivotRow; } /** What {@link serverPivotResult} needs. */ interface ServerPivotOptions { /** The configuration that was sent, for the measures and their order. */ config: PivotConfig; /** Format a computed cell, as the local engine's `format` does. */ format?: (value: ReactNode, measure: PivotConfig["measures"][number]) => ReactNode; } /** * Turn a server's answer into the result the adapters already render. * * @param page - What the server sent. * @param options - The configuration that was asked for, and formatting. * @returns The same `PivotResult` shape the local engine returns. */ declare function serverPivotResult(page: QueryPivotPage, { config, format }: ServerPivotOptions): PivotResult; //#endregion export { EMPTY_PIVOT_CONFIG, PIVOT_BLANK, PIVOT_GRAND_TOTAL_KEY, PIVOT_ROW_COLUMN_KEY, PIVOT_ZONES, type PivotColumnLeaf, type PivotColumnNode, type PivotConfig, type PivotField, type PivotMeasure, type PivotOptions, type PivotResult, type PivotRow, type PivotRowKind, type PivotTableModel, type PivotTableModelOptions, type PivotUrlState, type PivotZone, type QueryPivotPage, type QueryPivotRow, type ServerPivotOptions, type UsePivotUrlStateOptions, type UsePivotUrlStateResult, assignField, availableFields, deserializePivot, deserializePivotState, isPivotReady, measureLabel, moveField, pivot, pivotTableModel, removeField, serializePivot, serializePivotState, serverPivotResult, setMeasureAgg, usePivotUrlState }; //# sourceMappingURL=pivot.d.cts.map