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,24 +1,20 @@
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 = ["defaultRefinement"];
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 _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; }
17
+ 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; }
22
18
  /**
23
19
  * The GeoSearch connector provides the logic to build a widget that will display the results on a map.
24
20
  * It also provides a way to search for results based on their position. The connector provides function to manage the search experience (search on map interaction).
@@ -35,24 +31,21 @@ var _excluded = ["defaultRefinement"];
35
31
  * @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied
36
32
  * @providedPropType {{ lat: number, lng: number }} [position] - the position of the search
37
33
  */
34
+
38
35
  // To control the map with an external widget the other widget
39
36
  // **must** write the value in the attribute `aroundLatLng`
40
37
  var getBoundingBoxId = function getBoundingBoxId() {
41
38
  return 'boundingBox';
42
39
  };
43
-
44
40
  var getAroundLatLngId = function getAroundLatLngId() {
45
41
  return 'aroundLatLng';
46
42
  };
47
-
48
43
  var getConfigureAroundLatLngId = function getConfigureAroundLatLngId() {
49
44
  return 'configure.aroundLatLng';
50
45
  };
51
-
52
46
  var currentRefinementToString = function currentRefinementToString(currentRefinement) {
53
47
  return [currentRefinement.northEast.lat, currentRefinement.northEast.lng, currentRefinement.southWest.lat, currentRefinement.southWest.lng].join();
54
48
  };
55
-
56
49
  var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
57
50
  var values = value.split(',');
58
51
  return {
@@ -66,9 +59,7 @@ var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
66
59
  }
67
60
  };
68
61
  };
69
-
70
62
  var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
71
-
72
63
  var stringToPosition = function stringToPosition(value) {
73
64
  var pattern = value.match(latLngRegExp);
74
65
  return {
@@ -76,15 +67,13 @@ var stringToPosition = function stringToPosition(value) {
76
67
  lng: parseFloat(pattern[2])
77
68
  };
78
69
  };
79
-
80
70
  var getCurrentRefinement = function getCurrentRefinement(props, searchState, context) {
81
71
  var refinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, getBoundingBoxId(), {});
82
-
83
72
  if (!(0, _utils.objectHasKeys)(refinement)) {
84
73
  return;
85
- } // eslint-disable-next-line consistent-return
86
-
74
+ }
87
75
 
76
+ // eslint-disable-next-line consistent-return
88
77
  return {
89
78
  northEast: {
90
79
  lat: parseFloat(refinement.northEast.lat),
@@ -96,27 +85,22 @@ var getCurrentRefinement = function getCurrentRefinement(props, searchState, con
96
85
  }
97
86
  };
98
87
  };
99
-
100
88
  var getCurrentPosition = function getCurrentPosition(props, searchState, context) {
101
89
  var defaultRefinement = props.defaultRefinement,
102
- propsWithoutDefaultRefinement = (0, _objectWithoutProperties2.default)(props, _excluded);
90
+ propsWithoutDefaultRefinement = _objectWithoutProperties(props, _excluded);
103
91
  var aroundLatLng = (0, _indexUtils.getCurrentRefinementValue)(propsWithoutDefaultRefinement, searchState, context, getAroundLatLngId());
104
-
105
92
  if (!aroundLatLng) {
106
93
  // Fallback on `configure.aroundLatLng`
107
94
  var configureAroundLatLng = (0, _indexUtils.getCurrentRefinementValue)(propsWithoutDefaultRefinement, searchState, context, getConfigureAroundLatLngId());
108
95
  return configureAroundLatLng && stringToPosition(configureAroundLatLng);
109
96
  }
110
-
111
97
  return aroundLatLng;
112
98
  };
113
-
114
99
  var _refine = function refine(searchState, nextValue, context) {
115
100
  var resetPage = true;
116
- var nextRefinement = (0, _defineProperty2.default)({}, getBoundingBoxId(), nextValue);
101
+ var nextRefinement = _defineProperty({}, getBoundingBoxId(), nextValue);
117
102
  return (0, _indexUtils.refineValue)(searchState, nextRefinement, context, resetPage);
118
103
  };
