react-instantsearch-core 6.38.1 → 6.38.2

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 (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -1
  3. package/dist/cjs/connectors/connectAutoComplete.js +14 -33
  4. package/dist/cjs/connectors/connectBreadcrumb.js +9 -22
  5. package/dist/cjs/connectors/connectConfigure.js +17 -26
  6. package/dist/cjs/connectors/connectConfigureRelatedItems.js +20 -33
  7. package/dist/cjs/connectors/connectCurrentRefinements.js +6 -13
  8. package/dist/cjs/connectors/connectDynamicWidgets.js +2 -13
  9. package/dist/cjs/connectors/connectGeoSearch.js +15 -34
  10. package/dist/cjs/connectors/connectHierarchicalMenu.js +22 -48
  11. package/dist/cjs/connectors/connectHighlight.js +8 -14
  12. package/dist/cjs/connectors/connectHitInsights.js +8 -20
  13. package/dist/cjs/connectors/connectHits.js +2 -11
  14. package/dist/cjs/connectors/connectHitsPerPage.js +8 -18
  15. package/dist/cjs/connectors/connectInfiniteHits.js +25 -43
  16. package/dist/cjs/connectors/connectMenu.js +14 -33
  17. package/dist/cjs/connectors/connectNumericMenu.js +24 -49
  18. package/dist/cjs/connectors/connectPagination.js +7 -17
  19. package/dist/cjs/connectors/connectPoweredBy.js +1 -5
  20. package/dist/cjs/connectors/connectQueryRules.js +11 -29
  21. package/dist/cjs/connectors/connectRange.js +33 -75
  22. package/dist/cjs/connectors/connectRefinementList.js +16 -34
  23. package/dist/cjs/connectors/connectRelevantSort.js +6 -13
  24. package/dist/cjs/connectors/connectScrollTo.js +6 -14
  25. package/dist/cjs/connectors/connectSearchBox.js +7 -17
  26. package/dist/cjs/connectors/connectSortBy.js +8 -18
  27. package/dist/cjs/connectors/connectStateResults.js +1 -6
  28. package/dist/cjs/connectors/connectStats.js +2 -8
  29. package/dist/cjs/connectors/connectToggleRefinement.js +14 -29
  30. package/dist/cjs/connectors/connectVoiceSearch.js +7 -24
  31. package/dist/cjs/core/context.js +3 -7
  32. package/dist/cjs/core/createConnector.js +60 -114
  33. package/dist/cjs/core/createInstantSearchManager.d.js +1 -0
  34. package/dist/cjs/core/createInstantSearchManager.js +67 -116
  35. package/dist/cjs/core/createStore.js +0 -1
  36. package/dist/cjs/core/createWidgetsManager.js +4 -7
  37. package/dist/cjs/core/highlight.js +11 -20
  38. package/dist/cjs/core/indexUtils.js +34 -77
  39. package/dist/cjs/core/metadata.js +7 -15
  40. package/dist/cjs/core/translatable.js +19 -46
  41. package/dist/cjs/core/utils.js +14 -52
  42. package/dist/cjs/core/version.js +1 -1
  43. package/dist/cjs/index.js +9 -44
  44. package/dist/cjs/types/index.js +0 -2
  45. package/dist/cjs/widgets/Configure.js +1 -5
  46. package/dist/cjs/widgets/ConfigureRelatedItems.js +1 -8
  47. package/dist/cjs/widgets/DynamicWidgets.js +12 -33
  48. package/dist/cjs/widgets/Index.js +26 -52
  49. package/dist/cjs/widgets/InstantSearch.js +28 -67
  50. package/dist/cjs/widgets/QueryRuleContext.js +1 -5
  51. package/dist/es/connectors/connectAutoComplete.js +11 -25
  52. package/dist/es/connectors/connectBreadcrumb.js +7 -13
  53. package/dist/es/connectors/connectConfigure.js +13 -22
  54. package/dist/es/connectors/connectConfigureRelatedItems.js +17 -25
  55. package/dist/es/connectors/connectCurrentRefinements.js +5 -7
  56. package/dist/es/connectors/connectDynamicWidgets.js +1 -6
  57. package/dist/es/connectors/connectGeoSearch.js +14 -27
  58. package/dist/es/connectors/connectHierarchicalMenu.js +19 -38
  59. package/dist/es/connectors/connectHighlight.js +7 -9
  60. package/dist/es/connectors/connectHitInsights.js +7 -14
  61. package/dist/es/connectors/connectHits.js +2 -5
  62. package/dist/es/connectors/connectHitsPerPage.js +5 -12
  63. package/dist/es/connectors/connectInfiniteHits.js +21 -31
  64. package/dist/es/connectors/connectMenu.js +12 -25
  65. package/dist/es/connectors/connectNumericMenu.js +22 -40
  66. package/dist/es/connectors/connectPagination.js +5 -12
  67. package/dist/es/connectors/connectPoweredBy.js +1 -1
  68. package/dist/es/connectors/connectQueryRules.js +9 -20
  69. package/dist/es/connectors/connectRange.js +31 -68
  70. package/dist/es/connectors/connectRefinementList.js +14 -24
  71. package/dist/es/connectors/connectRelevantSort.js +7 -8
  72. package/dist/es/connectors/connectScrollTo.js +6 -7
  73. package/dist/es/connectors/connectSearchBox.js +5 -11
  74. package/dist/es/connectors/connectSortBy.js +5 -12
  75. package/dist/es/connectors/connectStateResults.js +1 -1
  76. package/dist/es/connectors/connectStats.js +2 -3
  77. package/dist/es/connectors/connectToggleRefinement.js +12 -22
  78. package/dist/es/connectors/connectVoiceSearch.js +4 -16
  79. package/dist/es/core/context.js +3 -5
  80. package/dist/es/core/createConnector.js +33 -86
  81. package/dist/es/core/createInstantSearchManager.d.js +0 -0
  82. package/dist/es/core/createInstantSearchManager.js +59 -100
  83. package/dist/es/core/createWidgetsManager.js +4 -5
  84. package/dist/es/core/highlight.js +11 -17
  85. package/dist/es/core/indexUtils.js +27 -62
  86. package/dist/es/core/metadata.js +6 -8
  87. package/dist/es/core/translatable.js +13 -29
  88. package/dist/es/core/utils.js +12 -29
  89. package/dist/es/core/version.js +1 -1
  90. package/dist/es/index.js +39 -6
  91. package/dist/es/widgets/Configure.js +1 -0
  92. package/dist/es/widgets/ConfigureRelatedItems.js +0 -2
  93. package/dist/es/widgets/DynamicWidgets.js +9 -18
  94. package/dist/es/widgets/Index.js +13 -31
  95. package/dist/es/widgets/InstantSearch.js +13 -42
  96. package/dist/umd/ReactInstantSearchCore.js +507 -1078
  97. package/dist/umd/ReactInstantSearchCore.js.map +1 -1
  98. package/dist/umd/ReactInstantSearchCore.min.js +2 -2
  99. package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
  100. package/package.json +7 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present Algolia, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,13 @@
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
+
5
+ - [react-instantsearch-core](#react-instantsearch-core)
6
+
7
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
8
+
1
9
  # react-instantsearch-core
2
10
 
3
11
  This is the [React](https://facebook.github.io/react) version of Algolia's `instantsearch` library.
4
12
 
5
- Go to the [React InstantSearch website](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/) or the [React InstantSearch GitHub repository](https://github.com/algolia/react-instantsearch) for more information.
13
+ Go to the [React InstantSearch website](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/) or the [React InstantSearch GitHub repository](https://github.com/algolia/instantsearch.js) for more information.
@@ -1,44 +1,41 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ 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); }
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
8
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
15
-
16
9
  var _indexUtils = require("../core/indexUtils");
17
-
18
10
  var _utils = require("../core/utils");
19
-
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ 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); }
15
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ 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); }
18
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
19
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
+ 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; }
20
21
  var getId = function getId() {
21
22
  return 'query';
22
23
  };
