{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "persian-calendar-picker",
  "title": "Persian Calendar Picker",
  "description": "A right-to-left Persian (Solar Hijri) date picker with Persian month names and digits, a Saturday week start, Nowruz marked and an ISO value. Use this when your app serves Persian-speaking users who expect their own calendar, direction and week.",
  "registryDependencies": [
    "@tealmac/calendar-grid",
    "@tealmac/date-time-core"
  ],
  "files": [
    {
      "path": "registry/patterns/persian-calendar-picker/persian-calendar-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { CalendarGrid } from \"@/components/ui/calendar-grid\"\nimport {\n  addDays,\n  calendarFullLabel,\n  calendarParts,\n  eachDay,\n  endOfMonth,\n  startOfMonth,\n  today as todayISO,\n} from \"@/components/ui/date-time-core\"\n\nexport interface PersianCalendarPickerProps {\n  value?: string | null\n  defaultValue?: string | null\n  onValueChange?: (value: string | null) => void\n  locale?: string\n  today?: string\n}\n\n/** The first day of the Persian year. */\nexport function isNowruz(iso: string) {\n  const p = calendarParts(iso, \"persian\", \"en\")\n  return p.month === 1 && p.day === 1\n}\n\nexport function PersianCalendarPicker({\n  value,\n  defaultValue = null,\n  onValueChange,\n  locale = \"fa-IR\",\n  today,\n}: PersianCalendarPickerProps) {\n  const now = today ?? todayISO()\n  const [inner, setInner] = React.useState<string | null>(defaultValue)\n  const [month, setMonth] = React.useState(defaultValue ?? now)\n  const date = value === undefined ? inner : value\n  // Nowruz can sit in the neighbouring Gregorian month's grid, so look a week either side.\n  const visible = eachDay(\n    addDays(startOfMonth(month), -7),\n    addDays(endOfMonth(month), 7)\n  )\n  const markers = Object.fromEntries(\n    visible.filter(isNowruz).map((d) => [d, \"Nowruz\"])\n  )\n\n  return (\n    <div dir=\"rtl\" lang={locale} className=\"flex w-fit flex-col gap-2\">\n      <CalendarGrid\n        label=\"تقویم\"\n        calendar=\"persian\"\n        locale={locale}\n        today={now}\n        firstDay={6}\n        month={month}\n        onMonthChange={setMonth}\n        markers={markers}\n        value={date}\n        onValueChange={(d) => {\n          if (value === undefined) setInner(d as string | null)\n          onValueChange?.(d as string | null)\n        }}\n        className=\"border\"\n      />\n      <p role=\"status\" className=\"text-sm\">\n        {date\n          ? calendarFullLabel(date, \"persian\", locale)\n          : \"یک روز را انتخاب کنید\"}\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}