{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "menu-recent-items",
  "title": "Menu Recent Items",
  "description": "A Recent menu built from a changing list that never shows empty: one disabled line explains an empty history and Clear recent sits apart and disables itself.",
  "registryDependencies": [
    "button",
    "dropdown-menu"
  ],
  "files": [
    {
      "path": "registry/patterns/menu-recent-items/menu-recent-items.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ClockIcon } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuItem,\n  DropdownMenuLabel,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from \"@/components/ui/dropdown-menu\"\n\nexport interface RecentItem {\n  id: string\n  label: string\n}\n\nexport interface MenuRecentItemsProps {\n  items: RecentItem[]\n  onOpen: (id: string) => void\n  onClear: () => void\n}\n\n/**\n * A \"Recent\" menu built from a list that changes. The first item is Open\n * recent's most recent entry, an empty history shows one disabled line that\n * says so (the menu is never empty), and Clear recent sits apart at the end\n * and is disabled when there is nothing to clear.\n */\nexport function MenuRecentItems({\n  items,\n  onOpen,\n  onClear,\n}: MenuRecentItemsProps) {\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger asChild>\n        <Button variant=\"outline\">\n          <ClockIcon aria-hidden=\"true\" /> Recent\n        </Button>\n      </DropdownMenuTrigger>\n      <DropdownMenuContent align=\"start\" className=\"w-56\">\n        <DropdownMenuLabel>Open recent</DropdownMenuLabel>\n        {items.length === 0 ? (\n          <DropdownMenuItem disabled>No recent items</DropdownMenuItem>\n        ) : (\n          items.map((item) => (\n            <DropdownMenuItem key={item.id} onSelect={() => onOpen(item.id)}>\n              {item.label}\n            </DropdownMenuItem>\n          ))\n        )}\n        <DropdownMenuSeparator />\n        <DropdownMenuItem disabled={items.length === 0} onSelect={onClear}>\n          Clear recent\n        </DropdownMenuItem>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}