{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "notifications-dropdown", "title": "Notifications Dropdown", "description": "Navbar dropdown for displaying notifications with icons and text.", "registryDependencies": [ "https://raw.githubusercontent.com/dnachavez/adminlte-next/master/public/r/adminlte-theme.json", "https://raw.githubusercontent.com/dnachavez/adminlte-next/master/public/r/adminlte-dropdown.json", "https://raw.githubusercontent.com/dnachavez/adminlte-next/master/public/r/adminlte-badge.json" ], "files": [ { "path": "registry/new-york/notifications-dropdown/components/notifications-dropdown.tsx", "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/registry/new-york/adminlte-theme/lib/cn\"\n\ninterface Notification {\n id: string | number\n icon: React.ReactNode\n text: string\n href?: string\n}\n\ninterface NotificationsDropdownProps\n extends React.HTMLAttributes {\n notifications: Notification[]\n count?: number\n onViewAll?: () => void\n}\n\nconst NotificationsDropdown = React.forwardRef<\n HTMLDivElement,\n NotificationsDropdownProps\n>(({ className, notifications, count, onViewAll, ...props }, ref) => {\n const [isOpen, setIsOpen] = React.useState(false)\n const containerRef = React.useRef(null)\n\n const displayCount = count ?? notifications.length\n\n React.useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (\n containerRef.current &&\n !containerRef.current.contains(e.target as Node)\n ) {\n setIsOpen(false)\n }\n }\n if (isOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside)\n }\n return () => document.removeEventListener(\"mousedown\", handleClickOutside)\n }, [isOpen])\n\n return (\n {\n ;(\n containerRef as React.MutableRefObject\n ).current = node\n if (typeof ref === \"function\") ref(node)\n else if (ref) ref.current = node\n }}\n className={cn(\"relative inline-block\", className)}\n {...props}\n >\n setIsOpen(!isOpen)}\n className=\"relative flex items-center justify-center w-[50px] h-[50px] bg-transparent border-none text-[var(--adminlte-skin-navbar-color)] cursor-pointer hover:bg-black/10\"\n aria-label=\"Notifications\"\n >\n {/* Bell icon */}\n \n \n \n {displayCount > 0 && (\n \n {displayCount}\n \n )}\n \n\n {isOpen && (\n
    \n
  • \n You have {displayCount} notifications\n
  • \n {notifications.map((notification) => (\n
  • \n \n \n {notification.icon}\n \n {notification.text}\n \n
  • \n ))}\n
  • \n {\n e.preventDefault()\n onViewAll?.()\n }}\n className=\"text-[14px] text-[#3c8dbc] no-underline hover:underline\"\n >\n View all\n \n
  • \n
\n )}\n \n )\n})\nNotificationsDropdown.displayName = \"NotificationsDropdown\"\n\nexport { NotificationsDropdown }\nexport type { NotificationsDropdownProps, Notification }\n", "type": "registry:component" } ], "type": "registry:component" }