import "./matrix.css"; import { type ReactNode } from "react"; import type * as React from "react"; import { useRender } from "@base-ui/react/use-render"; import { type ColorName } from "./colors"; import { type MatrixAxisItem, type MatrixCellRef, type MatrixHeatScale } from "./matrix_totals"; import { type StyleProps } from "./style_props"; type Display = "number" | "heat" | "both"; export interface MatrixProps extends StyleProps { /** Row dimension (e.g. one shipping line per row). The consumer pre-sorts. */ rows: MatrixAxisItem[]; /** Column dimension (e.g. container size). Few, fixed — they share the width. */ cols: MatrixAxisItem[]; /** The cell value at an intersection. Pure — keep it a Map lookup, not a scan. */ value: (row: string, col: string) => number; /** The inspected cell. Press the same cell again to clear. */ selected?: MatrixCellRef | null; /** Omit for an informational matrix (no drill-down). */ onSelectCell?: (cell: MatrixCellRef | null) => void; /** Heat hue. Intensity is alpha within it; zero cells go neutral. Default blue. */ heatColor?: ColorName; /** * How a value becomes ink. `rank` spends the band on the cells' ORDER, * `linear` on their share of the largest cell. Default: `rank` behind numbers, * `linear` for a pure heatmap, where the colour is the only statement of * magnitude. */ heatScale?: MatrixHeatScale; formatValue?: (n: number) => string; /** Width of the leading row-label column. Default 140 (room for long names). */ rowLabelWidth?: number; children: ReactNode; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** * A two-dimensional cross-tab — the pivot of one dimension against another * ("how many of each line × size?"). Band-compound: the root owns the data, * the heat scale, the totals and the cell-selection; you compose the opt-in * bands — `MatrixHeader`, `MatrixGrid`, `MatrixTotals`, `MatrixLegend`. * Pressing a cell selects it for the host to drill — every number is a door. */ export declare function Matrix({ rows, cols, value, selected, onSelectCell, heatColor, heatScale, formatValue: formatValueProp, rowLabelWidth, children, testID, render, ref, ...props }: MatrixProps): React.JSX.Element; export interface MatrixHeaderProps extends StyleProps { /** Top-left corner label — name the two axes, e.g. "Line \ Size". */ corner?: ReactNode; /** Header for the trailing total column (only shown when `MatrixTotals` is present). */ totalLabel?: string; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** The axis labels and the corner that names both axes. */ export declare function MatrixHeader({ corner, totalLabel, testID, render, ref, ...props }: MatrixHeaderProps): React.ReactElement>; export interface MatrixGridProps extends StyleProps { /** What each cell shows. `both` = a heat wash behind the number. Default `both`. */ display?: Display; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** The cells — a number, a heat wash, or both. Every number is a door. */ declare function MatrixGridBand({ display, testID, render, ref, ...props }: MatrixGridProps): React.ReactElement>; export interface MatrixTotalsProps extends StyleProps { /** The row label for the totals band, e.g. "Total". */ label?: string; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** The column totals and the grand total, set off by their own rule. */ declare function MatrixTotalsBand({ label, testID, render, ref, ...props }: MatrixTotalsProps): React.ReactElement>; /** The band the root detects to decide whether a total column exists at all. */ export declare const MatrixTotals: typeof MatrixTotalsBand & { isMatrixTotals: true; }; /** The band the root detects to learn which `display` its heat band is for. */ export declare const MatrixGrid: typeof MatrixGridBand & { isMatrixGrid: true; }; export interface MatrixLegendProps extends StyleProps { lessLabel?: string; moreLabel?: string; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } /** The less → more scale the heat wash is read against. */ export declare function MatrixLegend({ lessLabel, moreLabel, testID, render, ref, ...props }: MatrixLegendProps): React.ReactElement> | null; export {};