@algolia/autocomplete-core 1.8.3 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/createAutocomplete.js +12 -9
- package/dist/esm/createStore.js +4 -5
- package/dist/esm/getAutocompleteSetters.d.ts +6 -6
- package/dist/esm/getAutocompleteSetters.js +4 -11
- package/dist/esm/getCompletion.js +0 -3
- package/dist/esm/getDefaultProps.js +6 -22
- package/dist/esm/getPropGetters.js +40 -69
- package/dist/esm/metadata.js +6 -9
- package/dist/esm/onInput.js +25 -34
- package/dist/esm/onKeyDown.js +30 -40
- package/dist/esm/reshape.d.ts +1 -1
- package/dist/esm/reshape.js +17 -19
- package/dist/esm/resolve.js +10 -28
- package/dist/esm/stateReducer.js +7 -24
- package/dist/esm/types/AutocompleteStore.d.ts +1 -3
- package/dist/esm/types/AutocompleteSubscribers.d.ts +1 -2
- package/dist/esm/types/index.d.ts +16 -11
- package/dist/esm/types/index.js +3 -12
- package/dist/esm/utils/createCancelablePromise.js +0 -8
- package/dist/esm/utils/createConcurrentSafePromise.js +0 -1
- package/dist/esm/utils/getActiveItem.d.ts +1 -1
- package/dist/esm/utils/getActiveItem.js +4 -12
- package/dist/esm/utils/getNextActiveItemId.js +0 -4
- package/dist/esm/utils/getNormalizedSources.js +5 -10
- package/dist/esm/utils/mapToAlgoliaResponse.d.ts +1 -1
- package/dist/esm/utils/mapToAlgoliaResponse.js +4 -6
- package/dist/umd/index.development.js +961 -387
- package/dist/umd/index.development.js.map +1 -1
- package/dist/umd/index.production.js +2 -2
- package/dist/umd/index.production.js.map +1 -1
- package/package.json +6 -5
- package/dist/esm/types/AutocompleteApi.d.ts +0 -15
- package/dist/esm/types/AutocompleteApi.js +0 -1
- package/dist/esm/types/AutocompleteCollection.d.ts +0 -10
- package/dist/esm/types/AutocompleteCollection.js +0 -1
- package/dist/esm/types/AutocompleteContext.d.ts +0 -3
- package/dist/esm/types/AutocompleteContext.js +0 -1
- package/dist/esm/types/AutocompleteEnvironment.d.ts +0 -13
- package/dist/esm/types/AutocompleteEnvironment.js +0 -1
- package/dist/esm/types/AutocompleteNavigator.d.ts +0 -28
- package/dist/esm/types/AutocompleteNavigator.js +0 -1
- package/dist/esm/types/AutocompleteOptions.d.ts +0 -185
- package/dist/esm/types/AutocompleteOptions.js +0 -1
- package/dist/esm/types/AutocompletePlugin.d.ts +0 -43
- package/dist/esm/types/AutocompletePlugin.js +0 -1
- package/dist/esm/types/AutocompletePropGetters.d.ts +0 -100
- package/dist/esm/types/AutocompletePropGetters.js +0 -1
- package/dist/esm/types/AutocompleteReshape.d.ts +0 -25
- package/dist/esm/types/AutocompleteReshape.js +0 -1
- package/dist/esm/types/AutocompleteSetters.d.ts +0 -46
- package/dist/esm/types/AutocompleteSetters.js +0 -1
- package/dist/esm/types/AutocompleteSource.d.ts +0 -75
- package/dist/esm/types/AutocompleteSource.js +0 -1
- package/dist/esm/types/AutocompleteState.d.ts +0 -12
- package/dist/esm/types/AutocompleteState.js +0 -1
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AutocompleteNavigator } from './AutocompleteNavigator';
|
|
2
|
-
import { AutocompletePropGetters } from './AutocompletePropGetters';
|
|
3
|
-
import { AutocompleteSetters } from './AutocompleteSetters';
|
|
4
|
-
export declare type BaseItem = Record<string, unknown>;
|
|
5
|
-
export interface AutocompleteScopeApi<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
|
|
6
|
-
/**
|
|
7
|
-
* Triggers a search to refresh the state.
|
|
8
|
-
*/
|
|
9
|
-
refresh(): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Functions to navigate to a URL.
|
|
12
|
-
*/
|
|
13
|
-
navigator: AutocompleteNavigator<TItem>;
|
|
14
|
-
}
|
|
15
|
-
export declare type AutocompleteApi<TItem extends BaseItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> = AutocompleteScopeApi<TItem> & AutocompletePropGetters<TItem, TEvent, TMouseEvent, TKeyboardEvent>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { InternalAutocompleteSource } from './AutocompleteSource';
|
|
3
|
-
export interface AutocompleteCollection<TItem extends BaseItem> {
|
|
4
|
-
source: InternalAutocompleteSource<TItem>;
|
|
5
|
-
items: TItem[];
|
|
6
|
-
}
|
|
7
|
-
export interface AutocompleteCollectionItemsArray<TItem extends BaseItem> {
|
|
8
|
-
source: InternalAutocompleteSource<TItem>;
|
|
9
|
-
items: TItem[][];
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare type AutocompleteEnvironment = Window | {
|
|
2
|
-
[prop: string]: unknown;
|
|
3
|
-
addEventListener: Window['addEventListener'];
|
|
4
|
-
removeEventListener: Window['removeEventListener'];
|
|
5
|
-
setTimeout: Window['setTimeout'];
|
|
6
|
-
clearTimeout: Window['clearTimeout'];
|
|
7
|
-
document: Window['document'];
|
|
8
|
-
location: {
|
|
9
|
-
assign: Location['assign'];
|
|
10
|
-
};
|
|
11
|
-
open: Window['open'];
|
|
12
|
-
navigator?: Partial<Window['navigator']>;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { AutocompleteState } from './AutocompleteState';
|
|
3
|
-
export interface AutocompleteNavigator<TItem extends BaseItem> {
|
|
4
|
-
/**
|
|
5
|
-
* Called when a URL should be open in the current page.
|
|
6
|
-
*/
|
|
7
|
-
navigate(params: {
|
|
8
|
-
itemUrl: string;
|
|
9
|
-
item: TItem;
|
|
10
|
-
state: AutocompleteState<TItem>;
|
|
11
|
-
}): void;
|
|
12
|
-
/**
|
|
13
|
-
* Called when a URL should be open in a new tab.
|
|
14
|
-
*/
|
|
15
|
-
navigateNewTab(params: {
|
|
16
|
-
itemUrl: string;
|
|
17
|
-
item: TItem;
|
|
18
|
-
state: AutocompleteState<TItem>;
|
|
19
|
-
}): void;
|
|
20
|
-
/**
|
|
21
|
-
* Called when a URL should be open in a new window.
|
|
22
|
-
*/
|
|
23
|
-
navigateNewWindow(params: {
|
|
24
|
-
itemUrl: string;
|
|
25
|
-
item: TItem;
|
|
26
|
-
state: AutocompleteState<TItem>;
|
|
27
|
-
}): void;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { MaybePromise } from '@algolia/autocomplete-shared';
|
|
2
|
-
import { AutocompleteScopeApi, BaseItem } from './AutocompleteApi';
|
|
3
|
-
import { AutocompleteEnvironment } from './AutocompleteEnvironment';
|
|
4
|
-
import { AutocompleteNavigator } from './AutocompleteNavigator';
|
|
5
|
-
import { AutocompletePlugin } from './AutocompletePlugin';
|
|
6
|
-
import { Reshape } from './AutocompleteReshape';
|
|
7
|
-
import { AutocompleteSource, InternalAutocompleteSource } from './AutocompleteSource';
|
|
8
|
-
import { AutocompleteState } from './AutocompleteState';
|
|
9
|
-
export interface OnSubmitParams<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
10
|
-
state: AutocompleteState<TItem>;
|
|
11
|
-
event: any;
|
|
12
|
-
}
|
|
13
|
-
export declare type OnResetParams<TItem extends BaseItem> = OnSubmitParams<TItem>;
|
|
14
|
-
export interface OnInputParams<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
15
|
-
query: string;
|
|
16
|
-
state: AutocompleteState<TItem>;
|
|
17
|
-
}
|
|
18
|
-
export declare type GetSourcesParams<TItem extends BaseItem> = OnInputParams<TItem>;
|
|
19
|
-
export declare type GetSources<TItem extends BaseItem> = (params: GetSourcesParams<TItem>) => MaybePromise<Array<AutocompleteSource<TItem> | boolean | undefined>>;
|
|
20
|
-
export declare type InternalGetSources<TItem extends BaseItem> = (params: GetSourcesParams<TItem>) => Promise<Array<InternalAutocompleteSource<TItem>>>;
|
|
21
|
-
interface OnStateChangeProps<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
22
|
-
/**
|
|
23
|
-
* The current Autocomplete state.
|
|
24
|
-
*/
|
|
25
|
-
state: AutocompleteState<TItem>;
|
|
26
|
-
/**
|
|
27
|
-
* The previous Autocomplete state.
|
|
28
|
-
*/
|
|
29
|
-
prevState: AutocompleteState<TItem>;
|
|
30
|
-
}
|
|
31
|
-
export interface AutocompleteOptions<TItem extends BaseItem> {
|
|
32
|
-
/**
|
|
33
|
-
* A flag to activate the debug mode.
|
|
34
|
-
*
|
|
35
|
-
* This is useful while developing because it keeps the panel open even when the blur event occurs. **Make sure to disable it in production.**
|
|
36
|
-
*
|
|
37
|
-
* See [**Debugging**](https://www.algolia.com/doc/ui-libraries/autocomplete/guides/debugging/) for more information.
|
|
38
|
-
*
|
|
39
|
-
* @default false
|
|
40
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-debug
|
|
41
|
-
*/
|
|
42
|
-
debug?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* An ID for the autocomplete to create accessible attributes.
|
|
45
|
-
*
|
|
46
|
-
* It is incremented by default when creating a new Autocomplete instance.
|
|
47
|
-
*
|
|
48
|
-
* @default "autocomplete-0"
|
|
49
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-id
|
|
50
|
-
*/
|
|
51
|
-
id?: string;
|
|
52
|
-
/**
|
|
53
|
-
* The function called when the internal state changes.
|
|
54
|
-
*
|
|
55
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-onstatechange
|
|
56
|
-
*/
|
|
57
|
-
onStateChange?(props: OnStateChangeProps<TItem>): void;
|
|
58
|
-
/**
|
|
59
|
-
* The placeholder text to show in the search input when there's no query.
|
|
60
|
-
*
|
|
61
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-placeholder
|
|
62
|
-
*/
|
|
63
|
-
placeholder?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Whether to focus the search input or not when the page is loaded.
|
|
66
|
-
*
|
|
67
|
-
* @default false
|
|
68
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-autofocus
|
|
69
|
-
*/
|
|
70
|
-
autoFocus?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* The default item index to pre-select.
|
|
73
|
-
*
|
|
74
|
-
* We recommend using `0` when the autocomplete is used to open links, instead of triggering a search in an application.
|
|
75
|
-
*
|
|
76
|
-
* @default null
|
|
77
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-defaultactiveitemid
|
|
78
|
-
*/
|
|
79
|
-
defaultActiveItemId?: number | null;
|
|
80
|
-
/**
|
|
81
|
-
* Whether to open the panel on focus when there's no query.
|
|
82
|
-
*
|
|
83
|
-
* @default false
|
|
84
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-openonfocus
|
|
85
|
-
*/
|
|
86
|
-
openOnFocus?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* How many milliseconds must elapse before considering the autocomplete experience [stalled](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-status).
|
|
89
|
-
*
|
|
90
|
-
* @default 300
|
|
91
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-stallthreshold
|
|
92
|
-
*/
|
|
93
|
-
stallThreshold?: number;
|
|
94
|
-
/**
|
|
95
|
-
* The initial state to apply when autocomplete is created.
|
|
96
|
-
*
|
|
97
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-initialstate
|
|
98
|
-
*/
|
|
99
|
-
initialState?: Partial<AutocompleteState<TItem>>;
|
|
100
|
-
/**
|
|
101
|
-
* The [sources](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/) to get the suggestions from.
|
|
102
|
-
*
|
|
103
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-getsources
|
|
104
|
-
*/
|
|
105
|
-
getSources?: GetSources<TItem>;
|
|
106
|
-
/**
|
|
107
|
-
* The environment in which your application is running.
|
|
108
|
-
*
|
|
109
|
-
* This is useful if you're using autocomplete in a different context than `window`.
|
|
110
|
-
*
|
|
111
|
-
* @default window
|
|
112
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-environment
|
|
113
|
-
*/
|
|
114
|
-
environment?: AutocompleteEnvironment;
|
|
115
|
-
/**
|
|
116
|
-
* An implementation of Autocomplete's Navigator API to redirect the user when opening a link.
|
|
117
|
-
*
|
|
118
|
-
* Learn more on the [**Navigator API**](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/keyboard-navigation/) documentation.
|
|
119
|
-
*
|
|
120
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-navigator
|
|
121
|
-
*/
|
|
122
|
-
navigator?: Partial<AutocompleteNavigator<TItem>>;
|
|
123
|
-
/**
|
|
124
|
-
* The function called to determine whether the panel should open or not.
|
|
125
|
-
*
|
|
126
|
-
* By default, the panel opens when there are items in the state.
|
|
127
|
-
*
|
|
128
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-shouldpanelopen
|
|
129
|
-
*/
|
|
130
|
-
shouldPanelOpen?(params: {
|
|
131
|
-
state: AutocompleteState<TItem>;
|
|
132
|
-
}): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* The function called when submitting the Autocomplete form.
|
|
135
|
-
*
|
|
136
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-onsubmit
|
|
137
|
-
*/
|
|
138
|
-
onSubmit?(params: OnSubmitParams<TItem>): void;
|
|
139
|
-
/**
|
|
140
|
-
* The function called when resetting the Autocomplete form.
|
|
141
|
-
*
|
|
142
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-onreset
|
|
143
|
-
*/
|
|
144
|
-
onReset?(params: OnResetParams<TItem>): void;
|
|
145
|
-
/**
|
|
146
|
-
* The plugins that encapsulate and distribute custom Autocomplete behaviors.
|
|
147
|
-
*
|
|
148
|
-
* See [**Plugins**](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/) for more information.
|
|
149
|
-
*
|
|
150
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-plugins
|
|
151
|
-
*/
|
|
152
|
-
plugins?: Array<AutocompletePlugin<any, any>>;
|
|
153
|
-
/**
|
|
154
|
-
* The function called to reshape the sources after they're resolved.
|
|
155
|
-
*
|
|
156
|
-
* This is useful to transform sources before rendering them. You can group sources by attribute, remove duplicates, create shared limits between sources, etc.
|
|
157
|
-
*
|
|
158
|
-
* See [**Reshaping sources**](https://www.algolia.com/doc/ui-libraries/autocomplete/guides/reshaping-sources/) for more information.
|
|
159
|
-
*
|
|
160
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-reshape
|
|
161
|
-
*/
|
|
162
|
-
reshape?: Reshape<TItem>;
|
|
163
|
-
}
|
|
164
|
-
export interface InternalAutocompleteOptions<TItem extends BaseItem> extends AutocompleteOptions<TItem> {
|
|
165
|
-
debug: boolean;
|
|
166
|
-
id: string;
|
|
167
|
-
onStateChange(props: OnStateChangeProps<TItem>): void;
|
|
168
|
-
placeholder: string;
|
|
169
|
-
autoFocus: boolean;
|
|
170
|
-
defaultActiveItemId: number | null;
|
|
171
|
-
openOnFocus: boolean;
|
|
172
|
-
stallThreshold: number;
|
|
173
|
-
initialState: AutocompleteState<TItem>;
|
|
174
|
-
getSources: InternalGetSources<TItem>;
|
|
175
|
-
environment: AutocompleteEnvironment;
|
|
176
|
-
navigator: AutocompleteNavigator<TItem>;
|
|
177
|
-
plugins: Array<AutocompletePlugin<any, any>>;
|
|
178
|
-
shouldPanelOpen(params: {
|
|
179
|
-
state: AutocompleteState<TItem>;
|
|
180
|
-
}): boolean;
|
|
181
|
-
onSubmit(params: OnSubmitParams<TItem>): void;
|
|
182
|
-
onReset(params: OnResetParams<TItem>): void;
|
|
183
|
-
reshape: Reshape<TItem>;
|
|
184
|
-
}
|
|
185
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AutocompleteScopeApi, BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { AutocompleteOptions } from './AutocompleteOptions';
|
|
3
|
-
import { PluginReshape } from './AutocompleteReshape';
|
|
4
|
-
import { OnSelectParams, OnActiveParams, OnResolveParams } from './AutocompleteSource';
|
|
5
|
-
declare type PluginSubscriber<TParams> = (params: TParams) => void;
|
|
6
|
-
export interface PluginSubscribeParams<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
7
|
-
onSelect(fn: PluginSubscriber<OnSelectParams<TItem>>): void;
|
|
8
|
-
onActive(fn: PluginSubscriber<OnActiveParams<TItem>>): void;
|
|
9
|
-
onResolve(fn: PluginSubscriber<OnResolveParams<TItem>>): void;
|
|
10
|
-
}
|
|
11
|
-
export declare type AutocompletePlugin<TItem extends BaseItem, TData = unknown> = Partial<Pick<AutocompleteOptions<any>, 'onStateChange' | 'onSubmit' | 'onReset'> & Pick<AutocompleteOptions<TItem>, 'getSources'>> & {
|
|
12
|
-
/**
|
|
13
|
-
* The function called when Autocomplete starts.
|
|
14
|
-
*
|
|
15
|
-
* It lets you subscribe to lifecycle hooks and interact with the instance's state and context.
|
|
16
|
-
*
|
|
17
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/#param-subscribe
|
|
18
|
-
*/
|
|
19
|
-
subscribe?(params: PluginSubscribeParams<any>): void;
|
|
20
|
-
/**
|
|
21
|
-
* An extra plugin object to expose properties and functions as APIs.
|
|
22
|
-
*
|
|
23
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/#param-data
|
|
24
|
-
*/
|
|
25
|
-
data?: TData;
|
|
26
|
-
/**
|
|
27
|
-
* A name to identify the plugin.
|
|
28
|
-
*
|
|
29
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/plugins/#param-name
|
|
30
|
-
*/
|
|
31
|
-
name?: string;
|
|
32
|
-
/**
|
|
33
|
-
* A function to reshape the sources.
|
|
34
|
-
*
|
|
35
|
-
* It gets called before the user's reshape function.
|
|
36
|
-
*/
|
|
37
|
-
reshape?: PluginReshape<TItem>;
|
|
38
|
-
/**
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
__autocomplete_pluginOptions?: Record<string, any>;
|
|
42
|
-
};
|
|
43
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { InternalAutocompleteSource } from './AutocompleteSource';
|
|
3
|
-
export interface AutocompletePropGetters<TItem extends BaseItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> {
|
|
4
|
-
getEnvironmentProps: GetEnvironmentProps;
|
|
5
|
-
getRootProps: GetRootProps;
|
|
6
|
-
getFormProps: GetFormProps<TEvent>;
|
|
7
|
-
getLabelProps: GetLabelProps;
|
|
8
|
-
getInputProps: GetInputProps<TEvent, TMouseEvent, TKeyboardEvent>;
|
|
9
|
-
getPanelProps: GetPanelProps<TMouseEvent>;
|
|
10
|
-
getListProps: GetListProps;
|
|
11
|
-
getItemProps: GetItemProps<TItem, TMouseEvent>;
|
|
12
|
-
}
|
|
13
|
-
export declare type GetEnvironmentProps = (props: {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
formElement: HTMLElement;
|
|
16
|
-
inputElement: HTMLInputElement;
|
|
17
|
-
panelElement: HTMLElement;
|
|
18
|
-
}) => {
|
|
19
|
-
onTouchStart(event: TouchEvent): void;
|
|
20
|
-
onTouchMove(event: TouchEvent): void;
|
|
21
|
-
onMouseDown(event: MouseEvent): void;
|
|
22
|
-
};
|
|
23
|
-
export declare type GetRootProps = (props?: {
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}) => {
|
|
26
|
-
role: string;
|
|
27
|
-
'aria-expanded': boolean;
|
|
28
|
-
'aria-haspopup': boolean | 'dialog' | 'menu' | 'true' | 'false' | 'grid' | 'listbox' | 'tree' | undefined;
|
|
29
|
-
'aria-owns': string | undefined;
|
|
30
|
-
'aria-labelledby': string;
|
|
31
|
-
};
|
|
32
|
-
export declare type GetFormProps<TEvent = Event> = (props: {
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
inputElement: HTMLInputElement | null;
|
|
35
|
-
}) => {
|
|
36
|
-
action: '';
|
|
37
|
-
noValidate: true;
|
|
38
|
-
role: 'search';
|
|
39
|
-
onSubmit(event: TEvent): void;
|
|
40
|
-
onReset(event: TEvent): void;
|
|
41
|
-
};
|
|
42
|
-
export declare type GetLabelProps = (props?: {
|
|
43
|
-
[key: string]: unknown;
|
|
44
|
-
sourceIndex?: number;
|
|
45
|
-
}) => {
|
|
46
|
-
htmlFor: string;
|
|
47
|
-
id: string;
|
|
48
|
-
};
|
|
49
|
-
export declare type GetInputProps<TEvent, TMouseEvent, TKeyboardEvent> = (props: {
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
inputElement: HTMLInputElement | null;
|
|
52
|
-
maxLength?: number;
|
|
53
|
-
}) => {
|
|
54
|
-
id: string;
|
|
55
|
-
value: string;
|
|
56
|
-
autoFocus: boolean;
|
|
57
|
-
placeholder: string;
|
|
58
|
-
autoComplete: 'on' | 'off';
|
|
59
|
-
autoCorrect: 'on' | 'off';
|
|
60
|
-
autoCapitalize: 'on' | 'off';
|
|
61
|
-
enterKeyHint: 'go' | 'search';
|
|
62
|
-
spellCheck: 'false';
|
|
63
|
-
maxLength: number;
|
|
64
|
-
type: 'search';
|
|
65
|
-
'aria-autocomplete': 'none' | 'inline' | 'list' | 'both';
|
|
66
|
-
'aria-activedescendant': string | undefined;
|
|
67
|
-
'aria-controls': string | undefined;
|
|
68
|
-
'aria-labelledby': string;
|
|
69
|
-
onChange(event: TEvent): void;
|
|
70
|
-
onKeyDown(event: TKeyboardEvent): void;
|
|
71
|
-
onFocus(event: TEvent): void;
|
|
72
|
-
onBlur(): void;
|
|
73
|
-
onClick(event: TMouseEvent): void;
|
|
74
|
-
};
|
|
75
|
-
export declare type GetPanelProps<TMouseEvent> = (props?: {
|
|
76
|
-
[key: string]: unknown;
|
|
77
|
-
}) => {
|
|
78
|
-
onMouseDown(event: TMouseEvent): void;
|
|
79
|
-
onMouseLeave(): void;
|
|
80
|
-
};
|
|
81
|
-
export declare type GetListProps = (props?: {
|
|
82
|
-
[key: string]: unknown;
|
|
83
|
-
sourceIndex?: number;
|
|
84
|
-
}) => {
|
|
85
|
-
role: string;
|
|
86
|
-
'aria-labelledby': string;
|
|
87
|
-
id: string;
|
|
88
|
-
};
|
|
89
|
-
export declare type GetItemProps<TItem extends BaseItem, TMouseEvent = MouseEvent> = (props: {
|
|
90
|
-
[key: string]: unknown;
|
|
91
|
-
item: TItem;
|
|
92
|
-
source: InternalAutocompleteSource<TItem>;
|
|
93
|
-
}) => {
|
|
94
|
-
id: string;
|
|
95
|
-
role: string;
|
|
96
|
-
'aria-selected': boolean;
|
|
97
|
-
onMouseMove(event: TMouseEvent): void;
|
|
98
|
-
onMouseDown(event: TMouseEvent): void;
|
|
99
|
-
onClick(event: TMouseEvent): void;
|
|
100
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { AutocompleteSource } from './AutocompleteSource';
|
|
3
|
-
import { AutocompleteState } from './AutocompleteState';
|
|
4
|
-
export declare type AutocompleteReshapeSource<TItem extends BaseItem> = AutocompleteSource<TItem> & {
|
|
5
|
-
getItems(): TItem[];
|
|
6
|
-
};
|
|
7
|
-
export declare type AutocompleteReshapeSourcesBySourceId<TItem extends BaseItem> = Record<string, AutocompleteReshapeSource<TItem>>;
|
|
8
|
-
export declare type ReshapeParams<TItem extends BaseItem, TState extends AutocompleteState<TItem> = AutocompleteState<TItem>> = {
|
|
9
|
-
/**
|
|
10
|
-
* The resolved sources provided by [`getSources`](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getsources)
|
|
11
|
-
*/
|
|
12
|
-
sources: Array<AutocompleteReshapeSource<TItem>>;
|
|
13
|
-
/**
|
|
14
|
-
* The resolved sources grouped by [`sourceId`](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-sourceid)s
|
|
15
|
-
*/
|
|
16
|
-
sourcesBySourceId: AutocompleteReshapeSourcesBySourceId<TItem>;
|
|
17
|
-
/**
|
|
18
|
-
* The current Autocomplete state.
|
|
19
|
-
*
|
|
20
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state
|
|
21
|
-
*/
|
|
22
|
-
state: TState;
|
|
23
|
-
};
|
|
24
|
-
export declare type Reshape<TItem extends BaseItem, TState extends AutocompleteState<TItem> = AutocompleteState<TItem>> = (params: ReshapeParams<TItem, TState>) => Array<AutocompleteReshapeSource<TItem>>;
|
|
25
|
-
export declare type PluginReshape<TItem extends BaseItem, TState extends AutocompleteState<TItem> = AutocompleteState<TItem>> = (params: Omit<ReshapeParams<TItem, TState>, 'sources'>) => Omit<ReshapeParams<TItem, TState>, 'sources'>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { AutocompleteCollection, AutocompleteCollectionItemsArray } from './AutocompleteCollection';
|
|
3
|
-
import { AutocompleteState } from './AutocompleteState';
|
|
4
|
-
export declare type StateUpdater<TState> = (value: TState) => void;
|
|
5
|
-
export interface AutocompleteSetters<TItem extends BaseItem> {
|
|
6
|
-
/**
|
|
7
|
-
* Sets the highlighted item index.
|
|
8
|
-
*
|
|
9
|
-
* Pass `null` to unselect items.
|
|
10
|
-
*
|
|
11
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setactiveitemid
|
|
12
|
-
*/
|
|
13
|
-
setActiveItemId: StateUpdater<AutocompleteState<TItem>['activeItemId']>;
|
|
14
|
-
/**
|
|
15
|
-
* Sets the query.
|
|
16
|
-
*
|
|
17
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setquery
|
|
18
|
-
*/
|
|
19
|
-
setQuery: StateUpdater<AutocompleteState<TItem>['query']>;
|
|
20
|
-
/**
|
|
21
|
-
* Sets the collections.
|
|
22
|
-
*
|
|
23
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setcollections
|
|
24
|
-
*/
|
|
25
|
-
setCollections: StateUpdater<Array<AutocompleteCollection<TItem> | AutocompleteCollectionItemsArray<TItem>>>;
|
|
26
|
-
/**
|
|
27
|
-
* Sets whether the panel is open or not.
|
|
28
|
-
*
|
|
29
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setisopen
|
|
30
|
-
*/
|
|
31
|
-
setIsOpen: StateUpdater<AutocompleteState<TItem>['isOpen']>;
|
|
32
|
-
/**
|
|
33
|
-
* Sets the status of the autocomplete.
|
|
34
|
-
*
|
|
35
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setisopen
|
|
36
|
-
*/
|
|
37
|
-
setStatus: StateUpdater<AutocompleteState<TItem>['status']>;
|
|
38
|
-
/**
|
|
39
|
-
* Sets the context passed to lifecycle hooks.
|
|
40
|
-
*
|
|
41
|
-
* See more in [**Context**](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/context/).
|
|
42
|
-
*
|
|
43
|
-
* @link https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/state/#param-setcontext
|
|
44
|
-
*/
|
|
45
|
-
setContext: StateUpdater<AutocompleteState<TItem>['context']>;
|
|
46
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { SearchForFacetValuesResponse, SearchResponse, RequesterDescription } from '@algolia/autocomplete-preset-algolia';
|
|
2
|
-
import type { MaybePromise } from '@algolia/autocomplete-shared';
|
|
3
|
-
import { FacetHit, Hit } from '@algolia/client-search';
|
|
4
|
-
import { AutocompleteScopeApi, BaseItem } from './AutocompleteApi';
|
|
5
|
-
import { GetSourcesParams } from './AutocompleteOptions';
|
|
6
|
-
import { AutocompleteState } from './AutocompleteState';
|
|
7
|
-
export interface OnSelectParams<TItem extends BaseItem> extends AutocompleteScopeApi<TItem> {
|
|
8
|
-
state: AutocompleteState<TItem>;
|
|
9
|
-
event: any;
|
|
10
|
-
item: TItem;
|
|
11
|
-
itemInputValue: ReturnType<InternalAutocompleteSource<TItem>['getItemInputValue']>;
|
|
12
|
-
itemUrl: ReturnType<InternalAutocompleteSource<TItem>['getItemUrl']>;
|
|
13
|
-
source: InternalAutocompleteSource<TItem>;
|
|
14
|
-
}
|
|
15
|
-
export declare type OnActiveParams<TItem extends BaseItem> = OnSelectParams<TItem>;
|
|
16
|
-
export declare type OnResolveParams<TItem extends BaseItem> = {
|
|
17
|
-
source: AutocompleteSource<TItem>;
|
|
18
|
-
results: SearchForFacetValuesResponse | SearchResponse<TItem> | TItem[] | TItem[][];
|
|
19
|
-
items: FacetHit[][] | FacetHit[] | Array<Hit<TItem>> | Array<SearchForFacetValuesResponse | SearchResponse<TItem> | TItem[] | TItem[][]>;
|
|
20
|
-
state: AutocompleteState<TItem>;
|
|
21
|
-
};
|
|
22
|
-
declare type DefaultIndicator = {
|
|
23
|
-
/**
|
|
24
|
-
* Optional key on a function to indicate it's the default value of this function.
|
|
25
|
-
*/
|
|
26
|
-
__default?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export interface AutocompleteSource<TItem extends BaseItem> {
|
|
29
|
-
/**
|
|
30
|
-
* Unique identifier for the source.
|
|
31
|
-
*/
|
|
32
|
-
sourceId: string;
|
|
33
|
-
/**
|
|
34
|
-
* The function called to get the value of an item.
|
|
35
|
-
*
|
|
36
|
-
* The value is used to fill the search box.
|
|
37
|
-
*/
|
|
38
|
-
getItemInputValue?: DefaultIndicator & (({ item, state, }: {
|
|
39
|
-
item: TItem;
|
|
40
|
-
state: AutocompleteState<TItem>;
|
|
41
|
-
}) => string);
|
|
42
|
-
/**
|
|
43
|
-
* The function called to get the URL of the item.
|
|
44
|
-
*
|
|
45
|
-
* The value is used to add [keyboard accessibility](https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/keyboard-navigation/) features to let users open items in the current tab, a new tab, or a new window.
|
|
46
|
-
*/
|
|
47
|
-
getItemUrl?: DefaultIndicator & (({ item, state, }: {
|
|
48
|
-
item: TItem;
|
|
49
|
-
state: AutocompleteState<TItem>;
|
|
50
|
-
}) => string | undefined);
|
|
51
|
-
/**
|
|
52
|
-
* The function called when the input changes.
|
|
53
|
-
*
|
|
54
|
-
* You can use this function to filter the items based on the query.
|
|
55
|
-
*/
|
|
56
|
-
getItems(params: GetSourcesParams<TItem>): MaybePromise<TItem[] | TItem[][] | RequesterDescription<TItem>>;
|
|
57
|
-
/**
|
|
58
|
-
* The function called whenever an item is selected.
|
|
59
|
-
*/
|
|
60
|
-
onSelect?: DefaultIndicator & ((params: OnSelectParams<TItem>) => void);
|
|
61
|
-
/**
|
|
62
|
-
* The function called whenever an item is active.
|
|
63
|
-
*
|
|
64
|
-
* You can trigger different behaviors if the item is active depending on the triggering event using the `event` parameter.
|
|
65
|
-
*/
|
|
66
|
-
onActive?: DefaultIndicator & ((params: OnActiveParams<TItem>) => void);
|
|
67
|
-
/**
|
|
68
|
-
* The function called whenever a source resolves.
|
|
69
|
-
*/
|
|
70
|
-
onResolve?: DefaultIndicator & ((params: OnResolveParams<TItem>) => void);
|
|
71
|
-
}
|
|
72
|
-
export declare type InternalAutocompleteSource<TItem extends BaseItem> = {
|
|
73
|
-
[KParam in keyof AutocompleteSource<TItem>]-?: AutocompleteSource<TItem>[KParam];
|
|
74
|
-
};
|
|
75
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseItem } from './AutocompleteApi';
|
|
2
|
-
import { AutocompleteCollection } from './AutocompleteCollection';
|
|
3
|
-
import { AutocompleteContext } from './AutocompleteContext';
|
|
4
|
-
export interface AutocompleteState<TItem extends BaseItem> {
|
|
5
|
-
activeItemId: number | null;
|
|
6
|
-
query: string;
|
|
7
|
-
completion: string | null;
|
|
8
|
-
collections: Array<AutocompleteCollection<TItem>>;
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
status: 'idle' | 'loading' | 'stalled' | 'error';
|
|
11
|
-
context: AutocompleteContext;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|