instantsearch.js 4.60.0 → 4.61.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 (35) hide show
  1. package/cjs/components/SearchBox/SearchBox.js +2 -2
  2. package/cjs/connectors/breadcrumb/connectBreadcrumb.js +18 -5
  3. package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
  4. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +17 -6
  5. package/cjs/connectors/menu/connectMenu.js +18 -6
  6. package/cjs/connectors/numeric-menu/connectNumericMenu.js +18 -5
  7. package/cjs/connectors/rating-menu/connectRatingMenu.js +19 -6
  8. package/cjs/connectors/refinement-list/connectRefinementList.js +17 -6
  9. package/cjs/lib/utils/hydrateSearchClient.js +39 -29
  10. package/cjs/lib/version.js +1 -1
  11. package/cjs/widgets/search-box/defaultTemplates.js +9 -3
  12. package/dist/instantsearch.development.d.ts +13 -3
  13. package/dist/instantsearch.development.js +200 -124
  14. package/dist/instantsearch.development.js.map +1 -1
  15. package/dist/instantsearch.production.d.ts +13 -3
  16. package/dist/instantsearch.production.min.d.ts +13 -3
  17. package/dist/instantsearch.production.min.js +2 -2
  18. package/dist/instantsearch.production.min.js.map +1 -1
  19. package/es/components/SearchBox/SearchBox.js +2 -2
  20. package/es/connectors/breadcrumb/connectBreadcrumb.js +18 -5
  21. package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +12 -2
  22. package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
  23. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +17 -6
  24. package/es/connectors/menu/connectMenu.js +18 -6
  25. package/es/connectors/numeric-menu/connectNumericMenu.js +18 -5
  26. package/es/connectors/rating-menu/connectRatingMenu.d.ts +1 -1
  27. package/es/connectors/rating-menu/connectRatingMenu.js +19 -6
  28. package/es/connectors/refinement-list/connectRefinementList.js +17 -6
  29. package/es/lib/utils/hydrateSearchClient.d.ts +5 -2
  30. package/es/lib/utils/hydrateSearchClient.js +39 -29
  31. package/es/lib/utils/render-args.d.ts +4 -4
  32. package/es/lib/version.d.ts +1 -1
  33. package/es/lib/version.js +1 -1
  34. package/es/widgets/search-box/defaultTemplates.js +10 -3
  35. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.60.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.61.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -1411,8 +1411,6 @@
1411
1411
  });
1412
1412
  }
1413
1413
 
