langfuse
117 строк · 2.7 Кб
1import * as React from "react";
2
3import { cn } from "@/src/utils/tailwind";
4
5const Table = React.forwardRef<
6HTMLTableElement,
7React.HTMLAttributes<HTMLTableElement>
8>(({ className, ...props }, ref) => (
9<div className="relative w-full overflow-auto">
10<table
11ref={ref}
12className={cn("w-full caption-bottom text-sm", className)}
13{...props}
14/>
15</div>
16));
17Table.displayName = "Table";
18
19const TableHeader = React.forwardRef<
20HTMLTableSectionElement,
21React.HTMLAttributes<HTMLTableSectionElement>
22>(({ className, ...props }, ref) => (
23<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
24));
25TableHeader.displayName = "TableHeader";
26
27const TableBody = React.forwardRef<
28HTMLTableSectionElement,
29React.HTMLAttributes<HTMLTableSectionElement>
30>(({ className, ...props }, ref) => (
31<tbody
32ref={ref}
33className={cn("[&_tr:last-child]:border-0", className)}
34{...props}
35/>
36));
37TableBody.displayName = "TableBody";
38
39const TableFooter = React.forwardRef<
40HTMLTableSectionElement,
41React.HTMLAttributes<HTMLTableSectionElement>
42>(({ className, ...props }, ref) => (
43<tfoot
44ref={ref}
45className={cn(
46"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
47className,
48)}
49{...props}
50/>
51));
52TableFooter.displayName = "TableFooter";
53
54const TableRow = React.forwardRef<
55HTMLTableRowElement,
56React.HTMLAttributes<HTMLTableRowElement>
57>(({ className, ...props }, ref) => (
58<tr
59ref={ref}
60className={cn(
61"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
62className,
63)}
64{...props}
65/>
66));
67TableRow.displayName = "TableRow";
68
69const TableHead = React.forwardRef<
70HTMLTableCellElement,
71React.ThHTMLAttributes<HTMLTableCellElement>
72>(({ className, ...props }, ref) => (
73<th
74ref={ref}
75className={cn(
76"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
77className,
78)}
79{...props}
80/>
81));
82TableHead.displayName = "TableHead";
83
84const TableCell = React.forwardRef<
85HTMLTableCellElement,
86React.TdHTMLAttributes<HTMLTableCellElement>
87>(({ className, ...props }, ref) => (
88<td
89ref={ref}
90className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
91{...props}
92/>
93));
94TableCell.displayName = "TableCell";
95
96const TableCaption = React.forwardRef<
97HTMLTableCaptionElement,
98React.HTMLAttributes<HTMLTableCaptionElement>
99>(({ className, ...props }, ref) => (
100<caption
101ref={ref}
102className={cn("mt-4 text-sm text-muted-foreground", className)}
103{...props}
104/>
105));
106TableCaption.displayName = "TableCaption";
107
108export {
109Table,
110TableHeader,
111TableBody,
112TableFooter,
113TableHead,
114TableRow,
115TableCell,
116TableCaption,
117};
118