API reference: @salmonui/data-grid/engine
DataGridModuleinterface
import type { DataGridModule } from '@salmonui/data-grid/engine';Also exported from @salmonui/data-grid.
interface DataGridModule<Row = unknown, State = unknown, Command extends DataGridCommand = DataGridCommand, Name extends string = string, Methods extends ModuleMethods<Row> = {}> {
readonly name: Name;
readonly dependencies?: readonly string[];
readonly inSnapshot?: boolean;
readonly commands: readonly Command['type'][];
initialState(options: DataGridOptions<Row>): State;
reduce?(state: State, command: Command, ctx: ModuleContext<Row>): State | CommandRejection;
extendColumns?(columns: readonly CompiledColumn<Row>[], ctx: ModuleContext<Row>): readonly CompiledColumn<Row>[];
extendQuery?(query: DataQuery, state: State): DataQuery;
readonly pipeline?: readonly PipelineStage<Row, State>[];
readonly selectors?: Readonly<Record<string, (snapshot: DataGridSnapshot<Row>) => unknown>>;
readonly methods?: Methods;
notify?(previous: State, next: State, ctx: ModuleContext<Row>): NotificationScope;
hiddenColumns?(state: State): readonly ColumnId[];
interceptRead?(query: DataQuery, state: State, ctx: ModuleContext<Row>): boolean;
onQueryChange?(previous: DataQuery, next: DataQuery, ctx: ModuleContext<Row>): void;
onConnect?(ctx: ModuleContext<Row>): void;
onSourceEvent?(event: DataSourceEvent<Row>, state: State, ctx: ModuleContext<Row>): boolean;
dispose?(): void;
}
| Name | Signature | Description |
|---|---|---|
name | readonly name: Name; | |
dependenciesoptional | readonly dependencies?: readonly string[]; | Validated at engine creation. |
inSnapshotoptional | readonly inSnapshot?: boolean; | When true (default) the slice lives in |
commands | readonly commands: readonly Command['type'][]; | Declared, validated, serializable. Every type must start with |
initialState | initialState(options: DataGridOptions<Row>): State; | |
reduceoptional | reduce?(state: State, command: Command, ctx: ModuleContext<Row>): State | CommandRejection; | |
extendColumnsoptional | extendColumns?(columns: readonly CompiledColumn<Row>[], ctx: ModuleContext<Row>): readonly CompiledColumn<Row>[]; | |
extendQueryoptional | extendQuery?(query: DataQuery, state: State): DataQuery; | |
pipelineoptional | readonly pipeline?: readonly PipelineStage<Row, State>[]; | |
selectorsoptional | readonly selectors?: Readonly<Record<string, (snapshot: DataGridSnapshot<Row>) => unknown>>; | |
methodsoptional | readonly methods?: Methods; | Reads that need more than the snapshot (facets, pager totals). Must not change state; names may not collide with command actions. |
notifyoptional | notify?(previous: State, next: State, ctx: ModuleContext<Row>): NotificationScope; | |
hiddenColumnsoptional | hiddenColumns?(state: State): readonly ColumnId[]; | Leaf columns this module hides from the visible column set (grouped columns with |
interceptReadoptional | interceptRead?(query: DataQuery, state: State, ctx: ModuleContext<Row>): boolean; | Remote sources only: return true to serve the main read of |
onQueryChangeoptional | onQueryChange?(previous: DataQuery, next: DataQuery, ctx: ModuleContext<Row>): void; | Called after the effective query changed (sort, filter, search, page,
group). Runs inside the dispatch of the command that changed it; may
dispatch commands through |
onConnectoptional | onConnect?(ctx: ModuleContext<Row>): void; |
|
onSourceEventoptional | onSourceEvent?(event: DataSourceEvent<Row>, state: State, ctx: ModuleContext<Row>): boolean; | A data source event (patch or reset). Return true to consume it: the engine then leaves its source rows unchanged (infinite scroll applies write echoes to the blocks it owns). |
disposeoptional | dispose?(): void; |