"use client"; import { InputHTMLAttributes, forwardRef, useState, ReactNode } from "react"; import { EyeIcon, EyeSlashIcon, ExclamationCircleIcon } from "@heroicons/react/24/outline"; interface InputProps extends InputHTMLAttributes { label?: string; error?: string; helperText?: string; leftIcon?: ReactNode; rightIcon?: 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 && ( )}
{leftIcon && (
{leftIcon}
)} {isPassword && ( )} {!isPassword && rightIcon && ( )}
{error && (

{error}

)} {helperText && !error && (

{helperText}

)}
); } ); Input.displayName = "Input"; export default Input;