1414
- // @ts-nocheck (types to be fixed during actual implementation)
1415
-
1416
1414
  function hydrateSearchClient(client, results) {
1417
1415
  if (!results) {
1418
1416
  return;
@@ -1422,9 +1420,22 @@
1422
1420
  // - Algoliasearch API Client < v4 with cache disabled
1423
1421
  // - Third party clients (detected by the `addAlgoliaAgent` function missing)
1424
1422
 
1425
- if ((!client.transporter || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
1423
+ if ((!('transporter' in client) || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
1426
1424
  return;
1427
1425
  }
1426
+ var cachedRequest = Object.keys(results).map(function (key) {
1427
+ return results[key].results.map(function (result) {
1428
+ return {
1429
+ indexName: result.index,
1430
+ // We normalize the params received from the server as they can
1431
+ // be serialized differently depending on the engine.
1432
+ params: serializeQueryParameters(deserializeQueryParameters(result.params))
1433
+ };
1434
+ });
1435
+ });
1436
+ var cachedResults = Object.keys(results).reduce(function (acc, key) {
1437
+ return acc.concat(results[key].results);
1438
+ }, []);
1428
1439
 
1429
1440
  // Algoliasearch API Client >= v4
1430
1441
  // To hydrate the client we need to populate the cache with the data from
@@ -1433,9 +1444,10 @@
1433
1444
  // for us to compute the key the same way as `algoliasearch-client` we need
1434
1445
  // to populate it on a custom key and override the `search` method to
1435
1446
  // search on it first.
1436
- if (client.transporter && !client._cacheHydrated) {
1447
+ if ('transporter' in client && !client._cacheHydrated) {
1437
1448
  client._cacheHydrated = true;
1438
1449
  var baseMethod = client.search;
1450
+ // @ts-ignore wanting type checks for v3 on this would make this too complex
1439
1451
  client.search = function (requests) {
1440
1452
  for (var _len = arguments.length, methodArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1441
1453
  methodArgs[_key - 1] = arguments[_key];
@@ -1452,22 +1464,11 @@
1452
1464
  return baseMethod.apply(void 0, [requests].concat(methodArgs));
1453
1465
  });
1454
1466
  };
1455
-
1456
- // Populate the cache with the data from the server
1457
1467
  client.transporter.responsesCache.set({
1458
1468
  method: 'search',
1459
- args: [Object.keys(results).reduce(function (acc, key) {
1460
- return acc.concat(results[key].results.map(function (request) {
1461
- return {
1462
- indexName: request.index,
1463
- params: request.params
1464
- };
1465
- }));
1466
- }, [])]
1469
+ args: cachedRequest
1467
1470
  }, {
1468
- results: Object.keys(results).reduce(function (acc, key) {
1469
- return acc.concat(results[key].results);
1470
- }, [])
1471
+ results: cachedResults
1471
1472
  });
1472
1473
  }
1473
1474
 
@@ -1477,24 +1478,27 @@
1477
1478
  // a single-index result. You can find more information about the
1478
1479
  // computation of the key inside the client (see link below).
1479
1480
  // https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
1480
- if (!client.transporter) {
1481
+ if (!('transporter' in client)) {
1481
1482
  var cacheKey = "/1/indexes/*/queries_body_".concat(JSON.stringify({
1482
- requests: Object.keys(results).reduce(function (acc, key) {
1483
- return acc.concat(results[key].rawResults.map(function (request) {
1484
- return {
1485
- indexName: request.index,
1486
- params: request.params
1487
- };
1488
- }));
1489
- }, [])
1483
+ requests: cachedRequest
1490
1484
  }));
1491
1485
  client.cache = _objectSpread2(_objectSpread2({}, client.cache), {}, _defineProperty({}, cacheKey, JSON.stringify({
1492
- results: Object.keys(results).reduce(function (acc, key) {
1493
- return acc.concat(results[key].rawResults);
1494
- }, [])
1486
+ results: Object.keys(results).map(function (key) {
1487
+ return results[key].results;
1488
+ })
1495
1489
  })));
1496
1490
  }
1497
1491
  }
1492
+ function deserializeQueryParameters(parameters) {
1493
+ return parameters.split('&').reduce(function (acc, parameter) {
1494
+ var _parameter$split = parameter.split('='),
1495
+ _parameter$split2 = _slicedToArray(_parameter$split, 2),
1496
+ key = _parameter$split2[0],
1497
+ value = _parameter$split2[1];
1498
+ acc[key] = value ? decodeURIComponent(value) : '';
1499
+ return acc;
1500
+ }, {});
1501
+ }
1498
1502
 
1499
1503
  // This function is copied from the algoliasearch v4 API Client. If modified,
1500
1504
  // consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
@@ -1950,8 +1954,8 @@
1950
1954
  }))) {
1951
1955
  throw new Error(withUsage$1('The `widgets` option expects an array of widgets.'));
1952
1956
  }
1953
- if (!(Array.isArray(facets) && facets.length <= 1 && (facets[0] === '*' || facets[0] === undefined))) {
1954
- throw new Error(withUsage$1("The `facets` option only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(facets))));
1957
+ if (!Array.isArray(facets)) {
1958
+ throw new Error(withUsage$1("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
1955
1959
  }
1956
1960
  var localWidgets = new Map();
1957
1961
  return {
@@ -2029,7 +2033,6 @@
2029
2033
  unmountFn();
2030
2034
  },
2031
2035
  getWidgetSearchParameters: function getWidgetSearchParameters(state) {
2032
- // broadening the scope of facets to avoid conflict between never and *
2033
2036
  return facets.reduce(function (acc, curr) {
2034
2037
  return acc.addFacet(curr);
2035
2038
  }, state.setQueryParameters({
@@ -2386,7 +2389,8 @@
2386
2389
  return refinement.name;
2387
2390
  }
2388
2391
 
2389
- var _excluded$1 = ["name", "escapedValue", "data", "path"];
2392
+ var _excluded$1 = ["name", "escapedValue", "data", "path"],
2393
+ _excluded2 = ["hierarchicalMenu"];
2390
2394
  var withUsage$4 = createDocumentationMessageGenerator({
2391
2395
  name: 'hierarchical-menu',
2392
2396
  connector: true
@@ -2572,12 +2576,9 @@
2572
2576
  getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
2573
2577
  var searchParameters = _ref5.searchParameters;
2574
2578
  var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
2575
- if (!path.length) {
2576
- return uiState;
2577
- }
2578
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
2579
+ return removeEmptyRefinementsFromUiState(_objectSpread2(_objectSpread2({}, uiState), {}, {
2579
2580
  hierarchicalMenu: _objectSpread2(_objectSpread2({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
2580
- });
2581
+ }));
2581
2582
  },
2582
2583
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
2583
2584
  var uiState = _ref6.uiState;
@@ -2610,6 +2611,19 @@
2610
2611
  };
2611
2612
  };
2612
2613
  };
2614
+ function removeEmptyRefinementsFromUiState(indexUiState) {
2615
+ var hierarchicalMenu = indexUiState.hierarchicalMenu,
2616
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded2);
2617
+ if (!hierarchicalMenu) {
2618
+ return indexUiState;
2619
+ }
2620
+ var connectorUiState = Object.keys(hierarchicalMenu).reduce(function (acc, key) {
2621
+ return _objectSpread2(_objectSpread2({}, acc), hierarchicalMenu[key].length > 0 ? _defineProperty({}, key, hierarchicalMenu[key]) : {});
2622
+ }, {});
2623
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
2624
+ hierarchicalMenu: connectorUiState
2625
+ } : {});
2626
+ }
2613
2627
 
2614
2628
  var withUsage$5 = createDocumentationMessageGenerator({
2615
2629
  name: 'hits',
@@ -3056,7 +3070,7 @@
3056
3070
  };
3057
3071
 
3058
3072
  var _excluded$2 = ["page"],
3059
- _excluded2 = ["clickAnalytics", "userToken"];
3073
+ _excluded2$1 = ["clickAnalytics", "userToken"];
3060
3074
  var withUsage$7 = createDocumentationMessageGenerator({
3061
3075
  name: 'infinite-hits',
3062
3076
  connector: true
@@ -3071,7 +3085,7 @@
3071
3085
  var _ref2 = state || {},
3072
3086
  clickAnalytics = _ref2.clickAnalytics,
3073
3087
  userToken = _ref2.userToken,
3074
- rest = _objectWithoutProperties(_ref2, _excluded2);
3088
+ rest = _objectWithoutProperties(_ref2, _excluded2$1);
3075
3089
  return rest;
3076
3090
  }
3077
3091
  function getInMemoryCache() {
@@ -3307,7 +3321,8 @@
3307
3321
  */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3308
3322
  var connectInfiniteHitsWithInsights = withInsights(connectInfiniteHits);
3309
3323
 
3310
- var _excluded$3 = ["name", "escapedValue", "path"];
3324
+ var _excluded$3 = ["name", "escapedValue", "path"],
3325
+ _excluded2$2 = ["menu"];
3311
3326
  var withUsage$8 = createDocumentationMessageGenerator({
3312
3327
  name: 'menu',
3313
3328
  connector: true
@@ -3465,12 +3480,9 @@
3465
3480
  var _searchParameters$get = searchParameters.getHierarchicalFacetBreadcrumb(attribute),
3466
3481
  _searchParameters$get2 = _slicedToArray(_searchParameters$get, 1),
3467
3482
  value = _searchParameters$get2[0];
3468
- if (!value) {
3469
- return uiState;
3470
- }
3471
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
3483
+ return removeEmptyRefinementsFromUiState$1(_objectSpread2(_objectSpread2({}, uiState), {}, {
3472
3484
  menu: _objectSpread2(_objectSpread2({}, uiState.menu), {}, _defineProperty({}, attribute, value))
3473
- });
3485
+ }));
3474
3486
  },
3475
3487
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
3476
3488
  var uiState = _ref5.uiState;
@@ -3496,7 +3508,22 @@
3496
3508
  };
3497
3509
  };
3498
3510
  };
3511
+ function removeEmptyRefinementsFromUiState$1(indexUiState) {
3512
+ var menu = indexUiState.menu,
3513
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded2$2);
3514
+ if (!menu) {
3515
+ return indexUiState;
3516
+ }
3517
+ var connectorUiState = Object.keys(menu).reduce(function (acc, key) {
3518
+ var _menu$key;
3519
+ return _objectSpread2(_objectSpread2({}, acc), ((_menu$key = menu[key]) === null || _menu$key === void 0 ? void 0 : _menu$key.length) > 0 ? _defineProperty({}, key, menu[key]) : {});
3520
+ }, {});
3521
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
3522
+ menu: connectorUiState
3523
+ } : {});
3524
+ }
3499
3525
 
3526
+ var _excluded$4 = ["numericMenu"];
3500
3527
  var withUsage$9 = createDocumentationMessageGenerator({
3501
3528
  name: 'numeric-menu',
3502
3529
  connector: true
@@ -3580,12 +3607,9 @@
3580
3607
  }
3581
3608
  var min = values['>='] && values['>='][0] || '';
3582
3609
  var max = values['<='] && values['<='][0] || '';
3583
- if (min === '' && max === '') {
3584
- return uiState;
3585
- }
3586
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
3610
+ return removeEmptyRefinementsFromUiState$2(_objectSpread2(_objectSpread2({}, uiState), {}, {
3587
3611
  numericMenu: _objectSpread2(_objectSpread2({}, uiState.numericMenu), {}, _defineProperty({}, attribute, "".concat(min, ":").concat(max)))
3588
- });
3612
+ }));
3589
3613
  },
