subman-nextjs/src/app/ui/tables/selectColumn.tsx

33 lines
897 B
TypeScript

import { Checkbox } from "@/components/ui/checkbox";
import { CellContext, Column, ColumnDef, ColumnMeta, Header, HeaderContext, RowSelectionTableState, Table, TableState } from "@tanstack/react-table";
export const selectCol = {
id: "select",
header: (props: HeaderContext<any, any>) => {
return (
<div className="flex items-center justify-center">
<Checkbox
checked={props.table.getIsAllRowsSelected()}
onCheckedChange={props.table.toggleAllRowsSelected}
aria-label="select/deselect all rows"
/>
</div>
)
},
cell: (props: CellContext<any, any>) => {
return (
<div className="flex items-center justify-center">
<Checkbox
checked={props.row.getIsSelected()}
onCheckedChange={props.row.toggleSelected}
aria-label="select/deselect row"
/>
</div>
)
}
}