119
-
120
104
  var _default = (0, _createConnector.default)({
121
105
  displayName: 'AlgoliaGeoSearch',
122
106
  $$type: 'ais.geoSearch',
@@ -125,7 +109,9 @@ var _default = (0, _createConnector.default)({
125
109
  ais: props.contextValue,
126
110
  multiIndexContext: props.indexContextValue
127
111
  };
128
- var results = (0, _indexUtils.getResults)(searchResults, context); // We read it from both because the SearchParameters & the searchState are not always
112
+ var results = (0, _indexUtils.getResults)(searchResults, context);
113
+
114
+ // We read it from both because the SearchParameters & the searchState are not always
129
115
  // in sync. When we set the refinement the searchState is used but when we clear the refinement
130
116
  // the SearchParameters is used. In the first case when we render, the results are not there
131
117
  // so we can't find the value from the results. The most up to date value is the searchState.
@@ -160,11 +146,9 @@ var _default = (0, _createConnector.default)({
160
146
  ais: props.contextValue,
161
147
  multiIndexContext: props.indexContextValue
162
148
  });
163
-
164
149
  if (!currentRefinement) {
165
150
  return searchParameters;
166
151
  }
167
-
168
152
  return searchParameters.setQueryParameter('insideBoundingBox', currentRefinementToString(currentRefinement));
169
153
  },
170
154
  cleanUp: function cleanUp(props, searchState) {
@@ -183,7 +167,6 @@ var _default = (0, _createConnector.default)({
183
167
  var index = (0, _indexUtils.getIndexId)(context);
184
168
  var nextRefinement = {};
185
169
  var currentRefinement = getCurrentRefinement(props, searchState, context);
186
-
187
170
  if (currentRefinement) {
188
171
  items.push({
189
172
  label: "".concat(id, ": ").concat(currentRefinementToString(currentRefinement)),
@@ -193,7 +176,6 @@ var _default = (0, _createConnector.default)({
193
176
  currentRefinement: currentRefinement
194
177
  });
195
178
  }
196
-
197
179
  return {
198
180
  id: id,
199
181
  index: index,
@@ -204,5 +186,4 @@ var _default = (0, _createConnector.default)({
204
186
  return true;
205
187
  }
206
188
  });
207
-
208
189
  exports.default = _default;
@@ -1,54 +1,41 @@
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 _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper"));
15
-
16
9
  var _createConnector = _interopRequireDefault(require("../core/createConnector"));
17
-
18
10
  var _indexUtils = require("../core/indexUtils");
19
-
20
11
  var _utils = require("../core/utils");
21
-
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
22
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; }
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
-
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); }
26
19
  var getId = function getId(props) {
27
20
  return props.attributes[0];
28
21
  };
29
-
30
22
  exports.getId = getId;
31
23
  var namespace = 'hierarchicalMenu';
32
-
33
24
  function getCurrentRefinement(props, searchState, context) {
34
25
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), null);
35
-
36
26
  if (currentRefinement === '') {
37
27
  return null;
38
28
  }
39
-
40
29
  return currentRefinement;
41
30
  }
42
-
43
31
  function getValue(value, props, searchState, context) {
44
32
  var id = props.id,
45
- attributes = props.attributes,
46
- separator = props.separator,
47
- rootPath = props.rootPath,
48
- showParentLevel = props.showParentLevel;
33
+ attributes = props.attributes,
34
+ separator = props.separator,
35
+ rootPath = props.rootPath,
36
+ showParentLevel = props.showParentLevel;
49
37
  var currentRefinement = getCurrentRefinement(props, searchState, context);
50
38
  var nextRefinement;
51
-
52
39
  if (currentRefinement === null) {
53
40
  nextRefinement = value;
54
41
  } else {
@@ -63,10 +50,8 @@ function getValue(value, props, searchState, context) {
63
50
  });
64
51
  nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
65
52
  }
66
-
67
53
  return nextRefinement;
68
54
  }
69
-
70
55
  function transformValue(value, props, searchState, context) {
71
56
  return value.map(function (v) {
72
57
  return {
@@ -78,7 +63,6 @@ function transformValue(value, props, searchState, context) {
78
63
  };
79
64
  });
80
65
  }
81
-
82
66
  var truncate = function truncate() {
83
67
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
84
68
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
@@ -89,19 +73,17 @@ var truncate = function truncate() {
89
73
  }) : item;
90
74
  });
