import { o as ColumnDef } from "./types-Cqk1_BXq.js"; import { a as Aggregator, n as AggregateName } from "./aggregate-C1nNljQr.js"; import { ReactNode } from "react"; //#region src/pivot/pivotKeys.d.ts /** The key of the grand-total line, distinct from every real row path. */ declare const PIVOT_GRAND_TOTAL_KEY = "\u0002grand"; //#endregion //#region src/pivot/pivotModel.d.ts /** The label a dimension value gets when the row has none. */ declare const PIVOT_BLANK = "\u2014"; /** One computed value per cell. */ interface PivotMeasure { /** The column key whose values are aggregated. */ key: string; /** A built-in aggregate name, or your own function. */ agg: AggregateName | Aggregator; /** Header caption. Defaults to the column key. */ label?: string; } /** What to pivot, and how. */ interface PivotConfig { /** Dimensions down the side, outermost first. Empty pivots to one line. */ rows: readonly string[]; /** Dimensions across the top, outermost first. Empty gives measure columns. */ columns: readonly string[]; /** What every cell computes. At least one, or there is nothing to show. */ measures: readonly PivotMeasure[]; /** A totals line for every level above the innermost. Defaults to `true`. */ subtotals?: boolean; /** A grand-total line across everything. Defaults to `true`. */ grandTotals?: boolean; } /** A node in the column header tree. */ interface PivotColumnNode { /** The dimension value this node stands for. */ label: string; /** Its full path from the outermost dimension. */ path: readonly string[]; /** How many leaf columns sit under it — the header cell's `colSpan`. */ span: number; /** Nested dimension values, or empty at the innermost level. */ children: readonly PivotColumnNode[]; } /** One rendered column: a column path plus the measure shown in it. */ interface PivotColumnLeaf { /** Stable key for React and for column-level state. */ key: string; /** The column-dimension values, outermost first. Empty without any. */ path: readonly string[]; /** The measure this column shows. */ measure: PivotMeasure; /** Whether this is the grand-total column rather than a real path. */ total: boolean; } /** What a line in the body is. */ type PivotRowKind = "leaf" | "subtotal" | "grandTotal"; /** One rendered line. */ interface PivotRow { /** Stable id — also the collapse key for a `subtotal` line. */ key: string; /** The row-dimension values, outermost first. */ path: readonly string[]; /** Nesting level, 0 for the outermost. */ depth: number; /** Whether this line is a data line, a subtotal, or the grand total. */ kind: PivotRowKind; /** The dimension value this line is labelled with. */ label: string; /** One value per entry of {@link PivotResult.columnLeaves}, in order. */ cells: readonly ReactNode[]; /** How many source rows it covers — for "12 rows" affordances. */ count: number; } /** The whole pivot, ready to render. */ interface PivotResult { /** The column header tree; empty when there are no column dimensions. */ columnTree: readonly PivotColumnNode[]; /** The rendered columns, left to right — the order every row's cells use. */ columnLeaves: readonly PivotColumnLeaf[]; /** Every line of the body, in render order. */ rows: readonly PivotRow[]; /** Depth of the row-header area — how many dimensions are down the side. */ rowDepth: number; } /** Options for {@link pivot}. */ interface PivotOptions { /** * Columns, so dimension and measure values resolve through `sortValue` * exactly as sorting and grouping do. */ columns?: readonly ColumnDef[]; /** Format a computed cell. Receives the raw result and the measure. */ format?: (value: ReactNode, measure: PivotMeasure) => ReactNode; /** * Subtotal keys the user has collapsed. A collapsed line keeps its own * totals and drops everything beneath it. */ collapsed?: ReadonlySet; } /** * Pivot rows into a table. * * @typeParam TRow - The row type. * @param rows - The rows to pivot. Filtering and searching happen upstream. * @param config - Which dimensions go where, and what each cell computes. * @param options - Columns for value resolution, formatting, collapse state. * @returns The column tree, the rendered columns and every body line. */ declare function pivot(rows: readonly TRow[], config: PivotConfig, options?: PivotOptions): PivotResult; //#endregion //#region src/pivot/pivotConfigModel.d.ts /** Where a field can sit. */ type PivotZone = "rows" | "columns" | "measures"; /** The zones a field can be moved between, in panel order. */ declare const PIVOT_ZONES: readonly PivotZone[]; /** A field the user can put on an axis. */ interface PivotField { /** The column key. */ key: string; /** What to call it in the panel. */ label: string; } /** An empty configuration — nothing on any axis. */ declare const EMPTY_PIVOT_CONFIG: PivotConfig; /** The fields not yet used on either axis. */ declare function availableFields(fields: readonly PivotField[], config: PivotConfig): PivotField[]; /** * Put a field on an axis. * * @param config - The configuration to change. * @param key - The column key to place. * @param zone - Where it should go. * @param index - Position within that zone. Past the end appends. * @returns A new configuration. */ declare function assignField(config: PivotConfig, key: string, zone: PivotZone, index?: number): PivotConfig; /** * Take a field off an axis. * * @param config - The configuration to change. * @param zone - Which axis to remove from. * @param index - The position to remove. * @returns A new configuration. */ declare function removeField(config: PivotConfig, zone: PivotZone, index: number): PivotConfig; /** * Move a field one step within its zone. * * The keyboard counterpart of dragging. A step past either end is a no-op * rather than a wrap: wrapping makes the last press of a held key undo the * whole journey. * * @param config - The configuration to change. * @param zone - Which axis the field is on. * @param index - Its current position. * @param delta - `-1` to move it out one level, `1` to move it in. * @returns A new configuration. */ declare function moveField(config: PivotConfig, zone: PivotZone, index: number, delta: -1 | 1): PivotConfig; /** * Change what a measure computes. * * @param config - The configuration to change. * @param index - Which measure. * @param agg - The new aggregation. * @returns A new configuration. */ declare function setMeasureAgg(config: PivotConfig, index: number, agg: AggregateName): PivotConfig; /** * Whether a configuration can actually be rendered. * * A pivot with no measure has nothing to put in its cells, which is a * half-built configuration rather than an error — the panel shows it and the * table waits. */ declare function isPivotReady(config: PivotConfig): boolean; /** The display label for one measure, for the panel and the column header. */ declare function measureLabel(measure: PivotMeasure, fields: readonly PivotField[]): string; //#endregion export { PIVOT_GRAND_TOTAL_KEY as S, PivotOptions as _, assignField as a, PivotRowKind as b, measureLabel as c, setMeasureAgg as d, PIVOT_BLANK as f, PivotMeasure as g, PivotConfig as h, PivotZone as i, moveField as l, PivotColumnNode as m, PIVOT_ZONES as n, availableFields as o, PivotColumnLeaf as p, PivotField as r, isPivotReady as s, EMPTY_PIVOT_CONFIG as t, removeField as u, PivotResult as v, pivot as x, PivotRow as y }; //# sourceMappingURL=pivotConfigModel-B6dLmZtw.d.ts.map