{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stat-priority-list",
  "title": "Stat priority list",
  "description": "A drag-to-reorder priority list — the stat-priority picker for a build optimizer (drag Resilience above Recovery).",
  "registryDependencies": [
    "@engram/cn",
    "@engram/dnd",
    "@engram/tokens"
  ],
  "files": [
    {
      "path": "src/components/stat-priority-list.tsx",
      "content": "\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn.js\";\nimport { Draggable, DropZone } from \"./dnd.js\";\n\nexport interface StatPriorityListProps<T> {\n  /** The ordered items (highest priority first). */\n  order: T[];\n  /** Fired with the reordered array after a drag-drop. */\n  onReorder: (next: T[]) => void;\n  /** Render the row content for an item. */\n  renderItem: (item: T, index: number) => ReactNode;\n  /** Stable key per item. Defaults to String(item). */\n  itemKey?: (item: T) => string;\n  className?: string;\n}\n\n/** Move an item from one index to another, returning a new array. */\nfunction move<T>(list: T[], from: number, to: number): T[] {\n  if (from === to) return list;\n  const next = [...list];\n  const [item] = next.splice(from, 1);\n  next.splice(to, 0, item);\n  return next;\n}\n\n/**\n * A drag-to-reorder priority list — the stat-priority picker for a build\n * optimizer (drag Resilience above Recovery). Generic over the item type;\n * engram handles the drag mechanics and emits the new order via `onReorder`.\n */\nexport function StatPriorityList<T>({\n  order,\n  onReorder,\n  renderItem,\n  itemKey = (item) => String(item),\n  className,\n}: StatPriorityListProps<T>) {\n  return (\n    <div className={cn(\"flex flex-col gap-1\", className)}>\n      {order.map((item, index) => (\n        <DropZone\n          key={itemKey(item)}\n          accept={(d) => typeof d === \"number\"}\n          onDrop={(d) => onReorder(move(order, d as number, index))}\n          activeClassName=\"outline-2 outline-engram-accent\"\n        >\n          <Draggable\n            data={index}\n            className=\"flex items-center gap-2 border border-engram-border bg-engram-raised px-2.5 py-1.5\"\n          >\n            <span\n              aria-hidden\n              className=\"font-engram-mono text-engram-faint text-xs tabular-nums\"\n            >\n              {index + 1}\n            </span>\n            <span\n              aria-hidden\n              className=\"text-engram-faint leading-none tracking-tighter\"\n            >\n              ⠿\n            </span>\n            <div className=\"min-w-0 flex-1\">{renderItem(item, index)}</div>\n          </Draggable>\n        </DropZone>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/engram/stat-priority-list.tsx"
    }
  ],
  "meta": {
    "level": "component"
  },
  "docs": "Extend without forking: edit the copied source, use `asChild` (Radix Slot) to change the rendered element, pass the typed `annotations` prop for curated data (verdict/tags/per-plug), or use slot / render-prop props for arbitrary content. Requires the @engram/tokens theme (--engram-* CSS variables).",
  "categories": [
    "stats"
  ],
  "type": "registry:component"
}