import React, { useState, useRef } from 'react'; import { Listbox, Transition } from '@headlessui/react'; import { Wrench, ArrowRight } from 'lucide-react'; import { CheckMark } from '~/components/svg'; import useOnClickOutside from '~/hooks/useOnClickOutside'; import { cn } from '~/utils/'; import type { TPlugin } from 'librechat-data-provider'; export type TMultiSelectDropDownProps = { title?: string; value: Array<{ icon?: string; name?: string; isButton?: boolean }>; disabled?: boolean; setSelected: (option: string) => void; availableValues: TPlugin[]; showAbove?: boolean; showLabel?: boolean; containerClassName?: string; isSelected: (value: string) => boolean; className?: string; optionValueKey?: string; }; function MultiSelectDropDown({ title = 'Plugins', value, disabled, setSelected, availableValues, showAbove = false, showLabel = true, containerClassName, isSelected, className, optionValueKey = 'value', }: TMultiSelectDropDownProps) { const [isOpen, setIsOpen] = useState(false); const menuRef = useRef(null); const excludeIds = ['select-plugin', 'plugins-label', 'selected-plugins']; useOnClickOutside(menuRef, () => setIsOpen(false), excludeIds); const handleSelect: (value: string) => void = (option) => { setSelected(option); setIsOpen(true); }; const transitionProps = { className: 'top-full mt-3' }; if (showAbove) { transitionProps.className = 'bottom-full mb-3'; } const openProps = { open: isOpen }; return (