import { useState } from 'react'; import type { ReactElement, InputHTMLAttributes } from 'react'; import { Eye, EyeOff } from 'lucide-react'; import { cn } from '@/lib/utils'; interface FormFieldProps extends InputHTMLAttributes { label: string; required?: boolean; error?: string; helperText?: string; } export const FormField = ({ label, required = false, error, helperText, className, id, type, ...props }: FormFieldProps): ReactElement => { const fieldId = id || `field-${label.toLowerCase().replace(/\s+/g, '-')}`; const hasError = Boolean(error); const isPassword = type === 'password'; const [showPassword, setShowPassword] = useState(false); return (
{isPassword && ( )}
{error && ( )} {helperText && !error && (

{helperText}

)}
); };