/** * PolicyTableV2 * * Main data table component for Policy Explorer V2. * Integrates TanStack Table with shadcn UI Table primitives. * * Features: * - Server-side pagination via TanStack Table manual mode * - Column sorting with visual indicators * - Column resizing with drag handles * - Sticky header (CSS position: sticky) * - Row selection for CSV export * - Density modes (compact/comfortable) */ 'use client'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { flexRender } from '@tanstack/react-table'; import type { Table as TanStackTable } from '@tanstack/react-table'; import type { PolicySettingRow } from '@/lib/types/policy-table'; import { cn } from '@/lib/utils'; interface PolicyTableV2Props { table: TanStackTable; density: 'compact' | 'comfortable'; isLoading?: boolean; } export function PolicyTableV2({ table, density, isLoading = false }: PolicyTableV2Props) { const rowHeight = density === 'compact' ? 'h-10' : 'h-14'; return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { return ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} {/* Column Resize Handle */} {header.column.getCanResize() && (
)} ); })} ))} {isLoading ? ( Loading... ) : table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext() )} ))} )) ) : ( No results found. )}
); }