import { Button } from '@/components/ui/button'; import { SearchInput } from '@/components/ui/input'; import { cn } from '@/lib/utils'; import { Search, X } from 'lucide-react'; import { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; interface ExpandableSearchInputProps { value: string; onChange: (value: string) => void; placeholder?: string; className?: string; inputClassName?: string; width?: number | string; } export function ExpandableSearchInput({ value, onChange, placeholder, className, inputClassName, width = 192, }: ExpandableSearchInputProps) { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); const handleToggle = useCallback(() => { setIsOpen((prev) => { const next = !prev; if (!next) { onChange(''); } return next; }); }, [onChange]); const handleChange = useCallback( (e: React.ChangeEvent) => { onChange(e.target.value); }, [onChange], ); return (
) : null } />
{!isOpen && ( )}
); }