import { PropsWithChildren } from "react" import Spinner from "../../atoms/spinner" import { TablePagination } from "./pagination" import { PagingProps } from "./types" const ROW_HEIGHT = 40 type Props = PropsWithChildren<{ isLoading?: boolean hasPagination?: T pagingState: T extends true ? PagingProps : undefined numberOfRows?: number }> const TableContainer = ({ children, // TODO: remove (redundant) hasPagination, pagingState, isLoading, numberOfRows = 12, }: Props) => { // We use the number of rows (query limit) plus the header row to calculate the minimum height of the table, to avoid the table jumping around while loading. const minHeight = (numberOfRows + 1) * ROW_HEIGHT return (
{isLoading && (
)} {children}
{hasPagination && pagingState && (
)}
) } export default TableContainer