import { type ReactNode } from 'react'; import { type HeatmapPrivacyScope, type HeatmapValueType } from './heatmap-format'; import { type HeatmapSelectionMode } from './heatmap-grid'; import { type HeatmapCellInfo, type HeatmapCellInput, type HeatmapCellKey, type HeatmapColumn, type HeatmapGetTotal, type HeatmapGroup, type HeatmapRow, type HeatmapSortRows } from './heatmap-model'; import { type HeatmapAggregate, type HeatmapScale } from './heatmap-scale'; import { HeatmapTooltip } from './heatmap-tooltip'; import { type HeatmapPalette } from './heatmap-variants'; export type { HeatmapCellData, HeatmapCellInfo, HeatmapCellInput, HeatmapCellKey, HeatmapCellStatus, HeatmapColumn, HeatmapGetTotal, HeatmapGroup, HeatmapRow, HeatmapSortRows, HeatmapTotalScope, } from './heatmap-model'; export type { HeatmapAggregate, HeatmapScale } from './heatmap-scale'; export type { HeatmapPalette } from './heatmap-variants'; export type { HeatmapPrivacyScope, HeatmapValueType } from './heatmap-format'; export type { HeatmapSelectionMode } from './heatmap-grid'; /** What `renderTooltip` is told besides the cell. */ export interface HeatmapTooltipContext { /** * True in privacy mode. The cell's labels are then already masked (and * its free-text `label` dropped), so text built from them is safe to show. */ privacyMode: boolean; } /** Which presentation is showing. */ export type HeatmapView = 'heatmap' | 'table'; /** What one cell reads back to an agent: structure and numbers, no labels. */ export interface HeatmapCellReading { value: number | null; count?: number; status: HeatmapCellInfo['status']; /** As `HeatmapCellInfo.step`: a value exactly on a diverging midpoint * reads step 5, though it is painted neutral grey. */ step: number | null; } /** * Curated handle for the agent adapter (see heatmap.agent.ts). Ids only, * never labels. Group ids are the public ones: a group's own id when it is * listed in `groups`, else `group-`. Every write throws on an id the * heatmap does not have, before it changes or announces anything. */ export interface HeatmapHandle { getSelection: () => HeatmapCellKey[]; getSelectionMode: () => HeatmapSelectionMode; selectCells: (cells: readonly HeatmapCellKey[]) => void; selectRange: (from: HeatmapCellKey, to: HeatmapCellKey) => void; clearSelection: () => void; readCell: (cell: HeatmapCellKey) => HeatmapCellReading | null; getView: () => HeatmapView; setView: (view: HeatmapView) => void; getSortRows: () => HeatmapSortRows; setSortRows: (sort: HeatmapSortRows) => void; /** Row ids in display order, every group expanded. */ getRowIds: () => string[]; /** Column ids in order. */ getColumnIds: () => (string | number)[]; /** Group ids in display order; empty unless `groupRows` is on. */ getGroupIds: () => string[]; getCollapsedGroups: () => string[]; setGroupCollapsed: (groupId: string, collapsed: boolean) => void; } export interface HeatmapProps { /** * Required. Names the grid for assistive technology and the table view. * Never masked, so it must not name a person. */ title: string; /** Rows, top to bottom. Keep the array stable (see Memoisation). */ rows: readonly HeatmapRow[]; /** Columns, in reading order. Keep the array stable. */ columns: readonly HeatmapColumn[]; /** * Returns a cell's data. Use this or `cells`. Keep it stable * (`useCallback`): an inline function rebuilds the matrix every render. */ getCell?: (row: HeatmapRow, column: HeatmapColumn, rowIndex: number, columnIndex: number) => HeatmapCellInput; /** The cells as a `[row][column]` matrix, in the order of `rows` and `columns`. */ cells?: readonly (readonly HeatmapCellInput[])[]; /** Visible labels for the group ids rows carry. Keep the array stable. */ groups?: readonly HeatmapGroup[]; /** How values map to colour steps. Default sequential with an auto domain. */ scale?: HeatmapScale; /** Colour palette. Default `diverging` for a diverging scale, else `primary`. */ palette?: HeatmapPalette; /** * `rate` for proportions between 0 and 1: formats as a percentage and * reads counts as "10 of 39". Default `number`. */ valueType?: HeatmapValueType; /** * Cells with a count below this render as "too few to show", hatched. * For a cell it is a display rule, not disclosure control: `read_cell`, * `onCellClick` and `onSelectionChange` still carry any value you pass. * To keep a value off the page, send `{ value: null, count }`: it still * renders as too few, and nothing can read a value the kit never had. * Totals follow small-number disclosure control: any total that, in any * combination with the other totals and cells, would pin down a hidden * cell, narrow it below the protection level (half its range, for a * rate), or determine a set of hidden cells with fewer than minCount * records, is withheld too, and carries no value anywhere. Every total * the data could show is audited, drawn or not. See `getTotal` and * heatmap.mdx. */ minCount?: number; /** * Supplies a total: a row's, a column's, a group's, a group header cell * or the grand total, as `scope.kind` says. Return a cell input (`null` * for no total), or `undefined` to let the kit work it out from the * cells. Needed when you withhold values (`value: null`): the kit cannot * add up a value it never had, so it withholds any total it would get * wrong. `minCount` and the disclosure audit apply to a supplied total * exactly as to a worked-out one, which must be the exact count-weighted * mean (or sum) of its cells. Asked for every row, every column and the * grand total, and, whenever rows carry a group, every group and group * header cell, drawn or not. Keep it stable (`useCallback`). */ getTotal?: HeatmapGetTotal; /** Formats a value. Default: Intl in the active locale. Keep it stable. */ valueFormatter?: (value: number) => string; /** Print the value inside each cell. */ showValues?: boolean; /** Built-in legend above the grid, or `false` to place `Heatmap.Legend` yourself. */ legend?: 'stepped' | 'continuous' | false; /** * A totals column at the row ends. A mean weights by count. Everything in * that column uses this method: each row's total, each group's and the * grand total in the corner. With `minCount`, a mean of plain numbers * (`valueType="number"`) is not audited for hidden cells: every such * average that holds one is withheld, so use `sum` for plain numbers. */ rowTotals?: HeatmapAggregate | false; /** * A totals row under the columns. A mean weights by count. A group * header's per-column totals use this method too (else `rowTotals`). * With `minCount`, a mean of plain numbers is withheld wherever it holds * a hidden cell, as for `rowTotals`: use `sum` for plain numbers. */ columnTotals?: HeatmapAggregate | false; /** * Row order (within each group). Controlled when set. In privacy mode * `label` keeps the given order: sorting by masked names would reveal * their order. A sort by total reads each row's total by the * `rowTotals` method (else the `columnTotals` one, else mean); a row * whose total is withheld sorts last. */ sortRows?: HeatmapSortRows; /** Initial row order when uncontrolled. Default `none`. */ defaultSortRows?: HeatmapSortRows; /** Called when the row order changes (agent `sort_rows`). */ onSortRowsChange?: (sort: HeatmapSortRows) => void; /** Group rows by `row.group`, each group collapsible with its totals. */ groupRows?: boolean; /** Group ids that start collapsed. */ defaultCollapsedGroups?: readonly string[]; /** How cells are selected. Default `none`. */ selection?: HeatmapSelectionMode; /** Selected cells. Controlled when set. */ selectedCells?: readonly HeatmapCellKey[]; /** Initially selected cells when uncontrolled. */ defaultSelectedCells?: readonly HeatmapCellKey[]; /** Called with every cell in the new selection. */ onSelectionChange?: (cells: HeatmapCellInfo[]) => void; /** Called when a cell is clicked, or activated with Enter or Space. */ onCellClick?: (cell: HeatmapCellInfo) => void; /** * Tooltip text for a cell. Plain text: the kit Tooltip is text-only. It * also describes the focused cell to screen readers (aria-describedby). * In privacy mode the cell arrives with its labels masked, its free-text * `label` dropped and `row.group` replaced by the public group id, and * the context says so. */ renderTooltip?: (cell: HeatmapCellInfo, context: HeatmapTooltipContext) => string; /** `compact` removes the gap between cells. Cells never shrink below the target size. */ density?: 'compact' | 'default'; /** Cell size. Every size keeps cells at least `--min-target-size`. */ size?: 'sm' | 'md' | 'lg'; /** Shows a skeleton while data loads. */ loading?: boolean; /** * Masks row labels (people, chairs, patients) in the grid, the tooltip, * the table view and the announcements, and drops free-text cell labels. * Columns and groups stay readable unless `privacyScope="all"`. `title` * and `rowsLabel` are never masked. */ privacyMode?: boolean; /** * What privacy mode masks: `rows` (default) or `all`, which masks column * and group labels too. */ privacyScope?: HeatmapPrivacyScope; /** * Names what the rows are ("Chair"): the corner header and the table's * first column. Never masked, so it must not name a person. */ rowsLabel?: string; /** Initial presentation. Default `heatmap`. */ defaultView?: HeatmapView; /** Called when the view switches between heatmap and table. */ onViewChange?: (view: HeatmapView) => void; /** Instance id: `data-component-id`, and the agent registry key. */ id?: string; className?: string; /** * Rendered inside the heatmap's context, after the grid (e.g. * `Heatmap.Legend`). Also while loading and when empty. */ children?: ReactNode; } /** * Heatmap: a grid of cells coloured by value on a token scale, for patterns * such as chair occupancy by hour or no-shows by weekday and hour. Keyboard, * screen reader and table view are built in; see heatmap.mdx. */ export declare const Heatmap: import("react").ForwardRefExoticComponent> & { Legend: import("react").ForwardRefExoticComponent>; Tooltip: typeof HeatmapTooltip; }; //# sourceMappingURL=heatmap.d.ts.map