import React from 'react' import { createPortal } from 'react-dom' import { useFixedMenu } from '../hooks/use-fixed-menu' import { Tooltip } from './ui/tooltip' // Generic settings dropdown used across the prompt bar's control rows. // The menu is portaled to document.body so overflow-hidden ancestors // (react-resizable-panels) cannot clip it. export function SettingsDropdown({ trigger, options, value, onChange, title, tooltip, triggerClassName, placement = 'above', }: { trigger: React.ReactNode options: { value: string; label: string; disabled?: boolean; tooltip?: string; icon?: React.ReactNode }[] value: string onChange: (value: string) => void title: string tooltip?: string // Extra classes on the trigger button — e.g. to visually attach it to an adjacent button // as a split-button (rounded-l-none, no left padding, etc). triggerClassName?: string // Prompt-bar menus open upward; gallery toolbar menus open downward. placement?: 'above' | 'below' }) { const { isOpen, setIsOpen, triggerRef, menuRef, style } = useFixedMenu(placement) const triggerButton = ( ) return (
{tooltip && !isOpen ? {triggerButton} : triggerButton} {isOpen && createPortal(
{title}
{/* Cap height + scroll so a long option list (e.g. many catalog / custom IC-LoRAs) doesn't clip off-screen — matches the LoRA picker's max-h-80. */}
{options.map(option => (
{option.disabled && option.tooltip && (
{option.tooltip}
)}
))}
, document.body, )}
) }