import type { UiTableHeaderCell } from './table-header-cell.js'; import type { UiTableRow } from './table-row.js'; /** Controls a cell may hold (selection, expand, author content); in a grid they leave the Tab order and the cell activates them. */ export declare const CELL_CONTROLS = "button, a[href], input, select, textarea, [tabindex], ui-checkbox, ui-radio, ui-button, ui-link"; /** * Takes a control out of the Tab order, including what it delegates focus to: a negative tabindex on a * shadow host (ui-checkbox, ui-radio) leaves the native control inside it tabbable. */ export declare function removeFromTabOrder(control: HTMLElement): void; /** What the grid reads from its ``. */ export interface GridSource { /** The body rows on screen (not left out by the search, on this page). */ shownRows(): UiTableRow[]; /** The column headers, in order. */ columns(): UiTableHeaderCell[]; /** "Press Enter to edit". */ editHint(): string; } /** * WAI-ARIA APG editable data grid for `` (Carbon's DataTable has no inline editing, so this follows the * APG pattern with Carbon styling, as `ui-data-table` did). Active while a header has `editable`. * * - The table becomes `role=grid` with one Tab stop among the body cells (roving tabindex), the chevron and * checkbox cells included; arrow keys, Home / End and Ctrl+Home / End move it. Controls inside cells leave * the Tab order: Enter or Space on their cell activates them. * - On an editable cell (a pencil after the value on hover and focus), Enter, F2, a double click, the pencil or * typing a character opens the editor; Enter saves, Escape cancels, Tab / Shift+Tab save and edit the next / * previous editable cell, leaving the cell saves. The header's `validate(value, cell)` returning a message keeps * the editor open. * - Saving fires a cancelable `ui-table-cell-edit` from the cell, then writes the value into the cell (its text, * a select column's label; `sort-value` follows, `csv-value` goes). Canceled, the cell stays as it was: write * it yourself (a framework that renders the rows). */ export declare class TableGrid { private readonly table; private readonly source; private active; /** The cell holding tabindex 0. */ private stop; /** The open editor's cell and the value it started from. */ private editing; /** Cells this grid gave a tabindex and role (handed back when the grid ends). */ private readonly touched; /** Controls already taken out of the Tab order (each once, not on every sync). */ private readonly outOfTabOrder; private enabled; constructor(table: HTMLElement, source: GridSource); get on(): boolean; /** The body cell that takes Tab (null when the grid is off). */ get stopCell(): HTMLElement | null; /** After the rows, columns or pages changed: roles, the Tab stop, the controls out of the Tab order. */ sync(): void; /** Every body cell out of the Tab order (but the stop), grid roles, the edit hint, controls out of the Tab order. */ private syncCells; /** Once the rows rendered their chevron and checkbox cells: the stop takes tabindex 0. */ private settle; /** The grid ended (no header is editable): the cells go back to a table's. */ private release; private setStop; /** The grid cell an event happened in: its row (on screen) and its place among the row's grid cells. */ private cellOf; private moveTo; private headerOf; /** Arrow keys and friends on a focused cell; Enter / F2 / a character edit, Enter / Space activate a control. */ readonly onKeydown: (e: Event) => void; /** Whatever focuses a body cell (a click, a script, a screen reader) makes it the Tab stop. */ readonly onFocusIn: (event: Event) => void; readonly onClick: (event: Event) => void; readonly onDoubleClick: (event: Event) => void; /** Leaving the editor saves (an invalid value keeps it open). */ readonly onFocusOut: (event: Event) => void; private editorOf; /** The cell's value as the editor starts it: its `sort-value`, a select's value by label, else its text. */ private valueOf; private start; private stopEditing; /** Validate, ask with `ui-table-cell-edit`, write the value into the cell; false while the value is invalid. */ private commit; private write; private onEditorKeydown; /** The next / previous editable cell on screen, in reading order. */ private nextEditable; }