2024-09-07 09:12:48 +02:00
|
|
|
import * as React from "react";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
2024-09-07 09:12:48 +02:00
|
|
|
import { cn } from "@/lib/utils";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const Table = React.forwardRef<
|
|
|
|
HTMLTableElement,
|
|
|
|
React.HTMLAttributes<HTMLTableElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<div className="relative w-full overflow-auto">
|
|
|
|
<table
|
|
|
|
ref={ref}
|
|
|
|
className={cn("w-full caption-bottom text-sm", className)}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
Table.displayName = "Table";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableHeader = React.forwardRef<
|
|
|
|
HTMLTableSectionElement,
|
|
|
|
React.HTMLAttributes<HTMLTableSectionElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableHeader.displayName = "TableHeader";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableBody = React.forwardRef<
|
|
|
|
HTMLTableSectionElement,
|
|
|
|
React.HTMLAttributes<HTMLTableSectionElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<tbody
|
|
|
|
ref={ref}
|
|
|
|
className={cn("[&_tr:last-child]:border-0", className)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableBody.displayName = "TableBody";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableFooter = React.forwardRef<
|
|
|
|
HTMLTableSectionElement,
|
|
|
|
React.HTMLAttributes<HTMLTableSectionElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<tfoot
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
|
|
|
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableFooter.displayName = "TableFooter";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableRow = React.forwardRef<
|
|
|
|
HTMLTableRowElement,
|
|
|
|
React.HTMLAttributes<HTMLTableRowElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<tr
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
|
|
|
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableRow.displayName = "TableRow";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableHead = React.forwardRef<
|
|
|
|
HTMLTableCellElement,
|
|
|
|
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<th
|
|
|
|
ref={ref}
|
|
|
|
className={cn(
|
|
|
|
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableHead.displayName = "TableHead";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableCell = React.forwardRef<
|
|
|
|
HTMLTableCellElement,
|
|
|
|
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<td
|
|
|
|
ref={ref}
|
|
|
|
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableCell.displayName = "TableCell";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
const TableCaption = React.forwardRef<
|
|
|
|
HTMLTableCaptionElement,
|
|
|
|
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
|
|
>(({ className, ...props }, ref) => (
|
|
|
|
<caption
|
|
|
|
ref={ref}
|
|
|
|
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
|
|
{...props}
|
|
|
|
/>
|
2024-09-07 09:12:48 +02:00
|
|
|
));
|
|
|
|
TableCaption.displayName = "TableCaption";
|
2024-06-16 13:13:09 +02:00
|
|
|
|
|
|
|
export {
|
|
|
|
Table,
|
|
|
|
TableHeader,
|
|
|
|
TableBody,
|
|
|
|
TableFooter,
|
|
|
|
TableHead,
|
|
|
|
TableRow,
|
|
|
|
TableCell,
|
2024-09-07 09:12:48 +02:00
|
|
|
TableCaption
|
|
|
|
};
|