{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "date-wheel-picker",
  "title": "Date Wheel Picker",
  "description": "Day, month and year wheels in one frame, with min and max dates.",
  "registryDependencies": [
    "@ikas/utils",
    "@ikas/wheel-picker"
  ],
  "files": [
    {
      "path": "registry/ikas/date-wheel-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { WheelPicker, WheelPickerGroup } from \"@/components/ui/wheel-picker\"\n\ntype DateWheelPickerProps = {\n  /** Selected date. Leave undefined with defaultValue for an uncontrolled picker. */\n  value?: Date\n  /** Initial date when uncontrolled. Today (kept inside the bounds) when left out. */\n  defaultValue?: Date\n  /** Called with the date under the band, at midnight local time. */\n  onValueChange?: (value: Date) => void\n  /** Earliest selectable day. 100 years before today when left out. */\n  minDate?: Date\n  /** Latest selectable day. The end of next year when left out. */\n  maxDate?: Date\n  /** Month names in full (\"Ekim\") or short (\"Eki\"). */\n  monthFormat?: \"long\" | \"short\"\n  /** BCP 47 locale for the month names. */\n  locale?: string\n  /** Row height: sm is 32px, default is 36px. */\n  size?: \"sm\" | \"default\"\n  /** Rows visible through the window. Use an odd number. */\n  visibleCount?: number\n  /** Blocks every wheel. */\n  disabled?: boolean\n  /** A soft tick as each row crosses the band, while the user turns a wheel. */\n  sound?: boolean\n  /** Accessible names of the day, month and year wheels. */\n  labels?: { day: string; month: string; year: string }\n  /** Classes for the frame. */\n  className?: string\n  /** Id of the frame, for an aria-labelledby. */\n  id?: string\n  /** Accessible name of the whole picker. */\n  \"aria-label\"?: string\n}\n\nconst dayStart = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())\nconst daysIn = (year: number, month: number) => new Date(year, month + 1, 0).getDate()\nconst range = (from: number, to: number) => Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i)\n\n/** Day, month and year wheels in one frame; days follow the month and bounds stay respected. */\nfunction DateWheelPicker({\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  minDate,\n  maxDate,\n  monthFormat = \"long\",\n  locale = \"tr-TR\",\n  size = \"default\",\n  visibleCount = 5,\n  disabled = false,\n  sound = false,\n  labels = { day: \"Gün\", month: \"Ay\", year: \"Yıl\" },\n  className,\n  id,\n  \"aria-label\": ariaLabel = \"Tarih\",\n}: DateWheelPickerProps) {\n  const [today] = React.useState(() => dayStart(new Date()))\n  const min = minDate ? dayStart(minDate) : new Date(today.getFullYear() - 100, 0, 1)\n  const max = maxDate ? dayStart(maxDate) : new Date(today.getFullYear() + 1, 11, 31)\n  const fit = (d: Date) => new Date(Math.min(Math.max(dayStart(d).getTime(), min.getTime()), max.getTime()))\n\n  const [uncontrolled, setUncontrolled] = React.useState(() => fit(defaultValue ?? valueProp ?? today))\n  const value = fit(valueProp ?? uncontrolled)\n  const year = value.getFullYear()\n  const month = value.getMonth()\n  const day = value.getDate()\n\n  const minY = min.getFullYear()\n  const maxY = max.getFullYear()\n  const firstMonth = year === minY ? min.getMonth() : 0\n  const lastMonth = year === maxY ? max.getMonth() : 11\n  const firstDay = year === minY && month === min.getMonth() ? min.getDate() : 1\n  const lastDay = year === maxY && month === max.getMonth() ? max.getDate() : daysIn(year, month)\n\n  const monthNames = React.useMemo(() => {\n    const format = new Intl.DateTimeFormat(locale, { month: monthFormat })\n    return range(0, 11).map((m) => format.format(new Date(2000, m, 1)))\n  }, [locale, monthFormat])\n  const years = React.useMemo(() => range(minY, maxY).map(String), [minY, maxY])\n  const months = React.useMemo(\n    () => range(firstMonth, lastMonth).map((m) => ({ value: String(m), label: monthNames[m] })),\n    [firstMonth, lastMonth, monthNames]\n  )\n  const days = React.useMemo(() => range(firstDay, lastDay).map((d) => ({ value: String(d), label: String(d).padStart(2, \"0\") })), [firstDay, lastDay])\n\n  /** Builds the date from the wheels, keeping the day inside the month (31 Mart → 30 Nisan) and the bounds. */\n  function change(next: { year?: number; month?: number; day?: number }) {\n    const y = next.year ?? year\n    const m = next.month ?? month\n    const date = fit(new Date(y, m, Math.min(next.day ?? day, daysIn(y, m))))\n    if (date.getTime() === value.getTime()) return\n    setUncontrolled(date)\n    onValueChange?.(date)\n  }\n\n  return (\n    <WheelPickerGroup\n      id={id}\n      aria-label={ariaLabel}\n      size={size}\n      visibleCount={visibleCount}\n      disabled={disabled}\n      sound={sound}\n      className={cn(\"w-full sm:w-72\", className)}\n    >\n      <WheelPicker aria-label={labels.day} options={days} value={String(day)} onValueChange={(d) => change({ day: Number(d) })} className=\"max-w-16\" />\n      <WheelPicker aria-label={labels.month} options={months} value={String(month)} onValueChange={(m) => change({ month: Number(m) })} className=\"flex-[1.6]\" />\n      <WheelPicker aria-label={labels.year} options={years} value={String(year)} onValueChange={(y) => change({ year: Number(y) })} className=\"max-w-20\" />\n    </WheelPickerGroup>\n  )\n}\n\nexport { DateWheelPicker, type DateWheelPickerProps }\n",
      "type": "registry:component",
      "target": "@components/ikas/date-wheel-picker.tsx"
    }
  ],
  "docs": "https://builders.ikas.com/tr/docs/app-development/ui-kit/components/date-wheel-picker",
  "categories": [
    "forms"
  ],
  "type": "registry:component"
}