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
@@ -1,52 +1,45 @@
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
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
-
16
8
  var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
17
-
18
9
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
19
-
20
10
  var _indexUtils = require("../core/indexUtils");
21
-
22
11
  var _utils = require("../core/utils");
23
-
24
12
  var _excluded = ["page"];
25
-
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ 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; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
+ 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); }
17
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
18
+ 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."); }
19
+ 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); }
20
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
+ 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; }
23
+ 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; }
24
+ 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; }
26
25
  function getId() {
27
26
  return 'page';
28
27
  }
29
-
30
28
  function getCurrentRefinement(props, searchState, context) {
31
29
  var id = getId();
32
30
  var page = 1;
33
31
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, page);
34
-
35
32
  if (typeof currentRefinement === 'string') {
36
33
  return parseInt(currentRefinement, 10);
37
34
  }
38
-
39
35
  return currentRefinement;
40
36
  }
41
-
42
37
  function getStateWithoutPage(state) {
43
38
  var _ref = state || {},
44
- page = _ref.page,
45
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
46
-
39
+ page = _ref.page,
40
+ rest = _objectWithoutProperties(_ref, _excluded);
47
41
  return rest;
48
42
  }
49
-
50
43
  function getInMemoryCache() {
51
44
  var cachedHits = undefined;
52
45
  var cachedState = undefined;
@@ -57,13 +50,12 @@ function getInMemoryCache() {
57
50
  },
58
51
  write: function write(_ref3) {
59
52
  var state = _ref3.state,
60
- hits = _ref3.hits;
53
+ hits = _ref3.hits;
61
54
  cachedState = getStateWithoutPage(state);
62
55
  cachedHits = hits;
63
56
  }
64
57
  };
65
58
  }
