instantsearch.js 4.60.0 → 4.62.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.
Files changed (38) hide show
  1. package/cjs/components/SearchBox/SearchBox.js +2 -2
  2. package/cjs/connectors/breadcrumb/connectBreadcrumb.js +14 -5
  3. package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
  4. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +14 -5
  5. package/cjs/connectors/menu/connectMenu.js +14 -5
  6. package/cjs/connectors/numeric-menu/connectNumericMenu.js +14 -5
  7. package/cjs/connectors/rating-menu/connectRatingMenu.js +15 -6
  8. package/cjs/connectors/refinement-list/connectRefinementList.js +14 -5
  9. package/cjs/lib/InstantSearch.js +5 -2
  10. package/cjs/lib/utils/hydrateSearchClient.js +39 -29
  11. package/cjs/lib/version.js +1 -1
  12. package/cjs/widgets/search-box/defaultTemplates.js +9 -3
  13. package/dist/instantsearch.development.d.ts +23 -3
  14. package/dist/instantsearch.development.js +167 -81
  15. package/dist/instantsearch.development.js.map +1 -1
  16. package/dist/instantsearch.production.d.ts +23 -3
  17. package/dist/instantsearch.production.min.d.ts +23 -3
  18. package/dist/instantsearch.production.min.js +2 -2
  19. package/dist/instantsearch.production.min.js.map +1 -1
  20. package/es/components/SearchBox/SearchBox.js +2 -2
  21. package/es/connectors/breadcrumb/connectBreadcrumb.js +14 -5
  22. package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +12 -2
  23. package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
  24. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +14 -5
  25. package/es/connectors/menu/connectMenu.js +14 -5
  26. package/es/connectors/numeric-menu/connectNumericMenu.js +14 -5
  27. package/es/connectors/rating-menu/connectRatingMenu.d.ts +1 -1
  28. package/es/connectors/rating-menu/connectRatingMenu.js +15 -6
  29. package/es/connectors/refinement-list/connectRefinementList.js +14 -5
  30. package/es/lib/InstantSearch.d.ts +10 -0
  31. package/es/lib/InstantSearch.js +5 -2
  32. package/es/lib/utils/hydrateSearchClient.d.ts +5 -2
  33. package/es/lib/utils/hydrateSearchClient.js +39 -29
  34. package/es/lib/utils/render-args.d.ts +4 -4
  35. package/es/lib/version.d.ts +1 -1
  36. package/es/lib/version.js +1 -1
  37. package/es/widgets/search-box/defaultTemplates.js +10 -3
  38. package/package.json +6 -6
@@ -177,7 +177,7 @@ var SearchBox = /*#__PURE__*/function (_Component) {
177
177
  rootProps: {
178
178
  className: cssClasses.submit,
179
179
  type: 'submit',
180
- title: 'Submit the search query.',
180
+ title: 'Submit the search query',
181
181
  hidden: !showSubmit
182
182
  },
183
183
  templates: templates,
@@ -190,7 +190,7 @@ var SearchBox = /*#__PURE__*/function (_Component) {
190
190
  rootProps: {
191
191
  className: cssClasses.reset,
192
192
  type: 'reset',
193
- title: 'Clear the search query.',
193
+ title: 'Clear the search query',
194
194
  hidden: !(showReset && this.state.query.trim() && !isSearchStalled)
195
195
  },
196
196
  templates: templates,
@@ -115,12 +115,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
115
115
  getWidgetUiState: function getWidgetUiState(uiState, _ref3) {
116
116
  var searchParameters = _ref3.searchParameters;
117
117
  var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
118
- if (!path.length) {
119
- return uiState;
120
- }
121
- return _objectSpread(_objectSpread({}, uiState), {}, {
118
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
122
119
  hierarchicalMenu: _objectSpread(_objectSpread({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
123
- });
120
+ }), hierarchicalFacetName);
124
121
  },
125
122
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref4) {
126
123
  var uiState = _ref4.uiState;
@@ -171,4 +168,16 @@ function shiftItemsValues(array) {
171
168
  };
172
169
  });
173
170
  }
