/// import type algoliasearch from 'algoliasearch/lite'; import type { AlgoliaSearchHelper } from 'algoliasearch-helper'; import type * as ClientSearch from '@algolia/client-search'; import EventEmitter from '@algolia/events'; import type { InsightsClient as InsightsClient_2 } from 'search-insights'; import type { InsightsMethodMap } from 'search-insights'; import type * as Places from 'places.js'; import type { PlainSearchParameters } from 'algoliasearch-helper'; import { default as qs_2 } from 'qs'; import type { SearchParameters } from 'algoliasearch-helper'; import type { SearchResults } from 'algoliasearch-helper'; declare type AlgoliaHit = { [attribute: string]: any; objectID: string; _highlightResult?: HitHighlightResult; _snippetResult?: HitSnippetResult; _rankingInfo?: { promoted: boolean; nbTypos: number; firstMatchedWord: number; proximityDistance?: number; geoDistance: number; geoPrecision?: number; nbExactWords: number; words: number; filters: number; userScore: number; matchedGeoLocation?: { lat: number; lng: number; distance: number; }; }; _distinctSeqID?: number; _geoLoc?: GeoLoc; }; declare const analytics: AnalyticsWidget; declare type AnalyticsWidget = WidgetFactory; declare type AnalyticsWidgetDescription = { $$type: 'ais.analytics'; $$widgetType: 'ais.analytics'; renderState: Record; indexRenderState: { analytics: WidgetRenderState, AnalyticsWidgetParams>; }; }; declare type AnalyticsWidgetParams = { /** * A function that is called every time the query or refinements changes. You * need to add the logic to push the data to your analytics platform. */ pushFunction: AnalyticsWidgetParamsPushFunction; /** * The number of milliseconds between the last search keystroke and calling `pushFunction`. * * @default 3000 */ delay?: number; /** * Triggers `pushFunction` after click on page or redirecting the page. This is useful if * you want the pushFunction to be called for the last actions before the user leaves the * current page, even if the delay wasn’t reached. * * @default false */ triggerOnUIInteraction?: boolean; /** * Triggers `pushFunction` when InstantSearch is initialized. This means * the `pushFunction` might be called even though the user didn’t perfom * any search-related action. * * @default true */ pushInitialSearch?: boolean; /** * Triggers `pushFunction` when the page changes, either through the UI or programmatically. * * @default false */ pushPagination?: boolean; }; declare type AnalyticsWidgetParamsPushFunction = ( /** * Contains the search parameters, serialized as a query string. */ formattedParameters: string, /** * Contains the whole search state. */ state: SearchParameters, /** * The last received results. */ results: SearchResults) => void; declare type AnswersConnector = Connector; declare type AnswersConnectorParams = { /** * Attributes to use for predictions. * If empty, we use all `searchableAttributes` to find answers. * All your `attributesForPrediction` must be part of your `searchableAttributes`. */ attributesForPrediction?: string[]; /** * The languages in the query. Currently only supports `en`. */ queryLanguages: ['en']; /** * Maximum number of answers to retrieve from the Answers Engine. * Cannot be greater than 1000. * @default 1 */ nbHits?: number; /** * Debounce time in milliseconds to debounce render * @default 100 */ renderDebounceTime?: number; /** * Debounce time in milliseconds to debounce search * @default 100 */ searchDebounceTime?: number; /** * Whether to escape HTML tags from hits string values. * * @default true */ escapeHTML?: boolean; /** * Extra parameters to pass to findAnswers method. * @default {} */ extraParameters?: FindAnswersOptions; }; declare type AnswersCSSClasses = Partial<{ /** * CSS class to add to the root element of the widget. */ root: string | string[]; /** * CSS class to add to the wrapping element when no results. */ emptyRoot: string | string[]; /** * CSS classes to add to the header. */ header: string | string[]; /** * CSS classes to add to the loader. */ loader: string | string[]; /** * CSS class to add to the list of results. */ list: string | string[]; /** * CSS class to add to each result. */ item: string | string[]; }>; declare type AnswersRenderState = { /** * The matched hits from Algolia API. */ hits: Hits; /** * Whether it's still loading the results from the Answers API. */ isLoading: boolean; }; declare type AnswersTemplates = Partial<{ /** * Template to use for the header. This template will receive an object containing `hits` and `isLoading`. */ header: Template<{ hits: Hit[]; isLoading: boolean; }>; /** * Template to use for the loader. */ loader: Template; /** * Template to use for each result. This template will receive an object containing a single record. */ item: Template; }>; declare type AnswersWidget = WidgetFactory; declare const answersWidget: AnswersWidget; declare type AnswersWidgetDescription = { $$type: 'ais.answers'; renderState: AnswersRenderState; indexRenderState: { answers: WidgetRenderState; }; }; declare type AnswersWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * The templates to use for the widget. */ templates?: AnswersTemplates; /** * The CSS classes to override. */ cssClasses?: AnswersCSSClasses; }; declare type AnyWidgetFactory = WidgetFactory<{ $$type: string; }, Record, any>; declare type AtLeastOne; }> = Partial & TMapped[keyof TMapped]; declare type AugmentedWidget = Omit, TOverriddenKeys> & Pick, TOverriddenKeys>; declare type AutocompleteConnector = Connector; declare type AutocompleteConnectorParams = { /** * Escapes HTML entities from hits string values. * * @default `true` */ escapeHTML?: boolean; }; declare type AutocompleteRenderState = { /** * The current value of the query. */ currentRefinement: string; /** * The indices this widget has access to. */ indices: Array<{ /** * The name of the index */ indexName: string; /** * The resolved hits from the index matching the query. */ hits: Hits; /** * The full results object from the Algolia API. */ results: SearchResults; /** * Send event to insights middleware */ sendEvent: SendEventForHits; }>; /** * Searches into the indices with the provided query. */ refine: (query: string) => void; }; declare type AutocompleteWidgetDescription = { $$type: 'ais.autocomplete'; renderState: AutocompleteRenderState; indexRenderState: { autocomplete: WidgetRenderState; }; indexUiState: { query: string; }; }; declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits; declare type Bounds = { /** * The top right corner of the map view. */ northEast: GeoLoc; /** * The bottom left corner of the map view. */ southWest: GeoLoc; }; declare const breadcrumb: BreadcrumbWidget; declare type BreadcrumbConnector = Connector; declare type BreadcrumbConnectorParams = { /** * Attributes to use to generate the hierarchy of the breadcrumb. */ attributes: string[]; /** * Prefix path to use if the first level is not the root level. */ rootPath?: string; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; /** * The level separator used in the records. * * @default '>' */ separator?: string; }; declare type BreadcrumbConnectorParamsItem = { /** * Label of the category or subcategory. */ label: string; /** * Value of breadcrumb item. */ value: string | null; }; declare type BreadcrumbCSSClasses = Partial<{ /** * CSS class to add to the root element of the widget. */ root: string | string[]; /** * CSS class to add to the root element of the widget if there are no refinements. */ noRefinementRoot: string | string[]; /** * CSS class to add to the list element. */ list: string | string[]; /** * CSS class to add to the items of the list. The items contains the link and the separator. */ item: string | string[]; /** * CSS class to add to the selected item in the list: the last one or the home if there are no refinements. */ selectedItem: string | string[]; /** * CSS class to add to the separator. */ separator: string | string[]; /** * CSS class to add to the links in the items. */ link: string | string[]; }>; declare type BreadcrumbRenderState = { /** * Creates the URL for a single item name in the list. */ createURL: CreateURL; /** * Array of objects defining the different values and labels. */ items: BreadcrumbConnectorParamsItem[]; /** * Sets the path of the hierarchical filter and triggers a new search. */ refine: (value: BreadcrumbConnectorParamsItem['value']) => void; /** * True if refinement can be applied. */ canRefine: boolean; }; declare type BreadcrumbTemplates = Partial<{ /** * Label of the breadcrumb's first element. */ home: Template; /** * Symbol used to separate the elements of the breadcrumb. */ separator: Template; }>; declare type BreadcrumbWidget = WidgetFactory; declare type BreadcrumbWidgetDescription = { $$type: 'ais.breadcrumb'; renderState: BreadcrumbRenderState; indexRenderState: { breadcrumb: { [rootAttribute: string]: WidgetRenderState; }; }; }; declare type BreadcrumbWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * Templates to use for the widget. */ templates?: BreadcrumbTemplates; /** * CSS classes to add to the wrapping elements. */ cssClasses?: BreadcrumbCSSClasses; }; declare class BrowserHistory implements Router { /** * Transforms a UI state into a title for the page. */ private readonly windowTitle?; /** * Time in milliseconds before performing a write in the history. * It prevents from adding too many entries in the history and * makes the back button more usable. * * @default 400 */ private readonly writeDelay; /** * Creates a full URL based on the route state. * The storage adaptor maps all syncable keys to the query string of the URL. */ private readonly _createURL; /** * Parses the URL into a route state. * It should be symmetrical to `createURL`. */ private readonly parseURL; /** * Returns the location to store in the history. * @default () => window.location */ private readonly getLocation; private writeTimer?; private _onPopState; /** * Indicates if history.pushState should be executed. * It needs to avoid pushing state to history in case of back/forward in browser */ private shouldPushState; /** * Initializes a new storage provider that syncs the search state to the URL * using web APIs (`window.location.pushState` and `onpopstate` event). */ constructor({ windowTitle, writeDelay, createURL, parseURL, getLocation, }: BrowserHistoryArgs); /** * Reads the URL and returns a syncable UI search state. */ read(): TRouteState; /** * Pushes a search state into the URL. */ write(routeState: TRouteState): void; /** * Sets a callback on the `onpopstate` event of the history API of the current page. * It enables the URL sync to keep track of the changes. */ onUpdate(callback: (routeState: TRouteState) => void): void; /** * Creates a complete URL from a given syncable UI state. * * It always generates the full URL, not a relative one. * This allows to handle cases like using a . * See: https://github.com/algolia/instantsearch.js/issues/790 */ createURL(routeState: TRouteState): string; /** * Removes the event listener and cleans up the URL. */ dispose(): void; } declare type BrowserHistoryArgs = { windowTitle?: (routeState: TRouteState) => string; writeDelay: number; createURL: CreateURL_2; parseURL: ParseURL; getLocation(): Location; }; declare type BuiltInBindEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => string; declare type BuiltInSendEventForFacet = (eventType: string, facetValue: string, eventName?: string) => void; declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => void; declare type BuiltInSendEventForToggle = (eventType: string, isRefined: boolean, eventName?: string) => void; declare const clearRefinements: ClearRefinementsWidget; declare type ClearRefinementsConnector = Connector; declare type ClearRefinementsConnectorParams = { /** * The attributes to include in the refinements to clear (all by default). Cannot be used with `excludedAttributes`. */ includedAttributes?: string[]; /** * The attributes to exclude from the refinements to clear. Cannot be used with `includedAttributes`. */ excludedAttributes?: string[]; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; }; declare type ClearRefinementsCSSClasses = Partial<{ /** * CSS class to add to the wrapper element. */ root: string | string[]; /** * CSS class to add to the button of the widget. */ button: string | string[]; /** * CSS class to add to the button when there are no refinements. */ disabledButton: string | string[]; }>; declare type ClearRefinementsRenderState = { /** * Triggers the clear of all the currently refined values. */ refine: () => void; /** * Indicates if search state is refined. * @deprecated prefer reading canRefine */ hasRefinements: boolean; /** * Indicates if search state can be refined. */ canRefine: boolean; /** * Creates a url for the next state when refinements are cleared. */ createURL: CreateURL; }; declare type ClearRefinementsTemplates = Partial<{ /** * Template for the content of the button */ resetLabel: Template; }>; declare type ClearRefinementsWidget = WidgetFactory; declare type ClearRefinementsWidgetDescription = { $$type: 'ais.clearRefinements'; renderState: ClearRefinementsRenderState; indexRenderState: { clearRefinements: WidgetRenderState; }; }; declare type ClearRefinementsWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * Templates to use for the widget. */ templates?: ClearRefinementsTemplates; /** * CSS classes to be added. */ cssClasses?: ClearRefinementsCSSClasses; }; declare type ComponentCSSClasses = Required<{ [className in keyof TCSSClasses]: string; }>; declare const configure: ConfigureWidget; declare type ConfigureConnector = Connector; declare type ConfigureConnectorParams = { /** * A list of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) * to enable when the widget mounts. */ searchParameters: PlainSearchParameters; }; declare const configureRelatedItems: ConfigureRelatedItemsWidget; declare type ConfigureRelatedItemsConnector = Connector; declare type ConfigureRelatedItemsConnectorParams = { /** * The reference hit to extract the filters from. */ hit: AlgoliaHit; /** * The schema to create the optional filters. * Each key represents an attribute from the hit. */ matchingPatterns: MatchingPatterns; /** * Function to transform the generated search parameters. */ transformSearchParameters?: TransformSearchParameters; }; declare type ConfigureRelatedItemsWidget = WidgetFactory; declare type ConfigureRelatedItemsWidgetDescription = { $$type: 'ais.configureRelatedItems'; } & Omit; declare type ConfigureRelatedItemsWidgetParams = PlainSearchParameters; declare type ConfigureRenderState = { /** * Refine the given search parameters. */ refine: Refine; }; declare type ConfigureWidget = (widgetParams: ConfigureWidgetParams) => Widget; declare type ConfigureWidgetDescription = { $$type: 'ais.configure'; renderState: ConfigureRenderState; indexRenderState: { configure: WidgetRenderState; }; indexUiState: { configure: PlainSearchParameters; }; }; /** * A list of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) * to enable when the widget mounts. */ declare type ConfigureWidgetParams = ConfigureConnectorParams['searchParameters']; declare const connectAnswers: AnswersConnector; declare const connectAutocomplete: AutocompleteConnector; declare const connectBreadcrumb: BreadcrumbConnector; declare const connectClearRefinements: ClearRefinementsConnector; declare const connectConfigure: ConfigureConnector; declare const connectConfigureRelatedItems: ConfigureRelatedItemsConnector; declare const connectCurrentRefinements: CurrentRefinementsConnector; declare const connectDynamicWidgets: DynamicWidgetsConnector; /** * 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). * * @requirements * * 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. * * Currently, the feature is not compatible with multiple values in the _geoloc attribute. */ declare const connectGeoSearch: GeoSearchConnector; /** * **HierarchicalMenu** connector provides the logic to build a custom widget * that will give the user the ability to explore facets in a tree-like structure. * * This is commonly used for multi-level categorization of products on e-commerce * websites. From a UX point of view, we suggest not displaying more than two * levels deep. * * @type {Connector} * @param {function(HierarchicalMenuRenderingOptions, boolean)} renderFn Rendering function for the custom **HierarchicalMenu** widget. * @param {function} unmountFn Unmount function called when the widget is disposed. * @return {function(CustomHierarchicalMenuWidgetParams)} Re-usable widget factory for a custom **HierarchicalMenu** widget. */ declare const connectHierarchicalMenu: HierarchicalMenuConnector; declare const connectHits: HitsConnector; declare const connectHitsPerPage: HitsPerPageConnector; declare const connectHitsWithInsights: HitsConnector; declare const connectInfiniteHits: InfiniteHitsConnector; declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector; /** * **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. * * This connector provides a `toggleShowMore()` function to display more or less items and a `refine()` * function to select an item. While selecting a new element, the `refine` will also unselect the * one that is currently selected. * * **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. */ declare const connectMenu: MenuConnector; declare const connectNumericMenu: NumericMenuConnector; /** * The connector handles the business logic and exposes * a simplified API to the rendering function. */ declare type Connector = ( /** * The render function. */ renderFn: Renderer, /** * The called function when unmounting a widget. */ unmountFn?: Unmounter) => (widgetParams: TConnectorParams & TWidgetParams) => Widget; declare 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']; declare namespace connectors { export { connectClearRefinements, connectCurrentRefinements, connectHierarchicalMenu, connectHits, connectHitsWithInsights, connectHitsPerPage, connectInfiniteHits, connectInfiniteHitsWithInsights, connectMenu, connectNumericMenu, connectPagination, connectRange, connectRefinementList, connectSearchBox, connectSortBy, connectRatingMenu, connectStats, connectToggleRefinement, connectBreadcrumb, connectGeoSearch, connectPoweredBy, connectConfigure, connectConfigureRelatedItems as EXPERIMENTAL_connectConfigureRelatedItems, connectAutocomplete, connectQueryRules, connectVoiceSearch, connectAnswers as EXPERIMENTAL_connectAnswers, connectRelevantSort, connectDynamicWidgets, EXPERIMENTAL_connectDynamicWidgets } } declare 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']; /** * **Pagination** connector provides the logic to build a widget that will let the user * choose the current page of the results. * * When using the pagination with Algolia, you should be aware that the engine won't provide you pages * 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). */ declare const connectPagination: PaginationConnector; /** * **PoweredBy** connector provides the logic to build a custom widget that will displays * the logo to redirect to Algolia. */ declare const connectPoweredBy: PoweredByConnector; declare const connectQueryRules: QueryRulesConnector; /** * **Range** connector provides the logic to create custom widget that will let * the user refine results using a numeric range. * * This connectors provides a `refine()` function that accepts bounds. It will also provide * information about the min and max bounds for the current result set. */ declare const connectRange: RangeConnector; /** * **StarRating** connector provides the logic to build a custom widget that will let * the user refine search results based on ratings. * * The connector provides to the rendering: `refine()` to select a value and * `items` that are the values that can be selected. `refine` should be used * with `items.value`. */ declare const connectRatingMenu: RatingMenuConnector; /** * **RefinementList** connector provides the logic to build a custom widget that * will let the user filter the results based on the values of a specific facet. * * **Requirement:** the attribute passed as `attribute` must be present in * attributesForFaceting of the searched index. * * This connector provides: * - a `refine()` function to select an item. * - a `toggleShowMore()` function to display more or less items * - a `searchForItems()` function to search within the items. */ declare const connectRefinementList: RefinementListConnector; declare const connectRelevantSort: RelevantSortConnector; /** * **SearchBox** connector provides the logic to build a widget that will let the user search for a query. * * The connector provides to the rendering: `refine()` to set the query. The behaviour of this function * may be impacted by the `queryHook` widget parameter. */ declare const connectSearchBox: SearchBoxConnector; declare const connectSortBy: SortByConnector; declare const connectStats: StatsConnector; /** * **Toggle** connector provides the logic to build a custom widget that will provide * an on/off filtering feature based on an attribute value or values. * * Two modes are implemented in the custom widget: * - with or without the value filtered * - switch between two values. */ declare const connectToggleRefinement: ToggleRefinementConnector; declare const connectVoiceSearch: VoiceSearchConnector; declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache; declare type CreateInsightsMiddleware = (props: InsightsProps) => InternalMiddleware; declare const createInsightsMiddleware: CreateInsightsMiddleware; /** * Exposes the metadata of mounted widgets in a custom * `` tag. The metadata per widget is: * - applied parameters * - widget name * - connector name */ declare function createMetadataMiddleware(): InternalMiddleware; declare const createRouterMiddleware: (props?: RouterProps) => InternalMiddleware; /** * Creates the URL for the given value. */ declare type CreateURL = (value: TValue) => string; declare type CreateURL_2 = (args: { qsModule: typeof qs_2; routeState: TRouteState; location: Location; }) => string; declare type CreateVoiceSearchHelper = (params: VoiceSearchHelperParams) => VoiceSearchHelper; declare const currentRefinements: CurrentRefinementsWidget; declare type CurrentRefinementsConnector = Connector; declare type CurrentRefinementsConnectorParams = { /** * The attributes to include in the widget (all by default). * Cannot be used with `excludedAttributes`. * * @default `[]` */ includedAttributes?: string[]; /** * The attributes to exclude from the widget. * Cannot be used with `includedAttributes`. * * @default `['query']` */ excludedAttributes?: string[]; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; }; declare type CurrentRefinementsConnectorParamsItem = { /** * The index name. */ indexName: string; /** * The attribute on which the refinement is applied. */ attribute: string; /** * The textual representation of this attribute. */ label: string; /** * Currently applied refinements. */ refinements: CurrentRefinementsConnectorParamsRefinement[]; /** * Removes the given refinement and triggers a new search. */ refine(refinement: CurrentRefinementsConnectorParamsRefinement): void; }; declare type CurrentRefinementsConnectorParamsRefinement = { /** * The attribute on which the refinement is applied. */ attribute: string; /** * The type of the refinement. * * It can be one of those: 'facet'|'exclude'|'disjunctive'|'hierarchical'|'numeric'|'query'|'tag'. */ type: string; /** * The raw value of the refinement. */ value: string | number; /** * The label of the refinement to display. */ label: string; /** * The value of the operator (only if applicable). */ operator?: string; /** * The number of found items (only if applicable). */ count?: number; /** * Whether the count is exhaustive (only if applicable). */ exhaustive?: boolean; }; declare type CurrentRefinementsCSSClasses = Partial<{ /** * CSS class to add to the root element. */ root: string | string[]; /** * CSS class to add to the list element. */ list: string | string[]; /** * CSS class to add to the each item element. */ item: string | string[]; /** * CSS class to add to the label element. */ label: string | string[]; /** * CSS class to add to the category element. */ category: string | string[]; /** * CSS class to add to the categoryLabel element. */ categoryLabel: string | string[]; /** * CSS class to add to the delete element. */ delete: string | string[]; }>; declare type CurrentRefinementsRenderState = { /** * All the currently refined items, grouped by attribute. */ items: CurrentRefinementsConnectorParamsItem[]; /** * Indicates if search state can be refined. */ canRefine: boolean; /** * Removes the given refinement and triggers a new search. */ refine(refinement: CurrentRefinementsConnectorParamsRefinement): void; /** * Generates a URL for the next state. */ createURL: CreateURL; }; declare type CurrentRefinementsWidget = WidgetFactory; declare type CurrentRefinementsWidgetDescription = { $$type: 'ais.currentRefinements'; renderState: CurrentRefinementsRenderState; indexRenderState: { currentRefinements: WidgetRenderState; }; }; declare type CurrentRefinementsWidgetParams = { /** * The CSS Selector or `HTMLElement` to insert the widget into. */ container: string | HTMLElement; /** * The CSS classes to override. */ cssClasses?: CurrentRefinementsCSSClasses; }; declare type CustomBindEventForHits = (customPayload: any) => string; declare type CustomSendEventForFacet = (customPayload: any) => void; declare type CustomSendEventForHits = (customPayload: any) => void; declare type CustomSendEventForToggle = (customPayload: any) => void; declare type DefaultSearchClient = ReturnType; declare type DisposeOptions = { helper: AlgoliaSearchHelper; state: SearchParameters; parent: IndexWidget; }; declare type DummySearchClientV4 = { readonly transporter: any; }; declare const dynamicWidgets: DynamicWidgetsWidget; declare type DynamicWidgetsConnector = Connector; declare type DynamicWidgetsConnectorParams = { /** * An array of widgets, displayed in the order defined by `facetOrdering`. */ widgets: Widget[]; /** * Function to return a fallback widget when an attribute isn't found in * `widgets`. */ fallbackWidget?(args: { /** The attribute name to create a widget for. */ attribute: string; }): Widget; /** * Function to transform the items to render. * The function also exposes the full search response. */ transformItems?(items: string[], metadata: { results: SearchResults; }): string[]; /** * To prevent unneeded extra network requests when widgets mount or unmount, * we request all facet values. * * @default ['*'] */ facets?: ['*'] | never[]; /** * If you have more than 20 facet values pinned, you need to increase the * maxValuesPerFacet to at least that value. * * @default 20 */ maxValuesPerFacet?: number; }; declare type DynamicWidgetsRenderState = { attributesToRender: string[]; }; declare type DynamicWidgetsWidget = WidgetFactory, DynamicWidgetsWidgetParams>; declare type DynamicWidgetsWidgetDescription = { $$type: 'ais.dynamicWidgets'; renderState: DynamicWidgetsRenderState; indexRenderState: { dynamicWidgets: DynamicWidgetsRenderState; }; }; declare type DynamicWidgetsWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * An array of widget creator functions, displayed in the order defined by * `facetOrdering`. */ widgets: Array<(container: HTMLElement) => Widget>; /** * Function to return a fallback widget when an attribute isn't found in * `widgets`. */ fallbackWidget?(args: { /** The attribute name to create a widget for. */ attribute: string; /** CSS Selector or HTMLElement to insert the widget */ container: HTMLElement; }): Widget; }; declare type Expand = T extends infer O ? { [K in keyof O]: O[K]; } : never; /** @deprecated use connectDynamicWidgets */ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector; /** @deprecated use dynamicWidgets */ declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget; declare type FindAnswersOptions = DefaultSearchClient extends DummySearchClientV4 ? ClientSearch.FindAnswersOptions : any; declare type GeoHit = Hit & Required>; declare type GeoLoc = { lat: number; lng: number; }; /** * 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. * * @requirements * * 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. * * Currently, the feature is not compatible with multiple values in the _geoloc attribute. * * 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). * * 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). */ declare const geoSearch: GeoSearchWidget; declare type GeoSearchConnector = Connector; declare type GeoSearchConnectorParams = { /** * If true, refine will be triggered as you move the map. * @default true */ enableRefineOnMapMove?: boolean; /** * Function to transform the items passed to the templates. * @default items => items */ transformItems?: TransformItems; }; declare type GeoSearchCSSClasses = Partial<{ /** The root div of the widget. */ root: string | string[]; /** The map container of the widget. */ map: string | string[]; /** The control element of the widget. */ control: string | string[]; /** The label of the control element. */ label: string | string[]; /** The selected label of the control element. */ selectedLabel: string | string[]; /** The input of the control element. */ input: string | string[]; /** The redo search button. */ redo: string | string[]; /** The disabled redo search button. */ disabledRedo: string | string[]; /** The reset refinement button. */ reset: string | string[]; }>; declare type GeoSearchMarker = { /** * Function used to create the options passed to the Google Maps marker. * See the documentation for more information: * https://developers.google.com/maps/documentation/javascript/reference/3/#MarkerOptions */ createOptions?(item: GeoHit): TOptions; /** * Object that takes an event type (ex: `click`, `mouseover`) as key and a * listener as value. The listener is provided with an object that contains: * `event`, `item`, `marker`, `map`. */ events: { [key: string]: (event: { item: any; marker: any; map: any; event: any; }) => void; }; }; declare type GeoSearchRenderState = { /** * Reset the current bounding box refinement. */ clearMapRefinement(): void; /** * The current bounding box of the search. */ currentRefinement?: Bounds; /** * Return true if the map has move since the last refinement. */ hasMapMoveSinceLastRefine(): boolean; /** * Return true if the current refinement is set with the map bounds. */ isRefinedWithMap(): boolean; /** * Return true if the user is able to refine on map move. */ isRefineOnMapMove(): boolean; /** * The matched hits from Algolia API. */ items: GeoHit[]; /** * The current position of the search. */ position?: GeoLoc; /** * Sets a bounding box to filter the results from the given map bounds. */ refine(bounds: Bounds): void; /** * Send event to insights middleware */ sendEvent: SendEventForHits; /** * Set the fact that the map has moved since the last refinement, should be * called on each map move. The call to the function triggers a new rendering * only when the value change. */ setMapMoveSinceLastRefine(): void; /** * Toggle the fact that the user is able to refine on map move. */ toggleRefineOnMapMove(): void; }; declare type GeoSearchTemplates = Partial<{ /** Template to use for the marker. */ HTMLMarker: Template; /** Template for the reset button. */ reset: Template; /** Template for the toggle label. */ toggle: Template; /** Template for the redo button. */ redo: Template; }>; declare type GeoSearchWidget = WidgetFactory; declare type GeoSearchWidgetDescription = { $$type: 'ais.geoSearch'; renderState: GeoSearchRenderState; indexRenderState: { geoSearch: WidgetRenderState; }; indexUiState: { geoSearch: { /** * The rectangular area in geo coordinates. * The rectangle is defined by two diagonally opposite points, * hence by 4 floats separated by commas. * * @example '47.3165,4.9665,47.3424,5.0201' */ boundingBox: string; }; }; }; declare type GeoSearchWidgetParams = { /** * By default the map will set the zoom accordingly to the markers displayed on it. * When we refine it may happen that the results are empty. For those situations we * need to provide a zoom to render the map. * @default 1 */ initialZoom?: number; /** * By default the map will set the position accordingly to the markers displayed on it. * When we refine it may happen that the results are empty. For those situations we need * to provide a position to render the map. This option is ignored when the `position` * is provided. * @default { lat: 0, lng: 0 } */ initialPosition?: GeoLoc; /** Templates to use for the widget. */ templates?: GeoSearchTemplates; /** CSS classes to add to the wrapping elements. */ cssClasses?: GeoSearchCSSClasses; /** * Options for customize the built-in Google Maps marker. This option is * ignored when the `customHTMLMarker` is provided. */ builtInMarker?: Partial>; /** * Options to customize the HTML marker. We provide an alternative to the * built-in Google Maps marker in order to have a full control of the marker * rendering. You can use plain HTML to build your marker. */ customHTMLMarker?: Partial>> | boolean; /** * If true, the map is used to search - otherwise it's for display purposes only. * @default true */ enableRefine?: boolean; /** * If true, a button is displayed on the map when the refinement is coming from * the map in order to remove it. * @default true */ enableClearMapRefinement?: boolean; /** * If true, the user can toggle the option `enableRefineOnMapMove` directly from the map. * @default true */ enableRefineControl?: boolean; /** * Option forwarded to the Google Maps constructor. * See the documentation for more information: * https://developers.google.com/maps/documentation/javascript/reference/3/#MapOptions */ mapOptions?: google.maps.MapOptions; /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * Reference to the global `window.google` object. * See [the documentation](https://developers.google.com/maps/documentation/javascript/tutorial) for more information. */ googleReference: typeof window['google']; }; /** * @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/ */ declare function getInsightsAnonymousUserToken(): string | undefined; declare function getInsightsAnonymousUserTokenInternal(): string | undefined; declare type GetWidgetRenderState = ReturnType['getWidgetRenderState'] extends (renderOptions: any) => infer TRenderState ? TRenderState extends Record ? TRenderState : never : Record; declare namespace helpers { export { reverseHighlight, reverseSnippet, highlight, snippet, insights, getInsightsAnonymousUserToken, getInsightsAnonymousUserTokenInternal, HighlightOptions, ReverseHighlightOptions, SnippetOptions, ReverseSnippetOptions } } declare const hierarchicalMenu: HierarchicalMenuWidget; declare type HierarchicalMenuConnector = Connector; declare type HierarchicalMenuConnectorParams = { /** * Attributes to use to generate the hierarchy of the menu. */ attributes: string[]; /** * Separator used in the attributes to separate level values. */ separator?: string; /** * Prefix path to use if the first level is not the root level. */ rootPath?: string | null; /** * Show the siblings of the selected parent levels of the current refined value. This * does not impact the root level. */ showParentLevel?: boolean; /** * Max number of values to display. */ limit?: number; /** * Whether to display the "show more" button. */ showMore?: boolean; /** * Max number of values to display when showing more. */ showMoreLimit?: number; /** * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`. * 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). * * If a facetOrdering is set in the index settings, it is used when sortBy isn't passed */ sortBy?: SortBy; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; }; declare type HierarchicalMenuCSSClasses = Partial<{ /** * CSS class to add to the root element. */ root: string | string[]; /** * CSS class to add to the root element when no refinements. */ noRefinementRoot: string | string[]; /** * CSS class to add to the list element. */ list: string | string[]; /** * CSS class to add to the child list element. */ childList: string | string[]; /** * CSS class to add to each item element. */ item: string | string[]; /** * CSS class to add to each selected item element. */ selectedItem: string | string[]; /** * CSS class to add to each parent item element. */ parentItem: string | string[]; /** * CSS class to add to each link (when using the default template). */ link: string | string[]; /** * CSS class to add to each label (when using the default template). */ label: string | string[]; /** * CSS class to add to each count element (when using the default template). */ count: string | string[]; /** * CSS class to add to the show more element. */ showMore: string | string[]; /** * CSS class to add to the disabled show more element. */ disabledShowMore: string | string[]; }>; declare type HierarchicalMenuItem = { /** * Value of the menu item. */ value: string; /** * Human-readable value of the menu item. */ label: string; /** * Number of matched results after refinement is applied. */ count: number; /** * Indicates if the refinement is applied. */ isRefined: boolean; /** * n+1 level of items, same structure HierarchicalMenuItem */ data: HierarchicalMenuItem[] | null; }; declare type HierarchicalMenuRenderState = { /** * Creates an url for the next state for a clicked item. */ createURL: CreateURL; /** * Values to be rendered. */ items: HierarchicalMenuItem[]; /** * Sets the path of the hierarchical filter and triggers a new search. */ refine: (value: string) => void; /** * Indicates if search state can be refined. */ canRefine: boolean; /** * True if the menu is displaying all the menu items. */ isShowingMore: boolean; /** * Toggles the number of values displayed between `limit` and `showMoreLimit`. */ toggleShowMore: () => void; /** * `true` if the toggleShowMore button can be activated (enough items to display more or * already displaying more than `limit` items) */ canToggleShowMore: boolean; /** * Send event to insights middleware */ sendEvent: SendEventForFacet; }; declare type HierarchicalMenuTemplates = Partial<{ /** * Item template, provided with `name`, `count`, `isRefined`, `url` data properties. */ item: Template<{ name: string; count: number; isRefined: boolean; url: string; }>; /** * Template used for the show more text, provided with `isShowingMore` data property. */ showMoreText: Template<{ isShowingMore: boolean; }>; }>; /** * The hierarchical menu widget is used to create a navigation based on a hierarchy of facet attributes. * * It is commonly used for categories with subcategories. * * 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 * Algolia settings. * * By default, the separator we expect is ` > ` (with spaces) but you can use * a different one by using the `separator` option. * @requirements * Your objects must be formatted in a specific way to be * able to display hierarchical menus. Here's an example: * * ```javascript * { * "objectID": "123", * "name": "orange", * "categories": { * "lvl0": "fruits", * "lvl1": "fruits > citrus" * } * } * ``` * * Every level must be specified entirely. * It's also possible to have multiple values per level, for example: * * ```javascript * { * "objectID": "123", * "name": "orange", * "categories": { * "lvl0": ["fruits", "vitamins"], * "lvl1": ["fruits > citrus", "vitamins > C"] * } * } * ``` * @type {WidgetFactory} * @devNovel HierarchicalMenu * @category filter * @param {HierarchicalMenuWidgetParams} widgetParams The HierarchicalMenu widget options. * @return {Widget} A new HierarchicalMenu widget instance. * @example * search.addWidgets([ * instantsearch.widgets.hierarchicalMenu({ * container: '#hierarchical-categories', * attributes: ['hierarchicalCategories.lvl0', 'hierarchicalCategories.lvl1', 'hierarchicalCategories.lvl2'], * }) * ]); */ declare type HierarchicalMenuWidget = WidgetFactory; declare type HierarchicalMenuWidgetDescription = { $$type: 'ais.hierarchicalMenu'; renderState: HierarchicalMenuRenderState; indexRenderState: { hierarchicalMenu: { [rootAttribute: string]: WidgetRenderState; }; }; indexUiState: { hierarchicalMenu: { [rootAttribute: string]: string[]; }; }; }; declare type HierarchicalMenuWidgetParams = { /** * CSS Selector or HTMLElement to insert the widget. */ container: string | HTMLElement; /** * Array of attributes to use to generate the hierarchy of the menu. */ attributes: string[]; /** * Separator used in the attributes to separate level values. */ separator?: string; /** * Prefix path to use if the first level is not the root level. */ rootPath?: string; /** * Show the siblings of the selected parent level of the current refined value. * * With `showParentLevel` set to `true` (default): * - Parent lvl0 * - **lvl1** * - **lvl2** * - lvl2 * - lvl2 * - lvl 1 * - lvl 1 * - Parent lvl0 * - Parent lvl0 * * With `showParentLevel` set to `false`: * - Parent lvl0 * - **lvl1** * - **lvl2** * - Parent lvl0 * - Parent lvl0 */ showParentLevel?: boolean; /** * Max number of values to display. */ limit?: number; /** * Whether to display the "show more" button. */ showMore?: boolean; /** * Max number of values to display when showing more. * does not impact the root level. */ showMoreLimit?: number; /** * How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`. * 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). */ sortBy?: SortBy; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; /** * Templates to use for the widget. */ templates?: HierarchicalMenuTemplates; /** * CSS classes to add to the wrapping elements. */ cssClasses?: HierarchicalMenuCSSClasses; }; declare function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string; declare type HighlightOptions = { attribute: string | string[]; highlightedTagName?: string; hit: Partial; cssClasses?: Partial<{ highlighted: string; }>; }; declare function historyRouter({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial>): BrowserHistory; declare type Hit = { __position: number; __queryID?: string; } & AlgoliaHit; declare type HitAttributeHighlightResult = { value: string; matchLevel: 'none' | 'partial' | 'full'; matchedWords: string[]; fullyHighlighted?: boolean; }; declare type HitAttributeSnippetResult = Pick; declare type HitHighlightResult = { [attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult; }; declare type Hits = Hit[]; declare const hits: HitsWidget; declare type HitsConnector = Connector; declare type HitsConnectorParams = { /** * Whether to escape HTML tags from hits string values. * * @default true */ escapeHTML?: boolean; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; }; declare type HitsCSSClasses = Partial<{ /** * CSS class to add to the wrapping element. */ root: string | string[]; /** * CSS class to add to the wrapping element when no results. */ emptyRoot: string | string[]; /** * CSS class to add to the list of results. */ list: string | string[]; /** * CSS class to add to each result. */ item: string | string[]; }>; declare type HitSnippetResult = { [attribute: string]: HitAttributeSnippetResult[] | HitSnippetResult[] | HitAttributeSnippetResult | HitSnippetResult; }; declare const hitsPerPage: HitsPerPageWidget; declare type HitsPerPageConnector = Connector; declare type HitsPerPageConnectorParams = { /** * Array of objects defining the different values and labels. */ items: HitsPerPageConnectorParamsItem[]; /** * Function to transform the items passed to the templates. */ transformItems?: TransformItems; }; declare type HitsPerPageConnectorParamsItem = { /** * Label to display in the option. */ label: string; /** * Number of hits to display per page. */ value: number; /** * The default hits per page on first search. * * @default false */ default?: boolean; }; declare type HitsPerPageCSSClasses = Partial<{ /** * CSS classes added to the outer `
`. */ root: string | string[]; /** * CSS classes added to the parent ``. */ select: string | string[]; /** * CSS classes added to each `