UNPKG

163 kBTypeScriptView Raw
1/// <reference types="google.maps" />
2
3import type algoliasearch from 'algoliasearch/lite';
4import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
5import type * as ClientSearch from '@algolia/client-search';
6import EventEmitter from '@algolia/events';
7import type { InsightsClient as InsightsClient_2 } from 'search-insights';
8import type { InsightsMethodMap } from 'search-insights';
9import type * as Places from 'places.js';
10import type { PlainSearchParameters } from 'algoliasearch-helper';
11import { default as qs_2 } from 'qs';
12import type { SearchParameters } from 'algoliasearch-helper';
13import type { SearchResults } from 'algoliasearch-helper';
14
15declare type AlgoliaHit = {
16 [attribute: string]: any;
17 objectID: string;
18 _highlightResult?: HitHighlightResult;
19 _snippetResult?: HitSnippetResult;
20 _rankingInfo?: {
21 promoted: boolean;
22 nbTypos: number;
23 firstMatchedWord: number;
24 proximityDistance?: number;
25 geoDistance: number;
26 geoPrecision?: number;
27 nbExactWords: number;
28 words: number;
29 filters: number;
30 userScore: number;
31 matchedGeoLocation?: {
32 lat: number;
33 lng: number;
34 distance: number;
35 };
36 };
37 _distinctSeqID?: number;
38 _geoLoc?: GeoLoc;
39};
40
41declare const analytics: AnalyticsWidget;
42
43declare type AnalyticsWidget = WidgetFactory<AnalyticsWidgetDescription, AnalyticsWidgetParams, AnalyticsWidgetParams>;
44
45declare type AnalyticsWidgetDescription = {
46 $$type: 'ais.analytics';
47 $$widgetType: 'ais.analytics';
48 renderState: Record<string, unknown>;
49 indexRenderState: {
50 analytics: WidgetRenderState<Record<string, unknown>, AnalyticsWidgetParams>;
51 };
52};
53
54declare type AnalyticsWidgetParams = {
55 /**
56 * A function that is called every time the query or refinements changes. You
57 * need to add the logic to push the data to your analytics platform.
58 */
59 pushFunction: AnalyticsWidgetParamsPushFunction;
60 /**
61 * The number of milliseconds between the last search keystroke and calling `pushFunction`.
62 *
63 * @default 3000
64 */
65 delay?: number;
66 /**
67 * Triggers `pushFunction` after click on page or redirecting the page. This is useful if
68 * you want the pushFunction to be called for the last actions before the user leaves the
69 * current page, even if the delay wasn’t reached.
70 *
71 * @default false
72 */
73 triggerOnUIInteraction?: boolean;
74 /**
75 * Triggers `pushFunction` when InstantSearch is initialized. This means
76 * the `pushFunction` might be called even though the user didn’t perfom
77 * any search-related action.
78 *
79 * @default true
80 */
81 pushInitialSearch?: boolean;
82 /**
83 * Triggers `pushFunction` when the page changes, either through the UI or programmatically.
84 *
85 * @default false
86 */
87 pushPagination?: boolean;
88};
89
90declare type AnalyticsWidgetParamsPushFunction = (
91/**
92 * Contains the search parameters, serialized as a query string.
93 */
94formattedParameters: string,
95/**
96 * Contains the whole search state.
97 */
98state: SearchParameters,
99/**
100 * The last received results.
101 */
102results: SearchResults) => void;
103
104declare type AnswersConnector = Connector<AnswersWidgetDescription, AnswersConnectorParams>;
105
106declare type AnswersConnectorParams = {
107 /**
108 * Attributes to use for predictions.
109 * If empty, we use all `searchableAttributes` to find answers.
110 * All your `attributesForPrediction` must be part of your `searchableAttributes`.
111 */
112 attributesForPrediction?: string[];
113 /**
114 * The languages in the query. Currently only supports `en`.
115 */
116 queryLanguages: ['en'];
117 /**
118 * Maximum number of answers to retrieve from the Answers Engine.
119 * Cannot be greater than 1000.
120 * @default 1
121 */
122 nbHits?: number;
123 /**
124 * Debounce time in milliseconds to debounce render
125 * @default 100
126 */
127 renderDebounceTime?: number;
128 /**
129 * Debounce time in milliseconds to debounce search
130 * @default 100
131 */
132 searchDebounceTime?: number;
133 /**
134 * Whether to escape HTML tags from hits string values.
135 *
136 * @default true
137 */
138 escapeHTML?: boolean;
139 /**
140 * Extra parameters to pass to findAnswers method.
141 * @default {}
142 */
143 extraParameters?: FindAnswersOptions;
144};
145
146declare type AnswersCSSClasses = Partial<{
147 /**
148 * CSS class to add to the root element of the widget.
149 */
150 root: string | string[];
151 /**
152 * CSS class to add to the wrapping element when no results.
153 */
154 emptyRoot: string | string[];
155 /**
156 * CSS classes to add to the header.
157 */
158 header: string | string[];
159 /**
160 * CSS classes to add to the loader.
161 */
162 loader: string | string[];
163 /**
164 * CSS class to add to the list of results.
165 */
166 list: string | string[];
167 /**
168 * CSS class to add to each result.
169 */
170 item: string | string[];
171}>;
172
173declare type AnswersRenderState = {
174 /**
175 * The matched hits from Algolia API.
176 */
177 hits: Hits;
178 /**
179 * Whether it's still loading the results from the Answers API.
180 */
181 isLoading: boolean;
182};
183
184declare type AnswersTemplates = Partial<{
185 /**
186 * Template to use for the header. This template will receive an object containing `hits` and `isLoading`.
187 */
188 header: Template<{
189 hits: Hit[];
190 isLoading: boolean;
191 }>;
192 /**
193 * Template to use for the loader.
194 */
195 loader: Template;
196 /**
197 * Template to use for each result. This template will receive an object containing a single record.
198 */
199 item: Template<Hit>;
200}>;
201
202declare type AnswersWidget = WidgetFactory<AnswersWidgetDescription & {
203 $$widgetType: 'ais.answers';
204}, AnswersConnectorParams, AnswersWidgetParams>;
205
206declare const answersWidget: AnswersWidget;
207
208declare type AnswersWidgetDescription = {
209 $$type: 'ais.answers';
210 renderState: AnswersRenderState;
211 indexRenderState: {
212 answers: WidgetRenderState<AnswersRenderState, AnswersConnectorParams>;
213 };
214};
215
216declare type AnswersWidgetParams = {
217 /**
218 * CSS Selector or HTMLElement to insert the widget.
219 */
220 container: string | HTMLElement;
221 /**
222 * The templates to use for the widget.
223 */
224 templates?: AnswersTemplates;
225 /**
226 * The CSS classes to override.
227 */
228 cssClasses?: AnswersCSSClasses;
229};
230
231declare type AnyWidgetFactory = WidgetFactory<{
232 $$type: string;
233}, Record<string, any>, any>;
234
235declare type AtLeastOne<TTarget, TMapped = {
236 [Key in keyof TTarget]: Pick<TTarget, Key>;
237}> = Partial<TTarget> & TMapped[keyof TMapped];
238
239declare type AugmentedWidget<TWidgetFactory extends AnyWidgetFactory, TOverriddenKeys extends keyof Widget = 'init' | 'render' | 'dispose'> = Omit<ReturnType<TWidgetFactory>, TOverriddenKeys> & Pick<Required<Widget>, TOverriddenKeys>;
240
241declare type AutocompleteConnector = Connector<AutocompleteWidgetDescription, AutocompleteConnectorParams>;
242
243declare type AutocompleteConnectorParams = {
244 /**
245 * Escapes HTML entities from hits string values.
246 *
247 * @default `true`
248 */
249 escapeHTML?: boolean;
250};
251
252declare type AutocompleteRenderState = {
253 /**
254 * The current value of the query.
255 */
256 currentRefinement: string;
257 /**
258 * The indices this widget has access to.
259 */
260 indices: Array<{
261 /**
262 * The name of the index
263 */
264 indexName: string;
265 /**
266 * The resolved hits from the index matching the query.
267 */
268 hits: Hits;
269 /**
270 * The full results object from the Algolia API.
271 */
272 results: SearchResults;
273 /**
274 * Send event to insights middleware
275 */
276 sendEvent: SendEventForHits;
277 }>;
278 /**
279 * Searches into the indices with the provided query.
280 */
281 refine: (query: string) => void;
282};
283
284declare type AutocompleteWidgetDescription = {
285 $$type: 'ais.autocomplete';
286 renderState: AutocompleteRenderState;
287 indexRenderState: {
288 autocomplete: WidgetRenderState<AutocompleteRenderState, AutocompleteConnectorParams>;
289 };
290 indexUiState: {
291 query: string;
292 };
293};
294
295declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
296
297declare type Bounds = {
298 /**
299 * The top right corner of the map view.
300 */
301 northEast: GeoLoc;
302 /**
303 * The bottom left corner of the map view.
304 */
305 southWest: GeoLoc;
306};
307
308declare const breadcrumb: BreadcrumbWidget;
309
310declare type BreadcrumbConnector = Connector<BreadcrumbWidgetDescription, BreadcrumbConnectorParams>;
311
312declare type BreadcrumbConnectorParams = {
313 /**
314 * Attributes to use to generate the hierarchy of the breadcrumb.
315 */
316 attributes: string[];
317 /**
318 * Prefix path to use if the first level is not the root level.
319 */
320 rootPath?: string;
321 /**
322 * Function to transform the items passed to the templates.
323 */
324 transformItems?: TransformItems<BreadcrumbConnectorParamsItem>;
325 /**
326 * The level separator used in the records.
327 *
328 * @default '>'
329 */
330 separator?: string;
331};
332
333declare type BreadcrumbConnectorParamsItem = {
334 /**
335 * Label of the category or subcategory.
336 */
337 label: string;
338 /**
339 * Value of breadcrumb item.
340 */
341 value: string | null;
342};
343
344declare type BreadcrumbCSSClasses = Partial<{
345 /**
346 * CSS class to add to the root element of the widget.
347 */
348 root: string | string[];
349 /**
350 * CSS class to add to the root element of the widget if there are no refinements.
351 */
352 noRefinementRoot: string | string[];
353 /**
354 * CSS class to add to the list element.
355 */
356 list: string | string[];
357 /**
358 * CSS class to add to the items of the list. The items contains the link and the separator.
359 */
360 item: string | string[];
361 /**
362 * CSS class to add to the selected item in the list: the last one or the home if there are no refinements.
363 */
364 selectedItem: string | string[];
365 /**
366 * CSS class to add to the separator.
367 */
368 separator: string | string[];
369 /**
370 * CSS class to add to the links in the items.
371 */
372 link: string | string[];
373}>;
374
375declare type BreadcrumbRenderState = {
376 /**
377 * Creates the URL for a single item name in the list.
378 */
379 createURL: CreateURL<BreadcrumbConnectorParamsItem['value']>;
380 /**
381 * Array of objects defining the different values and labels.
382 */
383 items: BreadcrumbConnectorParamsItem[];
384 /**
385 * Sets the path of the hierarchical filter and triggers a new search.
386 */
387 refine: (value: BreadcrumbConnectorParamsItem['value']) => void;
388 /**
389 * True if refinement can be applied.
390 */
391 canRefine: boolean;
392};
393
394declare type BreadcrumbTemplates = Partial<{
395 /**
396 * Label of the breadcrumb's first element.
397 */
398 home: Template;
399 /**
400 * Symbol used to separate the elements of the breadcrumb.
401 */
402 separator: Template;
403}>;
404
405declare type BreadcrumbWidget = WidgetFactory<BreadcrumbWidgetDescription & {
406 $$widgetType: 'ais.breadcrumb';
407}, BreadcrumbConnectorParams, BreadcrumbWidgetParams>;
408
409declare type BreadcrumbWidgetDescription = {
410 $$type: 'ais.breadcrumb';
411 renderState: BreadcrumbRenderState;
412 indexRenderState: {
413 breadcrumb: {
414 [rootAttribute: string]: WidgetRenderState<BreadcrumbRenderState, BreadcrumbConnectorParams>;
415 };
416 };
417};
418
419declare type BreadcrumbWidgetParams = {
420 /**
421 * CSS Selector or HTMLElement to insert the widget.
422 */
423 container: string | HTMLElement;
424 /**
425 * Templates to use for the widget.
426 */
427 templates?: BreadcrumbTemplates;
428 /**
429 * CSS classes to add to the wrapping elements.
430 */
431 cssClasses?: BreadcrumbCSSClasses;
432};
433
434declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
435 /**
436 * Transforms a UI state into a title for the page.
437 */
438 private readonly windowTitle?;
439 /**
440 * Time in milliseconds before performing a write in the history.
441 * It prevents from adding too many entries in the history and
442 * makes the back button more usable.
443 *
444 * @default 400
445 */
446 private readonly writeDelay;
447 /**
448 * Creates a full URL based on the route state.
449 * The storage adaptor maps all syncable keys to the query string of the URL.
450 */
451 private readonly _createURL;
452 /**
453 * Parses the URL into a route state.
454 * It should be symmetrical to `createURL`.
455 */
456 private readonly parseURL;
457 /**
458 * Returns the location to store in the history.
459 * @default () => window.location
460 */
461 private readonly getLocation;
462 private writeTimer?;
463 private _onPopState;
464 /**
465 * Indicates if history.pushState should be executed.
466 * It needs to avoid pushing state to history in case of back/forward in browser
467 */
468 private shouldPushState;
469 /**
470 * Initializes a new storage provider that syncs the search state to the URL
471 * using web APIs (`window.location.pushState` and `onpopstate` event).
472 */
473 constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, }: BrowserHistoryArgs<TRouteState>);
474 /**
475 * Reads the URL and returns a syncable UI search state.
476 */
477 read(): TRouteState;
478 /**
479 * Pushes a search state into the URL.
480 */
481 write(routeState: TRouteState): void;
482 /**
483 * Sets a callback on the `onpopstate` event of the history API of the current page.
484 * It enables the URL sync to keep track of the changes.
485 */
486 onUpdate(callback: (routeState: TRouteState) => void): void;
487 /**
488 * Creates a complete URL from a given syncable UI state.
489 *
490 * It always generates the full URL, not a relative one.
491 * This allows to handle cases like using a <base href>.
492 * See: https://github.com/algolia/instantsearch.js/issues/790
493 */
494 createURL(routeState: TRouteState): string;
495 /**
496 * Removes the event listener and cleans up the URL.
497 */
498 dispose(): void;
499}
500
501declare type BrowserHistoryArgs<TRouteState> = {
502 windowTitle?: (routeState: TRouteState) => string;
503 writeDelay: number;
504 createURL: CreateURL_2<TRouteState>;
505 parseURL: ParseURL<TRouteState>;
506 getLocation(): Location;
507};
508
509declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string;
510
511declare type BuiltInSendEventForFacet = (eventType: string, facetValue: string, eventName?: string) => void;
512
513declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => void;
514
515declare type BuiltInSendEventForToggle = (eventType: string, isRefined: boolean, eventName?: string) => void;
516
517declare const clearRefinements: ClearRefinementsWidget;
518
519declare type ClearRefinementsConnector = Connector<ClearRefinementsWidgetDescription, ClearRefinementsConnectorParams>;
520
521declare type ClearRefinementsConnectorParams = {
522 /**
523 * The attributes to include in the refinements to clear (all by default). Cannot be used with `excludedAttributes`.
524 */
525 includedAttributes?: string[];
526 /**
527 * The attributes to exclude from the refinements to clear. Cannot be used with `includedAttributes`.
528 */
529 excludedAttributes?: string[];
530 /**
531 * Function to transform the items passed to the templates.
532 */
533 transformItems?: TransformItems<string>;
534};
535
536declare type ClearRefinementsCSSClasses = Partial<{
537 /**
538 * CSS class to add to the wrapper element.
539 */
540 root: string | string[];
541 /**
542 * CSS class to add to the button of the widget.
543 */
544 button: string | string[];
545 /**
546 * CSS class to add to the button when there are no refinements.
547 */
548 disabledButton: string | string[];
549}>;
550
551declare type ClearRefinementsRenderState = {
552 /**
553 * Triggers the clear of all the currently refined values.
554 */
555 refine: () => void;
556 /**
557 * Indicates if search state is refined.
558 * @deprecated prefer reading canRefine
559 */
560 hasRefinements: boolean;
561 /**
562 * Indicates if search state can be refined.
563 */
564 canRefine: boolean;
565 /**
566 * Creates a url for the next state when refinements are cleared.
567 */
568 createURL: CreateURL<void>;
569};
570
571declare type ClearRefinementsTemplates = Partial<{
572 /**
573 * Template for the content of the button
574 */
575 resetLabel: Template;
576}>;
577
578declare type ClearRefinementsWidget = WidgetFactory<ClearRefinementsWidgetDescription & {
579 $$widgetType: 'ais.clearRefinements';
580}, ClearRefinementsConnectorParams, ClearRefinementsWidgetParams>;
581
582declare type ClearRefinementsWidgetDescription = {
583 $$type: 'ais.clearRefinements';
584 renderState: ClearRefinementsRenderState;
585 indexRenderState: {
586 clearRefinements: WidgetRenderState<ClearRefinementsRenderState, ClearRefinementsConnectorParams>;
587 };
588};
589
590declare type ClearRefinementsWidgetParams = {
591 /**
592 * CSS Selector or HTMLElement to insert the widget.
593 */
594 container: string | HTMLElement;
595 /**
596 * Templates to use for the widget.
597 */
598 templates?: ClearRefinementsTemplates;
599 /**
600 * CSS classes to be added.
601 */
602 cssClasses?: ClearRefinementsCSSClasses;
603};
604
605declare type ComponentCSSClasses<TCSSClasses> = Required<{
606 [className in keyof TCSSClasses]: string;
607}>;
608
609declare const configure: ConfigureWidget;
610
611declare type ConfigureConnector = Connector<ConfigureWidgetDescription, ConfigureConnectorParams>;
612
613declare type ConfigureConnectorParams = {
614 /**
615 * A list of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/)
616 * to enable when the widget mounts.
617 */
618 searchParameters: PlainSearchParameters;
619};
620
621declare const configureRelatedItems: ConfigureRelatedItemsWidget;
622
623declare type ConfigureRelatedItemsConnector = Connector<ConfigureRelatedItemsWidgetDescription, ConfigureRelatedItemsConnectorParams>;
624
625declare type ConfigureRelatedItemsConnectorParams = {
626 /**
627 * The reference hit to extract the filters from.
628 */
629 hit: AlgoliaHit;
630 /**
631 * The schema to create the optional filters.
632 * Each key represents an attribute from the hit.
633 */
634 matchingPatterns: MatchingPatterns;
635 /**
636 * Function to transform the generated search parameters.
637 */
638 transformSearchParameters?: TransformSearchParameters;
639};
640
641declare type ConfigureRelatedItemsWidget = WidgetFactory<ConfigureRelatedItemsWidgetDescription & {
642 $$widgetType: 'ais.configureRelatedItems';
643}, ConfigureRelatedItemsConnectorParams, ConfigureRelatedItemsWidgetParams>;
644
645declare type ConfigureRelatedItemsWidgetDescription = {
646 $$type: 'ais.configureRelatedItems';
647} & Omit<ConfigureWidgetDescription, '$$type'>;
648
649declare type ConfigureRelatedItemsWidgetParams = PlainSearchParameters;
650
651declare type ConfigureRenderState = {
652 /**
653 * Refine the given search parameters.
654 */
655 refine: Refine;
656};
657
658declare type ConfigureWidget = (widgetParams: ConfigureWidgetParams) => Widget<ConfigureWidgetDescription & {
659 $$widgetType: 'ais.configure';
660 widgetParams: ConfigureConnectorParams;
661}>;
662
663declare type ConfigureWidgetDescription = {
664 $$type: 'ais.configure';
665 renderState: ConfigureRenderState;
666 indexRenderState: {
667 configure: WidgetRenderState<ConfigureRenderState, ConfigureConnectorParams>;
668 };
669 indexUiState: {
670 configure: PlainSearchParameters;
671 };
672};
673
674/**
675 * A list of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/)
676 * to enable when the widget mounts.
677 */
678declare type ConfigureWidgetParams = ConfigureConnectorParams['searchParameters'];
679
680declare const connectAnswers: AnswersConnector;
681
682declare const connectAutocomplete: AutocompleteConnector;
683
684declare const connectBreadcrumb: BreadcrumbConnector;
685
686declare const connectClearRefinements: ClearRefinementsConnector;
687
688declare const connectConfigure: ConfigureConnector;
689
690declare const connectConfigureRelatedItems: ConfigureRelatedItemsConnector;
691
692declare const connectCurrentRefinements: CurrentRefinementsConnector;
693
694declare const connectDynamicWidgets: DynamicWidgetsConnector;
695
696/**
697 * The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example).
698 *
699 * @requirements
700 *
701 * Note that the GeoSearch connector uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia. Your hits **must** have a `_geoloc` attribute in order to be passed to the rendering function.
702 *
703 * Currently, the feature is not compatible with multiple values in the _geoloc attribute.
704 */
705declare const connectGeoSearch: GeoSearchConnector;
706
707/**
708 * **HierarchicalMenu** connector provides the logic to build a custom widget
709 * that will give the user the ability to explore facets in a tree-like structure.
710 *
711 * This is commonly used for multi-level categorization of products on e-commerce
712 * websites. From a UX point of view, we suggest not displaying more than two
713 * levels deep.
714 *
715 * @type {Connector}
716 * @param {function(HierarchicalMenuRenderingOptions, boolean)} renderFn Rendering function for the custom **HierarchicalMenu** widget.
717 * @param {function} unmountFn Unmount function called when the widget is disposed.
718 * @return {function(CustomHierarchicalMenuWidgetParams)} Re-usable widget factory for a custom **HierarchicalMenu** widget.
719 */
720declare const connectHierarchicalMenu: HierarchicalMenuConnector;
721
722declare const connectHits: HitsConnector;
723
724declare const connectHitsPerPage: HitsPerPageConnector;
725
726declare const connectHitsWithInsights: HitsConnector;
727
728declare const connectInfiniteHits: InfiniteHitsConnector;
729
730declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector;
731
732/**
733 * **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories.
734 *
735 * This connector provides a `toggleShowMore()` function to display more or less items and a `refine()`
736 * function to select an item. While selecting a new element, the `refine` will also unselect the
737 * one that is currently selected.
738 *
739 * **Requirement:** the attribute passed as `attribute` must be present in "attributes for faceting" on the Algolia dashboard or configured as attributesForFaceting via a set settings call to the Algolia API.
740 */
741declare const connectMenu: MenuConnector;
742
743declare const connectNumericMenu: NumericMenuConnector;
744
745/**
746 * The connector handles the business logic and exposes
747 * a simplified API to the rendering function.
748 */
749declare type Connector<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams> = <TWidgetParams extends UnknownWidgetParams>(
750/**
751 * The render function.
752 */
753renderFn: Renderer<TWidgetDescription['renderState'], TConnectorParams & TWidgetParams>,
754/**
755 * The called function when unmounting a widget.
756 */
757unmountFn?: Unmounter) => (widgetParams: TConnectorParams & TWidgetParams) => Widget<TWidgetDescription & {
758 widgetParams: typeof widgetParams;
759}>;
760
761declare type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] & AutocompleteWidgetDescription['indexRenderState'] & BreadcrumbWidgetDescription['indexRenderState'] & ClearRefinementsWidgetDescription['indexRenderState'] & ConfigureWidgetDescription['indexRenderState'] & CurrentRefinementsWidgetDescription['indexRenderState'] & GeoSearchWidgetDescription['indexRenderState'] & HierarchicalMenuWidgetDescription['indexRenderState'] & HitsWidgetDescription['indexRenderState'] & HitsPerPageWidgetDescription['indexRenderState'] & InfiniteHitsWidgetDescription['indexRenderState'] & MenuWidgetDescription['indexRenderState'] & NumericMenuWidgetDescription['indexRenderState'] & PaginationWidgetDescription['indexRenderState'] & PoweredByWidgetDescription['indexRenderState'] & QueryRulesWidgetDescription['indexRenderState'] & RangeWidgetDescription['indexRenderState'] & RatingMenuWidgetDescription['indexRenderState'] & RefinementListWidgetDescription['indexRenderState'] & RelevantSortWidgetDescription['indexRenderState'] & SearchBoxWidgetDescription['indexRenderState'] & SortByWidgetDescription['indexRenderState'] & StatsWidgetDescription['indexRenderState'] & ToggleRefinementWidgetDescription['indexRenderState'] & VoiceSearchWidgetDescription['indexRenderState'];
762
763declare namespace connectors {
764 export {
765 connectClearRefinements,
766 connectCurrentRefinements,
767 connectHierarchicalMenu,
768 connectHits,
769 connectHitsWithInsights,
770 connectHitsPerPage,
771 connectInfiniteHits,
772 connectInfiniteHitsWithInsights,
773 connectMenu,
774 connectNumericMenu,
775 connectPagination,
776 connectRange,
777 connectRefinementList,
778 connectSearchBox,
779 connectSortBy,
780 connectRatingMenu,
781 connectStats,
782 connectToggleRefinement,
783 connectBreadcrumb,
784 connectGeoSearch,
785 connectPoweredBy,
786 connectConfigure,
787 connectConfigureRelatedItems as EXPERIMENTAL_connectConfigureRelatedItems,
788 connectAutocomplete,
789 connectQueryRules,
790 connectVoiceSearch,
791 connectAnswers as EXPERIMENTAL_connectAnswers,
792 connectRelevantSort,
793 connectDynamicWidgets,
794 EXPERIMENTAL_connectDynamicWidgets
795 }
796}
797
798declare type ConnectorUiStates = AutocompleteWidgetDescription['indexUiState'] & ConfigureWidgetDescription['indexUiState'] & GeoSearchWidgetDescription['indexUiState'] & HierarchicalMenuWidgetDescription['indexUiState'] & HitsPerPageWidgetDescription['indexUiState'] & InfiniteHitsWidgetDescription['indexUiState'] & MenuWidgetDescription['indexUiState'] & NumericMenuWidgetDescription['indexUiState'] & PaginationWidgetDescription['indexUiState'] & RangeWidgetDescription['indexUiState'] & RatingMenuWidgetDescription['indexUiState'] & RefinementListWidgetDescription['indexUiState'] & RelevantSortWidgetDescription['indexUiState'] & SearchBoxWidgetDescription['indexUiState'] & SortByWidgetDescription['indexUiState'] & ToggleRefinementWidgetDescription['indexUiState'] & VoiceSearchWidgetDescription['indexUiState'];
799
800/**
801 * **Pagination** connector provides the logic to build a widget that will let the user
802 * choose the current page of the results.
803 *
804 * When using the pagination with Algolia, you should be aware that the engine won't provide you pages
805 * beyond the 1000th hits by default. You can find more information on the [Algolia documentation](https://www.algolia.com/doc/guides/searching/pagination/#pagination-limitations).
806 */
807declare const connectPagination: PaginationConnector;
808
809/**
810 * **PoweredBy** connector provides the logic to build a custom widget that will displays
811 * the logo to redirect to Algolia.
812 */
813declare const connectPoweredBy: PoweredByConnector;
814
815declare const connectQueryRules: QueryRulesConnector;
816
817/**
818 * **Range** connector provides the logic to create custom widget that will let
819 * the user refine results using a numeric range.
820 *
821 * This connectors provides a `refine()` function that accepts bounds. It will also provide
822 * information about the min and max bounds for the current result set.
823 */
824declare const connectRange: RangeConnector;
825
826/**
827 * **StarRating** connector provides the logic to build a custom widget that will let
828 * the user refine search results based on ratings.
829 *
830 * The connector provides to the rendering: `refine()` to select a value and
831 * `items` that are the values that can be selected. `refine` should be used
832 * with `items.value`.
833 */
834declare const connectRatingMenu: RatingMenuConnector;
835
836/**
837 * **RefinementList** connector provides the logic to build a custom widget that
838 * will let the user filter the results based on the values of a specific facet.
839 *
840 * **Requirement:** the attribute passed as `attribute` must be present in
841 * attributesForFaceting of the searched index.
842 *
843 * This connector provides:
844 * - a `refine()` function to select an item.
845 * - a `toggleShowMore()` function to display more or less items
846 * - a `searchForItems()` function to search within the items.
847 */
848declare const connectRefinementList: RefinementListConnector;
849
850declare const connectRelevantSort: RelevantSortConnector;
851
852/**
853 * **SearchBox** connector provides the logic to build a widget that will let the user search for a query.
854 *
855 * The connector provides to the rendering: `refine()` to set the query. The behaviour of this function
856 * may be impacted by the `queryHook` widget parameter.
857 */
858declare const connectSearchBox: SearchBoxConnector;
859
860declare const connectSortBy: SortByConnector;
861
862declare const connectStats: StatsConnector;
863
864/**
865 * **Toggle** connector provides the logic to build a custom widget that will provide
866 * an on/off filtering feature based on an attribute value or values.
867 *
868 * Two modes are implemented in the custom widget:
869 * - with or without the value filtered
870 * - switch between two values.
871 */
872declare const connectToggleRefinement: ToggleRefinementConnector;
873
874declare const connectVoiceSearch: VoiceSearchConnector;
875
876declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
877
878declare type CreateInsightsMiddleware = (props: InsightsProps) => InternalMiddleware;
879
880declare const createInsightsMiddleware: CreateInsightsMiddleware;
881
882/**
883 * Exposes the metadata of mounted widgets in a custom
884 * `<meta name="instantsearch:widgets" />` tag. The metadata per widget is:
885 * - applied parameters
886 * - widget name
887 * - connector name
888 */
889declare function createMetadataMiddleware(): InternalMiddleware;
890
891declare const createRouterMiddleware: <TUiState extends UiState = UiState, TRouteState = TUiState>(props?: RouterProps<TUiState, TRouteState>) => InternalMiddleware<TUiState>;
892
893/**
894 * Creates the URL for the given value.
895 */
896declare type CreateURL<TValue> = (value: TValue) => string;
897
898declare type CreateURL_2<TRouteState> = (args: {
899 qsModule: typeof qs_2;
900 routeState: TRouteState;
901 location: Location;
902}) => string;
903
904declare type CreateVoiceSearchHelper = (params: VoiceSearchHelperParams) => VoiceSearchHelper;
905
906declare const currentRefinements: CurrentRefinementsWidget;
907
908declare type CurrentRefinementsConnector = Connector<CurrentRefinementsWidgetDescription, CurrentRefinementsConnectorParams>;
909
910declare type CurrentRefinementsConnectorParams = {
911 /**
912 * The attributes to include in the widget (all by default).
913 * Cannot be used with `excludedAttributes`.
914 *
915 * @default `[]`
916 */
917 includedAttributes?: string[];
918 /**
919 * The attributes to exclude from the widget.
920 * Cannot be used with `includedAttributes`.
921 *
922 * @default `['query']`
923 */
924 excludedAttributes?: string[];
925 /**
926 * Function to transform the items passed to the templates.
927 */
928 transformItems?: TransformItems<CurrentRefinementsConnectorParamsItem>;
929};
930
931declare type CurrentRefinementsConnectorParamsItem = {
932 /**
933 * The index name.
934 */
935 indexName: string;
936 /**
937 * The attribute on which the refinement is applied.
938 */
939 attribute: string;
940 /**
941 * The textual representation of this attribute.
942 */
943 label: string;
944 /**
945 * Currently applied refinements.
946 */
947 refinements: CurrentRefinementsConnectorParamsRefinement[];
948 /**
949 * Removes the given refinement and triggers a new search.
950 */
951 refine(refinement: CurrentRefinementsConnectorParamsRefinement): void;
952};
953
954declare type CurrentRefinementsConnectorParamsRefinement = {
955 /**
956 * The attribute on which the refinement is applied.
957 */
958 attribute: string;
959 /**
960 * The type of the refinement.
961 *
962 * It can be one of those: 'facet'|'exclude'|'disjunctive'|'hierarchical'|'numeric'|'query'|'tag'.
963 */
964 type: string;
965 /**
966 * The raw value of the refinement.
967 */
968 value: string | number;
969 /**
970 * The label of the refinement to display.
971 */
972 label: string;
973 /**
974 * The value of the operator (only if applicable).
975 */
976 operator?: string;
977 /**
978 * The number of found items (only if applicable).
979 */
980 count?: number;
981 /**
982 * Whether the count is exhaustive (only if applicable).
983 */
984 exhaustive?: boolean;
985};
986
987declare type CurrentRefinementsCSSClasses = Partial<{
988 /**
989 * CSS class to add to the root element.
990 */
991 root: string | string[];
992 /**
993 * CSS class to add to the list element.
994 */
995 list: string | string[];
996 /**
997 * CSS class to add to the each item element.
998 */
999 item: string | string[];
1000 /**
1001 * CSS class to add to the label element.
1002 */
1003 label: string | string[];
1004 /**
1005 * CSS class to add to the category element.
1006 */
1007 category: string | string[];
1008 /**
1009 * CSS class to add to the categoryLabel element.
1010 */
1011 categoryLabel: string | string[];
1012 /**
1013 * CSS class to add to the delete element.
1014 */
1015 delete: string | string[];
1016}>;
1017
1018declare type CurrentRefinementsRenderState = {
1019 /**
1020 * All the currently refined items, grouped by attribute.
1021 */
1022 items: CurrentRefinementsConnectorParamsItem[];
1023 /**
1024 * Indicates if search state can be refined.
1025 */
1026 canRefine: boolean;
1027 /**
1028 * Removes the given refinement and triggers a new search.
1029 */
1030 refine(refinement: CurrentRefinementsConnectorParamsRefinement): void;
1031 /**
1032 * Generates a URL for the next state.
1033 */
1034 createURL: CreateURL<CurrentRefinementsConnectorParamsRefinement>;
1035};
1036
1037declare type CurrentRefinementsWidget = WidgetFactory<CurrentRefinementsWidgetDescription & {
1038 $$widgetType: 'ais.currentRefinements';
1039}, CurrentRefinementsConnectorParams, CurrentRefinementsWidgetParams>;
1040
1041declare type CurrentRefinementsWidgetDescription = {
1042 $$type: 'ais.currentRefinements';
1043 renderState: CurrentRefinementsRenderState;
1044 indexRenderState: {
1045 currentRefinements: WidgetRenderState<CurrentRefinementsRenderState, CurrentRefinementsConnectorParams>;
1046 };
1047};
1048
1049declare type CurrentRefinementsWidgetParams = {
1050 /**
1051 * The CSS Selector or `HTMLElement` to insert the widget into.
1052 */
1053 container: string | HTMLElement;
1054 /**
1055 * The CSS classes to override.
1056 */
1057 cssClasses?: CurrentRefinementsCSSClasses;
1058};
1059
1060declare type CustomBindEventForHits = (customPayload: any) => string;
1061
1062declare type CustomSendEventForFacet = (customPayload: any) => void;
1063
1064declare type CustomSendEventForHits = (customPayload: any) => void;
1065
1066declare type CustomSendEventForToggle = (customPayload: any) => void;
1067
1068declare type DefaultSearchClient = ReturnType<typeof algoliasearch>;
1069
1070declare type DisposeOptions = {
1071 helper: AlgoliaSearchHelper;
1072 state: SearchParameters;
1073 parent: IndexWidget;
1074};
1075
1076declare type DummySearchClientV4 = {
1077 readonly transporter: any;
1078};
1079
1080declare const dynamicWidgets: DynamicWidgetsWidget;
1081
1082declare type DynamicWidgetsConnector = Connector<DynamicWidgetsWidgetDescription, DynamicWidgetsConnectorParams>;
1083
1084declare type DynamicWidgetsConnectorParams = {
1085 /**
1086 * An array of widgets, displayed in the order defined by `facetOrdering`.
1087 */
1088 widgets: Widget[];
1089 /**
1090 * Function to return a fallback widget when an attribute isn't found in
1091 * `widgets`.
1092 */
1093 fallbackWidget?(args: {
1094 /** The attribute name to create a widget for. */
1095 attribute: string;
1096 }): Widget;
1097 /**
1098 * Function to transform the items to render.
1099 * The function also exposes the full search response.
1100 */
1101 transformItems?(items: string[], metadata: {
1102 results: SearchResults;
1103 }): string[];
1104 /**
1105 * To prevent unneeded extra network requests when widgets mount or unmount,
1106 * we request all facet values.
1107 *
1108 * @default ['*']
1109 */
1110 facets?: ['*'] | never[];
1111 /**
1112 * If you have more than 20 facet values pinned, you need to increase the
1113 * maxValuesPerFacet to at least that value.
1114 *
1115 * @default 20
1116 */
1117 maxValuesPerFacet?: number;
1118};
1119
1120declare type DynamicWidgetsRenderState = {
1121 attributesToRender: string[];
1122};
1123
1124declare type DynamicWidgetsWidget = WidgetFactory<DynamicWidgetsWidgetDescription & {
1125 $$widgetType: 'ais.dynamicWidgets';
1126}, Omit<DynamicWidgetsConnectorParams, 'widgets' | 'fallbackWidget'>, DynamicWidgetsWidgetParams>;
1127
1128declare type DynamicWidgetsWidgetDescription = {
1129 $$type: 'ais.dynamicWidgets';
1130 renderState: DynamicWidgetsRenderState;
1131 indexRenderState: {
1132 dynamicWidgets: DynamicWidgetsRenderState;
1133 };
1134};
1135
1136declare type DynamicWidgetsWidgetParams = {
1137 /**
1138 * CSS Selector or HTMLElement to insert the widget.
1139 */
1140 container: string | HTMLElement;
1141 /**
1142 * An array of widget creator functions, displayed in the order defined by
1143 * `facetOrdering`.
1144 */
1145 widgets: Array<(container: HTMLElement) => Widget>;
1146 /**
1147 * Function to return a fallback widget when an attribute isn't found in
1148 * `widgets`.
1149 */
1150 fallbackWidget?(args: {
1151 /** The attribute name to create a widget for. */
1152 attribute: string;
1153 /** CSS Selector or HTMLElement to insert the widget */
1154 container: HTMLElement;
1155 }): Widget;
1156};
1157
1158declare type Expand<T> = T extends infer O ? {
1159 [K in keyof O]: O[K];
1160} : never;
1161
1162/** @deprecated use connectDynamicWidgets */
1163declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1164
1165/** @deprecated use dynamicWidgets */
1166declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1167
1168declare type FindAnswersOptions = DefaultSearchClient extends DummySearchClientV4 ? ClientSearch.FindAnswersOptions : any;
1169
1170declare type GeoHit = Hit & Required<Pick<Hit, '_geoLoc'>>;
1171
1172declare type GeoLoc = {
1173 lat: number;
1174 lng: number;
1175};
1176
1177/**
1178 * The **GeoSearch** widget displays the list of results from the search on a Google Maps. It also provides a way to search for results based on their position. The widget also provide some of the common GeoSearch patterns like search on map interaction.
1179 *
1180 * @requirements
1181 *
1182 * Note that the GeoSearch widget uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia. Your hits **must** have a `_geoloc` attribute in order to be displayed on the map.
1183 *
1184 * Currently, the feature is not compatible with multiple values in the _geoloc attribute.
1185 *
1186 * You are also responsible for loading the Google Maps library, it's not shipped with InstantSearch. You need to load the Google Maps library and pass a reference to the widget. You can find more information about how to install the library in [the Google Maps documentation](https://developers.google.com/maps/documentation/javascript/tutorial).
1187 *
1188 * Don't forget to explicitly set the `height` of the map container (default class `.ais-geo-search--map`), otherwise it won't be shown (it's a requirement of Google Maps).
1189 */
1190declare const geoSearch: GeoSearchWidget;
1191
1192declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription, GeoSearchConnectorParams>;
1193
1194declare type GeoSearchConnectorParams = {
1195 /**
1196 * If true, refine will be triggered as you move the map.
1197 * @default true
1198 */
1199 enableRefineOnMapMove?: boolean;
1200 /**
1201 * Function to transform the items passed to the templates.
1202 * @default items => items
1203 */
1204 transformItems?: TransformItems<GeoHit>;
1205};
1206
1207declare type GeoSearchCSSClasses = Partial<{
1208 /** The root div of the widget. */
1209 root: string | string[];
1210 /** The map container of the widget. */
1211 map: string | string[];
1212 /** The control element of the widget. */
1213 control: string | string[];
1214 /** The label of the control element. */
1215 label: string | string[];
1216 /** The selected label of the control element. */
1217 selectedLabel: string | string[];
1218 /** The input of the control element. */
1219 input: string | string[];
1220 /** The redo search button. */
1221 redo: string | string[];
1222 /** The disabled redo search button. */
1223 disabledRedo: string | string[];
1224 /** The reset refinement button. */
1225 reset: string | string[];
1226}>;
1227
1228declare type GeoSearchMarker<TOptions> = {
1229 /**
1230 * Function used to create the options passed to the Google Maps marker.
1231 * See the documentation for more information:
1232 * https://developers.google.com/maps/documentation/javascript/reference/3/#MarkerOptions
1233 */
1234 createOptions?(item: GeoHit): TOptions;
1235 /**
1236 * Object that takes an event type (ex: `click`, `mouseover`) as key and a
1237 * listener as value. The listener is provided with an object that contains:
1238 * `event`, `item`, `marker`, `map`.
1239 */
1240 events: {
1241 [key: string]: (event: {
1242 item: any;
1243 marker: any;
1244 map: any;
1245 event: any;
1246 }) => void;
1247 };
1248};
1249
1250declare type GeoSearchRenderState = {
1251 /**
1252 * Reset the current bounding box refinement.
1253 */
1254 clearMapRefinement(): void;
1255 /**
1256 * The current bounding box of the search.
1257 */
1258 currentRefinement?: Bounds;
1259 /**
1260 * Return true if the map has move since the last refinement.
1261 */
1262 hasMapMoveSinceLastRefine(): boolean;
1263 /**
1264 * Return true if the current refinement is set with the map bounds.
1265 */
1266 isRefinedWithMap(): boolean;
1267 /**
1268 * Return true if the user is able to refine on map move.
1269 */
1270 isRefineOnMapMove(): boolean;
1271 /**
1272 * The matched hits from Algolia API.
1273 */
1274 items: GeoHit[];
1275 /**
1276 * The current position of the search.
1277 */
1278 position?: GeoLoc;
1279 /**
1280 * Sets a bounding box to filter the results from the given map bounds.
1281 */
1282 refine(bounds: Bounds): void;
1283 /**
1284 * Send event to insights middleware
1285 */
1286 sendEvent: SendEventForHits;
1287 /**
1288 * Set the fact that the map has moved since the last refinement, should be
1289 * called on each map move. The call to the function triggers a new rendering
1290 * only when the value change.
1291 */
1292 setMapMoveSinceLastRefine(): void;
1293 /**
1294 * Toggle the fact that the user is able to refine on map move.
1295 */
1296 toggleRefineOnMapMove(): void;
1297};
1298
1299declare type GeoSearchTemplates = Partial<{
1300 /** Template to use for the marker. */
1301 HTMLMarker: Template<GeoHit>;
1302 /** Template for the reset button. */
1303 reset: Template;
1304 /** Template for the toggle label. */
1305 toggle: Template;
1306 /** Template for the redo button. */
1307 redo: Template;
1308}>;
1309
1310declare type GeoSearchWidget = WidgetFactory<GeoSearchWidgetDescription & {
1311 $$widgetType: 'ais.geoSearch';
1312}, GeoSearchConnectorParams, GeoSearchWidgetParams>;
1313
1314declare type GeoSearchWidgetDescription = {
1315 $$type: 'ais.geoSearch';
1316 renderState: GeoSearchRenderState;
1317 indexRenderState: {
1318 geoSearch: WidgetRenderState<GeoSearchRenderState, GeoSearchConnectorParams>;
1319 };
1320 indexUiState: {
1321 geoSearch: {
1322 /**
1323 * The rectangular area in geo coordinates.
1324 * The rectangle is defined by two diagonally opposite points,
1325 * hence by 4 floats separated by commas.
1326 *
1327 * @example '47.3165,4.9665,47.3424,5.0201'
1328 */
1329 boundingBox: string;
1330 };
1331 };
1332};
1333
1334declare type GeoSearchWidgetParams = {
1335 /**
1336 * By default the map will set the zoom accordingly to the markers displayed on it.
1337 * When we refine it may happen that the results are empty. For those situations we
1338 * need to provide a zoom to render the map.
1339 * @default 1
1340 */
1341 initialZoom?: number;
1342 /**
1343 * By default the map will set the position accordingly to the markers displayed on it.
1344 * When we refine it may happen that the results are empty. For those situations we need
1345 * to provide a position to render the map. This option is ignored when the `position`
1346 * is provided.
1347 * @default { lat: 0, lng: 0 }
1348 */
1349 initialPosition?: GeoLoc;
1350 /** Templates to use for the widget. */
1351 templates?: GeoSearchTemplates;
1352 /** CSS classes to add to the wrapping elements. */
1353 cssClasses?: GeoSearchCSSClasses;
1354 /**
1355 * Options for customize the built-in Google Maps marker. This option is
1356 * ignored when the `customHTMLMarker` is provided.
1357 */
1358 builtInMarker?: Partial<GeoSearchMarker<google.maps.MarkerOptions>>;
1359 /**
1360 * Options to customize the HTML marker. We provide an alternative to the
1361 * built-in Google Maps marker in order to have a full control of the marker
1362 * rendering. You can use plain HTML to build your marker.
1363 */
1364 customHTMLMarker?: Partial<GeoSearchMarker<Partial<HTMLMarkerArguments>>> | boolean;
1365 /**
1366 * If true, the map is used to search - otherwise it's for display purposes only.
1367 * @default true
1368 */
1369 enableRefine?: boolean;
1370 /**
1371 * If true, a button is displayed on the map when the refinement is coming from
1372 * the map in order to remove it.
1373 * @default true
1374 */
1375 enableClearMapRefinement?: boolean;
1376 /**
1377 * If true, the user can toggle the option `enableRefineOnMapMove` directly from the map.
1378 * @default true
1379 */
1380 enableRefineControl?: boolean;
1381 /**
1382 * Option forwarded to the Google Maps constructor.
1383 * See the documentation for more information:
1384 * https://developers.google.com/maps/documentation/javascript/reference/3/#MapOptions
1385 */
1386 mapOptions?: google.maps.MapOptions;
1387 /**
1388 * CSS Selector or HTMLElement to insert the widget.
1389 */
1390 container: string | HTMLElement;
1391 /**
1392 * Reference to the global `window.google` object.
1393 * See [the documentation](https://developers.google.com/maps/documentation/javascript/tutorial) for more information.
1394 */
1395 googleReference: typeof window['google'];
1396};
1397
1398/**
1399 * @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
1400 */
1401declare function getInsightsAnonymousUserToken(): string | undefined;
1402
1403declare function getInsightsAnonymousUserTokenInternal(): string | undefined;
1404
1405declare type GetWidgetRenderState<TWidgetFactory extends AnyWidgetFactory> = ReturnType<TWidgetFactory>['getWidgetRenderState'] extends (renderOptions: any) => infer TRenderState ? TRenderState extends Record<string, unknown> ? TRenderState : never : Record<string, unknown>;
1406
1407declare namespace helpers {
1408 export {
1409 reverseHighlight,
1410 reverseSnippet,
1411 highlight,
1412 snippet,
1413 insights,
1414 getInsightsAnonymousUserToken,
1415 getInsightsAnonymousUserTokenInternal,
1416 HighlightOptions,
1417 ReverseHighlightOptions,
1418 SnippetOptions,
1419 ReverseSnippetOptions
1420 }
1421}
1422
1423declare const hierarchicalMenu: HierarchicalMenuWidget;
1424
1425declare type HierarchicalMenuConnector = Connector<HierarchicalMenuWidgetDescription, HierarchicalMenuConnectorParams>;
1426
1427declare type HierarchicalMenuConnectorParams = {
1428 /**
1429 * Attributes to use to generate the hierarchy of the menu.
1430 */
1431 attributes: string[];
1432 /**
1433 * Separator used in the attributes to separate level values.
1434 */
1435 separator?: string;
1436 /**
1437 * Prefix path to use if the first level is not the root level.
1438 */
1439 rootPath?: string | null;
1440 /**
1441 * Show the siblings of the selected parent levels of the current refined value. This
1442 * does not impact the root level.
1443 */
1444 showParentLevel?: boolean;
1445 /**
1446 * Max number of values to display.
1447 */
1448 limit?: number;
1449 /**
1450 * Whether to display the "show more" button.
1451 */
1452 showMore?: boolean;
1453 /**
1454 * Max number of values to display when showing more.
1455 */
1456 showMoreLimit?: number;
1457 /**
1458 * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.
1459 * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).
1460 *
1461 * If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
1462 */
1463 sortBy?: SortBy<HierarchicalMenuItem>;
1464 /**
1465 * Function to transform the items passed to the templates.
1466 */
1467 transformItems?: TransformItems<HierarchicalMenuItem>;
1468};
1469
1470declare type HierarchicalMenuCSSClasses = Partial<{
1471 /**
1472 * CSS class to add to the root element.
1473 */
1474 root: string | string[];
1475 /**
1476 * CSS class to add to the root element when no refinements.
1477 */
1478 noRefinementRoot: string | string[];
1479 /**
1480 * CSS class to add to the list element.
1481 */
1482 list: string | string[];
1483 /**
1484 * CSS class to add to the child list element.
1485 */
1486 childList: string | string[];
1487 /**
1488 * CSS class to add to each item element.
1489 */
1490 item: string | string[];
1491 /**
1492 * CSS class to add to each selected item element.
1493 */
1494 selectedItem: string | string[];
1495 /**
1496 * CSS class to add to each parent item element.
1497 */
1498 parentItem: string | string[];
1499 /**
1500 * CSS class to add to each link (when using the default template).
1501 */
1502 link: string | string[];
1503 /**
1504 * CSS class to add to each label (when using the default template).
1505 */
1506 label: string | string[];
1507 /**
1508 * CSS class to add to each count element (when using the default template).
1509 */
1510 count: string | string[];
1511 /**
1512 * CSS class to add to the show more element.
1513 */
1514 showMore: string | string[];
1515 /**
1516 * CSS class to add to the disabled show more element.
1517 */
1518 disabledShowMore: string | string[];
1519}>;
1520
1521declare type HierarchicalMenuItem = {
1522 /**
1523 * Value of the menu item.
1524 */
1525 value: string;
1526 /**
1527 * Human-readable value of the menu item.
1528 */
1529 label: string;
1530 /**
1531 * Number of matched results after refinement is applied.
1532 */
1533 count: number;
1534 /**
1535 * Indicates if the refinement is applied.
1536 */
1537 isRefined: boolean;
1538 /**
1539 * n+1 level of items, same structure HierarchicalMenuItem
1540 */
1541 data: HierarchicalMenuItem[] | null;
1542};
1543
1544declare type HierarchicalMenuRenderState = {
1545 /**
1546 * Creates an url for the next state for a clicked item.
1547 */
1548 createURL: CreateURL<string>;
1549 /**
1550 * Values to be rendered.
1551 */
1552 items: HierarchicalMenuItem[];
1553 /**
1554 * Sets the path of the hierarchical filter and triggers a new search.
1555 */
1556 refine: (value: string) => void;
1557 /**
1558 * Indicates if search state can be refined.
1559 */
1560 canRefine: boolean;
1561 /**
1562 * True if the menu is displaying all the menu items.
1563 */
1564 isShowingMore: boolean;
1565 /**
1566 * Toggles the number of values displayed between `limit` and `showMoreLimit`.
1567 */
1568 toggleShowMore: () => void;
1569 /**
1570 * `true` if the toggleShowMore button can be activated (enough items to display more or
1571 * already displaying more than `limit` items)
1572 */
1573 canToggleShowMore: boolean;
1574 /**
1575 * Send event to insights middleware
1576 */
1577 sendEvent: SendEventForFacet;
1578};
1579
1580declare type HierarchicalMenuTemplates = Partial<{
1581 /**
1582 * Item template, provided with `name`, `count`, `isRefined`, `url` data properties.
1583 */
1584 item: Template<{
1585 name: string;
1586 count: number;
1587 isRefined: boolean;
1588 url: string;
1589 }>;
1590 /**
1591 * Template used for the show more text, provided with `isShowingMore` data property.
1592 */
1593 showMoreText: Template<{
1594 isShowingMore: boolean;
1595 }>;
1596}>;
1597
1598/**
1599 * The hierarchical menu widget is used to create a navigation based on a hierarchy of facet attributes.
1600 *
1601 * It is commonly used for categories with subcategories.
1602 *
1603 * All attributes (lvl0, lvl1 here) must be declared as [attributes for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) in your
1604 * Algolia settings.
1605 *
1606 * By default, the separator we expect is ` > ` (with spaces) but you can use
1607 * a different one by using the `separator` option.
1608 * @requirements
1609 * Your objects must be formatted in a specific way to be
1610 * able to display hierarchical menus. Here's an example:
1611 *
1612 * ```javascript
1613 * {
1614 * "objectID": "123",
1615 * "name": "orange",
1616 * "categories": {
1617 * "lvl0": "fruits",
1618 * "lvl1": "fruits > citrus"
1619 * }
1620 * }
1621 * ```
1622 *
1623 * Every level must be specified entirely.
1624 * It's also possible to have multiple values per level, for example:
1625 *
1626 * ```javascript
1627 * {
1628 * "objectID": "123",
1629 * "name": "orange",
1630 * "categories": {
1631 * "lvl0": ["fruits", "vitamins"],
1632 * "lvl1": ["fruits > citrus", "vitamins > C"]
1633 * }
1634 * }
1635 * ```
1636 * @type {WidgetFactory}
1637 * @devNovel HierarchicalMenu
1638 * @category filter
1639 * @param {HierarchicalMenuWidgetParams} widgetParams The HierarchicalMenu widget options.
1640 * @return {Widget} A new HierarchicalMenu widget instance.
1641 * @example
1642 * search.addWidgets([
1643 * instantsearch.widgets.hierarchicalMenu({
1644 * container: '#hierarchical-categories',
1645 * attributes: ['hierarchicalCategories.lvl0', 'hierarchicalCategories.lvl1', 'hierarchicalCategories.lvl2'],
1646 * })
1647 * ]);
1648 */
1649declare type HierarchicalMenuWidget = WidgetFactory<HierarchicalMenuWidgetDescription & {
1650 $$widgetType: 'ais.hierarchicalMenu';
1651}, HierarchicalMenuConnectorParams, HierarchicalMenuWidgetParams>;
1652
1653declare type HierarchicalMenuWidgetDescription = {
1654 $$type: 'ais.hierarchicalMenu';
1655 renderState: HierarchicalMenuRenderState;
1656 indexRenderState: {
1657 hierarchicalMenu: {
1658 [rootAttribute: string]: WidgetRenderState<HierarchicalMenuRenderState, HierarchicalMenuConnectorParams>;
1659 };
1660 };
1661 indexUiState: {
1662 hierarchicalMenu: {
1663 [rootAttribute: string]: string[];
1664 };
1665 };
1666};
1667
1668declare type HierarchicalMenuWidgetParams = {
1669 /**
1670 * CSS Selector or HTMLElement to insert the widget.
1671 */
1672 container: string | HTMLElement;
1673 /**
1674 * Array of attributes to use to generate the hierarchy of the menu.
1675 */
1676 attributes: string[];
1677 /**
1678 * Separator used in the attributes to separate level values.
1679 */
1680 separator?: string;
1681 /**
1682 * Prefix path to use if the first level is not the root level.
1683 */
1684 rootPath?: string;
1685 /**
1686 * Show the siblings of the selected parent level of the current refined value.
1687 *
1688 * With `showParentLevel` set to `true` (default):
1689 * - Parent lvl0
1690 * - **lvl1**
1691 * - **lvl2**
1692 * - lvl2
1693 * - lvl2
1694 * - lvl 1
1695 * - lvl 1
1696 * - Parent lvl0
1697 * - Parent lvl0
1698 *
1699 * With `showParentLevel` set to `false`:
1700 * - Parent lvl0
1701 * - **lvl1**
1702 * - **lvl2**
1703 * - Parent lvl0
1704 * - Parent lvl0
1705 */
1706 showParentLevel?: boolean;
1707 /**
1708 * Max number of values to display.
1709 */
1710 limit?: number;
1711 /**
1712 * Whether to display the "show more" button.
1713 */
1714 showMore?: boolean;
1715 /**
1716 * Max number of values to display when showing more.
1717 * does not impact the root level.
1718 */
1719 showMoreLimit?: number;
1720 /**
1721 * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.
1722 * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).
1723 */
1724 sortBy?: SortBy<HierarchicalMenuItem>;
1725 /**
1726 * Function to transform the items passed to the templates.
1727 */
1728 transformItems?: TransformItems<HierarchicalMenuItem>;
1729 /**
1730 * Templates to use for the widget.
1731 */
1732 templates?: HierarchicalMenuTemplates;
1733 /**
1734 * CSS classes to add to the wrapping elements.
1735 */
1736 cssClasses?: HierarchicalMenuCSSClasses;
1737};
1738
1739declare function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string;
1740
1741declare type HighlightOptions = {
1742 attribute: string | string[];
1743 highlightedTagName?: string;
1744 hit: Partial<Hit>;
1745 cssClasses?: Partial<{
1746 highlighted: string;
1747 }>;
1748};
1749
1750declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
1751
1752declare type Hit = {
1753 __position: number;
1754 __queryID?: string;
1755} & AlgoliaHit;
1756
1757declare type HitAttributeHighlightResult = {
1758 value: string;
1759 matchLevel: 'none' | 'partial' | 'full';
1760 matchedWords: string[];
1761 fullyHighlighted?: boolean;
1762};
1763
1764declare type HitAttributeSnippetResult = Pick<HitAttributeHighlightResult, 'value' | 'matchLevel'>;
1765
1766declare type HitHighlightResult = {
1767 [attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
1768};
1769
1770declare type Hits = Hit[];
1771
1772declare const hits: HitsWidget;
1773
1774declare type HitsConnector = Connector<HitsWidgetDescription, HitsConnectorParams>;
1775
1776declare type HitsConnectorParams = {
1777 /**
1778 * Whether to escape HTML tags from hits string values.
1779 *
1780 * @default true
1781 */
1782 escapeHTML?: boolean;
1783 /**
1784 * Function to transform the items passed to the templates.
1785 */
1786 transformItems?: TransformItems<Hit>;
1787};
1788
1789declare type HitsCSSClasses = Partial<{
1790 /**
1791 * CSS class to add to the wrapping element.
1792 */
1793 root: string | string[];
1794 /**
1795 * CSS class to add to the wrapping element when no results.
1796 */
1797 emptyRoot: string | string[];
1798 /**
1799 * CSS class to add to the list of results.
1800 */
1801 list: string | string[];
1802 /**
1803 * CSS class to add to each result.
1804 */
1805 item: string | string[];
1806}>;
1807
1808declare type HitSnippetResult = {
1809 [attribute: string]: HitAttributeSnippetResult[] | HitSnippetResult[] | HitAttributeSnippetResult | HitSnippetResult;
1810};
1811
1812declare const hitsPerPage: HitsPerPageWidget;
1813
1814declare type HitsPerPageConnector = Connector<HitsPerPageWidgetDescription, HitsPerPageConnectorParams>;
1815
1816declare type HitsPerPageConnectorParams = {
1817 /**
1818 * Array of objects defining the different values and labels.
1819 */
1820 items: HitsPerPageConnectorParamsItem[];
1821 /**
1822 * Function to transform the items passed to the templates.
1823 */
1824 transformItems?: TransformItems<HitsPerPageRenderStateItem>;
1825};
1826
1827declare type HitsPerPageConnectorParamsItem = {
1828 /**
1829 * Label to display in the option.
1830 */
1831 label: string;
1832 /**
1833 * Number of hits to display per page.
1834 */
1835 value: number;
1836 /**
1837 * The default hits per page on first search.
1838 *
1839 * @default false
1840 */
1841 default?: boolean;
1842};
1843
1844declare type HitsPerPageCSSClasses = Partial<{
1845 /**
1846 * CSS classes added to the outer `<div>`.
1847 */
1848 root: string | string[];
1849 /**
1850 * CSS classes added to the parent `<select>`.
1851 */
1852 select: string | string[];
1853 /**
1854 * CSS classes added to each `<option>`.
1855 */
1856 option: string | string[];
1857}>;
1858
1859declare type HitsPerPageRenderState = {
1860 /**
1861 * Array of objects defining the different values and labels.
1862 */
1863 items: HitsPerPageRenderStateItem[];
1864 /**
1865 * Sets the number of hits per page and triggers a search.
1866 */
1867 refine: (value: number) => void;
1868 /**
1869 * Indicates whether or not the search has results.
1870 */
1871 hasNoResults: boolean;
1872};
1873
1874declare type HitsPerPageRenderStateItem = {
1875 /**
1876 * Label to display in the option.
1877 */
1878 label: string;
1879 /**
1880 * Number of hits to display per page.
1881 */
1882 value: number;
1883 /**
1884 * Indicates if it's the current refined value.
1885 */
1886 isRefined: boolean;
1887};
1888
1889declare type HitsPerPageWidget = WidgetFactory<HitsPerPageWidgetDescription & {
1890 $$widgetType: 'ais.hitsPerPage';
1891}, HitsPerPageConnectorParams, HitsPerPageWidgetParams>;
1892
1893declare type HitsPerPageWidgetDescription = {
1894 $$type: 'ais.hitsPerPage';
1895 renderState: HitsPerPageRenderState;
1896 indexRenderState: {
1897 hitsPerPage: WidgetRenderState<HitsPerPageRenderState, HitsPerPageConnectorParams>;
1898 };
1899 indexUiState: {
1900 hitsPerPage: number;
1901 };
1902};
1903
1904declare type HitsPerPageWidgetParams = {
1905 /**
1906 * CSS Selector or HTMLElement to insert the widget.
1907 */
1908 container: string | HTMLElement;
1909 /**
1910 * CSS classes to be added.
1911 */
1912 cssClasses?: HitsPerPageCSSClasses;
1913};
1914
1915declare type HitsRenderState = {
1916 /**
1917 * The matched hits from Algolia API.
1918 */
1919 hits: Hits;
1920 /**
1921 * The response from the Algolia API.
1922 */
1923 results?: SearchResults<Hit>;
1924 /**
1925 * Sends an event to the Insights middleware.
1926 */
1927 sendEvent: SendEventForHits;
1928 /**
1929 * Returns a string for the `data-insights-event` attribute for the Insights middleware
1930 */
1931 bindEvent: BindEventForHits;
1932};
1933
1934declare type HitsTemplates = Partial<{
1935 /**
1936 * Template to use when there are no results.
1937 *
1938 * @default 'No Results'
1939 */
1940 empty: Template;
1941 /**
1942 * Template to use for each result. This template will receive an object containing a single record.
1943 *
1944 * @default ''
1945 */
1946 item: TemplateWithBindEvent<Hit & {
1947 __hitIndex: number;
1948 }>;
1949}>;
1950
1951declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
1952 $$widgetType: 'ais.hits';
1953}, HitsConnectorParams, HitsWidgetParams>;
1954
1955declare type HitsWidgetDescription = {
1956 $$type: 'ais.hits';
1957 renderState: HitsRenderState;
1958 indexRenderState: {
1959 hits: WidgetRenderState<HitsRenderState, HitsConnectorParams>;
1960 };
1961};
1962
1963declare type HitsWidgetParams = {
1964 /**
1965 * CSS Selector or HTMLElement to insert the widget.
1966 */
1967 container: string | HTMLElement;
1968 /**
1969 * Templates to use for the widget.
1970 */
1971 templates?: HitsTemplates;
1972 /**
1973 * CSS classes to add.
1974 */
1975 cssClasses?: HitsCSSClasses;
1976};
1977
1978declare type HTMLMarkerArguments = {
1979 __id: string;
1980 position: google.maps.LatLngLiteral;
1981 map: google.maps.Map;
1982 template: string;
1983 title?: string;
1984 className: string;
1985 anchor?: {
1986 x: number;
1987 y: number;
1988 };
1989};
1990
1991declare const index: (widgetParams: IndexWidgetParams) => IndexWidget;
1992
1993declare type IndexInitOptions = Pick<InitOptions, 'instantSearchInstance' | 'parent' | 'uiState'>;
1994
1995declare type IndexRenderOptions = Pick<RenderOptions, 'instantSearchInstance'>;
1996
1997declare type IndexRenderState = Partial<ConnectorRenderStates & WidgetRenderStates>;
1998
1999declare type IndexUiState = Partial<ConnectorUiStates & WidgetUiStates>;
2000
2001declare type IndexWidget = Omit<Widget<IndexWidgetDescription & {
2002 widgetParams: IndexWidgetParams;
2003}>, 'getWidgetUiState' | 'getWidgetState'> & {
2004 getIndexName(): string;
2005 getIndexId(): string;
2006 getHelper(): AlgoliaSearchHelper | null;
2007 getResults(): SearchResults | null;
2008 getScopedResults(): ScopedResult[];
2009 getParent(): IndexWidget | null;
2010 getWidgets(): Array<Widget | IndexWidget>;
2011 createURL(state: SearchParameters): string;
2012 addWidgets(widgets: Array<Widget | IndexWidget>): IndexWidget;
2013 removeWidgets(widgets: Array<Widget | IndexWidget>): IndexWidget;
2014 init(options: IndexInitOptions): void;
2015 render(options: IndexRenderOptions): void;
2016 dispose(): void;
2017 /**
2018 * @deprecated
2019 */
2020 getWidgetState(uiState: UiState): UiState;
2021 getWidgetUiState<TUiState = UiState>(uiState: TUiState): TUiState;
2022 getWidgetSearchParameters(searchParameters: SearchParameters, searchParametersOptions: {
2023 uiState: IndexUiState;
2024 }): SearchParameters;
2025 refreshUiState(): void;
2026};
2027
2028declare type IndexWidgetDescription = {
2029 $$type: 'ais.index';
2030 $$widgetType: 'ais.index';
2031};
2032
2033declare type IndexWidgetParams = {
2034 indexName: string;
2035 indexId?: string;
2036};
2037
2038declare const infiniteHits: InfiniteHitsWidget;
2039
2040declare type InfiniteHitsCache = {
2041 read: Read;
2042 write: Write;
2043};
2044
2045declare type InfiniteHitsCachedHits = {
2046 [page: number]: Hits;
2047};
2048
2049declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription, InfiniteHitsConnectorParams>;
2050
2051declare type InfiniteHitsConnectorParams = {
2052 /**
2053 * Escapes HTML entities from hits string values.
2054 *
2055 * @default `true`
2056 */
2057 escapeHTML?: boolean;
2058 /**
2059 * Enable the button to load previous results.
2060 *
2061 * @default `false`
2062 */
2063 showPrevious?: boolean;
2064 /**
2065 * Receives the items, and is called before displaying them.
2066 * Useful for mapping over the items to transform, and remove or reorder them.
2067 */
2068 transformItems?: TransformItems<Hit>;
2069 /**
2070 * Reads and writes hits from/to cache.
2071 * When user comes back to the search page after leaving for product page,
2072 * this helps restore InfiniteHits and its scroll position.
2073 */
2074 cache?: InfiniteHitsCache;
2075};
2076
2077declare type InfiniteHitsCSSClasses = Partial<{
2078 /**
2079 * The root element of the widget.
2080 */
2081 root: string | string[];
2082 /**
2083 * The root container without results.
2084 */
2085 emptyRoot: string | string[];
2086 /**
2087 * The list of results.
2088 */
2089 list: string | string[];
2090 /**
2091 * The list item.
2092 */
2093 item: string | string[];
2094 /**
2095 * The “Show previous” button.
2096 */
2097 loadPrevious: string | string[];
2098 /**
2099 * The disabled “Show previous” button.
2100 */
2101 disabledLoadPrevious: string | string[];
2102 /**
2103 * The “Show more” button.
2104 */
2105 loadMore: string | string[];
2106 /**
2107 * The disabled “Show more” button.
2108 */
2109 disabledLoadMore: string | string[];
2110}>;
2111
2112declare type InfiniteHitsRenderState = {
2113 /**
2114 * Loads the previous results.
2115 */
2116 showPrevious: () => void;
2117 /**
2118 * Loads the next page of hits.
2119 */
2120 showMore: () => void;
2121 /**
2122 * Indicates whether the first page of hits has been reached.
2123 */
2124 isFirstPage: boolean;
2125 /**
2126 * Indicates whether the last page of hits has been reached.
2127 */
2128 isLastPage: boolean;
2129 /**
2130 * Send event to insights middleware
2131 */
2132 sendEvent: SendEventForHits;
2133 /**
2134 * Returns a string of data-insights-event attribute for insights middleware
2135 */
2136 bindEvent: BindEventForHits;
2137 /**
2138 * Hits for the current page
2139 */
2140 currentPageHits: Hits;
2141 /**
2142 * Hits for current and cached pages
2143 */
2144 hits: Hits;
2145 /**
2146 * The response from the Algolia API.
2147 */
2148 results?: SearchResults<Hit>;
2149};
2150
2151declare type InfiniteHitsTemplates = Partial<{
2152 /**
2153 * The template to use when there are no results.
2154 */
2155 empty: Template<{
2156 results: SearchResults;
2157 }>;
2158 /**
2159 * The template to use for the “Show previous” label.
2160 */
2161 showPreviousText: Template;
2162 /**
2163 * The template to use for the “Show more” label.
2164 */
2165 showMoreText: Template;
2166 /**
2167 * The template to use for each result.
2168 */
2169 item: TemplateWithBindEvent<Hit & {
2170 __hitIndex: number;
2171 }>;
2172}>;
2173
2174declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription & {
2175 $$widgetType: 'ais.infiniteHits';
2176}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
2177
2178declare type InfiniteHitsWidgetDescription = {
2179 $$type: 'ais.infiniteHits';
2180 renderState: InfiniteHitsRenderState;
2181 indexRenderState: {
2182 infiniteHits: WidgetRenderState<InfiniteHitsRenderState, InfiniteHitsConnectorParams>;
2183 };
2184 indexUiState: {
2185 page: number;
2186 };
2187};
2188
2189declare type InfiniteHitsWidgetParams = {
2190 /**
2191 * The CSS Selector or `HTMLElement` to insert the widget into.
2192 */
2193 container: string | HTMLElement;
2194 /**
2195 * The CSS classes to override.
2196 */
2197 cssClasses?: InfiniteHitsCSSClasses;
2198 /**
2199 * The templates to use for the widget.
2200 */
2201 templates?: InfiniteHitsTemplates;
2202 /**
2203 * Reads and writes hits from/to cache.
2204 * When user comes back to the search page after leaving for product page,
2205 * this helps restore InfiniteHits and its scroll position.
2206 */
2207 cache?: InfiniteHitsCache;
2208};
2209
2210declare type InitialResult = {
2211 state: PlainSearchParameters;
2212 results: SearchResults['_rawResults'];
2213};
2214
2215declare type InitialResults = Record<string, InitialResult>;
2216
2217declare type InitOptions = SharedRenderOptions & {
2218 uiState: UiState;
2219 results?: undefined;
2220};
2221
2222/**
2223 * @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
2224 */
2225declare function insights(method: InsightsClientMethod, payload: Partial<InsightsClientPayload>): string;
2226
2227declare type InsightsClient = InsightsClient_2 & {
2228 queue?: QueueItem[];
2229};
2230
2231declare type InsightsClientMethod = keyof InsightsMethodMap;
2232
2233declare type InsightsClientPayload = {
2234 eventName: string;
2235 queryID: string;
2236 index: string;
2237 objectIDs: string[];
2238 positions?: number[];
2239};
2240
2241declare type InsightsEvent = {
2242 insightsMethod?: InsightsClientMethod;
2243 payload: any;
2244 widgetType: string;
2245 eventType: string;
2246 hits?: Hit[];
2247 attribute?: string;
2248};
2249
2250declare type InsightsProps = {
2251 insightsClient: null | InsightsClient;
2252 insightsInitParams?: {
2253 userHasOptedOut?: boolean;
2254 useCookie?: boolean;
2255 cookieDuration?: number;
2256 region?: 'de' | 'us';
2257 };
2258 onEvent?: (event: InsightsEvent, insightsClient: null | InsightsClient) => void;
2259};
2260
2261/**
2262 * The actual implementation of the InstantSearch. This is
2263 * created using the `instantsearch` factory function.
2264 * It emits the 'render' event every time a search is done
2265 */
2266declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TUiState> extends EventEmitter {
2267 client: InstantSearchOptions['searchClient'];
2268 indexName: string;
2269 insightsClient: InsightsClient | null;
2270 onStateChange: InstantSearchOptions['onStateChange'] | null;
2271 helper: AlgoliaSearchHelper | null;
2272 mainHelper: AlgoliaSearchHelper | null;
2273 mainIndex: IndexWidget;
2274 started: boolean;
2275 templatesConfig: Record<string, unknown>;
2276 renderState: RenderState;
2277 _stalledSearchDelay: number;
2278 _searchStalledTimer: any;
2279 _isSearchStalled: boolean;
2280 _initialUiState: UiState;
2281 _initialResults: InitialResults | null;
2282 _createURL: CreateURL<UiState>;
2283 _searchFunction?: InstantSearchOptions['searchFunction'];
2284 _mainHelperSearch?: AlgoliaSearchHelper['search'];
2285 middleware: Array<{
2286 creator: Middleware;
2287 instance: MiddlewareDefinition;
2288 }>;
2289 sendEventToInsights: (event: InsightsEvent) => void;
2290 constructor(options: InstantSearchOptions<TUiState, TRouteState>);
2291 /**
2292 * Hooks a middleware into the InstantSearch lifecycle.
2293 */
2294 use(...middleware: Middleware[]): this;
2295 /**
2296 * Removes a middleware from the InstantSearch lifecycle.
2297 */
2298 unuse(...middlewareToUnuse: Middleware[]): this;
2299 EXPERIMENTAL_use(...middleware: Middleware[]): this;
2300 /**
2301 * Adds a widget to the search instance.
2302 * A widget can be added either before or after InstantSearch has started.
2303 * @param widget The widget to add to InstantSearch.
2304 *
2305 * @deprecated This method will still be supported in 4.x releases, but not further. It is replaced by `addWidgets([widget])`.
2306 */
2307 addWidget(widget: Widget): this;
2308 /**
2309 * Adds multiple widgets to the search instance.
2310 * Widgets can be added either before or after InstantSearch has started.
2311 * @param widgets The array of widgets to add to InstantSearch.
2312 */
2313 addWidgets(widgets: Array<Widget | IndexWidget>): this;
2314 /**
2315 * Removes a widget from the search instance.
2316 * @deprecated This method will still be supported in 4.x releases, but not further. It is replaced by `removeWidgets([widget])`
2317 * @param widget The widget instance to remove from InstantSearch.
2318 *
2319 * The widget must implement a `dispose()` method to clear its state.
2320 */
2321 removeWidget(widget: Widget | IndexWidget): this;
2322 /**
2323 * Removes multiple widgets from the search instance.
2324 * @param widgets Array of widgets instances to remove from InstantSearch.
2325 *
2326 * The widgets must implement a `dispose()` method to clear their states.
2327 */
2328 removeWidgets(widgets: Array<Widget | IndexWidget>): this;
2329 /**
2330 * Ends the initialization of InstantSearch.js and triggers the
2331 * first search. This method should be called after all widgets have been added
2332 * to the instance of InstantSearch.js. InstantSearch.js also supports adding and removing
2333 * widgets after the start as an **EXPERIMENTAL** feature.
2334 */
2335 start(): void;
2336 /**
2337 * Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,
2338 * if you find an issue with it, please
2339 * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20dispose).
2340 * @return {undefined} This method does not return anything
2341 */
2342 dispose(): void;
2343 scheduleSearch: ((...args: any[]) => void) & {
2344 wait(): Promise<void>;
2345 cancel(): void;
2346 };
2347 scheduleRender: ((...args: any[]) => void) & {
2348 wait(): Promise<void>;
2349 cancel(): void;
2350 };
2351 scheduleStalledRender(): void;
2352 setUiState(uiState: UiState | ((previousUiState: UiState) => UiState)): void;
2353 getUiState(): UiState;
2354 onInternalStateChange: ((...args: any[]) => void) & {
2355 wait(): Promise<void>;
2356 cancel(): void;
2357 };
2358 createURL(nextState?: UiState): string;
2359 refresh(): void;
2360}
2361
2362/**
2363 * InstantSearch is the main component of InstantSearch.js. This object
2364 * manages the widget and lets you add new ones.
2365 *
2366 * Two parameters are required to get you started with InstantSearch.js:
2367 * - `indexName`: the main index that you will use for your new search UI
2368 * - `searchClient`: the search client to plug to InstantSearch.js
2369 *
2370 * The [search client provided by Algolia](algolia.com/doc/api-client/getting-started/what-is-the-api-client/javascript/)
2371 * needs an `appId` and an `apiKey`. Those parameters can be found in your
2372 * [Algolia dashboard](https://www.algolia.com/api-keys).
2373 *
2374 * If you want to get up and running quickly with InstantSearch.js, have a
2375 * look at the [getting started](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/).
2376 */
2377declare const instantsearch: InstantSearchModule;
2378export default instantsearch;
2379
2380declare type InstantSearchModule = {
2381 <TUiState = Record<string, unknown>, TRouteState = TUiState>(options: InstantSearchOptions<Expand<UiState & TUiState>, TRouteState>): InstantSearch<Expand<UiState & TUiState>, TRouteState>;
2382 version: string;
2383 connectors: typeof connectors;
2384 widgets: typeof widgets;
2385 middlewares: typeof middlewares;
2386 routers: typeof routers;
2387 stateMappings: typeof stateMappings;
2388 createInfiniteHitsSessionStorageCache: typeof createInfiniteHitsSessionStorageCache;
2389 highlight: typeof helpers.highlight;
2390 reverseHighlight: typeof helpers.reverseHighlight;
2391 snippet: typeof helpers.snippet;
2392 reverseSnippet: typeof helpers.reverseSnippet;
2393 insights: typeof helpers.insights;
2394};
2395
2396/**
2397 * Global options for an InstantSearch instance.
2398 */
2399declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteState = TUiState> = {
2400 /**
2401 * The name of the main index
2402 */
2403 indexName: string;
2404 /**
2405 * The search client to plug to InstantSearch.js
2406 *
2407 * Usage:
2408 * ```javascript
2409 * // Using the default Algolia search client
2410 * instantsearch({
2411 * indexName: 'indexName',
2412 * searchClient: algoliasearch('appId', 'apiKey')
2413 * });
2414 *
2415 * // Using a custom search client
2416 * instantsearch({
2417 * indexName: 'indexName',
2418 * searchClient: {
2419 * search(requests) {
2420 * // fetch response based on requests
2421 * return response;
2422 * },
2423 * searchForFacetValues(requests) {
2424 * // fetch response based on requests
2425 * return response;
2426 * }
2427 * }
2428 * });
2429 * ```
2430 */
2431 searchClient: SearchClient;
2432 /**
2433 * The locale used to display numbers. This will be passed
2434 * to `Number.prototype.toLocaleString()`
2435 */
2436 numberLocale?: string;
2437 /**
2438 * A hook that will be called each time a search needs to be done, with the
2439 * helper as a parameter. It's your responsibility to call `helper.search()`.
2440 * This option allows you to avoid doing searches at page load for example.
2441 */
2442 searchFunction?: (helper: AlgoliaSearchHelper) => void;
2443 /**
2444 * Function called when the state changes.
2445 *
2446 * Using this function makes the instance controlled. This means that you
2447 * become in charge of updating the UI state with the `setUiState` function.
2448 */
2449 onStateChange?: (params: {
2450 uiState: UiState;
2451 setUiState(uiState: UiState | ((previousUiState: UiState) => UiState)): void;
2452 }) => void;
2453 /**
2454 * Injects a `uiState` to the `instantsearch` instance. You can use this option
2455 * to provide an initial state to a widget. Note that the state is only used
2456 * for the first search. To unconditionally pass additional parameters to the
2457 * Algolia API, take a look at the `configure` widget.
2458 */
2459 initialUiState?: TUiState;
2460 /**
2461 * Time before a search is considered stalled. The default is 200ms
2462 */
2463 stalledSearchDelay?: number;
2464 /**
2465 * Router configuration used to save the UI State into the URL or any other
2466 * client side persistence. Passing `true` will use the default URL options.
2467 */
2468 routing?: RouterProps<TUiState, TRouteState> | boolean;
2469 /**
2470 * the instance of search-insights to use for sending insights events inside
2471 * widgets like `hits`.
2472 *
2473 * @deprecated This property will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
2474 */
2475 insightsClient?: InsightsClient;
2476};
2477
2478declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
2479
2480declare function isMetadataEnabled(): boolean;
2481
2482declare type MatchingPatterns = {
2483 [attribute: string]: {
2484 /**
2485 * The score of the optional filter.
2486 *
2487 * @see https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/in-depth/optional-filters/
2488 */
2489 score: number;
2490 };
2491};
2492
2493declare const menu: MenuWidget;
2494
2495declare type MenuConnector = Connector<MenuWidgetDescription, MenuConnectorParams>;
2496
2497declare type MenuConnectorParams = {
2498 /**
2499 * Name of the attribute for faceting (eg. "free_shipping").
2500 */
2501 attribute: string;
2502 /**
2503 * How many facets values to retrieve.
2504 */
2505 limit?: number;
2506 /**
2507 * Whether to display a button that expands the number of items.
2508 */
2509 showMore?: boolean;
2510 /**
2511 * How many facets values to retrieve when `toggleShowMore` is called, this value is meant to be greater than `limit` option.
2512 */
2513 showMoreLimit?: number;
2514 /**
2515 * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.
2516 *
2517 * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).
2518 *
2519 * If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
2520 */
2521 sortBy?: SortBy<MenuItem>;
2522 /**
2523 * Function to transform the items passed to the templates.
2524 */
2525 transformItems?: TransformItems<MenuItem>;
2526};
2527
2528declare type MenuCSSClasses = Partial<{
2529 /**
2530 * CSS class to add to the root element.
2531 */
2532 root: string | string[];
2533 /**
2534 * CSS class to add to the root element when no refinements.
2535 */
2536 noRefinementRoot: string | string[];
2537 /**
2538 * CSS class to add to the list element.
2539 */
2540 list: string | string[];
2541 /**
2542 * CSS class to add to each item element.
2543 */
2544 item: string | string[];
2545 /**
2546 * CSS class to add to each selected item element.
2547 */
2548 selectedItem: string | string[];
2549 /**
2550 * CSS class to add to each link (when using the default template).
2551 */
2552 link: string | string[];
2553 /**
2554 * CSS class to add to each label (when using the default template).
2555 */
2556 label: string | string[];
2557 /**
2558 * CSS class to add to each count element (when using the default template).
2559 */
2560 count: string | string[];
2561 /**
2562 * CSS class to add to the show more button.
2563 */
2564 showMore: string | string[];
2565 /**
2566 * CSS class to add to the disabled show more button.
2567 */
2568 disabledShowMore: string | string[];
2569}>;
2570
2571declare type MenuItem = {
2572 /**
2573 * The value of the menu item.
2574 */
2575 value: string;
2576 /**
2577 * Human-readable value of the menu item.
2578 */
2579 label: string;
2580 /**
2581 * Number of results matched after refinement is applied.
2582 */
2583 count: number;
2584 /**
2585 * Indicates if the refinement is applied.
2586 */
2587 isRefined: boolean;
2588};
2589
2590declare type MenuRenderState = {
2591 /**
2592 * The elements that can be refined for the current search results.
2593 */
2594 items: MenuItem[];
2595 /**
2596 * Creates the URL for a single item name in the list.
2597 */
2598 createURL: CreateURL<string>;
2599 /**
2600 * Filter the search to item value.
2601 */
2602 refine(value: string): void;
2603 /**
2604 * True if refinement can be applied.
2605 */
2606 canRefine: boolean;
2607 /**
2608 * True if the menu is displaying all the menu items.
2609 */
2610 isShowingMore: boolean;
2611 /**
2612 * Toggles the number of values displayed between `limit` and `showMore.limit`.
2613 */
2614 toggleShowMore(): void;
2615 /**
2616 * `true` if the toggleShowMore button can be activated (enough items to display more or
2617 * already displaying more than `limit` items)
2618 */
2619 canToggleShowMore: boolean;
2620 /**
2621 * Send event to insights middleware
2622 */
2623 sendEvent: SendEventForFacet;
2624};
2625
2626declare const menuSelect: MenuSelectWidget;
2627
2628declare type MenuSelectCSSClasses = Partial<{
2629 /**
2630 * CSS class to add to the root element.
2631 */
2632 root: string | string[];
2633 /**
2634 * CSS class to add to the root when there are no items to display
2635 */
2636 noRefinementRoot: string | string[];
2637 /**
2638 * CSS class to add to the select element.
2639 */
2640 select: string | string[];
2641 /**
2642 * CSS class to add to the option element.
2643 */
2644 option: string | string[];
2645}>;
2646
2647declare type MenuSelectTemplates = Partial<{
2648 /**
2649 * Item template, provided with `label`, `count`, `isRefined` and `value` data properties.
2650 */
2651 item: Template<{
2652 label: string;
2653 value: string;
2654 count: number;
2655 isRefined: boolean;
2656 }>;
2657 /**
2658 * Label of the "see all" option in the select.
2659 */
2660 defaultOption: Template;
2661}>;
2662
2663declare type MenuSelectWidget = WidgetFactory<MenuWidgetDescription & {
2664 $$widgetType: 'ais.menuSelect';
2665}, MenuConnectorParams, MenuSelectWidgetParams>;
2666
2667declare type MenuSelectWidgetParams = {
2668 /**
2669 * CSS Selector or HTMLElement to insert the widget.
2670 */
2671 container: string | HTMLElement;
2672 /**
2673 * Customize the output through templating.
2674 */
2675 templates?: MenuSelectTemplates;
2676 /**
2677 * CSS classes to add to the wrapping elements.
2678 */
2679 cssClasses?: MenuSelectCSSClasses;
2680};
2681
2682declare type MenuTemplates = Partial<{
2683 /**
2684 * Item template. The string template gets the same values as the function.
2685 */
2686 item: Template<{
2687 count: number;
2688 cssClasses: MenuCSSClasses;
2689 isRefined: boolean;
2690 label: string;
2691 url: string;
2692 value: string;
2693 }>;
2694 /**
2695 * Template used for the show more text, provided with `isShowingMore` data property.
2696 */
2697 showMoreText: Template<{
2698 isShowingMore: boolean;
2699 }>;
2700}>;
2701
2702declare type MenuWidget = WidgetFactory<MenuWidgetDescription & {
2703 $$widgetType: 'ais.menu';
2704}, MenuConnectorParams, MenuWidgetParams>;
2705
2706declare type MenuWidgetDescription = {
2707 $$type: 'ais.menu';
2708 renderState: MenuRenderState;
2709 indexRenderState: {
2710 menu: {
2711 [attribute: string]: WidgetRenderState<MenuRenderState, MenuConnectorParams>;
2712 };
2713 };
2714 indexUiState: {
2715 menu: {
2716 [attribute: string]: string;
2717 };
2718 };
2719};
2720
2721declare type MenuWidgetParams = {
2722 /**
2723 * CSS Selector or HTMLElement to insert the widget.
2724 */
2725 container: string | HTMLElement;
2726 /**
2727 * Customize the output through templating.
2728 */
2729 templates?: MenuTemplates;
2730 /**
2731 * CSS classes to add to the wrapping elements.
2732 */
2733 cssClasses?: MenuCSSClasses;
2734};
2735
2736declare type Middleware = (options: MiddlewareOptions) => AtLeastOne<MiddlewareDefinition>;
2737
2738declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
2739 onStateChange(options: {
2740 uiState: TUiState;
2741 }): void;
2742 subscribe(): void;
2743 unsubscribe(): void;
2744};
2745
2746declare type MiddlewareOptions = {
2747 instantSearchInstance: InstantSearch;
2748};
2749
2750declare namespace middlewares {
2751 export {
2752 InsightsEvent,
2753 InsightsProps,
2754 CreateInsightsMiddleware,
2755 createInsightsMiddleware,
2756 RouterProps,
2757 createRouterMiddleware,
2758 isMetadataEnabled,
2759 createMetadataMiddleware
2760 }
2761}
2762
2763declare const numericMenu: NumericMenuWidget;
2764
2765declare type NumericMenuComponentCSSClasses = ComponentCSSClasses<NumericMenuCSSClasses>;
2766
2767declare type NumericMenuConnector = Connector<NumericMenuWidgetDescription, NumericMenuConnectorParams>;
2768
2769declare type NumericMenuConnectorParams = {
2770 /**
2771 * Name of the attribute for filtering
2772 */
2773 attribute: string;
2774 /**
2775 * List of all the items
2776 */
2777 items: NumericMenuConnectorParamsItem[];
2778 /**
2779 * Function to transform the items passed to the templates
2780 */
2781 transformItems?: TransformItems<NumericMenuRenderStateItem>;
2782};
2783
2784declare type NumericMenuConnectorParamsItem = {
2785 /**
2786 * Name of the option
2787 */
2788 label: string;
2789 /**
2790 * Higher bound of the option (<=)
2791 */
2792 start?: number;
2793 /**
2794 * Lower bound of the option (>=)
2795 */
2796 end?: number;
2797};
2798
2799declare type NumericMenuCSSClasses = Partial<{
2800 /**
2801 * CSS class to add to the root element.
2802 */
2803 root: string | string[];
2804 /**
2805 * CSS class to add to the root element when no refinements.
2806 */
2807 noRefinementRoot: string | string[];
2808 /**
2809 * CSS class to add to the list element.
2810 */
2811 list: string | string[];
2812 /**
2813 * CSS class to add to each item element.
2814 */
2815 item: string | string[];
2816 /**
2817 * CSS class to add to each selected item element.
2818 */
2819 selectedItem: string | string[];
2820 /**
2821 * CSS class to add to each label element.
2822 */
2823 label: string | string[];
2824 /**
2825 * CSS class to add to each label text element.
2826 */
2827 labelText: string | string[];
2828 /**
2829 * CSS class to add to each radio element (when using the default template).
2830 */
2831 radio: string | string[];
2832}>;
2833
2834declare type NumericMenuRenderState = {
2835 /**
2836 * The list of available choices
2837 */
2838 items: NumericMenuRenderStateItem[];
2839 /**
2840 * Creates URLs for the next state, the string is the name of the selected option
2841 */
2842 createURL: CreateURL<NumericMenuRenderStateItem['value']>;
2843 /**
2844 * `true` if the last search contains no result
2845 */
2846 hasNoResults: boolean;
2847 /**
2848 * Sets the selected value and trigger a new search
2849 */
2850 refine: (facetValue: string) => void;
2851 /**
2852 * Send event to insights middleware
2853 */
2854 sendEvent: SendEventForFacet;
2855};
2856
2857declare type NumericMenuRenderStateItem = {
2858 /**
2859 * Name of the option.
2860 */
2861 label: string;
2862 /**
2863 * URL encoded of the bounds object with the form `{start, end}`.
2864 * This value can be used verbatim in the webpage and can be read by `refine`
2865 * directly. If you want to inspect the value, you can do:
2866 * `JSON.parse(decodeURI(value))` to get the object.
2867 */
2868 value: string;
2869 /**
2870 * True if the value is selected
2871 */
2872 isRefined: boolean;
2873};
2874
2875declare type NumericMenuTemplates = Partial<{
2876 /**
2877 * Item template, provided with `label` (the name in the configuration), `isRefined`, `url`, `value` (the setting for the filter) data properties.
2878 */
2879 item: Template<{
2880 /**
2881 * The name of the attribute.
2882 */
2883 attribute: string;
2884 /**
2885 * The label for the option.
2886 */
2887 label: string;
2888 /**
2889 * The encoded URL of the bounds object with a {start, end} form. This
2890 * value can be used verbatim in the webpage and can be read by refine
2891 * directly. If you want to inspect the value, you can do JSON.parse(window.decodeURI(value))
2892 * to get the object.
2893 */
2894 value: string;
2895 /**
2896 * Whether or not the refinement is selected.
2897 */
2898 isRefined: boolean;
2899 /**
2900 * The URL with the applied refinement.
2901 */
2902 url: string;
2903 /**
2904 * The CSS classes provided to the widget.
2905 */
2906 cssClasses: NumericMenuComponentCSSClasses;
2907 }>;
2908}>;
2909
2910declare type NumericMenuWidget = WidgetFactory<NumericMenuWidgetDescription & {
2911 $$widgetType: 'ais.numericMenu';
2912}, NumericMenuConnectorParams, NumericMenuWidgetParams>;
2913
2914declare type NumericMenuWidgetDescription = {
2915 $$type: 'ais.numericMenu';
2916 renderState: NumericMenuRenderState;
2917 indexRenderState: {
2918 numericMenu: {
2919 [attribute: string]: WidgetRenderState<NumericMenuRenderState, NumericMenuConnectorParams>;
2920 };
2921 };
2922 indexUiState: {
2923 numericMenu: {
2924 [attribute: string]: string;
2925 };
2926 };
2927};
2928
2929declare type NumericMenuWidgetParams = {
2930 /**
2931 * CSS Selector or HTMLElement to insert the widget.
2932 */
2933 container: string | HTMLElement;
2934 /**
2935 * Templates to use for the widget.
2936 */
2937 templates?: NumericMenuTemplates;
2938 /**
2939 * CSS classes to add to the wrapping elements.
2940 */
2941 cssClasses?: NumericMenuCSSClasses;
2942};
2943
2944declare const pagination: PaginationWidget;
2945
2946declare type PaginationConnector = Connector<PaginationWidgetDescription, PaginationConnectorParams>;
2947
2948declare type PaginationConnectorParams = {
2949 /**
2950 * The total number of pages to browse.
2951 */
2952 totalPages?: number;
2953 /**
2954 * The padding of pages to show around the current page
2955 * @default 3
2956 */
2957 padding?: number;
2958};
2959
2960declare type PaginationCSSClasses = Partial<{
2961 /**
2962 * CSS classes added to the root element of the widget.
2963 */
2964 root: string | string[];
2965 /**
2966 * CSS class to add to the root element of the widget if there are no refinements.
2967 */
2968 noRefinementRoot: string | string[];
2969 /**
2970 * CSS classes added to the wrapping `<ul>`.
2971 */
2972 list: string | string[];
2973 /**
2974 * CSS classes added to each `<li>`.
2975 */
2976 item: string | string[];
2977 /**
2978 * CSS classes added to the first `<li>`.
2979 */
2980 firstPageItem: string | string[];
2981 /**
2982 * CSS classes added to the last `<li>`.
2983 */
2984 lastPageItem: string | string[];
2985 /**
2986 * CSS classes added to the previous `<li>`.
2987 */
2988 previousPageItem: string | string[];
2989 /**
2990 * CSS classes added to the next `<li>`.
2991 */
2992 nextPageItem: string | string[];
2993 /**
2994 * CSS classes added to page `<li>`.
2995 */
2996 pageItem: string | string[];
2997 /**
2998 * CSS classes added to the selected `<li>`.
2999 */
3000 selectedItem: string | string[];
3001 /**
3002 * CSS classes added to the disabled `<li>`.
3003 */
3004 disabledItem: string | string[];
3005 /**
3006 * CSS classes added to each link.
3007 */
3008 link: string | string[];
3009}>;
3010
3011declare type PaginationRenderState = {
3012 /** Creates URLs for the next state, the number is the page to generate the URL for. */
3013 createURL: CreateURL<number>;
3014 /** Sets the current page and triggers a search. */
3015 refine(page: number): void;
3016 /** true if this search returned more than one page */
3017 canRefine: boolean;
3018 /** The number of the page currently displayed. */
3019 currentRefinement: number;
3020 /** The number of hits computed for the last query (can be approximated). */
3021 nbHits: number;
3022 /** The number of pages for the result set. */
3023 nbPages: number;
3024 /** The actual pages relevant to the current situation and padding. */
3025 pages: number[];
3026 /** true if the current page is also the first page. */
3027 isFirstPage: boolean;
3028 /** true if the current page is also the last page. */
3029 isLastPage: boolean;
3030};
3031
3032declare type PaginationTemplates = Partial<{
3033 /**
3034 * Label for the Previous link.
3035 */
3036 previous: string;
3037 /**
3038 * Label for the Next link.
3039 */
3040 next: string;
3041 /**
3042 * Label for the First link.
3043 */
3044 first: string;
3045 /**
3046 * Label for the Last link.
3047 */
3048 last: string;
3049}>;
3050
3051declare type PaginationWidget = WidgetFactory<PaginationWidgetDescription & {
3052 $$widgetType: 'ais.pagination';
3053}, PaginationConnectorParams, PaginationWidgetParams>;
3054
3055declare type PaginationWidgetDescription = {
3056 $$type: 'ais.pagination';
3057 renderState: PaginationRenderState;
3058 indexRenderState: {
3059 pagination: WidgetRenderState<PaginationRenderState, PaginationConnectorParams>;
3060 };
3061 indexUiState: {
3062 page: number;
3063 };
3064};
3065
3066declare type PaginationWidgetParams = {
3067 /**
3068 * CSS Selector or HTMLElement to insert the widget.
3069 */
3070 container: string | HTMLElement;
3071 /**
3072 * The max number of pages to browse.
3073 */
3074 totalPages?: number;
3075 /**
3076 * The number of pages to display on each side of the current page.
3077 * @default 3
3078 */
3079 padding?: number;
3080 /**
3081 * Where to scroll after a click, set to `false` to disable.
3082 * @default body
3083 */
3084 scrollTo?: string | HTMLElement | boolean;
3085 /**
3086 * Whether to show the "first page" control
3087 * @default true
3088 */
3089 showFirst?: boolean;
3090 /**
3091 * Whether to show the "last page" control
3092 * @default true
3093 */
3094 showLast?: boolean;
3095 /**
3096 * Whether to show the "next page" control
3097 * @default true
3098 */
3099 showNext?: boolean;
3100 /**
3101 * Whether to show the "previous page" control
3102 * @default true
3103 */
3104 showPrevious?: boolean;
3105 /**
3106 * Text to display in the links.
3107 */
3108 templates?: PaginationTemplates;
3109 /**
3110 * CSS classes to be added.
3111 */
3112 cssClasses?: PaginationCSSClasses;
3113};
3114
3115/**
3116 * The panel widget wraps other widgets in a consistent panel design.
3117 * It also reacts, indicates and sets CSS classes when widgets are no longer relevant for refining.
3118 */
3119declare const panel: PanelWidget;
3120
3121declare type PanelCSSClasses = Partial<{
3122 /**
3123 * CSS classes to add to the root element of the widget.
3124 */
3125 root: string | string[];
3126 /**
3127 * CSS classes to add to the root element of the widget when there's no refinements.
3128 */
3129 noRefinementRoot: string | string[];
3130 /**
3131 * CSS classes to add to the root element when collapsible (`collapse` is defined).
3132 */
3133 collapsibleRoot: string | string[];
3134 /**
3135 * CSS classes to add to the root element when collapsed.
3136 */
3137 collapsedRoot: string | string[];
3138 /**
3139 * CSS classes to add to the collapse button element.
3140 */
3141 collapseButton: string | string[];
3142 /**
3143 * CSS classes to add to the collapse icon of the button.
3144 */
3145 collapseIcon: string | string[];
3146 /**
3147 * CSS classes to add to the header.
3148 */
3149 header: string | string[];
3150 /**
3151 * CSS classes to add to the body.
3152 */
3153 body: string | string[];
3154 /**
3155 * CSS classes to add to the footer.
3156 */
3157 footer: string | string[];
3158}>;
3159
3160declare type PanelRenderOptions<TWidgetFactory extends AnyWidgetFactory> = RenderOptions & GetWidgetRenderState<TWidgetFactory>;
3161
3162declare type PanelTemplates<TWidget extends AnyWidgetFactory> = Partial<{
3163 /**
3164 * Template to use for the header.
3165 */
3166 header: Template<PanelRenderOptions<TWidget>>;
3167 /**
3168 * Template to use for the footer.
3169 */
3170 footer: Template<PanelRenderOptions<TWidget>>;
3171 /**
3172 * Template to use for collapse button.
3173 */
3174 collapseButtonText: Template<{
3175 collapsed: boolean;
3176 }>;
3177}>;
3178
3179declare type PanelWidget = <TWidgetFactory extends AnyWidgetFactory>(panelWidgetParams?: PanelWidgetParams<TWidgetFactory>) => (widgetFactory: TWidgetFactory) => (widgetParams: Parameters<TWidgetFactory>[0]) => AugmentedWidget<TWidgetFactory>;
3180
3181declare type PanelWidgetParams<TWidgetFactory extends AnyWidgetFactory> = {
3182 /**
3183 * A function that is called on each render to determine if the
3184 * panel should be hidden based on the render options.
3185 */
3186 hidden?(options: PanelRenderOptions<TWidgetFactory>): boolean;
3187 /**
3188 * A function that is called on each render to determine if the
3189 * panel should be collapsed based on the render options.
3190 */
3191 collapsed?(options: PanelRenderOptions<TWidgetFactory>): boolean;
3192 /**
3193 * The templates to use for the widget.
3194 */
3195 templates?: PanelTemplates<TWidgetFactory>;
3196 /**
3197 * The CSS classes to override.
3198 */
3199 cssClasses?: PanelCSSClasses;
3200};
3201
3202declare type ParamTrackedFilters = {
3203 [facetName: string]: (facetValues: TrackedFilterRefinement[]) => TrackedFilterRefinement[];
3204};
3205
3206declare type ParamTransformItems = TransformItems<any>;
3207
3208declare type ParamTransformRuleContexts = (ruleContexts: string[]) => string[];
3209
3210declare type ParseURL<TRouteState> = (args: {
3211 qsModule: typeof qs_2;
3212 location: Location;
3213}) => TRouteState;
3214
3215declare type PlacesInstance = Places.PlacesInstance;
3216
3217declare type PlacesWidget = WidgetFactory<PlacesWidgetDescription, PlacesWidgetParams, PlacesWidgetParams>;
3218
3219/**
3220 * This widget sets the geolocation value for the search based on the selected
3221 * result in the Algolia Places autocomplete.
3222 */
3223declare const placesWidget: PlacesWidget;
3224
3225declare type PlacesWidgetDescription = {
3226 $$type: 'ais.places';
3227 $$widgetType: 'ais.places';
3228 renderState: Record<string, unknown>;
3229 indexRenderState: {
3230 places: WidgetRenderState<Record<string, unknown>, PlacesWidgetParams>;
3231 };
3232 indexUiState: {
3233 places: {
3234 query: string;
3235 position: string;
3236 };
3237 };
3238};
3239
3240declare type PlacesWidgetParams = {
3241 /**
3242 * The Algolia Places reference to use.
3243 *
3244 * @see https://github.com/algolia/places
3245 */
3246 placesReference: (options: StaticOptions & ReconfigurableOptions) => PlacesInstance;
3247 /**
3248 * The default position when the input is empty.
3249 */
3250 defaultPosition?: string[];
3251} & StaticOptions;
3252
3253declare const poweredBy: PoweredByWidget;
3254
3255declare type PoweredByConnector = Connector<PoweredByWidgetDescription, PoweredByConnectorParams>;
3256
3257declare type PoweredByConnectorParams = {
3258 /** the url to redirect to on click */
3259 url?: string;
3260};
3261
3262declare type PoweredByCSSClasses = Partial<{
3263 /**
3264 * CSS class to add to the wrapping element.
3265 */
3266 root: string | string[];
3267 /**
3268 * CSS class to add to the link.
3269 */
3270 link: string | string[];
3271 /**
3272 * CSS class to add to the SVG logo.
3273 */
3274 logo: string | string[];
3275}>;
3276
3277declare type PoweredByRenderState = {
3278 /** the url to redirect to on click */
3279 url: string;
3280};
3281
3282declare type PoweredByWidget = WidgetFactory<PoweredByWidgetDescription & {
3283 $$widgetType: 'ais.poweredBy';
3284}, PoweredByConnectorParams, PoweredByWidgetParams>;
3285
3286declare type PoweredByWidgetDescription = {
3287 $$type: 'ais.poweredBy';
3288 renderState: PoweredByRenderState;
3289 indexRenderState: {
3290 poweredBy: WidgetRenderState<PoweredByRenderState, PoweredByConnectorParams>;
3291 };
3292};
3293
3294declare type PoweredByWidgetParams = {
3295 /**
3296 * CSS Selector or HTMLElement to insert the widget.
3297 */
3298 container: string | HTMLElement;
3299 /**
3300 * The theme of the logo.
3301 * @default 'light'
3302 */
3303 theme?: 'light' | 'dark';
3304 /**
3305 * CSS classes to add.
3306 */
3307 cssClasses?: PoweredByCSSClasses;
3308};
3309
3310declare const queryRuleContext: QueryRuleContextWidget;
3311
3312declare type QueryRuleContextWidget = WidgetFactory<QueryRulesWidgetDescription & {
3313 $$widgetType: 'ais.queryRuleContext';
3314}, QueryRulesConnectorParams, QueryRuleContextWidgetParams>;
3315
3316declare type QueryRuleContextWidgetParams = {
3317 trackedFilters: ParamTrackedFilters;
3318 transformRuleContexts?: ParamTransformRuleContexts;
3319};
3320
3321declare const queryRuleCustomData: QueryRuleCustomDataWidget;
3322
3323declare type QueryRuleCustomDataCSSClasses = Partial<{
3324 root: string | string[];
3325}>;
3326
3327declare type QueryRuleCustomDataTemplates = Partial<{
3328 default: Template<{
3329 items: any[];
3330 }>;
3331}>;
3332
3333declare type QueryRuleCustomDataWidget = WidgetFactory<QueryRulesWidgetDescription & {
3334 $$widgetType: 'ais.queryRuleCustomData';
3335}, QueryRulesConnectorParams, QueryRuleCustomDataWidgetParams>;
3336
3337declare type QueryRuleCustomDataWidgetParams = {
3338 container: string | HTMLElement;
3339 cssClasses?: QueryRuleCustomDataCSSClasses;
3340 templates?: QueryRuleCustomDataTemplates;
3341};
3342
3343declare type QueryRulesConnector = Connector<QueryRulesWidgetDescription, QueryRulesConnectorParams>;
3344
3345declare type QueryRulesConnectorParams = {
3346 trackedFilters?: ParamTrackedFilters;
3347 transformRuleContexts?: ParamTransformRuleContexts;
3348 transformItems?: ParamTransformItems;
3349};
3350
3351declare type QueryRulesRenderState = {
3352 items: any[];
3353};
3354
3355declare type QueryRulesWidgetDescription = {
3356 $$type: 'ais.queryRules';
3357 renderState: QueryRulesRenderState;
3358 indexRenderState: {
3359 queryRules: WidgetRenderState<QueryRulesRenderState, QueryRulesConnectorParams>;
3360 };
3361};
3362
3363declare type QueueItem = QueueItemMap[keyof QueueItemMap];
3364
3365declare type QueueItemMap = {
3366 [MethodName in keyof InsightsMethodMap]: [
3367 methodName: MethodName,
3368 ...args: InsightsMethodMap[MethodName]
3369 ];
3370};
3371
3372declare type Range_2 = {
3373 min: RangeMin;
3374 max: RangeMax;
3375};
3376
3377declare type RangeBoundaries = [RangeMin, RangeMax];
3378
3379declare type RangeConnector = Connector<RangeWidgetDescription, RangeConnectorParams>;
3380
3381declare type RangeConnectorParams = {
3382 /**
3383 * Name of the attribute for faceting.
3384 */
3385 attribute: string;
3386 /**
3387 * Minimal range value, default to automatically computed from the result set.
3388 */
3389 min?: number;
3390 /**
3391 * Maximal range value, default to automatically computed from the result set.
3392 */
3393 max?: number;
3394 /**
3395 * Number of digits after decimal point to use.
3396 */
3397 precision?: number;
3398};
3399
3400declare const rangeInput: RangeInputWidget;
3401
3402declare type RangeInputCSSClasses = Partial<{
3403 /**
3404 * CSS class to add to the root element.
3405 */
3406 root: string | string[];
3407 /**
3408 * CSS class to add to the root element when there's no refinements.
3409 */
3410 noRefinement: string | string[];
3411 /**
3412 * CSS class to add to the form element.
3413 */
3414 form: string | string[];
3415 /**
3416 * CSS class to add to the label element.
3417 */
3418 label: string | string[];
3419 /**
3420 * CSS class to add to the input element.
3421 */
3422 input: string | string[];
3423 /**
3424 * CSS class to add to the min input element.
3425 */
3426 inputMin: string | string[];
3427 /**
3428 * CSS class to add to the max input element.
3429 */
3430 separator: string | string[];
3431 /**
3432 * CSS class to add to the separator of the form.
3433 */
3434 inputMax: string | string[];
3435 /**
3436 * CSS class to add to the submit button of the form.
3437 */
3438 submit: string | string[];
3439}>;
3440
3441declare type RangeInputTemplates = Partial<{
3442 /**
3443 * The label of the separator, between min and max.
3444 * @default "to"
3445 */
3446 separatorText: Template;
3447 /**
3448 * The label of the submit button
3449 * @default "Go"
3450 */
3451 submitText: Template;
3452}>;
3453
3454declare type RangeInputWidget = WidgetFactory<Omit<RangeWidgetDescription, '$$type'> & {
3455 $$widgetType: 'ais.rangeInput';
3456 $$type: 'ais.rangeInput';
3457}, RangeConnectorParams, RangeInputWidgetParams>;
3458
3459declare type RangeInputWidgetParams = {
3460 /**
3461 * Valid CSS Selector as a string or DOMElement.
3462 */
3463 container: string | HTMLElement;
3464 /**
3465 * Name of the attribute for faceting.
3466 */
3467 attribute: string;
3468 /**
3469 * Minimal slider value, default to automatically computed from the result set.
3470 */
3471 min?: number;
3472 /**
3473 * Maximal slider value, defaults to automatically computed from the result set.
3474 */
3475 max?: number;
3476 /**
3477 * Number of digits after decimal point to use.
3478 * @default 0
3479 */
3480 precision?: number;
3481 /**
3482 * Labels to use for the widget.
3483 */
3484 templates?: RangeInputTemplates;
3485 /**
3486 * CSS classes to add.
3487 */
3488 cssClasses?: RangeInputCSSClasses;
3489};
3490
3491declare type RangeMax = number | undefined;
3492
3493declare type RangeMin = number | undefined;
3494
3495declare type RangeRenderState = {
3496 /**
3497 * Sets a range to filter the results on. Both values
3498 * are optional, and will default to the higher and lower bounds. You can use `undefined` to remove a
3499 * previously set bound or to set an infinite bound.
3500 * @param rangeValue tuple of [min, max] bounds
3501 */
3502 refine(rangeValue: RangeBoundaries): void;
3503 /**
3504 * Indicates whether this widget can be refined
3505 */
3506 canRefine: boolean;
3507 /**
3508 * Send an event to the insights middleware
3509 */
3510 sendEvent: SendEventForFacet;
3511 /**
3512 * Maximum range possible for this search
3513 */
3514 range: Range_2;
3515 /**
3516 * Current refinement of the search
3517 */
3518 start: RangeBoundaries;
3519 /**
3520 * Transform for the rendering `from` and/or `to` values.
3521 * Both functions take a `number` as input and should output a `string`.
3522 */
3523 format: {
3524 from(fromValue: number): string;
3525 to(toValue: number): string;
3526 };
3527};
3528
3529/**
3530 * The range slider is a widget which provides a user-friendly way to filter the
3531 * results based on a single numeric range.
3532 *
3533 * @requirements
3534 * The attribute passed to `attribute` must be declared as an
3535 * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting)
3536 * in your Algolia settings.
3537 *
3538 * The values inside this attribute must be JavaScript numbers (not strings).
3539 */
3540declare const rangeSlider: RangeSliderWidget;
3541
3542declare type RangeSliderCssClasses = Partial<{
3543 /**
3544 * CSS class to add to the root element.
3545 */
3546 root: string | string[];
3547 /**
3548 * CSS class to add to the disabled root element.
3549 */
3550 disabledRoot: string | string[];
3551}>;
3552
3553declare type RangeSliderTooltipOptions = {
3554 /**
3555 * The function takes the raw value as input, and should return
3556 * a string for the label that should be used for this value.
3557 * @example
3558 * { format(rawValue) {return '$' + Math.round(rawValue).toLocaleString() } }
3559 */
3560 format(value: number): string;
3561};
3562
3563declare type RangeSliderWidget = WidgetFactory<Omit<RangeWidgetDescription, '$$type'> & {
3564 $$widgetType: 'ais.rangeSlider';
3565 $$type: 'ais.rangeSlider';
3566}, RangeConnectorParams, RangeSliderWidgetParams>;
3567
3568declare type RangeSliderWidgetParams = {
3569 /**
3570 * CSS Selector or DOMElement to insert the widget.
3571 */
3572 container: string | HTMLElement;
3573 /**
3574 * Name of the attribute for faceting.;
3575 */
3576 attribute: string;
3577 /**
3578 * Should we show tooltips or not.
3579 * The default tooltip will show the raw value.
3580 * You can also provide an object with a format function as an attribute.
3581 * So that you can format the tooltip display value as you want.
3582 * @default true
3583 */
3584 tooltips?: boolean | RangeSliderTooltipOptions;
3585 /**
3586 * CSS classes to add to the wrapping elements.
3587 */
3588 cssClasses?: RangeSliderCssClasses;
3589 /**
3590 * Show slider pips.
3591 * @default true
3592 */
3593 pips?: boolean;
3594 /**
3595 * Number of digits after decimal point to use.
3596 * @default 0
3597 */
3598 precision?: number;
3599 /**
3600 * Every handle move will jump that number of steps.
3601 */
3602 step?: number;
3603 /**
3604 * Minimal slider value, default to automatically computed from the result set.
3605 */
3606 min?: number;
3607 /**
3608 * Maximal slider value, defaults to automatically computed from the result set.
3609 */
3610 max?: number;
3611};
3612
3613declare type RangeWidgetDescription = {
3614 $$type: 'ais.range';
3615 renderState: RangeRenderState;
3616 indexRenderState: {
3617 range: {
3618 [attribute: string]: WidgetRenderState<RangeRenderState, RangeConnectorParams>;
3619 };
3620 };
3621 indexUiState: {
3622 range: {
3623 [attribute: string]: string;
3624 };
3625 };
3626};
3627
3628declare const ratingMenu: RatingMenuWidget;
3629
3630declare type RatingMenuConnector = Connector<RatingMenuWidgetDescription, RatingMenuConnectorParams>;
3631
3632declare type RatingMenuConnectorParams = {
3633 /**
3634 * Name of the attribute for faceting (eg. "free_shipping").
3635 */
3636 attribute: string;
3637 /**
3638 * The maximum rating value.
3639 */
3640 max?: number;
3641};
3642
3643declare type RatingMenuCSSClasses = Partial<{
3644 /**
3645 * CSS class to add to the root element.
3646 */
3647 root: string | string[];
3648 /**
3649 * CSS class to add to the root element when there's no refinements.
3650 */
3651 noRefinementRoot: string | string[];
3652 /**
3653 * CSS class to add to the list element.
3654 */
3655 list: string | string[];
3656 /**
3657 * CSS class to add to each item element.
3658 */
3659 item: string | string[];
3660 /**
3661 * CSS class to add the selected item element.
3662 */
3663 selectedItem: string | string[];
3664 /**
3665 * CSS class to add a disabled item element.
3666 */
3667 disabledItem: string | string[];
3668 /**
3669 * CSS class to add to each link element.
3670 */
3671 link: string | string[];
3672 /**
3673 * CSS class to add to each star element (when using the default template).
3674 */
3675 starIcon: string | string[];
3676 /**
3677 * CSS class to add to each full star element (when using the default template).
3678 */
3679 fullStarIcon: string | string[];
3680 /**
3681 * CSS class to add to each empty star element (when using the default template).
3682 */
3683 emptyStarIcon: string | string[];
3684 /**
3685 * CSS class to add to each label.
3686 */
3687 label: string | string[];
3688 /**
3689 * CSS class to add to each counter.
3690 */
3691 count: string | string[];
3692}>;
3693
3694declare type RatingMenuRenderState = {
3695 /**
3696 * Possible star ratings the user can apply.
3697 */
3698 items: StarRatingItems[];
3699 /**
3700 * Creates an URL for the next state (takes the item value as parameter). Takes the value of an item as parameter.
3701 */
3702 createURL: CreateURL<string>;
3703 /**
3704 * Indicates if search state can be refined.
3705 */
3706 canRefine: boolean;
3707 /**
3708 * Selects a rating to filter the results (takes the filter value as parameter). Takes the value of an item as parameter.
3709 */
3710 refine: (value: string) => void;
3711 /**
3712 * `true` if the last search contains no result.
3713 */
3714 hasNoResults: boolean;
3715 /**
3716 * Send event to insights middleware
3717 */
3718 sendEvent: SendEvent;
3719};
3720
3721declare type RatingMenuTemplates = Partial<{
3722 /**
3723 * Item template, provided with `name`, `count`, `isRefined`, `url` data properties.
3724 */
3725 item: Template<{
3726 name: string;
3727 count: number;
3728 isRefined: boolean;
3729 url: string;
3730 }>;
3731}>;
3732
3733/**
3734 * Rating menu is used for displaying grade like filters. The values are normalized within boundaries.
3735 *
3736 * The maximum value can be set (with `max`), the minimum is always 0.
3737 *
3738 * @requirements
3739 * The attribute passed to `attribute` must be declared as an
3740 * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting)
3741 * in your Algolia settings.
3742 *
3743 * The values inside this attribute must be JavaScript numbers (not strings).
3744 *
3745 * @type {WidgetFactory}
3746 * @devNovel RatingMenu
3747 * @category filter
3748 * @param {RatingMenuWidgetParams} widgetParams RatingMenu widget options.
3749 * @return {Widget} A new RatingMenu widget instance.
3750 * @example
3751 * search.addWidgets([
3752 * instantsearch.widgets.ratingMenu({
3753 * container: '#stars',
3754 * attribute: 'rating',
3755 * max: 5,
3756 * })
3757 * ]);
3758 */
3759declare type RatingMenuWidget = WidgetFactory<RatingMenuWidgetDescription & {
3760 $$widgetType: 'ais.ratingMenu';
3761}, RatingMenuConnectorParams, RatingMenuWidgetParams>;
3762
3763declare type RatingMenuWidgetDescription = {
3764 $$type: 'ais.ratingMenu';
3765 renderState: RatingMenuRenderState;
3766 indexRenderState: {
3767 ratingMenu: {
3768 [attribute: string]: WidgetRenderState<RatingMenuRenderState, RatingMenuConnectorParams>;
3769 };
3770 };
3771 indexUiState: {
3772 ratingMenu: {
3773 [attribute: string]: number;
3774 };
3775 };
3776};
3777
3778declare type RatingMenuWidgetParams = {
3779 /**
3780 * Place where to insert the widget in your webpage.
3781 */
3782 container: string | HTMLElement;
3783 /**
3784 * Name of the attribute in your records that contains the ratings.
3785 */
3786 attribute: string;
3787 /**
3788 * The maximum rating value.
3789 */
3790 max?: number;
3791 /**
3792 * Templates to use for the widget.
3793 */
3794 templates?: RatingMenuTemplates;
3795 /**
3796 * CSS classes to add.
3797 */
3798 cssClasses?: RatingMenuCSSClasses;
3799};
3800
3801declare type Read = ({ state, }: {
3802 state: PlainSearchParameters;
3803}) => InfiniteHitsCachedHits | null;
3804
3805declare type ReconfigurableOptions = Places.ReconfigurableOptions;
3806
3807/**
3808 * Refine the given search parameters.
3809 */
3810declare type Refine = (searchParameters: PlainSearchParameters) => void;
3811
3812declare type Refine_2 = (relevancyStrictness: number) => void;
3813
3814/**
3815 * The refinement list widget is one of the most common widget that you can find
3816 * in a search UI. With this widget, the user can filter the dataset based on facets.
3817 *
3818 * The refinement list displays only the most relevant facets for the current search
3819 * context. The sort option only affects the facet that are returned by the engine,
3820 * not which facets are returned.
3821 *
3822 * This widget also implements search for facet values, which is a mini search inside the
3823 * values of the facets. This makes easy to deal with uncommon facet values.
3824 *
3825 * @requirements
3826 *
3827 * The attribute passed to `attribute` must be declared as an
3828 * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting)
3829 * in your Algolia settings.
3830 *
3831 * If you also want to use search for facet values on this attribute, you need to make it searchable using the [dashboard](https://www.algolia.com/explorer/display/) or using the [API](https://www.algolia.com/doc/guides/searching/faceting/#search-for-facet-values).
3832 */
3833declare const refinementList: RefinementListWidget;
3834
3835declare type RefinementListConnector = Connector<RefinementListWidgetDescription, RefinementListConnectorParams>;
3836
3837declare type RefinementListConnectorParams = {
3838 /**
3839 * The name of the attribute in the records.
3840 */
3841 attribute: string;
3842 /**
3843 * How the filters are combined together.
3844 */
3845 operator?: 'and' | 'or';
3846 /**
3847 * The max number of items to display when
3848 * `showMoreLimit` is not set or if the widget is showing less value.
3849 */
3850 limit?: number;
3851 /**
3852 * Whether to display a button that expands the number of items.
3853 */
3854 showMore?: boolean;
3855 /**
3856 * The max number of items to display if the widget
3857 * is showing more items.
3858 */
3859 showMoreLimit?: number;
3860 /**
3861 * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.
3862 *
3863 * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).
3864 *
3865 * If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
3866 */
3867 sortBy?: SortBy<RefinementListItem>;
3868 /**
3869 * Escapes the content of the facet values.
3870 */
3871 escapeFacetValues?: boolean;
3872 /**
3873 * Function to transform the items passed to the templates.
3874 */
3875 transformItems?: TransformItems<RefinementListItem>;
3876};
3877
3878declare type RefinementListCSSClasses = RefinementListOwnCSSClasses & RefinementListSearchableCSSClasses;
3879
3880declare type RefinementListItem = {
3881 /**
3882 * The value of the refinement list item.
3883 */
3884 value: string;
3885 /**
3886 * Human-readable value of the refinement list item.
3887 */
3888 label: string;
3889 /**
3890 * Human-readable value of the searched refinement list item.
3891 */
3892 highlighted?: string;
3893 /**
3894 * Number of matched results after refinement is applied.
3895 */
3896 count: number;
3897 /**
3898 * Indicates if the list item is refined.
3899 */
3900 isRefined: boolean;
3901};
3902
3903declare type RefinementListItemData = {
3904 /**
3905 * The number of occurrences of the facet in the result set.
3906 */
3907 count: number;
3908 /**
3909 * True if the value is selected.
3910 */
3911 isRefined: boolean;
3912 /**
3913 * The label to display.
3914 */
3915 label: string;
3916 /**
3917 * The value used for refining.
3918 */
3919 value: string;
3920 /**
3921 * The label highlighted (when using search for facet values). This value is displayed in the default template.
3922 */
3923 highlighted: string;
3924 /**
3925 * The url with this refinement selected.
3926 */
3927 url: string;
3928 /**
3929 * Object containing all the classes computed for the item.
3930 */
3931 cssClasses: RefinementListCSSClasses;
3932};
3933
3934declare type RefinementListOwnCSSClasses = Partial<{
3935 /**
3936 * CSS class to add to the root element.
3937 */
3938 root: string | string[];
3939 /**
3940 * CSS class to add to the root element when no refinements.
3941 */
3942 noRefinementRoot: string | string[];
3943 /**
3944 * CSS class to add to the root element with no results.
3945 */
3946 noResults: string | string[];
3947 /**
3948 * CSS class to add to the list element.
3949 */
3950 list: string | string[];
3951 /**
3952 * CSS class to add to each item element.
3953 */
3954 item: string | string[];
3955 /**
3956 * CSS class to add to each selected element.
3957 */
3958 selectedItem: string | string[];
3959 /**
3960 * CSS class to add to each label element (when using the default template).
3961 */
3962 label: string | string[];
3963 /**
3964 * CSS class to add to each checkbox element (when using the default template).
3965 */
3966 checkbox: string | string[];
3967 /**
3968 * CSS class to add to each label text element.
3969 */
3970 labelText: string | string[];
3971 /**
3972 * CSS class to add to the show more element
3973 */
3974 showMore: string | string[];
3975 /**
3976 * CSS class to add to the disabled show more element
3977 */
3978 disabledShowMore: string | string[];
3979 /**
3980 * CSS class to add to each count element (when using the default template).
3981 */
3982 count: string | string[];
3983 /**
3984 * CSS class to add to the searchable container.
3985 */
3986 searchBox: string | string[];
3987}>;
3988
3989declare type RefinementListOwnTemplates = Partial<{
3990 /**
3991 * Item template, provided with `label`, `highlighted`, `value`, `count`, `isRefined`, `url` data properties.
3992 */
3993 item: Template<RefinementListItemData>;
3994 /**
3995 * Template used for the show more text, provided with `isShowingMore` data property.
3996 */
3997 showMoreText: Template;
3998 /**
3999 * Templates to use for search for facet values when there are no results.
4000 */
4001 searchableNoResults: Template;
4002}>;
4003
4004declare type RefinementListRenderState = {
4005 /**
4006 * The list of filtering values returned from Algolia API.
4007 */
4008 items: RefinementListItem[];
4009 /**
4010 * indicates whether the results are exhaustive (complete)
4011 */
4012 hasExhaustiveItems: boolean;
4013 /**
4014 * Creates the next state url for a selected refinement.
4015 */
4016 createURL: CreateURL<string>;
4017 /**
4018 * Action to apply selected refinements.
4019 */
4020 refine(value: string): void;
4021 /**
4022 * Send event to insights middleware
4023 */
4024 sendEvent: SendEventForFacet;
4025 /**
4026 * Searches for values inside the list.
4027 */
4028 searchForItems(query: string): void;
4029 /**
4030 * `true` if the values are from an index search.
4031 */
4032 isFromSearch: boolean;
4033 /**
4034 * `true` if a refinement can be applied.
4035 */
4036 canRefine: boolean;
4037 /**
4038 * `true` if the toggleShowMore button can be activated (enough items to display more or
4039 * already displaying more than `limit` items)
4040 */
4041 canToggleShowMore: boolean;
4042 /**
4043 * True if the menu is displaying all the menu items.
4044 */
4045 isShowingMore: boolean;
4046 /**
4047 * Toggles the number of values displayed between `limit` and `showMoreLimit`.
4048 */
4049 toggleShowMore(): void;
4050};
4051
4052declare type RefinementListSearchableCSSClasses = Partial<{
4053 searchableRoot: string | string[];
4054 searchableForm: string | string[];
4055 searchableInput: string | string[];
4056 searchableSubmit: string | string[];
4057 searchableSubmitIcon: string | string[];
4058 searchableReset: string | string[];
4059 searchableResetIcon: string | string[];
4060 searchableLoadingIndicator: string | string[];
4061 searchableLoadingIcon: string | string[];
4062}>;
4063
4064declare type RefinementListSearchableTemplates = Partial<{
4065 /**
4066 * Templates to use for search for facet values submit button.
4067 */
4068 searchableSubmit: SearchBoxTemplates['submit'];
4069 /**
4070 * Templates to use for search for facet values reset button.
4071 */
4072 searchableReset: SearchBoxTemplates['reset'];
4073 /**
4074 * Templates to use for the search for facet values loading indicator.
4075 */
4076 searchableLoadingIndicator: SearchBoxTemplates['loadingIndicator'];
4077}>;
4078
4079declare type RefinementListTemplates = RefinementListOwnTemplates & RefinementListSearchableTemplates;
4080
4081declare type RefinementListWidget = WidgetFactory<RefinementListWidgetDescription & {
4082 $$widgetType: 'ais.refinementList';
4083}, RefinementListConnectorParams, RefinementListWidgetParams>;
4084
4085declare type RefinementListWidgetDescription = {
4086 $$type: 'ais.refinementList';
4087 renderState: RefinementListRenderState;
4088 indexRenderState: {
4089 refinementList: {
4090 [attribute: string]: WidgetRenderState<RefinementListRenderState, RefinementListConnectorParams>;
4091 };
4092 };
4093 indexUiState: {
4094 refinementList: {
4095 [attribute: string]: string[];
4096 };
4097 };
4098};
4099
4100declare type RefinementListWidgetParams = {
4101 /**
4102 * CSS Selector or HTMLElement to insert the widget.
4103 */
4104 container: string | HTMLElement;
4105 /**
4106 * Add a search input to let the user search for more facet values. In order
4107 * to make this feature work, you need to make the attribute searchable
4108 * [using the API](https://www.algolia.com/doc/guides/searching/faceting/?language=js#declaring-a-searchable-attribute-for-faceting)
4109 * or [the dashboard](https://www.algolia.com/explorer/display/)
4110 */
4111 searchable?: boolean;
4112 /**
4113 * Value of the search field placeholder.
4114 */
4115 searchablePlaceholder?: string;
4116 /**
4117 * When `false` the search field will become disabled if there are less items
4118 * to display than the `options.limit`, otherwise the search field is always usable.
4119 */
4120 searchableIsAlwaysActive?: boolean;
4121 /**
4122 * When activated, it will escape the facet values that are returned from Algolia.
4123 * In this case, the surrounding tags will always be `<mark></mark>`.
4124 */
4125 searchableEscapeFacetValues?: boolean;
4126 /**
4127 * Templates to use for the widget.
4128 */
4129 templates?: RefinementListTemplates;
4130 /**
4131 * CSS classes to add to the wrapping elements.
4132 */
4133 cssClasses?: RefinementListCSSClasses;
4134};
4135
4136declare const relevantSort: RelevantSortWidget;
4137
4138declare type RelevantSortConnector = Connector<RelevantSortWidgetDescription, RelevantSortConnectorParams>;
4139
4140declare type RelevantSortConnectorParams = Record<string, unknown>;
4141
4142declare type RelevantSortCSSClasses = Partial<{
4143 root: string;
4144 text: string;
4145 button: string;
4146}>;
4147
4148declare type RelevantSortRenderState = {
4149 /**
4150 * Indicates if it has appliedRelevancyStrictness greater than zero
4151 */
4152 isRelevantSorted: boolean;
4153 /**
4154 * Indicates if the results come from a virtual replica
4155 */
4156 isVirtualReplica: boolean;
4157 /**
4158 * Indicates if search state can be refined
4159 */
4160 canRefine: boolean;
4161 /**
4162 * Sets the value as relevancyStrictness and trigger a new search
4163 */
4164 refine: Refine_2;
4165};
4166
4167declare type RelevantSortTemplates = Partial<{
4168 text: Template<{
4169 isRelevantSorted: boolean;
4170 }>;
4171 button: Template<{
4172 isRelevantSorted: boolean;
4173 }>;
4174}>;
4175
4176declare type RelevantSortWidget = WidgetFactory<RelevantSortWidgetDescription & {
4177 $$widgetType: 'ais.relevantSort';
4178}, RelevantSortConnectorParams, RelevantSortWidgetParams>;
4179
4180declare type RelevantSortWidgetDescription = {
4181 $$type: 'ais.relevantSort';
4182 renderState: RelevantSortRenderState;
4183 indexRenderState: {
4184 relevantSort: WidgetRenderState<RelevantSortRenderState, RelevantSortConnectorParams>;
4185 };
4186 indexUiState: {
4187 relevantSort: number;
4188 };
4189};
4190
4191declare type RelevantSortWidgetParams = {
4192 container: string | HTMLElement;
4193 cssClasses?: RelevantSortCSSClasses;
4194 templates?: RelevantSortTemplates;
4195};
4196
4197/**
4198 * The render function.
4199 */
4200declare type Renderer<TRenderState, TWidgetParams> = (
4201/**
4202 * The base render options plus the specific options of the widget.
4203 */
4204renderState: TRenderState & RendererOptions<TWidgetParams>,
4205/**
4206 * If is the first run.
4207 */
4208isFirstRender: boolean) => void;
4209
4210/**
4211 * The base renderer options. All render functions receive
4212 * the options below plus the specific options per connector.
4213 */
4214declare type RendererOptions<TWidgetParams> = {
4215 /**
4216 * The original widget params. Useful as you may
4217 * need them while using the render function.
4218 */
4219 widgetParams: TWidgetParams;
4220 /**
4221 * The current instant search instance.
4222 */
4223 instantSearchInstance: InstantSearch;
4224 /**
4225 * The original search results.
4226 */
4227 results?: SearchResults;
4228 /**
4229 * The mutable list of hits. The may change depending
4230 * of the given transform items function.
4231 */
4232 hits?: Hits;
4233 /**
4234 * The current insights client, if any.
4235 */
4236 insights?: InsightsClient;
4237};
4238
4239declare type RenderOptions = SharedRenderOptions & {
4240 results: SearchResults;
4241};
4242
4243declare type RenderState = {
4244 [indexId: string]: IndexRenderState;
4245};
4246
4247declare type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
4248
4249declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
4250
4251declare type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = {
4252 /**
4253 * Returns the render state of the current widget to pass to the render function.
4254 */
4255 getWidgetRenderState: (renderOptions: InitOptions | RenderOptions) => Expand<WidgetRenderState<TWidgetDescription['renderState'], TWidgetDescription['widgetParams']>>;
4256 /**
4257 * Returns IndexRenderState of the current index component tree
4258 * to build the render state of the whole app.
4259 */
4260 getRenderState: (renderState: Expand<IndexRenderState & Partial<TWidgetDescription['indexRenderState']>>, renderOptions: InitOptions | RenderOptions) => IndexRenderState & TWidgetDescription['indexRenderState'];
4261};
4262
4263declare type RequiredUiStateLifeCycle<TWidgetDescription extends WidgetDescription> = {
4264 /**
4265 * This function is required for a widget to be taken in account for routing.
4266 * It will derive a uiState for this widget based on the existing uiState and
4267 * the search parameters applied.
4268 *
4269 * @param uiState - Current state.
4270 * @param widgetStateOptions - Extra information to calculate uiState.
4271 */
4272 getWidgetUiState: (uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>, widgetUiStateOptions: {
4273 searchParameters: SearchParameters;
4274 helper: AlgoliaSearchHelper;
4275 }) => Partial<IndexUiState & TWidgetDescription['indexUiState']>;
4276 /**
4277 * This function is required for a widget to be taken in account for routing.
4278 * It will derive a uiState for this widget based on the existing uiState and
4279 * the search parameters applied.
4280 *
4281 * @deprecated Use `getWidgetUiState` instead.
4282 * @param uiState - Current state.
4283 * @param widgetStateOptions - Extra information to calculate uiState.
4284 */
4285 getWidgetState?: RequiredUiStateLifeCycle<TWidgetDescription>['getWidgetUiState'];
4286 /**
4287 * This function is required for a widget to behave correctly when a URL is
4288 * loaded via e.g. Routing. It receives the current UiState and applied search
4289 * parameters, and is expected to return a new search parameters.
4290 *
4291 * @param state - Applied search parameters.
4292 * @param widgetSearchParametersOptions - Extra information to calculate next searchParameters.
4293 */
4294 getWidgetSearchParameters: (state: SearchParameters, widgetSearchParametersOptions: {
4295 uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
4296 }) => SearchParameters;
4297};
4298
4299declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
4300 /**
4301 * Identifier for connectors and widgets.
4302 */
4303 $$type: TWidgetDescription['$$type'];
4304 /**
4305 * Called once before the first search.
4306 */
4307 init?: (options: InitOptions) => void;
4308 /**
4309 * Called after each search response has been received.
4310 */
4311 render?: (options: RenderOptions) => void;
4312 /**
4313 * Called when this widget is unmounted. Used to remove refinements set by
4314 * during this widget's initialization and life time.
4315 */
4316 dispose?: (options: DisposeOptions) => SearchParameters | void;
4317};
4318
4319declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> = {
4320 /**
4321 * Identifier for widgets.
4322 */
4323 $$widgetType: TWidgetDescription['$$widgetType'];
4324};
4325
4326declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
4327
4328declare type ReverseHighlightOptions = {
4329 attribute: string | string[];
4330 highlightedTagName?: string;
4331 hit: Partial<Hit>;
4332 cssClasses?: Partial<{
4333 highlighted: string;
4334 }>;
4335};
4336
4337declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
4338
4339declare type ReverseSnippetOptions = {
4340 attribute: string | string[];
4341 highlightedTagName?: string;
4342 hit: Partial<Hit>;
4343 cssClasses?: Partial<{
4344 highlighted: string;
4345 }>;
4346};
4347
4348/**
4349 * The router is the part that saves and reads the object from the storage.
4350 * Usually this is the URL.
4351 */
4352declare type Router<TRouteState = UiState> = {
4353 /**
4354 * onUpdate Sets an event listener that is triggered when the storage is updated.
4355 * The function should accept a callback to trigger when the update happens.
4356 * In the case of the history / URL in a browser, the callback will be called
4357 * by `onPopState`.
4358 */
4359 onUpdate(callback: (route: TRouteState) => void): void;
4360 /**
4361 * Reads the storage and gets a route object. It does not take parameters,
4362 * and should return an object
4363 */
4364 read(): TRouteState;
4365 /**
4366 * Pushes a route object into a storage. Takes the UI state mapped by the state
4367 * mapping configured in the mapping
4368 */
4369 write(route: TRouteState): void;
4370 /**
4371 * Transforms a route object into a URL. It receives an object and should
4372 * return a string. It may return an empty string.
4373 */
4374 createURL(state: TRouteState): string;
4375 /**
4376 * Called when InstantSearch is disposed. Used to remove subscriptions.
4377 */
4378 dispose(): void;
4379};
4380
4381declare type RouterProps<TUiState extends UiState = UiState, TRouteState = TUiState> = {
4382 router?: Router<TRouteState>;
4383 stateMapping?: StateMapping<TUiState, TRouteState>;
4384};
4385
4386declare namespace routers {
4387 export {
4388 historyRouter as history
4389 }
4390}
4391
4392declare type ScopedResult = {
4393 indexId: string;
4394 results: SearchResults;
4395 helper: AlgoliaSearchHelper;
4396};
4397
4398declare const searchBox: SearchBoxWidget;
4399
4400declare type SearchBoxConnector = Connector<SearchBoxWidgetDescription, SearchBoxConnectorParams>;
4401
4402declare type SearchBoxConnectorParams = {
4403 /**
4404 * A function that will be called every time
4405 * a new value for the query is set. The first parameter is the query and the second is a
4406 * function to actually trigger the search. The function takes the query as the parameter.
4407 *
4408 * This queryHook can be used to debounce the number of searches done from the searchBox.
4409 */
4410 queryHook?: (query: string, hook: (value: string) => void) => void;
4411};
4412
4413declare type SearchBoxCSSClasses = Partial<{
4414 /**
4415 * CSS class to add to the wrapping `<div>`
4416 */
4417 root: string | string[];
4418 /**
4419 * CSS class to add to the form
4420 */
4421 form: string | string[];
4422 /**
4423 * CSS class to add to the input.
4424 */
4425 input: string | string[];
4426 /**
4427 * CSS classes added to the submit button.
4428 */
4429 submit: string | string[];
4430 /**
4431 * CSS classes added to the submit icon.
4432 */
4433 submitIcon: string | string[];
4434 /**
4435 * CSS classes added to the reset button.
4436 */
4437 reset: string | string[];
4438 /**
4439 * CSS classes added to the reset icon.
4440 */
4441 resetIcon: string | string[];
4442 /**
4443 * CSS classes added to the loading indicator element.
4444 */
4445 loadingIndicator: string | string[];
4446 /**
4447 * CSS classes added to the loading indicator icon.
4448 */
4449 loadingIcon: string | string[];
4450}>;
4451
4452/**
4453 * @typedef {Object} CustomSearchBoxWidgetParams@typedef {Object} CustomSearchBoxWidgetParams
4454 * @property {function(string, function(string))} [queryHook = undefined] A function that will be called every time
4455 * a new value for the query is set. The first parameter is the query and the second is a
4456 * function to actually trigger the search. The function takes the query as the parameter.
4457 *
4458 * This queryHook can be used to debounce the number of searches done from the searchBox.
4459 */
4460declare type SearchBoxRenderState = {
4461 /**
4462 * The query from the last search.
4463 */
4464 query: string;
4465 /**
4466 * Sets a new query and searches.
4467 */
4468 refine: (value: string) => void;
4469 /**
4470 * Remove the query and perform search.
4471 */
4472 clear: () => void;
4473 /**
4474 * `true` if the search results takes more than a certain time to come back
4475 * from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
4476 * `stalledSearchDelay` which is 200ms, by default.
4477 */
4478 isSearchStalled: boolean;
4479};
4480
4481declare type SearchBoxTemplates = Partial<{
4482 /**
4483 * Template used for displaying the submit button. Can accept a function or a Hogan string.
4484 */
4485 submit: Template;
4486 /**
4487 * Template used for displaying the reset button. Can accept a function or a Hogan string.
4488 */
4489 reset: Template;
4490 /**
4491 * Template used for displaying the loading indicator. Can accept a function or a Hogan string.
4492 */
4493 loadingIndicator: Template;
4494}>;
4495
4496/**
4497 * The searchbox widget is used to let the user set a text based query.
4498 *
4499 * This is usually the main entry point to start the search in an instantsearch context. For that
4500 * reason is usually placed on top, and not hidden so that the user can start searching right
4501 * away.
4502 *
4503 */
4504declare type SearchBoxWidget = WidgetFactory<SearchBoxWidgetDescription & {
4505 $$widgetType: 'ais.searchBox';
4506}, SearchBoxConnectorParams, SearchBoxWidgetParams>;
4507
4508declare type SearchBoxWidgetDescription = {
4509 $$type: 'ais.searchBox';
4510 renderState: SearchBoxRenderState;
4511 indexRenderState: {
4512 searchBox: WidgetRenderState<SearchBoxRenderState, SearchBoxConnectorParams>;
4513 };
4514 indexUiState: {
4515 query: string;
4516 };
4517};
4518
4519declare type SearchBoxWidgetParams = {
4520 /**
4521 * CSS Selector or HTMLElement to insert the widget
4522 */
4523 container: string | HTMLElement;
4524 /**
4525 * The placeholder of the input
4526 */
4527 placeholder?: string;
4528 /**
4529 * Whether the input should be autofocused
4530 */
4531 autofocus?: boolean;
4532 /**
4533 * If set, trigger the search
4534 * once `<Enter>` is pressed only.
4535 */
4536 searchAsYouType?: boolean;
4537 /**
4538 * Whether to show the reset button
4539 */
4540 showReset?: boolean;
4541 /**
4542 * Whether to show the submit button
4543 */
4544 showSubmit?: boolean;
4545 /**
4546 * Whether to show the loading indicator (replaces the submit if
4547 * the search is stalled)
4548 */
4549 showLoadingIndicator?: boolean;
4550 /**
4551 * CSS classes to add
4552 */
4553 cssClasses?: SearchBoxCSSClasses;
4554 /**
4555 * Templates used for customizing the rendering of the searchbox
4556 */
4557 templates?: SearchBoxTemplates;
4558 /**
4559 * A function that is called every time a new search is done. You
4560 * will get the query as the first parameter and a search (query) function to call as the second parameter.
4561 * This `queryHook` can be used to debounce the number of searches done from the search box.
4562 */
4563 queryHook?: (query: string, hook: (value: string) => void) => void;
4564};
4565
4566declare type SearchClient = {
4567 search: DefaultSearchClient['search'];
4568 searchForFacetValues: DefaultSearchClient['searchForFacetValues'];
4569 addAlgoliaAgent?: DefaultSearchClient['addAlgoliaAgent'];
4570 initIndex?: (indexName: string) => SearchIndex extends {
4571 findAnswers: any;
4572 } ? Partial<Pick<SearchIndex, 'findAnswers'>> : SearchIndex;
4573};
4574
4575declare type SearchIndex = ReturnType<DefaultSearchClient['initIndex']>;
4576
4577declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
4578
4579declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
4580
4581declare type SendEventForHits = BuiltInSendEventForHits & CustomSendEventForHits;
4582
4583declare type SendEventForToggle = BuiltInSendEventForToggle & CustomSendEventForToggle;
4584
4585declare type SharedRenderOptions = {
4586 instantSearchInstance: InstantSearch;
4587 parent: IndexWidget | null;
4588 templatesConfig: Record<string, unknown>;
4589 scopedResults: ScopedResult[];
4590 state: SearchParameters;
4591 renderState: IndexRenderState;
4592 helper: AlgoliaSearchHelper;
4593 searchMetadata: {
4594 isSearchStalled: boolean;
4595 };
4596 createURL(state: SearchParameters): string;
4597};
4598
4599declare function simpleStateMapping<TUiState extends UiState = UiState>(): StateMapping<TUiState, TUiState>;
4600
4601declare function singleIndexStateMapping<TUiState extends UiState = UiState>(indexName: keyof TUiState): StateMapping<TUiState, TUiState[typeof indexName]>;
4602
4603declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
4604
4605declare type SnippetOptions = {
4606 attribute: string | string[];
4607 highlightedTagName?: string;
4608 hit: Partial<Hit>;
4609 cssClasses?: {
4610 highlighted?: string;
4611 };
4612};
4613
4614/**
4615 * Transforms the given items.
4616 */
4617declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<'count' | 'isRefined' | 'name:asc' | 'name:desc'>;
4618
4619/**
4620 * Sort by selector is a widget used for letting the user choose between different
4621 * indices that contains the same data with a different order / ranking formula.
4622 */
4623declare const sortBy: SortByWidget;
4624
4625declare type SortByConnector = Connector<SortByWidgetDescription, SortByConnectorParams>;
4626
4627declare type SortByConnectorParams = {
4628 /**
4629 * Array of objects defining the different indices to choose from.
4630 */
4631 items: SortByItem[];
4632 /**
4633 * Function to transform the items passed to the templates.
4634 */
4635 transformItems?: TransformItems<SortByItem>;
4636};
4637
4638declare type SortByIndexDefinition = {
4639 /**
4640 * The name of the index to target.
4641 */
4642 value: string;
4643 /**
4644 * The label of the index to display.
4645 */
4646 label: string;
4647};
4648
4649/**
4650 * The **SortBy** connector provides the logic to build a custom widget that will display a
4651 * list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows
4652 * a user to change how the hits are being sorted.
4653 */
4654declare type SortByItem = {
4655 /**
4656 * The name of the index to target.
4657 */
4658 value: string;
4659 /**
4660 * The label of the index to display.
4661 */
4662 label: string;
4663};
4664
4665declare type SortByRenderState = {
4666 /**
4667 * The initially selected index.
4668 */
4669 initialIndex?: string;
4670 /**
4671 * The currently selected index.
4672 */
4673 currentRefinement: string;
4674 /**
4675 * All the available indices
4676 */
4677 options: SortByItem[];
4678 /**
4679 * Switches indices and triggers a new search.
4680 */
4681 refine: (value: string) => void;
4682 /**
4683 * `true` if the last search contains no result.
4684 */
4685 hasNoResults: boolean;
4686};
4687
4688declare type SortByWidget = WidgetFactory<SortByWidgetDescription & {
4689 $$widgetType: 'ais.sortBy';
4690}, SortByConnectorParams, SortByWidgetParams>;
4691
4692declare type SortByWidgetCssClasses = Partial<{
4693 /**
4694 * CSS classes added to the outer `<div>`.
4695 */
4696 root: string | string[];
4697 /**
4698 * CSS classes added to the parent `<select>`.
4699 */
4700 select: string | string[];
4701 /**
4702 * CSS classes added to each `<option>`.
4703 */
4704 option: string | string[];
4705}>;
4706
4707declare type SortByWidgetDescription = {
4708 $$type: 'ais.sortBy';
4709 renderState: SortByRenderState;
4710 indexRenderState: {
4711 sortBy: WidgetRenderState<SortByRenderState, SortByConnectorParams>;
4712 };
4713 indexUiState: {
4714 sortBy: string;
4715 };
4716};
4717
4718declare type SortByWidgetParams = {
4719 /**
4720 * CSS Selector or HTMLElement to insert the widget.
4721 */
4722 container: string | HTMLElement;
4723 /**
4724 * Array of objects defining the different indices to choose from.
4725 */
4726 items: SortByIndexDefinition[];
4727 /**
4728 * CSS classes to be added.
4729 */
4730 cssClasses?: SortByWidgetCssClasses;
4731 /**
4732 * Function to transform the items passed to the templates.
4733 */
4734 transformItems?: TransformItems<SortByItem>;
4735};
4736
4737declare type StarRatingItems = {
4738 /**
4739 * Name corresponding to the number of stars.
4740 */
4741 name: string;
4742 /**
4743 * Human-readable name corresponding to the number of stars.
4744 */
4745 label: string;
4746 /**
4747 * Number of stars as string.
4748 */
4749 value: string;
4750 /**
4751 * Count of matched results corresponding to the number of stars.
4752 */
4753 count: number;
4754 /**
4755 * Array of length of maximum rating value with stars to display or not.
4756 */
4757 stars: boolean[];
4758 /**
4759 * Indicates if star rating refinement is applied.
4760 */
4761 isRefined: boolean;
4762};
4763
4764/**
4765 * The state mapping is a way to customize the structure before sending it to the router.
4766 * It can transform and filter out the properties. To work correctly, the following
4767 * should be valid for any UiState:
4768 * `UiState = routeToState(stateToRoute(UiState))`.
4769 */
4770declare type StateMapping<TUiState = UiState, TRouteState = TUiState> = {
4771 /**
4772 * Transforms a UI state representation into a route object.
4773 * It receives an object that contains the UI state of all the widgets in the page.
4774 * It should return an object of any form as long as this form can be read by
4775 * the `routeToState` function.
4776 */
4777 stateToRoute(uiState: TUiState): TRouteState;
4778 /**
4779 * Transforms route object into a UI state representation.
4780 * It receives an object that contains the UI state stored by the router.
4781 * The format is the output of `stateToRoute`.
4782 */
4783 routeToState(routeState: TRouteState): TUiState;
4784};
4785
4786declare namespace stateMappings {
4787 export {
4788 simpleStateMapping as simple,
4789 singleIndexStateMapping as singleIndex
4790 }
4791}
4792
4793declare type StaticOptions = Places.StaticOptions;
4794
4795/**
4796 * The `stats` widget is used to display useful insights about the current results.
4797 *
4798 * By default, it will display the **number of hits** and the time taken to compute the
4799 * results inside the engine.
4800 */
4801declare const stats: StatsWidget;
4802
4803declare type StatsConnector = Connector<StatsWidgetDescription, StatsConnectorParams>;
4804
4805declare type StatsConnectorParams = Record<string, unknown>;
4806
4807declare type StatsCSSClasses = Partial<{
4808 /**
4809 * CSS class to add to the root element.
4810 */
4811 root: string | string[];
4812 /**
4813 * CSS class to add to the text span element.
4814 */
4815 text: string | string[];
4816}>;
4817
4818/**
4819 * **Stats** connector provides the logic to build a custom widget that will displays
4820 * search statistics (hits number and processing time).
4821 */
4822declare type StatsRenderState = {
4823 /**
4824 * The maximum number of hits per page returned by Algolia.
4825 */
4826 hitsPerPage?: number;
4827 /**
4828 * The number of hits in the result set.
4829 */
4830 nbHits: number;
4831 /**
4832 * The number of sorted hits in the result set (when using Relevant sort).
4833 */
4834 nbSortedHits?: number;
4835 /**
4836 * Indicates whether the index is currently using Relevant sort and is displaying only sorted hits.
4837 */
4838 areHitsSorted: boolean;
4839 /**
4840 * The number of pages computed for the result set.
4841 */
4842 nbPages: number;
4843 /**
4844 * The current page.
4845 */
4846 page: number;
4847 /**
4848 * The time taken to compute the results inside the Algolia engine.
4849 */
4850 processingTimeMS: number;
4851 /**
4852 * The query used for the current search.
4853 */
4854 query: string;
4855};
4856
4857declare type StatsTemplates = Partial<{
4858 /**
4859 * Text template, provided with `hasManyResults`, `hasNoResults`, `hasOneResult`, `hitsPerPage`, `nbHits`, `nbSortedHits`, `nbPages`, `areHitsSorted`, `page`, `processingTimeMS`, `query`.
4860 */
4861 text: Template<{
4862 hasManyResults: boolean;
4863 hasNoResults: boolean;
4864 hasOneResult: boolean;
4865 } & StatsRenderState>;
4866}>;
4867
4868declare type StatsWidget = WidgetFactory<StatsWidgetDescription & {
4869 $$widgetType: 'ais.stats';
4870}, StatsConnectorParams, StatsWidgetParams>;
4871
4872declare type StatsWidgetDescription = {
4873 $$type: 'ais.stats';
4874 renderState: StatsRenderState;
4875 indexRenderState: {
4876 stats: WidgetRenderState<StatsRenderState, StatsConnectorParams>;
4877 };
4878};
4879
4880declare type StatsWidgetParams = {
4881 /**
4882 * CSS Selector or HTMLElement to insert the widget.
4883 */
4884 container: string | HTMLElement;
4885 /**
4886 * Templates to use for the widget.
4887 */
4888 templates?: StatsTemplates;
4889 /**
4890 * CSS classes to add.
4891 */
4892 cssClasses?: StatsCSSClasses;
4893};
4894
4895declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
4896
4897declare type Template<TTemplateData = void> = string | ((data: TTemplateData) => string);
4898
4899declare type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, bindEvent: BindEventForHits) => string);
4900
4901/**
4902 * The toggleRefinement widget lets the user either:
4903 * - switch between two values for a single facetted attribute (free_shipping / not_free_shipping)
4904 * - toggleRefinement a faceted value on and off (only 'canon' for brands)
4905 *
4906 * This widget is particularly useful if you have a boolean value in the records.
4907 *
4908 * @requirements
4909 * The attribute passed to `attribute` must be declared as an
4910 * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting)
4911 * in your Algolia settings.
4912 */
4913declare const toggleRefinement: ToggleRefinementWidget;
4914
4915declare type ToggleRefinementConnector = Connector<ToggleRefinementWidgetDescription, ToggleRefinementConnectorParams>;
4916
4917declare type ToggleRefinementConnectorParams = {
4918 /** Name of the attribute for faceting (eg. "free_shipping"). */
4919 attribute: string;
4920 /**
4921 * Value to filter on when toggled.
4922 * @default "true"
4923 */
4924 on?: string | string[] | boolean | boolean[] | number | number[];
4925 /**
4926 * Value to filter on when not toggled.
4927 */
4928 off?: string | string[] | boolean | boolean[] | number | number[];
4929};
4930
4931declare type ToggleRefinementCSSClasses = Partial<{
4932 /**
4933 * CSS class to add to the root element.
4934 */
4935 root: string | string[];
4936 /**
4937 * CSS class to add to the label wrapping element.
4938 */
4939 label: string | string[];
4940 /**
4941 * CSS class to add to the checkbox.
4942 */
4943 checkbox: string | string[];
4944 /**
4945 * CSS class to add to the label text.
4946 */
4947 labelText: string | string[];
4948}>;
4949
4950declare type ToggleRefinementRenderState = {
4951 /** The current toggle value */
4952 value: {
4953 name: string;
4954 isRefined: boolean;
4955 count: number | null;
4956 onFacetValue: ToggleRefinementValue;
4957 offFacetValue: ToggleRefinementValue;
4958 };
4959 /** Creates an URL for the next state. */
4960 createURL: CreateURL<string>;
4961 /** send a "facet clicked" insights event */
4962 sendEvent: SendEventForToggle;
4963 /** Indicates if search state can be refined. */
4964 canRefine: boolean;
4965 /** Updates to the next state by applying the toggle refinement. */
4966 refine: (value?: {
4967 isRefined: boolean;
4968 }) => void;
4969};
4970
4971declare type ToggleRefinementTemplates = Partial<{
4972 /**
4973 * the text that describes the toggle action
4974 */
4975 labelText: Template<ToggleRefinementValue>;
4976}>;
4977
4978declare type ToggleRefinementValue = {
4979 /** whether this option is enabled */
4980 isRefined: boolean;
4981 /** number of result if this option is enabled */
4982 count: number | null;
4983};
4984
4985declare type ToggleRefinementWidget = WidgetFactory<ToggleRefinementWidgetDescription & {
4986 $$widgetType: 'ais.toggleRefinement';
4987}, ToggleRefinementConnectorParams, ToggleRefinementWidgetParams>;
4988
4989declare type ToggleRefinementWidgetDescription = {
4990 $$type: 'ais.toggleRefinement';
4991 renderState: ToggleRefinementRenderState;
4992 indexRenderState: {
4993 toggleRefinement: {
4994 [attribute: string]: WidgetRenderState<ToggleRefinementRenderState, ToggleRefinementConnectorParams>;
4995 };
4996 };
4997 indexUiState: {
4998 toggle: {
4999 [attribute: string]: boolean;
5000 };
5001 };
5002};
5003
5004declare type ToggleRefinementWidgetParams = {
5005 /**
5006 * CSS Selector or HTMLElement to insert the widget.
5007 */
5008 container: string | HTMLElement;
5009 /**
5010 * Templates to use for the widget.
5011 */
5012 templates?: ToggleRefinementTemplates;
5013 /**
5014 * CSS classes to be added.
5015 */
5016 cssClasses?: ToggleRefinementCSSClasses;
5017};
5018
5019declare type TrackedFilterRefinement = string | number | boolean;
5020
5021/**
5022 * Transforms the given items.
5023 */
5024declare type TransformItems<TItem> = (items: TItem[]) => TItem[];
5025
5026declare type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
5027
5028declare type UiState = {
5029 [indexId: string]: IndexUiState;
5030};
5031
5032declare type UiStateLifeCycle<TWidgetDescription extends WidgetDescription> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'indexUiState'> ? RequiredUiStateLifeCycle<TWidgetDescription> : Partial<RequiredUiStateLifeCycle<TWidgetDescription>>;
5033
5034declare type UnknownWidgetParams = NonNullable<object>;
5035
5036/**
5037 * The called function when unmounting a widget.
5038 */
5039declare type Unmounter = () => void;
5040
5041declare type VoiceListeningState = {
5042 status: Status;
5043 transcript: string;
5044 isSpeechFinal: boolean;
5045 errorCode?: string;
5046};
5047
5048declare const voiceSearch: VoiceSearchWidget;
5049
5050declare type VoiceSearchConnector = Connector<VoiceSearchWidgetDescription, VoiceSearchConnectorParams>;
5051
5052declare type VoiceSearchConnectorParams = {
5053 searchAsYouSpeak?: boolean;
5054 language?: string;
5055 additionalQueryParameters?: (params: {
5056 query: string;
5057 }) => PlainSearchParameters | void;
5058 createVoiceSearchHelper?: CreateVoiceSearchHelper;
5059};
5060
5061declare type VoiceSearchCSSClasses = Partial<{
5062 root: string | string[];
5063 button: string | string[];
5064 status: string | string[];
5065}>;
5066
5067declare type VoiceSearchHelper = {
5068 getState: () => VoiceListeningState;
5069 isBrowserSupported: () => boolean;
5070 isListening: () => boolean;
5071 startListening: () => void;
5072 stopListening: () => void;
5073 dispose: () => void;
5074};
5075
5076declare type VoiceSearchHelperParams = {
5077 searchAsYouSpeak: boolean;
5078 language?: string;
5079 onQueryChange: (query: string) => void;
5080 onStateChange: () => void;
5081};
5082
5083declare type VoiceSearchRenderState = {
5084 isBrowserSupported: boolean;
5085 isListening: boolean;
5086 toggleListening: () => void;
5087 voiceListeningState: VoiceListeningState;
5088};
5089
5090declare type VoiceSearchTemplateProps = {
5091 status: string;
5092 errorCode: string;
5093 isListening: boolean;
5094 transcript: string;
5095 isSpeechFinal: boolean;
5096 isBrowserSupported: boolean;
5097};
5098
5099declare type VoiceSearchTemplates = Partial<{
5100 buttonText: Template<VoiceSearchTemplateProps>;
5101 status: Template<VoiceSearchTemplateProps>;
5102}>;
5103
5104declare type VoiceSearchWidget = WidgetFactory<VoiceSearchWidgetDescription & {
5105 $$type: 'ais.voiceSearch';
5106}, VoiceSearchConnectorParams, VoiceSearchWidgetParams>;
5107
5108declare type VoiceSearchWidgetDescription = {
5109 $$type: 'ais.voiceSearch';
5110 renderState: VoiceSearchRenderState;
5111 indexRenderState: {
5112 voiceSearch: WidgetRenderState<VoiceSearchRenderState, VoiceSearchConnectorParams>;
5113 };
5114 indexUiState: {
5115 query: string;
5116 };
5117};
5118
5119declare type VoiceSearchWidgetParams = {
5120 container: string | HTMLElement;
5121 cssClasses?: VoiceSearchCSSClasses;
5122 templates?: VoiceSearchTemplates;
5123 searchAsYouSpeak?: boolean;
5124 language?: string;
5125 additionalQueryParameters?: (params: {
5126 query: string;
5127 }) => PlainSearchParameters | void;
5128 createVoiceSearchHelper?: CreateVoiceSearchHelper;
5129};
5130
5131declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
5132 $$type: string;
5133}> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
5134
5135declare type WidgetDescription = {
5136 $$type: string;
5137 $$widgetType?: string;
5138 renderState?: Record<string, unknown>;
5139 indexRenderState?: Record<string, unknown>;
5140 indexUiState?: Record<string, unknown>;
5141};
5142
5143/**
5144 * The function that creates a new widget.
5145 */
5146declare type WidgetFactory<TWidgetDescription extends WidgetDescription, TConnectorParams extends UnknownWidgetParams, TWidgetParams extends UnknownWidgetParams> = (
5147/**
5148 * The params of the widget.
5149 */
5150widgetParams: TWidgetParams & TConnectorParams) => Widget<TWidgetDescription & {
5151 widgetParams: TConnectorParams;
5152}>;
5153
5154declare type WidgetParams = {
5155 widgetParams?: UnknownWidgetParams;
5156};
5157
5158declare type WidgetRenderState<TWidgetRenderState, TWidgetParams> = TWidgetRenderState & {
5159 widgetParams: TWidgetParams;
5160};
5161
5162declare type WidgetRenderStates = AnalyticsWidgetDescription['indexRenderState'] & PlacesWidgetDescription['indexRenderState'];
5163
5164declare namespace widgets {
5165 export {
5166 analytics,
5167 breadcrumb,
5168 clearRefinements,
5169 configure,
5170 currentRefinements,
5171 answersWidget as EXPERIMENTAL_answers,
5172 configureRelatedItems as EXPERIMENTAL_configureRelatedItems,
5173 dynamicWidgets,
5174 EXPERIMENTAL_dynamicWidgets,
5175 geoSearch,
5176 hierarchicalMenu,
5177 hits,
5178 hitsPerPage,
5179 index,
5180 infiniteHits,
5181 menu,
5182 menuSelect,
5183 numericMenu,
5184 pagination,
5185 panel,
5186 placesWidget as places,
5187 poweredBy,
5188 queryRuleContext,
5189 queryRuleCustomData,
5190 rangeInput,
5191 rangeSlider,
5192 ratingMenu,
5193 refinementList,
5194 relevantSort,
5195 searchBox,
5196 sortBy,
5197 stats,
5198 toggleRefinement,
5199 voiceSearch
5200 }
5201}
5202
5203declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetDescription extends RequiredKeys<WidgetDescription, '$$widgetType'> ? RequiredWidgetType<TWidgetDescription> : {
5204 /**
5205 * Identifier for widgets.
5206 */
5207 $$widgetType?: string;
5208};
5209
5210declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
5211
5212declare type Write = ({ state, hits, }: {
5213 state: PlainSearchParameters;
5214 hits: InfiniteHitsCachedHits;
5215}) => void;
5216
5217export { }
5218
\No newline at end of file