/** * DataTable component * Optional features: * - sortable columns * - expandable rows * - selectable rows (checkbox column) * - pagination * - empty state * - sticky header * - drag and drop sortable rows * * Docs: https://react-table-v7.tanstack.com/docs/api/overview * Types: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table */ import React from 'react'; import { Cell } from 'react-table-7'; import { IDataTablePaginationProps } from './subcomponents/DataTablePagination'; interface IDataTableSortByProps { id: string; desc?: boolean; } interface IDataTableColumnProps { /** Title of the column */ Header: string; /** Key of the data to list in this column */ accessor: string; /** Same as the accessor by default */ id?: string; /** Optional tooltip beside the column title */ tooltipMessage?: string; /** Align the title and cell content. Default: left aligned */ align?: 'left' | 'center' | 'right'; /** Auto: equal width columns. Wide: expand to fill remaining space. Narrow: collapse to min-width of cell content. Default: auto */ columnWidth?: 'auto' | 'wide' | 'narrow'; /** Hide the sort arrows for this column */ disableSortBy?: boolean; /** Apply white-space: nowrap to cell content so it won't wrap */ noWrap?: boolean; /** Add formatting to cell content */ Cell?: (props: Cell) => void; } interface IDataTableProps { /** The table ID */ id?: string; /** The table data */ data: TData[]; /** The available table columns */ columns: Array>; /** Add sort arrows to each column header. Disable per column with disableSortBy=true */ isSortable?: boolean; /** Add a column of checkboxes */ isSelectable?: boolean; /** Add drag/drop to table rows */ isDraggable?: boolean; /** Overlay a loading indicator */ isLoading?: boolean; /** Show the table skeleton while data is loading */ showSkeleton?: boolean; /** Remove header row */ hideHeaders?: boolean; /** Header row scrolls with the table */ hasStickyHeader?: boolean; variant?: 'default' | 'compact'; /** Props for the DataTablePagination component */ paginationProps?: IDataTablePaginationProps; /** Set selected rows by ID */ selectedRows?: { [i: string]: boolean; }; /** Set the default sort order by column(s) eg. [{id: 'name', desc: false}] */ defaultSorted?: Array<{ id: string; desc?: boolean; }>; /** Expanded rows collapse on rerenders. Set autoResetExpanded=false to keep them open */ autoResetExpanded?: boolean; /** Text or element when no items listed. */ emptyState?: JSX.Element; componentContext?: string; /** Callback when page number changed */ onPageChange?: (page: number) => void; /** Callback when rows are selected */ onSelectedRowsChange?: (rows: any) => void; /** Callback when rows are selected */ onSortChange?: (sortBy: IDataTableSortByProps[]) => void; /** Callback when a row changes sort order by dragging */ onRowOrderChange?: (source: number, destination: number) => void; /** Show timezone disclaimer under the table */ timezoneDisclaimer?: React.ReactNode; } declare const DataTable: ({ id, columns, data, isSortable, isSelectable, isDraggable, isLoading, showSkeleton, hideHeaders, hasStickyHeader, variant, paginationProps, selectedRows, defaultSorted, emptyState, componentContext, autoResetExpanded, onPageChange, onSelectedRowsChange, onSortChange, onRowOrderChange, timezoneDisclaimer }: IDataTableProps) => JSX.Element; export { DataTable, IDataTableProps, IDataTableSortByProps, IDataTableColumnProps };