BillTracker/client/components/ui/table.jsx

132 lines
2.4 KiB
React
Raw Normal View History

import { motion } from 'framer-motion';
2026-05-03 19:51:57 -05:00
import { cn } from '@/lib/utils';
function Table({ className, ref, ...props }) {
return (
<div className="relative w-full overflow-auto">
<table
ref={ref}
className={cn(
'w-full caption-bottom text-sm',
'border-collapse',
className
)}
{...props}
/>
</div>
);
}
function TableHeader({ className, ref, ...props }) {
return (
<thead
2026-05-03 19:51:57 -05:00
ref={ref}
className={cn(
'[&_tr]:border-b [&_tr]:border-border/60',
2026-05-03 19:51:57 -05:00
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableBody({ className, ref, ...props }) {
return (
<tbody
ref={ref}
className={cn(
'[&_tr:last-child]:border-0',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableFooter({ className, ref, ...props }) {
return (
<tfoot
ref={ref}
className={cn(
'border-t border-border/60 bg-muted/50 font-medium',
'[&>tr]:last:border-b-0',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableRow({ className, ref, ...props }) {
return (
<motion.tr
ref={ref}
className={cn(
'border-b border-border/50 last:border-0',
'transition-colors duration-150',
'hover:bg-accent/50',
'data-[state=selected]:bg-accent/70',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableHead({ className, ref, ...props }) {
return (
<th
ref={ref}
className={cn(
'h-10 px-4 text-left align-middle',
'text-xs font-semibold uppercase tracking-normal',
'text-muted-foreground',
'[&:has([role=checkbox])]:pr-0',
'[&>[role=checkbox]]:translate-y-[2px]',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableCell({ className, ref, ...props }) {
return (
<td
ref={ref}
className={cn(
'px-5 py-3 align-middle',
'text-sm font-medium text-foreground',
'[&:has([role=checkbox])]:pr-0',
'[&>[role=checkbox]]:translate-y-[2px]',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
function TableCaption({ className, ref, ...props }) {
return (
<caption
ref={ref}
className={cn(
'mt-4 text-sm text-muted-foreground',
className
)}
{...props}
/>
);
}
2026-05-03 19:51:57 -05:00
export {
Table,
TableHeader,
TableBody,
TableFooter,
TableHead,
TableRow,
TableCell,
TableCaption,
};