import { FC } from "react"; import { twMerge } from "tailwind-merge"; import { observer } from "mobx-react-lite"; import { ChevronDown, X } from "lucide-react"; // hooks import { useModule } from "hooks/store"; // ui and components import { DiceIcon, Tooltip } from "@plane/ui"; // types import { TModuleSelectButton } from "./types"; export const ModuleSelectButton: FC = observer((props) => { const { value, onChange, placeholder, buttonClassName, buttonVariant, hideIcon, hideText, dropdownArrow, dropdownArrowClassName, showTooltip, showCount, } = props; // hooks const { getModuleById } = useModule(); return (
{value && typeof value === "string" ? (
{!hideIcon && } {!hideText && ( {getModuleById(value)?.name || placeholder} )}
) : value && Array.isArray(value) && value.length > 0 ? ( showCount ? (
{!hideIcon && } {!hideText && ( {value.length} Modules )}
) : ( value.map((moduleId) => { const _module = getModuleById(moduleId); if (!_module) return <>; return (
{!hideIcon && } {!hideText && ( {_module?.name} )}
{ e.preventDefault(); e.stopPropagation(); onChange(_module.id); }} >
); }) ) ) : ( !hideText && (
{!hideIcon && } {!hideText && ( {placeholder} )}
) )}
{dropdownArrow && (
); });