3590
3614
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
3591
3615
  var uiState = _ref6.uiState;
@@ -3747,6 +3771,19 @@
3747
3771
  function hasNumericRefinement(currentRefinements, operator, value) {
3748
3772
  return currentRefinements[operator] !== undefined && currentRefinements[operator].includes(value);
3749
3773
  }
3774
+ function removeEmptyRefinementsFromUiState$2(indexUiState) {
3775
+ var numericMenu = indexUiState.numericMenu,
3776
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded$4);
3777
+ if (!numericMenu) {
3778
+ return indexUiState;
3779
+ }
3780
+ var connectorUiState = Object.keys(numericMenu).reduce(function (acc, key) {
3781
+ return _objectSpread2(_objectSpread2({}, acc), numericMenu[key] !== ':' ? _defineProperty({}, key, numericMenu[key]) : {});
3782
+ }, {});
3783
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
3784
+ numericMenu: connectorUiState
3785
+ } : {});
3786
+ }
3750
3787
 
3751
3788
  var Paginator = /*#__PURE__*/function () {
3752
3789
  function Paginator(params) {
@@ -4196,8 +4233,9 @@
4196
4233
  };
4197
4234
  };
4198
4235
 
4199
- var _excluded$4 = ["name", "escapedValue"],
4200
- _excluded2$1 = ["escapedValue", "value"];
4236
+ var _excluded$5 = ["name", "escapedValue"],
4237
+ _excluded2$3 = ["escapedValue", "value"],
4238
+ _excluded3 = ["refinementList"];
4201
4239
  var withUsage$c = createDocumentationMessageGenerator({
4202
4240
  name: 'refinement-list',
4203
4241
  connector: true
@@ -4249,7 +4287,7 @@
4249
4287
  var formatItems = function formatItems(_ref2) {
4250
4288
  var label = _ref2.name,
4251
4289
  value = _ref2.escapedValue,
4252
- item = _objectWithoutProperties(_ref2, _excluded$4);
4290
+ item = _objectWithoutProperties(_ref2, _excluded$5);
4253
4291
  return _objectSpread2(_objectSpread2({}, item), {}, {
4254
4292
  value: value,
4255
4293
  label: label,
@@ -4306,7 +4344,7 @@
4306
4344
  var normalizedFacetValues = transformItems(facetValues.map(function (_ref3) {
4307
4345
  var escapedValue = _ref3.escapedValue,
4308
4346
  value = _ref3.value,
4309
- item = _objectWithoutProperties(_ref3, _excluded2$1);
4347
+ item = _objectWithoutProperties(_ref3, _excluded2$3);
4310
4348
  return _objectSpread2(_objectSpread2({}, item), {}, {
4311
4349
  value: escapedValue,
4312
4350
  label: value
@@ -4432,12 +4470,9 @@
4432
4470
  getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
4433
4471
  var searchParameters = _ref5.searchParameters;
4434
4472
  var values = operator === 'or' ? searchParameters.getDisjunctiveRefinements(attribute) : searchParameters.getConjunctiveRefinements(attribute);
4435
- if (!values.length) {
4436
- return uiState;
4437
- }
4438
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
4473
+ return removeEmptyRefinementsFromUiState$3(_objectSpread2(_objectSpread2({}, uiState), {}, {
4439
4474
  refinementList: _objectSpread2(_objectSpread2({}, uiState.refinementList), {}, _defineProperty({}, attribute, values))
4440
- });
4475
+ }));
4441
4476
  },
4442
4477
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
4443
4478
  var uiState = _ref6.uiState;
@@ -4467,6 +4502,19 @@
4467
4502
  };
4468
4503
  };
4469
4504
  };
4505
+ function removeEmptyRefinementsFromUiState$3(indexUiState) {
4506
+ var refinementList = indexUiState.refinementList,
4507
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded3);
4508
+ if (!refinementList) {
4509
+ return indexUiState;
4510
+ }
4511
+ var connectorUiState = Object.keys(refinementList).reduce(function (acc, key) {
4512
+ return _objectSpread2(_objectSpread2({}, acc), refinementList[key].length > 0 ? _defineProperty({}, key, refinementList[key]) : {});
4513
+ }, {});
4514
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
4515
+ refinementList: connectorUiState
4516
+ } : {});
4517
+ }
4470
4518
 
4471
4519
  var withUsage$d = createDocumentationMessageGenerator({
4472
4520
  name: 'search-box',
@@ -4660,6 +4708,7 @@
4660
4708
  };
4661
4709
  };
4662
4710
 
4711
+ var _excluded$6 = ["ratingMenu"];
4663
4712
  var withUsage$f = createDocumentationMessageGenerator({
4664
4713
  name: 'rating-menu',
4665
4714
  connector: true
@@ -4901,12 +4950,9 @@
4901
4950
  getWidgetUiState: function getWidgetUiState(uiState, _ref7) {
4902
4951
  var searchParameters = _ref7.searchParameters;
4903
4952
  var value = _getRefinedStar(searchParameters);
4904
- if (typeof value !== 'number') {
4905
- return uiState;
4906
- }
4907
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
4908
- ratingMenu: _objectSpread2(_objectSpread2({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, value))
4909
- });
4953
+ return removeEmptyRefinementsFromUiState$4(_objectSpread2(_objectSpread2({}, uiState), {}, {
4954
+ ratingMenu: _objectSpread2(_objectSpread2({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, typeof value === 'number' ? value : undefined))
4955
+ }));
4910
4956
  },
4911
4957
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref8) {
4912
4958
  var uiState = _ref8.uiState;
@@ -4923,6 +4969,19 @@
4923
4969
  };
4924
4970
  };
4925
4971
  };
