import { FC, ComponentType, ReactElement } from 'react'; import { Identifier, Record, RecordMap, SortPayload } from '../../../features/core'; import { TableProps } from '@mui/material'; import useDatagridStyles from './useDatagridStyles'; import { ClassesOverride } from '../../types'; import { RowClickFunction } from './DatagridRow'; /** * The Datagrid component renders a list of records as a table. * It is usually used as a child of the and components. * * Props: * - rowStyle * * @example Display all posts as a datagrid * const postRowStyle = (record, index) => ({ * backgroundColor: record.nb_views >= 500 ? '#efe' : 'white', * }); * export const PostList = (props) => ( * * * * * * * * * ); * * @example Display all the comments of the current post as a datagrid * * * * * * * * * * * @example Usage outside of a or a . * * const currentSort = { field: 'published_at', order: 'DESC' }; * * export const MyCustomList = (props) => { * const { ids, data, total, loaded } = useGetList( * 'posts', * { page: 1, perPage: 10 }, * currentSort * ); * * return ( * { * console.log('set sort'); * }} * onSelect={() => { * console.log('on select'); * }} * onToggleItem={() => { * console.log('on toggle item'); * }} * > * * * * ); * } */ declare const Datagrid: FC; export interface DatagridProps extends Omit { body?: ReactElement | ComponentType; classes?: ClassesOverride; className?: string; expand?: ReactElement | FC<{ basePath: string; id: Identifier; record: Record; resource: string; }>; hasBulkActions?: boolean; header?: ReactElement | ComponentType; hover?: boolean; empty?: ReactElement; isRowSelectable?: (record: Record) => boolean; isRowExpandable?: (record: Record) => boolean; optimized?: boolean; rowClick?: string | RowClickFunction; rowStyle?: (record: Record, index: number) => any; size?: 'medium' | 'small'; basePath?: string; currentSort?: SortPayload; data?: RecordMap; ids?: Identifier[]; loaded?: boolean; onSelect?: (ids: Identifier[]) => void; onToggleItem?: (id: Identifier) => void; setSort?: (sort: string, order?: string) => void; selectedIds?: Identifier[]; total?: number; } export default Datagrid;