{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-column-resize",
  "type": "registry:lib",
  "title": "core/column-resize",
  "description": "Framework-free behaviour shared by the ui-* components (column-resize); no DOM, no lit. 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": [],
  "files": [
    {
      "path": "src/core/column-resize.ts",
      "type": "registry:lib",
      "target": "components/ui/core/column-resize.ts",
      "content": "/**\n * Column resizing for the data tables, framework-free, after IBM Products Datagrid (Carbon's\n * DataTable has none): how narrow and wide a column may get and what each key does to its width.\n */\n\n/** IBM Products Datagrid: columns stop at 50px. */\nexport const MIN_COLUMN_WIDTH = 50;\n/** An arrow press moves the edge 2px… */\nexport const RESIZE_STEP = 2;\n/** …Shift + arrow and Page Up / Down 16px. */\nexport const RESIZE_BIG_STEP = 16;\n\nexport interface ColumnLimits {\n    minWidth?: number;\n    maxWidth?: number;\n}\n\n/** The narrowest a column may get. */\nexport const columnMin = (column: ColumnLimits) => column.minWidth ?? MIN_COLUMN_WIDTH;\n\n/**\n * The widest a column may get: its `maxWidth`, else no less than the table's visible width — and\n * never less than `width` itself, so a column already wider than the box can still be dragged.\n */\nexport const columnMax = (column: ColumnLimits, width: number, viewWidth: number) => column.maxWidth ?? Math.max(width, viewWidth, columnMin(column));\n\n/** `width` kept within the column's limits, in whole pixels. */\nexport const clampColumnWidth = (column: ColumnLimits, width: number, viewWidth: number) => Math.round(Math.min(Math.max(width, columnMin(column)), columnMax(column, width, viewWidth)));\n\n/**\n * The width a key on a column's resize handle asks for, or undefined for a key it ignores. The arrow\n * pointing out of the column widens it (left in right-to-left); Up / Down widen / narrow; Shift makes\n * an arrow step 16px; Home / End the narrowest / widest.\n */\nexport function resizeKeyWidth(key: string, options: { shift: boolean; rtl: boolean; current: number; column: ColumnLimits; viewWidth: number }): number | undefined {\n    const { shift, rtl, current, column, viewWidth } = options;\n    const step = shift ? RESIZE_BIG_STEP : RESIZE_STEP;\n    const outward = rtl ? -1 : 1;\n    const deltas: Record<string, number> = {\n        ArrowRight: step * outward,\n        ArrowLeft: -step * outward,\n        ArrowUp: step,\n        ArrowDown: -step,\n        PageUp: RESIZE_BIG_STEP,\n        PageDown: -RESIZE_BIG_STEP,\n    };\n    if (key in deltas) return current + deltas[key];\n    if (key === 'Home') return columnMin(column);\n    if (key === 'End') return columnMax(column, current, viewWidth);\n    return undefined;\n}\n"
    }
  ]
}
