"use no memo"; import { flexRender, type Table as TanstackTable } from "@tanstack/react-table"; import type * as React from "react"; import { DataTablePagination } from "@/components/data-table/data-table-pagination"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { getColumnPinningStyle } from "@/lib/data-table"; import { cn } from "@/lib/utils"; interface DataTableProps extends React.ComponentProps<"div"> { table: TanstackTable; actionBar?: React.ReactNode; showPagination?: boolean; onRowClick?: (row: TData) => void; } export function DataTable({ table, actionBar, showPagination = true, onRowClick, children, className, ...props }: DataTableProps) { return (
{children}
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )} ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( onRowClick(row.original) : undefined } > {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext(), )} ))} )) ) : ( No results. )}
{showPagination && (
{actionBar && table.getFilteredSelectedRowModel().rows.length > 0 && actionBar}
)}
); }