import type { InputHTMLAttributes } from "react"; export interface InputProps extends Omit, "size"> { label?: string; error?: string; helperText?: string; fullWidth?: boolean; } export function Input({ label, error, helperText, fullWidth = false, className = "", id, ...props }: InputProps) { const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`; const errorId = error ? `${inputId}-error` : undefined; const helperId = helperText ? `${inputId}-helper` : undefined; const baseStyles = "px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors"; const widthStyles = fullWidth ? "w-full" : ""; const errorStyles = error ? "border-red-500 focus:ring-red-500" : "border-gray-300"; const combinedClassName = [baseStyles, widthStyles, errorStyles, className].filter(Boolean).join(" "); return (
{label && ( )} {error && ( )} {helperText && !error && (

{helperText}

)}
); }