Skip to content

Interaction configuration and presets

View as Markdown

Choose the interaction model before customizing individual cells. The normalized configuration is immutable for the lifetime of the runtime.

cell-grid uses a cell cursor. Arrow keys move between cells and Shift+Arrow can extend a rectangular cell range. Editing is available in this mode.

row-list uses a row cursor. Arrow keys move between selectable rows and may extend row selection. It has no active cell or cell range.

type GridInteractionConfig =
CellGridInteractionConfig | RowListInteractionConfig;
type CellGridInteractionConfig = {
readonly mode: "cell-grid";
readonly activeCell: {
readonly kind: "enabled";
readonly keyboard: ActiveCellKeyboardConfig;
};
readonly selectedCells:
{ readonly kind: "none" } | { readonly kind: "range" };
readonly activeRow:
| { readonly kind: "none" }
| {
readonly kind: "from-active-cell";
readonly activation?: RowActivationConfig;
};
readonly selectedRows: SelectedRowsConfig;
};
type RowListInteractionConfig = {
readonly mode: "row-list";
readonly activeCell: { readonly kind: "none" };
readonly selectedCells: { readonly kind: "none" };
readonly activeRow: {
readonly kind: "from-row-cursor";
readonly keyboard: ActiveRowKeyboardConfig;
readonly activation?: RowActivationConfig;
};
readonly selectedRows: SelectedRowsConfig;
};

Pass the configuration during construction:

const runtime = createGridRuntime({
schema,
dataSource,
interaction: CELL_GRID_WITH_INDEPENDENT_ROW_SELECTION,
});

runtime.interaction contains the normalized immutable configuration.

The exported presets are ordinary GridInteractionConfig values:

PresetModeCell selectionActive rowSelected rows
CELL_EDITING_GRIDcell-gridrangenonenone
CELL_EDITING_NO_SELECTION_GRIDcell-gridnonenonenone
CELL_GRID_WITH_ACTIVE_ROWcell-gridrangeactive cellnone
CELL_GRID_WITH_INDEPENDENT_ROW_SELECTIONcell-gridrangeactive cellindependent multi
CELL_PRIMARY_WITH_SIDE_PANEL_ROWcell-gridrangeactive cellfollows active row
CELL_PRIMARY_WITH_SELECTED_SIDE_PANEL_ROWcell-gridrangeactive cellindependent single
ROW_PRIMARY_MASTER_DETAILrow-listnonerow cursorfollows active row
ROW_PRIMARY_MASTER_DETAIL_WITH_ACTIVATIONrow-listnonerow cursor; Enter and double-click activatefollows active row
ROW_MULTISELECT_LISTrow-listnonerow cursorindependent multi

Use satisfies GridInteractionConfig for custom configurations:

const interaction = {
mode: "row-list",
activeCell: { kind: "none" },
selectedCells: { kind: "none" },
activeRow: {
kind: "from-row-cursor",
keyboard: {
arrows: "move-active-row",
shiftArrows: "extend-selected-rows",
expansion: "left-right-enter",
},
},
selectedRows: {
kind: "enabled",
mode: "range",
sync: { kind: "independent" },
keyboard: { space: "toggle-active-row" },
},
} satisfies GridInteractionConfig;