import { Fragment, useRef, useState } from "react"; import { observer } from "mobx-react-lite"; import { ChevronDown, LucideIcon } from "lucide-react"; // headless ui import { Combobox } from "@headlessui/react"; // helpers import { cn } from "@/helpers/common.helper"; // hooks import { useMember } from "@/hooks/store"; import { useDropdown } from "@/hooks/use-dropdown"; // components import { DropdownButton } from "../buttons"; import { BUTTON_VARIANTS_WITH_TEXT } from "../constants"; import { ButtonAvatars } from "./avatar"; // constants import { MemberOptions } from "./member-options"; // types import { MemberDropdownProps } from "./types"; type Props = { projectId?: string; icon?: LucideIcon; onClose?: () => void; } & MemberDropdownProps; export const MemberDropdown: React.FC = observer((props) => { const { button, buttonClassName, buttonContainerClassName, buttonVariant, className = "", disabled = false, dropdownArrow = false, dropdownArrowClassName = "", hideIcon = false, multiple, onChange, onClose, placeholder = "Members", tooltipContent, placement, projectId, showTooltip = false, tabIndex, value, icon, } = props; // states const [isOpen, setIsOpen] = useState(false); // refs const dropdownRef = useRef(null); // popper-js refs const [referenceElement, setReferenceElement] = useState(null); const { getUserDetails } = useMember(); // eslint-disable-next-line @typescript-eslint/no-explicit-any const comboboxProps: any = { value, onChange, disabled, }; if (multiple) comboboxProps.multiple = true; const { handleClose, handleKeyDown, handleOnClick } = useDropdown({ dropdownRef, isOpen, onClose, setIsOpen, }); const dropdownOnChange = (val: string & string[]) => { onChange(val); if (!multiple) handleClose(); }; return ( {button ? ( ) : ( )} {isOpen && ( )} ); });