// src/components/SearchInput.tsx // Copyright (C) 2026 Robert Colbert // All Rights Reserved import { useState } from "react"; import { Search, X } from "lucide-react"; interface SearchInputProps { placeholder?: string; onSearch: (query: string) => void; onClear?: () => void; className?: string; } export default function SearchInput({ placeholder = "Search…", onSearch, onClear, className = "", }: SearchInputProps) { const [value, setValue] = useState(""); const handleChange = (e: React.ChangeEvent) => { const v = e.target.value; setValue(v); if (!v.trim()) { onClear?.(); } }; const handleClear = () => { setValue(""); onClear?.(); }; const handleSubmit = () => { if (value.trim()) onSearch(value.trim()); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") handleSubmit(); if (e.key === "Escape") handleClear(); }; return (
{value && ( <> )}
); }