"use client"; import { useState } from "react"; import Link from "next/link"; import { ChevronDown } from "lucide-react"; import { cn } from "@/lib/utils"; interface DropdownItem { label: string; href: string; description?: string; } interface DropdownSection { title?: string; items: DropdownItem[]; } interface NavDropdownProps { label: string; triggerHref?: string; sections: DropdownSection[]; align?: "left" | "center" | "right"; } export function NavDropdown({ label, triggerHref, sections, align = "center" }: NavDropdownProps) { const [isOpen, setIsOpen] = useState(false); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Escape") { setIsOpen(false); } }; return (
setIsOpen(true)} onMouseLeave={() => setIsOpen(false)} onKeyDown={handleKeyDown} >
{triggerHref ? ( {label} ) : ( {label} )}
{/* Dropdown Panel */}
{sections.map((section, sIdx) => (
{section.title && (

{section.title}

)}
    {section.items.map((item, iIdx) => (
  • setIsOpen(false)} > {item.label} {item.description && ( {item.description} )}
  • ))}
))}
); }