171
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
172
+ if (!indexUiState.hierarchicalMenu) {
173
+ return indexUiState;
174
+ }
175
+ if (!indexUiState.hierarchicalMenu[attribute] || !indexUiState.hierarchicalMenu[attribute].length) {
176
+ delete indexUiState.hierarchicalMenu[attribute];
177
+ }
178
+ if (Object.keys(indexUiState.hierarchicalMenu).length === 0) {
179
+ delete indexUiState.hierarchicalMenu;
180
+ }
181
+ return indexUiState;
182
+ }
174
183
  export default connectBreadcrumb;
@@ -24,11 +24,21 @@ export type DynamicWidgetsConnectorParams = {
24
24
  }>;
25
25
  /**
26
26
  * To prevent unneeded extra network requests when widgets mount or unmount,
27
- * we request all facet values.
27
+ * we request all facet values by default. If you want to only request the
28
+ * facet values that are needed, you can set this option to the list of
29
+ * attributes you want to display.
30
+ *
31
+ * If `facets` is set to `['*']`, we request all facet values.
32
+ *
33
+ * Any facets that are requested due to the `facetOrdering` result are always
34
+ * requested by the widget that mounted itself.
35
+ *
36
+ * Setting `facets` to a value other than `['*']` will only prevent extra
37
+ * requests if all potential facets are listed.
28
38
  *
29
39
  * @default ['*']
30
40
  */