23
-
24
24
  function getCurrentRefinement(props, searchState, context) {
25
25
  var id = getId();
26
26
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
27
-
28
27
  if (currentRefinement) {
29
28
  return currentRefinement;
30
29
  }
31
-
32
30
  return '';
33
31
  }
34
-
35
32
  function getHits(searchResults) {
36
33
  if (searchResults.results) {
37
34
  if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
38
35
  return (0, _utils.addAbsolutePositions)((0, _utils.addQueryID)(searchResults.results.hits, searchResults.results.queryID), searchResults.results.hitsPerPage, searchResults.results.page);
39
36
  } else {
40
37
  return Object.keys(searchResults.results).reduce(function (hits, index) {
41
- return [].concat((0, _toConsumableArray2.default)(hits), [{
38
+ return [].concat(_toConsumableArray(hits), [{
42
39
  index: index,
43
40
  hits: (0, _utils.addAbsolutePositions)((0, _utils.addQueryID)(searchResults.results[index].hits, searchResults.results[index].queryID), searchResults.results[index].hitsPerPage, searchResults.results[index].page)
44
41
  }]);
@@ -48,17 +45,16 @@ function getHits(searchResults) {
48
45
  return [];
49
46
  }
50
47
  }
51
-
52
48
  function _refine(props, searchState, nextRefinement, context) {
53
49
  var id = getId();
54
- var nextValue = (0, _defineProperty2.default)({}, id, nextRefinement);
50
+ var nextValue = _defineProperty({}, id, nextRefinement);
55
51
  var resetPage = true;
56
52
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
57
53
  }
58
-
59
54
  function _cleanUp(props, searchState, context) {
60
55
  return (0, _indexUtils.cleanUpValue)(searchState, context, getId());
61
56
  }
57
+
62
58
  /**
63
59
  * connectAutoComplete connector provides the logic to create connected
64
60
  * components that will render the results retrieved from
@@ -74,8 +70,6 @@ function _cleanUp(props, searchState, context) {
74
70
  * @providedPropType {function} refine - a function to change the query
75
71
  * @providedPropType {string} currentRefinement - the query to search for
76
72
  */
77
-
78
-
79
73
  var _default = (0, _createConnector.default)({
80
74
  displayName: 'AlgoliaAutoComplete',
81
75
  $$type: 'ais.autoComplete',
@@ -100,18 +94,6 @@ var _default = (0, _createConnector.default)({
100
94
  multiIndexContext: props.indexContextValue
101
95
  });
102
96
  },
103
-
104
- /**
105
- * AutoComplete needs to be considered as a widget to trigger a search,
106
- * even if no other widgets are used.
107
- *
108
- * To be considered as a widget you need either:
109
- * - getSearchParameters
110
- * - getMetadata
111
- * - transitionState
112
- *
113
- * See: createConnector.tsx
114
- */
115
97
  getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
116
98
  return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
117
99
  ais: props.contextValue,
@@ -119,5 +101,4 @@ var _default = (0, _createConnector.default)({
119
101
  }));
120
102
  }
121
103
  });
122
-
123
104
  exports.default = _default;
@@ -1,34 +1,28 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.getId = exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
8
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
15
-
16
9
  var _indexUtils = require("../core/indexUtils");
17
-
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ 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); }
18
15
  var getId = function getId(props) {
19
16
  return props.attributes[0];
20
17
  };
21
-
22
18
  exports.getId = getId;
23
19
  var namespace = 'hierarchicalMenu';
24
-
25
20
  function _refine(props, searchState, nextRefinement, context) {
26
21
  var id = getId(props);
27
- var nextValue = (0, _defineProperty2.default)({}, id, nextRefinement || '');
22
+ var nextValue = _defineProperty({}, id, nextRefinement || '');
28
23
  var resetPage = true;
29
24
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
30
25
  }
31
-
32
26
  function transformValue(values) {
33
27
  return values.reduce(function (acc, item) {
34
28
  if (item.isRefined) {
@@ -37,16 +31,16 @@ function transformValue(values) {
37
31
  // If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
38
32
  // If dealing with the first level, "value" is equal to the current value
39
33
  value: item.escapedValue
40
- }); // Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
41
-
34
+ });
35
+ // Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
42
36
  if (item.data) {
43
37
  acc = acc.concat(transformValue(item.data, acc));
44
38
  }
45
39
  }
46
-
47
40
  return acc;
48
41
  }, []);
