import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { Control, FieldPath, FieldValues, useController, useFormState } from "react-hook-form"; import { useTranslation } from "../../locales/i18n.ts"; type SelectFieldProps = { control: Control; name: FieldPath; items: Array<{ value: string; label: string }>; label?: string; placeholder?: string; description?: string; disabled?: boolean; required?: boolean; readOnly?: boolean; className?: string; }; export function SelectField({ control, name, items, label, placeholder, description, disabled = false, required = false, readOnly = false, className, }: SelectFieldProps) { const { t } = useTranslation(); const { isSubmitting, isValidating } = useFormState({ control, name }); const { field, fieldState } = useController({ control, name }); const isDisabled = disabled || readOnly; return ( ( {label && (
{label} {required && ( {t("common.required")} )}
{/* Punto “unsaved” */} {fieldState.isDirty && ( {t("common.modified")} )}
)} {description || "\u00A0"}
)} /> ); }