{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar",
  "title": "Calendar",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/calendar/Calendar.tsx",
      "content": "import * as React from 'react'\nimport { Pressable, ScrollView, View, useWindowDimensions, type ViewProps } from 'react-native'\nimport { ChevronLeft, ChevronRight } from 'lucide-react-native'\nimport { IconButton } from '@/components/ui/icon-button'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\nimport {\n  calendarDateDisabled,\n  calendarDateParts,\n  calendarMonthDays,\n  calendarMonthParts,\n  localCalendarDate,\n  moveCalendarMonth,\n  type CalendarDate,\n  type CalendarMonth,\n} from './calendar.utils'\n\nexport interface CalendarProps extends ViewProps {\n  className?: string\n  value?: CalendarDate\n  defaultValue?: CalendarDate\n  onValueChange?: (date: CalendarDate) => void\n  month?: CalendarMonth\n  defaultMonth?: CalendarMonth\n  onMonthChange?: (month: CalendarMonth) => void\n  minDate?: CalendarDate\n  maxDate?: CalendarDate\n  disabled?: boolean\n  locale?: string\n  weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6\n  previousMonthLabel?: string\n  nextMonthLabel?: string\n}\n\nexport const Calendar = React.forwardRef<React.ComponentRef<typeof View>, CalendarProps>(\n  (\n    {\n      className,\n      value,\n      defaultValue,\n      onValueChange,\n      month,\n      defaultMonth,\n      onMonthChange,\n      minDate,\n      maxDate,\n      disabled = false,\n      locale,\n      weekStartsOn = 0,\n      previousMonthLabel = 'Previous month',\n      nextMonthLabel = 'Next month',\n      ...props\n    },\n    ref,\n  ) => {\n    const [today] = React.useState(() => localCalendarDate(new Date()))\n    const [internalValue, setInternalValue] = React.useState(defaultValue)\n    const [internalMonth, setInternalMonth] = React.useState(() =>\n      calendarMonthParts(defaultMonth)\n        ? defaultMonth!\n        : calendarDateParts(value ?? defaultValue)\n          ? (value ?? defaultValue)!.slice(0, 7)\n          : today.slice(0, 7),\n    )\n    const selected = value === undefined ? internalValue : value\n    const shownMonth = calendarMonthParts(month) ? month! : internalMonth\n    const minimum = calendarDateParts(minDate) ? minDate : undefined\n    const maximum = calendarDateParts(maxDate) ? maxDate : undefined\n    const unavailable = disabled || !!(minimum && maximum && minimum > maximum)\n    const start = Number.isInteger(weekStartsOn) && weekStartsOn >= 0 && weekStartsOn <= 6 ? weekStartsOn : 0\n    const parts = calendarMonthParts(shownMonth)!\n    const days = calendarMonthDays(shownMonth, start)\n    const { fontScale } = useWindowDimensions()\n    const cellWidth = Math.max(44, Math.ceil(28 * fontScale))\n    const previous = moveCalendarMonth(shownMonth, -1)\n    const next = moveCalendarMonth(shownMonth, 1)\n    const previousDisabled = unavailable || !previous || !!(minimum && previous < minimum.slice(0, 7))\n    const nextDisabled = unavailable || !next || !!(maximum && next > maximum.slice(0, 7))\n    const heading = new Intl.DateTimeFormat(locale, {\n      month: 'long',\n      year: 'numeric',\n      calendar: 'gregory',\n      timeZone: 'UTC',\n    })\n    const fullDate = new Intl.DateTimeFormat(locale, {\n      weekday: 'long',\n      year: 'numeric',\n      month: 'long',\n      day: 'numeric',\n      calendar: 'gregory',\n      timeZone: 'UTC',\n    })\n    const dayName = new Intl.DateTimeFormat(locale, { weekday: 'narrow', timeZone: 'UTC' })\n    const number = new Intl.NumberFormat(locale, { useGrouping: false })\n\n    function navigate(nextMonth: CalendarMonth | undefined) {\n      if (unavailable || !nextMonth) return\n      if (month === undefined) setInternalMonth(nextMonth)\n      onMonthChange?.(nextMonth)\n    }\n\n    return (\n      <View\n        ref={ref}\n        {...props}\n        className={cn(\n          'gap-[8px] rounded-lg border border-border bg-card p-[8px]',\n          unavailable && 'opacity-50',\n          className,\n        )}\n      >\n        <View className=\"flex-row items-center gap-[8px]\">\n          <IconButton\n            icon={ChevronLeft}\n            accessibilityLabel={previousMonthLabel}\n            disabled={previousDisabled}\n            onPress={() => {\n              if (!previousDisabled) navigate(previous)\n            }}\n          />\n          <Text accessibilityRole=\"header\" className=\"min-w-0 flex-1 text-center font-semibold\">\n            {heading.format(parts.date)}\n          </Text>\n          <IconButton\n            icon={ChevronRight}\n            accessibilityLabel={nextMonthLabel}\n            disabled={nextDisabled}\n            onPress={() => {\n              if (!nextDisabled) navigate(next)\n            }}\n          />\n        </View>\n        <ScrollView horizontal contentContainerStyle={{ flexGrow: 1 }}>\n          <View style={{ minWidth: cellWidth * 7, flexGrow: 1 }}>\n            <View className=\"flex-row\">\n              {Array.from({ length: 7 }, (_, index) => (\n                <View\n                  key={index}\n                  className=\"min-h-[32px] items-center justify-center p-[4px]\"\n                  style={{ minWidth: cellWidth, flex: 1 }}\n                >\n                  <Text size=\"sm\" variant=\"muted\" accessible={false}>\n                    {dayName.format(new Date(Date.UTC(2020, 5, 7 + ((start + index) % 7))))}\n                  </Text>\n                </View>\n              ))}\n            </View>\n            {Array.from({ length: 6 }, (_, week) => (\n              <View key={week} className=\"min-h-[48px] flex-row\">\n                {days.slice(week * 7, week * 7 + 7).map((date, index) => {\n                  if (!date) return <View key={`blank-${index}`} style={{ minWidth: cellWidth, flex: 1 }} />\n                  const day = calendarDateParts(date)!\n                  const blocked = unavailable || calendarDateDisabled(date, minimum, maximum)\n                  const checked = selected === date\n                  return (\n                    <Pressable\n                      key={date}\n                      accessibilityRole=\"button\"\n                      accessibilityLabel={fullDate.format(day.date)}\n                      accessibilityState={{ selected: checked, disabled: blocked }}\n                      disabled={blocked}\n                      onPress={() => {\n                        if (blocked || date === selected) return\n                        if (value === undefined) setInternalValue(date)\n                        onValueChange?.(date)\n                      }}\n                      className={cn(\n                        'min-h-[48px] items-center justify-center rounded-md border border-transparent p-[4px] active:bg-muted',\n                        date === today && 'border-primary',\n                        checked && 'bg-primary active:bg-primary',\n                        blocked && 'opacity-40',\n                      )}\n                      style={{ minWidth: cellWidth, flex: 1 }}\n                    >\n                      <Text\n                        className={checked ? 'text-primary-foreground' : undefined}\n                        style={{ fontVariant: ['tabular-nums'] }}\n                      >\n                        {number.format(day.day)}\n                      </Text>\n                    </Pressable>\n                  )\n                })}\n              </View>\n            ))}\n          </View>\n        </ScrollView>\n      </View>\n    )\n  },\n)\nCalendar.displayName = 'Calendar'\n",
      "type": "registry:ui",
      "target": "~/components/ui/calendar/Calendar.tsx"
    },
    {
      "path": "packages/registry-native/components/calendar/calendar.utils.ts",
      "content": "export type CalendarDate = string\nexport type CalendarMonth = string\n\nexport function calendarDateParts(value: string | undefined) {\n  if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return undefined\n  const [year, month, day] = value.split('-').map(Number)\n  const date = new Date(0)\n  date.setUTCFullYear(year, month - 1, day)\n  date.setUTCHours(12, 0, 0, 0)\n  if (year < 1 || date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {\n    return undefined\n  }\n  return { year, month, day, date }\n}\n\nexport function calendarMonthParts(value: string | undefined) {\n  return value && /^\\d{4}-\\d{2}$/.test(value) ? calendarDateParts(`${value}-01`) : undefined\n}\n\nexport function localCalendarDate(date: Date): CalendarDate {\n  return `${String(date.getFullYear()).padStart(4, '0')}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`\n}\n\nexport function moveCalendarMonth(month: CalendarMonth, direction: -1 | 1): CalendarMonth | undefined {\n  const parts = calendarMonthParts(month)\n  if (!parts) return undefined\n  const date = new Date(parts.date)\n  date.setUTCMonth(date.getUTCMonth() + direction)\n  const year = date.getUTCFullYear()\n  if (year < 1 || year > 9999) return undefined\n  return `${String(year).padStart(4, '0')}-${String(date.getUTCMonth() + 1).padStart(2, '0')}`\n}\n\nexport function calendarMonthDays(month: CalendarMonth, weekStartsOn: number): Array<CalendarDate | undefined> {\n  const parts = calendarMonthParts(month)\n  if (!parts) return []\n  const offset = (parts.date.getUTCDay() - weekStartsOn + 7) % 7\n  return Array.from({ length: 42 }, (_, index) => {\n    const date = new Date(parts.date)\n    date.setUTCDate(1 + index - offset)\n    return date.getUTCMonth() === parts.month - 1 ? `${month}-${String(date.getUTCDate()).padStart(2, '0')}` : undefined\n  })\n}\n\nexport function calendarDateDisabled(date: CalendarDate, minimum?: CalendarDate, maximum?: CalendarDate) {\n  return !calendarDateParts(date) || !!(minimum && date < minimum) || !!(maximum && date > maximum)\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/calendar/calendar.utils.ts"
    },
    {
      "path": "packages/registry-native/components/calendar/index.ts",
      "content": "export { Calendar, type CalendarProps } from './Calendar'\nexport type { CalendarDate, CalendarMonth } from './calendar.utils'\n",
      "type": "registry:ui",
      "target": "~/components/ui/calendar/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/icon-button.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Gregorian month calendar with date-only selection, bounded navigation, localized labels, and scalable touch cells.",
  "categories": [
    "input",
    "date"
  ]
}