{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar-01",
  "description": "A month grid of team events, launches, travel and holidays, with the selected day listed beside it.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/calendar.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/schedule.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/calendar/calendar-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  BlockStateText,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  type CalendarEvent,\n  CalendarLegend,\n  CalendarMonthView,\n  CalendarToolbar,\n  getEventDays,\n  getEventsForDay,\n  startOfMonth,\n} from '@/registry/components/dashboardblocks/calendar'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { EventRow, getDay } from '@/registry/components/dashboardblocks/schedule'\nimport { formatDate, formatDayHeading } from '@/registry/lib/dashboardblocks/format'\nimport { useId, useState } from 'react'\n\ninterface Calendar1Props extends BlockStateProps {\n  calendars: { color: string; name: string }[]\n  /** Leave out, or pass none, to show the empty state. */\n  events?: CalendarEvent[]\n  now: Date\n  onSelectDay?: (day: Date) => void\n  onSelectEvent?: (event: CalendarEvent) => void\n  /** @default 'UTC' */\n  timeZone?: string\n  /** 0 for Sunday, 1 for Monday. */\n  weekStartsOn?: 0 | 1\n}\n\nconst NOW = Date.UTC(2026, 8, 28, 9, 40)\nconst at = (month: number, day: number, hour = 0, minute = 0) =>\n  new Date(Date.UTC(2026, month, day, hour, minute))\n\nconst CALENDARS = {\n  customers: { calendar: 'Customers', color: 'var(--color-chart-3)' },\n  holidays: { calendar: 'Holidays', color: 'var(--color-chart-5)' },\n  launches: { calendar: 'Launches', color: 'var(--color-chart-2)' },\n  team: { calendar: 'Team', color: 'var(--color-chart-4)' },\n  travel: { calendar: 'Travel', color: 'var(--color-chart-1)' },\n}\n\nconst teamSyncs: CalendarEvent[] = Array.from({ length: 9 }, (_, week) => ({\n  ...CALENDARS.team,\n  end: at(8, 1 + week * 7, 10, 45),\n  id: `sync-${week}`,\n  location: 'Zoom',\n  start: at(8, 1 + week * 7, 10),\n  title: 'Team sync',\n}))\n\nconst exampleProps: Calendar1Props = {\n  calendars: Object.values(CALENDARS).map(({ calendar, color }) => ({\n    color,\n    name: calendar,\n  })),\n  events: [\n    ...teamSyncs,\n    {\n      ...CALENDARS.team,\n      allDay: true,\n      end: at(8, 3),\n      id: 'offsite',\n      location: 'Sonoma',\n      start: at(8, 1),\n      title: 'Q4 planning offsite',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 3, 17, 30),\n      id: 'hooli',\n      location: 'Google Meet',\n      start: at(8, 3, 17),\n      title: 'Demo for Hooli',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 4, 17),\n      id: 'retro-1',\n      start: at(8, 4, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.holidays,\n      allDay: true,\n      id: 'labor-day',\n      start: at(8, 7),\n      title: 'Labor Day',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 9, 11),\n      id: 'initech',\n      location: 'Zoom',\n      start: at(8, 9, 10),\n      title: 'Kickoff with Initech',\n    },\n    {\n      ...CALENDARS.launches,\n      allDay: true,\n      id: 'v41',\n      start: at(8, 10),\n      title: 'v4.1 release',\n    },\n    {\n      ...CALENDARS.travel,\n      allDay: true,\n      end: at(8, 18),\n      id: 'saastr',\n      location: 'San Mateo, CA',\n      start: at(8, 15),\n      title: 'SaaStr Annual',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 16, 21),\n      id: 'stark',\n      location: 'Pausa, San Mateo',\n      start: at(8, 16, 19),\n      title: 'Dinner with Stark Industries',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 18, 17),\n      id: 'retro-2',\n      start: at(8, 18, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.team,\n      allDay: true,\n      end: at(8, 26),\n      id: 'priya-ooo',\n      start: at(8, 21),\n      title: 'Priya out of office',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 22, 15),\n      id: 'umbrella',\n      location: 'Zoom',\n      start: at(8, 22, 14),\n      title: 'Security review with Umbrella',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 24, 13, 30),\n      id: 'lunch',\n      location: 'Tartine Manufactory',\n      start: at(8, 24, 12, 30),\n      title: 'Team lunch',\n    },\n    {\n      ...CALENDARS.launches,\n      allDay: true,\n      end: at(8, 30),\n      id: 'freeze',\n      start: at(8, 28),\n      title: 'v4.2 code freeze',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 28, 10, 30),\n      id: 'roadmap',\n      location: 'Room 4B',\n      start: at(8, 28, 9, 30),\n      title: 'Roadmap review',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 28, 14, 45),\n      id: 'northwind',\n      location: 'Google Meet',\n      start: at(8, 28, 14),\n      title: 'Northwind onboarding',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 28, 17),\n      id: 'hiring',\n      location: 'Room 2A',\n      start: at(8, 28, 16),\n      title: 'Hiring panel: Staff engineer',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 29, 16, 30),\n      id: 'acme',\n      location: 'Zoom',\n      start: at(8, 29, 15, 30),\n      title: 'Acme QBR',\n    },\n    {\n      ...CALENDARS.launches,\n      allDay: true,\n      id: 'v42',\n      start: at(8, 30),\n      title: 'v4.2 release',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(9, 2, 17),\n      id: 'retro-3',\n      start: at(9, 2, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.travel,\n      allDay: true,\n      end: at(9, 9),\n      id: 'london',\n      location: 'London',\n      start: at(9, 6),\n      title: 'Customer visits, London',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(9, 7, 11),\n      id: 'globex',\n      location: 'Globex, Canary Wharf',\n      start: at(9, 7, 10),\n      title: 'Globex renewal',\n    },\n    {\n      ...CALENDARS.holidays,\n      allDay: true,\n      id: 'indigenous-peoples-day',\n      start: at(9, 12),\n      title: \"Indigenous Peoples' Day\",\n    },\n    {\n      ...CALENDARS.team,\n      end: at(9, 16, 17),\n      id: 'retro-4',\n      start: at(9, 16, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.launches,\n      allDay: true,\n      id: 'pricing',\n      start: at(9, 21),\n      title: 'New pricing live',\n    },\n  ],\n  now: new Date(NOW),\n}\n\nconst Calendar1 = (props: Calendar1Props) => {\n  const {\n    calendars,\n    events: data = [],\n    now,\n    onSelectDay,\n    onSelectEvent,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    weekStartsOn = 0,\n  } = props\n  const state = getBlockState(status, data)\n  const events = state ? [] : data\n  const today = getDay(now, timeZone)\n  const [month, setMonth] = useState(() => startOfMonth(today))\n  const [selectedDay, setSelectedDay] = useState(today)\n  const [selectedEventId, setSelectedEventId] = useState<string>()\n  const id = useId()\n\n  const monthLabel = formatDate(month, 'month-long-year')\n  const monthEvents = events.filter((event) => {\n    const { first, last } = getEventDays(event, timeZone)\n    return first < startOfMonth(month, 1) && last >= month\n  })\n  const todayEvents = getEventsForDay(events, today, timeZone)\n  const showsToday = today >= month && today < startOfMonth(month, 1)\n  const dayEvents = getEventsForDay(events, selectedDay, timeZone)\n  const relative = formatDayHeading(selectedDay, today)\n\n  const selectDay = (day: Date) => {\n    setSelectedDay(day)\n    setSelectedEventId(undefined)\n    onSelectDay?.(day)\n  }\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <section className='@container flex flex-col gap-4 [--calendar-surface:var(--color-background)]'>\n        <CalendarToolbar\n          title={monthLabel}\n          description={\n            state ? (\n              <BlockStateText />\n            ) : (\n              `${monthEvents.length} ${monthEvents.length === 1 ? 'event' : 'events'} in ${formatDate(month, 'month-long')}${showsToday ? `, ${todayEvents.length} of them today` : ''}.`\n            )\n          }\n          onToday={() => {\n            setMonth(startOfMonth(today))\n            selectDay(today)\n          }}\n          onPrevious={() => setMonth(startOfMonth(month, -1))}\n          onNext={() => setMonth(startOfMonth(month, 1))}\n          previousLabel='Previous month'\n          nextLabel='Next month'\n        />\n        <div className='grid gap-6 @4xl:grid-cols-[minmax(0,1fr)_16rem]'>\n          <CalendarMonthView\n            events={events}\n            label={monthLabel}\n            month={month}\n            now={now}\n            onMonthChange={setMonth}\n            onSelectDay={selectDay}\n            onSelectEvent={(event) => {\n              setSelectedDay(getEventDays(event, timeZone).first)\n              setSelectedEventId(event.id)\n              onSelectEvent?.(event)\n            }}\n            selectedDay={selectedDay}\n            selectedEventId={selectedEventId}\n            timeZone={timeZone}\n            weekStartsOn={weekStartsOn}\n          />\n          <section\n            aria-labelledby={id}\n            className='flex min-w-0 flex-col gap-3 border-t pt-4 @4xl:border-t-0 @4xl:border-l @4xl:pt-0 @4xl:pl-6'\n          >\n            <h3\n              id={id}\n              aria-live='polite'\n              className='flex flex-col gap-0.5 px-2 text-sm font-medium'\n            >\n              {formatDate(selectedDay, 'weekday-long-day')}\n              <Details className='text-muted-foreground font-normal'>\n                {['Today', 'Tomorrow', 'Yesterday'].includes(relative) && relative}\n                {!state &&\n                  `${dayEvents.length} ${dayEvents.length === 1 ? 'event' : 'events'}`}\n              </Details>\n            </h3>\n            {state ? (\n              state === 'loading' && <BlockStateRows className='px-2' rows={3} />\n            ) : dayEvents.length === 0 ? (\n              <p className='text-muted-foreground px-2 text-sm'>Nothing scheduled.</p>\n            ) : (\n              <ul className='flex flex-col gap-1'>\n                {dayEvents.map((event) => (\n                  <EventRow\n                    key={event.id}\n                    event={event}\n                    now={now}\n                    timeZone={timeZone}\n                    selected={event.id === selectedEventId}\n                    className='rounded-md px-2 py-1.5'\n                  />\n                ))}\n              </ul>\n            )}\n          </section>\n        </div>\n        {!state && <CalendarLegend calendars={calendars} />}\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport { Calendar1, exampleProps as calendar1ExampleProps, type Calendar1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/calendar/calendar-01.tsx"
    }
  ],
  "meta": {
    "shows": "A month grid of team events, launches, travel and holidays, with the selected day listed beside it.",
    "size": "full",
    "usedWith": [
      "calendar-02",
      "schedule-01"
    ],
    "component": "Calendar1",
    "props": "{ calendars: { color: string; name: string }[]; events?: { attendees?: { avatar?: string; name: string }[]; description?: string; resource?: string; allDay?: boolean; calendar?: string; color?: string; end?: Date; id: string; location?: string; start: Date; title: string }[]; now: Date; onSelectDay?: (day: Date) => void; onSelectEvent?: (event: { attendees?: { avatar?: string; name: string }[]; description?: string; resource?: string; allDay?: boolean; calendar?: string; color?: string; end?: Date; id: string; location?: string; start: Date; title: string }) => void; timeZone?: string; weekStartsOn?: 0 | 1; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
