"use client"; import { Filter } from "@openstatus/icons"; import { Button } from "@openstatus/ui/components/ui/button"; import { Skeleton } from "@openstatus/ui/components/ui/skeleton"; import { TableCell, TableRow } from "@openstatus/ui/components/ui/table"; import type { Table } from "@tanstack/react-table"; import { EmptyStateActions, EmptyStateContainer, EmptyStateDescription, EmptyStateMedia, EmptyStateTitle, } from "@/components/content/empty-state"; import { cn } from "@/lib/utils"; // pill widths cycle per cell so the ghost rows read as rows, not a grid const GHOST_WIDTHS = ["w-3/5", "w-2/5", "w-1/2", "w-1/3", "w-2/5"]; const GHOST_ROWS = 5; // rows are h-10; the empty state pulls itself up by this much const GHOST_HEIGHT = `${GHOST_ROWS * 2.5}rem`; /** Real table rows, so the ghost cells share the header column widths. */ export function DataTableGhostRows({ table }: { table: Table }) { const columns = table.getVisibleLeafColumns(); // TanStack fills in a header for every column; only labeled ones get a pill. // Internal API: if it ever goes away, unlabeled columns merely get a pill too. const defaultHeader = table._getDefaultColumnDef?.().header; const labeled = (column: (typeof columns)[number]) => column.columnDef.meta?.ghost !== false && column.columnDef.header !== defaultHeader && column.columnDef.header !== ""; return Array.from({ length: GHOST_ROWS }).map((_, row) => ( {columns.map((column, cell) => ( {labeled(column) ? ( ) : null} ))} )); } /** First-run body, pulled up over the ghost rows the table renders. */ export function DataTableEmpty({ children, className, ...props }: React.ComponentProps<"div">) { return (
{children}
); } /** Rows exist but the filters match none of them. */ export function DataTableEmptyFiltered({ table, }: { table: Table; }) { return ( No matches Nothing matches the current filters. ); }