-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathTableLayout.tsx
More file actions
26 lines (24 loc) · 845 Bytes
/
TableLayout.tsx
File metadata and controls
26 lines (24 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { Table as ReactTable, Row } from "@tanstack/react-table";
import type { ReactNode } from "react";
import { TableBody } from "./TableBody";
import { TableHeader } from "./TableHeader";
interface TableLayoutProps<TFields> {
tableInstance: ReactTable<TFields>;
emptyState?: React.ReactNode;
extraStyles?: {
row: (rowData: TFields) => any | undefined;
};
renderRow?: (row: Row<TFields>) => ReactNode;
}
function TableLayout<TFields>(props: TableLayoutProps<TFields>) {
const hasRows = props.tableInstance.getRowModel().rows.length > 0;
return (
<div className="table-responsive">
<table className="table table-vcenter table-selectable mb-0">
{hasRows ? <TableHeader tableInstance={props.tableInstance} /> : null}
<TableBody {...props} />
</table>
</div>
);
}
export { TableLayout, type TableLayoutProps };