import React, { useMemo, useState } from 'react'; import { Wrench } from 'lucide-react'; import { Root, Trigger, Content, Portal } from '@radix-ui/react-popover'; import type { TPlugin } from 'librechat-data-provider'; import MenuItem from '~/components/Chat/Menus/UI/MenuItem'; import { useMultiSearch } from './MultiSearch'; import { cn } from '~/utils/'; type SelectDropDownProps = { 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; searchPlaceholder?: string; }; function MultiSelectPop({ title: _title = 'Plugins', value, setSelected, availableValues, showAbove = false, showLabel = true, containerClassName, isSelected, optionValueKey = 'value', searchPlaceholder, }: SelectDropDownProps) { // const localize = useLocalize(); const title = _title; const excludeIds = ['select-plugin', 'plugins-label', 'selected-plugins']; // Detemine if we should to convert this component into a searchable select const [filteredValues, searchRender] = useMultiSearch({ availableOptions: availableValues, placeholder: searchPlaceholder, getTextKeyOverride: (option) => (option.name || '').toUpperCase(), }); const hasSearchRender = Boolean(searchRender); const options = hasSearchRender ? filteredValues : availableValues; return (
{searchRender} {options.map((option) => { if (!option) { return null; } const selected = isSelected(option[optionValueKey]); return ( setSelected(option.pluginKey)} icon={ option.icon ? ( {`${option.name} ) : ( ) } /> ); })}
); } export default MultiSelectPop;