import type { FC } from 'react' import { useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { RiSearchLine } from '@remixicon/react' import cn from '@/utils/classnames' import { XCircle } from '@/app/components/base/icons/src/vender/solid/general' type SearchInputProps = { placeholder?: string className?: string value: string onChange: (v: string) => void white?: boolean } const SearchInput: FC = ({ placeholder, className, value, onChange, white, }) => { const { t } = useTranslation() const [focus, setFocus] = useState(false) const isComposing = useRef(false) return (
{ if (!isComposing.current) onChange(e.target.value) }} onCompositionStart={() => { isComposing.current = true }} onCompositionEnd={() => { isComposing.current = false }} onFocus={() => setFocus(true)} onBlur={() => setFocus(false)} autoComplete="off" /> {value && (
onChange('')} >
)}
) } export default SearchInput