4972
+ function removeEmptyRefinementsFromUiState$4(indexUiState) {
4973
+ var ratingMenu = indexUiState.ratingMenu,
4974
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded$6);
4975
+ if (!ratingMenu) {
4976
+ return indexUiState;
4977
+ }
4978
+ var connectorUiState = Object.keys(ratingMenu).reduce(function (acc, key) {
4979
+ return _objectSpread2(_objectSpread2({}, acc), typeof ratingMenu[key] === 'number' ? _defineProperty({}, key, ratingMenu[key]) : {});
4980
+ }, {});
4981
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
4982
+ ratingMenu: connectorUiState
4983
+ } : {});
4984
+ }
4926
4985
 
4927
4986
  var withUsage$g = createDocumentationMessageGenerator({
4928
4987
  name: 'stats',
@@ -5288,6 +5347,7 @@
5288
5347
  };
5289
5348
  };
5290
5349
 
5350
+ var _excluded$7 = ["hierarchicalMenu"];
5291
5351
  var withUsage$i = createDocumentationMessageGenerator({
5292
5352
  name: 'breadcrumb',
5293
5353
  connector: true
@@ -5392,12 +5452,9 @@
5392
5452
  getWidgetUiState: function getWidgetUiState(uiState, _ref3) {
5393
5453
  var searchParameters = _ref3.searchParameters;
5394
5454
  var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
5395
- if (!path.length) {
5396
- return uiState;
5397
- }
5398
- return _objectSpread2(_objectSpread2({}, uiState), {}, {
5455
+ return removeEmptyRefinementsFromUiState$5(_objectSpread2(_objectSpread2({}, uiState), {}, {
5399
5456
  hierarchicalMenu: _objectSpread2(_objectSpread2({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
5400
- });
5457
+ }));
5401
5458
  },
5402
5459
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref4) {
5403
5460
  var uiState = _ref4.uiState;
@@ -5448,6 +5505,19 @@
5448
5505
  };
5449
5506
  });
5450
5507
  }
5508
+ function removeEmptyRefinementsFromUiState$5(indexUiState) {
5509
+ var hierarchicalMenu = indexUiState.hierarchicalMenu,
5510
+ indexUiStateBase = _objectWithoutProperties(indexUiState, _excluded$7);
5511
+ if (!hierarchicalMenu) {
5512
+ return indexUiState;
5513
+ }
5514
+ var connectorUiState = Object.keys(hierarchicalMenu).reduce(function (acc, key) {
5515
+ return _objectSpread2(_objectSpread2({}, acc), hierarchicalMenu[key].length > 0 ? _defineProperty({}, key, hierarchicalMenu[key]) : {});
5516
+ }, {});
5517
+ return _objectSpread2(_objectSpread2({}, indexUiStateBase), Object.keys(connectorUiState).length > 0 ? {
5518
+ hierarchicalMenu: connectorUiState
5519
+ } : {});
5520
+ }
5451
5521
 
5452
5522
  var withUsage$j = createDocumentationMessageGenerator({
5453
5523
  name: 'geo-search',
@@ -12597,11 +12667,11 @@
12597
12667
  return getCookie(ANONYMOUS_TOKEN_COOKIE_KEY);
12598
12668
  }
12599
12669
 
12600
- var _excluded$5 = ["page"];
12670
+ var _excluded$8 = ["page"];
12601
12671
  function getStateWithoutPage$1(state) {
12602
12672
  var _ref = state || {},
12603
12673
  page = _ref.page,
12604
- rest = _objectWithoutProperties(_ref, _excluded$5);
12674
+ rest = _objectWithoutProperties(_ref, _excluded$8);
12605
12675
  return rest;
12606
12676
  }
12607
12677
  var KEY = 'ais.infiniteHits';
@@ -14110,10 +14180,10 @@
14110
14180
  });
