import { useId, useState, type ComponentProps, type ReactNode } from 'react' import { Eye, EyeOff } from 'lucide-react' import type { FieldError } from 'react-hook-form' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { cn } from '@/lib/utils' /** * Etiket + giriş alanı + (varsa) hata/ipucu metni. * Erişilebilirlik: hata `aria-invalid` ve `aria-describedby` ile alana bağlanır, * ekran okuyucu alanı odaklayınca hatayı okur. */ export function FormField({ label, error, hint, className, children, }: { label: string error?: FieldError hint?: string className?: string /** Alanı üreten fonksiyon: kimlik ve aria özelliklerini alır */ children: (field: { id: string 'aria-invalid': boolean 'aria-describedby'?: string }) => ReactNode }) { const id = useId() const messageId = `${id}-message` const message = error?.message ?? hint return (
{children({ id, 'aria-invalid': !!error, 'aria-describedby': message ? messageId : undefined, })} {message && (

{message}

)}
) } /** Şifre alanı: göster/gizle düğmeli. */ export function PasswordInput(props: ComponentProps) { const [visible, setVisible] = useState(false) return (
) } /** Sunucudan gelen, belirli bir alana ait olmayan hata (ör. "E-posta veya şifre hatalı"). */ export function FormError({ message }: { message?: string }) { if (!message) return null return (

{message}

) }