import { type InputHTMLAttributes, type Ref, useId } from "react"; export interface InputProps extends InputHTMLAttributes { label?: string; helper?: string; error?: string; ref?: Ref; } export const Input = ({ ref, label, helper, error, id, className = "", ...rest }: InputProps) => { const generated = useId(); const inputId = id ?? generated; const helperId = helper ? `${inputId}-helper` : undefined; const errorId = error ? `${inputId}-error` : undefined; const describedBy = [helperId, errorId].filter(Boolean).join(" ") || undefined; return (
{label ? ( ) : null} {error ? (

{error}

) : helper ? (

{helper}

) : null}
); };