// DatePickerField.tsx import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Textarea, } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { Control, FieldPath, FieldValues, useController } from "react-hook-form"; import { useTranslation } from "../../locales/i18n.ts"; import { CommonInputProps } from "./types.js"; type TextAreaFieldProps = CommonInputProps & { control: Control; name: FieldPath; label?: string; placeholder?: string; description?: string; disabled?: boolean; required?: boolean; readOnly?: boolean; className?: string; /** Contador de caracteres (si usas maxLength) */ showCounter?: boolean; }; export function TextAreaField({ control, name, label, placeholder, description, disabled = false, required = false, readOnly = false, className, showCounter = false, maxLength, }: TextAreaFieldProps) { const { t } = useTranslation(); const isDisabled = disabled || readOnly; const { field, fieldState } = useController({ control, name }); const describedById = description ? `${name}-desc` : undefined; const errorId = fieldState.error ? `${name}-err` : undefined; const valueLength = (field.value?.length ?? 0) as number; return ( ( {label && (
{label} {required && ( {t("common.required")} )}
{/* Punto “unsaved” */} {fieldState.isDirty && ( {t("common.modified")} )}
)}