import React, { forwardRef } from 'react'; interface FormInputProps extends Omit, 'size'> { label?: string; error?: string; hint?: string; /** Size variant */ inputSize?: 'sm' | 'md' | 'lg'; /** Full width */ fullWidth?: boolean; /** Icon to display on the left */ leftIcon?: React.ReactNode; /** Icon to display on the right */ rightIcon?: React.ReactNode; /** Container class name */ containerClassName?: string; } const sizeClasses = { sm: 'px-2 py-1 text-sm', md: 'px-3 py-2', lg: 'px-4 py-3 text-lg', }; export const FormInput = forwardRef( ( { label, error, hint, inputSize = 'md', fullWidth = true, leftIcon, rightIcon, containerClassName = '', className = '', id, ...props }, ref ) => { const inputId = id || props.name || `input-${Math.random().toString(36).substr(2, 9)}`; const baseClasses = 'border rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-brand-500 focus:border-brand-500 transition-colors'; const stateClasses = error ? 'border-red-500 dark:border-red-500 focus:ring-red-500 focus:border-red-500' : 'border-gray-300 dark:border-gray-600'; const disabledClasses = props.disabled ? 'bg-gray-100 dark:bg-gray-800 cursor-not-allowed opacity-60' : ''; const widthClass = fullWidth ? 'w-full' : ''; return (
{label && ( )}
{leftIcon && (
{leftIcon}
)} {rightIcon && (
{rightIcon}
)}
{error && (

{error}

)} {hint && !error && (

{hint}

)}
); } ); FormInput.displayName = 'FormInput'; export default FormInput;