'use client' import React from 'react' export type InputType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' export interface InputProps extends Omit, 'type' | 'size'> { type?: InputType label?: string error?: string helperText?: string fullWidth?: boolean leftIcon?: React.ReactNode rightIcon?: React.ReactNode } export const Input = React.forwardRef( ( { type = 'text', label, error, helperText, fullWidth = false, leftIcon, rightIcon, className = '', id, required, disabled, ...props }, ref ) => { const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}` const errorId = `${inputId}-error` const helperId = `${inputId}-helper` const hasError = Boolean(error) const baseInputStyles = 'block w-full rounded-md border transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-offset-0' const normalStyles = 'border-gray-300 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white' const errorStyles = 'border-error-500 focus:border-error-500 focus:ring-error-500' const disabledStyles = 'disabled:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60 dark:disabled:bg-gray-900' const paddingStyles = leftIcon || rightIcon ? 'px-10 py-2' : 'px-4 py-2' const inputClassName = `${baseInputStyles} ${hasError ? errorStyles : normalStyles} ${disabledStyles} ${paddingStyles} ${className}`.trim() const containerWidth = fullWidth ? 'w-full' : '' return (
{label && ( )}
{leftIcon && (
{leftIcon}
)} {rightIcon && (
{rightIcon}
)} {hasError && (
)}
{error && ( )} {helperText && !error && (

{helperText}

)}
) } ) Input.displayName = 'Input'