{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "table",
  "type": "registry:ui",
  "title": "Table",
  "description": "Table displays structured data in rows and columns.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/table/Table.context.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/Table.context.tsx",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { TableContextType } from './Table.types';\n\nexport const TableContext = createContext<TableContextType | undefined>(undefined);\n\nexport const useTableContext = () => {\n  const context = useContext(TableContext);\n\n  if (context === undefined) {\n    throw new Error('useTableContext must be used within a Table');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/table/Table.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/Table.tsx",
      "content": "'use client';\n\n/* eslint-disable jsx-a11y/no-noninteractive-tabindex */\nimport { cn } from '@/lib/wideset/utils';\n\nimport { TableContext } from './Table.context';\nimport type { TableProps } from './Table.types';\nimport { TableBody } from './TableBody';\nimport { TableCell } from './TableCell';\nimport { TableFoot } from './TableFoot';\nimport { TableHead } from './TableHead';\nimport { TableHeader } from './TableHeader';\nimport { TableRow } from './TableRow';\n\nconst TableRoot = ({\n  children,\n  className,\n  size,\n  separated,\n  striped,\n  truncate,\n  flushMargin,\n  placement,\n  align,\n  stickyHeader,\n  stickyColumn,\n  hasBackground,\n  interactive,\n  selectionMode,\n  ...props\n}: TableProps) => {\n  const effectiveHasBackground = hasBackground ?? (stickyHeader || stickyColumn ? true : undefined);\n\n  return (\n    <TableContext.Provider\n      value={{\n        align,\n        flushMargin,\n        size,\n        separated,\n        striped,\n        truncate,\n        placement,\n        stickyHeader,\n        stickyColumn,\n        hasBackground: effectiveHasBackground,\n        selectionMode,\n        interactive: interactive || !!selectionMode,\n      }}\n    >\n      <table\n        data-slot=\"table\"\n        {...props}\n        role={selectionMode ? 'grid' : undefined}\n        aria-multiselectable={selectionMode === 'multiple' ? true : undefined}\n        className={cn(\n          separated && 'is-separated',\n          'group w-full table-auto border-separate border-spacing-0',\n          className,\n        )}\n        tabIndex={stickyColumn || stickyHeader ? 0 : -1}\n      >\n        {children}\n      </table>\n    </TableContext.Provider>\n  );\n};\n\nconst Table = TableRoot as typeof TableRoot & {\n  Body: typeof TableBody;\n  Cell: typeof TableCell;\n  Foot: typeof TableFoot;\n  Head: typeof TableHead;\n  Header: typeof TableHeader;\n  Row: typeof TableRow;\n};\n\nTable.Cell = TableCell;\nTable.Row = TableRow;\nTable.Header = TableHeader;\nTable.Head = TableHead;\nTable.Body = TableBody;\nTable.Foot = TableFoot;\n\nexport { Table };\n"
    },
    {
      "path": "src/components/table/Table.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/Table.types.ts",
      "content": "import type { VariantProps } from 'class-variance-authority';\n\nimport type { cellVariants } from './Table.variants';\n\nexport type SelectionMode = 'single' | 'multiple';\n\nexport type TableContextType = Omit<VariantProps<typeof cellVariants>, 'header'> & {\n  /** Indicates whether the table rows should have alternating background colors */\n  striped?: boolean;\n  /** Whether the header should be sticky */\n  stickyHeader?: boolean;\n  /**\n   * Applies a solid background color to all cells.\n   * Required for sticky header/column to appear correctly over scrolling content.\n   * Automatically defaults to `true` when `stickyHeader` or `stickyColumn` is enabled.\n   */\n  hasBackground?: boolean;\n  /** Enables row selection\n   * - `single` — only one row can be selected at a time\n   * - `multiple` — multiple rows can be selected\n   */\n  selectionMode?: SelectionMode;\n};\n\n/** Structured content arranged in rows and columns. */\nexport type TableProps = React.HTMLAttributes<HTMLTableElement> & TableContextType;\n\nexport type SortDirection = 'asc' | 'desc' | null;\n\n/** Props shared by header and data cells. */\ntype TableCellBaseProps = {\n  /** Horizontal alignment of the cell content. Overrides the table-level value. */\n  align?: 'left' | 'center' | 'right';\n  /** Removes horizontal padding. Overrides the table-level value. */\n  flushMargin?: boolean;\n  /**\n   * Truncates overflowing content to a single line with an ellipsis. Overrides the table-level\n   * value. Requires a constrained column width (`table-fixed` class on the table with `w-*`\n   * classes on the headers, or a `max-w-*` class on the cell); without one, the forced\n   * single line widens the column to the full text width and can overflow the container.\n   */\n  truncate?: boolean;\n};\n\n/** A column header cell (`<th>`), optionally sortable. */\nexport type TableHeaderProps = React.ThHTMLAttributes<HTMLTableCellElement> &\n  TableCellBaseProps & {\n    /** Makes the column sortable — renders a sort button and sets aria-sort on the th. */\n    sortable?: boolean;\n    /**\n     * Current sort direction.\n     * - `null` — sortable, not currently sorted\n     * - `'asc'` — sorted ascending\n     * - `'desc'` — sorted descending\n     */\n    sortDirection?: SortDirection;\n    /** Called when the user clicks to sort. Required when sortable is true. */\n    onSort?: () => void;\n    /** Disables the sort interaction visually and functionally. Only applies when sortable is true. */\n    disabled?: boolean;\n    /** Accessible label for the sort button. When omitted, defaults to `` `Sort by ${column}` `` using the column's text content, or `'Sort by this column'` as a fallback. */\n    sortAriaLabel?: string;\n  };\n\n/** A data row with an optional selected state. */\nexport type TableRowProps = React.HTMLAttributes<HTMLTableRowElement> & {\n  /** Whether the row is in the selected state. */\n  selected?: boolean;\n};\n\n/** A data cell with optional alignment and truncation. */\nexport type TableCellProps = React.TdHTMLAttributes<HTMLTableCellElement> &\n  TableCellBaseProps & {\n    /** Vertical alignment of the cell content. Overrides the table-level value. */\n    placement?: 'top' | 'middle' | 'bottom';\n  };\n\n/** The table section containing column headings. */\nexport type TableHeadProps = React.HTMLAttributes<HTMLTableSectionElement>;\n\n/** The table section containing the body rows. */\nexport type TableBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;\n\n/** The table section containing summary rows. */\nexport type TableFootProps = React.HTMLAttributes<HTMLTableSectionElement>;\n"
    },
    {
      "path": "src/components/table/Table.utils.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/Table.utils.ts",
      "content": "/** Full content of a truncated cell for the `title` attribute (text-like children only). */\nexport const getTruncatedTitle = (\n  children: React.ReactNode,\n  truncate: boolean | null | undefined,\n): string | undefined => {\n  if (!truncate) return undefined;\n  const parts = Array.isArray(children) ? children : [children];\n  const isText = parts.every((part) => typeof part === 'string' || typeof part === 'number');\n  return isText ? parts.join('') || undefined : undefined;\n};\n"
    },
    {
      "path": "src/components/table/Table.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/Table.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\n\nexport const cellVariants = cva(\n  `border-ws-static-base text-ws-static-base border-b [tfoot_&]:border-t [tfoot_&]:border-b-0`,\n  {\n    variants: {\n      size: {\n        sm: 'h-ws-16 px-ws-9 py-ws-3',\n        md: 'h-ws-18 px-ws-9 py-ws-5',\n        lg: 'h-ws-20 px-ws-9 py-ws-7',\n      },\n      header: {\n        true: '',\n        false: '',\n      },\n      align: {\n        left: 'text-left',\n        center: 'text-center',\n        right: 'text-right',\n      },\n      placement: {\n        top: 'align-top',\n        middle: 'align-middle',\n        bottom: 'align-bottom',\n      },\n      flushMargin: {\n        true: 'px-0',\n      },\n      hasBackground: {\n        true: 'bg-ws-static-container',\n      },\n      stickyColumn: {\n        true: 'first-of-type:shadow-ws-table-freeze first-of-type:z-ws-mask [thead_&]:first-of-type:z-ws-sticky first-of-type:sticky first-of-type:left-0 first-of-type:border-r',\n      },\n      separated: {\n        true: 'border-r last:border-r-0',\n      },\n      interactive: {\n        true: 'group-hover/row:bg-ws-dynamic-secondary-alpha-hover group-active/row:bg-ws-dynamic-secondary-alpha-pressed',\n      },\n      selected: {\n        true: '',\n      },\n      truncate: {\n        true: 'truncate',\n      },\n    },\n    compoundVariants: [\n      { header: false, size: 'sm', class: 'typography-label-sm' },\n      { header: false, size: 'md', class: 'typography-label-sm' },\n      { header: false, size: 'lg', class: 'typography-label-md' },\n      { header: true, size: 'sm', class: 'typography-label-strong-sm' },\n      { header: true, size: 'md', class: 'typography-label-strong-sm' },\n      { header: true, size: 'lg', class: 'typography-label-strong-md' },\n      {\n        interactive: true,\n        selected: true,\n        class:\n          'bg-ws-dynamic-primary-alpha-strong-default group-hover/row:bg-ws-dynamic-primary-alpha-strong-hover group-active/row:bg-ws-dynamic-primary-alpha-strong-pressed',\n      },\n    ],\n    defaultVariants: {\n      align: 'left',\n      flushMargin: false,\n      header: false,\n      separated: false,\n      size: 'sm',\n    },\n  },\n);\n"
    },
    {
      "path": "src/components/table/TableBody.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableBody.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { TableBodyProps } from './Table.types';\n\nexport const TableBody = ({ children, className, ...props }: TableBodyProps) => {\n  return (\n    <tbody data-slot=\"table-body\" {...props} className={cn(className)}>\n      {children}\n    </tbody>\n  );\n};\n\nTableBody.displayName = 'Table.Body';\n"
    },
    {
      "path": "src/components/table/TableCell.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableCell.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useTableContext } from './Table.context';\nimport type { TableCellProps } from './Table.types';\nimport { getTruncatedTitle } from './Table.utils';\nimport { cellVariants } from './Table.variants';\n\nexport const TableCell = ({\n  children,\n  className,\n  align,\n  flushMargin,\n  placement,\n  truncate,\n  ...props\n}: TableCellProps) => {\n  const {\n    align: contextAlign,\n    flushMargin: contextFlushMargin,\n    placement: contextPlacement,\n    truncate: contextTruncate,\n    stickyColumn,\n    separated,\n    size,\n    selected,\n    interactive,\n    hasBackground,\n  } = useTableContext();\n\n  const shouldTruncate = truncate ?? contextTruncate;\n\n  return (\n    <td\n      data-slot=\"table-cell\"\n      title={getTruncatedTitle(children, shouldTruncate)}\n      {...props}\n      className={cn(\n        cellVariants({\n          align: align ?? contextAlign,\n          flushMargin: flushMargin ?? contextFlushMargin,\n          placement: placement ?? contextPlacement,\n          truncate: shouldTruncate,\n          stickyColumn,\n          separated,\n          size,\n          interactive,\n          selected,\n          hasBackground,\n        }),\n        className,\n      )}\n    >\n      {children}\n    </td>\n  );\n};\n\nTableCell.displayName = 'Table.Cell';\n"
    },
    {
      "path": "src/components/table/TableFoot.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableFoot.tsx",
      "content": "'use client';\n\nimport type { TableFootProps } from './Table.types';\n\nexport const TableFoot = ({ children, className, ...props }: TableFootProps) => {\n  return (\n    <tfoot data-slot=\"table-foot\" {...props} className={className}>\n      {children}\n    </tfoot>\n  );\n};\n\nTableFoot.displayName = 'Table.Foot';\n"
    },
    {
      "path": "src/components/table/TableHead.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableHead.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useTableContext } from './Table.context';\nimport type { TableHeadProps } from './Table.types';\n\nexport const TableHead = ({ children, className, ...props }: TableHeadProps) => {\n  const { stickyHeader, hasBackground } = useTableContext();\n\n  return (\n    <thead\n      data-slot=\"table-head\"\n      {...props}\n      className={cn(\n        stickyHeader && cn('z-ws-sticky sticky top-0', hasBackground && 'bg-ws-static-container'),\n        className,\n      )}\n    >\n      {children}\n    </thead>\n  );\n};\n\nTableHead.displayName = 'Table.Head';\n"
    },
    {
      "path": "src/components/table/TableHeader.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableHeader.tsx",
      "content": "'use client';\n\nimport { RiArrowLeftRightLine, RiSortAsc, RiSortDesc } from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { IconButton } from '../button/IconButton';\nimport { useTableContext } from './Table.context';\nimport type { SortDirection, TableHeaderProps } from './Table.types';\nimport { getTruncatedTitle } from './Table.utils';\nimport { cellVariants } from './Table.variants';\n\nconst toAriaSortValue = (sortDirection: SortDirection): React.AriaAttributes['aria-sort'] =>\n  sortDirection === 'asc' ? 'ascending' : sortDirection === 'desc' ? 'descending' : 'none';\n\nexport const TableHeader = ({\n  children,\n  className,\n  align,\n  flushMargin,\n  truncate,\n  sortable,\n  sortDirection = null,\n  onSort,\n  disabled = false,\n  sortAriaLabel,\n  ...props\n}: TableHeaderProps) => {\n  const {\n    align: contextAlign,\n    flushMargin: contextFlushMargin,\n    truncate: contextTruncate,\n    stickyColumn,\n    separated,\n    size,\n    hasBackground,\n  } = useTableContext();\n\n  const shouldTruncate = truncate ?? contextTruncate;\n\n  const icon =\n    sortDirection === 'asc'\n      ? RiSortAsc\n      : sortDirection === 'desc'\n        ? RiSortDesc\n        : RiArrowLeftRightLine;\n\n  const sortButton = sortable && (\n    <IconButton\n      size=\"xs\"\n      icon={icon}\n      onClick={onSort}\n      variant=\"secondary\"\n      preset=\"ghost\"\n      disabled={disabled}\n      className=\"ml-ws-2 align-middle\"\n      aria-label={\n        sortAriaLabel ?? `Sort by ${typeof children === 'string' ? children : 'this column'}`\n      }\n    />\n  );\n\n  return (\n    <th\n      data-slot=\"table-header\"\n      title={getTruncatedTitle(children, shouldTruncate)}\n      {...props}\n      aria-sort={sortable ? toAriaSortValue(sortDirection) : undefined}\n      className={cn(\n        cellVariants({\n          align: align ?? contextAlign,\n          flushMargin: flushMargin ?? contextFlushMargin,\n          header: true,\n          stickyColumn,\n          separated,\n          size,\n          hasBackground,\n        }),\n        '[thead_&]:border-b-2',\n        className,\n      )}\n    >\n      {shouldTruncate ? (\n        // Truncate an inner wrapper, not the th itself — clipping the th would\n        // also clip the sort button out of view in a narrow column.\n        <span className=\"flex items-center\">\n          <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n          {sortButton}\n        </span>\n      ) : (\n        <>\n          {children}\n          {sortButton}\n        </>\n      )}\n    </th>\n  );\n};\n\nTableHeader.displayName = 'Table.Header';\n"
    },
    {
      "path": "src/components/table/TableRow.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/table/TableRow.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport { TableContext, useTableContext } from './Table.context';\nimport type { TableRowProps } from './Table.types';\n\nexport const TableRow = ({ children, className, selected, ...props }: TableRowProps) => {\n  const tableContext = useTableContext();\n  const { selectionMode, interactive, striped } = tableContext;\n\n  return (\n    <TableContext.Provider value={{ ...tableContext, selected }}>\n      <tr\n        data-slot=\"table-row\"\n        {...props}\n        {...(selectionMode && { 'aria-selected': selected })}\n        className={cn(\n          (interactive || selectionMode) && 'group/row cursor-pointer',\n          striped &&\n            'even:bg-ws-dynamic-tertiary-alpha-strong-default odd:bg-ws-dynamic-secondary-alpha-default',\n          className,\n        )}\n      >\n        {children}\n      </tr>\n    </TableContext.Provider>\n  );\n};\n\nTableRow.displayName = 'Table.Row';\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
