{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "table",
  "title": "Table",
  "description": "A table with 38px heads and 42px rows, and an embedded variant for tables inside a page.",
  "registryDependencies": [
    "@khaeli/utils"
  ],
  "files": [
    {
      "path": "registry/khaeli/ui/table.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n/**\n * `embedded`: a small table inside a page (line items, action items), drawn\n * as Underlay's bordered 12px container with 48px rows and column hairlines.\n * Tables inside a record block take it without asking (foundation.css).\n */\nfunction Table({\n  className,\n  variant = \"default\",\n  ...props\n}: React.ComponentProps<\"table\"> & { variant?: \"default\" | \"embedded\" }) {\n  const containerRef = React.useRef<HTMLDivElement>(null)\n  const [scrolls, setScrolls] = React.useState(false)\n  React.useEffect(() => {\n    const container = containerRef.current\n    if (!container) return\n    const observer = new ResizeObserver(() =>\n      setScrolls(container.scrollWidth > container.clientWidth)\n    )\n    observer.observe(container)\n    if (container.firstElementChild) observer.observe(container.firstElementChild)\n    return () => observer.disconnect()\n  }, [])\n  // A table wider than its place scrolls sideways, and a scrolling region\n  // cannot be scrolled from the keyboard unless it takes focus. Only then is\n  // the container a tab stop, and a region when the table has a name to share.\n  const label = props[\"aria-label\"]\n  const labelledBy = props[\"aria-labelledby\"]\n  const named = label !== undefined || labelledBy !== undefined\n\n  return (\n    <div\n      ref={containerRef}\n      data-slot=\"table-container\"\n      data-variant={variant}\n      className=\"focus-ring-inset relative w-full overflow-x-auto\"\n      {...(scrolls && {\n        tabIndex: 0,\n        ...(named && {\n          role: \"region\",\n          \"aria-label\": label,\n          \"aria-labelledby\": labelledBy,\n        }),\n      })}\n    >\n      <table\n        data-slot=\"table\"\n        className={cn(\"w-full caption-bottom text-xs\", className)}\n        {...props}\n      />\n    </div>\n  )\n}\n\nfunction TableHeader({ className, ...props }: React.ComponentProps<\"thead\">) {\n  return (\n    <thead\n      data-slot=\"table-header\"\n      className={cn(\"[&_tr]:border-b\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction TableBody({ className, ...props }: React.ComponentProps<\"tbody\">) {\n  return (\n    <tbody\n      data-slot=\"table-body\"\n      className={cn(\"[&_tr:last-child]:border-0\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction TableFooter({ className, ...props }: React.ComponentProps<\"tfoot\">) {\n  return (\n    <tfoot\n      data-slot=\"table-footer\"\n      className={cn(\n        \"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction TableRow({ className, ...props }: React.ComponentProps<\"tr\">) {\n  return (\n    <tr\n      data-slot=\"table-row\"\n      className={cn(\n        \"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction TableHead({ className, ...props }: React.ComponentProps<\"th\">) {\n  return (\n    <th\n      data-slot=\"table-head\"\n      className={cn(\n        \"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction TableCell({ className, ...props }: React.ComponentProps<\"td\">) {\n  return (\n    <td\n      data-slot=\"table-cell\"\n      className={cn(\n        \"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction TableCaption({\n  className,\n  ...props\n}: React.ComponentProps<\"caption\">) {\n  return (\n    <caption\n      data-slot=\"table-caption\"\n      className={cn(\"mt-4 text-xs text-muted-foreground\", className)}\n      {...props}\n    />\n  )\n}\n\nexport {\n  Table,\n  TableHeader,\n  TableBody,\n  TableFooter,\n  TableHead,\n  TableRow,\n  TableCell,\n  TableCaption,\n}\n",
      "type": "registry:ui"
    }
  ],
  "css": {
    "@layer components": {
      "[data-slot=\"table\"]": {
        "font-size": "var(--type-body) !important",
        "line-height": "var(--type-body-leading) !important"
      },
      "[data-slot=\"table-row\"]": {
        "height": "42px"
      },
      "[data-slot=\"table-header\"] [data-slot=\"table-row\"]": {
        "height": "38px",
        "background-color": "var(--row-hover)"
      },
      "[data-slot=\"table-head\"]": {
        "height": "38px !important",
        "padding": "0 12px !important",
        "font-size": "var(--type-caption) !important",
        "line-height": "var(--type-caption-leading) !important",
        "font-weight": "400",
        "color": "var(--muted-foreground) !important",
        "border-bottom": "1px solid var(--border)"
      },
      "[data-slot=\"table-cell\"]": {
        "height": "42px",
        "padding": "0 12px !important",
        "border-bottom": "1px solid var(--border)"
      },
      "@media (hover: hover) and (pointer: fine)": {
        "[data-slot=\"table-body\"] [data-slot=\"table-row\"]:hover": {
          "background-color": "var(--row-hover) !important"
        }
      },
      "[data-slot=\"table-container\"][data-variant=\"embedded\"]": {
        "border": "1px solid var(--border)",
        "border-radius": "var(--radius-xl)"
      },
      "[data-slot=\"table-container\"][data-variant=\"embedded\"] :is([data-slot=\"table-head\"], [data-slot=\"table-cell\"])": {
        "padding": "0 16px !important"
      },
      "[data-slot=\"table-container\"][data-variant=\"embedded\"] :is([data-slot=\"table-head\"], [data-slot=\"table-cell\"]) + :is([data-slot=\"table-head\"], [data-slot=\"table-cell\"])": {
        "border-left": "1px solid var(--border)"
      },
      "[data-slot=\"table-container\"][data-variant=\"embedded\"] :is([data-slot=\"table-body\"] [data-slot=\"table-row\"], [data-slot=\"table-cell\"])": {
        "height": "48px"
      },
      "[data-slot=\"table-container\"][data-variant=\"embedded\"] [data-slot=\"table-body\"] [data-slot=\"table-row\"]:last-child [data-slot=\"table-cell\"]": {
        "border-bottom": "0"
      }
    },
    "[data-slot=\"table-row\"]": {
      "transition-property": "color, background-color",
      "transition-duration": "80ms",
      "transition-timing-function": "ease"
    }
  },
  "docs": "Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.",
  "type": "registry:ui"
}