import React, { useId } from 'react'; import { X } from 'lucide-react'; interface FilledInputProps { label: string; value: string | number; onChange: (e: React.ChangeEvent) => void; onClear?: () => void; onFocus?: (e: React.FocusEvent) => void; onBlur?: (e: React.FocusEvent) => void; type?: string; icon?: React.ReactNode; autoFocus?: boolean; step?: string; inputMode?: "search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal"; autocapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters"; autoComplete?: string; rightElement?: React.ReactNode; multiline?: boolean; rows?: number; } const FilledInput: React.FC = ({ label, value, onChange, onClear, onFocus, onBlur, type = "number", icon, autoFocus, step, inputMode, autocapitalize, autoComplete, rightElement, multiline = false, rows = 3 }) => { const id = useId(); const inputRef = React.useRef(null); const handleClear = () => { const syntheticEvent = { target: { value: '' } } as React.ChangeEvent; onChange(syntheticEvent); if (onClear) onClear(); inputRef.current?.focus(); }; return (
{!multiline ? ( } id={id} type={type} step={step} inputMode={inputMode || (type === 'number' ? 'decimal' : 'text')} autoFocus={autoFocus} className={`w-full h-[56px] pt-5 pb-1 pl-4 bg-transparent text-body-lg text-on-surface focus:outline-none placeholder-transparent ${rightElement ? 'pr-20' : 'pr-10'}`} placeholder=" " value={value} onChange={onChange} onFocus={onFocus} onBlur={onBlur} autoCapitalize={autocapitalize} autoComplete={autoComplete} /> ) : (