66
-
67
59
  function extractHitsFromCachedHits(cachedHits) {
68
60
  return Object.keys(cachedHits).map(Number).sort(function (a, b) {
69
61
  return a - b;
@@ -71,6 +63,7 @@ function extractHitsFromCachedHits(cachedHits) {
71
63
  return acc.concat(cachedHits[page]);
72
64
  }, []);
73
65
  }
66
+
74
67
  /**
75
68
  * InfiniteHits connector provides the logic to create connected
76
69
  * components that will render an continuous list of results retrieved from
@@ -81,19 +74,15 @@ function extractHitsFromCachedHits(cachedHits) {
81
74
  * @providedPropType {boolean} hasMore - indicates if there are more pages to load
82
75
  * @providedPropType {function} refine - call to load more results
83
76
  */
84
-
85
-
86
77
  var _default = (0, _createConnector.default)({
87
78
  displayName: 'AlgoliaInfiniteHits',
88
79
  $$type: 'ais.infiniteHits',
89
80
  getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
90
81
  var _this = this;
91
-
92
82
  var results = (0, _indexUtils.getResults)(searchResults, {
93
83
  ais: props.contextValue,
94
84
  multiIndexContext: props.indexContextValue
95
85
  });
96
-
97
86
  if (!results) {
98
87
  return {
99
88
  hits: [],
@@ -104,12 +93,11 @@ var _default = (0, _createConnector.default)({
104
93
  refineNext: function refineNext() {}
105
94
  };
106
95
  }
107
-
108
96
  var page = results.page,
109
- hits = results.hits,
110
- hitsPerPage = results.hitsPerPage,
111
- nbPages = results.nbPages,
112
- state = results._state;
97
+ hits = results.hits,
98
+ hitsPerPage = results.hitsPerPage,
99
+ nbPages = results.nbPages,
100
+ state = results._state;
113
101
  this._cache = props.cache ? props.cache : this._cache || getInMemoryCache();
114
102
  var cachedHits = this._cache.read({
115
103
  state: state
@@ -117,31 +105,26 @@ var _default = (0, _createConnector.default)({
117
105
  var hitsWithPositions = (0, _utils.addAbsolutePositions)(hits, hitsPerPage, page);
118
106
  var hitsWithPositionsAndQueryID = (0, _utils.addQueryID)(hitsWithPositions, results.queryID);
119
107
  cachedHits[page] = hitsWithPositionsAndQueryID;
120
-
121
108
  this._cache.write({
122
109
  state: state,
123
110
  hits: cachedHits
124
111
  });
112
+
125
113
  /*
126
114
  Math.min() and Math.max() returns Infinity or -Infinity when no argument is given.
127
115
  But there is always something in this point because of `cachedHits[page]`.
128
116
  */
129
-
130
-
131
- var firstReceivedPage = Math.min.apply(Math, (0, _toConsumableArray2.default)(Object.keys(cachedHits).map(Number)));
132
- var lastReceivedPage = Math.max.apply(Math, (0, _toConsumableArray2.default)(Object.keys(cachedHits).map(Number)));
117
+ var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
118
+ var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
133
119
  var hasPrevious = firstReceivedPage > 0;
134
120
  var lastPageIndex = nbPages - 1;
135
121
  var hasMore = lastReceivedPage < lastPageIndex;
136
-
137
122
  var refinePrevious = function refinePrevious(event) {
138
123
  return _this.refine(event, firstReceivedPage - 1);
139
124
  };
140
-
141
125
  var refineNext = function refineNext(event) {
142
126
  return _this.refine(event, lastReceivedPage + 1);
143
127
  };
144
-
145
128
  return {
146
129
  hits: extractHitsFromCachedHits(cachedHits),
147
130
  hasPrevious: hasPrevious,
@@ -160,7 +143,7 @@ var _default = (0, _createConnector.default)({
160
143
  },
161
144
  refine: function refine(props, searchState, event, index) {
162
145
  var id = getId();
163
- var nextValue = (0, _defineProperty2.default)({}, id, index + 1);
146
+ var nextValue = _defineProperty({}, id, index + 1);
164
147
  var resetPage = false;
165
148
  return (0, _indexUtils.refineValue)(searchState, nextValue, {
166
149
  ais: props.contextValue,
@@ -168,5 +151,4 @@ var _default = (0, _createConnector.default)({
168
151
  }, resetPage);
169
152
  }
170
153
  });
171
-
172
154
  exports.default = _default;
@@ -1,62 +1,50 @@
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
-
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 _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 _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
  var namespace = 'menu';
21
-
22
17
  function getId(props) {
23
18
  return props.attribute;
24
19
  }
25
-
26
20
  function getCurrentRefinement(props, searchState, context) {
27
21
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), null);
28
-
29
22
  if (currentRefinement === '') {
30
23
  return null;
31
24
  }
32
-
33
25
  return currentRefinement;
34
26
  }
35
-
36
27
  function getValue(value, props, searchState, context) {
37
28
  var currentRefinement = getCurrentRefinement(props, searchState, context);
38
29
  return value === currentRefinement ? '' : value;
39
30
  }
40
-
41
31
  function getLimit(_ref) {
42
32
  var showMore = _ref.showMore,
43
- limit = _ref.limit,
44
- showMoreLimit = _ref.showMoreLimit;
33
+ limit = _ref.limit,
34
+ showMoreLimit = _ref.showMoreLimit;
45
35
  return showMore ? showMoreLimit : limit;
46
36
  }
47
-
48
37
  function _refine(props, searchState, nextRefinement, context) {
49
38
  var id = getId(props);
50
- var nextValue = (0, _defineProperty2.default)({}, id, nextRefinement ? nextRefinement : '');
39
+ var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : '');
51
40
  var resetPage = true;
52
41
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
53
42
  }
54
-
55
43
  function _cleanUp(props, searchState, context) {
56
44
  return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
57
45
  }
58
-
59
46
  var defaultSortBy = ['count:desc', 'name:asc'];
47
+
60
48
  /**
61
49
  * connectMenu connector provides the logic to build a widget that will
62
50
  * give the user the ability to choose a single value for a specific facet.
@@ -77,7 +65,6 @@ var defaultSortBy = ['count:desc', 'name:asc'];
77
65
  * @providedPropType {function} searchForItems - a function to toggle a search inside items values
78
66
  * @providedPropType {boolean} isFromSearch - a boolean that says if the `items` props contains facet values from the global search or from the search inside items.
79
67
  */
80
-
81
68
  var _default = (0, _createConnector.default)({
82
69
  displayName: 'AlgoliaMenu',
83
70
  $$type: 'ais.menu',
@@ -99,20 +86,20 @@ var _default = (0, _createConnector.default)({
99
86
  },
100
87
  getProvidedProps: function getProvidedProps(props, searchState, searchResults, meta, searchForFacetValuesResults) {
101
88
  var attribute = props.attribute,
102
- searchable = props.searchable,
103
- indexContextValue = props.indexContextValue,
104
- facetOrdering = props.facetOrdering;
89
+ searchable = props.searchable,
90
+ indexContextValue = props.indexContextValue,
91
+ facetOrdering = props.facetOrdering;
105
92
  var results = (0, _indexUtils.getResults)(searchResults, {
106
93
  ais: props.contextValue,
107
94
  multiIndexContext: props.indexContextValue
108
95
  });
109
96
  var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
110
- var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== ''); // Search For Facet Values is not available with derived helper (used for multi index search)
97
+ var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
111
98
 
99
+ // Search For Facet Values is not available with derived helper (used for multi index search)
112
100
  if (searchable && indexContextValue) {
113
101
  throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
114
102
  }
115
-
116
103
  if (!canRefine) {
117
104
  return {
118
105
  items: [],
@@ -125,9 +112,7 @@ var _default = (0, _createConnector.default)({
125
112
  canRefine: canRefine
126
113
  };
127
114
  }
128
-
129
115
  var items;
130
-
131
116
  if (isFromSearch) {
132
117
  items = searchForFacetValuesResults[attribute].map(function (v) {
133
118
  return {
@@ -161,7 +146,6 @@ var _default = (0, _createConnector.default)({
161
146
  };
162
147
  });
163
148
  }
164
-
165
149
  var transformedItems = props.transformItems ? props.transformItems(items) : items;
166
150
  return {
167
151
  items: transformedItems.slice(0, getLimit(props)),
@@ -203,11 +187,9 @@ var _default = (0, _createConnector.default)({
203
187
  ais: props.contextValue,
204
188
  multiIndexContext: props.indexContextValue
205
189
  });
206
-
207
190
  if (currentRefinement !== null) {
208
191
  searchParameters = searchParameters.addDisjunctiveFacetRefinement(attribute, currentRefinement);
209
192
  }
210
-
211
193
  return searchParameters;
212
194
  },
213
195
  getMetadata: function getMetadata(props, searchState) {
@@ -236,5 +218,4 @@ var _default = (0, _createConnector.default)({
236
218
  };
237
219
  }
238
220
  });
239
-
240
221
  exports.default = _default;
@@ -1,34 +1,32 @@
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
-
16
9
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
17
-
18
10
  var _utils = require("../core/utils");
19
-
20
11
  var _indexUtils = require("../core/indexUtils");
21
-
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
16
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
+ 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."); }
18
+ 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); }
19
+ 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
+ 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; } }
21
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
22
  function stringifyItem(item) {
23
23
  if (typeof item.start === 'undefined' && typeof item.end === 'undefined') {
24
24
  return '';
25
25
  }
26
-
27
26
  var start = typeof item.start !== 'undefined' ? item.start : '';
28
27
  var end = typeof item.end !== 'undefined' ? item.end : '';
29
28
  return "".concat(start, ":").concat(end);
30
29
  }
31
-
32
30
  function parseItem(value) {
33
31
  if (value.length === 0) {
34
32
  return {
@@ -36,42 +34,33 @@ function parseItem(value) {
36
34
  end: null
37
35
  };
38
36
  }
39
-
40
37
  var _value$split = value.split(':'),
41
- _value$split2 = (0, _slicedToArray2.default)(_value$split, 2),
42
- startStr = _value$split2[0],
43
- endStr = _value$split2[1];
44
-
38
+ _value$split2 = _slicedToArray(_value$split, 2),
39
+ startStr = _value$split2[0],
40
+ endStr = _value$split2[1];
45
41
  return {
46
42
  start: startStr.length > 0 ? parseFloat(startStr) : null,
47
43
  end: endStr.length > 0 ? parseFloat(endStr) : null
48
44
  };
49
45
  }
50
-
51
46
  var namespace = 'multiRange';
52
-
53
47
  function getId(props) {
54
48
  return props.attribute;
55
49
  }
56
-
57
50
  function getCurrentRefinement(props, searchState, context) {
58
51
  return (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), '', function (currentRefinement) {
59
52
  if (currentRefinement === '') {
60
53
  return '';
61
54
  }
62
-
63
55
  return currentRefinement;
64
56
  });
65
57
  }
66
-
67
58
  function isRefinementsRangeIncludesInsideItemRange(stats, start, end) {
68
59
  return stats.min >= start && stats.min <= end || stats.max >= start && stats.max <= end;
69
60
  }
70
-
71
61
  function isItemRangeIncludedInsideRefinementsRange(stats, start, end) {
72
62
  return start >= stats.min && start <= stats.max || end >= stats.min && end <= stats.max;
73
63
  }
74
-
75
64
  function itemHasRefinement(attribute, results, value) {
76
65
  var stats = results.getFacetByName(attribute) ? results.getFacetStats(attribute) : null;
77
66
  var range = value.split(':');
@@ -79,16 +68,15 @@ function itemHasRefinement(attribute, results, value) {
79
68
  var end = Number(range[1]) === 0 || value === '' ? Number.POSITIVE_INFINITY : Number(range[1]);
80
69
  return !(Boolean(stats) && (isRefinementsRangeIncludesInsideItemRange(stats, start, end) || isItemRangeIncludedInsideRefinementsRange(stats, start, end)));
81
70
  }
82
-
83
71
  function _refine(props, searchState, nextRefinement, context) {
84
- var nextValue = (0, _defineProperty2.default)({}, getId(props, searchState), nextRefinement);
72
+ var nextValue = _defineProperty({}, getId(props, searchState), nextRefinement);
85
73
  var resetPage = true;
86
74
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
87
75
  }
88
-
89
76
  function _cleanUp(props, searchState, context) {
90
77
  return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
91
78
  }
79
+
92
80
  /**
93
81
  * connectNumericMenu connector provides the logic to build a widget that will
94
82
  * give the user the ability to select a range value for a numeric attribute.
@@ -105,8 +93,6 @@ function _cleanUp(props, searchState, context) {
105
93
  * @providedPropType {string} currentRefinement - the refinement currently applied. follow the shape of a `string` with a pattern of `'{start}:{end}'` which corresponds to the current selected item. For instance, when the selected item is `{start: 10, end: 20}`, the searchState of the widget is `'10:20'`. When `start` isn't defined, the searchState of the widget is `':{end}'`, and the same way around when `end` isn't defined. However, when neither `start` nor `end` are defined, the searchState is an empty string.
106
94
  * @providedPropType {array.<{isRefined: boolean, label: string, value: string, isRefined: boolean, noRefinement: boolean}>} items - the list of ranges the NumericMenu can display.
107
95
  */
108
-
109
-
110
96
  var _default = (0, _createConnector.default)({
111
97
  displayName: 'AlgoliaNumericMenu',
112
98
  $$type: 'ais.numericMenu',
@@ -143,7 +129,6 @@ var _default = (0, _createConnector.default)({
143
129
  var refinedItem = (0, _utils.find)(items, function (item) {
144
130
  return item.isRefined === true;
145
131
  });
146
-
147
132
  if (!items.some(function (item) {
148
133
  return item.value === '';
149
134
  })) {
@@ -154,7 +139,6 @@ var _default = (0, _createConnector.default)({
154
139
  label: 'All'
155
140
  });
156
141
  }
157
-
158
142
  var transformedItems = props.transformItems ? props.transformItems(items) : items;
159
143
  return {
160
144
  items: transformedItems,
@@ -178,24 +162,19 @@ var _default = (0, _createConnector.default)({
178
162
  },
179
163
  getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
180
164
  var attribute = props.attribute;
181
-
182
165
  var _parseItem = parseItem(getCurrentRefinement(props, searchState, {
183
- ais: props.contextValue,
184
- multiIndexContext: props.indexContextValue
185
- })),
186
- start = _parseItem.start,
187
- end = _parseItem.end;
188
-
166
+ ais: props.contextValue,
167
+ multiIndexContext: props.indexContextValue
168
+ })),
169
+ start = _parseItem.start,
170
+ end = _parseItem.end;
189
171
  searchParameters = searchParameters.addDisjunctiveFacet(attribute);
190
-
191
172
  if (typeof start === 'number') {
192
173
  searchParameters = searchParameters.addNumericRefinement(attribute, '>=', start);
193
174
  }
194
-
195
175
  if (typeof end === 'number') {
196
176
  searchParameters = searchParameters.addNumericRefinement(attribute, '<=', end);
197
177
  }
198
-
199
178
  return searchParameters;
200
179
  },
201
180
  getMetadata: function getMetadata(props, searchState) {
@@ -209,13 +188,11 @@ var _default = (0, _createConnector.default)({
209
188
  ais: props.contextValue,
210
189
  multiIndexContext: props.indexContextValue
211
190
  });
212
-
213
191
  if (value !== '') {
214
192
  var _find = (0, _utils.find)(props.items, function (item) {
215
- return stringifyItem(item) === value;
216
- }),
217
- label = _find.label;
218
-
193
+ return stringifyItem(item) === value;
194
+ }),
195
+ label = _find.label;
219
196
  items.push({
220
197
  label: "".concat(props.attribute, ": ").concat(label),
221
198
  attribute: props.attribute,
@@ -228,7 +205,6 @@ var _default = (0, _createConnector.default)({
228
205
  }
229
206
  });
230
207
  }
231
-
232
208
  return {
233
209
  id: id,
234
210
  index: index,
@@ -236,5 +212,4 @@ var _default = (0, _createConnector.default)({
236
212
  };
237
213
  }
238
214
  });
239
-
240
215
  exports.default = _default;
@@ -1,40 +1,35 @@
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 _createConnector = _interopRequireDefault(require("../core/createConnector"));
13
-
14
8
  var _indexUtils = require("../core/indexUtils");
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); }
11
+ 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; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
+ 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); }
16
14
  function getId() {
17
15
  return 'page';
18
16
  }
19
-
20
17
  function getCurrentRefinement(props, searchState, context) {
21
18
  var id = getId();
22
19
  var page = 1;
23
20
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, page);
24
-
25
21
  if (typeof currentRefinement === 'string') {
26
22
  return parseInt(currentRefinement, 10);
27
23
  }
28
-
29
24
  return currentRefinement;
30
25
  }
31
-
32
26
  function _refine(props, searchState, nextPage, context) {
33
27
  var id = getId();
34
- var nextValue = (0, _defineProperty2.default)({}, id, nextPage);
28
+ var nextValue = _defineProperty({}, id, nextPage);
35
29
  var resetPage = false;
36
30
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
37
31
  }
32
+
38
33
  /**
39
34
  * connectPagination connector provides the logic to build a widget that will
40
35
  * let the user displays hits corresponding to a certain page.
@@ -51,8 +46,6 @@ function _refine(props, searchState, nextPage, context) {
51
46
  * @providedPropType {number} nbPages - the total of existing pages
52
47
  * @providedPropType {number} currentRefinement - the page refinement currently applied
53
48
  */
54
-
55
-
56
49
  var _default = (0, _createConnector.default)({
57
50
  displayName: 'AlgoliaPagination',
58
51
  $$type: 'ais.pagination',
@@ -61,11 +54,9 @@ var _default = (0, _createConnector.default)({
61
54
  ais: props.contextValue,
62
55
  multiIndexContext: props.indexContextValue
63
56
  });
64
-
65
57
  if (!results) {
66
58
  return null;
67
59
  }
68
-
69
60
  var nbPages = results.nbPages;
70
61
  return {
71
62
  nbPages: nbPages,
@@ -100,5 +91,4 @@ var _default = (0, _createConnector.default)({
100
91
  };
101
92
  }
102
93
  });
103
-
104
94
  exports.default = _default;
@@ -1,14 +1,11 @@
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 _createConnector = _interopRequireDefault(require("../core/createConnector"));
11
-
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
9
  /**
13
10
  * connectPoweredBy connector provides the logic to build a widget that
14
11
  * will display a link to algolia.
@@ -27,5 +24,4 @@ var _default = (0, _createConnector.default)({
27
24
  };
28
25
  }
29
26
  });
30
-
31
27
  exports.default = _default;