{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "schedule-02",
  "description": "A month calendar with a dot on each day that has events, and a list of the events on the selected day.",
  "registryDependencies": [
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/schedule.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/schedule/schedule-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport {\n  EventRow,\n  MonthCalendar,\n  type ScheduleEvent,\n  getDay,\n} from '@/registry/components/dashboardblocks/schedule'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport {\n  dayIn,\n  formatDate,\n  formatDayHeading,\n} from '@/registry/lib/dashboardblocks/format'\nimport { useId, useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\n\ninterface Schedule2Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  events?: ScheduleEvent[]\n  now: Date\n  onSelect?: (day: Date) => void\n  /** @default 'UTC' */\n  timeZone?: string\n  title: 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: number, 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  product: { calendar: 'Product', color: 'var(--color-chart-2)' },\n  team: { calendar: 'Team', color: 'var(--color-chart-4)' },\n}\n\nconst exampleProps: Schedule2Props = {\n  events: [\n    {\n      ...CALENDARS.team,\n      end: at(8, 2, 17),\n      id: 'c1',\n      start: at(8, 2, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 9, 11),\n      id: 'c2',\n      start: at(8, 9, 10),\n      title: 'Kickoff with Initech',\n    },\n    {\n      ...CALENDARS.product,\n      end: at(8, 15, 12),\n      id: 'c3',\n      start: at(8, 15, 11),\n      title: 'Pricing workshop',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 16, 17),\n      id: 'c4',\n      start: at(8, 16, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 22, 15),\n      id: 'c5',\n      start: at(8, 22, 14),\n      title: 'Security review with Umbrella',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(8, 28, 9, 15),\n      id: 'c6',\n      location: 'Zoom',\n      start: at(8, 28, 9),\n      title: 'Daily standup',\n    },\n    {\n      ...CALENDARS.product,\n      end: at(8, 28, 10, 30),\n      id: 'c7',\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: 'c8',\n      location: 'Google Meet',\n      start: at(8, 28, 14),\n      title: 'Onboarding call with Northwind',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(8, 29, 16, 30),\n      id: 'c9',\n      location: 'Zoom',\n      start: at(8, 29, 15, 30),\n      title: 'Quarterly business review: Acme',\n    },\n    {\n      ...CALENDARS.product,\n      allDay: true,\n      id: 'c10',\n      start: at(8, 30, 0),\n      title: 'v4.2 release',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(9, 2, 17),\n      id: 'c11',\n      start: at(9, 2, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(9, 7, 11),\n      id: 'c12',\n      start: at(9, 7, 10),\n      title: 'Renewal call with Globex',\n    },\n    {\n      ...CALENDARS.product,\n      end: at(9, 13, 15),\n      id: 'c13',\n      start: at(9, 13, 13),\n      title: 'Planning: Q4 roadmap',\n    },\n    {\n      ...CALENDARS.team,\n      allDay: true,\n      id: 'c14',\n      start: at(9, 16, 0),\n      title: 'Company offsite',\n    },\n  ],\n  now: new Date(NOW),\n  title: 'Calendar',\n}\n\nconst monthOf = (day: Date) =>\n  new Date(Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), 1))\n\nconst Schedule2 = (props: Schedule2Props) => {\n  const {\n    events = [],\n    now,\n    onSelect,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n    weekStartsOn = 0,\n  } = props\n  const ready = !status && events.length > 0\n  const [selected, setSelected] = useState(() => getDay(now, timeZone))\n  const [month, setMonth] = useState(() => monthOf(getDay(now, timeZone)))\n  const id = useId()\n\n  const monthLabel = formatDate(month, 'month-long-year')\n  const monthKey = month.toISOString().slice(0, 7)\n  const monthCount = events.filter(\n    (event) => dayIn(event.start, timeZone).slice(0, 7) === monthKey,\n  ).length\n  const selectedKey = selected.toISOString().slice(0, 10)\n  const dayEvents = events\n    .filter((event) => dayIn(event.start, timeZone) === selectedKey)\n    .sort((a, b) => a.start.getTime() - b.start.getTime())\n  const selectedLabel = formatDayHeading(selected, getDay(now, timeZone))\n  const showMonth = (months: number) =>\n    setMonth(new Date(Date.UTC(month.getUTCFullYear(), month.getUTCMonth() + months, 1)))\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={getBlockState(status, events)}>\n      <section className='@container flex flex-col gap-4'>\n        <header className='flex flex-col gap-0.5'>\n          <h2 className='font-semibold tracking-tight'>{title}</h2>\n          <BlockReady className='text-sm'>\n            <p className='text-muted-foreground text-sm'>\n              {monthCount} {monthCount === 1 ? 'event' : 'events'} in{' '}\n              {formatDate(month, 'month-long')}.\n            </p>\n          </BlockReady>\n        </header>\n        <div className='grid gap-6 border-t pt-4 @xl:grid-cols-[18rem_minmax(0,1fr)]'>\n          <div className='flex flex-col gap-2'>\n            <div className='flex items-center justify-between gap-2'>\n              <h3 id={id} aria-live='polite' className='text-sm font-medium'>\n                {monthLabel}\n              </h3>\n              <div className='flex gap-1'>\n                <Button\n                  variant='ghost'\n                  size='icon-sm'\n                  aria-label='Previous month'\n                  onClick={() => showMonth(-1)}\n                >\n                  <IconPlaceholder\n                    lucide='ChevronLeftIcon'\n                    tabler='IconChevronLeft'\n                    hugeicons='ArrowLeft01Icon'\n                    phosphor='CaretLeftIcon'\n                    remixicon='RiArrowLeftSLine'\n                  />\n                </Button>\n                <Button\n                  variant='ghost'\n                  size='icon-sm'\n                  aria-label='Next month'\n                  onClick={() => showMonth(1)}\n                >\n                  <IconPlaceholder\n                    lucide='ChevronRightIcon'\n                    tabler='IconChevronRight'\n                    hugeicons='ArrowRight01Icon'\n                    phosphor='CaretRightIcon'\n                    remixicon='RiArrowRightSLine'\n                  />\n                </Button>\n              </div>\n            </div>\n            <MonthCalendar\n              events={ready ? events : []}\n              label={monthLabel}\n              month={month}\n              now={now}\n              onMonthChange={setMonth}\n              onSelect={(day) => {\n                setSelected(day)\n                onSelect?.(day)\n              }}\n              selected={selected}\n              timeZone={timeZone}\n              weekStartsOn={weekStartsOn}\n            />\n          </div>\n          <section\n            aria-labelledby={`${id}-day`}\n            className='flex min-w-0 flex-col gap-3 border-t pt-4 @xl:border-t-0 @xl:border-l @xl:pt-0 @xl:pl-6'\n          >\n            <h3 id={`${id}-day`} className='flex flex-col gap-0.5 text-sm font-medium'>\n              {selectedLabel}\n              <Details className='text-muted-foreground font-normal'>\n                {formatDate(selected, 'weekday-day')}\n                {ready &&\n                  `${dayEvents.length} ${dayEvents.length === 1 ? 'event' : 'events'}`}\n              </Details>\n            </h3>\n            {!ready ? (\n              <BlockStateRows rows={3} />\n            ) : dayEvents.length === 0 ? (\n              <p className='text-muted-foreground text-sm'>Nothing scheduled.</p>\n            ) : (\n              <ul className='flex flex-col gap-3'>\n                {dayEvents.map((event) => (\n                  <EventRow key={event.id} event={event} now={now} timeZone={timeZone} />\n                ))}\n              </ul>\n            )}\n          </section>\n        </div>\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport { Schedule2, exampleProps as schedule2ExampleProps, type Schedule2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/schedule/schedule-02.tsx"
    }
  ],
  "meta": {
    "shows": "A month calendar with a dot on each day that has events, and a list of the events on the selected day.",
    "size": "full",
    "usedWith": [
      "schedule-01",
      "schedule-03"
    ],
    "component": "Schedule2",
    "props": "{ events?: { allDay?: boolean; calendar?: string; color?: string; end?: Date; id: string; location?: string; start: Date; title: string }[]; now: Date; onSelect?: (day: Date) => void; timeZone?: string; title: string; weekStartsOn?: 0 | 1; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
