import { Input, Textarea } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import React, { ForwardRefExoticComponent, RefAttributes } from 'react'; import { Button } from '../ui/button'; import { Eye, EyeOff, LucideProps } from 'lucide-react'; import { cn } from '@/lib/utils'; export default function LabeledInput({ type, label, subtext, placeholder, value, defaultValue, name, icon, variantSize = 'default', autocomplete, error, 'data-cy': dataCy, ...rest }: { label: string; subtext?: string; placeholder?: string; value?: string; name?: string; icon?: ForwardRefExoticComponent< Omit & RefAttributes >; variantSize?: 'default' | 'big' | 'textarea'; autocomplete?: string; error?: string; 'data-cy'?: string; } & React.InputHTMLAttributes) { const [passwordVisible, setPasswordVisible] = React.useState(false); const [inputValue, setInputValue] = React.useState( value || defaultValue || '', ); React.useEffect(() => { if (value !== undefined) { setInputValue(value); } }, [value]); const handleInputChange = (e: React.ChangeEvent) => { setInputValue(e.target.value); if (rest.onChange) { rest.onChange(e); } }; return (
{subtext && ( )} {variantSize === 'textarea' ? (