{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-menu",
  "title": "Command Menu",
  "description": "The live demo's ⌘K menu: today, previous/next and the views, plus your app's panel, theme and .ics commands.",
  "registryDependencies": [
    "@calendarcn/calendar-core",
    "command",
    "dialog",
    "kbd"
  ],
  "files": [
    {
      "path": "src/components/command-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { useCalendar } from \"@/components/calendar-provider\";\nimport {\n  Command,\n  CommandEmpty,\n  CommandGroup,\n  CommandInput,\n  CommandItem,\n  CommandList,\n} from \"@/components/ui/command\";\nimport {\n  Dialog,\n  DialogContent,\n  DialogDescription,\n  DialogTitle,\n} from \"@/components/ui/dialog\";\nimport { Kbd, KbdGroup } from \"@/components/ui/kbd\";\n\n/** Reusable \"Soon\" badge for unimplemented command items */\nconst SOON_BADGE = (\n  <span className=\"bg-muted text-muted-foreground ml-auto rounded px-1.5 py-0.5 text-[10px] leading-none font-medium\">\n    Soon\n  </span>\n);\n\n/**\n * The menu's look, on the dialog: translucent and blurred in dark mode, and\n * a gap between groups. `data-command-menu` on the same element lets the CSS\n * that ships with the menu dim the page less in dark mode.\n */\nconst DIALOG_CLASS =\n  \"overflow-hidden p-0 dark:bg-popover/60 dark:backdrop-blur-xl dark:border-border/50 dark:[&_[data-slot=command]]:bg-transparent [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-2\";\n\n/** Taller input and items, and padded group headings, as shadcn/ui's CommandDialog has them */\nconst COMMAND_CLASS =\n  \"**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\";\n\n/** One command of the menu */\ninterface MenuCommand {\n  label: string;\n  /** Shortcut keys shown on the right, e.g. [\"⌘\", \"/\"] */\n  keys?: string[];\n  /** Runs the command once the menu has closed. Missing when the app doesn't offer it */\n  run?: () => void;\n  /** Not built yet: listed disabled with a \"Soon\" badge, only with `showComingSoon` */\n  soon?: boolean;\n}\n\n/** A titled group of commands */\ninterface MenuGroup {\n  heading: string;\n  commands: MenuCommand[];\n}\n\ninterface CommandMenuProps {\n  /** Whether the menu is open */\n  open: boolean;\n  /** Called when the menu opens or closes, including after a command runs */\n  onOpenChange: (open: boolean) => void;\n  /** Adds \"Toggle sidebar\" (⌘ /) */\n  onToggleSidebar?: () => void;\n  /** Adds \"Toggle context panel\" (/) */\n  onToggleContextPanel?: () => void;\n  /** Adds \"Set theme...\" (Shift M) */\n  onCycleTheme?: () => void;\n  /** Adds \"Import .ics file...\" */\n  onImportIcs?: () => void;\n  /** Adds \"Export .ics file\" */\n  onExportIcs?: () => void;\n  /**\n   * Also lists the Notion Calendar commands CalendarCN doesn't have yet,\n   * disabled with a \"Soon\" badge, as the live demo does\n   */\n  showComingSoon?: boolean;\n}\n\n/**\n * The live demo's ⌘K menu. Going to today, previous and next, and the views\n * come from `useCalendar()`, so it goes inside `CalendarProvider`. Commands\n * that belong to your app (panels, theme, .ics files) show only when you pass\n * their callback. Open it with `useCalendarShortcuts({ onToggleCommandMenu })`.\n */\nexport function CommandMenu({\n  open,\n  onOpenChange,\n  onToggleSidebar,\n  onToggleContextPanel,\n  onCycleTheme,\n  onImportIcs,\n  onExportIcs,\n  showComingSoon = false,\n}: CommandMenuProps) {\n  const { goToToday, goToPrev, goToNext, switchView } = useCalendar();\n\n  const runCommand = React.useCallback(\n    (command: () => void) => {\n      onOpenChange(false);\n      command();\n    },\n    [onOpenChange],\n  );\n\n  const groups: MenuGroup[] = [\n    {\n      heading: \"Calendar\",\n      commands: [\n        { label: \"Create event...\", soon: true },\n        { label: \"Meet with...\", soon: true },\n        { label: \"Show teammate calendar...\", soon: true },\n        { label: \"Create recurring scheduling link...\", soon: true },\n        { label: \"Create one-off scheduling link...\", soon: true },\n        { label: \"Import .ics file...\", run: onImportIcs },\n        { label: \"Export .ics file\", run: onExportIcs },\n      ],\n    },\n    {\n      heading: \"Navigation\",\n      commands: [\n        { label: \"Go to date...\", soon: true },\n        { label: \"Go to today\", keys: [\"T\"], run: goToToday },\n        { label: \"Go to next week\", keys: [\"K\"], run: goToNext },\n        { label: \"Go to previous week\", keys: [\"J\"], run: goToPrev },\n        { label: \"Search events\", soon: true },\n      ],\n    },\n    {\n      heading: \"Time zones\",\n      commands: [\n        { label: \"Travel to time zone...\", soon: true },\n        { label: \"Show additional time zones...\", soon: true },\n      ],\n    },\n    {\n      heading: \"App\",\n      commands: [\n        { label: \"Toggle sidebar\", keys: [\"⌘\", \"/\"], run: onToggleSidebar },\n        { label: \"Set theme...\", keys: [\"shift\", \"M\"], run: onCycleTheme },\n      ],\n    },\n    {\n      heading: \"View\",\n      commands: [\n        { label: \"Start week on...\", soon: true },\n        {\n          label: \"Display day view\",\n          keys: [\"D\"],\n          run: () => switchView(\"day\"),\n        },\n        {\n          label: \"Display week view\",\n          keys: [\"W\"],\n          run: () => switchView(\"week\"),\n        },\n        {\n          label: \"Display month view\",\n          keys: [\"M\"],\n          run: () => switchView(\"month\"),\n        },\n        {\n          label: \"Display year view\",\n          keys: [\"Y\"],\n          run: () => switchView(\"year\"),\n        },\n        {\n          label: \"Display agenda view\",\n          keys: [\"A\"],\n          run: () => switchView(\"agenda\"),\n        },\n        { label: \"Set number of displayed days...\", soon: true },\n        { label: \"Select all visible\", soon: true },\n        { label: \"Default hour size\", soon: true },\n        { label: \"Zoom hours in\", soon: true },\n        { label: \"Zoom hours out\", soon: true },\n        { label: \"Hide weekends\", soon: true },\n        { label: \"Hide declined events\", soon: true },\n        { label: \"Hide week numbers\", soon: true },\n      ],\n    },\n    {\n      heading: \"Settings & help\",\n      commands: [\n        { label: \"Get CalendarCN mobile app\", soon: true },\n        { label: \"Show keyboard shortcuts\", soon: true },\n        { label: \"Go to settings\", soon: true },\n        { label: \"Support & feedback\", soon: true },\n      ],\n    },\n    {\n      heading: \"Accounts\",\n      commands: [\n        { label: \"Add Google Calendar account\", soon: true },\n        { label: \"Manage calendar accounts\", soon: true },\n        { label: \"Log out\", soon: true },\n      ],\n    },\n    {\n      heading: \"CalendarCN\",\n      commands: [\n        { label: \"Check for update\", soon: true },\n        { label: \"About CalendarCN\", soon: true },\n      ],\n    },\n    {\n      heading: \"Panels\",\n      commands: [\n        {\n          label: \"Toggle context panel\",\n          keys: [\"/\"],\n          run: onToggleContextPanel,\n        },\n      ],\n    },\n  ];\n\n  return (\n    <Dialog open={open} onOpenChange={onOpenChange}>\n      <DialogContent\n        showCloseButton={false}\n        data-command-menu=\"\"\n        className={DIALOG_CLASS}\n      >\n        <DialogTitle className=\"sr-only\">Command Menu</DialogTitle>\n        <DialogDescription className=\"sr-only\">\n          Search for a command to run...\n        </DialogDescription>\n        <Command className={COMMAND_CLASS}>\n          <CommandInput placeholder=\"Type a command...\" />\n          <CommandList>\n            <CommandEmpty>No results found.</CommandEmpty>\n            {groups.map((group) => {\n              const commands = group.commands.filter((command) =>\n                command.soon ? showComingSoon : command.run !== undefined,\n              );\n              if (commands.length === 0) return null;\n\n              return (\n                <CommandGroup key={group.heading} heading={group.heading}>\n                  {commands.map(({ label, keys, run, soon }) => (\n                    <CommandItem\n                      key={label}\n                      disabled={soon}\n                      onSelect={run ? () => runCommand(run) : undefined}\n                    >\n                      {label}\n                      {soon && SOON_BADGE}\n                      {keys && (\n                        <KbdGroup className=\"ml-auto\">\n                          {keys.map((key) => (\n                            <Kbd key={key}>{key}</Kbd>\n                          ))}\n                        </KbdGroup>\n                      )}\n                    </CommandItem>\n                  ))}\n                </CommandGroup>\n              );\n            })}\n          </CommandList>\n\n          <div className=\"border-t px-3 py-2 flex items-center gap-4 text-xs text-muted-foreground\">\n            <span className=\"flex items-center gap-1\">\n              <span className=\"text-muted-foreground/70\">↑↓</span> Navigate\n            </span>\n            <span className=\"flex items-center gap-1\">\n              <span className=\"text-muted-foreground/70\">↵</span> Select\n            </span>\n            <span className=\"flex items-center gap-1\">\n              <Kbd>esc</Kbd> Close\n            </span>\n          </div>\n        </Command>\n      </DialogContent>\n    </Dialog>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {
    ".dark [data-slot=\"dialog-overlay\"]:has(~ [data-command-menu])": {
      "background-color": "rgb(0 0 0 / 0.3)"
    }
  },
  "type": "registry:component"
}