49
42
  }
43
+
50
44
  /**
51
45
  * The breadcrumb component is s a type of secondary navigation scheme that
52
46
  * reveals the user’s location in a website or web application.
@@ -83,8 +77,6 @@ function transformValue(values) {
83
77
  * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
84
78
  * @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
85
79
  */
86
-
87
-
88
80
  var _default = (0, _createConnector.default)({
89
81
  displayName: 'AlgoliaBreadcrumb',
90
82
  $$type: 'ais.breadcrumb',
@@ -93,11 +85,9 @@ var _default = (0, _createConnector.default)({
93
85
  var isNotString = function isNotString(val) {
94
86
  return typeof val !== 'string';
95
87
  };
96
-
97
88
  if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
98
89
  return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
99
90
  }
100
-
101
91
  return undefined;
102
92
  },
103
93
  transformItems: _propTypes.default.func
@@ -109,14 +99,12 @@ var _default = (0, _createConnector.default)({
109
99
  multiIndexContext: props.indexContextValue
110
100
  });
111
101
  var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
112
-
113
102
  if (!isFacetPresent) {
114
103
  return {
115
104
  items: [],
116
105
  canRefine: false
117
106
  };
118
107
  }
119
-
120
108
  var values = results.getFacetValues(id);
121
109
  var items = values.data ? transformValue(values.data) : [];
122
110
  var transformedItems = props.transformItems ? props.transformItems(items) : items;
@@ -132,5 +120,4 @@ var _default = (0, _createConnector.default)({
132
120
  });
133
121
  }
134
122
  });