31
- facets?: ['*'] | never[];
41
+ facets?: ['*'] | string[];
32
42
  /**
33
43
  * If you have more than 20 facet values pinned, you need to increase the
34
44
  * maxValuesPerFacet to at least that value.
@@ -29,8 +29,8 @@ var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
29
29
  }))) {
30
30
  throw new Error(withUsage('The `widgets` option expects an array of widgets.'));
31
31
  }
32
- if (!(Array.isArray(facets) && facets.length <= 1 && (facets[0] === '*' || facets[0] === undefined))) {
33
- throw new Error(withUsage("The `facets` option only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(facets))));
32
+ if (!Array.isArray(facets)) {
33
+ throw new Error(withUsage("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
34
34
  }
35
35
  var localWidgets = new Map();
36
36
  return {
@@ -108,7 +108,6 @@ var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
108
108
  unmountFn();
109
109
  },
110
110
  getWidgetSearchParameters: function getWidgetSearchParameters(state) {
111
- // broadening the scope of facets to avoid conflict between never and *
112
111
  return facets.reduce(function (acc, curr) {
113
112
  return acc.addFacet(curr);
114
113
  }, state.setQueryParameters({
@@ -199,12 +199,9 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
199
199
  getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
200
200
  var searchParameters = _ref5.searchParameters;
201
201
  var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
202
- if (!path.length) {
203
- return uiState;
204
- }
205
- return _objectSpread(_objectSpread({}, uiState), {}, {
202
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
206
203
  hierarchicalMenu: _objectSpread(_objectSpread({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
207
- });
204
+ }), hierarchicalFacetName);
208
205
  },
209
206
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
210
207
  var uiState = _ref6.uiState;
@@ -237,4 +234,16 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
237
234
  };
238
235
  };
239
236
  };
237
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
238
+ if (!indexUiState.hierarchicalMenu) {
239
+ return indexUiState;
240
+ }
241
+ if (!indexUiState.hierarchicalMenu[attribute] || indexUiState.hierarchicalMenu[attribute].length === 0) {
242
+ delete indexUiState.hierarchicalMenu[attribute];
243
+ }
244
+ if (Object.keys(indexUiState.hierarchicalMenu).length === 0) {
245
+ delete indexUiState.hierarchicalMenu;
246
+ }
247
+ return indexUiState;
248
+ }
240
249
  export default connectHierarchicalMenu;
@@ -171,12 +171,9 @@ var connectMenu = function connectMenu(renderFn) {
171
171
  var _searchParameters$get = searchParameters.getHierarchicalFacetBreadcrumb(attribute),
172
172
  _searchParameters$get2 = _slicedToArray(_searchParameters$get, 1),
173
173
  value = _searchParameters$get2[0];
174
- if (!value) {
175
- return uiState;
176
- }
177
- return _objectSpread(_objectSpread({}, uiState), {}, {
174
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
178
175
  menu: _objectSpread(_objectSpread({}, uiState.menu), {}, _defineProperty({}, attribute, value))
179
- });
176
+ }), attribute);
180
177
  },
181
178
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
182
179
  var uiState = _ref5.uiState;
@@ -202,4 +199,16 @@ var connectMenu = function connectMenu(renderFn) {
202
199
  };
203
200
  };
204
201
  };
202
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
203
+ if (!indexUiState.menu) {
204
+ return indexUiState;
205
+ }
206
+ if (indexUiState.menu[attribute] === undefined) {
207
+ delete indexUiState.menu[attribute];
208
+ }
209
+ if (Object.keys(indexUiState.menu).length === 0) {
210
+ delete indexUiState.menu;
211
+ }
212
+ return indexUiState;
213
+ }
205
214
  export default connectMenu;
@@ -95,12 +95,9 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
95
95
  }
96
96
  var min = values['>='] && values['>='][0] || '';
97
97
  var max = values['<='] && values['<='][0] || '';
98
- if (min === '' && max === '') {
99
- return uiState;
100
- }
101
- return _objectSpread(_objectSpread({}, uiState), {}, {
98
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
102
99
  numericMenu: _objectSpread(_objectSpread({}, uiState.numericMenu), {}, _defineProperty({}, attribute, "".concat(min, ":").concat(max)))
103
- });
100
+ }), attribute);
104
101
  },
105
102
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
106
103
  var uiState = _ref6.uiState;
@@ -262,4 +259,16 @@ function getRefinedState(state, attribute, facetValue) {
262
259
  function hasNumericRefinement(currentRefinements, operator, value) {
263
260
  return currentRefinements[operator] !== undefined && currentRefinements[operator].includes(value);
264
261
  }
262
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
263
+ if (!indexUiState.numericMenu) {
264
+ return indexUiState;
265
+ }
266
+ if (indexUiState.numericMenu[attribute] === ':') {
267
+ delete indexUiState.numericMenu[attribute];
268
+ }
269
+ if (Object.keys(indexUiState.numericMenu).length === 0) {
270
+ delete indexUiState.numericMenu;
271
+ }
272
+ return indexUiState;
273
+ }
265
274
  export default connectNumericMenu;
@@ -75,7 +75,7 @@ export type RatingMenuWidgetDescription = {
75
75
  };
76
76
  indexUiState: {
77
77
  ratingMenu: {
78
- [attribute: string]: number;
78
+ [attribute: string]: number | undefined;
79
79
  };
80
80
  };
81
81
  };
@@ -256,12 +256,9 @@ var connectRatingMenu = function connectRatingMenu(renderFn) {
256
256
  getWidgetUiState: function getWidgetUiState(uiState, _ref7) {
257
257
  var searchParameters = _ref7.searchParameters;
258
258
  var value = _getRefinedStar(searchParameters);
259
- if (typeof value !== 'number') {
260
- return uiState;
261
- }
262
- return _objectSpread(_objectSpread({}, uiState), {}, {
263
- ratingMenu: _objectSpread(_objectSpread({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, value))
264
- });
259
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
260
+ ratingMenu: _objectSpread(_objectSpread({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, typeof value === 'number' ? value : undefined))
261
+ }), attribute);
265
262
  },
266
263
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref8) {
267
264
  var uiState = _ref8.uiState;
@@ -278,4 +275,16 @@ var connectRatingMenu = function connectRatingMenu(renderFn) {
278
275
  };
279
276
  };
280
277
  };
278
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
279
+ if (!indexUiState.ratingMenu) {
280
+ return indexUiState;
281
+ }
282
+ if (typeof indexUiState.ratingMenu[attribute] !== 'number') {
283
+ delete indexUiState.ratingMenu[attribute];
284
+ }
285
+ if (Object.keys(indexUiState.ratingMenu).length === 0) {
286
+ delete indexUiState.ratingMenu;
287
+ }
288
+ return indexUiState;
289
+ }
281
290
  export default connectRatingMenu;
@@ -243,12 +243,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
243
243
  getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
244
244
  var searchParameters = _ref5.searchParameters;
245
245
  var values = operator === 'or' ? searchParameters.getDisjunctiveRefinements(attribute) : searchParameters.getConjunctiveRefinements(attribute);
246
- if (!values.length) {
247
- return uiState;
248
- }
249
- return _objectSpread(_objectSpread({}, uiState), {}, {
246
+ return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
250
247
  refinementList: _objectSpread(_objectSpread({}, uiState.refinementList), {}, _defineProperty({}, attribute, values))
251
- });
248
+ }), attribute);
252
249
  },
253
250
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
254
251
  var uiState = _ref6.uiState;
@@ -278,4 +275,16 @@ var connectRefinementList = function connectRefinementList(renderFn) {
278
275
  };
279
276
  };
280
277
  };
278
+ function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
279
+ if (!indexUiState.refinementList) {
280
+ return indexUiState;
281
+ }
282
+ if (!indexUiState.refinementList[attribute] || indexUiState.refinementList[attribute].length === 0) {
283
+ delete indexUiState.refinementList[attribute];
284
+ }
285
+ if (Object.keys(indexUiState.refinementList).length === 0) {
286
+ delete indexUiState.refinementList;
287
+ }
288
+ return indexUiState;
289
+ }
281
290
  export default connectRefinementList;
@@ -107,6 +107,16 @@ export type InstantSearchOptions<TUiState extends UiState = UiState, TRouteState
107
107
  * @default false
108
108
  */
