|
1 | 1 | /* eslint-disable @typescript-eslint/no-explicit-any */
|
2 |
| -import { GetItemPropsOptions, UseComboboxStateChange } from 'downshift'; |
| 2 | +import { GetItemPropsOptions, UseComboboxProps } from 'downshift'; |
3 | 3 | import { ReactNode } from 'react';
|
4 | 4 | import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
5 | 5 | import {
|
@@ -34,24 +34,29 @@ export interface AdvancedParametersBase {
|
34 | 34 | export type AdvancedParameters = AdvancedParametersBase &
|
35 | 35 | Omit<IAutocompleteParameters, 'resultsPerSection'>;
|
36 | 36 |
|
37 |
| -export type CioAutocompleteProps = CioClientConfig & { |
38 |
| - openOnFocus?: boolean; |
39 |
| - getSearchResultsUrl?: (item: SearchSuggestion) => string; |
40 |
| - onSubmit: OnSubmit; |
41 |
| - onFocus?: () => void; |
42 |
| - onChange?: (input: string) => void; |
43 |
| - onIsOpenChange?: (changes: UseComboboxStateChange<Item>) => void; |
44 |
| - placeholder?: string; |
45 |
| - children?: ReactNode; |
46 |
| - sections?: UserDefinedSection[]; |
47 |
| - zeroStateSections?: UserDefinedSection[]; |
48 |
| - autocompleteClassName?: string; |
49 |
| - advancedParameters?: AdvancedParameters; |
50 |
| - defaultInput?: string; |
| 37 | +// Type UseComboboxProps with items as optional |
| 38 | +type OptionalItemsComboboxProps<Item> = Partial<UseComboboxProps<Item>> & { |
| 39 | + items?: Item[]; |
51 | 40 | };
|
52 | 41 |
|
53 | 42 | export type UseCioAutocompleteOptions = Omit<CioAutocompleteProps, 'children'>;
|
54 | 43 |
|
| 44 | +export type CioAutocompleteProps = CioClientConfig & |
| 45 | + OptionalItemsComboboxProps<Item> & { |
| 46 | + openOnFocus?: boolean; |
| 47 | + getSearchResultsUrl?: (item: SearchSuggestion) => string; |
| 48 | + onSubmit: OnSubmit; |
| 49 | + onFocus?: () => void; |
| 50 | + onChange?: (input: string) => void; |
| 51 | + placeholder?: string; |
| 52 | + children?: ReactNode; |
| 53 | + sections?: UserDefinedSection[]; |
| 54 | + zeroStateSections?: UserDefinedSection[]; |
| 55 | + autocompleteClassName?: string; |
| 56 | + advancedParameters?: AdvancedParameters; |
| 57 | + defaultInput?: string; |
| 58 | + }; |
| 59 | + |
55 | 60 | /**
|
56 | 61 | * AutocompleteSubmitEvent type is AutocompleteSelectSubmit or AutocompleteSearchSubmit.
|
57 | 62 | * Use isAutocompleteSearchSubmit or isAutocompleteSelectSubmit type predicates to safely access event properties.
|
|
0 commit comments