-
Notifications
You must be signed in to change notification settings - Fork 552
Expand file tree
/
Copy pathAutocompleteSearch.tsx
More file actions
43 lines (39 loc) · 1.15 KB
/
AutocompleteSearch.tsx
File metadata and controls
43 lines (39 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { createAutocompleteSearchComponent } from 'instantsearch-ui-components';
import React, { createElement, Fragment } from 'react';
import type { ComponentProps, Pragma } from 'instantsearch-ui-components';
const AutocompleteSearchComponent = createAutocompleteSearchComponent({
createElement: createElement as Pragma,
Fragment,
});
export type AutocompleteSearchProps = {
inputProps: ComponentProps<'input'>;
clearQuery: () => void;
onQueryChange?: (query: string) => void;
query: string;
isSearchStalled: boolean;
onAiModeClick?: () => void;
};
export function AutocompleteSearch({
inputProps,
clearQuery,
onQueryChange,
query,
isSearchStalled,
onAiModeClick,
}: AutocompleteSearchProps) {
return (
<AutocompleteSearchComponent
inputProps={{
...(inputProps as NonNullable<AutocompleteSearchProps['inputProps']>),
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.currentTarget.value;
onQueryChange?.(value);
},
}}
onClear={clearQuery}
query={query}
isSearchStalled={isSearchStalled}
onAiModeClick={onAiModeClick}
/>
);
}