"use client"; import { useState, useRef, useEffect } from "react"; import { motion, AnimatePresence } from "motion/react"; import { ChevronDown } from "lucide-react"; import { cls } from "@/lib/utils"; interface DropdownMenuProps { options: { label: string; value: string }[]; value?: string; onChange?: (value: string) => void; placeholder?: string; className?: string; } const DropdownMenu = ({ options, value, onChange, placeholder = "Select...", className = "" }: DropdownMenuProps) => { const [isOpen, setIsOpen] = useState(false); const ref = useRef(null); const selected = options.find((o) => o.value === value); useEffect(() => { const handleClickOutside = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setIsOpen(false); }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); return (
{isOpen && ( {options.map((option) => ( ))} )}
); }; export default DropdownMenu;