Skip to content

Commit

Permalink
idontevenknowman
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman committed Dec 20, 2024
1 parent 88fe0fb commit 64c8b5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/SearchInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ForwardedRef, RefAttributes, ChangeEvent, HTMLAttributes, forwardRef, useCallback } from "react"
import { ForwardedRef, RefAttributes, ChangeEvent, forwardRef, useCallback, InputHTMLAttributes } from "react"

export type SearchValue<Keyword> = {
values: string[]
keywords: { keyword: Keyword; value: string }[]
raw: string
}

type Props<Keyword> = Omit<HTMLAttributes<HTMLInputElement>, "value" | "onChange"> & {
type Props<Keyword> = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> & {
value: SearchValue<Keyword>
onChange: (search: SearchValue<Keyword>) => void
}
Expand Down Expand Up @@ -42,7 +42,7 @@ export const EmptySearch: Readonly<SearchValue<unknown>> = {

function SearchInputComponent<Keyword>(
{ value, onChange, ...rest }: Props<Keyword> & RefAttributes<HTMLInputElement>,
ref: ForwardedRef<HTMLInputElement>
ref: ForwardedRef<HTMLInputElement>,
) {
const handleChange = useCallback(
(event: ChangeEvent<HTMLInputElement>) => {
Expand All @@ -52,7 +52,7 @@ function SearchInputComponent<Keyword>(
onChange(parseSearch(event.target.value) as SearchValue<Keyword>)
}
},
[onChange]
[onChange],
)

return <input {...rest} ref={ref} type="search" value={value.raw} onChange={handleChange} />
Expand Down

0 comments on commit 64c8b5e

Please sign in to comment.