14111
14181
  }
14112
14182
 
14113
- var _excluded$6 = ["configure"];
14183
+ var _excluded$9 = ["configure"];
14114
14184
  function getIndexStateWithoutConfigure(uiState) {
14115
14185
  var configure = uiState.configure,
14116
- trackedUiState = _objectWithoutProperties(uiState, _excluded$6);
14186
+ trackedUiState = _objectWithoutProperties(uiState, _excluded$9);
14117
14187
  return trackedUiState;
14118
14188
  }
14119
14189
 
@@ -14198,7 +14268,7 @@
14198
14268
  };
14199
14269
  };
14200
14270
 
14201
- var _excluded$7 = ["initialSearchParameters"];
14271
+ var _excluded$a = ["initialSearchParameters"];
14202
14272
  var withUsage$q = createDocumentationMessageGenerator({
14203
14273
  name: 'index-widget'
14204
14274
  });
@@ -14238,7 +14308,7 @@
14238
14308
  }
14239
14309
  function getLocalWidgetsSearchParameters(widgets, widgetSearchParametersOptions) {
14240
14310
  var initialSearchParameters = widgetSearchParametersOptions.initialSearchParameters,
14241
- rest = _objectWithoutProperties(widgetSearchParametersOptions, _excluded$7);
14311
+ rest = _objectWithoutProperties(widgetSearchParametersOptions, _excluded$a);
14242
14312
  return widgets.filter(function (widget) {
14243
14313
  return !isIndexWidget(widget);
14244
14314
  }).reduce(function (state, widget) {
@@ -14745,7 +14815,7 @@
14745
14815
  };
14746
14816
  }
14747
14817
 
14748
- var version$1 = '4.60.0';
14818
+ var version$1 = '4.61.0';
14749
14819
 
14750
14820
  var withUsage$r = createDocumentationMessageGenerator({
14751
14821
  name: 'instantsearch'
@@ -15345,10 +15415,10 @@
15345
15415
  history: historyRouter
15346
15416
  });
15347
15417
 
15348
- var _excluded$8 = ["configure"];
15418
+ var _excluded$b = ["configure"];
15349
15419
  function getIndexStateWithoutConfigure$1(uiState) {
15350
15420
  var configure = uiState.configure,
15351
- trackedUiState = _objectWithoutProperties(uiState, _excluded$8);
15421
+ trackedUiState = _objectWithoutProperties(uiState, _excluded$b);
15352
15422
  return trackedUiState;
15353
15423
  }
15354
15424
  function singleIndexStateMapping(indexName) {
@@ -16274,7 +16344,7 @@
16274
16344
 
16275
16345
  var _objectWithoutProperties$1 = unwrapExports(objectWithoutProperties);
16276
16346
 
16277
- var _excluded$9 = ["parts", "highlightedTagName", "nonHighlightedTagName", "separator", "className", "classNames"];
16347
+ var _excluded$c = ["parts", "highlightedTagName", "nonHighlightedTagName", "separator", "className", "classNames"];
16278
16348
 
16279
16349
  function createHighlightPartComponent(_ref) {
16280
16350
  var createElement = _ref.createElement;
@@ -16311,7 +16381,7 @@
16311
16381
  className = userProps.className,
16312
16382
  _userProps$classNames = userProps.classNames,
16313
16383
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
16314
- props = _objectWithoutProperties$1(userProps, _excluded$9);
16384
+ props = _objectWithoutProperties$1(userProps, _excluded$c);
16315
16385
 
16316
16386
  return createElement("span", _extends$1({}, props, {
16317
16387
  className: cx(classNames.root, className)
@@ -16339,11 +16409,11 @@
16339
16409
  Fragment: p
16340
16410
  });
16341
16411
 
16342
- var _excluded$a = ["classNames"];
16412
+ var _excluded$d = ["classNames"];
16343
16413
  function Highlight(_ref) {
16344
16414
  var _ref$classNames = _ref.classNames,
16345
16415
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
16346
- props = _objectWithoutProperties(_ref, _excluded$a);
16416
+ props = _objectWithoutProperties(_ref, _excluded$d);
16347
16417
  return h(InternalHighlight, _extends({
16348
16418
  classNames: {
16349
16419
  root: cx('ais-Highlight', classNames.root),
@@ -16354,12 +16424,12 @@
16354
16424
  }, props));
16355
16425
  }
16356
16426
 
16357
- var _excluded$b = ["hit", "attribute", "cssClasses"];
16427
+ var _excluded$e = ["hit", "attribute", "cssClasses"];
16358
16428
  function Highlight$1(_ref) {
16359
16429
  var hit = _ref.hit,
16360
16430
  attribute = _ref.attribute,
16361
16431
  cssClasses = _ref.cssClasses,
16362
- props = _objectWithoutProperties(_ref, _excluded$b);
16432
+ props = _objectWithoutProperties(_ref, _excluded$e);
16363
16433
  var property = getPropertyByPath(hit._highlightResult, attribute) || [];
16364
16434
  var properties = toArray(property);
16365
16435
  _warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) ;
@@ -16373,11 +16443,11 @@
16373
16443
  }));
16374
16444
  }
16375
16445
 
16376
- var _excluded$c = ["classNames"];
16446
+ var _excluded$f = ["classNames"];
16377
16447
  function ReverseHighlight(_ref) {
16378
16448
  var _ref$classNames = _ref.classNames,
16379
16449
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
16380
- props = _objectWithoutProperties(_ref, _excluded$c);
16450
+ props = _objectWithoutProperties(_ref, _excluded$f);
16381
16451
  return h(InternalHighlight, _extends({
16382
16452
  classNames: {
16383
16453
  root: cx('ais-ReverseHighlight', classNames.root),
@@ -16388,13 +16458,13 @@
16388
16458
  }, props));
16389
16459
  }
16390
16460
 
16391
- var _excluded$d = ["hit", "attribute", "cssClasses"],
16392
- _excluded2$2 = ["isHighlighted"];
16461
+ var _excluded$g = ["hit", "attribute", "cssClasses"],
16462
+ _excluded2$4 = ["isHighlighted"];
16393
16463
  function ReverseHighlight$1(_ref) {
16394
16464
  var hit = _ref.hit,
16395
16465
  attribute = _ref.attribute,
16396
16466
  cssClasses = _ref.cssClasses,
16397
- props = _objectWithoutProperties(_ref, _excluded$d);
16467
+ props = _objectWithoutProperties(_ref, _excluded$g);
16398
16468
  var property = getPropertyByPath(hit._highlightResult, attribute) || [];
16399
16469
  var properties = toArray(property);
16400
16470
  _warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) ;
@@ -16402,7 +16472,7 @@
16402
16472
  var value = _ref2.value;
16403
16473
  return getHighlightedParts(unescape$1(value || '')).map(function (_ref3) {
16404
16474
  var isHighlighted = _ref3.isHighlighted,
16405
- rest = _objectWithoutProperties(_ref3, _excluded2$2);
16475
+ rest = _objectWithoutProperties(_ref3, _excluded2$4);
16406
16476
  return _objectSpread2(_objectSpread2({}, rest), {}, {
16407
16477
  isHighlighted: !isHighlighted
16408
16478
  });
@@ -16414,11 +16484,11 @@
16414
16484
  }));
16415
16485
  }
