import React, {useEffect, useRef} from "react"; import clsx from "clsx"; type DropdownItemProps = { item: string; onClick: (item: string) => void; className?: string; } const DropdownItem = ({ item, onClick, className }: DropdownItemProps) => { return (
  • onClick(item)}> {item}
  • ); } type DropdownProps = { label: string; children: React.ReactNode; className?: string; } const Dropdown = ({ label, children, className }: DropdownProps) => { const [isOpen, setIsOpen] = React.useState(false); const ref = useRef(null); const toggleDropdown = () => { setIsOpen(!isOpen); }; useEffect(() => { function handleClickOutside(event: { target: any; }) { if (ref.current && !ref.current.contains(event.target)) { setIsOpen(false); } } document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, []); return (
    {isOpen && ( )}
    ); }; export { Dropdown, DropdownItem };