"use client"; import { useId } from "react"; import { useTranslations } from "next-intl"; import { cn } from "@/shared/utils/cn"; interface SelectOption { value: string; label: string; } interface SelectProps extends Omit, "size"> { label?: React.ReactNode; options?: SelectOption[]; placeholder?: string; error?: React.ReactNode; hint?: React.ReactNode; selectClassName?: string; /** Keep the placeholder selectable after a real value is chosen. */ placeholderDisabled?: boolean; } export default function Select({ label, options = [], value, onChange, placeholder, error, hint, disabled = false, required = false, className, selectClassName, placeholderDisabled = true, id: externalId, children, ...props }: SelectProps) { const t = useTranslations("common"); const generatedId = useId(); const selectId = externalId || generatedId; const errorId = error ? `${selectId}-error` : undefined; const hintId = hint && !error ? `${selectId}-hint` : undefined; const describedBy = [errorId, hintId].filter(Boolean).join(" ") || undefined; return (
{label && ( )}
{error && ( )} {hint && !error && (

{hint}

)}
); }