{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "picker-wheel",
  "type": "registry:ui",
  "title": "Picker Wheel",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "iOS-inspired 3D cylindrical scrolling drum picker for dates, times, and custom option columns with wheel, drag, and click-to-snap physics.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/picker-wheel.tsx",
      "content": "\"use client\";\n\nimport React, { useState } from \"react\";\nimport { motion, useReducedMotion, type PanInfo } from \"framer-motion\";\nimport { Calendar, Clock } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface PickerColumn {\n  id: string;\n  label?: string;\n  options: string[];\n  defaultIndex?: number;\n}\n\nexport interface PickerWheelProps {\n  /** Columns rendered side-by-side inside the drum wheel */\n  columns?: PickerColumn[];\n  /** Callback fired whenever any column selection changes */\n  onChange?: (selectedValues: Record<string, string>) => void;\n  /** Title shown in the header bar */\n  title?: string;\n  className?: string;\n}\n\nconst DEFAULT_COLUMNS: PickerColumn[] = [\n  {\n    id: \"day\",\n    options: [\n      \"Mon, Oct 5\",\n      \"Tue, Oct 6\",\n      \"Wed, Oct 7\",\n      \"Today\",\n      \"Fri, Oct 9\",\n      \"Sat, Oct 10\",\n      \"Sun, Oct 11\",\n    ],\n    defaultIndex: 3,\n  },\n  {\n    id: \"hour\",\n    options: [\"07\", \"08\", \"09\", \"10\", \"11\", \"12\", \"01\", \"02\", \"03\"],\n    defaultIndex: 2,\n  },\n  {\n    id: \"minute\",\n    options: [\"00\", \"15\", \"30\", \"45\"],\n    defaultIndex: 2,\n  },\n  {\n    id: \"period\",\n    options: [\"AM\", \"PM\"],\n    defaultIndex: 0,\n  },\n];\n\nconst ITEM_HEIGHT = 36;\n\nexport function PickerWheel({\n  columns = DEFAULT_COLUMNS,\n  onChange,\n  title = \"Schedule Deployment\",\n  className,\n}: PickerWheelProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n\n  const [selectedIndices, setSelectedIndices] = useState<Record<string, number>>(\n    () => {\n      const initial: Record<string, number> = {};\n      columns.forEach((col) => {\n        initial[col.id] = col.defaultIndex ?? 0;\n      });\n      return initial;\n    }\n  );\n\n  const selectOption = (colId: string, nextIdx: number, maxLen: number) => {\n    const clamped = Math.max(0, Math.min(maxLen - 1, nextIdx));\n    setSelectedIndices((prev) => {\n      const next = { ...prev, [colId]: clamped };\n      if (onChange) {\n        const result: Record<string, string> = {};\n        columns.forEach((c) => {\n          result[c.id] = c.options[next[c.id] ?? 0] ?? \"\";\n        });\n        onChange(result);\n      }\n      return next;\n    });\n  };\n\n  const formattedSummary = columns\n    .map((col) => col.options[selectedIndices[col.id] ?? 0])\n    .join(\" · \");\n\n  return (\n    <div\n      className={cn(\n        \"w-full max-w-md overflow-hidden rounded-3xl border border-neutral-200 bg-white p-5 shadow-sm dark:border-neutral-800 dark:bg-[#0A0A0A]\",\n        className\n      )}\n    >\n      {/* Top Header */}\n      <div className=\"mb-3 flex items-center justify-between\">\n        <span className=\"inline-flex items-center gap-1.5 text-xs font-semibold text-neutral-950 dark:text-white\">\n          <Clock className=\"h-3.5 w-3.5 text-neutral-400\" />\n          {title}\n        </span>\n        <span className=\"rounded-lg border border-neutral-200 bg-neutral-50 px-2.5 py-0.5 font-mono text-[11px] font-medium text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300\">\n          {formattedSummary}\n        </span>\n      </div>\n\n      {/* Drum Wheel Container */}\n      <div className=\"relative flex h-[180px] select-none items-center justify-center overflow-hidden rounded-2xl border border-neutral-200/80 bg-neutral-50/60 px-3 dark:border-neutral-800/80 dark:bg-[#111111]\">\n        {/* Top & Bottom Fade Masks */}\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 top-0 z-20 h-14 bg-gradient-to-b from-neutral-50 via-neutral-50/80 to-transparent dark:from-[#111111] dark:via-[#111111]/80\"\n        />\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-0 bottom-0 z-20 h-14 bg-gradient-to-t from-neutral-50 via-neutral-50/80 to-transparent dark:from-[#111111] dark:via-[#111111]/80\"\n        />\n\n        {/* Center Highlight Selection Bar */}\n        <div\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-x-2.5 top-1/2 z-10 h-9 -translate-y-1/2 rounded-xl border border-neutral-300/80 bg-white/90 shadow-2xs dark:border-neutral-700/80 dark:bg-neutral-900/90\"\n        />\n\n        {/* Columns */}\n        <div className=\"relative z-20 flex w-full items-center justify-around\">\n          {columns.map((col) => {\n            const activeIdx = selectedIndices[col.id] ?? 0;\n            const offsetY = (2 - activeIdx) * ITEM_HEIGHT;\n\n            return (\n              <div\n                key={col.id}\n                role=\"listbox\"\n                tabIndex={0}\n                aria-label={col.label ?? col.id}\n                onWheel={(e) => {\n                  e.preventDefault();\n                  const delta = e.deltaY > 0 ? 1 : -1;\n                  selectOption(col.id, activeIdx + delta, col.options.length);\n                }}\n                onKeyDown={(e) => {\n                  if (e.key === \"ArrowDown\") {\n                    e.preventDefault();\n                    selectOption(col.id, activeIdx + 1, col.options.length);\n                  } else if (e.key === \"ArrowUp\") {\n                    e.preventDefault();\n                    selectOption(col.id, activeIdx - 1, col.options.length);\n                  }\n                }}\n                className=\"relative h-[180px] flex-1 overflow-hidden focus-visible:outline-none\"\n              >\n                <motion.div\n                  drag=\"y\"\n                  dragConstraints={{ top: 0, bottom: 0 }}\n                  dragElastic={0.2}\n                  onDragEnd={(\n                    _: MouseEvent | TouchEvent | PointerEvent,\n                    info: PanInfo\n                  ) => {\n                    const stepsMoved = Math.round(\n                      -info.offset.y / (ITEM_HEIGHT * 0.75)\n                    );\n                    if (stepsMoved !== 0) {\n                      selectOption(\n                        col.id,\n                        activeIdx + stepsMoved,\n                        col.options.length\n                      );\n                    }\n                  }}\n                  animate={{ y: offsetY }}\n                  transition={\n                    shouldReduceMotion\n                      ? { duration: 0 }\n                      : { type: \"spring\", stiffness: 380, damping: 32 }\n                  }\n                  className=\"cursor-grab active:cursor-grabbing\"\n                >\n                  {col.options.map((opt, idx) => {\n                    const distance = idx - activeIdx;\n                    const absDist = Math.abs(distance);\n                    const isSelected = distance === 0;\n\n                    return (\n                      <button\n                        key={opt}\n                        type=\"button\"\n                        role=\"option\"\n                        aria-selected={isSelected}\n                        onClick={() =>\n                          selectOption(col.id, idx, col.options.length)\n                        }\n                        style={{\n                          height: ITEM_HEIGHT,\n                          transform: shouldReduceMotion\n                            ? undefined\n                            : `perspective(300px) rotateX(${distance * -18}deg) scale(${Math.max(0.82, 1 - absDist * 0.08)})`,\n                        }}\n                        className={cn(\n                          \"flex w-full items-center justify-center px-1 text-center font-mono text-xs transition-opacity\",\n                          isSelected\n                            ? \"font-bold text-neutral-950 opacity-100 dark:text-white\"\n                            : absDist === 1\n                              ? \"font-medium text-neutral-500 opacity-70 dark:text-neutral-400\"\n                              : \"text-neutral-400 opacity-35 dark:text-neutral-600\"\n                        )}\n                      >\n                        <span className=\"truncate\">{opt}</span>\n                      </button>\n                    );\n                  })}\n                </motion.div>\n              </div>\n            );\n          })}\n        </div>\n      </div>\n\n      <p className=\"mt-2.5 text-center text-[11px] text-neutral-400 dark:text-neutral-500\">\n        Scroll wheel, drag vertically, or click any row to snap\n      </p>\n    </div>\n  );\n}\n\nexport default PickerWheel;\n",
      "type": "registry:ui",
      "target": "components/ui/picker-wheel.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
