({
placeholder,
className,
shallow = true,
}: {
placeholder: string;
className?: string;
shallow?: boolean;
})
| 5 | import { SearchField } from "./ui/search-field"; |
| 6 | |
| 7 | export function SearchInput({ |
| 8 | placeholder, |
| 9 | className, |
| 10 | shallow = true, |
| 11 | }: { |
| 12 | placeholder: string; |
| 13 | className?: string; |
| 14 | shallow?: boolean; |
| 15 | }) { |
| 16 | const [search, setSearch] = useQueryState("q", { |
| 17 | defaultValue: "", |
| 18 | shallow, |
| 19 | }); |
| 20 | |
| 21 | const handleClear = () => setSearch(""); |
| 22 | |
| 23 | return ( |
| 24 | <SearchField |
| 25 | placeholder={placeholder} |
| 26 | value={search} |
| 27 | onChange={setSearch} |
| 28 | onClear={handleClear} |
| 29 | onKeyDown={(e) => { |
| 30 | if (e.key === "Escape") handleClear(); |
| 31 | }} |
| 32 | className={cn("w-full", className)} |
| 33 | /> |
| 34 | ); |
| 35 | } |
nothing calls this directly
no test coverage detected