import clsx from "clsx" import React, { ChangeEventHandler, FocusEventHandler, useEffect, useImperativeHandle, useRef, useState, } from "react" import EyeIcon from "../../fundamentals/icons/eye-icon" import EyeOffIcon from "../../fundamentals/icons/eye-off-icon" import LockIcon from "../../fundamentals/icons/lock-icon" type InputProps = React.InputHTMLAttributes & { key?: string onChange?: ChangeEventHandler onFocus?: FocusEventHandler props?: React.HTMLAttributes } const SigninInput = React.forwardRef( ( { placeholder, name, key, onChange, onFocus, className, type, ...props }: InputProps, ref ) => { const inputRef = useRef(null) const [showPassword, setShowPassword] = useState(false) const [inputType, setInputType] = useState(type) useEffect(() => { if (type === "password" && showPassword) { setInputType("text") } if (type === "password" && !showPassword) { setInputType("password") } }, [type, showPassword]) useImperativeHandle(ref, () => inputRef.current) return (
{type === "password" && ( )} {props.readOnly && ( )}
) } ) SigninInput.displayName = "SigninInput" export default SigninInput