import clsx from 'clsx' import {Search, X} from 'lucide-react' import {ComponentPropsWithoutRef, forwardRef, Ref, useState} from 'react' import {Row} from 'web/components/layout/row' /** Text input. Wraps html `` */ export const Input = forwardRef( ( props: { error?: boolean searchIcon?: boolean } & ComponentPropsWithoutRef<'input'>, ref: Ref, ) => { const {error, searchIcon, className, value, onChange, ...rest} = props const [hasValue, setHasValue] = useState(!!value) const rowClassName = clsx( 'bg-canvas-50 h-12 rounded-xl border border-canvas-200 px-4 shadow-sm transition-colors items-center gap-2', className, ) const handleChange = (e: React.ChangeEvent) => { setHasValue(!!e.target.value) onChange?.(e) } const handleClear = () => { setHasValue(false) // Trigger onChange with empty value const syntheticEvent = { target: {value: ''}, } as React.ChangeEvent onChange?.(syntheticEvent) } const elem = ( ) if (searchIcon) return ( {elem} {hasValue && ( )} ) return elem }, )