import { Fragment, PropsWithChildren } from 'react'; import { Row } from '@tanstack/react-table'; import { DefaultType } from './types'; interface Props { isLoading?: boolean; rows: Row[]; emptyContent?: string; renderRow(row: Row): React.ReactNode; } export function TableContent({ isLoading = false, rows, emptyContent = 'No items available', renderRow, }: Props) { if (isLoading) { return Loading...; } if (!rows.length) { return {emptyContent}; } return ( <> {rows.map((row) => ( {renderRow(row)} ))} ); } function TableContentOneColumn({ children }: PropsWithChildren) { // using MAX_SAFE_INTEGER to make sure the single column will be the size of the table return ( {children} ); }