import * as Menu from '@ariakit/react/menu'; import { ChevronDown } from 'lucide-react'; import { Input, Label, SecretInput, DropdownPopup } from '@librechat/client'; import type { SearchApiKeyFormData } from '~/hooks/Plugins/useAuthSearchTool'; import type { UseFormRegister } from 'react-hook-form'; import type { MenuItemProps } from '~/common'; interface InputConfig { placeholder: string; type?: 'text' | 'password'; link?: { url: string; text: string; }; } interface DropdownOption { key: string; label: string; inputs?: Record; } interface InputSectionProps { title: string; selectedKey: string; onSelectionChange: (key: string) => void; dropdownOptions: DropdownOption[]; showDropdown: boolean; register: UseFormRegister; dropdownOpen: boolean; setDropdownOpen: (open: boolean) => void; dropdownKey: string; } export default function InputSection({ title, selectedKey, onSelectionChange, dropdownOptions, showDropdown, register, dropdownOpen, setDropdownOpen, dropdownKey, }: InputSectionProps) { const selectedOption = dropdownOptions.find((opt) => opt.key === selectedKey); const dropdownItems: MenuItemProps[] = dropdownOptions.map((option) => ({ label: option.label, onClick: () => onSelectionChange(option.key), })); return (
{showDropdown ? ( setDropdownOpen(!dropdownOpen)} className="flex items-center gap-1.5 whitespace-nowrap rounded-lg border border-border-light px-3 py-1.5 text-sm text-text-secondary transition-colors hover:bg-surface-hover" > {selectedOption?.label}
{selectedOption?.inputs && (
{Object.entries(selectedOption.inputs).map(([name, config]) => (
{config.type === 'password' ? ( ) : ( )} {config.link && ( {config.link.text} )}
))}
)}
); } export type { InputConfig, DropdownOption };