import { ChevronDown } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { useTranslation } from '@/i18n/useI18n.ts';
interface Props {
/** Currently selected dimension. */
value?: number | null;
/** Allowed dimensions. ``null`` means no model picked yet. */
options: number[] | null;
onChange?: (dimension: number) => void;
disabled?: boolean;
}
/**
* Dimension picker for embedding models. Renders:
*
* - a placeholder when no model is selected;
* - a read-only badge when only one dimension is allowed
* (fixed-dim model, or matryoshka narrowed by server policy);
* - a dropdown when multiple dimensions are allowed (matryoshka
* under an ``ANY`` policy).
*/
export function DimensionSelect({ value, options, onChange, disabled }: Props) {
const { t } = useTranslation();
if (options === null || options.length === 0) {
return (
{t('dimension-select.pickModelFirst')}
);
}
if (options.length === 1) {
return (
{options[0]}d
);
}
const display = value != null ? `${value}d` : t('dimension-select.placeholder');
return (
{options.map((dim) => (
onChange?.(dim)}>
{dim}d
))}
);
}