import { FormControl, FormField, FormItem, FormLabel, FormMessage, Input, } from "@repo/shadcn-ui/components"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { Control, FieldPath, FieldValues } from "react-hook-form"; import { useTranslation } from "../../locales/i18n.ts"; type TextFieldProps = { control: Control; name: FieldPath; label?: string; placeholder?: string; description?: string; disabled?: boolean; required?: boolean; readOnly?: boolean; className?: string; icon?: React.ReactNode; // Icono con tamaño: iconPosition?: "left" | "right"; // 'left' por defecto }; export function TextField({ control, name, label, placeholder, description, disabled = false, required = false, readOnly = false, className, icon, iconPosition = "left", }: TextFieldProps) { const { t } = useTranslation(); const isDisabled = disabled || readOnly; const hasIcon = Boolean(icon); const isLeft = iconPosition === "left"; const inputPadding = hasIcon ? (isLeft ? "pl-10" : "pr-10") : ""; const { getFieldState } = control; const state = getFieldState(name); return ( ( {label && (
{label} {required && {t("common.required")}}
)}
{hasIcon && ( )}

{description || "\u00A0"}

)} /> ); }