import * as React from 'react'; import { cn } from '@/lib/utils'; import { useId, useState } from 'react'; import { Eye, EyeOff } from 'lucide-react'; export interface FloatingInputProps extends React.InputHTMLAttributes { label: string; error?: string; icon?: React.ReactNode; showPasswordToggle?: boolean; } const FloatingInput = React.forwardRef( ({ className, label, error, icon, type, id, showPasswordToggle, ...props }, ref) => { const generatedId = useId(); const inputId = id || generatedId; const [showPassword, setShowPassword] = useState(false); const inputType = type === 'password' && showPassword ? 'text' : type; const hasToggle = type === 'password' && showPasswordToggle; return (
{/* Icon */} {icon && (
{icon}
)} {/* Password visibility toggle */} {hasToggle && ( )} {/* Floating Label */}
{/* Error Message */} {error && (

{error}

)}
); } ); FloatingInput.displayName = 'FloatingInput'; export { FloatingInput };