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 (
{message}
)}{message}
) }