{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar",
  "title": "Calendar",
  "author": "vmnog <https://vmnog.com>",
  "description": "The full calendar: a toolbar with the view switcher, today and previous/next, over day, week, month, year and agenda views, with keyboard shortcuts.",
  "registryDependencies": [
    "@calendarcn/calendar-header",
    "@calendarcn/time-grid",
    "@calendarcn/month-view",
    "@calendarcn/agenda-view",
    "@calendarcn/year-view"
  ],
  "files": [
    {
      "path": "src/components/calendar.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { useCalendarShortcuts } from \"@/hooks/use-calendar-shortcuts\";\nimport {\n  CalendarNavigation,\n  CalendarPeriodLabel,\n  CalendarViewSwitcher,\n} from \"@/components/calendar-header\";\n\nimport { AgendaView } from \"./agenda-view\";\nimport { CalendarProvider, useCalendar } from \"./calendar-provider\";\nimport { MonthView } from \"./month-view\";\nimport { TimeGrid } from \"./time-grid\";\nimport { YearView } from \"./year-view\";\nimport type { CalendarEvent, CalendarProviderProps } from \"./calendar-types\";\nimport type { CalendarProps } from \"./week-view-types\";\n\n/** Hour the time grid opens on unless `scrollToHour` says otherwise */\nconst DEFAULT_SCROLL_HOUR = 8;\n\n/**\n * The full calendar: a toolbar with the title, view switcher, today and\n * previous/next, over a day, week, month, year or agenda view. Takes every\n * `CalendarProvider` prop, so events, view and date can be controlled or\n * left to the calendar.\n */\nexport function Calendar<TEvent extends CalendarEvent = CalendarEvent>(\n  props: CalendarProps<TEvent>,\n) {\n  const {\n    scrollToHour = DEFAULT_SCROLL_HOUR,\n    shortcuts = true,\n    className,\n    children,\n  } = props;\n\n  // The provider reads only its own props, so the calendar's extra ones pass\n  // through harmlessly. Callers are type-checked against `CalendarProps<TEvent>`\n  // (which keeps `createEvent` required for custom event types); inside, the\n  // event type is erased, as CalendarProvider does itself, because TypeScript\n  // can't check JSX props against the generic conditional type.\n  const providerProps: CalendarProviderProps = {\n    ...(props as CalendarProviderProps),\n    children: (\n      <>\n        <CalendarShortcuts enabled={shortcuts} />\n        <div className={cn(\"flex h-full min-h-0 flex-col\", className)}>\n          <CalendarToolbar />\n          <div className=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n            <CalendarBody scrollToHour={scrollToHour} />\n          </div>\n        </div>\n        {children}\n      </>\n    ),\n  };\n\n  return <CalendarProvider {...providerProps} />;\n}\n\ninterface CalendarShortcutsProps {\n  enabled: boolean;\n}\n\n/** Turns on the single-key shortcuts. A component so the hook runs inside the provider */\nfunction CalendarShortcuts({ enabled }: CalendarShortcutsProps) {\n  useCalendarShortcuts({ enabled });\n  return null;\n}\n\n/**\n * Title, view switcher, today, and previous and next: a compact bar built\n * from the Calendar Header's parts\n */\nfunction CalendarToolbar() {\n  const { monthName, year } = useCalendar();\n\n  return (\n    <header className=\"@container/header flex h-12 shrink-0 items-center gap-1 border-b px-2 @md/header:gap-2 @md/header:px-3\">\n      <h2 className=\"min-w-0 flex-1 truncate text-sm @xs/header:text-base\">\n        <span className=\"font-semibold\">\n          {monthName} {year}\n        </span>\n        <CalendarPeriodLabel className=\"ml-2 hidden text-xs text-muted-foreground @lg/header:inline\" />\n      </h2>\n      <div className=\"hidden @xs/header:block\">\n        <CalendarViewSwitcher />\n      </div>\n      <CalendarNavigation buttonClassName=\"size-8\" />\n    </header>\n  );\n}\n\ninterface CalendarBodyProps {\n  scrollToHour: number;\n}\n\n/** The view the provider is on */\nfunction CalendarBody({ scrollToHour }: CalendarBodyProps) {\n  const { view } = useCalendar();\n\n  if (view === \"month\") {\n    return <MonthView />;\n  }\n\n  if (view === \"agenda\") {\n    return <AgendaView />;\n  }\n\n  if (view === \"year\") {\n    return <YearView />;\n  }\n\n  // One grid for day and week: switching re-lays it out instead of\n  // remounting, so the vertical scroll position is kept\n  return <TimeGrid view={view} scrollToHour={scrollToHour} />;\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Calendar: render <Calendar events={events} onEventsChange={setEvents} /> in an element with a height. It brings its own CalendarProvider. https://calendarcn.xyz/docs/installation#render-it",
  "categories": [
    "calendar",
    "blocks"
  ],
  "type": "registry:block"
}