import classNames from "classnames"; import { forwardRef } from "react"; const SIZE = ["m", "l"] as const; type Props = { className?: string; id?: string; name?: string; isInvalid?: boolean; value?: string; size?: (typeof SIZE)[number]; fullWidth?: boolean; onChange: (event: React.ChangeEvent) => void; placeholder?: string; onSubmit?: () => void; maxLength?: number; autoComplete?: boolean; autoFocus?: boolean; }; export const VuiTextInput = forwardRef( ( { className, id, placeholder, value, size = "m", onChange, fullWidth, onSubmit, isInvalid, name, autoComplete, autoFocus, ...rest }: Props, ref ) => { const classes = classNames( "vuiInput", "vuiInput--text", `vuiInput--${size}`, { "vuiInput-isInvalid": isInvalid, "vuiInput--fullWidth": fullWidth }, className ); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); e.stopPropagation(); onSubmit?.(); } }; return ( ); } );