16416
16486
 
16417
- var _excluded$e = ["classNames"];
16487
+ var _excluded$h = ["classNames"];
16418
16488
  function ReverseSnippet(_ref) {
16419
16489
  var _ref$classNames = _ref.classNames,
16420
16490
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
16421
- props = _objectWithoutProperties(_ref, _excluded$e);
16491
+ props = _objectWithoutProperties(_ref, _excluded$h);
16422
16492
  return h(InternalHighlight, _extends({
16423
16493
  classNames: {
16424
16494
  root: cx('ais-ReverseSnippet', classNames.root),
@@ -16429,13 +16499,13 @@
16429
16499
  }, props));
16430
16500
  }
16431
16501
 
16432
- var _excluded$f = ["hit", "attribute", "cssClasses"],
16433
- _excluded2$3 = ["isHighlighted"];
16502
+ var _excluded$i = ["hit", "attribute", "cssClasses"],
16503
+ _excluded2$5 = ["isHighlighted"];
16434
16504
  function ReverseSnippet$1(_ref) {
16435
16505
  var hit = _ref.hit,
16436
16506
  attribute = _ref.attribute,
16437
16507
  cssClasses = _ref.cssClasses,
16438
- props = _objectWithoutProperties(_ref, _excluded$f);
16508
+ props = _objectWithoutProperties(_ref, _excluded$i);
16439
16509
  var property = getPropertyByPath(hit._snippetResult, attribute) || [];
16440
16510
  var properties = toArray(property);
16441
16511
  _warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) ;
@@ -16443,7 +16513,7 @@
16443
16513
  var value = _ref2.value;
16444
16514
  return getHighlightedParts(unescape$1(value || '')).map(function (_ref3) {
16445
16515
  var isHighlighted = _ref3.isHighlighted,
16446
- rest = _objectWithoutProperties(_ref3, _excluded2$3);
16516
+ rest = _objectWithoutProperties(_ref3, _excluded2$5);
16447
16517
  return _objectSpread2(_objectSpread2({}, rest), {}, {
16448
16518
  isHighlighted: !isHighlighted
16449
16519
  });
@@ -16455,11 +16525,11 @@
16455
16525
  }));
16456
16526
  }
16457
16527
 