109
109
  preserveSharedStateOnUnmount?: boolean;
110
+ /**
111
+ * Changes the way root levels of hierarchical facets have their count displayed.
112
+ *
113
+ * If `false` (by default), the count of the refined root level is updated to match the count of the actively refined parent level.
114
+ *
115
+ * If `true`, the count of the root level stays the same as the count of all children levels.
116
+ *
117
+ * @default false
118
+ */
119
+ persistHierarchicalRootCount?: boolean;
110
120
  };
111
121
  };
112
122
  export type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
@@ -37,7 +37,8 @@ function defaultCreateURL() {
37
37
  * Global options for an InstantSearch instance.
38
38
  */
39
39
  export var INSTANTSEARCH_FUTURE_DEFAULTS = {
40
- preserveSharedStateOnUnmount: false
40
+ preserveSharedStateOnUnmount: false,
41
+ persistHierarchicalRootCount: false
41
42
  };
42
43
 
43
44
  /**
@@ -373,7 +374,9 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
373
374
  // DerivedHelper scoped into the `index` widgets.
374
375
  // In Vue InstantSearch' hydrate, a main helper gets set before start, so
375
376
  // we need to respect this helper as a way to keep all listeners correct.
376
- var mainHelper = this.mainHelper || algoliasearchHelper(this.client, this.indexName);
377
+ var mainHelper = this.mainHelper || algoliasearchHelper(this.client, this.indexName, undefined, {
378
+ persistHierarchicalRootCount: this.future.persistHierarchicalRootCount
379
+ });
377
380
  mainHelper.search = function () {
378
381
  _this3.status = 'loading';
379
382
  _this3.scheduleRender(false);
@@ -1,2 +1,5 @@
1
- import type { InitialResults, SearchClient } from '../../types';
2
- export declare function hydrateSearchClient(client: SearchClient, results?: InitialResults): void;
1
+ import type { SearchClient, InitialResults } from '../../types';
2
+ export declare function hydrateSearchClient(client: SearchClient & {
3
+ _cacheHydrated?: boolean;
4
+ _useCache?: boolean;
5
+ }, results?: InitialResults): void;
@@ -1,11 +1,15 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
11
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
12
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- // @ts-nocheck (types to be fixed during actual implementation)
8
-
9
13
  export function hydrateSearchClient(client, results) {
10
14
  if (!results) {
11
15
  return;
@@ -15,9 +19,22 @@ export function hydrateSearchClient(client, results) {
15
19
  // - Algoliasearch API Client < v4 with cache disabled
16
20
  // - Third party clients (detected by the `addAlgoliaAgent` function missing)
17
21
 
18
- if ((!client.transporter || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
22
+ if ((!('transporter' in client) || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
19
23
  return;
20
24
  }
25
+ var cachedRequest = Object.keys(results).map(function (key) {
26
+ return results[key].results.map(function (result) {
27
+ return {
28
+ indexName: result.index,
29
+ // We normalize the params received from the server as they can
30
+ // be serialized differently depending on the engine.
31
+ params: serializeQueryParameters(deserializeQueryParameters(result.params))
32
+ };
33
+ });
34
+ });
35
+ var cachedResults = Object.keys(results).reduce(function (acc, key) {
36
+ return acc.concat(results[key].results);
37
+ }, []);
21
38
 
22
39
  // Algoliasearch API Client >= v4
23
40
  // To hydrate the client we need to populate the cache with the data from
@@ -26,9 +43,10 @@ export function hydrateSearchClient(client, results) {
26
43
  // for us to compute the key the same way as `algoliasearch-client` we need
27
44
  // to populate it on a custom key and override the `search` method to
28
45
  // search on it first.
29
- if (client.transporter && !client._cacheHydrated) {
46
+ if ('transporter' in client && !client._cacheHydrated) {
30
47
  client._cacheHydrated = true;
31
48
  var baseMethod = client.search;
49
+ // @ts-ignore wanting type checks for v3 on this would make this too complex
32
50
  client.search = function (requests) {
33
51
  for (var _len = arguments.length, methodArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34
52
  methodArgs[_key - 1] = arguments[_key];
@@ -45,22 +63,11 @@ export function hydrateSearchClient(client, results) {
45
63
  return baseMethod.apply(void 0, [requests].concat(methodArgs));
46
64
  });
47
65
  };
48
-
49
- // Populate the cache with the data from the server
50
66
  client.transporter.responsesCache.set({
51
67
  method: 'search',
52
- args: [Object.keys(results).reduce(function (acc, key) {
53
- return acc.concat(results[key].results.map(function (request) {
54
- return {
55
- indexName: request.index,
56
- params: request.params
57
- };
58
- }));
59
- }, [])]
68
+ args: cachedRequest
60
69
  }, {
61
- results: Object.keys(results).reduce(function (acc, key) {
62
- return acc.concat(results[key].results);
63
- }, [])
70
+ results: cachedResults
64
71
  });
65
72
  }
66
73
 
@@ -70,24 +77,27 @@ export function hydrateSearchClient(client, results) {
70
77
  // a single-index result. You can find more information about the
71
78
  // computation of the key inside the client (see link below).
72
79
  // https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
73
- if (!client.transporter) {
80
+ if (!('transporter' in client)) {
74
81
  var cacheKey = "/1/indexes/*/queries_body_".concat(JSON.stringify({
75
- requests: Object.keys(results).reduce(function (acc, key) {
76
- return acc.concat(results[key].rawResults.map(function (request) {
77
- return {
78
- indexName: request.index,
79
- params: request.params
80
- };
81
- }));
82
- }, [])
82
+ requests: cachedRequest
83
83
  }));
