import { type ComponentPropsWithRef, type FC, useEffect, useState } from 'react'; import { cn } from '@wener/console'; import { useEvent } from '@wener/reaction'; export const SearchInput: FC< { initialValue?: string; onValueChange?: (v: string) => void; } & Omit, 'value'> > = ({ initialValue = '', onValueChange, ...props }) => { const [value, setValue] = useState(() => initialValue || ''); useEffect(() => { if (!value) { setValue(initialValue || ''); } }, [initialValue]); return ( setValue(e.target.value))} onKeyDown={useEvent((e) => { if (e.key === 'Enter') { onValueChange?.(value); } })} {...props} /> ); };