import { cn } from "@/utils/helpers"; import { Eye, EyeOff } from "lucide-react"; import * as React from "react"; import { useState } from "react"; export interface InputProps extends React.InputHTMLAttributes { customPrefix?: React.ReactNode; customSuffix?: React.ReactNode; maxWidthClass?: string; icon?: React.ReactNode; error?: string; prefixClassName?: string; showPasswordToggle?: boolean; variant?: "default" | "darker"; } const variantStyles = { default: [ "bg-nb-gray-900 placeholder:text-neutral-400/70 border-nb-gray-700", "ring-offset-neutral-950/50 focus-visible:ring-neutral-500/20", ], darker: [ "bg-nb-gray-920 placeholder:text-neutral-400/70 border-nb-gray-800", "ring-offset-neutral-950/50 focus-visible:ring-neutral-500/20", ], error: [ "bg-nb-gray-900 placeholder:text-neutral-400/70 border-red-500 text-red-500", "ring-offset-red-500/10 focus-visible:ring-red-500/10", ], }; const prefixSuffixStyles = { default: "bg-nb-gray-900 border-nb-gray-700 text-nb-gray-300", error: "bg-nb-gray-900 border-red-500 text-nb-gray-300 text-red-500", }; const Input = React.forwardRef( ( { className, type, customSuffix, customPrefix, icon, maxWidthClass = "", error, variant = "default", prefixClassName, showPasswordToggle = false, ...props }, ref ) => { const [showPassword, setShowPassword] = useState(false); const isPasswordType = type === "password"; const inputType = isPasswordType && showPassword ? "text" : type; const passwordToggle = isPasswordType && showPasswordToggle ? ( ) : null; const suffix = passwordToggle || customSuffix; const activeVariant = error ? "error" : variant; return ( <>
{customPrefix && (
{customPrefix}
)}
{icon}
{suffix}
{error && (

{error}

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