import "./state_matrix.css"; import type * as React from "react"; import { type ReactNode } from "react"; import { useRender } from "@base-ui/react/use-render"; import { type ColorName } from "./color_tokens"; import { type OptionMark } from "./status"; import { type StyleProps } from "./style_props"; export interface StateMatrixState { key: string; label: string; /** The cell's wash and the mark's colour. */ color: ColorName; /** The option's own mark in the dot's place, as `Status` draws it, so cell and legend read one kind by one * shape. */ mark?: OptionMark; } /** One row a cell stands for — a trip, a shift, a paper — by its state. */ export interface StateMatrixEntry { /** Handed back by `onPressCell` when it is pressed: alone in its cell, or chosen from the list a cell of * several opens. */ key: string; state: string; /** Its state's words first, then at most one more fact: what a worded cell says of its first entry, and the * list a cell of several opens of each. Absent, the state's label. */ words?: readonly string[]; } export interface StateMatrixColumn { key: string; /** Shown once in the header: a day's number, ringed on today — or words (a paper's name, where the columns * are kinds rather than days), which widen the column to their measure and wrap to a second line past its * cap rather than clip. */ label: string; caption?: string; /** Today: its label ringed as the calendar rings it, with `aria-current`. */ current?: boolean; /** A position read less, such as a weekend or a closed day. Its heading takes the quiet ink. */ quiet?: boolean; } export interface StateMatrixCell { /** What the cell stands for, a mark each in its state's colour, side by side: the state latest in `states` * first — the cell's ground — then `MARKS_SHOWN` at most and "+N". Absent or empty, the cell is a blank: * nothing was due. Under `onAddCell`, it is the press that adds one. */ entries?: readonly StateMatrixEntry[]; /** The datum under `mark="intensity"`. */ value?: number; /** Only a pressable cell holds a button; the rest are read, not pressed. */ pressable?: boolean; /** The cell the host has open, announced as `aria-pressed`. */ selected?: boolean; /** The row, the column and the value — each entry's state, where it holds several — in words. */ name: string; } export type StateMatrixRow = { key: string; label: ReactNode; /** A picture or a face, at the lead rung of a register row. */ leading?: ReactNode; total?: string; /** In column order, or with no axis the row's whole pile. */ cells: (StateMatrixCell | undefined)[]; } & ({ /** The row's name opens what it names — a register row's door, named for where it goes. */ onPress: () => void; accessibilityLabel: string; } | { onPress?: never; accessibilityLabel?: never; }); /** The window the columns show, stepped by the host, drawn as the calendar steps its own. */ export interface StateMatrixPeriod { title: string; onPrevious: () => void; onNext: () => void; onToday: () => void; /** The sizes the window is read at (a week, a month), switched after the title; fewer than two draw none. */ sizes?: readonly { value: string; label: string; }[]; /** The size in view, one of `sizes`' values. */ size?: string; onSize?: (value: string) => void; } export interface StateMatrixLabels { total: string; less: string; more: string; previous: string; next: string; today: string; /** The size switch's name. */ period: string; } interface StateMatrixBase extends StyleProps { rows: StateMatrixRow[]; /** `dated` (default): columns across the top, row names pinned left — a month, a rota. `none`: the * wallboard, cells wrapping as a dense field scanned for the red one. */ axis?: "dated" | "none"; /** Required by `dated`. */ columns?: StateMatrixColumn[]; /** A pressable cell pressed, with the entry pressed: its one, or the one chosen from the list a cell of * several opens; a density cell hands none. */ onPressCell?: (rowKey: string, colKey: string, entryKey: string | undefined) => void; /** Stepped back and forth above the grid. */ period?: StateMatrixPeriod; /** `mark` (default): a cell is its state's mark — a month read at a glance. `words`: every column is wide * enough to say a cell's `words` — a week read for who does what where. */ cells?: "mark" | "words"; rowLabelWidth?: number; labels?: Partial; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } interface StateMatrixGlyphProps extends StateMatrixBase { mark?: "glyph"; /** The legend, calmest first: a cell holding several is read by — grounded by and led by — the latest of * theirs. */ states: StateMatrixState[]; /** The state drilled into from the legend, its entry pressed; the host narrows what the matrix holds. */ selectedState?: string | null; /** Press again to clear; omit for an informational legend. */ onSelectState?: (key: string | null) => void; /** On the dated axis, a blank cell (one with a `name` and no `entries`) becomes the press that adds one * there. Its "+" shows on hover and keyboard focus only. Omit where the reader cannot write. */ onAddCell?: (rowKey: string, colKey: string) => void; color?: never; formatValue?: never; } interface StateMatrixIntensityProps extends StateMatrixBase { mark: "intensity"; /** Intensity mixes within this hue; zero goes neutral so a gap reads as quiet. Defaults to the sheet's * blue. */ color?: string; formatValue?: (n: number) => string; states?: never; selectedState?: never; onSelectState?: never; onAddCell?: never; } export type StateMatrixProps = StateMatrixGlyphProps | StateMatrixIntensityProps; /** A categorical cross-tab — subjects by positions, each cell a state (attendance, a fleet's month, a * rota). `axis` asks whether positions are named (`dated` vs the `none` wallboard); `mark` what a cell * holds (a `glyph` of `states`, or `intensity`). Not `Matrix` (a state is no number; blank means nothing * was due) nor `Timetable` (undated pattern, per-mark editors). One scroll container with both edges * sticky; a WAI-ARIA grid the arrow keys walk; columns share the slack, a cell's width being a floor. */ export declare function StateMatrix(props: StateMatrixProps): React.ReactElement>; export {};