import * as React from 'react'; import { GridCellMode } from '../gridCell'; import { GridRowId, GridRowModel, GridTreeNode, GridTreeNodeWithRender, GridValidRowModel } from '../gridRows'; import type { GridStateColDef } from '../colDef/gridColDef'; import { GridEditCellProps } from '../gridEditRowModel'; import { GridApiCommunity } from '../api/gridApiCommunity'; /** * Object passed as parameter in the column [[GridColDef]] cell renderer. */ export interface GridCellParams { /** * The grid row id. */ id: GridRowId; /** * The column field of the cell that triggered the event. */ field: string; /** * The cell value. * If the column has `valueGetter`, use `params.row` to directly access the fields. */ value?: V | undefined; /** * The cell value formatted with the column valueFormatter. */ formattedValue?: F | undefined; /** * The row model of the row that the current cell belongs to. */ row: GridRowModel; /** * The node of the row that the current cell belongs to. */ rowNode: N; /** * The column of the row that the current cell belongs to. */ colDef: GridStateColDef; /** * If true, the cell is editable. */ isEditable?: boolean; /** * The mode of the cell. */ cellMode: GridCellMode; /** * If true, the cell is the active element. */ hasFocus: boolean; /** * the tabIndex value. */ tabIndex: 0 | -1; } export interface FocusElement { focus(): void; } /** * GridCellParams containing api. */ export interface GridRenderCellParams extends GridCellParams { /** * GridApi that let you manipulate the grid. */ api: GridApiCommunity; /** * A ref allowing to set imperative focus. * It can be passed to the element that should receive focus. * @ignore - do not document. */ focusElementRef?: React.Ref; } /** * GridEditCellProps containing api. */ export interface GridRenderEditCellParams extends GridCellParams, GridEditCellProps { /** * GridApi that let you manipulate the grid. */ api: GridApiCommunity; } /** * Parameters passed to `colDef.valueGetter`. */ export interface GridValueGetterParams extends Omit, 'formattedValue' | 'isEditable'> { /** * GridApi that let you manipulate the grid. */ api: GridApiCommunity; /** * The default value for the cell that the `valueGetter` is overriding. */ value: GridCellParams['value']; } /** * Object passed as parameter in the column [[GridColDef]] value setter callback. */ export interface GridValueSetterParams { /** * The new cell value. */ value: V; /** * The row that is being edited. */ row: R; } /** * Object passed as parameter in the column [[GridColDef]] value formatter callback. */ export interface GridValueFormatterParams { /** * The grid row id. * It is not available when the value formatter is called by the filter panel. */ id?: GridRowId; /** * The column field of the cell that triggered the event. */ field: string; /** * The cell value, if the column has valueGetter it is the value returned by it. */ value: V; /** * GridApi that let you manipulate the grid. */ api: GridApiCommunity; } /** * Object passed as parameter in the column [[GridColDef]] edit cell props change callback. */ export interface GridPreProcessEditCellProps { /** * The grid row id. */ id: GridRowId; /** * The row that is being edited. */ row: GridRowModel; /** * The edit cell props. */ props: GridEditCellProps; /** * Whether the new value is different from the stored value or not. */ hasChanged?: boolean; /** * Object containing the props of the other fields. * Only available for row editing and when using the new editing API. */ otherFieldsProps?: Record>; }