91
75
  };
92
-
93
76
  function _refine(props, searchState, nextRefinement, context) {
94
77
  var id = getId(props);
95
- var nextValue = (0, _defineProperty2.default)({}, id, nextRefinement || '');
78
+ var nextValue = _defineProperty({}, id, nextRefinement || '');
96
79
  var resetPage = true;
97
80
  return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
98
81
  }
99
-
100
82
  function _cleanUp(props, searchState, context) {
101
83
  return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
102
84
  }
103
-
104
85
  var sortBy = ['name:asc'];
86
+
105
87
  /**
106
88
  * connectHierarchicalMenu connector provides the logic to build a widget that will
107
89
  * give the user the ability to explore a tree-like structure.
@@ -147,7 +129,6 @@ var sortBy = ['name:asc'];
147
129
  * @providedPropType {string} currentRefinement - the refinement currently applied
148
130
  * @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the HierarchicalMenu can display. items has the same shape as parent items.
149
131
  */
150
-
151
132
  var _default = (0, _createConnector.default)({
152
133
  displayName: 'AlgoliaHierarchicalMenu',
153
134
  $$type: 'ais.hierarchicalMenu',
@@ -156,11 +137,9 @@ var _default = (0, _createConnector.default)({
156
137
  var isNotString = function isNotString(val) {
157
138
  return typeof val !== 'string';
158
139
  };
159
-
160
140
  if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
161
141
  return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
162
142
  }
163
-
164
143
  return undefined;
165
144
  },
166
145
  separator: _propTypes.default.string,
@@ -184,16 +163,15 @@ var _default = (0, _createConnector.default)({
184
163
  },
185
164
  getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
186
165
  var showMore = props.showMore,
187
- limit = props.limit,
188
- showMoreLimit = props.showMoreLimit,
189
- facetOrdering = props.facetOrdering;
166
+ limit = props.limit,
167
+ showMoreLimit = props.showMoreLimit,
168
+ facetOrdering = props.facetOrdering;
190
169
  var id = getId(props);
191
170
  var results = (0, _indexUtils.getResults)(searchResults, {
192
171
  ais: props.contextValue,
193
172
  multiIndexContext: props.indexContextValue
194
173
  });
195
174
  var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
196
-
197
175
  if (!isFacetPresent) {
198
176
  return {
199
177
  items: [],
@@ -204,7 +182,6 @@ var _default = (0, _createConnector.default)({
204
182
  canRefine: false
205
183
  };
206
184
  }
207
-
208
185
  var itemsLimit = showMore ? showMoreLimit : limit;
209
186
  var value = results.getFacetValues(id, {
210
187
  sortBy: sortBy,
@@ -238,13 +215,13 @@ var _default = (0, _createConnector.default)({
238
215
  },
239
216
  getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
240
217
  var attributes = props.attributes,
241
- separator = props.separator,
242
- rootPath = props.rootPath,
243
- showParentLevel = props.showParentLevel,
244
- showMore = props.showMore,
245
- limit = props.limit,
246
- showMoreLimit = props.showMoreLimit,
247
- contextValue = props.contextValue;
218
+ separator = props.separator,
219
+ rootPath = props.rootPath,
220
+ showParentLevel = props.showParentLevel,
221
+ showMore = props.showMore,
222
+ limit = props.limit,
223
+ showMoreLimit = props.showMoreLimit,
224
+ contextValue = props.contextValue;
248
225
  var id = getId(props);
249
226
  var itemsLimit = showMore ? showMoreLimit : limit;
250
227
  searchParameters = searchParameters.addHierarchicalFacet({
@@ -260,11 +237,9 @@ var _default = (0, _createConnector.default)({
260
237
  ais: contextValue,
261
238
  multiIndexContext: props.indexContextValue
262
239
  });
263
-
264
240
  if (currentRefinement !== null) {
265
241
  searchParameters = searchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement);
266
242
  }
267
-
268
243
  return searchParameters;
269
244
  },
270
245
  getMetadata: function getMetadata(props, searchState) {
@@ -295,5 +270,4 @@ var _default = (0, _createConnector.default)({
295
270
  };
296
271
  }
297
272
  });
298
-
299
273
  exports.default = _default;
@@ -1,24 +1,20 @@
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
-
12
8
  var _highlight = require("../core/highlight");
13
-
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
10
  var highlight = function highlight(_ref) {
15
11
  var attribute = _ref.attribute,
16
- hit = _ref.hit,
17
- highlightProperty = _ref.highlightProperty,
18
- _ref$preTag = _ref.preTag,
19
- preTag = _ref$preTag === void 0 ? _highlight.HIGHLIGHT_TAGS.highlightPreTag : _ref$preTag,
20
- _ref$postTag = _ref.postTag,
21
- postTag = _ref$postTag === void 0 ? _highlight.HIGHLIGHT_TAGS.highlightPostTag : _ref$postTag;
12
+ hit = _ref.hit,
13
+ highlightProperty = _ref.highlightProperty,
14
+ _ref$preTag = _ref.preTag,
15
+ preTag = _ref$preTag === void 0 ? _highlight.HIGHLIGHT_TAGS.highlightPreTag : _ref$preTag,
16
+ _ref$postTag = _ref.postTag,
17
+ postTag = _ref$postTag === void 0 ? _highlight.HIGHLIGHT_TAGS.highlightPostTag : _ref$postTag;
22
18
  return (0, _highlight.parseAlgoliaHit)({
23
19
  attribute: attribute,
24
20
  highlightProperty: highlightProperty,
@@ -27,6 +23,7 @@ var highlight = function highlight(_ref) {
27
23
  postTag: postTag
28
24
  });
29
25
  };
26
+
30
27
  /**
31
28
  * connectHighlight connector provides the logic to create an highlighter
32
29
  * component that will retrieve, parse and render an highlighted attribute
@@ -77,8 +74,6 @@ var highlight = function highlight(_ref) {
77
74
  * </InstantSearch>
78
75
  * );
79
76
  */
80
-
81
-
82
77
  var _default = (0, _createConnector.default)({
83
78
  displayName: 'AlgoliaHighlighter',
84
79
  $$type: 'ais.highlighter',
@@ -89,5 +84,4 @@ var _default = (0, _createConnector.default)({
89
84
  };
90
85
  }
91
86
  });
92
-
93
87
  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.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); }
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
  function inferPayload(_ref) {
21
17
  var method = _ref.method,
22
- results = _ref.results,
23
- currentHit = _ref.currentHit;
18
+ results = _ref.results,
19
+ currentHit = _ref.currentHit;
24
20
  var index = results.index;
25
21
  var queryID = currentHit.__queryID;
26
22
  var objectIDs = [currentHit.objectID];
27
-
28
23
  if (!queryID) {
29
24
  throw new Error("Could not infer `queryID`. Ensure `clickAnalytics: true` was added with the Configure widget.\nSee: https://alg.li/VpPpLt");
30
25
  }
31
-
32
26
  switch (method) {
33
27
  case 'clickedObjectIDsAfterSearch':
34
28
  {
@@ -40,25 +34,21 @@ function inferPayload(_ref) {
40
34
  positions: positions
41
35
  };
42
36
  }
43
-
44
37
  case 'convertedObjectIDsAfterSearch':
45
38
  return {
46
39
  index: index,
47
40
  queryID: queryID,
48
41
  objectIDs: objectIDs
49
42
  };
50
-
51
43
  default:
52
44
  throw new Error("Unsupported method \"".concat(method, "\" passed to the insights function. The supported methods are: \"clickedObjectIDsAfterSearch\", \"convertedObjectIDsAfterSearch\"."));
53
45
  }
54
46
  }
55
-
56
47
  var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
57
48
  return function (method, payload) {
58
49
  if (typeof aa !== 'function') {
59
50
  throw new TypeError("Expected insightsClient to be a Function");
60
51
  }
61
-
62
52
  var inferredPayload = inferPayload({
63
53
  method: method,
64
54
  results: results,
@@ -67,7 +57,6 @@ var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
67
57
  aa(method, _objectSpread(_objectSpread({}, inferredPayload), payload));
68
58
  };
69
59
  };
70
-
71
60
  var _default = function _default(insightsClient) {
72
61
  return (0, _createConnector.default)({
73
62
  displayName: 'AlgoliaInsights',
@@ -84,5 +73,4 @@ var _default = function _default(insightsClient) {
84
73
  }
85
74
  });
86
75
  };
87
-
88
76
  exports.default = _default;
@@ -1,18 +1,13 @@
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
-
12
8
  var _indexUtils = require("../core/indexUtils");
13
-
14
9
  var _utils = require("../core/utils");
15
-
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
11
  /**
17
12
  * connectHits connector provides the logic to create connected
18
13
  * components that will render the results retrieved from
@@ -64,21 +59,18 @@ var _default = (0, _createConnector.default)({
64
59
  ais: props.contextValue,
65
60
  multiIndexContext: props.indexContextValue
66
61
  });
67
-
68
62
  if (!results) {
69
63
  return {
70
64
  hits: []
71
65
  };
72
66
  }
73
-
74
67
  var hitsWithPositions = (0, _utils.addAbsolutePositions)(results.hits, results.hitsPerPage, results.page);
75
68
  var hitsWithPositionsAndQueryID = (0, _utils.addQueryID)(hitsWithPositions, results.queryID);
76
69
  return {
77
70
  hits: hitsWithPositionsAndQueryID
78
71
  };
79
72
  },
80
-
81
- /**
73
+ /*
82
74
  * Hits needs to be considered as a widget to trigger a search,
83
75
  * even if no other widgets are used.
84
76
  *
@@ -93,5 +85,4 @@ var _default = (0, _createConnector.default)({
93
85
  return searchParameters;
94
86
  }
95
87
  });
96
-
97
88
  exports.default = _default;
@@ -1,38 +1,31 @@
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
-
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); }
18
12
  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; }
19
-
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) { (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; }
21
-
13
+ 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; }
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); }
22
17
  function getId() {
23
18
  return 'hitsPerPage';
24
19
  }
25
-
26
20
  function getCurrentRefinement(props, searchState, context) {
27
21
  var id = getId();
28
22
  var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, null);
29
-
30
23
  if (typeof currentRefinement === 'string') {
31
24
  return parseInt(currentRefinement, 10);
32
25
  }
33
-
34
26
  return currentRefinement;
35
27
  }
28
+
36
29
  /**
37
30
  * connectHitsPerPage connector provides the logic to create connected
38
31
  * components that will allow a user to choose to display more or less results from Algolia.
@@ -46,8 +39,6 @@ function getCurrentRefinement(props, searchState, context) {
46
39
  * @providedPropType {string} currentRefinement - the refinement currently applied
47
40
  * @providedPropType {array.<{isRefined: boolean, label?: string, value: number}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
48
41
  */
49
-
50
-
51
42
  var _default = (0, _createConnector.default)({
52
43
  displayName: 'AlgoliaHitsPerPage',
53
44
  $$type: 'ais.hitsPerPage',
@@ -78,7 +69,7 @@ var _default = (0, _createConnector.default)({
78
69
  },
79
70
  refine: function refine(props, searchState, nextRefinement) {
80
71
  var id = getId();
81
- var nextValue = (0, _defineProperty2.default)({}, id, nextRefinement);
72
+ var nextValue = _defineProperty({}, id, nextRefinement);
82
73
  var resetPage = true;
83
74
  return (0, _indexUtils.refineValue)(searchState, nextValue, {
84
75
  ais: props.contextValue,
@@ -103,5 +94,4 @@ var _default = (0, _createConnector.default)({
103
94
  };
104
95
  }
105
96
  });
106
-
107
97
  exports.default = _default;