Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/autocomplete-core

Package Overview
Dependencies
Maintainers
62
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/autocomplete-core - npm Package Compare versions

Comparing version 1.0.0-alpha.35 to 1.0.0-alpha.36

dist/esm/types/subscriber.d.ts

4

dist/esm/checkOptions.d.ts

@@ -1,2 +0,2 @@

import { AutocompleteOptions } from './types';
export declare function checkOptions<TItem>(option: AutocompleteOptions<TItem>): void;
import { AutocompleteOptions, BaseItem } from './types';
export declare function checkOptions<TItem extends BaseItem>(option: AutocompleteOptions<TItem>): void;

@@ -1,2 +0,2 @@

import { AutocompleteApi, AutocompleteOptions } from './types';
export declare function createAutocomplete<TItem extends {}, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent>(options: AutocompleteOptions<TItem>): AutocompleteApi<TItem, TEvent, TMouseEvent, TKeyboardEvent>;
import { AutocompleteApi, AutocompleteOptions, BaseItem } from './types';
export declare function createAutocomplete<TItem extends BaseItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent>(options: AutocompleteOptions<TItem>): AutocompleteApi<TItem, TEvent, TMouseEvent, TKeyboardEvent>;

@@ -10,3 +10,4 @@ import { checkOptions } from './checkOptions';

checkOptions(options);
var props = getDefaultProps(options);
var subscribers = [];
var props = getDefaultProps(options, subscribers);
var store = createStore(stateReducer, props);

@@ -63,2 +64,24 @@

