import { Icon, IconButton, Input, InputGroup, InputLeftElement, InputRightElement, useControllableState } from '@chakra-ui/react'; import React from 'react'; import { TbCircleX } from 'react-icons/tb'; import { useTranslation } from 'react-i18next'; interface SearchInputProps { icon: React.ReactNode; placeholder: string; value?: string; onChange?: (value: string) => void; onClear?: () => void; } const SearchInput: React.FC = ({ placeholder, icon, value, onChange, onClear }) => { const [controlledValue, setControlledValue] = useControllableState({ value, onChange, defaultValue: '' }); const { t } = useTranslation(); return ( setControlledValue(e.target.value)} /> {value === '' ? null : ( } variant="unstyled" onClick={() => { setControlledValue('') onClear && onClear() }} /> )} ); }; export default SearchInput;