@linzjs/step-ag-grid
Version:
[](https://github.com/semantic-release/semantic-release) > Reusable [ag-grid](https://www.ag-grid.com/) component for LINZ / Toitū te whenua.
41 lines (36 loc) • 1.88 kB
text/typescript
import { ColDef, EditableCallback, ICellRendererParams, ValueFormatterFunc, ValueGetterFunc } from 'ag-grid-community';
import { ReactElement } from 'react';
export const agGridSelectRowColId = 'ag-Grid-SelectionColumn';
export interface GridBaseRow {
id: string | number;
}
export interface GridOnRowDragEndProps<TData extends GridBaseRow> {
/** The row the user physically grabbed by its drag handle. */
movedRow: TData;
/** All rows being moved, ordered by display index. Single-element array when dragging an unselected row. */
movedRows: TData[];
targetRow: TData;
/** -1 = dropped above target, 1 = dropped below target. */
direction: -1 | 1;
}
// This is so that typescript retains the row type to pass to the GridCells
export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
editable?: boolean | EditableCallback<TData, ValueType>;
/** When true, this column's editable state ignores the grid-level `readOnly` prop. */
ignoreGridReadOnly?: boolean;
valueGetter?: string | ValueGetterFunc<TData, ValueType>;
valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
cellRenderer?:
| ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined)
| string;
cellRendererParams?: {
rightHoverElement?: ReactElement;
originalCellRenderer?: any;
editAction?: (selectedRows: TData[]) => void;
shortcutKeys?: Record<string, () => void>;
error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
};
editor?: (editorProps: any) => ReactElement;
}