import React, { useEffect, useRef } from 'react'; import { Search, X } from 'lucide-react'; import { cn } from '../../lib/utils'; type Props = { value: string; onChange: (v: string) => void; placeholder?: string; autoFocus?: boolean; }; export function SearchBar({ value, onChange, placeholder = 'Search models...', autoFocus = true, }: Props) { const inputRef = useRef(null); useEffect(() => { if (autoFocus && inputRef.current) { setTimeout(() => { inputRef.current?.focus(); }, 100); } }, [autoFocus]); return (
onChange(e.target.value)} className={cn( 'w-full h-11 pl-10 pr-10 rounded-xl', 'bg-muted/50 border border-border/50', 'text-sm placeholder:text-muted-foreground/70', 'focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/50', 'transition-all duration-200' )} /> {value && ( )}
); }