{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-data-table-parts",
  "type": "registry:ui",
  "title": "react-tw/data-table-parts.tsx",
  "description": "The parts of DataTable (data-table.tsx) that stand on their own: the title, the toolbar search, the batch-action bar 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": [
    "@purpurabog/ui@^2.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-i18n",
    "@kanok-ui/core-table",
    "@kanok-ui/tw-data-table",
    "@kanok-ui/tw-data-table-resize",
    "@kanok-ui/tw-search",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/data-table-parts.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/data-table-parts.tsx",
      "content": "import { useEffect, useRef, useState, type FocusEvent, type ReactNode, type Ref } from 'react';\nimport { nextSortDirection } from '../core/table.ts';\nimport type { DataTableMessages } from '../core/i18n.ts';\nimport { DataTable as DataTablePrimitive } from '@purpurabog/ui/headless';\nimport type { DataTableHeader, DataTableRow } from './data-table.tsx';\nimport { ResizeHandle, resizableHeaderClasses } from './data-table-resize.tsx';\nimport { barButtonClasses, type DataTableSize } from './data-table.styles.ts';\nimport { Search } from './search.tsx';\nimport { cn } from './lib/utils.ts';\n\n/**\n * The parts of DataTable (data-table.tsx) that stand on their own: the title, the toolbar search, the batch-action bar\n * and a column header, as small components, and the naming of the table and its scrolling box.\n */\n\nexport const chevronRight = <path d=\"M11 8 6 13l-.7-.7L9.6 8 5.3 3.7 6 3z\" />;\nconst arrowUp = <path d=\"M16 4 6 14l1.41 1.41L15 7.83V28h2V7.83l7.59 7.58L26 14 16 4z\" />;\nconst arrowsVertical = <path d=\"M27.6 20.6 24 24.2V4h-2v20.2l-3.6-3.6L17 22l6 6 6-6-1.4-1.4zM9 4l-6 6 1.4 1.4L8 7.8V28h2V7.8l3.6 3.6L15 10 9 4z\" />;\n\n/** A heading or label that is plain text (a file name can't be made of markup). */\nexport const textOf = (node: ReactNode) => (typeof node === 'string' && node !== '' ? node : undefined);\n\n/** The table's title and description above it (Carbon TableContainer). */\nexport function TableTitle({ heading, description, ids }: Readonly<{ heading: ReactNode; description: ReactNode; ids: string }>) {\n    if (!heading && !description) return null;\n    return (\n        <div className=\"bg-[color:var(--ui-table-background,var(--ui-surface-1))] px-4 pt-4 pb-6\">\n            {heading ? (\n                <h4 id={`${ids}title`} className=\"m-0 text-ink type-subhead\">\n                    {heading}\n                </h4>\n            ) : null}\n            {description ? (\n                <p id={`${ids}description`} className=\"m-0 text-ink-muted type-body-sm leading-[18px]! min-[672px]:max-w-[50ch] min-[1056px]:max-w-[80ch]\">\n                    {description}\n                </p>\n            ) : null}\n        </div>\n    );\n}\n\n/** A scrolling box must be reachable by keyboard (WCAG 2.1.1): then it is a named region (by the heading, else the label). */\nexport function scrollBoxProps(scrolls: boolean, named: boolean, label: string | undefined, ids: string) {\n    if (!scrolls) return {};\n    return { tabIndex: 0, role: 'region', 'aria-labelledby': named ? `${ids}title` : undefined, 'aria-label': !named && label ? label : undefined };\n}\n\n/** The table's name (the heading, else the label) and description. */\nexport function tableNaming(named: boolean, label: string | undefined, described: boolean, ids: string) {\n    return {\n        'aria-labelledby': named ? `${ids}title` : undefined,\n        'aria-describedby': described ? `${ids}description` : undefined,\n        'aria-label': named || !label ? undefined : label,\n    };\n}\n\ninterface HeaderCellProps<R extends DataTableRow> {\n    header: DataTableHeader;\n    index: number;\n    table: DataTablePrimitive.DataTableInstance<R, DataTableHeader>;\n    t: DataTableMessages;\n    size: DataTableSize;\n    ids: string;\n    /** The classes every header cell shares (fill, sticky). */\n    cellClassName: string;\n    /** The first column's start padding (with both the chevron and the selection column), applied last. */\n    firstClassName: string;\n    /** The sort that was just asked for, to announce. */\n    onSort: (message: string) => void;\n}\n\n/** A column header: its text, or (sortable) a button that cycles the sort, with its resize handle. */\nexport function HeaderCell<R extends DataTableRow>({ header, index, table, t, size, ids, cellClassName, firstClassName, onSort }: Readonly<HeaderCellProps<R>>) {\n    const resizeClasses = table.resize.isResizable(header) ? resizableHeaderClasses : '';\n    const handle = <ResizeHandle column={header} label={t.resizeColumn} valueText={t.columnWidth} />;\n    if (!table.isSortable(header)) {\n        return (\n            <DataTablePrimitive.ColumnHeader column={header.key} className={cn(resizeClasses, cellClassName, 'py-(--_label-pad) font-semibold text-[color:var(--ui-table-header-ink,var(--ui-ink))]', firstClassName)}>\n                {header.header}\n                {handle}\n            </DataTablePrimitive.ColumnHeader>\n        );\n    }\n    const direction = table.sortDirectionOf(header.key);\n    const active = direction !== 'none';\n    const descriptionId = `${ids}sort-${index}`;\n    const next = nextSortDirection(direction);\n    let action = t.unsort;\n    if (next === 'ascending') action = t.sortAscending;\n    else if (next === 'descending') action = t.sortDescending;\n    return (\n        <DataTablePrimitive.ColumnHeader column={header.key} className={cn(resizeClasses, cellClassName, 'p-0 font-semibold text-[color:var(--ui-table-header-ink,var(--ui-ink))]', firstClassName)}>\n            <DataTablePrimitive.SortButton\n                aria-describedby={descriptionId}\n                className={cn(\n                    'group/sort m-0 box-border flex min-h-(--_row) w-full cursor-pointer items-center justify-between border-0 bg-[color:var(--ui-table-header-background,var(--ui-layer-accent))] p-0 ps-4 text-start text-[color:var(--ui-table-header-ink,var(--ui-ink))] [font:inherit] [letter-spacing:inherit]',\n                    'transition-[background-color,outline] duration-(--ui-duration-fast) ease-(--ui-easing-entrance) hover:bg-[var(--ui-table-sort-hover,var(--ui-layer-selected-hover))]',\n                    'outline-none focus-visible:outline-[length:var(--ui-focus-width,2px)] focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-focus',\n                    // --ui-table-sort-hover / --ui-table-sorted-background: a design can keep the sorted header on the header fill\n                    active && 'not-hover:bg-[var(--ui-table-sorted-background,var(--ui-layer-selected-hover))] forced-colors:outline-1 forced-colors:outline-solid forced-colors:-outline-offset-1 forced-colors:outline-[Highlight]',\n                    size === 'xl' && 'items-start',\n                )}\n                onClick={() => onSort(next === 'none' ? t.unsorted : t.sorted(header.header, next))}\n            >\n                <span className=\"py-(--_label-pad)\">{header.header}</span>\n                <svg\n                    viewBox=\"0 0 32 32\"\n                    aria-hidden=\"true\"\n                    className={cn(\n                        'mx-2 size-5 min-w-4 shrink-0 fill-icon-primary forced-colors:fill-[ButtonText]',\n                        active && 'fill-[var(--ui-table-sorted-icon,var(--ui-icon-primary))]',\n                        size === 'xl' && 'mt-[13px]',\n                        active\n                            ? 'transition-transform duration-[250ms] ease-[cubic-bezier(0.5,0,0.1,1)] motion-reduce:transition-none'\n                            : 'opacity-0 group-hover/sort:opacity-100 group-focus-visible/sort:opacity-100',\n                        direction === 'descending' && 'rotate-180',\n                    )}\n                >\n                    {active ? arrowUp : arrowsVertical}\n                </svg>\n            </DataTablePrimitive.SortButton>\n            <span className=\"sr-only\" id={descriptionId}>\n                {action.replaceAll('{header}', header.header)}\n            </span>\n            {handle}\n        </DataTablePrimitive.ColumnHeader>\n    );\n}\n\ninterface ToolbarSearchProps {\n    size: DataTableSize;\n    /** Always open (Carbon `persistent`); else collapsed to its magnifier until focused or filled. */\n    persistent: boolean;\n    filter: string;\n    /** The table's name, for the search's label (\"Search: Contracts\"). */\n    tableName: string | undefined;\n    label: string | undefined;\n    placeholder: string | undefined;\n    lang: string | undefined;\n    t: DataTableMessages;\n    onChange: (value: string) => void;\n}\n\n/**\n * While the box is still widening from its magnifier (right after the click), Chrome leaves the caret where it was after\n * text that goes in by insertion (an IME, voice input, a test's insertText): typed fast, \"สมชาย\" came out \"ยาชมส\". Puts\n * the caret back after what went in (as the Lit ui-table-toolbar-search).\n */\nfunction useCaretAfterInsertion() {\n    const box = useRef<HTMLDivElement>(null);\n    useEffect(() => {\n        const el = box.current;\n        if (!el) return;\n        let after: number | null = null;\n        const before = (event: Event) => {\n            const { inputType, data, target } = event as InputEvent;\n            const start = (target as HTMLInputElement).selectionStart;\n            after = inputType === 'insertText' && data && start !== null ? start + data.length : null;\n        };\n        const input = (event: Event) => {\n            const field = event.target as HTMLInputElement;\n            const at = after;\n            after = null;\n            if (at !== null && field.selectionStart !== at && at <= field.value.length) field.setSelectionRange(at, at);\n        };\n        el.addEventListener('beforeinput', before);\n        el.addEventListener('input', input);\n        return () => {\n            el.removeEventListener('beforeinput', before);\n            el.removeEventListener('input', input);\n        };\n    }, []);\n    return box;\n}\n\n/** The toolbar's filter field (Carbon TableToolbarSearch). */\nexport function ToolbarSearch({ size, persistent, filter, tableName, label, placeholder, lang, t, onChange }: Readonly<ToolbarSearchProps>) {\n    const [focused, setFocused] = useState(false);\n    const open = persistent || focused || filter !== '';\n    const box = useCaretAfterInsertion();\n    return (\n        <div /* NOSONAR: tracks focus within the toolbar search (Carbon collapses it on blur when empty); the input takes the keyboard */\n            ref={box}\n            data-search=\"\"\n            className={cn(\n                'min-w-0 flex-[0_1_auto]',\n                persistent\n                    ? 'w-full'\n                    : 'w-(--_toolbar) transition-[inline-size,background-color] [transition-duration:300ms,var(--ui-duration-moderate)] [transition-timing-function:cubic-bezier(0.5,0,0.1,1),var(--ui-easing-entrance)] motion-reduce:transition-none',\n                open ? 'w-full' : 'hover:bg-ghost-hover',\n            )}\n            onFocus={() => setFocused(true)}\n            // collapses on blur only when empty (Carbon); moving to its clear button keeps it open\n            onBlur={(event: FocusEvent<HTMLDivElement>) => {\n                if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n            }}\n        >\n            <Search\n                size={size === 'xs' || size === 'sm' ? 'sm' : 'lg'}\n                label={label || (tableName ? `${t.searchLabel}: ${tableName}` : t.searchLabel)}\n                placeholder={placeholder || t.searchPlaceholder}\n                value={filter}\n                lang={lang}\n                onChange={(event) => onChange(event.target.value)}\n                inputClassName={cn(\n                    'bg-surface-1 transition-[outline-color,background-color] duration-(--ui-duration-moderate) ease-carbon',\n                    persistent && 'border-b-0 hover:bg-ghost-hover',\n                    filter !== '' && 'bg-[var(--ui-field-open-background,var(--ui-ghost-hover))]',\n                    !open && 'cursor-pointer p-0 opacity-0',\n                )}\n            />\n        </div>\n    );\n}\n\ninterface BatchActionsBarProps {\n    /** Your buttons. */\n    actions: ReactNode;\n    /** Rows are selected: the bar slides in over the toolbar. */\n    active: boolean;\n    selectedCount: number;\n    /** With paging, \"Select all (N)\" while not everything is selected. */\n    selectAllTotal: number | undefined;\n    t: DataTableMessages;\n    barRef: Ref<HTMLDivElement>;\n    onSelectAll: () => void;\n    onCancel: () => void;\n}\n\n/** The brand bar over the toolbar while rows are selected (Carbon TableBatchActions): the count, your actions, Cancel. */\nexport function BatchActionsBar({ actions, active, selectedCount, selectAllTotal, t, barRef, onSelectAll, onCancel }: Readonly<BatchActionsBarProps>) {\n    const showSelectAll = active && selectAllTotal !== undefined && selectedCount < selectAllTotal;\n    return (\n        <div\n            ref={barRef}\n            aria-hidden={!active}\n            inert={!active}\n            className={cn(\n                // --ui-batch-*: Carbon's brand bar; a design can make it a tinted row with ink text and text buttons (as <ui-table-batch-actions>)\n                'absolute inset-x-0 bottom-0 flex h-(--_toolbar) items-center justify-between bg-[var(--ui-batch-background,var(--ui-background-brand))]',\n                'transition-[transform,clip-path,opacity] duration-(--ui-duration-moderate) ease-carbon motion-reduce:transition-none forced-colors:outline-1 forced-colors:outline-solid forced-colors:-outline-offset-1 forced-colors:outline-[CanvasText]',\n                active\n                    ? 'pointer-events-auto z-1 [clip-path:polygon(0_0,300%_0,300%_300%,0_300%)] [transform:translate3d(0,0,0)] opacity-100'\n                    : 'pointer-events-none [clip-path:polygon(0_0,100%_0,100%_0,0_0)] [transform:translate3d(0,var(--_toolbar),0)] opacity-0',\n            )}\n        >\n            <div className=\"flex min-w-0 items-center\">\n                <p /* NOSONAR: role=status is a polite live region; <output> isn't announced by every screen reader */ role=\"status\" className=\"m-0 flex min-h-(--_toolbar) items-center whitespace-nowrap px-4 text-[var(--ui-batch-ink,var(--ui-on-primary))] type-body-sm leading-[18px]!\">\n                    {t.selectedCount(selectedCount)}\n                </p>\n                {showSelectAll ? (\n                    <>\n                        <span aria-hidden=\"true\" className=\"text-[var(--ui-batch-ink,var(--ui-on-primary))] type-body-sm\">\n                            |\n                        </span>\n                        <button type=\"button\" data-select-all-pages=\"\" className={barButtonClasses} onClick={onSelectAll}>\n                            {t.selectAllCount(selectAllTotal)}\n                        </button>\n                    </>\n                ) : null}\n            </div>\n            {/* Carbon .action-list .btn: 16px both sides */}\n            <div className=\"flex h-full items-center [&>*]:shrink-0 [&>button:not([data-cancel])]:ps-4 [&>button:not([data-cancel])]:pe-4\">\n                {actions}\n                <button\n                    type=\"button\"\n                    data-cancel=\"\"\n                    className={cn(\n                        barButtonClasses,\n                        'relative',\n                        // 1px divider before Cancel, hidden while it is hovered\n                        \"before:absolute before:start-0 before:top-[calc((var(--_toolbar)-16px)/2)] before:h-4 before:w-px before:bg-[var(--ui-batch-divider,var(--ui-on-primary))] before:content-['']\",\n                        'before:transition-opacity before:duration-(--ui-duration-moderate) before:ease-carbon hover:before:opacity-0 hover:before:duration-[250ms] hover:before:ease-[cubic-bezier(0.5,0,0.1,1)] motion-reduce:before:transition-none',\n                    )}\n                    onClick={onCancel}\n                >\n                    {t.cancel}\n                </button>\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"
    }
  ]
}
