import { HeaderGroup, TableHeaderProps } from 'react-table'; import { useTableContext } from './TableContainer'; import { TableHeaderCell } from './TableHeaderCell'; interface Props = Record> { headers: HeaderGroup[]; onSortChange?(colId: string, desc: boolean): void; } export function TableHeaderRow< D extends Record = Record >({ headers, onSortChange, className, role, style, }: Props & TableHeaderProps) { useTableContext(); return ( {headers.map((column) => ( { column.toggleSortBy(desc); if (onSortChange) { onSortChange(column.id, desc); } }} isSorted={column.isSorted} isSortedDesc={column.isSortedDesc} render={() => column.render('Header')} canFilter={!column.disableFilters} renderFilter={() => column.render('Filter')} /> ))} ); }