16458
- var _excluded$g = ["classNames"];
16528
+ var _excluded$j = ["classNames"];
16459
16529
  function Snippet(_ref) {
16460
16530
  var _ref$classNames = _ref.classNames,
16461
16531
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
16462
- props = _objectWithoutProperties(_ref, _excluded$g);
16532
+ props = _objectWithoutProperties(_ref, _excluded$j);
16463
16533
  return h(InternalHighlight, _extends({
16464
16534
  classNames: {
16465
16535
  root: cx('ais-Snippet', classNames.root),
@@ -16470,12 +16540,12 @@
16470
16540
  }, props));
16471
16541
  }
16472
16542
 
16473
- var _excluded$h = ["hit", "attribute", "cssClasses"];
16543
+ var _excluded$k = ["hit", "attribute", "cssClasses"];
16474
16544
  function Snippet$1(_ref) {
16475
16545
  var hit = _ref.hit,
16476
16546
  attribute = _ref.attribute,
16477
16547
  cssClasses = _ref.cssClasses,
16478
- props = _objectWithoutProperties(_ref, _excluded$h);
16548
+ props = _objectWithoutProperties(_ref, _excluded$k);
16479
16549
  var property = getPropertyByPath(hit._snippetResult, attribute) || [];
16480
16550
  var properties = toArray(property);
16481
16551
  _warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) ;
@@ -16746,7 +16816,7 @@
16746
16816
  });
16747
16817
  };
16748
16818
 
16749
- var _excluded$i = ["container", "widgets", "fallbackWidget"];
16819
+ var _excluded$l = ["container", "widgets", "fallbackWidget"];
16750
16820
  var withUsage$t = createDocumentationMessageGenerator({
16751
16821
  name: 'dynamic-widgets'
16752
16822
  });
@@ -16764,7 +16834,7 @@
16764
16834
  containerSelector = _ref.container,
16765
16835
  widgets = _ref.widgets,
16766
16836
  fallbackWidget = _ref.fallbackWidget,
16767
- otherWidgetParams = _objectWithoutProperties(_ref, _excluded$i);
16837
+ otherWidgetParams = _objectWithoutProperties(_ref, _excluded$l);
16768
16838
  if (!containerSelector) {
16769
16839
  throw new Error(withUsage$t('The `container` option is required.'));
16770
16840
  }
@@ -17738,9 +17808,9 @@
17738
17808
  }), container.querySelector(".".concat(cssClasses.tree)));
17739
17809
  };
17740
17810
 
17741
- var _excluded$j = ["initialZoom", "initialPosition", "templates", "cssClasses", "builtInMarker", "customHTMLMarker", "enableRefine", "enableClearMapRefinement", "enableRefineControl", "container", "googleReference"],
17742
- _excluded2$4 = ["item"],
17743
- _excluded3 = ["item"];
17811
+ var _excluded$m = ["initialZoom", "initialPosition", "templates", "cssClasses", "builtInMarker", "customHTMLMarker", "enableRefine", "enableClearMapRefinement", "enableRefineControl", "container", "googleReference"],
17812
+ _excluded2$6 = ["item"],
17813
+ _excluded3$1 = ["item"];
17744
17814
  var withUsage$y = createDocumentationMessageGenerator({
17745
17815
  name: 'geo-search'
17746
17816
  });
@@ -17782,7 +17852,7 @@
17782
17852
  enableRefineControl = _ref$enableRefineCont === void 0 ? true : _ref$enableRefineCont,
17783
17853
  container = _ref.container,
17784
17854
  googleReference = _ref.googleReference,
