{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "basic-table",
  "title": "Basic Table",
  "description": "A clean, semantic table for showing data as it is: plain, striped or bordered, comfortable or compact, a caption and a totals row, custom cells such as status pills, a sticky header that casts a shadow once you scroll, and rows that fade in on load.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/basic-table/basic-table.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type TableRow = Record<string, React.ReactNode>;\n\nexport interface TableColumn {\n  key: string;\n  label: string;\n  align?: \"left\" | \"center\" | \"right\";\n  width?: number | string;\n  /** Custom cell content; receives the cell value and the whole row. */\n  render?: (value: React.ReactNode, row: TableRow) => React.ReactNode;\n}\n\nexport interface BasicTableProps {\n  columns?: TableColumn[];\n  rows?: TableRow[];\n  /** A title above the table (also its accessible caption). */\n  caption?: string;\n  /** Values for a summary row at the bottom, by column key. */\n  footer?: TableRow;\n  variant?: \"plain\" | \"striped\" | \"bordered\";\n  density?: \"comfortable\" | \"compact\";\n  hoverable?: boolean;\n  /** Keep the header visible while the body scrolls (needs maxHeight). */\n  stickyHeader?: boolean;\n  maxHeight?: number;\n  /** Rows fade in one after another on mount. */\n  animateIn?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.52)\", panel: \"#0E0E0E\", head: \"#131313\", border: \"rgba(255,255,255,0.09)\", line: \"rgba(255,255,255,0.06)\", stripe: \"rgba(255,255,255,0.022)\", hover: \"rgba(255,255,255,0.045)\", shadow: \"0 8px 16px -10px rgba(0,0,0,0.8)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.52)\", panel: \"#FFFFFF\", head: \"#FAFAF9\", border: \"rgba(10,10,10,0.1)\", line: \"rgba(10,10,10,0.06)\", stripe: \"rgba(10,10,10,0.02)\", hover: \"rgba(10,10,10,0.035)\", shadow: \"0 8px 16px -10px rgba(10,10,10,0.25)\" },\n};\n\nconst STATUS: Record<string, { dot: string; label: string }> = {\n  Paid: { dot: \"#3FBF7F\", label: \"Paid\" },\n  Pending: { dot: \"#F2A841\", label: \"Pending\" },\n  Overdue: { dot: \"#FF7A6B\", label: \"Overdue\" },\n  Refunded: { dot: \"#8A8A8A\", label: \"Refunded\" },\n};\n\nfunction StatusPill({ value }: { value: React.ReactNode }) {\n  const s = typeof value === \"string\" ? STATUS[value] : undefined;\n  if (!s) return <>{value}</>;\n  return (\n    <span className=\"inline-flex items-center rounded-full text-[12px] font-medium\" style={{ gap: 6, padding: \"3px 9px\", border: \"1px solid rgba(128,128,128,0.25)\" }}>\n      <span aria-hidden=\"true\" className=\"block rounded-full\" style={{ width: 6, height: 6, background: s.dot }} />\n      {s.label}\n    </span>\n  );\n}\n\nconst DEFAULT_COLUMNS: TableColumn[] = [\n  { key: \"invoice\", label: \"Invoice\", width: 110 },\n  { key: \"customer\", label: \"Customer\" },\n  { key: \"date\", label: \"Date\", width: 110 },\n  { key: \"status\", label: \"Status\", width: 120, render: (v) => <StatusPill value={v} /> },\n  { key: \"amount\", label: \"Amount\", align: \"right\", width: 110 },\n];\n\nconst DEFAULT_ROWS: TableRow[] = [\n  { invoice: \"INV-2041\", customer: \"Northwind Ltd\", date: \"Sep 24\", status: \"Paid\", amount: \"$2,400.00\" },\n  { invoice: \"INV-2040\", customer: \"Maya Chen\", date: \"Sep 22\", status: \"Pending\", amount: \"$640.00\" },\n  { invoice: \"INV-2039\", customer: \"Okafor Studio\", date: \"Sep 19\", status: \"Paid\", amount: \"$1,180.00\" },\n  { invoice: \"INV-2038\", customer: \"Berg & Co.\", date: \"Sep 12\", status: \"Overdue\", amount: \"$3,050.00\" },\n  { invoice: \"INV-2037\", customer: \"Leo Fischer\", date: \"Sep 08\", status: \"Refunded\", amount: \"$220.00\" },\n  { invoice: \"INV-2036\", customer: \"Iris Novak\", date: \"Sep 03\", status: \"Paid\", amount: \"$890.00\" },\n];\n\nexport function BasicTable({\n  columns = DEFAULT_COLUMNS,\n  rows = DEFAULT_ROWS,\n  caption = \"Recent invoices\",\n  footer = { customer: \"6 invoices\", amount: \"$8,380.00\" },\n  variant = \"plain\",\n  density = \"comfortable\",\n  hoverable = true,\n  stickyHeader = false,\n  maxHeight,\n  animateIn = true,\n  theme = \"dark\",\n  className,\n}: BasicTableProps) {\n  const p = PALETTES[theme];\n  const reduce = Boolean(useReducedMotion());\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const [scrolled, setScrolled] = React.useState(false);\n  const padY = density === \"compact\" ? 8 : 13;\n  const bordered = variant === \"bordered\";\n\n  const cell = (col: TableColumn, i: number): React.CSSProperties => ({\n    padding: `${padY}px 16px`,\n    textAlign: col.align ?? \"left\",\n    width: col.width,\n    borderLeft: bordered && i > 0 ? `1px solid ${p.line}` : undefined,\n    whiteSpace: \"nowrap\",\n  });\n\n  return (\n    <div className={cn(\"flex w-full flex-col overflow-hidden\", className)} style={{ borderRadius: 16, background: p.panel, border: `1px solid ${p.border}`, fontFamily: \"Inter, sans-serif\", color: p.text }}>\n      <div ref={scrollRef} className=\"overflow-auto\" style={{ maxHeight: stickyHeader ? maxHeight : undefined, scrollbarWidth: \"thin\" }} onScroll={(e) => setScrolled(e.currentTarget.scrollTop > 2)}>\n        <table className=\"w-full border-collapse text-[13.5px]\" style={{ minWidth: 560 }}>\n          {caption && (\n            <caption className=\"text-left text-[14.5px] font-semibold tracking-[-0.01em]\" style={{ padding: \"14px 16px 12px\", captionSide: \"top\" }}>\n              {caption}\n            </caption>\n          )}\n          <thead>\n            <tr style={{ background: p.head }}>\n              {columns.map((col, i) => (\n                <th\n                  key={col.key}\n                  scope=\"col\"\n                  className=\"text-[12px] font-semibold tracking-wide uppercase\"\n                  style={{\n                    ...cell(col, i),\n                    paddingTop: 10,\n                    paddingBottom: 10,\n                    color: p.muted,\n                    borderTop: `1px solid ${p.line}`,\n                    borderBottom: `1px solid ${p.line}`,\n                    position: stickyHeader ? \"sticky\" : undefined,\n                    top: 0,\n                    zIndex: 1,\n                    background: p.head,\n                    boxShadow: stickyHeader && scrolled ? p.shadow : \"none\",\n                    transition: \"box-shadow 0.2s ease\",\n                  }}\n                >\n                  {col.label}\n                </th>\n              ))}\n            </tr>\n          </thead>\n          <tbody>\n            {rows.map((row, r) => (\n              <motion.tr\n                key={r}\n                className={cn(hoverable && \"hover:bg-[var(--bt-hover)]\")}\n                style={{ [\"--bt-hover\" as string]: p.hover, background: variant === \"striped\" && r % 2 === 1 ? p.stripe : \"transparent\", borderBottom: r < rows.length - 1 || footer ? `1px solid ${p.line}` : undefined, transition: \"background-color 0.15s ease\" }}\n                initial={animateIn && !reduce ? { opacity: 0, y: 6 } : false}\n                animate={{ opacity: 1, y: 0 }}\n                transition={{ duration: 0.3, delay: animateIn && !reduce ? r * 0.04 : 0, ease: [0.22, 1, 0.36, 1] }}\n              >\n                {columns.map((col, i) => {\n                  const Tag = i === 0 ? \"th\" : \"td\";\n                  return (\n                    <Tag key={col.key} scope={i === 0 ? \"row\" : undefined} className={cn(\"tabular-nums\", i === 0 ? \"font-semibold\" : \"font-normal\")} style={{ ...cell(col, i), color: i === 0 || col.align === \"right\" ? p.text : p.muted }}>\n                      {col.render ? col.render(row[col.key], row) : row[col.key]}\n                    </Tag>\n                  );\n                })}\n              </motion.tr>\n            ))}\n          </tbody>\n          {footer && (\n            <tfoot>\n              <tr style={{ background: p.head }}>\n                {columns.map((col, i) => (\n                  <td key={col.key} className=\"font-semibold tabular-nums\" style={{ ...cell(col, i), color: footer[col.key] !== undefined && col.align !== \"right\" ? p.muted : p.text }}>\n                    {footer[col.key]}\n                  </td>\n                ))}\n              </tr>\n            </tfoot>\n          )}\n        </table>\n      </div>\n    </div>\n  );\n}\n\nexport default BasicTable;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}