props.plugins.forEach(function (plugin) {
var _plugin$subscribe;
return (_plugin$subscribe = plugin.subscribe) === null || _plugin$subscribe === void 0 ? void 0 : _plugin$subscribe.call(plugin, {
setSelectedItemId: setSelectedItemId,
setQuery: setQuery,
setCollections: setCollections,
setIsOpen: setIsOpen,
setStatus: setStatus,
setContext: setContext,
onSelect: function onSelect(fn) {
subscribers.push({
onSelect: fn
});
},
onHighlight: function onHighlight(fn) {
subscribers.push({
onHighlight: fn
});
}
});
});
return {

@@ -65,0 +88,0 @@ setSelectedItemId: setSelectedItemId,

@@ -1,2 +0,2 @@

import { AutocompleteStore, InternalAutocompleteOptions, Reducer } from './types';
export declare function createStore<TItem>(reducer: Reducer, props: InternalAutocompleteOptions<TItem>): AutocompleteStore<TItem>;
import { AutocompleteStore, BaseItem, InternalAutocompleteOptions, Reducer } from './types';
export declare function createStore<TItem extends BaseItem>(reducer: Reducer, props: InternalAutocompleteOptions<TItem>): AutocompleteStore<TItem>;

@@ -13,3 +13,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

},
send: function send(action, payload) {
dispatch: function dispatch(action, payload) {
var prevState = _objectSpread({}, state);

@@ -16,0 +16,0 @@

@@ -1,9 +0,9 @@

import { AutocompleteStore } from './types';
interface GetAutocompleteSettersOptions<TItem> {
import { AutocompleteCollection, AutocompleteStore, BaseItem } from './types';
interface GetAutocompleteSettersOptions<TItem extends BaseItem> {
store: AutocompleteStore<TItem>;
}
export declare function getAutocompleteSetters<TItem>({ store, }: GetAutocompleteSettersOptions<TItem>): {
export declare function getAutocompleteSetters<TItem extends BaseItem>({ store, }: GetAutocompleteSettersOptions<TItem>): {
setSelectedItemId: import("./types").StateUpdater<number | null>;
setQuery: import("./types").StateUpdater<string>;
setCollections: import("./types").StateUpdater<import("./types").AutocompleteCollection<TItem | TItem[]>[]>;
setCollections: import("./types").StateUpdater<(AutocompleteCollection<TItem> | import("./types").AutocompleteCollectionItemsArray<TItem>)[]>;
setIsOpen: import("./types").StateUpdater<boolean>;

@@ -10,0 +10,0 @@ setStatus: import("./types").StateUpdater<"idle" | "loading" | "stalled" | "error">;

@@ -12,7 +12,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var setSelectedItemId = function setSelectedItemId(value) {
store.send('setSelectedItemId', value);
store.dispatch('setSelectedItemId', value);
};
var setQuery = function setQuery(value) {
store.send('setQuery', value);
store.dispatch('setQuery', value);
};

@@ -33,15 +33,15 @@

});
store.send('setCollections', value);
store.dispatch('setCollections', value);
};
var setIsOpen = function setIsOpen(value) {
store.send('setIsOpen', value);
store.dispatch('setIsOpen', value);
};
var setStatus = function setStatus(value) {
store.send('setStatus', value);
store.dispatch('setStatus', value);
};
var setContext = function setContext(value) {
store.send('setContext', value);
store.dispatch('setContext', value);
};

@@ -48,0 +48,0 @@

@@ -1,6 +0,6 @@

import { AutocompleteState } from './types';
interface GetCompletionProps<TItem> {
import { AutocompleteState, BaseItem } from './types';
interface GetCompletionProps<TItem extends BaseItem> {
state: AutocompleteState<TItem>;
}
export declare function getCompletion<TItem>({ state, }: GetCompletionProps<TItem>): string | null;
export declare function getCompletion<TItem extends BaseItem>({ state, }: GetCompletionProps<TItem>): string | null;
export {};

@@ -1,2 +0,2 @@

import { InternalAutocompleteOptions, AutocompleteOptions } from './types';
export declare function getDefaultProps<TItem>(props: AutocompleteOptions<TItem>): InternalAutocompleteOptions<TItem>;
import { AutocompleteOptions, BaseItem, InternalAutocompleteOptions, Subscribers } from './types';
export declare function getDefaultProps<TItem extends BaseItem>(props: AutocompleteOptions<TItem>, subscribers: Subscribers<TItem>): InternalAutocompleteOptions<TItem>;

@@ -21,3 +21,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

import { generateAutocompleteId, getItemsCount, getNormalizedSources, flatten } from './utils';
export function getDefaultProps(props) {
export function getDefaultProps(props, subscribers) {
var _props$id;

@@ -86,7 +86,15 @@

source.onSelect(params);
plugins.forEach(function (plugin) {
var _plugin$subscribed, _plugin$subscribed$on;
subscribers.forEach(function (subscriber) {
var _subscriber$onSelect;
(_plugin$subscribed = plugin.subscribed) === null || _plugin$subscribed === void 0 ? void 0 : (_plugin$subscribed$on = _plugin$subscribed.onSelect) === null || _plugin$subscribed$on === void 0 ? void 0 : _plugin$subscribed$on.call(_plugin$subscribed, params);
(_subscriber$onSelect = subscriber.onSelect) === null || _subscriber$onSelect === void 0 ? void 0 : _subscriber$onSelect.call(subscriber, params);
});
},
onHighlight: function onHighlight(params) {
source.onHighlight(params);
subscribers.forEach(function (subscriber) {
var _subscriber$onHighlig;
(_subscriber$onHighlig = subscriber.onHighlight) === null || _subscriber$onHighlig === void 0 ? void 0 : _subscriber$onHighlig.call(subscriber, params);
});
}

@@ -93,0 +101,0 @@ });

@@ -1,2 +0,2 @@

import { InternalAutocompleteOptions } from './types';
export declare function getNavigator({ environment, }: Pick<InternalAutocompleteOptions<unknown>, 'environment'>): InternalAutocompleteOptions<unknown>['navigator'];
import { BaseItem, InternalAutocompleteOptions } from './types';
export declare function getNavigator<TItem extends BaseItem>({ environment, }: Pick<InternalAutocompleteOptions<TItem>, 'environment'>): InternalAutocompleteOptions<TItem>['navigator'];

@@ -1,3 +0,3 @@

import { InternalAutocompleteOptions, AutocompleteSetters, AutocompleteStore, AutocompleteRefresh, GetPanelProps, GetEnvironmentProps, GetFormProps, GetInputProps, GetItemProps, GetLabelProps, GetListProps, GetRootProps } from './types';
interface GetPropGettersOptions<TItem> extends AutocompleteSetters<TItem> {
import { InternalAutocompleteOptions, AutocompleteSetters, AutocompleteStore, AutocompleteRefresh, GetPanelProps, GetEnvironmentProps, GetFormProps, GetInputProps, GetItemProps, GetLabelProps, GetListProps, GetRootProps, BaseItem } from './types';
interface GetPropGettersOptions<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
store: AutocompleteStore<TItem>;

@@ -7,3 +7,3 @@ props: InternalAutocompleteOptions<TItem>;

}
export declare function getPropGetters<TItem, TEvent, TMouseEvent, TKeyboardEvent>({ store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, refresh, }: GetPropGettersOptions<TItem>): {
export declare function getPropGetters<TItem extends BaseItem, TEvent, TMouseEvent, TKeyboardEvent>({ store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, refresh, }: GetPropGettersOptions<TItem>): {
getEnvironmentProps: GetEnvironmentProps;

@@ -10,0 +10,0 @@ getRootProps: GetRootProps;

@@ -37,3 +37,3 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

var isTargetWithinAutocomplete = [getterProps.searchBoxElement, getterProps.panelElement].some(function (contextNode) {
var isTargetWithinAutocomplete = [getterProps.formElement, getterProps.panelElement].some(function (contextNode) {
return contextNode && (isOrContainsNode(contextNode, event.target) || isOrContainsNode(contextNode, props.environment.document.activeElement));

@@ -43,3 +43,3 @@ });

if (isTargetWithinAutocomplete === false) {
store.send('blur', null);
store.dispatch('blur', null);
}

@@ -91,3 +91,3 @@ },

});
store.send('submit', null);
store.dispatch('submit', null);

@@ -117,3 +117,3 @@ if (providedProps.inputElement) {

store.send('reset', null);
store.dispatch('reset', null);

@@ -147,3 +147,3 @@ if (providedProps.inputElement) {

store.send('focus', null);
store.dispatch('focus', null);
}

@@ -208,3 +208,3 @@

if (!isTouchDevice) {
store.send('blur', null);
store.dispatch('blur', null);
}

@@ -251,3 +251,3 @@ },

onMouseLeave: function onMouseLeave() {
store.send('mouseleave', null);
store.dispatch('mouseleave', null);
}

@@ -271,3 +271,3 @@ }, rest);

store.send('mousemove', item.__autocomplete_id);
store.dispatch('mousemove', item.__autocomplete_id);
var highlightedItem = getSelectedItem({

@@ -274,0 +274,0 @@ state: store.getState()

@@ -1,3 +0,3 @@

import { InternalAutocompleteOptions, AutocompleteSetters, AutocompleteState, AutocompleteStore, AutocompleteRefresh } from './types';
interface OnInputParams<TItem> extends AutocompleteSetters<TItem> {
import { AutocompleteSetters, AutocompleteState, AutocompleteStore, AutocompleteRefresh, BaseItem, InternalAutocompleteOptions } from './types';
interface OnInputParams<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
query: string;

@@ -17,3 +17,3 @@ event: any;

}
export declare function onInput<TItem>({ query, event, store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, nextState, refresh, }: OnInputParams<TItem>): Promise<void>;
export declare function onInput<TItem extends BaseItem>({ query, event, store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, nextState, refresh, }: OnInputParams<TItem>): Promise<void>;
export {};

@@ -1,3 +0,3 @@

import { InternalAutocompleteOptions, AutocompleteSetters, AutocompleteStore, AutocompleteRefresh } from './types';
interface OnKeyDownOptions<TItem> extends AutocompleteSetters<TItem> {
import { AutocompleteSetters, AutocompleteStore, AutocompleteRefresh, BaseItem, InternalAutocompleteOptions } from './types';
interface OnKeyDownOptions<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
event: KeyboardEvent;

@@ -8,3 +8,3 @@ store: AutocompleteStore<TItem>;

}
export declare function onKeyDown<TItem>({ event, store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, refresh, }: OnKeyDownOptions<TItem>): void;
export declare function onKeyDown<TItem extends BaseItem>({ event, store, props, setSelectedItemId, setQuery, setCollections, setIsOpen, setStatus, setContext, refresh, }: OnKeyDownOptions<TItem>): void;
export {};

@@ -19,3 +19,3 @@ import { onInput } from './onInput';

event.preventDefault();
store.send(event.key, null);
store.dispatch(event.key, null);
var nodeItem = props.environment.document.getElementById("".concat(props.id, "-item-").concat(store.getState().selectedItemId));

@@ -60,3 +60,3 @@

event.preventDefault();
store.send(event.key, null);
store.dispatch(event.key, null);
} else if (event.key === 'Enter') {

@@ -63,0 +63,0 @@ // No item is selected, so we let the browser handle the native `onSubmit`

@@ -6,3 +6,4 @@ import { MaybePromise } from '@algolia/autocomplete-shared';

import { AutocompleteState } from './state';
export interface AutocompleteApi<TItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> extends AutocompleteSetters<TItem>, AutocompleteAccessibilityGetters<TItem, TEvent, TMouseEvent, TKeyboardEvent> {
export declare type BaseItem = Record<string, unknown>;
export interface AutocompleteApi<TItem extends BaseItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> extends AutocompleteSetters<TItem>, AutocompleteAccessibilityGetters<TItem, TEvent, TMouseEvent, TKeyboardEvent> {
/**

@@ -14,7 +15,11 @@ * Triggers a search to refresh the state.

export declare type AutocompleteRefresh = () => Promise<void>;
export interface AutocompleteCollection<TItem> {
export interface AutocompleteCollection<TItem extends BaseItem> {
source: InternalAutocompleteSource<TItem>;
items: TItem[];
}
export interface GetSourcesParams<TItem> extends AutocompleteSetters<TItem> {
export interface AutocompleteCollectionItemsArray<TItem extends BaseItem> {
source: InternalAutocompleteSource<TItem>;
items: TItem[][];
}
export interface GetSourcesParams<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
query: string;

@@ -24,3 +29,3 @@ state: AutocompleteState<TItem>;

}
interface ItemParams<TItem> {
interface ItemParams<TItem extends BaseItem> {
item: TItem;

@@ -31,12 +36,12 @@ itemInputValue: ReturnType<InternalAutocompleteSource<TItem>['getItemInputValue']>;

}
interface OnSelectParams<TItem> extends ItemParams<TItem>, AutocompleteSetters<TItem> {
export interface OnSelectParams<TItem extends BaseItem> extends ItemParams<TItem>, AutocompleteSetters<TItem> {
state: AutocompleteState<TItem>;
event: any;
}
declare type OnHighlightParams<TItem> = OnSelectParams<TItem>;
interface OnSubmitParams<TItem> extends AutocompleteSetters<TItem> {
export declare type OnHighlightParams<TItem extends BaseItem> = OnSelectParams<TItem>;
interface OnSubmitParams<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
state: AutocompleteState<TItem>;
event: any;
}
interface OnInputParams<TItem> extends AutocompleteSetters<TItem> {
interface OnInputParams<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
query: string;

@@ -46,4 +51,3 @@ state: AutocompleteState<TItem>;

}
export interface AutocompleteSource<TItem> {
[key: string]: unknown;
export interface AutocompleteSource<TItem extends BaseItem> {
/**

@@ -80,6 +84,6 @@ * Get the string value of the item. The value is used to fill the search box.

}
export declare type InternalAutocompleteSource<TItem> = {
export declare type InternalAutocompleteSource<TItem extends BaseItem> = {
[KParam in keyof AutocompleteSource<TItem>]-?: AutocompleteSource<TItem>[KParam];
};
export declare type GetSources<TItem> = (params: GetSourcesParams<TItem>) => Promise<Array<InternalAutocompleteSource<TItem>>>;
export declare type GetSources<TItem extends BaseItem> = (params: GetSourcesParams<TItem>) => Promise<Array<InternalAutocompleteSource<TItem>>>;
export declare type Environment = Window | {

@@ -96,3 +100,3 @@ [prop: string]: unknown;

};
interface Navigator<TItem> {
interface Navigator<TItem extends BaseItem> {
/**

@@ -123,3 +127,3 @@ * Called when a URL should be open in the current page.

}
export interface AutocompleteOptions<TItem> {
export interface AutocompleteOptions<TItem extends BaseItem> {
/**

@@ -135,4 +139,6 @@ * Whether to consider the experience in debug mode.

/**
* The Autocomplete ID to create accessible attributes.
* The unique Autocomplete ID to create accessible attributes.
*
* It is incremented by default when creating a new Autocomplete instance.
*
* @default "autocomplete-0"

@@ -144,3 +150,3 @@ */

*/
onStateChange?<TItem>(props: {
onStateChange?(props: {
state: AutocompleteState<TItem>;

@@ -220,6 +226,6 @@ prevState: AutocompleteState<TItem>;

}
export interface InternalAutocompleteOptions<TItem> extends AutocompleteOptions<TItem> {
export interface InternalAutocompleteOptions<TItem extends BaseItem> extends AutocompleteOptions<TItem> {
debug: boolean;
id: string;
onStateChange<TItem>(props: {
onStateChange(props: {
state: AutocompleteState<TItem>;

@@ -226,0 +232,0 @@ prevState: AutocompleteState<TItem>;

@@ -1,3 +0,3 @@

import { InternalAutocompleteSource } from './api';
export interface AutocompleteAccessibilityGetters<TItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> {
import { BaseItem, InternalAutocompleteSource } from './api';
export interface AutocompleteAccessibilityGetters<TItem extends BaseItem, TEvent = Event, TMouseEvent = MouseEvent, TKeyboardEvent = KeyboardEvent> {
getEnvironmentProps: GetEnvironmentProps;

@@ -14,5 +14,5 @@ getRootProps: GetRootProps;

[key: string]: unknown;
searchBoxElement: HTMLElement;
formElement: HTMLElement;
inputElement: HTMLInputElement;
panelElement: HTMLElement;
inputElement: HTMLInputElement;
}) => {

@@ -49,3 +49,3 @@ onTouchStart(event: TouchEvent): void;

[key: string]: unknown;
inputElement: HTMLInputElement;
inputElement: HTMLInputElement | null;
maxLength?: number;

@@ -86,3 +86,3 @@ }) => {

};
export declare type GetItemProps<TItem, TMouseEvent = MouseEvent> = (props: {
export declare type GetItemProps<TItem extends BaseItem, TMouseEvent = MouseEvent> = (props: {
[key: string]: unknown;

@@ -89,0 +89,0 @@ item: TItem;

@@ -7,1 +7,2 @@ export * from './api';

export * from './store';
export * from './subscriber';

@@ -6,2 +6,3 @@ export * from './api';

export * from './state';
export * from './store';
export * from './store';
export * from './subscriber';

@@ -1,14 +0,21 @@

import { AutocompleteOptions, AutocompleteSource } from './api';
export declare type AutocompletePlugin<TItem, TData = unknown> = Partial<Pick<AutocompleteOptions<TItem>, 'onStateChange' | 'onSubmit' | 'getSources'>> & {
import { AutocompleteOptions, OnHighlightParams, OnSelectParams, BaseItem } from './api';
import { AutocompleteSetters } from './setters';
declare type PluginSubscriber<TParams> = (params: TParams) => void;
interface PluginSubscribeParams<TItem extends BaseItem> extends AutocompleteSetters<TItem> {
onSelect(fn: PluginSubscriber<OnSelectParams<TItem>>): void;
onHighlight(fn: PluginSubscriber<OnHighlightParams<TItem>>): void;
}
export declare type AutocompletePlugin<TItem extends BaseItem, TData = unknown> = Partial<Pick<AutocompleteOptions<TItem>, 'onStateChange' | 'onSubmit' | 'getSources'>> & {
/**
* The subscribed properties are properties that are called when other sources
* are interacted with.
* Function called when Autocomplete starts.
*
* It can be used to subscribe to lifecycle hooks or to interact with the
* Autocomplete state and context.
*/
subscribed?: {
onSelect: AutocompleteSource<TItem>['onSelect'];
};
subscribe?(params: PluginSubscribeParams<TItem>): void;
/**
* An extra plugin specific object to store variables and functions
* Extra plugin object to expose properties and functions as APIs.
*/
data?: TData;
};
export {};

@@ -0,7 +1,8 @@

import { AutocompleteCollection, AutocompleteCollectionItemsArray, BaseItem } from './api';
import { AutocompleteState } from './state';
export declare type StateUpdater<TState> = (value: TState) => void;
export interface AutocompleteSetters<TItem> {
export interface AutocompleteSetters<TItem extends BaseItem> {
setSelectedItemId: StateUpdater<AutocompleteState<TItem>['selectedItemId']>;
setQuery: StateUpdater<AutocompleteState<TItem>['query']>;
setCollections: StateUpdater<AutocompleteState<TItem | TItem[]>['collections']>;
setCollections: StateUpdater<Array<AutocompleteCollection<TItem> | AutocompleteCollectionItemsArray<TItem>>>;
setIsOpen: StateUpdater<AutocompleteState<TItem>['isOpen']>;

@@ -8,0 +9,0 @@ setStatus: StateUpdater<AutocompleteState<TItem>['status']>;

@@ -1,3 +0,3 @@

import { AutocompleteCollection } from './api';
export interface AutocompleteState<TItem> {
import { AutocompleteCollection, BaseItem } from './api';
export interface AutocompleteState<TItem extends BaseItem> {
selectedItemId: number | null;

@@ -4,0 +4,0 @@ query: string;

@@ -1,9 +0,9 @@

import { InternalAutocompleteOptions } from './api';
import { BaseItem, InternalAutocompleteOptions } from './api';
import { AutocompleteState } from './state';
export interface AutocompleteStore<TItem> {
export interface AutocompleteStore<TItem extends BaseItem> {
getState(): AutocompleteState<TItem>;
send(action: ActionType, payload: any): void;
dispatch(action: ActionType, payload: any): void;
}
export declare type Reducer = <TItem>(state: AutocompleteState<TItem>, action: Action<TItem, any>) => AutocompleteState<TItem>;
declare type Action<TItem, TPayload> = {
export declare type Reducer = <TItem extends BaseItem>(state: AutocompleteState<TItem>, action: Action<TItem, any>) => AutocompleteState<TItem>;
declare type Action<TItem extends BaseItem, TPayload> = {
type: ActionType;

@@ -10,0 +10,0 @@ props: InternalAutocompleteOptions<TItem>;

@@ -1,2 +0,2 @@

import { InternalAutocompleteOptions } from '../types';
export declare function getNextSelectedItemId<TItem>(moveAmount: number, baseIndex: number | null, itemCount: number, defaultSelectedItemId: InternalAutocompleteOptions<TItem>['defaultSelectedItemId']): number | null;
import { BaseItem, InternalAutocompleteOptions } from '../types';
export declare function getNextSelectedItemId<TItem extends BaseItem>(moveAmount: number, baseIndex: number | null, itemCount: number, defaultSelectedItemId: InternalAutocompleteOptions<TItem>['defaultSelectedItemId']): number | null;
import { MaybePromise } from '@algolia/autocomplete-shared';
import { AutocompleteSource, GetSourcesParams, InternalAutocompleteSource } from '../types';
export declare function getNormalizedSources<TItem>(getSources: (params: GetSourcesParams<TItem>) => MaybePromise<Array<AutocompleteSource<TItem>>>, options: GetSourcesParams<TItem>): Promise<Array<InternalAutocompleteSource<TItem>>>;
import { AutocompleteSource, BaseItem, GetSourcesParams, InternalAutocompleteSource } from '../types';
export declare function getNormalizedSources<TItem extends BaseItem>(getSources: (params: GetSourcesParams<TItem>) => MaybePromise<Array<AutocompleteSource<TItem>>>, options: GetSourcesParams<TItem>): Promise<Array<InternalAutocompleteSource<TItem>>>;

@@ -8,26 +8,23 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

import { noop } from './noop';
function normalizeSource(source) {
return _objectSpread({
getItemInputValue: function getItemInputValue(_ref) {
var state = _ref.state;
return state.query;
},
getItemUrl: function getItemUrl() {
return undefined;
},
onSelect: function onSelect(_ref2) {
var setIsOpen = _ref2.setIsOpen;
setIsOpen(false);
},
onHighlight: noop
}, source);
}
export function getNormalizedSources(getSources, options) {
return Promise.resolve(getSources(options)).then(function (sources) {
return Promise.all(sources.filter(Boolean).map(function (source) {
return Promise.resolve(normalizeSource(source));
var normalizedSource = _objectSpread({
getItemInputValue: function getItemInputValue(_ref) {
var state = _ref.state;
return state.query;
},
getItemUrl: function getItemUrl() {
return undefined;
},
onSelect: function onSelect(_ref2) {
var setIsOpen = _ref2.setIsOpen;
setIsOpen(false);
},
onHighlight: noop
}, source);
return Promise.resolve(normalizedSource);
}));
});
}

@@ -1,3 +0,3 @@

import { AutocompleteState } from '../types';
export declare function getSelectedItem<TItem>({ state, }: {
import { AutocompleteState, BaseItem } from '../types';
export declare function getSelectedItem<TItem extends BaseItem>({ state, }: {
state: AutocompleteState<TItem>;

@@ -4,0 +4,0 @@ }): {

@@ -0,1 +1,2 @@

export * from './createConcurrentSafePromise';
export * from './flatten';

@@ -2,0 +3,0 @@ export * from './generateAutocompleteId';

@@ -0,1 +1,2 @@

export * from './createConcurrentSafePromise';
export * from './flatten';

@@ -2,0 +3,0 @@ export * from './generateAutocompleteId';

@@ -1,1 +0,1 @@

export declare const version = "1.0.0-alpha.35";
export declare const version = "1.0.0-alpha.36";

@@ -1,1 +0,1 @@

export var version = '1.0.0-alpha.35';
export var version = '1.0.0-alpha.36';

@@ -1,6 +0,6 @@

/*! @algolia/autocomplete-core 1.0.0-alpha.35 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
/*! @algolia/autocomplete-core 1.0.0-alpha.36 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global['@algolia/autocomplete-core'] = {}));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@algolia/autocomplete-core'] = {}));
}(this, (function (exports) { 'use strict';

@@ -160,3 +160,3 @@

},
send: function send(action, payload) {
dispatch: function dispatch(action, payload) {
var prevState = _objectSpread2({}, state);

@@ -225,23 +225,21 @@

function normalizeSource(source) {
return _objectSpread2({
getItemInputValue: function getItemInputValue(_ref) {
var state = _ref.state;
return state.query;
},
getItemUrl: function getItemUrl() {
return undefined;
},
onSelect: function onSelect(_ref2) {
var setIsOpen = _ref2.setIsOpen;
setIsOpen(false);
},
onHighlight: noop
}, source);
}
function getNormalizedSources(getSources, options) {
return Promise.resolve(getSources(options)).then(function (sources) {
return Promise.all(sources.filter(Boolean).map(function (source) {
return Promise.resolve(normalizeSource(source));
var normalizedSource = _objectSpread2({
getItemInputValue: function getItemInputValue(_ref) {
var state = _ref.state;
return state.query;
},
getItemUrl: function getItemUrl() {
return undefined;
},
onSelect: function onSelect(_ref2) {
var setIsOpen = _ref2.setIsOpen;
setIsOpen(false);
},
onHighlight: noop
}, source);
return Promise.resolve(normalizedSource);
}));

@@ -349,7 +347,7 @@ });

var setSelectedItemId = function setSelectedItemId(value) {
store.send('setSelectedItemId', value);
store.dispatch('setSelectedItemId', value);
};
var setQuery = function setQuery(value) {
store.send('setQuery', value);
store.dispatch('setQuery', value);
};

@@ -370,15 +368,15 @@

});
store.send('setCollections', value);
store.dispatch('setCollections', value);
};
var setIsOpen = function setIsOpen(value) {
store.send('setIsOpen', value);
store.dispatch('setIsOpen', value);
};
var setStatus = function setStatus(value) {
store.send('setStatus', value);
store.dispatch('setStatus', value);
};
var setContext = function setContext(value) {
store.send('setContext', value);
store.dispatch('setContext', value);
};

@@ -418,3 +416,3 @@

function getDefaultProps(props) {
function getDefaultProps(props, subscribers) {
var _props$id;

@@ -483,7 +481,15 @@

source.onSelect(params);
plugins.forEach(function (plugin) {
var _plugin$subscribed, _plugin$subscribed$on;
subscribers.forEach(function (subscriber) {
var _subscriber$onSelect;
(_plugin$subscribed = plugin.subscribed) === null || _plugin$subscribed === void 0 ? void 0 : (_plugin$subscribed$on = _plugin$subscribed.onSelect) === null || _plugin$subscribed$on === void 0 ? void 0 : _plugin$subscribed$on.call(_plugin$subscribed, params);
(_subscriber$onSelect = subscriber.onSelect) === null || _subscriber$onSelect === void 0 ? void 0 : _subscriber$onSelect.call(subscriber, params);
});
},
onHighlight: function onHighlight(params) {
source.onHighlight(params);
subscribers.forEach(function (subscriber) {
var _subscriber$onHighlig;
(_subscriber$onHighlig = subscriber.onHighlight) === null || _subscriber$onHighlig === void 0 ? void 0 : _subscriber$onHighlig.call(subscriber, params);
});
}

@@ -645,3 +651,3 @@ });

event.preventDefault();
store.send(event.key, null);
store.dispatch(event.key, null);
var nodeItem = props.environment.document.getElementById("".concat(props.id, "-item-").concat(store.getState().selectedItemId));

@@ -686,3 +692,3 @@

event.preventDefault();
store.send(event.key, null);
store.dispatch(event.key, null);
} else if (event.key === 'Enter') {

@@ -838,3 +844,3 @@ // No item is selected, so we let the browser handle the native `onSubmit`

var isTargetWithinAutocomplete = [getterProps.searchBoxElement, getterProps.panelElement].some(function (contextNode) {
var isTargetWithinAutocomplete = [getterProps.formElement, getterProps.panelElement].some(function (contextNode) {
return contextNode && (isOrContainsNode(contextNode, event.target) || isOrContainsNode(contextNode, props.environment.document.activeElement));

@@ -844,3 +850,3 @@ });

if (isTargetWithinAutocomplete === false) {
store.send('blur', null);
store.dispatch('blur', null);
}

@@ -892,3 +898,3 @@ },

});
store.send('submit', null);
store.dispatch('submit', null);

@@ -918,3 +924,3 @@ if (providedProps.inputElement) {

store.send('reset', null);
store.dispatch('reset', null);

@@ -948,3 +954,3 @@ if (providedProps.inputElement) {

store.send('focus', null);
store.dispatch('focus', null);
}

@@ -1009,3 +1015,3 @@

if (!isTouchDevice) {
store.send('blur', null);
store.dispatch('blur', null);
}

@@ -1052,3 +1058,3 @@ },

onMouseLeave: function onMouseLeave() {
store.send('mouseleave', null);
store.dispatch('mouseleave', null);
}

@@ -1072,3 +1078,3 @@ }, rest);

store.send('mousemove', item.__autocomplete_id);
store.dispatch('mousemove', item.__autocomplete_id);
var highlightedItem = getSelectedItem({

@@ -1334,3 +1340,4 @@ state: store.getState()

checkOptions(options);
var props = getDefaultProps(options);
var subscribers = [];
var props = getDefaultProps(options, subscribers);
var store = createStore(stateReducer, props);

@@ -1387,2 +1394,24 @@

props.plugins.forEach(function (plugin) {
var _plugin$subscribe;
return (_plugin$subscribe = plugin.subscribe) === null || _plugin$subscribe === void 0 ? void 0 : _plugin$subscribe.call(plugin, {
setSelectedItemId: setSelectedItemId,
setQuery: setQuery,
setCollections: setCollections,
setIsOpen: setIsOpen,
setStatus: setStatus,
setContext: setContext,
onSelect: function onSelect(fn) {
subscribers.push({
onSelect: fn
});
},
onHighlight: function onHighlight(fn) {
subscribers.push({
onHighlight: fn
});
}
});
});
return {

@@ -1407,3 +1436,3 @@ setSelectedItemId: setSelectedItemId,

var version = '1.0.0-alpha.35';
var version = '1.0.0-alpha.36';

@@ -1410,0 +1439,0 @@ exports.createAutocomplete = createAutocomplete;

@@ -1,3 +0,3 @@

/*! @algolia/autocomplete-core 1.0.0-alpha.35 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["@algolia/autocomplete-core"]={})}(this,(function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var o=1;o<arguments.length;o++){var s=null!=arguments[o]?arguments[o]:{};o%2?n(Object(s),!0).forEach((function(n){t(e,n,s[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function s(e,t){if(null==e)return{};var n,o,s=function(e,t){if(null==e)return{};var n,o,s={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function r(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function u(e){return e.reduce((function(e,t){return e.concat(t)}),[])}var i=0;function a(e){return 0===e.collections.length?0:e.collections.reduce((function(e,t){return e+t.items.length}),0)}function c(e,t,n,o){if(null===t&&e<0)return n-1;if(null!==o&&0===t&&e<0)return n-1;var s=(null===t?-1:t)+e;return s<=-1||s>=n?null===o?null:0:s}var p=function(){};function d(e,t){return Promise.resolve(e(t)).then((function(e){return Promise.all(e.filter(Boolean).map((function(e){return Promise.resolve(function(e){return o({getItemInputValue:function(e){return e.state.query},getItemUrl:function(){},onSelect:function(e){(0,e.setIsOpen)(!1)},onHighlight:p},e)}(e))})))}))}function m(e){var t=e.state,n=function(e){var t=e.state,n=t.collections.map((function(e){return e.items.length})).reduce((function(e,t,n){var o=(e[n-1]||0)+t;return e.push(o),e}),[]).reduce((function(e,n){return n<=t.selectedItemId?e+1:e}),0);return t.collections[n]}({state:t});if(!n)return null;var o=n.items[function(e){for(var t=e.state,n=e.collection,o=!1,s=0,r=0;!1===o;){var l=t.collections[s];if(l===n){o=!0;break}r+=l.items.length,s++}return t.selectedItemId-r}({state:t,collection:n})],s=n.source;return{item:o,itemInputValue:s.getItemInputValue({item:o,state:t}),itemUrl:s.getItemUrl({item:o,state:t}),source:s}}function f(e,t){return e===t||e.contains&&e.contains(t)}function I(e){var t=e.environment;return{navigate:function(e){var n=e.itemUrl;t.location.assign(n)},navigateNewTab:function(e){var n=e.itemUrl,o=t.open(n,"_blank","noopener");o&&o.focus()},navigateNewWindow:function(e){var n=e.itemUrl;t.open(n,"_blank","noopener")}}}function S(e){var t,n="undefined"!=typeof window?window:{},s=e.plugins||[];return o(o({debug:!1,openOnFocus:!1,placeholder:"",autoFocus:!1,defaultSelectedItemId:null,stallThreshold:300,environment:n,shouldPanelShow:function(e){return a(e.state)>0}},e),{},{id:null!==(t=e.id)&&void 0!==t?t:"autocomplete-".concat(i++),initialState:o({selectedItemId:null,query:"",completion:null,collections:[],isOpen:!1,status:"idle",context:{}},e.initialState),plugins:s,onStateChange:function(t){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t),s.forEach((function(e){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t)}))},onSubmit:function(t){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t),s.forEach((function(e){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t)}))},getSources:function(t){return Promise.all([].concat(r(s.map((function(e){return e.getSources}))),[e.getSources]).filter(Boolean).map((function(e){return d(e,t)}))).then((function(e){return u(e)})).then((function(e){return e.map((function(e){return o(o({},e),{},{onSelect:function(t){e.onSelect(t),s.forEach((function(e){var n,o;null===(n=e.subscribed)||void 0===n||null===(o=n.onSelect)||void 0===o||o.call(n,t)}))}})}))}))},navigator:o(o({},I({environment:n})),e.navigator)})}var g=null;function v(e){var t,n=e.query,s=e.event,r=e.store,l=e.props,u=e.setSelectedItemId,i=e.setQuery,a=e.setCollections,c=e.setIsOpen,p=e.setStatus,d=e.setContext,f=e.nextState,I=void 0===f?{}:f,S=e.refresh;return l.onInput?Promise.resolve(l.onInput({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,refresh:S})):(g&&clearTimeout(g),i(n),u(l.defaultSelectedItemId),0===n.length&&!1===l.openOnFocus?(p("idle"),a(r.getState().collections.map((function(e){return o(o({},e),{},{items:[]})}))),c(null!==(t=I.isOpen)&&void 0!==t?t:l.shouldPanelShow({state:r.getState()})),Promise.resolve()):(p("loading"),g=l.environment.setTimeout((function(){p("stalled")}),l.stallThreshold),l.getSources({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,refresh:S}).then((function(e){return p("loading"),Promise.all(e.map((function(e){return Promise.resolve(e.getItems({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,refresh:S})).then((function(t){return{source:e,items:t}}))}))).then((function(e){var t;p("idle"),a(e),c(null!==(t=I.isOpen)&&void 0!==t?t:0===n.length&&l.openOnFocus||l.shouldPanelShow({state:r.getState()}));var o=m({state:r.getState()});if(null!==r.getState().selectedItemId&&o){var f=o.item,S=o.itemInputValue,g=o.itemUrl,v=o.source;v.onHighlight({item:f,itemInputValue:S,itemUrl:g,source:v,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,event:s})}})).catch((function(e){throw p("error"),e})).finally((function(){g&&clearTimeout(g)}))}))))}function y(e){var t=e.store,n=e.props,r=e.setSelectedItemId,l=e.setQuery,u=e.setCollections,i=e.setIsOpen,a=e.setStatus,c=e.setContext,p=e.refresh;return{getEnvironmentProps:function(e){return{onTouchStart:function(o){!1!==t.getState().isOpen&&o.target!==e.inputElement&&(!1===[e.searchBoxElement,e.panelElement].some((function(e){return e&&(f(e,o.target)||f(e,n.environment.document.activeElement))}))&&t.send("blur",null))},onTouchMove:function(o){!1!==t.getState().isOpen&&e.inputElement===n.environment.document.activeElement&&o.target!==e.inputElement&&e.inputElement.blur()}}},getRootProps:function(e){return o({role:"combobox","aria-expanded":t.getState().isOpen,"aria-haspopup":"listbox","aria-owns":t.getState().isOpen?"".concat(n.id,"-list"):void 0,"aria-labelledby":"".concat(n.id,"-label")},e)},getFormProps:function(e){e.inputElement;return o({action:"",noValidate:!0,role:"search",onSubmit:function(o){o.preventDefault(),n.onSubmit({state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:o}),t.send("submit",null),e.inputElement&&e.inputElement.blur()},onReset:function(o){o.preventDefault(),n.openOnFocus&&v({query:"",event:o,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p}),t.send("reset",null),e.inputElement&&e.inputElement.focus()}},s(e,["inputElement"]))},getLabelProps:function(e){return o({htmlFor:"".concat(n.id,"-input"),id:"".concat(n.id,"-label")},e)},getInputProps:function(e){function d(e){(n.openOnFocus||t.getState().query.length>0)&&v({query:t.getState().completion||t.getState().query,event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p}),t.send("focus",null)}var f="ontouchstart"in n.environment,I=e||{},S=(I.inputElement,I.maxLength),g=void 0===S?512:S,y=s(I,["inputElement","maxLength"]);return o({"aria-autocomplete":"both","aria-activedescendant":t.getState().isOpen&&null!==t.getState().selectedItemId?"".concat(n.id,"-item-").concat(t.getState().selectedItemId):void 0,"aria-controls":t.getState().isOpen?"".concat(n.id,"-list"):void 0,"aria-labelledby":"".concat(n.id,"-label"),value:t.getState().completion||t.getState().query,id:"".concat(n.id,"-input"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",autoFocus:n.autoFocus,placeholder:n.placeholder,maxLength:g,type:"search",onChange:function(e){v({query:e.currentTarget.value.slice(0,g),event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p})},onKeyDown:function(e){!function(e){var t=e.event,n=e.store,o=e.props,s=e.setSelectedItemId,r=e.setQuery,l=e.setCollections,u=e.setIsOpen,i=e.setStatus,a=e.setContext,c=e.refresh;if("ArrowUp"===t.key||"ArrowDown"===t.key){t.preventDefault(),n.send(t.key,null);var p=o.environment.document.getElementById("".concat(o.id,"-item-").concat(n.getState().selectedItemId));p&&(p.scrollIntoViewIfNeeded?p.scrollIntoViewIfNeeded(!1):p.scrollIntoView(!1));var d=m({state:n.getState()});if(null!==n.getState().selectedItemId&&d){var f=d.item,I=d.itemInputValue,S=d.itemUrl,g=d.source;g.onHighlight({item:f,itemInputValue:I,itemUrl:S,source:g,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t})}}else if("Escape"===t.key)t.preventDefault(),n.send(t.key,null);else if("Enter"===t.key){if(null===n.getState().selectedItemId||n.getState().collections.every((function(e){return 0===e.items.length})))return;t.preventDefault();var y=m({state:n.getState()}),h=y.item,O=y.itemInputValue,b=y.itemUrl,C=y.source;if(t.metaKey||t.ctrlKey)void 0!==b&&(C.onSelect({item:h,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),o.navigator.navigateNewTab({itemUrl:b,item:h,state:n.getState()}));else if(t.shiftKey)void 0!==b&&(C.onSelect({item:h,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),o.navigator.navigateNewWindow({itemUrl:b,item:h,state:n.getState()}));else if(t.altKey);else{if(void 0!==b)return C.onSelect({item:h,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),void o.navigator.navigate({itemUrl:b,item:h,state:n.getState()});v({query:O,event:t,store:n,props:o,setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,nextState:{isOpen:!1},refresh:c}).then((function(){C.onSelect({item:h,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t})}))}}}({event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p})},onFocus:d,onBlur:function(){f||t.send("blur",null)},onClick:function(o){e.inputElement!==n.environment.document.activeElement||t.getState().isOpen||d(o)}},y)},getPanelProps:function(e){return o({onMouseDown:function(e){e.preventDefault()},onMouseLeave:function(){t.send("mouseleave",null)}},e)},getListProps:function(e){return o({role:"listbox","aria-labelledby":"".concat(n.id,"-label"),id:"".concat(n.id,"-list")},e)},getItemProps:function(e){var d=e.item,f=e.source,I=s(e,["item","source"]);return o({id:"".concat(n.id,"-item-").concat(d.__autocomplete_id),role:"option","aria-selected":t.getState().selectedItemId===d.__autocomplete_id,onMouseMove:function(e){if(d.__autocomplete_id!==t.getState().selectedItemId){t.send("mousemove",d.__autocomplete_id);var n=m({state:t.getState()});if(null!==t.getState().selectedItemId&&n){var o=n.item,s=n.itemInputValue,p=n.itemUrl,f=n.source;f.onHighlight({item:o,itemInputValue:s,itemUrl:p,source:f,state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:e})}}},onMouseDown:function(e){e.preventDefault()},onClick:function(e){var o=f.getItemInputValue({item:d,state:t.getState()}),s=f.getItemUrl({item:d,state:t.getState()});(s?Promise.resolve():v({query:o,event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p,nextState:{isOpen:!1}})).then((function(){f.onSelect({item:d,itemInputValue:o,itemUrl:s,source:f,state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:e})}))}},I)}}}function h(e){var t=e.state;return!1===t.isOpen||null===t.selectedItemId?null:m({state:t}).itemInputValue||null}var O=function(e,t){switch(t.type){case"setSelectedItemId":return o(o({},e),{},{selectedItemId:t.payload});case"setQuery":return o(o({},e),{},{query:t.payload,completion:null});case"setCollections":return o(o({},e),{},{collections:t.payload});case"setIsOpen":return o(o({},e),{},{isOpen:t.payload});case"setStatus":return o(o({},e),{},{status:t.payload});case"setContext":return o(o({},e),{},{context:o(o({},e.context),t.payload)});case"ArrowDown":var n=o(o({},e),{},{selectedItemId:c(1,e.selectedItemId,a(e),t.props.defaultSelectedItemId)});return o(o({},n),{},{completion:h({state:n})});case"ArrowUp":var s=o(o({},e),{},{selectedItemId:c(-1,e.selectedItemId,a(e),t.props.defaultSelectedItemId)});return o(o({},s),{},{completion:h({state:s})});case"Escape":return e.isOpen?o(o({},e),{},{isOpen:!1,completion:null}):o(o({},e),{},{query:"",status:"idle",collections:[]});case"submit":return o(o({},e),{},{selectedItemId:null,isOpen:!1,status:"idle"});case"reset":return o(o({},e),{},{selectedItemId:!0===t.props.openOnFocus?t.props.defaultSelectedItemId:null,isOpen:t.props.openOnFocus,status:"idle",query:""});case"focus":return o(o({},e),{},{selectedItemId:t.props.defaultSelectedItemId,isOpen:t.props.openOnFocus||e.query.length>0});case"blur":return t.props.debug?e:o(o({},e),{},{isOpen:!1,selectedItemId:null});case"mousemove":return o(o({},e),{},{selectedItemId:t.payload});case"mouseleave":return o(o({},e),{},{selectedItemId:t.props.defaultSelectedItemId});default:return e}};e.createAutocomplete=function(e){var t=S(e),n=function(e,t){var n=t.initialState;return{getState:function(){return n},send:function(s,r){var l=o({},n);n=e(n,{type:s,props:t,payload:r}),t.onStateChange({state:n,prevState:l})}}}(O,t),s=function(e){var t=e.store;return{setSelectedItemId:function(e){t.send("setSelectedItemId",e)},setQuery:function(e){t.send("setQuery",e)},setCollections:function(e){var n=0,s=e.map((function(e){return o(o({},e),{},{items:u(e.items).map((function(e){return o(o({},e),{},{__autocomplete_id:n++})}))})}));t.send("setCollections",s)},setIsOpen:function(e){t.send("setIsOpen",e)},setStatus:function(e){t.send("setStatus",e)},setContext:function(e){t.send("setContext",e)}}}({store:n}),r=s.setSelectedItemId,l=s.setQuery,i=s.setCollections,a=s.setIsOpen,c=s.setStatus,p=s.setContext,d=y({store:n,props:t,setSelectedItemId:r,setQuery:l,setCollections:i,setIsOpen:a,setStatus:c,setContext:p,refresh:x}),m=d.getEnvironmentProps,f=d.getRootProps,I=d.getFormProps,g=d.getLabelProps,h=d.getInputProps,b=d.getPanelProps,C=d.getListProps,P=d.getItemProps;function x(){return v({query:n.getState().query,event:new Event("input"),store:n,props:t,setSelectedItemId:r,setQuery:l,setCollections:i,setIsOpen:a,setStatus:c,setContext:p,nextState:{isOpen:n.getState().isOpen},refresh:x})}return{setSelectedItemId:r,setQuery:l,setCollections:i,setIsOpen:a,setStatus:c,setContext:p,getEnvironmentProps:m,getRootProps:f,getFormProps:I,getInputProps:h,getLabelProps:g,getPanelProps:b,getListProps:C,getItemProps:P,refresh:x}},e.getDefaultProps=S,e.version="1.0.0-alpha.35",Object.defineProperty(e,"__esModule",{value:!0})}));
/*! @algolia/autocomplete-core 1.0.0-alpha.36 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete.js */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/autocomplete-core"]={})}(this,(function(e){"use strict";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var o=1;o<arguments.length;o++){var s=null!=arguments[o]?arguments[o]:{};o%2?n(Object(s),!0).forEach((function(n){t(e,n,s[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function s(e,t){if(null==e)return{};var n,o,s=function(e,t){if(null==e)return{};var n,o,s={},r=Object.keys(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)n=r[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function r(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function u(e){return e.reduce((function(e,t){return e.concat(t)}),[])}var i=0;function a(e){return 0===e.collections.length?0:e.collections.reduce((function(e,t){return e+t.items.length}),0)}function c(e,t,n,o){if(null===t&&e<0)return n-1;if(null!==o&&0===t&&e<0)return n-1;var s=(null===t?-1:t)+e;return s<=-1||s>=n?null===o?null:0:s}var p=function(){};function d(e){var t=e.state,n=function(e){var t=e.state,n=t.collections.map((function(e){return e.items.length})).reduce((function(e,t,n){var o=(e[n-1]||0)+t;return e.push(o),e}),[]).reduce((function(e,n){return n<=t.selectedItemId?e+1:e}),0);return t.collections[n]}({state:t});if(!n)return null;var o=n.items[function(e){for(var t=e.state,n=e.collection,o=!1,s=0,r=0;!1===o;){var l=t.collections[s];if(l===n){o=!0;break}r+=l.items.length,s++}return t.selectedItemId-r}({state:t,collection:n})],s=n.source;return{item:o,itemInputValue:s.getItemInputValue({item:o,state:t}),itemUrl:s.getItemUrl({item:o,state:t}),source:s}}function m(e,t){return e===t||e.contains&&e.contains(t)}function f(e){var t=e.environment;return{navigate:function(e){var n=e.itemUrl;t.location.assign(n)},navigateNewTab:function(e){var n=e.itemUrl,o=t.open(n,"_blank","noopener");o&&o.focus()},navigateNewWindow:function(e){var n=e.itemUrl;t.open(n,"_blank","noopener")}}}function I(e,t){var n,s="undefined"!=typeof window?window:{},l=e.plugins||[];return o(o({debug:!1,openOnFocus:!1,placeholder:"",autoFocus:!1,defaultSelectedItemId:null,stallThreshold:300,environment:s,shouldPanelShow:function(e){return a(e.state)>0}},e),{},{id:null!==(n=e.id)&&void 0!==n?n:"autocomplete-".concat(i++),initialState:o({selectedItemId:null,query:"",completion:null,collections:[],isOpen:!1,status:"idle",context:{}},e.initialState),plugins:l,onStateChange:function(t){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t),l.forEach((function(e){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t)}))},onSubmit:function(t){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t),l.forEach((function(e){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t)}))},getSources:function(n){return Promise.all([].concat(r(l.map((function(e){return e.getSources}))),[e.getSources]).filter(Boolean).map((function(e){return function(e,t){return Promise.resolve(e(t)).then((function(e){return Promise.all(e.filter(Boolean).map((function(e){var t=o({getItemInputValue:function(e){return e.state.query},getItemUrl:function(){},onSelect:function(e){(0,e.setIsOpen)(!1)},onHighlight:p},e);return Promise.resolve(t)})))}))}(e,n)}))).then((function(e){return u(e)})).then((function(e){return e.map((function(e){return o(o({},e),{},{onSelect:function(n){e.onSelect(n),t.forEach((function(e){var t;null===(t=e.onSelect)||void 0===t||t.call(e,n)}))},onHighlight:function(n){e.onHighlight(n),t.forEach((function(e){var t;null===(t=e.onHighlight)||void 0===t||t.call(e,n)}))}})}))}))},navigator:o(o({},f({environment:s})),e.navigator)})}var g=null;function S(e){var t,n=e.query,s=e.event,r=e.store,l=e.props,u=e.setSelectedItemId,i=e.setQuery,a=e.setCollections,c=e.setIsOpen,p=e.setStatus,m=e.setContext,f=e.nextState,I=void 0===f?{}:f,S=e.refresh;return l.onInput?Promise.resolve(l.onInput({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:m,refresh:S})):(g&&clearTimeout(g),i(n),u(l.defaultSelectedItemId),0===n.length&&!1===l.openOnFocus?(p("idle"),a(r.getState().collections.map((function(e){return o(o({},e),{},{items:[]})}))),c(null!==(t=I.isOpen)&&void 0!==t?t:l.shouldPanelShow({state:r.getState()})),Promise.resolve()):(p("loading"),g=l.environment.setTimeout((function(){p("stalled")}),l.stallThreshold),l.getSources({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:m,refresh:S}).then((function(e){return p("loading"),Promise.all(e.map((function(e){return Promise.resolve(e.getItems({query:n,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:m,refresh:S})).then((function(t){return{source:e,items:t}}))}))).then((function(e){var t;p("idle"),a(e),c(null!==(t=I.isOpen)&&void 0!==t?t:0===n.length&&l.openOnFocus||l.shouldPanelShow({state:r.getState()}));var o=d({state:r.getState()});if(null!==r.getState().selectedItemId&&o){var f=o.item,g=o.itemInputValue,S=o.itemUrl,v=o.source;v.onHighlight({item:f,itemInputValue:g,itemUrl:S,source:v,state:r.getState(),setSelectedItemId:u,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:m,event:s})}})).catch((function(e){throw p("error"),e})).finally((function(){g&&clearTimeout(g)}))}))))}function v(e){var t=e.store,n=e.props,r=e.setSelectedItemId,l=e.setQuery,u=e.setCollections,i=e.setIsOpen,a=e.setStatus,c=e.setContext,p=e.refresh;return{getEnvironmentProps:function(e){return{onTouchStart:function(o){!1!==t.getState().isOpen&&o.target!==e.inputElement&&(!1===[e.formElement,e.panelElement].some((function(e){return e&&(m(e,o.target)||m(e,n.environment.document.activeElement))}))&&t.dispatch("blur",null))},onTouchMove:function(o){!1!==t.getState().isOpen&&e.inputElement===n.environment.document.activeElement&&o.target!==e.inputElement&&e.inputElement.blur()}}},getRootProps:function(e){return o({role:"combobox","aria-expanded":t.getState().isOpen,"aria-haspopup":"listbox","aria-owns":t.getState().isOpen?"".concat(n.id,"-list"):void 0,"aria-labelledby":"".concat(n.id,"-label")},e)},getFormProps:function(e){e.inputElement;return o({action:"",noValidate:!0,role:"search",onSubmit:function(o){o.preventDefault(),n.onSubmit({state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:o}),t.dispatch("submit",null),e.inputElement&&e.inputElement.blur()},onReset:function(o){o.preventDefault(),n.openOnFocus&&S({query:"",event:o,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p}),t.dispatch("reset",null),e.inputElement&&e.inputElement.focus()}},s(e,["inputElement"]))},getLabelProps:function(e){return o({htmlFor:"".concat(n.id,"-input"),id:"".concat(n.id,"-label")},e)},getInputProps:function(e){function m(e){(n.openOnFocus||t.getState().query.length>0)&&S({query:t.getState().completion||t.getState().query,event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p}),t.dispatch("focus",null)}var f="ontouchstart"in n.environment,I=e||{},g=(I.inputElement,I.maxLength),v=void 0===g?512:g,h=s(I,["inputElement","maxLength"]);return o({"aria-autocomplete":"both","aria-activedescendant":t.getState().isOpen&&null!==t.getState().selectedItemId?"".concat(n.id,"-item-").concat(t.getState().selectedItemId):void 0,"aria-controls":t.getState().isOpen?"".concat(n.id,"-list"):void 0,"aria-labelledby":"".concat(n.id,"-label"),value:t.getState().completion||t.getState().query,id:"".concat(n.id,"-input"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",autoFocus:n.autoFocus,placeholder:n.placeholder,maxLength:v,type:"search",onChange:function(e){S({query:e.currentTarget.value.slice(0,v),event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p})},onKeyDown:function(e){!function(e){var t=e.event,n=e.store,o=e.props,s=e.setSelectedItemId,r=e.setQuery,l=e.setCollections,u=e.setIsOpen,i=e.setStatus,a=e.setContext,c=e.refresh;if("ArrowUp"===t.key||"ArrowDown"===t.key){t.preventDefault(),n.dispatch(t.key,null);var p=o.environment.document.getElementById("".concat(o.id,"-item-").concat(n.getState().selectedItemId));p&&(p.scrollIntoViewIfNeeded?p.scrollIntoViewIfNeeded(!1):p.scrollIntoView(!1));var m=d({state:n.getState()});if(null!==n.getState().selectedItemId&&m){var f=m.item,I=m.itemInputValue,g=m.itemUrl,v=m.source;v.onHighlight({item:f,itemInputValue:I,itemUrl:g,source:v,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t})}}else if("Escape"===t.key)t.preventDefault(),n.dispatch(t.key,null);else if("Enter"===t.key){if(null===n.getState().selectedItemId||n.getState().collections.every((function(e){return 0===e.items.length})))return;t.preventDefault();var h=d({state:n.getState()}),y=h.item,O=h.itemInputValue,b=h.itemUrl,C=h.source;if(t.metaKey||t.ctrlKey)void 0!==b&&(C.onSelect({item:y,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),o.navigator.navigateNewTab({itemUrl:b,item:y,state:n.getState()}));else if(t.shiftKey)void 0!==b&&(C.onSelect({item:y,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),o.navigator.navigateNewWindow({itemUrl:b,item:y,state:n.getState()}));else if(t.altKey);else{if(void 0!==b)return C.onSelect({item:y,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t}),void o.navigator.navigate({itemUrl:b,item:y,state:n.getState()});S({query:O,event:t,store:n,props:o,setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,nextState:{isOpen:!1},refresh:c}).then((function(){C.onSelect({item:y,itemInputValue:O,itemUrl:b,source:C,state:n.getState(),setSelectedItemId:s,setQuery:r,setCollections:l,setIsOpen:u,setStatus:i,setContext:a,event:t})}))}}}({event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p})},onFocus:m,onBlur:function(){f||t.dispatch("blur",null)},onClick:function(o){e.inputElement!==n.environment.document.activeElement||t.getState().isOpen||m(o)}},h)},getPanelProps:function(e){return o({onMouseDown:function(e){e.preventDefault()},onMouseLeave:function(){t.dispatch("mouseleave",null)}},e)},getListProps:function(e){return o({role:"listbox","aria-labelledby":"".concat(n.id,"-label"),id:"".concat(n.id,"-list")},e)},getItemProps:function(e){var m=e.item,f=e.source,I=s(e,["item","source"]);return o({id:"".concat(n.id,"-item-").concat(m.__autocomplete_id),role:"option","aria-selected":t.getState().selectedItemId===m.__autocomplete_id,onMouseMove:function(e){if(m.__autocomplete_id!==t.getState().selectedItemId){t.dispatch("mousemove",m.__autocomplete_id);var n=d({state:t.getState()});if(null!==t.getState().selectedItemId&&n){var o=n.item,s=n.itemInputValue,p=n.itemUrl,f=n.source;f.onHighlight({item:o,itemInputValue:s,itemUrl:p,source:f,state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:e})}}},onMouseDown:function(e){e.preventDefault()},onClick:function(e){var o=f.getItemInputValue({item:m,state:t.getState()}),s=f.getItemUrl({item:m,state:t.getState()});(s?Promise.resolve():S({query:o,event:e,store:t,props:n,setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,refresh:p,nextState:{isOpen:!1}})).then((function(){f.onSelect({item:m,itemInputValue:o,itemUrl:s,source:f,state:t.getState(),setSelectedItemId:r,setQuery:l,setCollections:u,setIsOpen:i,setStatus:a,setContext:c,event:e})}))}},I)}}}function h(e){var t=e.state;return!1===t.isOpen||null===t.selectedItemId?null:d({state:t}).itemInputValue||null}var y=function(e,t){switch(t.type){case"setSelectedItemId":return o(o({},e),{},{selectedItemId:t.payload});case"setQuery":return o(o({},e),{},{query:t.payload,completion:null});case"setCollections":return o(o({},e),{},{collections:t.payload});case"setIsOpen":return o(o({},e),{},{isOpen:t.payload});case"setStatus":return o(o({},e),{},{status:t.payload});case"setContext":return o(o({},e),{},{context:o(o({},e.context),t.payload)});case"ArrowDown":var n=o(o({},e),{},{selectedItemId:c(1,e.selectedItemId,a(e),t.props.defaultSelectedItemId)});return o(o({},n),{},{completion:h({state:n})});case"ArrowUp":var s=o(o({},e),{},{selectedItemId:c(-1,e.selectedItemId,a(e),t.props.defaultSelectedItemId)});return o(o({},s),{},{completion:h({state:s})});case"Escape":return e.isOpen?o(o({},e),{},{isOpen:!1,completion:null}):o(o({},e),{},{query:"",status:"idle",collections:[]});case"submit":return o(o({},e),{},{selectedItemId:null,isOpen:!1,status:"idle"});case"reset":return o(o({},e),{},{selectedItemId:!0===t.props.openOnFocus?t.props.defaultSelectedItemId:null,isOpen:t.props.openOnFocus,status:"idle",query:""});case"focus":return o(o({},e),{},{selectedItemId:t.props.defaultSelectedItemId,isOpen:t.props.openOnFocus||e.query.length>0});case"blur":return t.props.debug?e:o(o({},e),{},{isOpen:!1,selectedItemId:null});case"mousemove":return o(o({},e),{},{selectedItemId:t.payload});case"mouseleave":return o(o({},e),{},{selectedItemId:t.props.defaultSelectedItemId});default:return e}};e.createAutocomplete=function(e){var t=[],n=I(e,t),s=function(e,t){var n=t.initialState;return{getState:function(){return n},dispatch:function(s,r){var l=o({},n);n=e(n,{type:s,props:t,payload:r}),t.onStateChange({state:n,prevState:l})}}}(y,n),r=function(e){var t=e.store;return{setSelectedItemId:function(e){t.dispatch("setSelectedItemId",e)},setQuery:function(e){t.dispatch("setQuery",e)},setCollections:function(e){var n=0,s=e.map((function(e){return o(o({},e),{},{items:u(e.items).map((function(e){return o(o({},e),{},{__autocomplete_id:n++})}))})}));t.dispatch("setCollections",s)},setIsOpen:function(e){t.dispatch("setIsOpen",e)},setStatus:function(e){t.dispatch("setStatus",e)},setContext:function(e){t.dispatch("setContext",e)}}}({store:s}),l=r.setSelectedItemId,i=r.setQuery,a=r.setCollections,c=r.setIsOpen,p=r.setStatus,d=r.setContext,m=v({store:s,props:n,setSelectedItemId:l,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,refresh:w}),f=m.getEnvironmentProps,g=m.getRootProps,h=m.getFormProps,O=m.getLabelProps,b=m.getInputProps,C=m.getPanelProps,P=m.getListProps,x=m.getItemProps;function w(){return S({query:s.getState().query,event:new Event("input"),store:s,props:n,setSelectedItemId:l,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,nextState:{isOpen:s.getState().isOpen},refresh:w})}return n.plugins.forEach((function(e){var n;return null===(n=e.subscribe)||void 0===n?void 0:n.call(e,{setSelectedItemId:l,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,onSelect:function(e){t.push({onSelect:e})},onHighlight:function(e){t.push({onHighlight:e})}})})),{setSelectedItemId:l,setQuery:i,setCollections:a,setIsOpen:c,setStatus:p,setContext:d,getEnvironmentProps:f,getRootProps:g,getFormProps:h,getInputProps:b,getLabelProps:O,getPanelProps:C,getListProps:P,getItemProps:x,refresh:w}},e.getDefaultProps=I,e.version="1.0.0-alpha.36",Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@algolia/autocomplete-core",
"description": "Core primitives for building autocomplete experiences.",
"version": "1.0.0-alpha.35",
"version": "1.0.0-alpha.36",
"license": "MIT",

@@ -34,4 +34,4 @@ "homepage": "https://github.com/algolia/autocomplete.js",

"dependencies": {
"@algolia/autocomplete-shared": "1.0.0-alpha.35"
"@algolia/autocomplete-shared": "1.0.0-alpha.36"
}
}

@@ -15,2 +15,2 @@ # @algolia/autocomplete-core

[Read documentation →](https://algolia-autocomplete.netlify.app/docs/createAutocomplete)
[Read documentation →](https://autocomplete.algolia.com/docs/createAutocomplete)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc