| 1 | import Form from "next/form"; |
| 2 | import { Search } |
| 3 | |
| 4 | import { |
| 5 | InputGroup, |
| 6 | InputGroupAddon, |
| 7 | InputGroupInput, |
| 8 | } from "@/components/ui/input-group"; |
| 9 | |
| 10 | export function SearchForm({ |
| 11 | action, |
| 12 | placeholder, |
| 13 | query = "", |
| 14 | type = null, |
| 15 | autoFocus, |
| 16 | className, |
| 17 | }: { |
| 18 | action: string |
| 19 | placeholder: string |
| 20 | query?: string |
| 21 | type?: string |
| 22 | autoFocus?: boolean |
| 23 | className?: string |
| 24 | }) { |
| 25 | return ( |
| 26 | <Form action={ |
| 27 | {type && <input |
| 28 | <InputGroup> |
| 29 | <InputGroupAddon> |
| 30 | <Search /> |
| 31 | </InputGroupAddon> |
| 32 | <InputGroupInput |
| 33 | key={query} |
| 34 | type="search" |
| 35 | name="q" |
| 36 | required |
| 37 | defaultValue={query} |
| 38 | placeholder={placeholder} |
| 39 | aria-label={placeholder} |
| 40 | autoFocus={autoFocus} |
| 41 | /> |
| 42 | </InputGroup> |
| 43 | </Form> |
| 44 | ); |
| 45 | } |