17785
- otherWidgetParams = _objectWithoutProperties(_ref, _excluded$j);
17855
+ otherWidgetParams = _objectWithoutProperties(_ref, _excluded$m);
17786
17856
  var defaultBuiltInMarker = {
17787
17857
  createOptions: function createOptions() {
17788
17858
  return {};
@@ -17841,7 +17911,7 @@
17841
17911
  var customHTMLMarker = isCustomHTMLMarker && _objectSpread2(_objectSpread2({}, defaultCustomHTMLMarker), userCustomHTMLMarker);
17842
17912
  var createBuiltInMarker = function createBuiltInMarker(_ref2) {
17843
17913
  var item = _ref2.item,
17844
- rest = _objectWithoutProperties(_ref2, _excluded2$4);
17914
+ rest = _objectWithoutProperties(_ref2, _excluded2$6);
17845
17915
  return new googleReference.maps.Marker(_objectSpread2(_objectSpread2(_objectSpread2({}, builtInMarker.createOptions(item)), rest), {}, {
17846
17916
  // @ts-expect-error @types/googlemaps doesn't document this
17847
17917
  __id: item.objectID,
@@ -17851,7 +17921,7 @@
17851
17921
  var HTMLMarker = createHTMLMarker(googleReference);
17852
17922
  var createCustomHTMLMarker = function createCustomHTMLMarker(_ref3) {
17853
17923
  var item = _ref3.item,
17854
- rest = _objectWithoutProperties(_ref3, _excluded3);
17924
+ rest = _objectWithoutProperties(_ref3, _excluded3$1);
17855
17925
  return new HTMLMarker(_objectSpread2(_objectSpread2(_objectSpread2({}, customHTMLMarker.createOptions(item)), rest), {}, {
17856
17926
  __id: item.objectID,
17857
17927
  position: item._geoloc,
@@ -18050,7 +18120,7 @@
18050
18120
  rootProps: {
18051
18121
  className: cssClasses.submit,
18052
18122
  type: 'submit',
18053
- title: 'Submit the search query.',
18123
+ title: 'Submit the search query',
18054
18124
  hidden: !showSubmit
18055
18125
  },
18056
18126
  templates: templates,
@@ -18063,7 +18133,7 @@
18063
18133
  rootProps: {
18064
18134
  className: cssClasses.reset,
18065
18135
  type: 'reset',
18066
- title: 'Clear the search query.',
18136
+ title: 'Clear the search query',
18067
18137
  hidden: !(showReset && this.state.query.trim() && !isSearchStalled)
18068
18138
  },
18069
18139
  templates: templates,
@@ -18112,7 +18182,7 @@
18112
18182
  })), subItems);
18113
18183
  }
18114
18184
 
18115
- var _excluded$k = ["root"];
18185
+ var _excluded$n = ["root"];
18116
18186
 
18117
18187
  // CSS types
18118
18188
 
@@ -18139,7 +18209,7 @@
18139
18209
  if (isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) {
18140
18210
  var _this$props$cssClasse = _this.props.cssClasses,
18141
18211
  root = _this$props$cssClasse.root,
18142
- cssClasses = _objectWithoutProperties(_this$props$cssClasse, _excluded$k);
18212
+ cssClasses = _objectWithoutProperties(_this$props$cssClasse, _excluded$n);
18143
18213
  subItems = h(RefinementList, _extends({}, _this.props, {
18144
18214
  // We want to keep `root` required for external usage but not for the
18145
18215
  // sub items.
@@ -19795,8 +19865,8 @@
19795
19865
  };
19796
19866
  };
19797
19867
 
19798
- var _excluded$l = ["placesReference", "defaultPosition"],
19799
- _excluded2$5 = ["places"];
19868
+ var _excluded$o = ["placesReference", "defaultPosition"],
19869
+ _excluded2$7 = ["places"];
19800
19870
  /* Places.js is an optional dependency, no error should be reported if the package is missing */
19801
19871
  /** @ts-ignore */
19802
19872
  // using the type like this requires only one ts-ignore
@@ -19809,7 +19879,7 @@
19809
19879
  placesReference = _ref.placesReference,
19810
19880
  _ref$defaultPosition = _ref.defaultPosition,
19811
19881
  defaultPosition = _ref$defaultPosition === void 0 ? [] : _ref$defaultPosition,
19812
- placesOptions = _objectWithoutProperties(_ref, _excluded$l);
19882
+ placesOptions = _objectWithoutProperties(_ref, _excluded$o);
19813
19883
  if (typeof placesReference !== 'function') {
19814
19884
  throw new Error('The `placesReference` option requires a valid Places.js reference.');
19815
19885
  }
@@ -19850,7 +19920,7 @@
19850
19920
  var hasPositionSet = position !== defaultPosition.join(',');
19851
19921
  if (!hasPositionSet && !state.query) {
19852
19922
  var places = uiState.places,
19853
- uiStateWithoutPlaces = _objectWithoutProperties(uiState, _excluded2$5);
19923
+ uiStateWithoutPlaces = _objectWithoutProperties(uiState, _excluded2$7);
19854
19924
  return uiStateWithoutPlaces;
19855
19925
  }
19856
19926
  return _objectSpread2(_objectSpread2({}, uiState), {}, {
@@ -21267,12 +21337,12 @@
21267
21337
  });
21268
21338
  var _ref6$1 = h("g", {
21269
21339
  fill: "none",
21270
- fillRule: "evenodd"
21340
+ "fill-rule": "evenodd"
21271
21341
  }, h("g", {
21272
21342
  transform: "translate(1 1)",
21273
- strokeWidth: "2"
21343
+ "stroke-width": "2"
21274
21344
  }, h("circle", {
21275
- strokeOpacity: ".5",
21345
+ "stroke-opacity": ".5",
21276
21346
  cx: "18",
21277
21347
  cy: "18",
21278
21348
  r: "18"
@@ -21309,7 +21379,12 @@
21309
21379
  },
21310
21380
  loadingIndicator: function loadingIndicator(_ref5) {
21311
21381
  var cssClasses = _ref5.cssClasses;
21382
+ /* eslint-disable react/no-unknown-property */
21383
+ // Preact supports kebab case attributes, and using camel case would
21384
+ // require using `preact/compat`.
21385
+ // @TODO: reconsider using the `react` ESLint preset
21312
21386
  return h("svg", {
21387
+ "aria-label": "Results are loading",
21313
21388
  className: cssClasses.loadingIcon,
21314
21389
  width: "16",
21315
21390
  height: "16",
@@ -21317,6 +21392,7 @@
21317
21392
  stroke: "#444",
21318
21393
  "aria-hidden": "true"
21319
21394
  }, _ref6$1);
21395
+ /* eslint-enable react/no-unknown-property */
21320
21396
  }
21321
21397
  };
21322
21398
 
@@ -21841,13 +21917,13 @@
21841
21917
  });
21842
21918
  };
21843
21919
 
21844
- var _excluded$m = ["nbHits", "nbSortedHits", "cssClasses", "templateProps"];
21920
+ var _excluded$p = ["nbHits", "nbSortedHits", "cssClasses", "templateProps"];
21845
21921
  var Stats = function Stats(_ref) {
21846
21922
  var nbHits = _ref.nbHits,
21847
21923
  nbSortedHits = _ref.nbSortedHits,
21848
21924
  cssClasses = _ref.cssClasses,
21849
21925
  templateProps = _ref.templateProps,
21850
- rest = _objectWithoutProperties(_ref, _excluded$m);
21926
+ rest = _objectWithoutProperties(_ref, _excluded$p);
21851
21927
  return h("div", {
21852
21928
  className: cx(cssClasses.root)
21853
21929
  }, h(Template, _extends({}, templateProps, {