Files
upstream-mirror 1416db152c
All checks were successful
Release / Create Version PR or Publish Stable Release (push) Has been skipped
Release / Publish Prerelease to NPM (push) Has been skipped
Monitor Registries / Monitor registry health (push) Has been skipped
snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:44:43 +05:00

123 lines
2.5 KiB
TypeScript

"use client"
import * as React from "react"
import { cn } from "cn"
import {
Cell as CellPrimitive,
Column as ColumnPrimitive,
Row as RowPrimitive,
TableBody as TableBodyPrimitive,
TableFooter as TableFooterPrimitive,
TableHeader as TableHeaderPrimitive,
Table as TablePrimitive,
type CellProps,
type ColumnProps,
type RowProps,
type TableBodyProps,
type TableFooterProps,
type TableHeaderProps,
type TableProps,
} from "react-aria-components"
function Table({ className, ...props }: TableProps) {
return (
<div data-slot="table-container" className="cn-table-container">
<TablePrimitive
data-slot="table"
className={cn("cn-table", className)}
{...props}
/>
</div>
)
}
function TableHeader<T>({ className, ...props }: TableHeaderProps<T>) {
return (
<TableHeaderPrimitive
data-slot="table-header"
className={cn("cn-table-header", className)}
{...props}
/>
)
}
function TableBody<T>({ className, ...props }: TableBodyProps<T>) {
return (
<TableBodyPrimitive
data-slot="table-body"
className={cn(
"cn-table-body data-empty:h-24 data-empty:text-center",
className
)}
{...props}
/>
)
}
function TableFooter<T>({ className, ...props }: TableFooterProps<T>) {
return (
<TableFooterPrimitive
data-slot="table-footer"
className={cn("cn-table-footer", className)}
{...props}
/>
)
}
function TableRow<T>({ className, ...props }: RowProps<T>) {
return (
<RowPrimitive
data-slot="table-row"
className={cn(
"cn-table-row cn-table-row-aria has-aria-expanded:bg-muted/50",
className
)}
{...props}
/>
)
}
function TableHead({ className, ...props }: ColumnProps) {
return (
<ColumnPrimitive
data-slot="table-head"
className={cn("cn-table-head cn-table-head-aria", className)}
{...props}
/>
)
}
function TableCell({ className, ...props }: CellProps) {
return (
<CellPrimitive
data-slot="table-cell"
className={cn("cn-table-cell cn-table-cell-aria", className)}
{...props}
/>
)
}
function TableCaption({
className,
...props
}: React.ComponentProps<"figcaption">) {
return (
<figcaption
data-slot="table-caption"
className={cn("cn-table-caption text-center", className)}
{...props}
/>
)
}
export {
Table,
TableHeader,
TableBody,
TableFooter,
TableHead,
TableRow,
TableCell,
TableCaption,
}