135
-
136
123
  exports.default = _default;
@@ -1,33 +1,26 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ 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); }
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
8
  var _utils = require("../core/utils");
15
-
16
9
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
17
-
18
10
  var _indexUtils = require("../core/indexUtils");
19
-
20
11
  var _excluded = ["children", "contextValue", "indexContextValue"],
21
- _excluded2 = ["children", "contextValue", "indexContextValue"];
22
-
12
+ _excluded2 = ["children", "contextValue", "indexContextValue"];
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
14
  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; }
24
-
25
- 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) { (0, _defineProperty2.default)(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; }
26
-
15
+ 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; }
16
+ 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; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
+ 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); }
19
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
27
21
  function getId() {
28
22
  return 'configure';
29
23
  }
30
-
31
24
  var _default = (0, _createConnector.default)({
32
25
  displayName: 'AlgoliaConfigure',
33
26
  $$type: 'ais.configure',
@@ -36,23 +29,23 @@ var _default = (0, _createConnector.default)({
36
29
  },
37
30
  getSearchParameters: function getSearchParameters(searchParameters, props) {
38
31
  var children = props.children,
39
- contextValue = props.contextValue,
40
- indexContextValue = props.indexContextValue,
41
- items = (0, _objectWithoutProperties2.default)(props, _excluded);
32
+ contextValue = props.contextValue,
33
+ indexContextValue = props.indexContextValue,
34
+ items = _objectWithoutProperties(props, _excluded);
42
35
  return searchParameters.setQueryParameters(items);
43
36
  },
44
37
  transitionState: function transitionState(props, prevSearchState, nextSearchState) {
45
38
  var id = getId();
46
39
  var children = props.children,
47
- contextValue = props.contextValue,
48
- indexContextValue = props.indexContextValue,
49
- items = (0, _objectWithoutProperties2.default)(props, _excluded2);
40
+ contextValue = props.contextValue,
41
+ indexContextValue = props.indexContextValue,
42
+ items = _objectWithoutProperties(props, _excluded2);
50
43
  var propKeys = Object.keys(props);
51
44
  var nonPresentKeys = this._props ? Object.keys(this._props).filter(function (prop) {
52
45
  return propKeys.indexOf(prop) === -1;
53
46
  }) : [];
54
47
  this._props = props;
55
- var nextValue = (0, _defineProperty2.default)({}, id, _objectSpread(_objectSpread({}, (0, _utils.omit)(nextSearchState[id], nonPresentKeys)), items));
48
+ var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, (0, _utils.omit)(nextSearchState[id], nonPresentKeys)), items));
56
49
  return (0, _indexUtils.refineValue)(nextSearchState, nextValue, {
57
50
  ais: props.contextValue,
58
51
  multiIndexContext: props.indexContextValue
@@ -73,15 +66,13 @@ var _default = (0, _createConnector.default)({
73
66
  if (!props[item]) {
74
67
  acc[item] = subState[id][item];
75
68
  }
76
-
77
69
  return acc;
78
70
  }, {});
79
- var nextValue = (0, _defineProperty2.default)({}, id, configureState);
71
+ var nextValue = _defineProperty({}, id, configureState);
80
72
  return (0, _indexUtils.refineValue)(searchState, nextValue, {
81
73
  ais: props.contextValue,
82
74
  multiIndexContext: props.indexContextValue
83
75
  });
84
76
  }
85
77
  });
86
-
87
78
  exports.default = _default;
@@ -1,54 +1,48 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
7
  var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper"));
15
-
16
8
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
17
-
18
9
  var _utils = require("../core/utils");
