import * as React from 'react'; import { XOR } from '../../utils'; import { TableProps, TableHeaderCellProps, TableRowColor, TablePaginationProps, TableSortDirection } from '../Table'; export interface DatagridColumn extends TableHeaderCellProps { /** * Unique identifier for each column */ field: string; /** * Header text for each column */ header: string; /** * Set to true if you want the column to be the header for each row * @default false */ isRowHeader?: boolean; } export interface DatagridRow { /** * Unique identifier for each row */ id: string | number; /** * The color scheme of the table row, giving contextual meaning to the content */ color?: TableRowColor; /** * If true, the select box will be disabled */ isSelectableDisabled?: boolean; /** * Used to allow each unique column field as a key with the row content as the value */ [key: string]: any; } export interface DatagridComponents { Pagination?: React.FunctionComponent; } export interface DatagridComponentsProps { pagination?: Partial>; } export interface BaseDatagridProps extends TableProps { /** * @children required */ children: React.ReactNode; /** * Column data to be displayed in the table header */ columns: DatagridColumn[]; /** * Custom components to replace internally used components with * @default { Pagination } */ components?: DatagridComponents; /** * Props to be passed to the default components used internally to build the datagrid * @default {} */ componentsProps?: DatagridComponentsProps; /** * Pass in false to turn off pagination * @default true */ hasPagination?: boolean; /** * Row data to be displayed in each row in the table */ rows: DatagridRow[]; /** * Function called when the checkbox in the table header is clicked on */ onHeaderSelect?: (event: React.ChangeEvent) => void; /** * Function called when the checkbox in each table row is clicked on */ onRowSelect?: (id: string | number, event: React.ChangeEvent) => void; /** * Function called when the rows selected in the table changes */ onSelectedRowsChange?: (newSelectedRows: (string | number)[]) => void; /** * Pagination data used to create the pagination footer. Created using the usePagination hook. * @default {} */ paginationProps?: Partial; /** * Function called when the sort button is clicked for selectable tables */ onSortBySelected?: () => void; /** * Direction by which the selectable column is sorted * @default TableSortDirection.none */ sortDirection?: TableSortDirection; } export interface ControlledSelectedRowsProps { /** * Array of rows that are selected in the table when component is controlled */ selectedRows?: (string | number)[]; } export interface UncontrolledSelectedRowsProps { /** * Array of rows that are selected in the table on render when component is uncontrolled */ defaultSelectedRows?: (string | number)[]; } export declare type DatagridSelectedRowsProps = XOR; export declare type DatagridProps = BaseDatagridProps & DatagridSelectedRowsProps; export declare const Datagrid: React.ForwardRefExoticComponent<(BaseDatagridProps & { selectedRows?: never; } & UncontrolledSelectedRowsProps & React.RefAttributes) | (BaseDatagridProps & { defaultSelectedRows?: never; } & ControlledSelectedRowsProps & React.RefAttributes)>;