| 1 | "use client" |
| 2 | |
| 3 | import * as React from "react" |
| 4 | |
| 5 | import { cn } |
| 6 | |
| 7 | function Table({ className |
| 8 | return ( |
| 9 | <div |
| 10 | data-slot="table-container" |
| 11 | className="relative w-full overflow-x-auto" |
| 12 | > |
| 13 | <table |
| 14 | data-slot="table" |
| 15 | className={cn(" |
| 16 | {...props} |
| 17 | /> |
| 18 | </div> |
| 19 | ) |
| 20 | } |
| 21 | |
| 22 | function TableHeader({ className |
| 23 | return ( |
| 24 | <thead |
| 25 | data-slot="table-header" |
| 26 | className={cn(" |
| 27 | {...props} |
| 28 | /> |
| 29 | ) |
| 30 | } |
| 31 | |
| 32 | function TableBody({ className |
| 33 | return ( |
| 34 | <tbody |
| 35 | data-slot="table-body" |
| 36 | className={cn(" |
| 37 | {...props} |
| 38 | /> |
| 39 | ) |
| 40 | } |
| 41 | |
| 42 | function TableFooter({ className |
| 43 | return ( |
| 44 | <tfoot |
| 45 | data-slot="table-footer" |
| 46 | className={cn( |
| 47 | "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", |
| 48 | className |
| 49 | )} |
| 50 | {...props} |
| 51 | /> |
| 52 | ) |
| 53 | } |
| 54 | |
| 55 | function TableRow({ className |
| 56 | return ( |
| 57 | <tr |
| 58 | data-slot="table-row" |
| 59 | className={cn( |
| 60 | "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", |
| 61 | className |
| 62 | )} |
| 63 | {...props} |
| 64 | /> |
| 65 | ) |
| 66 | } |
| 67 | |
| 68 | function TableHead({ className |
| 69 | return ( |
| 70 | <th |
| 71 | data-slot="table-head" |
| 72 | className={cn( |
| 73 | "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", |
| 74 | className |
| 75 | )} |
| 76 | {...props} |
| 77 | /> |
| 78 | ) |
| 79 | } |
| 80 | |
| 81 | function TableCell({ className |
| 82 | return ( |
| 83 | <td |
| 84 | data-slot="table-cell" |
| 85 | className={cn( |
| 86 | "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", |
| 87 | className |
| 88 | )} |
| 89 | {...props} |
| 90 | /> |
| 91 | ) |
| 92 | } |
| 93 | |
| 94 | function TableCaption({ |
| 95 | className, |
| 96 | ...props |
| 97 | }: React. |
| 98 | return ( |
| 99 | <caption |
| 100 | data-slot="table-caption" |
| 101 | className={cn(" |
| 102 | {...props} |
| 103 | /> |
| 104 | ) |
| 105 | } |
| 106 | |
| 107 | export { |
| 108 | Table, |
| 109 | TableHeader, |
| 110 | TableBody, |
| 111 | TableFooter, |
| 112 | TableHead, |
| 113 | TableRow, |
| 114 | TableCell, |
| 115 | TableCaption, |
| 116 | } |