import { IconAlertCircle as AlertCircle, IconEye as Eye, IconEyeOff as EyeOff, IconKey as KeyRound, IconLock as LockKeyhole, IconMail as Mail, IconUser as UserRound, } from '@tabler/icons-react' import { useState } from 'react' import { t } from '@/shared/i18n' export interface FieldProps { name: string label: string value: string onInput?: (value: string) => void placeholder?: string type?: 'text' | 'email' | 'password' icon?: 'mail' | 'lock' | 'user' | 'key' helper?: string error?: string autoComplete?: string disabled?: boolean readOnly?: boolean maxLength?: number } const fieldIcons = { mail: Mail, lock: LockKeyhole, user: UserRound, key: KeyRound } export function Field({ name, label, value, onInput, placeholder, type = 'text', icon = 'mail', helper, error, autoComplete, disabled, readOnly, maxLength, }: FieldProps) { const [show, setShow] = useState(false) const Icon = fieldIcons[icon] const description = error || helper return (
onInput?.(event.currentTarget.value)} placeholder={placeholder} autoComplete={autoComplete} disabled={disabled} readOnly={readOnly} maxLength={maxLength} autoCapitalize="none" spellCheck={false} aria-invalid={!!error} aria-describedby={description ? `${name}-description` : undefined} className={`h-full min-w-0 flex-1 border-0 bg-transparent text-base text-ink outline-none placeholder:text-muted disabled:cursor-not-allowed ${type === 'email' ? 'font-latin' : ''} ${type === 'password' ? '' : 'pr-3'}`} /> {type === 'password' && ( )}
{description && (

{error && } {description}

)}
) }