eolas-app/src/components/SearchInput.tsx
thomasabishop 7f9e227f6b
All checks were successful
Deploy eolas-app / deploy (push) Successful in 1m45s
feat: add search functionality
2025-12-11 19:17:37 +00:00

42 lines
1.6 KiB
TypeScript

import { Field } from "./ui/field"
import { Input } from "./ui/input"
import { Kbd } from "./ui/kbd"
export default function SearchInput({ form, inputRef }) {
return (
<>
<form className="w-full">
<form.Field
name="search"
children={(field) => {
return (
<Field>
<div className="relative">
<Input
ref={inputRef}
className="rounded-none [&::-webkit-search-cancel-button]:hidden"
id={field.name}
name={field.name}
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault()
form.handleSubmit()
}
}}
type="search"
placeholder="Search"
/>
<div className="absolute right-5 top-1 pointer-events-none">
{field.state.value ? <Kbd>Enter</Kbd> : <Kbd>Ctrl + K</Kbd>}
</div>
</div>
</Field>
)
}}
/>
</form>
</>
)
}