import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { Columns2 } from "lucide-react"; export function ColumnVisibilityToggle({ table, label = "Columns" }) { const columns = table.getAllLeafColumns().filter( (col) => col.id !== "select" && col.id !== "actions" ); const allVisible = columns.every((col) => col.getIsVisible()); return ( Toggle visible columns {/* ─── Show All ──────────────────────────────────────────────────── */} table.toggleAllColumnsVisible(v)} className="text-xs font-medium" > Show All {/* ─── Individual columns ────────────────────────────────────────── */} {columns.map((col) => { const headerLabel = typeof col.columnDef.header === "string" ? col.columnDef.header : col.id; return ( col.toggleVisibility(v)} className="text-xs" > {headerLabel} ); })} ); }