{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "schedule-01",
  "description": "Upcoming events grouped by day, as Today, Tomorrow and then weekdays, with the event in progress marked.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/schedule.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/schedule/schedule-01.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 {\n  EventRow,\n  type ScheduleEvent,\n  formatCountdown,\n  getDayOffset,\n  groupByDay,\n} from '@/registry/components/dashboardblocks/schedule'\nimport { formatDate } from '@/registry/lib/dashboardblocks/format'\nimport { useId } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Schedule1Props extends BlockStateProps {\n  days?: number\n  /** Leave out, or pass none, to show the empty state. */\n  events?: ScheduleEvent[]\n  now: Date\n  /** @default 'UTC' */\n  timeZone?: string\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 28, 9, 40)\nconst at = (day: number, hour: number, minute = 0) =>\n  new Date(Date.UTC(2026, 8, 28 + 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: Schedule1Props = {\n  events: [\n    {\n      ...CALENDARS.team,\n      end: at(0, 9, 15),\n      id: 'e1',\n      location: 'Zoom',\n      start: at(0, 9),\n      title: 'Daily standup',\n    },\n    {\n      ...CALENDARS.product,\n      end: at(0, 10, 30),\n      id: 'e2',\n      location: 'Room 4B',\n      start: at(0, 9, 30),\n      title: 'Roadmap review',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(0, 14, 45),\n      id: 'e3',\n      location: 'Google Meet',\n      start: at(0, 14),\n      title: 'Onboarding call with Northwind',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(1, 13),\n      id: 'e4',\n      location: 'Cafeteria',\n      start: at(1, 12),\n      title: 'Team lunch',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(1, 16, 30),\n      id: 'e5',\n      location: 'Zoom',\n      start: at(1, 15, 30),\n      title: 'Quarterly business review: Acme',\n    },\n    {\n      ...CALENDARS.product,\n      allDay: true,\n      id: 'e6',\n      start: at(2, 0),\n      title: 'v4.2 release',\n    },\n    {\n      ...CALENDARS.product,\n      end: at(2, 11),\n      id: 'e7',\n      location: 'Room 2A',\n      start: at(2, 10),\n      title: 'Design critique',\n    },\n    {\n      ...CALENDARS.team,\n      end: at(4, 17),\n      id: 'e8',\n      location: 'Zoom',\n      start: at(4, 16),\n      title: 'Sprint retro',\n    },\n    {\n      ...CALENDARS.customers,\n      end: at(9, 11),\n      id: 'e9',\n      start: at(9, 10),\n      title: 'Renewal call with Globex',\n    },\n  ],\n  now: new Date(NOW),\n  title: 'Upcoming',\n}\n\nconst Schedule1 = (props: Schedule1Props) => {\n  const {\n    days = 7,\n    events = [],\n    now,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n  } = props\n  const upcoming = events.filter((event) => {\n    const offset = getDayOffset(event.start, now, timeZone)\n    return offset >= 0 && offset < days\n  })\n  const groups = groupByDay(upcoming, now, timeZone)\n  const id = useId()\n  const next = upcoming\n    .filter((event) => !event.allDay && event.start > now)\n    .sort((a, b) => a.start.getTime() - b.start.getTime())[0]\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={getBlockState(status, events)}>\n      <Card>\n        <CardContent>\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                  {upcoming.length} {upcoming.length === 1 ? 'event' : 'events'} in the\n                  next {days} days.\n                  {next && (\n                    <>\n                      {' '}\n                      Next up is {next.title},{' '}\n                      {formatCountdown(next.start, now, timeZone)}.\n                    </>\n                  )}\n                </p>\n              </BlockReady>\n            </header>\n            {status || events.length === 0 ? (\n              <div className='border-t'>\n                <BlockStateRows rows={4} />\n              </div>\n            ) : groups.length === 0 ? (\n              <p className='text-muted-foreground border-t pt-3 text-sm'>\n                Nothing scheduled in the next {days} days.\n              </p>\n            ) : (\n              groups.map((group) => (\n                <section\n                  key={group.key}\n                  aria-labelledby={`${id}-${group.key}`}\n                  className='flex flex-col gap-3 border-t pt-3'\n                >\n                  <h3\n                    id={`${id}-${group.key}`}\n                    className='text-muted-foreground flex justify-between text-xs font-medium'\n                  >\n                    {group.label}\n                    {/* Not a count: the day's date */}\n                    <span className='font-normal tabular-nums'>\n                      {formatDate(group.day, 'day')}\n                    </span>\n                  </h3>\n                  <ul className='flex flex-col gap-3'>\n                    {group.events.map((event) => (\n                      <EventRow\n                        key={event.id}\n                        event={event}\n                        now={now}\n                        timeZone={timeZone}\n                      />\n                    ))}\n                  </ul>\n                </section>\n              ))\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Schedule1, exampleProps as schedule1ExampleProps, type Schedule1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/schedule/schedule-01.tsx"
    }
  ],
  "meta": {
    "shows": "Upcoming events grouped by day, as Today, Tomorrow and then weekdays, with the event in progress marked.",
    "size": "half",
    "usedWith": [
      "schedule-02",
      "calendar-01",
      "team-04"
    ],
    "component": "Schedule1",
    "props": "{ days?: number; events?: { allDay?: boolean; calendar?: string; color?: string; end?: Date; id: string; location?: string; start: Date; title: string }[]; now: Date; timeZone?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
