{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-data-table-resize",
  "type": "registry:ui",
  "title": "react-tw/data-table-resize.tsx",
  "description": "The look of column resizing in the React DataTable, as `<ui-data-table>`'s; the behaviour is the 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/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/data-table-resize.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/data-table-resize.tsx",
      "content": "import { DataTable as DataTablePrimitive } from '@purpurabog/ui/headless';\nimport { cn } from './lib/utils.ts';\n\n/**\n * The look of column resizing in the React DataTable, as `<ui-data-table>`'s; the behaviour is the\n * headless DataTable's (`useDataTable`'s resize, `DataTable.ResizeHandle`; core/column-resize, after\n * IBM Products Datagrid): a handle on the end edge of each resizable column header — drag it, or Tab\n * to it (a native range input named \"Resize Name column\" that reads the width in pixels) and use the\n * arrow keys (2px; Shift, Page Up / Down 16px; Home / End narrowest / widest). The first resize\n * freezes the automatic layout into fixed widths and an empty filler column takes the rest of the\n * row. Each finished resize (a drag, a key press) calls `onColumnResize` with the new widths.\n */\nexport type DataTableColumnResize = DataTablePrimitive.DataTableColumnResize;\n\nconst handleClasses = cn(\n    'peer/resize absolute -end-3 top-0 z-2 m-0 box-border h-full w-6 cursor-col-resize touch-none appearance-none bg-transparent p-0 outline-none',\n    '[&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:border-0 [&::-webkit-slider-thumb]:bg-transparent [&::-moz-range-thumb]:invisible',\n);\n\n// the 4px strip and its 2px line, 3px either side of the edge; keyboard focus: a 2px blue line with an 8px dot\nconst barClasses = cn(\n    'pointer-events-none absolute inset-y-0 -end-[3px] z-1 box-content w-1 border-0 border-e-2 border-solid border-e-transparent',\n    '[@media(any-hover:hover)]:group-hover/th:border-e-hairline-strong [@media(any-hover:hover)]:group-hover/th:bg-canvas-selected-hover group-data-[resizing]/th:border-e-secondary-hover!',\n    'peer-focus-visible/resize:border-e-transparent peer-focus-visible/resize:bg-transparent',\n    'peer-focus-visible/resize:before:absolute peer-focus-visible/resize:before:inset-y-0 peer-focus-visible/resize:before:-end-px peer-focus-visible/resize:before:w-0.5 peer-focus-visible/resize:before:bg-focus',\n    'peer-focus-visible/resize:after:absolute peer-focus-visible/resize:after:-end-1 peer-focus-visible/resize:after:top-[calc(50%-4px)] peer-focus-visible/resize:after:size-2 peer-focus-visible/resize:after:rounded-[50%] peer-focus-visible/resize:after:bg-focus',\n    'forced-colors:group-data-[resizing]/th:border-e-[Highlight]! forced-colors:peer-focus-visible/resize:before:bg-[Highlight] forced-colors:peer-focus-visible/resize:after:bg-[Highlight]',\n);\n\n/** A resizable header: its own hover, and a 1px guide down the body while resizing or keyed. */\nexport const resizableHeaderClasses = cn(\n    'group/th relative [@media(any-hover:hover)]:hover:bg-[var(--ui-table-sort-hover,var(--ui-layer-selected-hover))]',\n    \"after:pointer-events-none after:absolute after:-end-[0.5px] after:top-full after:z-1 after:hidden after:h-(--_resize-guide,0) after:w-px after:bg-ghost-active after:content-['']\",\n    'data-[resizing]:after:block has-[input:focus-visible]:after:block forced-colors:after:bg-[Highlight]',\n);\n\n/** The handle on the end edge of a column header (inside `DataTable.ColumnHeader`), with its strip; nothing for a column that doesn't resize. */\nexport function ResizeHandle({ column, label, valueText }: Readonly<{ column: DataTablePrimitive.DataTableColumn; label: (header: string) => string; valueText: (px: number) => string }>) {\n    const { resize } = DataTablePrimitive.useDataTableContext();\n    if (!resize.isResizable(column)) return null;\n    return (\n        <>\n            <DataTablePrimitive.ResizeHandle aria-label={label(column.header)} valueText={valueText} className={handleClasses} />\n            <span aria-hidden=\"true\" className={barClasses} />\n        </>\n    );\n}\n"
    }
  ]
}
