instantsearch.js 4.54.1 → 4.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Breadcrumb/Breadcrumb.js +2 -2
- package/cjs/components/Hits/Hits.js +16 -7
- package/cjs/components/InfiniteHits/InfiniteHits.js +13 -2
- package/cjs/components/RangeInput/RangeInput.js +22 -11
- package/cjs/components/RefinementList/RefinementList.js +34 -52
- package/cjs/components/Slider/Rheostat.js +163 -249
- package/cjs/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/cjs/connectors/geo-search/connectGeoSearch.js +1 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/cjs/connectors/hits/connectHits.js +1 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +55 -32
- package/cjs/connectors/menu/connectMenu.js +1 -1
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/cjs/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/cjs/connectors/refinement-list/connectRefinementList.js +1 -1
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +14 -4
- package/cjs/helpers/insights.js +3 -4
- package/cjs/lib/InstantSearch.js +20 -6
- package/cjs/lib/insights/listener.js +43 -36
- package/cjs/lib/routers/history.js +55 -1
- package/cjs/lib/stateMappings/simple.js +1 -0
- package/cjs/lib/stateMappings/singleIndex.js +1 -0
- package/cjs/lib/utils/createSendEventForFacet.js +12 -2
- package/cjs/lib/utils/createSendEventForHits.js +34 -11
- package/cjs/lib/utils/render-args.js +3 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +135 -33
- package/cjs/middlewares/createMetadataMiddleware.js +17 -5
- package/cjs/middlewares/createRouterMiddleware.js +5 -1
- package/cjs/widgets/hits/hits.js +1 -2
- package/cjs/widgets/hits-per-page/hits-per-page.js +3 -1
- package/cjs/widgets/index/index.js +8 -8
- package/cjs/widgets/infinite-hits/infinite-hits.js +1 -2
- package/dist/instantsearch.development.d.ts +143 -84
- package/dist/instantsearch.development.js +770 -584
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +143 -84
- package/dist/instantsearch.production.min.d.ts +143 -84
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
- package/es/components/Breadcrumb/Breadcrumb.js +2 -2
- package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.d.ts +3 -3
- package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
- package/es/components/Hits/Hits.d.ts +5 -5
- package/es/components/Hits/Hits.js +15 -5
- package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -2
- package/es/components/InfiniteHits/InfiniteHits.js +13 -2
- package/es/components/Pagination/Pagination.d.ts +2 -2
- package/es/components/RangeInput/RangeInput.d.ts +7 -4
- package/es/components/RangeInput/RangeInput.js +22 -11
- package/es/components/RefinementList/RefinementList.d.ts +0 -1
- package/es/components/RefinementList/RefinementList.js +34 -52
- package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
- package/es/components/Selector/Selector.d.ts +2 -2
- package/es/components/Slider/Rheostat.d.ts +23 -17
- package/es/components/Slider/Rheostat.js +163 -249
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +2 -2
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +2 -2
- package/es/connectors/geo-search/connectGeoSearch.d.ts +7 -7
- package/es/connectors/geo-search/connectGeoSearch.js +1 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/es/connectors/hits/connectHits.js +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.js +56 -33
- package/es/connectors/menu/connectMenu.d.ts +2 -2
- package/es/connectors/menu/connectMenu.js +1 -1
- package/es/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/es/connectors/pagination/connectPagination.d.ts +1 -1
- package/es/connectors/range/connectRange.d.ts +3 -3
- package/es/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/es/connectors/refinement-list/connectRefinementList.d.ts +3 -3
- package/es/connectors/refinement-list/connectRefinementList.js +1 -1
- package/es/connectors/relevant-sort/connectRelevantSort.d.ts +1 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +13 -3
- package/es/helpers/insights.d.ts +2 -1
- package/es/helpers/insights.js +3 -3
- package/es/lib/InstantSearch.d.ts +24 -14
- package/es/lib/InstantSearch.js +21 -7
- package/es/lib/insights/listener.d.ts +10 -6
- package/es/lib/insights/listener.js +42 -36
- package/es/lib/routers/history.d.ts +3 -2
- package/es/lib/routers/history.js +56 -2
- package/es/lib/stateMappings/simple.js +1 -0
- package/es/lib/stateMappings/singleIndex.js +1 -0
- package/es/lib/utils/createSendEventForFacet.js +12 -2
- package/es/lib/utils/createSendEventForHits.d.ts +8 -0
- package/es/lib/utils/createSendEventForHits.js +33 -11
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/render-args.js +3 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.d.ts +12 -12
- package/es/middlewares/createInsightsMiddleware.js +136 -34
- package/es/middlewares/createMetadataMiddleware.d.ts +3 -1
- package/es/middlewares/createMetadataMiddleware.js +17 -5
- package/es/middlewares/createRouterMiddleware.js +5 -1
- package/es/types/insights.d.ts +19 -1
- package/es/types/middleware.d.ts +22 -6
- package/es/types/router.d.ts +15 -7
- package/es/types/widget.d.ts +1 -1
- package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
- package/es/widgets/geo-search/geo-search.d.ts +1 -1
- package/es/widgets/hits/hits.js +2 -3
- package/es/widgets/hits-per-page/hits-per-page.js +3 -1
- package/es/widgets/index/index.d.ts +20 -20
- package/es/widgets/index/index.js +8 -8
- package/es/widgets/infinite-hits/infinite-hits.js +2 -3
- package/es/widgets/panel/panel.d.ts +2 -2
- package/es/widgets/range-slider/range-slider.d.ts +1 -1
- package/package.json +7 -7
|
@@ -10,7 +10,7 @@ import type { HighlightProps as HighlightProps_3 } from '@algolia/ui-components-
|
|
|
10
10
|
import type { HoganOptions } from 'hogan.js';
|
|
11
11
|
import type { html } from 'htm/preact';
|
|
12
12
|
import type { InsightsClient as InsightsClient_2 } from 'search-insights';
|
|
13
|
-
import type { InsightsMethodMap } from 'search-insights';
|
|
13
|
+
import type { InsightsMethodMap as InsightsMethodMap_2 } from 'search-insights';
|
|
14
14
|
import type * as Places from 'places.js';
|
|
15
15
|
import type { PlainSearchParameters } from 'algoliasearch-helper';
|
|
16
16
|
import { default as qs_2 } from 'qs';
|
|
@@ -438,6 +438,7 @@ declare type BreadcrumbWidgetParams = {
|
|
|
438
438
|
};
|
|
439
439
|
|
|
440
440
|
declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
441
|
+
$$type: string;
|
|
441
442
|
/**
|
|
442
443
|
* Transforms a UI state into a title for the page.
|
|
443
444
|
*/
|
|
@@ -466,7 +467,7 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
467
|
*/
|
|
467
468
|
private readonly getLocation;
|
|
468
469
|
private writeTimer?;
|
|
469
|
-
private _onPopState
|
|
470
|
+
private _onPopState?;
|
|
470
471
|
/**
|
|
471
472
|
* Indicates if last action was back/forward in the browser.
|
|
472
473
|
*/
|
|
@@ -524,7 +525,7 @@ declare type BrowserHistoryArgs<TRouteState> = {
|
|
|
524
525
|
writeDelay: number;
|
|
525
526
|
createURL: CreateURL_2<TRouteState>;
|
|
526
527
|
parseURL: ParseURL<TRouteState>;
|
|
527
|
-
getLocation()
|
|
528
|
+
getLocation: () => Location;
|
|
528
529
|
start?: (onUpdate: () => void) => void;
|
|
529
530
|
dispose?: () => void;
|
|
530
531
|
push?: (url: string) => void;
|
|
@@ -901,7 +902,7 @@ declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
|
|
|
901
902
|
|
|
902
903
|
declare type CreateInsightsMiddleware = typeof createInsightsMiddleware;
|
|
903
904
|
|
|
904
|
-
declare function createInsightsMiddleware<TInsightsClient extends
|
|
905
|
+
declare function createInsightsMiddleware<TInsightsClient extends ProvidedInsightsClient>(props?: InsightsProps<TInsightsClient>): InternalMiddleware;
|
|
905
906
|
|
|
906
907
|
/**
|
|
907
908
|
* Exposes the metadata of mounted widgets in a custom
|
|
@@ -910,7 +911,9 @@ declare function createInsightsMiddleware<TInsightsClient extends null | Insight
|
|
|
910
911
|
* - widget name
|
|
911
912
|
* - connector name
|
|
912
913
|
*/
|
|
913
|
-
declare function createMetadataMiddleware(
|
|
914
|
+
declare function createMetadataMiddleware({ $$internal, }?: {
|
|
915
|
+
$$internal?: boolean;
|
|
916
|
+
}): InternalMiddleware;
|
|
914
917
|
|
|
915
918
|
declare const createRouterMiddleware: <TUiState extends UiState = UiState, TRouteState = TUiState>(props?: RouterProps<TUiState, TRouteState>) => InternalMiddleware<TUiState>;
|
|
916
919
|
|
|
@@ -976,7 +979,7 @@ declare type CurrentRefinementsConnectorParamsItem = {
|
|
|
976
979
|
/**
|
|
977
980
|
* Removes the given refinement and triggers a new search.
|
|
978
981
|
*/
|
|
979
|
-
refine(refinement: CurrentRefinementsConnectorParamsRefinement)
|
|
982
|
+
refine: (refinement: CurrentRefinementsConnectorParamsRefinement) => void;
|
|
980
983
|
};
|
|
981
984
|
|
|
982
985
|
declare type CurrentRefinementsConnectorParamsRefinement = {
|
|
@@ -1057,7 +1060,7 @@ declare type CurrentRefinementsRenderState = {
|
|
|
1057
1060
|
/**
|
|
1058
1061
|
* Removes the given refinement and triggers a new search.
|
|
1059
1062
|
*/
|
|
1060
|
-
refine(refinement: CurrentRefinementsConnectorParamsRefinement)
|
|
1063
|
+
refine: (refinement: CurrentRefinementsConnectorParamsRefinement) => void;
|
|
1061
1064
|
/**
|
|
1062
1065
|
* Generates a URL for the next state.
|
|
1063
1066
|
*/
|
|
@@ -1114,10 +1117,10 @@ declare type DynamicWidgetsConnectorParams = {
|
|
|
1114
1117
|
* Function to return a fallback widget when an attribute isn't found in
|
|
1115
1118
|
* `widgets`.
|
|
1116
1119
|
*/
|
|
1117
|
-
fallbackWidget
|
|
1120
|
+
fallbackWidget?: (args: {
|
|
1118
1121
|
/** The attribute name to create a widget for. */
|
|
1119
1122
|
attribute: string;
|
|
1120
|
-
})
|
|
1123
|
+
}) => Widget;
|
|
1121
1124
|
/**
|
|
1122
1125
|
* Function to transform the items to render.
|
|
1123
1126
|
* The function also exposes the full search response.
|
|
@@ -1171,12 +1174,12 @@ declare type DynamicWidgetsWidgetParams = {
|
|
|
1171
1174
|
* Function to return a fallback widget when an attribute isn't found in
|
|
1172
1175
|
* `widgets`.
|
|
1173
1176
|
*/
|
|
1174
|
-
fallbackWidget
|
|
1177
|
+
fallbackWidget?: (args: {
|
|
1175
1178
|
/** The attribute name to create a widget for. */
|
|
1176
1179
|
attribute: string;
|
|
1177
1180
|
/** CSS Selector or HTMLElement to insert the widget */
|
|
1178
1181
|
container: HTMLElement;
|
|
1179
|
-
})
|
|
1182
|
+
}) => Widget;
|
|
1180
1183
|
};
|
|
1181
1184
|
|
|
1182
1185
|
declare type Expand<T> = T extends infer O ? {
|
|
@@ -1261,7 +1264,7 @@ declare type GeoSearchMarker<TOptions> = {
|
|
|
1261
1264
|
* See the documentation for more information:
|
|
1262
1265
|
* https://developers.google.com/maps/documentation/javascript/reference/3/#MarkerOptions
|
|
1263
1266
|
*/
|
|
1264
|
-
createOptions
|
|
1267
|
+
createOptions?: (item: GeoHit) => TOptions;
|
|
1265
1268
|
/**
|
|
1266
1269
|
* Object that takes an event type (ex: `click`, `mouseover`) as key and a
|
|
1267
1270
|
* listener as value. The listener is provided with an object that contains:
|
|
@@ -1281,7 +1284,7 @@ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> =
|
|
|
1281
1284
|
/**
|
|
1282
1285
|
* Reset the current bounding box refinement.
|
|
1283
1286
|
*/
|
|
1284
|
-
clearMapRefinement()
|
|
1287
|
+
clearMapRefinement: () => void;
|
|
1285
1288
|
/**
|
|
1286
1289
|
* The current bounding box of the search.
|
|
1287
1290
|
*/
|
|
@@ -1289,15 +1292,15 @@ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> =
|
|
|
1289
1292
|
/**
|
|
1290
1293
|
* Return true if the map has move since the last refinement.
|
|
1291
1294
|
*/
|
|
1292
|
-
hasMapMoveSinceLastRefine()
|
|
1295
|
+
hasMapMoveSinceLastRefine: () => boolean;
|
|
1293
1296
|
/**
|
|
1294
1297
|
* Return true if the current refinement is set with the map bounds.
|
|
1295
1298
|
*/
|
|
1296
|
-
isRefinedWithMap()
|
|
1299
|
+
isRefinedWithMap: () => boolean;
|
|
1297
1300
|
/**
|
|
1298
1301
|
* Return true if the user is able to refine on map move.
|
|
1299
1302
|
*/
|
|
1300
|
-
isRefineOnMapMove()
|
|
1303
|
+
isRefineOnMapMove: () => boolean;
|
|
1301
1304
|
/**
|
|
1302
1305
|
* The matched hits from Algolia API.
|
|
1303
1306
|
*/
|
|
@@ -1309,7 +1312,7 @@ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> =
|
|
|
1309
1312
|
/**
|
|
1310
1313
|
* Sets a bounding box to filter the results from the given map bounds.
|
|
1311
1314
|
*/
|
|
1312
|
-
refine(bounds: Bounds)
|
|
1315
|
+
refine: (bounds: Bounds) => void;
|
|
1313
1316
|
/**
|
|
1314
1317
|
* Send event to insights middleware
|
|
1315
1318
|
*/
|
|
@@ -1319,11 +1322,11 @@ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> =
|
|
|
1319
1322
|
* called on each map move. The call to the function triggers a new rendering
|
|
1320
1323
|
* only when the value change.
|
|
1321
1324
|
*/
|
|
1322
|
-
setMapMoveSinceLastRefine()
|
|
1325
|
+
setMapMoveSinceLastRefine: () => void;
|
|
1323
1326
|
/**
|
|
1324
1327
|
* Toggle the fact that the user is able to refine on map move.
|
|
1325
1328
|
*/
|
|
1326
|
-
toggleRefineOnMapMove()
|
|
1329
|
+
toggleRefineOnMapMove: () => void;
|
|
1327
1330
|
};
|
|
1328
1331
|
|
|
1329
1332
|
declare type GeoSearchTemplates = Partial<{
|
|
@@ -2066,39 +2069,39 @@ declare type IndexUiState = Partial<ConnectorUiStates & WidgetUiStates>;
|
|
|
2066
2069
|
declare type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<IndexWidgetDescription & {
|
|
2067
2070
|
widgetParams: IndexWidgetParams;
|
|
2068
2071
|
}>, 'getWidgetUiState' | 'getWidgetState'> & {
|
|
2069
|
-
getIndexName()
|
|
2070
|
-
getIndexId()
|
|
2071
|
-
getHelper()
|
|
2072
|
-
getResults()
|
|
2073
|
-
getPreviousState()
|
|
2074
|
-
getScopedResults()
|
|
2075
|
-
getParent()
|
|
2076
|
-
getWidgets()
|
|
2077
|
-
createURL(state: SearchParameters)
|
|
2078
|
-
addWidgets(widgets: Array<Widget | IndexWidget>)
|
|
2079
|
-
removeWidgets(widgets: Array<Widget | IndexWidget>)
|
|
2080
|
-
init(options: IndexInitOptions)
|
|
2081
|
-
render(options: IndexRenderOptions)
|
|
2082
|
-
dispose()
|
|
2072
|
+
getIndexName: () => string;
|
|
2073
|
+
getIndexId: () => string;
|
|
2074
|
+
getHelper: () => AlgoliaSearchHelper | null;
|
|
2075
|
+
getResults: () => SearchResults | null;
|
|
2076
|
+
getPreviousState: () => SearchParameters | null;
|
|
2077
|
+
getScopedResults: () => ScopedResult[];
|
|
2078
|
+
getParent: () => IndexWidget | null;
|
|
2079
|
+
getWidgets: () => Array<Widget | IndexWidget>;
|
|
2080
|
+
createURL: (state: SearchParameters) => string;
|
|
2081
|
+
addWidgets: (widgets: Array<Widget | IndexWidget>) => IndexWidget;
|
|
2082
|
+
removeWidgets: (widgets: Array<Widget | IndexWidget>) => IndexWidget;
|
|
2083
|
+
init: (options: IndexInitOptions) => void;
|
|
2084
|
+
render: (options: IndexRenderOptions) => void;
|
|
2085
|
+
dispose: () => void;
|
|
2083
2086
|
/**
|
|
2084
2087
|
* @deprecated
|
|
2085
2088
|
*/
|
|
2086
|
-
getWidgetState(uiState: UiState)
|
|
2087
|
-
getWidgetUiState<TSpecificUiState extends UiState = TUiState>(uiState: TSpecificUiState)
|
|
2088
|
-
getWidgetSearchParameters(searchParameters: SearchParameters, searchParametersOptions: {
|
|
2089
|
+
getWidgetState: (uiState: UiState) => UiState;
|
|
2090
|
+
getWidgetUiState: <TSpecificUiState extends UiState = TUiState>(uiState: TSpecificUiState) => TSpecificUiState;
|
|
2091
|
+
getWidgetSearchParameters: (searchParameters: SearchParameters, searchParametersOptions: {
|
|
2089
2092
|
uiState: IndexUiState;
|
|
2090
|
-
})
|
|
2093
|
+
}) => SearchParameters;
|
|
2091
2094
|
/**
|
|
2092
2095
|
* Set this index' UI state back to the state defined by the widgets.
|
|
2093
2096
|
* Can only be called after `init`.
|
|
2094
2097
|
*/
|
|
2095
|
-
refreshUiState()
|
|
2098
|
+
refreshUiState: () => void;
|
|
2096
2099
|
/**
|
|
2097
2100
|
* Set this index' UI state and search. This is the equivalent of calling
|
|
2098
2101
|
* a spread `setUiState` on the InstantSearch instance.
|
|
2099
2102
|
* Can only be called after `init`.
|
|
2100
2103
|
*/
|
|
2101
|
-
setIndexUiState(indexUiState: TUiState[string] | ((previousIndexUiState: TUiState[string]) => TUiState[string]))
|
|
2104
|
+
setIndexUiState: (indexUiState: TUiState[string] | ((previousIndexUiState: TUiState[string]) => TUiState[string])) => void;
|
|
2102
2105
|
};
|
|
2103
2106
|
|
|
2104
2107
|
declare type IndexWidgetDescription = {
|
|
@@ -2313,20 +2316,39 @@ declare type InsightsClientPayload = {
|
|
|
2313
2316
|
positions?: number[];
|
|
2314
2317
|
};
|
|
2315
2318
|
|
|
2316
|
-
declare type
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
+
declare type InsightsClientWithGlobals = InsightsClient & {
|
|
2320
|
+
shouldAddScript?: boolean;
|
|
2321
|
+
version?: string;
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
declare type InsightsEvent<TMethod extends InsightsMethod = InsightsMethod> = InsightsEvent_2<TMethod>;
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* The event sent to the insights middleware.
|
|
2328
|
+
*/
|
|
2329
|
+
declare type InsightsEvent_2<TMethod extends InsightsMethod = InsightsMethod> = {
|
|
2330
|
+
insightsMethod?: TMethod;
|
|
2331
|
+
payload: InsightsMethodMap[TMethod][0];
|
|
2319
2332
|
widgetType: string;
|
|
2320
2333
|
eventType: string;
|
|
2334
|
+
eventModifier?: string;
|
|
2321
2335
|
hits?: Hit[];
|
|
2322
2336
|
attribute?: string;
|
|
2323
2337
|
};
|
|
2324
2338
|
|
|
2325
|
-
|
|
2326
|
-
|
|
2339
|
+
/**
|
|
2340
|
+
* Method allowed by the insights middleware.
|
|
2341
|
+
*/
|
|
2342
|
+
declare type InsightsMethod = 'clickedObjectIDsAfterSearch' | 'clickedObjectIDs' | 'clickedFilters' | 'convertedObjectIDsAfterSearch' | 'convertedObjectIDs' | 'convertedFilters' | 'viewedObjectIDs' | 'viewedFilters';
|
|
2343
|
+
|
|
2344
|
+
declare type InsightsMethodMap = InsightsMethodMap_2;
|
|
2345
|
+
|
|
2346
|
+
declare type InsightsProps<TInsightsClient extends ProvidedInsightsClient = ProvidedInsightsClient> = {
|
|
2347
|
+
insightsClient?: TInsightsClient;
|
|
2327
2348
|
insightsInitParams?: {
|
|
2328
2349
|
userHasOptedOut?: boolean;
|
|
2329
2350
|
useCookie?: boolean;
|
|
2351
|
+
anonymousUserToken?: boolean;
|
|
2330
2352
|
cookieDuration?: number;
|
|
2331
2353
|
region?: 'de' | 'us';
|
|
2332
2354
|
};
|
|
@@ -2357,8 +2379,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2357
2379
|
_searchFunction?: InstantSearchOptions['searchFunction'];
|
|
2358
2380
|
_mainHelperSearch?: AlgoliaSearchHelper['search'];
|
|
2359
2381
|
middleware: Array<{
|
|
2360
|
-
creator: Middleware
|
|
2361
|
-
instance: MiddlewareDefinition
|
|
2382
|
+
creator: Middleware<TUiState>;
|
|
2383
|
+
instance: MiddlewareDefinition<TUiState>;
|
|
2362
2384
|
}>;
|
|
2363
2385
|
sendEventToInsights: (event: InsightsEvent) => void;
|
|
2364
2386
|
/**
|
|
@@ -2378,11 +2400,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2378
2400
|
/**
|
|
2379
2401
|
* Hooks a middleware into the InstantSearch lifecycle.
|
|
2380
2402
|
*/
|
|
2381
|
-
use(...middleware: Middleware
|
|
2403
|
+
use(...middleware: Array<Middleware<TUiState>>): this;
|
|
2382
2404
|
/**
|
|
2383
2405
|
* Removes a middleware from the InstantSearch lifecycle.
|
|
2384
2406
|
*/
|
|
2385
|
-
unuse(...middlewareToUnuse: Middleware
|
|
2407
|
+
unuse(...middlewareToUnuse: Array<Middleware<TUiState>>): this;
|
|
2386
2408
|
EXPERIMENTAL_use(...middleware: Middleware[]): this;
|
|
2387
2409
|
/**
|
|
2388
2410
|
* Adds a widget to the search instance.
|
|
@@ -2428,12 +2450,12 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2428
2450
|
*/
|
|
2429
2451
|
dispose(): void;
|
|
2430
2452
|
scheduleSearch: (() => void) & {
|
|
2431
|
-
wait()
|
|
2432
|
-
cancel()
|
|
2453
|
+
wait: () => Promise<void>;
|
|
2454
|
+
cancel: () => void;
|
|
2433
2455
|
};
|
|
2434
2456
|
scheduleRender: ((shouldResetStatus?: boolean) => void) & {
|
|
2435
|
-
wait()
|
|
2436
|
-
cancel()
|
|
2457
|
+
wait: () => Promise<void>;
|
|
2458
|
+
cancel: () => void;
|
|
2437
2459
|
};
|
|
2438
2460
|
scheduleStalledRender(): void;
|
|
2439
2461
|
/**
|
|
@@ -2444,8 +2466,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2444
2466
|
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
2445
2467
|
getUiState(): TUiState;
|
|
2446
2468
|
onInternalStateChange: (() => void) & {
|
|
2447
|
-
wait()
|
|
2448
|
-
cancel()
|
|
2469
|
+
wait: () => Promise<void>;
|
|
2470
|
+
cancel: () => void;
|
|
2449
2471
|
};
|
|
2450
2472
|
createURL(nextState?: TUiState): string;
|
|
2451
2473
|
refresh(): void;
|
|
@@ -2498,9 +2520,9 @@ declare type InstantSearchModule = {
|
|
|
2498
2520
|
*/
|
|
2499
2521
|
declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteState = TUiState> = {
|
|
2500
2522
|
/**
|
|
2501
|
-
* The name of the main index
|
|
2523
|
+
* The name of the main index. If no indexName is provided, you have to manually add an index widget.
|
|
2502
2524
|
*/
|
|
2503
|
-
indexName
|
|
2525
|
+
indexName?: string;
|
|
2504
2526
|
/**
|
|
2505
2527
|
* The search client to plug to InstantSearch.js
|
|
2506
2528
|
*
|
|
@@ -2549,7 +2571,7 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2549
2571
|
*/
|
|
2550
2572
|
onStateChange?: (params: {
|
|
2551
2573
|
uiState: TUiState;
|
|
2552
|
-
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState))
|
|
2574
|
+
setUiState: (uiState: TUiState | ((previousUiState: TUiState) => TUiState)) => void;
|
|
2553
2575
|
}) => void;
|
|
2554
2576
|
/**
|
|
2555
2577
|
* Injects a `uiState` to the `instantsearch` instance. You can use this option
|
|
@@ -2567,6 +2589,16 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2567
2589
|
* client side persistence. Passing `true` will use the default URL options.
|
|
2568
2590
|
*/
|
|
2569
2591
|
routing?: RouterProps<TUiState, TRouteState> | boolean;
|
|
2592
|
+
/**
|
|
2593
|
+
* Enables the Insights middleware and loads the Insights library
|
|
2594
|
+
* if not already loaded.
|
|
2595
|
+
*
|
|
2596
|
+
* The Insights middleware sends view and click events automatically, and lets
|
|
2597
|
+
* you set up your own events.
|
|
2598
|
+
*
|
|
2599
|
+
* @default false
|
|
2600
|
+
*/
|
|
2601
|
+
insights?: InsightsProps | boolean;
|
|
2570
2602
|
/**
|
|
2571
2603
|
* the instance of search-insights to use for sending insights events inside
|
|
2572
2604
|
* widgets like `hits`.
|
|
@@ -2702,7 +2734,7 @@ declare type MenuRenderState = {
|
|
|
2702
2734
|
/**
|
|
2703
2735
|
* Filter the search to item value.
|
|
2704
2736
|
*/
|
|
2705
|
-
refine(value: string)
|
|
2737
|
+
refine: (value: string) => void;
|
|
2706
2738
|
/**
|
|
2707
2739
|
* True if refinement can be applied.
|
|
2708
2740
|
*/
|
|
@@ -2714,7 +2746,7 @@ declare type MenuRenderState = {
|
|
|
2714
2746
|
/**
|
|
2715
2747
|
* Toggles the number of values displayed between `limit` and `showMore.limit`.
|
|
2716
2748
|
*/
|
|
2717
|
-
toggleShowMore()
|
|
2749
|
+
toggleShowMore: () => void;
|
|
2718
2750
|
/**
|
|
2719
2751
|
* `true` if the toggleShowMore button can be activated (enough items to display more or
|
|
2720
2752
|
* already displaying more than `limit` items)
|
|
@@ -2836,15 +2868,31 @@ declare type MenuWidgetParams = {
|
|
|
2836
2868
|
cssClasses?: MenuCSSClasses;
|
|
2837
2869
|
};
|
|
2838
2870
|
|
|
2839
|
-
declare type Middleware = (options: MiddlewareOptions) => AtLeastOne<MiddlewareDefinition
|
|
2871
|
+
declare type Middleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => AtLeastOne<MiddlewareDefinition<TUiState>>;
|
|
2840
2872
|
|
|
2841
2873
|
declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
|
|
2842
|
-
|
|
2874
|
+
/**
|
|
2875
|
+
* string to identify the middleware
|
|
2876
|
+
*/
|
|
2877
|
+
$$type: string;
|
|
2878
|
+
/**
|
|
2879
|
+
* Change handler called on every UiState change
|
|
2880
|
+
*/
|
|
2881
|
+
onStateChange: (options: {
|
|
2843
2882
|
uiState: TUiState;
|
|
2844
|
-
})
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2883
|
+
}) => void;
|
|
2884
|
+
/**
|
|
2885
|
+
* Called when the middleware is added to InstantSearch
|
|
2886
|
+
*/
|
|
2887
|
+
subscribe: () => void;
|
|
2888
|
+
/**
|
|
2889
|
+
* Called when InstantSearch is started
|
|
2890
|
+
*/
|
|
2891
|
+
started: () => void;
|
|
2892
|
+
/**
|
|
2893
|
+
* Called when the middleware is removed from InstantSearch
|
|
2894
|
+
*/
|
|
2895
|
+
unsubscribe: () => void;
|
|
2848
2896
|
};
|
|
2849
2897
|
|
|
2850
2898
|
declare type MiddlewareOptions = {
|
|
@@ -2856,6 +2904,7 @@ declare namespace middlewares {
|
|
|
2856
2904
|
createInsightsMiddleware,
|
|
2857
2905
|
InsightsEvent,
|
|
2858
2906
|
InsightsProps,
|
|
2907
|
+
InsightsClientWithGlobals,
|
|
2859
2908
|
CreateInsightsMiddleware,
|
|
2860
2909
|
RouterProps,
|
|
2861
2910
|
createRouterMiddleware,
|
|
@@ -3126,7 +3175,7 @@ declare type PaginationRenderState = {
|
|
|
3126
3175
|
/** Creates URLs for the next state, the number is the page to generate the URL for. */
|
|
3127
3176
|
createURL: CreateURL<number>;
|
|
3128
3177
|
/** Sets the current page and triggers a search. */
|
|
3129
|
-
refine(page: number)
|
|
3178
|
+
refine: (page: number) => void;
|
|
3130
3179
|
/** true if this search returned more than one page */
|
|
3131
3180
|
canRefine: boolean;
|
|
3132
3181
|
/** The number of the page currently displayed. */
|
|
@@ -3304,12 +3353,12 @@ declare type PanelWidgetParams<TWidgetFactory extends AnyWidgetFactory> = {
|
|
|
3304
3353
|
* A function that is called on each render to determine if the
|
|
3305
3354
|
* panel should be hidden based on the render options.
|
|
3306
3355
|
*/
|
|
3307
|
-
hidden
|
|
3356
|
+
hidden?: (options: PanelRenderOptions<TWidgetFactory>) => boolean;
|
|
3308
3357
|
/**
|
|
3309
3358
|
* A function that is called on each render to determine if the
|
|
3310
3359
|
* panel should be collapsed based on the render options.
|
|
3311
3360
|
*/
|
|
3312
|
-
collapsed
|
|
3361
|
+
collapsed?: (options: PanelRenderOptions<TWidgetFactory>) => boolean;
|
|
3313
3362
|
/**
|
|
3314
3363
|
* The templates to use for the widget.
|
|
3315
3364
|
*/
|
|
@@ -3431,6 +3480,8 @@ declare type PoweredByWidgetParams = {
|
|
|
3431
3480
|
cssClasses?: PoweredByCSSClasses;
|
|
3432
3481
|
};
|
|
3433
3482
|
|
|
3483
|
+
declare type ProvidedInsightsClient = InsightsClient | null | undefined;
|
|
3484
|
+
|
|
3434
3485
|
declare const queryRuleContext: QueryRuleContextWidget;
|
|
3435
3486
|
|
|
3436
3487
|
declare type QueryRuleContextWidget = WidgetFactory<QueryRulesWidgetDescription & {
|
|
@@ -3623,7 +3674,7 @@ declare type RangeRenderState = {
|
|
|
3623
3674
|
* previously set bound or to set an infinite bound.
|
|
3624
3675
|
* @param rangeValue tuple of [min, max] bounds
|
|
3625
3676
|
*/
|
|
3626
|
-
refine(rangeValue: RangeBoundaries)
|
|
3677
|
+
refine: (rangeValue: RangeBoundaries) => void;
|
|
3627
3678
|
/**
|
|
3628
3679
|
* Indicates whether this widget can be refined
|
|
3629
3680
|
*/
|
|
@@ -3645,8 +3696,8 @@ declare type RangeRenderState = {
|
|
|
3645
3696
|
* Both functions take a `number` as input and should output a `string`.
|
|
3646
3697
|
*/
|
|
3647
3698
|
format: {
|
|
3648
|
-
from(fromValue: number)
|
|
3649
|
-
to(toValue: number)
|
|
3699
|
+
from: (fromValue: number) => string;
|
|
3700
|
+
to: (toValue: number) => string;
|
|
3650
3701
|
};
|
|
3651
3702
|
};
|
|
3652
3703
|
|
|
@@ -3681,7 +3732,7 @@ declare type RangeSliderTooltipOptions = {
|
|
|
3681
3732
|
* @example
|
|
3682
3733
|
* { format(rawValue) {return '$' + Math.round(rawValue).toLocaleString() } }
|
|
3683
3734
|
*/
|
|
3684
|
-
format(value: number)
|
|
3735
|
+
format: (value: number) => string;
|
|
3685
3736
|
};
|
|
3686
3737
|
|
|
3687
3738
|
declare type RangeSliderWidget = WidgetFactory<Omit<RangeWidgetDescription, '$$type'> & {
|
|
@@ -3941,7 +3992,7 @@ declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
|
3941
3992
|
*/
|
|
3942
3993
|
declare type Refine = (searchParameters: PlainSearchParameters) => void;
|
|
3943
3994
|
|
|
3944
|
-
declare type Refine_2 = (relevancyStrictness: number) => void;
|
|
3995
|
+
declare type Refine_2 = (relevancyStrictness: number | undefined) => void;
|
|
3945
3996
|
|
|
3946
3997
|
/**
|
|
3947
3998
|
* The refinement list widget is one of the most common widget that you can find
|
|
@@ -4155,7 +4206,7 @@ declare type RefinementListRenderState = {
|
|
|
4155
4206
|
/**
|
|
4156
4207
|
* Action to apply selected refinements.
|
|
4157
4208
|
*/
|
|
4158
|
-
refine(value: string)
|
|
4209
|
+
refine: (value: string) => void;
|
|
4159
4210
|
/**
|
|
4160
4211
|
* Send event to insights middleware
|
|
4161
4212
|
*/
|
|
@@ -4163,7 +4214,7 @@ declare type RefinementListRenderState = {
|
|
|
4163
4214
|
/**
|
|
4164
4215
|
* Searches for values inside the list.
|
|
4165
4216
|
*/
|
|
4166
|
-
searchForItems(query: string)
|
|
4217
|
+
searchForItems: (query: string) => void;
|
|
4167
4218
|
/**
|
|
4168
4219
|
* `true` if the values are from an index search.
|
|
4169
4220
|
*/
|
|
@@ -4184,7 +4235,7 @@ declare type RefinementListRenderState = {
|
|
|
4184
4235
|
/**
|
|
4185
4236
|
* Toggles the number of values displayed between `limit` and `showMoreLimit`.
|
|
4186
4237
|
*/
|
|
4187
|
-
toggleShowMore()
|
|
4238
|
+
toggleShowMore: () => void;
|
|
4188
4239
|
};
|
|
4189
4240
|
|
|
4190
4241
|
declare type RefinementListSearchableCSSClasses = Partial<{
|
|
@@ -4538,30 +4589,34 @@ declare type Router<TRouteState = UiState> = {
|
|
|
4538
4589
|
* In the case of the history / URL in a browser, the callback will be called
|
|
4539
4590
|
* by `onPopState`.
|
|
4540
4591
|
*/
|
|
4541
|
-
onUpdate(callback: (route: TRouteState) => void)
|
|
4592
|
+
onUpdate: (callback: (route: TRouteState) => void) => void;
|
|
4542
4593
|
/**
|
|
4543
4594
|
* Reads the storage and gets a route object. It does not take parameters,
|
|
4544
4595
|
* and should return an object
|
|
4545
4596
|
*/
|
|
4546
|
-
read()
|
|
4597
|
+
read: () => TRouteState;
|
|
4547
4598
|
/**
|
|
4548
4599
|
* Pushes a route object into a storage. Takes the UI state mapped by the state
|
|
4549
4600
|
* mapping configured in the mapping
|
|
4550
4601
|
*/
|
|
4551
|
-
write(route: TRouteState)
|
|
4602
|
+
write: (route: TRouteState) => void;
|
|
4552
4603
|
/**
|
|
4553
4604
|
* Transforms a route object into a URL. It receives an object and should
|
|
4554
4605
|
* return a string. It may return an empty string.
|
|
4555
4606
|
*/
|
|
4556
|
-
createURL(state: TRouteState)
|
|
4607
|
+
createURL: (state: TRouteState) => string;
|
|
4557
4608
|
/**
|
|
4558
4609
|
* Called when InstantSearch is disposed. Used to remove subscriptions.
|
|
4559
4610
|
*/
|
|
4560
|
-
dispose()
|
|
4611
|
+
dispose: () => void;
|
|
4561
4612
|
/**
|
|
4562
4613
|
* Called when InstantSearch is started.
|
|
4563
4614
|
*/
|
|
4564
4615
|
start?: () => void;
|
|
4616
|
+
/**
|
|
4617
|
+
* Identifier for this router. Used to differentiate between routers.
|
|
4618
|
+
*/
|
|
4619
|
+
$$type?: string;
|
|
4565
4620
|
};
|
|
4566
4621
|
|
|
4567
4622
|
declare type RouterProps<TUiState extends UiState = UiState, TRouteState = TUiState> = {
|
|
@@ -4781,7 +4836,7 @@ declare type SharedRenderOptions = {
|
|
|
4781
4836
|
};
|
|
4782
4837
|
status: InstantSearch['status'];
|
|
4783
4838
|
error: InstantSearch['error'];
|
|
4784
|
-
createURL(state: SearchParameters)
|
|
4839
|
+
createURL: (state: SearchParameters) => string;
|
|
4785
4840
|
};
|
|
4786
4841
|
|
|
4787
4842
|
declare function simpleStateMapping<TUiState extends UiState = UiState>(): StateMapping<TUiState, TUiState>;
|
|
@@ -4986,13 +5041,17 @@ declare type StateMapping<TUiState = UiState, TRouteState = TUiState> = {
|
|
|
4986
5041
|
* It should return an object of any form as long as this form can be read by
|
|
4987
5042
|
* the `routeToState` function.
|
|
4988
5043
|
*/
|
|
4989
|
-
stateToRoute(uiState: TUiState)
|
|
5044
|
+
stateToRoute: (uiState: TUiState) => TRouteState;
|
|
4990
5045
|
/**
|
|
4991
5046
|
* Transforms route object into a UI state representation.
|
|
4992
5047
|
* It receives an object that contains the UI state stored by the router.
|
|
4993
5048
|
* The format is the output of `stateToRoute`.
|
|
4994
5049
|
*/
|
|
4995
|
-
routeToState(routeState: TRouteState)
|
|
5050
|
+
routeToState: (routeState: TRouteState) => TUiState;
|
|
5051
|
+
/**
|
|
5052
|
+
* Identifier for this stateMapping. Used to differentiate between stateMappings.
|
|
5053
|
+
*/
|
|
5054
|
+
$$type?: string;
|
|
4996
5055
|
};
|
|
4997
5056
|
|
|
4998
5057
|
declare namespace stateMappings {
|