"use client"; import { InputHTMLAttributes, forwardRef, useState, ReactNode } from "react"; import { EyeIcon, EyeSlashIcon } from '@heroicons/react/24/outline'; interface InputProps extends InputHTMLAttributes { label?: string; error?: string; helperText?: ReactNode; leftIcon?: string | ReactNode; rightIcon?: string | ReactNode; onRightIconClick?: () => void; } const Input = forwardRef( ( { label, error, helperText, leftIcon, rightIcon, onRightIconClick, className = "", type, ...props }, ref ) => { const [showPassword, setShowPassword] = useState(false); const isPassword = type === "password"; const inputType = isPassword ? (showPassword ? "text" : "password") : type; return ( {label && ( {label} {props.required && *} )} {leftIcon && ( {typeof leftIcon === 'string' ? ( ) : ( {leftIcon} )} )} {isPassword && ( setShowPassword(!showPassword)} className="absolute right-3.5 top-1/2 -translate-y-1/2 text-zinc-500 hover:text-zinc-900 dark:text-gray-400 dark:hover:text-white transition-colors cursor-pointer" > {showPassword ? ( ) : ( )} )} {!isPassword && rightIcon && ( {typeof rightIcon === 'string' ? ( ) : ( {rightIcon} )} )} {error && ( {error} )} {helperText && !error && ( {helperText} )} ); } ); Input.displayName = "Input"; export default Input;
{error}
{helperText}