import React, { forwardRef, useState } from "react"; import ContentEditable from "react-contenteditable"; import { HiOutlineEye, HiOutlineEyeSlash } from "react-icons/hi2"; import { twMerge } from "tailwind-merge"; interface InputProps extends React.InputHTMLAttributes { contentEditable?: boolean; prefix?: string; iconRight?: React.ReactNode; minHeight?: number; value?: string; errorMessage?: string; className?: string; onChange?: ( e: React.ChangeEvent, ) => void; onKeyDown?: (e: React.KeyboardEvent) => void; type?: string; } const Input = forwardRef( ( { contentEditable, errorMessage, prefix, value, onChange, onKeyDown, iconRight, className, type = "text", ...props }, ref, ) => { const [showPassword, setShowPassword] = useState(false); if (contentEditable) { return ( ); } return (
{prefix && (
{prefix}
)} {type === "password" && ( )} {iconRight && type !== "password" && (
{iconRight}
)}
{errorMessage && (
{errorMessage}
)}
); }, ); Input.displayName = "Input"; export default Input;