19
-
20
10
  var _indexUtils = require("../core/indexUtils");
21
-
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); }
13
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ 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); }
16
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
+ 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; }
22
19
  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; }
23
-
24
- 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) { (0, _defineProperty2.default)(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; }
25
-
20
+ 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; }
21
+ 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; }
22
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
+ 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); }
26
24
  function createOptionalFilter(_ref) {
27
25
  var attributeName = _ref.attributeName,
28
- attributeValue = _ref.attributeValue,
29
- attributeScore = _ref.attributeScore;
26
+ attributeValue = _ref.attributeValue,
27
+ attributeScore = _ref.attributeScore;
30
28
  return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
31
29
  }
32
-
33
30
  var defaultProps = {
34
31
  transformSearchParameters: function transformSearchParameters(x) {
35
32
  return _objectSpread({}, x);
36
33
  }
37
34
  };
38
-
39
35
  function getId() {
40
36
  // We store the search state of this widget in `configure`.
41
37
  return 'configure';
42
38
  }
43
-
44
39
  function getSearchParametersFromProps(props) {
45
40
  var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
46
41
  var attributePattern = props.matchingPatterns[attributeName];
47
42
  var attributeValue = (0, _utils.getPropertyByPath)(props.hit, attributeName);
48
43
  var attributeScore = attributePattern.score;
49
-
50
44
  if (Array.isArray(attributeValue)) {
51
- return [].concat((0, _toConsumableArray2.default)(acc), [attributeValue.map(function (attributeSubValue) {
45
+ return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
52
46
  return createOptionalFilter({
53
47
  attributeName: attributeName,
54
48
  attributeValue: attributeSubValue,
@@ -56,20 +50,17 @@ function getSearchParametersFromProps(props) {
56
50
  });
57
51
  })]);
58
52
  }
59
-
60
53
  if (typeof attributeValue === 'string') {
61
- return [].concat((0, _toConsumableArray2.default)(acc), [createOptionalFilter({
54
+ return [].concat(_toConsumableArray(acc), [createOptionalFilter({
62
55
  attributeName: attributeName,
63
56
  attributeValue: attributeValue,
64
57
  attributeScore: attributeScore
65
58
  })]);
66
59
  }
67
-
68
60
  if (process.env.NODE_ENV === 'development') {
69
61
  // eslint-disable-next-line no-console
70
62
  console.warn("The `matchingPatterns` option returned a value of type ".concat((0, _utils.getObjectType)(attributeValue), " for the \"").concat(attributeName, "\" key. This value was not sent to Algolia because `optionalFilters` only supports strings and array of strings.\n\nYou can remove the \"").concat(attributeName, "\" key from the `matchingPatterns` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/"));
71
63
  }
72
-
73
64
  return acc;
74
65
  }, []);
75
66
  return props.transformSearchParameters(new _algoliasearchHelper.default.SearchParameters({
@@ -81,7 +72,6 @@ function getSearchParametersFromProps(props) {
81
72
  optionalFilters: optionalFilters
82
73
  }));
83
74
  }
84
-
85
75
  var _default = (0, _createConnector.default)({
86
76
  displayName: 'AlgoliaConfigureRelatedItems',
87
77
  $$type: 'ais.configureRelatedItems',
@@ -93,17 +83,17 @@ var _default = (0, _createConnector.default)({
93
83
  return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
94
84
  },
95
85
  transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
96
- var id = getId(); // We need to transform the exhaustive search parameters back to clean
86
+ var id = getId();
87
+ // We need to transform the exhaustive search parameters back to clean
97
88
  // search parameters without the empty default keys so we don't pollute the
98
89
  // `configure` search state.
99
-
100
90
  var searchParameters = (0, _utils.removeEmptyArraysFromObject)((0, _utils.removeEmptyKey)(getSearchParametersFromProps(props)));
101
91
  var searchParametersKeys = Object.keys(searchParameters);
102
92
  var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
103
93
  return searchParametersKeys.indexOf(prop) === -1;
104
94
  }) : [];
105
95
  this._searchParameters = searchParameters;
106
- var nextValue = (0, _defineProperty2.default)({}, id, _objectSpread(_objectSpread({}, (0, _utils.omit)(nextSearchState[id], nonPresentKeys)), searchParameters));
96
+ var nextValue = _defineProperty({}, id, _objectSpread(_objectSpread({}, (0, _utils.omit)(nextSearchState[id], nonPresentKeys)), searchParameters));
107
97
  return (0, _indexUtils.refineValue)(nextSearchState, nextValue, {
108
98
  ais: props.contextValue,
109
99
  multiIndexContext: props.indexContextValue
@@ -111,7 +101,6 @@ var _default = (0, _createConnector.default)({
111
101
  },
112
102
  cleanUp: function cleanUp(props, searchState) {
113
103
  var _this = this;
114
-
115
104
  var id = getId();
116
105
  var indexId = (0, _indexUtils.getIndexId)({
117
106
  ais: props.contextValue,
@@ -126,15 +115,13 @@ var _default = (0, _createConnector.default)({
126
115
  if (!_this._searchParameters[item]) {
127
116
  acc[item] = subState[id][item];
128
117
  }
129
-
130
118
  return acc;
131
119
  }, {});
132
- var nextValue = (0, _defineProperty2.default)({}, id, configureState);
120
+ var nextValue = _defineProperty({}, id, configureState);
133
121
  return (0, _indexUtils.refineValue)(searchState, nextValue, {
134
122
  ais: props.contextValue,
135
123
  multiIndexContext: props.indexContextValue
136
124
  });
137
125
  }
138
126
  });
139
-
140
127
  exports.default = _default;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
8
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
15
-
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ 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); }
16
11
  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; }
17
-
18
- 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) { (0, _defineProperty2.default)(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; }
19
-
12
+ 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; }
13
+ 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; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ 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); }
20
16
  /**
21
17
  * connectCurrentRefinements connector provides the logic to build a widget that will
22
18
  * give the user the ability to remove all or some of the filters that were
@@ -44,7 +40,6 @@ var _default = (0, _createConnector.default)({
44
40
  if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
45
41
  return res;
46
42
  }
47
-
48
43
  return res.concat(meta.items.map(function (item) {
49
44
  return _objectSpread(_objectSpread({}, item), {}, {
50
45
  id: meta.id,
@@ -53,7 +48,6 @@ var _default = (0, _createConnector.default)({
53
48
  }));
54
49
  }
55
50
  }
56
-
57
51
  return res;
58
52
  }, []);
59
53
  var transformedItems = props.transformItems ? props.transformItems(items) : items;
@@ -72,5 +66,4 @@ var _default = (0, _createConnector.default)({
72
66
  }, searchState);
73
67
  }
74
68
  });
75
-
76
69
  exports.default = _default;
@@ -1,20 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
-
10
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
8
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
13
-
14
9
  var _indexUtils = require("../core/indexUtils");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ // @ts-ignore
15
12
 
16
13
  var MAX_WILDCARD_FACETS = 20;
17
-
18
14
  var _default = (0, _createConnector.default)({
19
15
  displayName: 'AlgoliaDynamicWidgets',
20
16
  $$type: 'ais.dynamicWidgets',
@@ -34,32 +30,26 @@ var _default = (0, _createConnector.default)({
34
30
  ais: props.contextValue,
35
31
  multiIndexContext: props.indexContextValue
36
32
  });
37
-
38
33
  if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
39
34
  throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
40
35
  }
41
-
42
36
  if (!results) {
43
37
  return {
44
38
  attributesToRender: []
45
39
  };
46
40
  }
47
-
48
41
  var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
49
42
  var attributesToRender = props.transformItems(facetOrder, {
50
43
  results: results
51
44
  });
52
-
53
45
  if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
54
46
  // eslint-disable-next-line no-console
55
47
  console.warn("More than ".concat(MAX_WILDCARD_FACETS, " facets are requested to be displayed without explicitly setting which facets to retrieve. This could have a performance impact. Set \"facets\" to [] to do two smaller network requests, or explicitly to ['*'] to avoid this warning."));
56
48
  }
57
-
58
49
  if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
59
50
  // eslint-disable-next-line no-console
60
51
  console.warn("The maxValuesPerFacet set by dynamic widgets (".concat(props.maxValuesPerFacet, ") is smaller than one of the limits set by a widget (").concat(results._state.maxValuesPerFacet, "). This causes a mismatch in query parameters and thus an extra network request when that widget is mounted."));
61
52
  }
62
-
63
53
  return {
64
54
  attributesToRender: attributesToRender
65
55
  };
@@ -72,5 +62,4 @@ var _default = (0, _createConnector.default)({
72
62
  }));
73
63
  }
74
64
  });
75
-
76
65
  exports.default = _default;