84
84
  client.cache = _objectSpread(_objectSpread({}, client.cache), {}, _defineProperty({}, cacheKey, JSON.stringify({
85
- results: Object.keys(results).reduce(function (acc, key) {
86
- return acc.concat(results[key].rawResults);
87
- }, [])
85
+ results: Object.keys(results).map(function (key) {
86
+ return results[key].results;
87
+ })
88
88
  })));
89
89
  }
90
90
  }
91
+ function deserializeQueryParameters(parameters) {
92
+ return parameters.split('&').reduce(function (acc, parameter) {
93
+ var _parameter$split = parameter.split('='),
94
+ _parameter$split2 = _slicedToArray(_parameter$split, 2),
95
+ key = _parameter$split2[0],
96
+ value = _parameter$split2[1];
97
+ acc[key] = value ? decodeURIComponent(value) : '';
98
+ return acc;
99
+ }, {});
100
+ }
91
101
 
92
102
  // This function is copied from the algoliasearch v4 API Client. If modified,
93
103
  // consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
@@ -40,7 +40,7 @@ export declare function createInitArgs(instantSearchInstance: InstantSearch, par
40
40
  };
41
41
  } & {
42
42
  ratingMenu: {
43
- [attribute: string]: number;
43
+ [attribute: string]: number | undefined;
44
44
  };
45
45
  } & {
46
46
  refinementList: {
@@ -95,7 +95,7 @@ export declare function createInitArgs(instantSearchInstance: InstantSearch, par
95
95
  };
96
96
  } & {
97
97
  ratingMenu: {
98
- [attribute: string]: number;
98
+ [attribute: string]: number | undefined;
99
99
  };
100
100
  } & {
101
101
  refinementList: {
@@ -167,7 +167,7 @@ export declare function createRenderArgs(instantSearchInstance: InstantSearch, p
167
167
  };
168
168
  } & {
169
169
  ratingMenu: {
170
- [attribute: string]: number;
170
+ [attribute: string]: number | undefined;
171
171
  };
172
172
  } & {
173
173
  refinementList: {
@@ -222,7 +222,7 @@ export declare function createRenderArgs(instantSearchInstance: InstantSearch, p
222
222
  };
223
223
  } & {
224
224
  ratingMenu: {
225
- [attribute: string]: number;
225
+ [attribute: string]: number | undefined;
226
226
  };
227
227
  } & {
228
228
  refinementList: {
@@ -1,2 +1,2 @@
1
- declare const _default: "4.60.0";
1
+ declare const _default: "4.62.0";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.60.0';
1
+ export default '4.62.0';
@@ -7,12 +7,12 @@ var _ref4 = h("path", {
7
7
  });
8
8
  var _ref6 = h("g", {
9
9
  fill: "none",
10
- fillRule: "evenodd"
10
+ "fill-rule": "evenodd"
11
11
  }, h("g", {
12
12
  transform: "translate(1 1)",
13
- strokeWidth: "2"
13
+ "stroke-width": "2"
14
14
  }, h("circle", {
15
- strokeOpacity: ".5",
15
+ "stroke-opacity": ".5",
16
16
  cx: "18",
17
17
  cy: "18",
18
18
  r: "18"
@@ -49,7 +49,12 @@ var defaultTemplate = {
49
49
  },
50
50
  loadingIndicator: function loadingIndicator(_ref5) {
51
51
  var cssClasses = _ref5.cssClasses;
52
+ /* eslint-disable react/no-unknown-property */
53
+ // Preact supports kebab case attributes, and using camel case would
54
+ // require using `preact/compat`.
55
+ // @TODO: reconsider using the `react` ESLint preset
52
56
  return h("svg", {
57
+ "aria-label": "Results are loading",
53
58
  className: cssClasses.loadingIcon,
54
59
  width: "16",
55
60
  height: "16",
@@ -57,6 +62,8 @@ var defaultTemplate = {
57
62
  stroke: "#444",
58
63
  "aria-hidden": "true"
59
64
  }, _ref6);
65
+ /* eslint-enable react/no-unknown-property */
60
66
  }
61
67
  };
68
+
62
69
  export default defaultTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.60.0",
3
+ "version": "4.62.0",
4
4
  "description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
5
5
  "homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
6
6
  "types": "es/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "@types/google.maps": "^3.45.3",
34
34
  "@types/hogan.js": "^3.0.0",
35
35
  "@types/qs": "^6.5.3",
36
- "algoliasearch-helper": "3.15.0",
36
+ "algoliasearch-helper": "3.16.0",
37
37
  "hogan.js": "^3.0.2",
38
38
  "htm": "^3.0.0",
39
39
  "preact": "^10.10.0",
@@ -55,9 +55,9 @@
55
55
  "version": "./scripts/version/update-version.js"
56
56
  },
57
57
  "devDependencies": {
58
- "@instantsearch/mocks": "1.29.0",
59
- "@instantsearch/tests": "1.29.0",
60
- "@instantsearch/testutils": "1.18.0",
58
+ "@instantsearch/mocks": "1.31.0",
59
+ "@instantsearch/tests": "1.31.0",
60
+ "@instantsearch/testutils": "1.20.0",
61
61
  "@storybook/html": "5.3.9",
62
62
  "@types/scriptjs": "0.0.2",
63
63
  "algoliasearch": "4.14.3",
@@ -65,5 +65,5 @@
65
65
  "scriptjs": "2.5.9",
66
66
  "webpack": "4.41.5"
67
67
  },
68
- "gitHead": "cacb63f88ce9f215e8f65af2b497e615a58b296e"
68
+ "gitHead": "967178e0e39302f1ff9552a42cfbdd9e06fd6864"
69
69
  }