{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-data-table-skeleton",
  "type": "registry:ui",
  "title": "react-tw/data-table-skeleton.tsx",
  "description": "Carbon `DataTableSkeleton`, the look of `<ui-data-table-skeleton>`: the table's shape while data Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/data-table-skeleton.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/data-table-skeleton.tsx",
      "content": "import type { ComponentProps } from 'react';\nimport { SIZES, cellBase, staticCell, type DataTableSize, type RowLook } from './data-table.styles.ts';\nimport { cn } from './lib/utils.ts';\n\nexport interface DataTableSkeletonProps extends Omit<ComponentProps<'div'>, 'headers' | 'rowCount' | 'columnCount' | 'size' | 'zebra' | 'hideHeader' | 'hideToolbar' | 'className'> {\n    /** Header texts to show instead of bars. */\n    headers?: string[];\n    rowCount?: number;\n    columnCount?: number;\n    size?: DataTableSize;\n    zebra?: boolean;\n    /** Hide the title / description placeholder (Carbon `showHeader={false}`). */\n    hideHeader?: boolean;\n    /** Hide the toolbar placeholder (Carbon `showToolbar={false}`). */\n    hideToolbar?: boolean;\n    className?: string;\n}\n\n/**\n * Carbon `DataTableSkeleton`, the look of `<ui-data-table-skeleton>`: the table's shape while data\n * loads — `headers` (or `columnCount` bars) in the header row, `rowCount` rows of bars, title and\n * toolbar placeholders. Purely visual (`aria-hidden`); put `aria-busy` and a status on the region.\n */\nexport function DataTableSkeleton({ headers, rowCount = 5, columnCount = 5, size = 'lg', zebra = false, hideHeader = false, hideToolbar = false, className, ...rest }: Readonly<DataTableSkeletonProps>) {\n    const columns = Array.from({ length: Math.max(1, columnCount) }, (_, i) => i);\n    const rowsShown = Array.from({ length: Math.max(0, rowCount) }, (_, i) => i);\n    return (\n        <div {...rest} aria-hidden=\"true\" className={cn('block font-sans', className)} style={{ ...rest.style, ...(SIZES[size].vars) }}>\n            <div className=\"relative pt-0.5\">\n                {hideHeader ? null : (\n                    <div className=\"bg-surface-1 px-4 pt-4 pb-6\">\n                        <span className=\"skeleton block h-6 w-[120px]\" />\n                        <span className=\"skeleton mt-2 block h-4 w-40\" />\n                    </div>\n                )}\n                {hideToolbar ? null : (\n                    <div className=\"flex h-12 justify-end bg-surface-1\">\n                        <span className=\"skeleton block h-full w-[150px]\" />\n                    </div>\n                )}\n                <div className=\"block overflow-x-auto\">\n                    <table className=\"w-full border-collapse border-spacing-0\">\n                        <thead className=\"bg-[color:var(--ui-table-header-background,var(--ui-layer-accent))] type-body-emphasis leading-[18px]!\">\n                            <tr className=\"h-(--_row)\">\n                                {columns.map((i) => (\n                                    <th key={i} className={cn(cellBase, 'bg-[color:var(--ui-table-header-background,var(--ui-layer-accent))] py-(--_label-pad) font-semibold text-ink')}>\n                                        {headers ? (headers[i] ?? '') : <span className=\"skeleton block h-4 w-16 bg-skeleton-element!\" />}\n                                    </th>\n                                ))}\n                            </tr>\n                        </thead>\n                        <tbody className=\"bg-surface-1 type-body-sm leading-[18px]!\">\n                            {rowsShown.map((r) => {\n                                const look: RowLook = { zebraTable: zebra, zebra: r % 2 === 1, selected: false, first: r === 0, last: r === rowsShown.length - 1, expanded: false };\n                                return (\n                                    <tr key={r} className={cn('h-(--_row)', zebra && r % 2 === 1 && 'bg-layer-background')}>\n                                        {columns.map((i) => (\n                                            <td key={i} className={cn(cellBase, 'pt-(--_cell-pad-start) pb-(--_cell-pad-end)', staticCell(look))}>\n                                                <span className=\"skeleton block h-4 w-16\" />\n                                            </td>\n                                        ))}\n                                    </tr>\n                                );\n                            })}\n                        </tbody>\n                    </table>\n                </div>\n            </div>\n        </div>\n    );\n}\n"
    },
    {
      "path": "src/react-tw/data-table.styles.ts",
      "type": "registry:ui",
      "target": "components/ui/react-tw/data-table.styles.ts",
      "content": "import { cn } from './lib/utils.ts';\n\n// The look of DataTable (and its skeleton): Carbon's sizes, and the cascade of <ui-data-table>'s row and cell rules,\n// resolved per row as Tailwind classes.\n\n/** Carbon's table sizes: rows of 24 / 32 / 40 / 48 (default) / 64px. */\nexport type DataTableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport interface SizeLook {\n    vars: Record<string, string>;\n    /** Padding of the selection cells (xl has its own). */\n    select: string;\n    radio: string;\n}\n\n/** Row height and paddings per size (Carbon `--data-table--{size}`). */\nexport const SIZES: Record<DataTableSize, SizeLook> = {\n    xs: { vars: { '--_row': '24px', '--_label-pad': '2px', '--_cell-pad-start': '2px', '--_cell-pad-end': '2px', '--_align': 'middle', '--_expand-pad': '0 0 0 8px', '--_expand-button': '24px', '--_toolbar': '24px' }, select: 'py-0', radio: 'py-0' },\n    sm: { vars: { '--_row': '32px', '--_label-pad': '7px', '--_cell-pad-start': '7px', '--_cell-pad-end': '6px', '--_align': 'middle', '--_expand-pad': '0 0 0 8px', '--_expand-button': '32px', '--_toolbar': '32px' }, select: 'py-[3px]', radio: 'py-[3px]' },\n    md: { vars: { '--_row': '40px', '--_label-pad': '7px', '--_cell-pad-start': '7px', '--_cell-pad-end': '6px', '--_align': 'middle', '--_expand-pad': '4px 0 4px 8px', '--_expand-button': '32px', '--_toolbar': '48px' }, select: 'py-[3px]', radio: 'py-[3px]' },\n    lg: { vars: { '--_row': 'var(--ui-table-row-height, 48px)', '--_label-pad': '0px', '--_cell-pad-start': '0px', '--_cell-pad-end': '0px', '--_align': 'middle', '--_expand-pad': '8px 0 8px 8px', '--_expand-button': '32px', '--_toolbar': '48px' }, select: 'py-0', radio: 'py-0' },\n    xl: { vars: { '--_row': '64px', '--_label-pad': '16px', '--_cell-pad-start': '16px', '--_cell-pad-end': '16px', '--_align': 'top', '--_expand-pad': '10px 0 22px 8px', '--_expand-button': '32px', '--_toolbar': '48px' }, select: 'pt-[13px] pb-0', radio: 'pt-4 pb-0' },\n};\n\nexport const PAGINATION_SIZE = { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg', xl: 'lg' } as const;\n\n// ---- the look of rows and cells (the cascade of <ui-data-table>'s rules, resolved per row) ----\n\n/**\n * Carbon's contextual tokens (they follow the enclosing <Layer>); `row` is the line between body rows: border-subtle as\n * Carbon web components (00 on the page, 01 / 02 in layers), as `<ui-data-table>`.\n */\ntype Ink = 'layer' | 'layer-background' | 'row' | 'subtle' | 'layer-accent' | 'selected' | 'active' | 'subtle-selected' | 'hover' | 'selected-hover' | 'transparent';\n\n/** Literal class names (Tailwind only sees whole names). */\nconst TOP: Record<Ink, string> = {\n    'layer': 'border-t-surface-1',\n    'layer-background': 'border-t-layer-background',\n    'row': 'border-t-hairline',\n    'subtle': 'border-t-hairline',\n    'layer-accent': 'border-t-layer-accent',\n    'selected': 'border-t-[color:var(--ui-table-row-selected,var(--ui-surface-2))]',\n    'active': 'border-t-ghost-active',\n    'subtle-selected': 'border-t-border-subtle-selected',\n    'hover': 'border-t-ghost-hover',\n    'selected-hover': 'border-t-layer-selected-hover',\n    transparent: 'border-t-transparent',\n};\nconst BOTTOM: Record<Ink, string> = {\n    'layer': 'border-b-surface-1',\n    'layer-background': 'border-b-layer-background',\n    'row': 'border-b-hairline',\n    'subtle': 'border-b-hairline',\n    'layer-accent': 'border-b-layer-accent',\n    'selected': 'border-b-[color:var(--ui-table-row-selected,var(--ui-surface-2))]',\n    'active': 'border-b-ghost-active',\n    'subtle-selected': 'border-b-border-subtle-selected',\n    'hover': 'border-b-ghost-hover',\n    'selected-hover': 'border-b-layer-selected-hover',\n    transparent: 'border-b-transparent',\n};\nconst HOVER_TOP: Record<Ink, string> = {\n    'layer': 'group-hover/row:border-t-surface-1',\n    'layer-background': 'group-hover/row:border-t-layer-background',\n    'row': 'group-hover/row:border-t-hairline',\n    'subtle': 'group-hover/row:border-t-hairline',\n    'layer-accent': 'group-hover/row:border-t-layer-accent',\n    'selected': 'group-hover/row:border-t-[color:var(--ui-table-row-selected,var(--ui-surface-2))]',\n    'active': 'group-hover/row:border-t-ghost-active',\n    'subtle-selected': 'group-hover/row:border-t-border-subtle-selected',\n    'hover': 'group-hover/row:border-t-ghost-hover',\n    'selected-hover': 'group-hover/row:border-t-layer-selected-hover',\n    transparent: 'group-hover/row:border-t-transparent',\n};\nconst HOVER_BOTTOM: Record<Ink, string> = {\n    'layer': 'group-hover/row:border-b-surface-1',\n    'layer-background': 'group-hover/row:border-b-layer-background',\n    'row': 'group-hover/row:border-b-hairline',\n    'subtle': 'group-hover/row:border-b-hairline',\n    'layer-accent': 'group-hover/row:border-b-layer-accent',\n    'selected': 'group-hover/row:border-b-[color:var(--ui-table-row-selected,var(--ui-surface-2))]',\n    'active': 'group-hover/row:border-b-ghost-active',\n    'subtle-selected': 'group-hover/row:border-b-border-subtle-selected',\n    'hover': 'group-hover/row:border-b-ghost-hover',\n    'selected-hover': 'group-hover/row:border-b-layer-selected-hover',\n    transparent: 'group-hover/row:border-b-transparent',\n};\n\nexport interface RowLook {\n    /** The table is zebra-striped. */\n    zebraTable: boolean;\n    /** This row is an odd (striped) one. */\n    zebra: boolean;\n    selected: boolean;\n    /** First `<tr>` of the body. */\n    first: boolean;\n    /** Last `<tr>` of the body (an open row's child row comes after it). */\n    last: boolean;\n    expanded: boolean;\n}\n\n/** A striped row (not selected): layer-background at rest, ghost-hover when hovered (as `<ui-data-table zebra>`). */\nconst striped = (look: RowLook) => look.zebraTable && look.zebra && !look.selected;\n\n/** A body row's background: stripe, selection, hover. */\nexport function rowClasses(look: RowLook) {\n    let rest = 'hover:bg-ghost-hover';\n    // --ui-table-row-selected: Carbon's layer-selected; a design can use its own highlight\n    if (look.selected) rest = 'bg-[color:var(--ui-table-row-selected,var(--ui-surface-2))] hover:bg-layer-selected-hover';\n    else if (striped(look)) rest = 'bg-layer-background hover:bg-ghost-hover';\n    return cn('group/row h-(--_row) transition-[background-color] duration-(--ui-duration-fast) ease-(--ui-easing-entrance) motion-reduce:transition-none', rest);\n}\n\n/** A body cell's top and bottom rules at rest: Carbon's row borders, striped rows, then the selected run (which wins). */\nfunction restRules(look: RowLook): { top: Ink; bottom: Ink } {\n    if (look.selected) {\n        if (look.last) return { top: 'selected', bottom: 'selected' };\n        return { top: look.first ? 'subtle-selected' : 'selected', bottom: 'active' };\n    }\n    if (!look.zebraTable) return { top: 'layer', bottom: 'row' };\n    return look.zebra ? { top: 'layer-background', bottom: 'layer-background' } : { top: 'layer', bottom: 'layer' };\n}\n\n/** An open row's bottom rule (at rest, hovered): the line above its child row; the chevron cell draws none. */\nfunction openRowBottom(look: RowLook, expandCell: boolean, rest: Ink, hover: Ink): { bottom: Ink; hoverBottom: Ink } {\n    if (!look.expanded) return { bottom: rest, hoverBottom: hover };\n    // zebra: the striped table's open-row hover rule outranks the chevron cell's own (as in <ui-data-table>)\n    if (expandCell) return { bottom: 'transparent', hoverBottom: look.zebraTable ? 'subtle' : 'hover' };\n    return { bottom: look.selected && look.last ? rest : 'subtle', hoverBottom: 'subtle' };\n}\n\n/** A body cell's rules and text colour, at rest and while its row is hovered. */\nexport function cellClasses(look: RowLook, expandCell = false) {\n    const rest = restRules(look);\n    const hoverTop: Ink = look.selected ? 'selected-hover' : 'hover';\n    const { bottom, hoverBottom } = openRowBottom(look, expandCell, rest.bottom, hoverTop);\n    const top = rest.top;\n    return cn(\n        'border-0 border-y border-solid transition-[background-color] duration-(--ui-duration-fast) ease-(--ui-easing-entrance) motion-reduce:transition-none',\n        TOP[top],\n        BOTTOM[bottom],\n        HOVER_TOP[hoverTop],\n        HOVER_BOTTOM[hoverBottom],\n        // Carbon: secondary text until hovered or chosen; --ui-table-cell-ink lets a design use primary text\n        look.selected ? 'text-ink' : 'text-[color:var(--ui-table-cell-ink,var(--ui-ink-muted))] group-hover/row:text-ink',\n        // the chosen row's mark on its start edge, in its first cell: none in Carbon (Kanok: a border-interactive mark)\n        look.selected && 'first:[background-image:var(--ui-table-row-thread,none)]',\n        // the open row's child row hovered: this row lights up with it\n        look.expanded && '[@media(hover:hover)]:[tr:has(+tr:hover)>&]:text-ink',\n        look.selected && 'forced-colors:border-y-[Highlight]',\n    );\n}\n\nexport const cellBase = 'box-border px-4 text-start align-(--_align)';\nexport const ALIGN = { start: '', center: 'text-center', end: 'text-end' } as const;\n\nexport const expandButtonClasses = cn(\n    'm-0 box-border inline-flex h-(--_expand-button) w-8 cursor-pointer items-center justify-center rounded-[var(--ui-icon-control-radius,0px)] border-0 bg-transparent px-2 py-0 align-middle text-[ButtonText]',\n    'outline-none focus-visible:shadow-[inset_0_0_0_var(--ui-focus-width,2px)_var(--ui-focus)]',\n    '[&_svg]:size-4 [&_svg]:fill-icon-primary [&_svg]:[transform:rotate(90deg)] [&_svg]:transition-transform [&_svg]:duration-150 [&_svg]:ease-carbon motion-reduce:[&_svg]:transition-none',\n    'aria-expanded:[&_svg]:[transform:rotate(270deg)]',\n);\n\nexport const barButtonClasses = cn(\n    // --ui-batch-button-*: a design can make them text buttons on its tinted bar\n    'm-0 h-(--_toolbar) cursor-pointer whitespace-nowrap border-0 bg-[var(--ui-batch-button,var(--ui-primary))] px-4 text-[var(--ui-batch-button-ink,var(--ui-on-primary))] type-button',\n    'hover:bg-[var(--ui-batch-button-hover,var(--ui-blue-hover))] active:bg-[var(--ui-batch-button-active,var(--ui-blue-80))] outline-none focus-visible:rounded-[var(--ui-focus-radius,0px)] focus-visible:outline-[length:var(--ui-focus-width,2px)] focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-[var(--ui-batch-focus,var(--ui-surface-1))]',\n    // Carbon .cds--btn: the fill and the ring change in fast-01 with the entrance easing\n    'transition-[background-color,outline] duration-(--ui-duration-fast) ease-(--ui-easing-entrance)',\n);\n\n/** Carbon draws the table checkbox 3px in and 4px down a 24px label. */\nexport const checkboxInCell = 'block h-6 ms-[3px] [&_label]:py-[3px]';\n\n/** A skeleton cell's rules: the table's, without hover. */\nexport function staticCell(look: RowLook) {\n    let bottom = look.zebraTable ? 'border-b-surface-1' : 'border-b-hairline';\n    if (look.zebraTable && look.zebra) bottom = 'border-b-layer-background';\n    return cn('border-0 border-y border-solid text-ink-muted', look.zebraTable && look.zebra ? 'border-t-layer-background' : 'border-t-surface-1', bottom);\n}\n"
    }
  ]
}
