instantsearch.js 4.60.0 → 4.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/SearchBox/SearchBox.js +2 -2
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +14 -5
- package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +14 -5
- package/cjs/connectors/menu/connectMenu.js +14 -5
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +14 -5
- package/cjs/connectors/rating-menu/connectRatingMenu.js +15 -6
- package/cjs/connectors/refinement-list/connectRefinementList.js +14 -5
- package/cjs/lib/InstantSearch.js +5 -2
- package/cjs/lib/utils/hydrateSearchClient.js +39 -29
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/search-box/defaultTemplates.js +9 -3
- package/dist/instantsearch.development.d.ts +23 -3
- package/dist/instantsearch.development.js +167 -81
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +23 -3
- package/dist/instantsearch.production.min.d.ts +23 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/SearchBox/SearchBox.js +2 -2
- package/es/connectors/breadcrumb/connectBreadcrumb.js +14 -5
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +12 -2
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -3
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +14 -5
- package/es/connectors/menu/connectMenu.js +14 -5
- package/es/connectors/numeric-menu/connectNumericMenu.js +14 -5
- package/es/connectors/rating-menu/connectRatingMenu.d.ts +1 -1
- package/es/connectors/rating-menu/connectRatingMenu.js +15 -6
- package/es/connectors/refinement-list/connectRefinementList.js +14 -5
- package/es/lib/InstantSearch.d.ts +10 -0
- package/es/lib/InstantSearch.js +5 -2
- package/es/lib/utils/hydrateSearchClient.d.ts +5 -2
- package/es/lib/utils/hydrateSearchClient.js +39 -29
- package/es/lib/utils/render-args.d.ts +4 -4
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/search-box/defaultTemplates.js +10 -3
- package/package.json +6 -6
|
@@ -184,7 +184,7 @@ var SearchBox = /*#__PURE__*/function (_Component) {
|
|
|
184
184
|
rootProps: {
|
|
185
185
|
className: cssClasses.submit,
|
|
186
186
|
type: 'submit',
|
|
187
|
-
title: 'Submit the search query
|
|
187
|
+
title: 'Submit the search query',
|
|
188
188
|
hidden: !showSubmit
|
|
189
189
|
},
|
|
190
190
|
templates: templates,
|
|
@@ -197,7 +197,7 @@ var SearchBox = /*#__PURE__*/function (_Component) {
|
|
|
197
197
|
rootProps: {
|
|
198
198
|
className: cssClasses.reset,
|
|
199
199
|
type: 'reset',
|
|
200
|
-
title: 'Clear the search query
|
|
200
|
+
title: 'Clear the search query',
|
|
201
201
|
hidden: !(showReset && this.state.query.trim() && !isSearchStalled)
|
|
202
202
|
},
|
|
203
203
|
templates: templates,
|
|
@@ -121,12 +121,9 @@ var connectBreadcrumb = function connectBreadcrumb(renderFn) {
|
|
|
121
121
|
getWidgetUiState: function getWidgetUiState(uiState, _ref3) {
|
|
122
122
|
var searchParameters = _ref3.searchParameters;
|
|
123
123
|
var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
|
|
124
|
-
|
|
125
|
-
return uiState;
|
|
126
|
-
}
|
|
127
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
124
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
128
125
|
hierarchicalMenu: _objectSpread(_objectSpread({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
|
|
129
|
-
});
|
|
126
|
+
}), hierarchicalFacetName);
|
|
130
127
|
},
|
|
131
128
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref4) {
|
|
132
129
|
var uiState = _ref4.uiState;
|
|
@@ -177,5 +174,17 @@ function shiftItemsValues(array) {
|
|
|
177
174
|
};
|
|
178
175
|
});
|
|
179
176
|
}
|
|
177
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
178
|
+
if (!indexUiState.hierarchicalMenu) {
|
|
179
|
+
return indexUiState;
|
|
180
|
+
}
|
|
181
|
+
if (!indexUiState.hierarchicalMenu[attribute] || !indexUiState.hierarchicalMenu[attribute].length) {
|
|
182
|
+
delete indexUiState.hierarchicalMenu[attribute];
|
|
183
|
+
}
|
|
184
|
+
if (Object.keys(indexUiState.hierarchicalMenu).length === 0) {
|
|
185
|
+
delete indexUiState.hierarchicalMenu;
|
|
186
|
+
}
|
|
187
|
+
return indexUiState;
|
|
188
|
+
}
|
|
180
189
|
var _default = connectBreadcrumb;
|
|
181
190
|
exports.default = _default;
|
|
@@ -35,8 +35,8 @@ var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
|
|
|
35
35
|
}))) {
|
|
36
36
|
throw new Error(withUsage('The `widgets` option expects an array of widgets.'));
|
|
37
37
|
}
|
|
38
|
-
if (!
|
|
39
|
-
throw new Error(withUsage("The `facets` option only accepts
|
|
38
|
+
if (!Array.isArray(facets)) {
|
|
39
|
+
throw new Error(withUsage("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
|
|
40
40
|
}
|
|
41
41
|
var localWidgets = new Map();
|
|
42
42
|
return {
|
|
@@ -114,7 +114,6 @@ var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
|
|
|
114
114
|
unmountFn();
|
|
115
115
|
},
|
|
116
116
|
getWidgetSearchParameters: function getWidgetSearchParameters(state) {
|
|
117
|
-
// broadening the scope of facets to avoid conflict between never and *
|
|
118
117
|
return facets.reduce(function (acc, curr) {
|
|
119
118
|
return acc.addFacet(curr);
|
|
120
119
|
}, state.setQueryParameters({
|
|
@@ -205,12 +205,9 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
|
|
|
205
205
|
getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
|
|
206
206
|
var searchParameters = _ref5.searchParameters;
|
|
207
207
|
var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName);
|
|
208
|
-
|
|
209
|
-
return uiState;
|
|
210
|
-
}
|
|
211
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
208
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
212
209
|
hierarchicalMenu: _objectSpread(_objectSpread({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path))
|
|
213
|
-
});
|
|
210
|
+
}), hierarchicalFacetName);
|
|
214
211
|
},
|
|
215
212
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
|
|
216
213
|
var uiState = _ref6.uiState;
|
|
@@ -243,5 +240,17 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
|
|
|
243
240
|
};
|
|
244
241
|
};
|
|
245
242
|
};
|
|
243
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
244
|
+
if (!indexUiState.hierarchicalMenu) {
|
|
245
|
+
return indexUiState;
|
|
246
|
+
}
|
|
247
|
+
if (!indexUiState.hierarchicalMenu[attribute] || indexUiState.hierarchicalMenu[attribute].length === 0) {
|
|
248
|
+
delete indexUiState.hierarchicalMenu[attribute];
|
|
249
|
+
}
|
|
250
|
+
if (Object.keys(indexUiState.hierarchicalMenu).length === 0) {
|
|
251
|
+
delete indexUiState.hierarchicalMenu;
|
|
252
|
+
}
|
|
253
|
+
return indexUiState;
|
|
254
|
+
}
|
|
246
255
|
var _default = connectHierarchicalMenu;
|
|
247
256
|
exports.default = _default;
|
|
@@ -177,12 +177,9 @@ var connectMenu = function connectMenu(renderFn) {
|
|
|
177
177
|
var _searchParameters$get = searchParameters.getHierarchicalFacetBreadcrumb(attribute),
|
|
178
178
|
_searchParameters$get2 = _slicedToArray(_searchParameters$get, 1),
|
|
179
179
|
value = _searchParameters$get2[0];
|
|
180
|
-
|
|
181
|
-
return uiState;
|
|
182
|
-
}
|
|
183
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
180
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
184
181
|
menu: _objectSpread(_objectSpread({}, uiState.menu), {}, _defineProperty({}, attribute, value))
|
|
185
|
-
});
|
|
182
|
+
}), attribute);
|
|
186
183
|
},
|
|
187
184
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
|
|
188
185
|
var uiState = _ref5.uiState;
|
|
@@ -208,5 +205,17 @@ var connectMenu = function connectMenu(renderFn) {
|
|
|
208
205
|
};
|
|
209
206
|
};
|
|
210
207
|
};
|
|
208
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
209
|
+
if (!indexUiState.menu) {
|
|
210
|
+
return indexUiState;
|
|
211
|
+
}
|
|
212
|
+
if (indexUiState.menu[attribute] === undefined) {
|
|
213
|
+
delete indexUiState.menu[attribute];
|
|
214
|
+
}
|
|
215
|
+
if (Object.keys(indexUiState.menu).length === 0) {
|
|
216
|
+
delete indexUiState.menu;
|
|
217
|
+
}
|
|
218
|
+
return indexUiState;
|
|
219
|
+
}
|
|
211
220
|
var _default = connectMenu;
|
|
212
221
|
exports.default = _default;
|
|
@@ -101,12 +101,9 @@ var connectNumericMenu = function connectNumericMenu(renderFn) {
|
|
|
101
101
|
}
|
|
102
102
|
var min = values['>='] && values['>='][0] || '';
|
|
103
103
|
var max = values['<='] && values['<='][0] || '';
|
|
104
|
-
|
|
105
|
-
return uiState;
|
|
106
|
-
}
|
|
107
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
104
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
108
105
|
numericMenu: _objectSpread(_objectSpread({}, uiState.numericMenu), {}, _defineProperty({}, attribute, "".concat(min, ":").concat(max)))
|
|
109
|
-
});
|
|
106
|
+
}), attribute);
|
|
110
107
|
},
|
|
111
108
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
|
|
112
109
|
var uiState = _ref6.uiState;
|
|
@@ -268,5 +265,17 @@ function getRefinedState(state, attribute, facetValue) {
|
|
|
268
265
|
function hasNumericRefinement(currentRefinements, operator, value) {
|
|
269
266
|
return currentRefinements[operator] !== undefined && currentRefinements[operator].includes(value);
|
|
270
267
|
}
|
|
268
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
269
|
+
if (!indexUiState.numericMenu) {
|
|
270
|
+
return indexUiState;
|
|
271
|
+
}
|
|
272
|
+
if (indexUiState.numericMenu[attribute] === ':') {
|
|
273
|
+
delete indexUiState.numericMenu[attribute];
|
|
274
|
+
}
|
|
275
|
+
if (Object.keys(indexUiState.numericMenu).length === 0) {
|
|
276
|
+
delete indexUiState.numericMenu;
|
|
277
|
+
}
|
|
278
|
+
return indexUiState;
|
|
279
|
+
}
|
|
271
280
|
var _default = connectNumericMenu;
|
|
272
281
|
exports.default = _default;
|
|
@@ -262,12 +262,9 @@ var connectRatingMenu = function connectRatingMenu(renderFn) {
|
|
|
262
262
|
getWidgetUiState: function getWidgetUiState(uiState, _ref7) {
|
|
263
263
|
var searchParameters = _ref7.searchParameters;
|
|
264
264
|
var value = _getRefinedStar(searchParameters);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
269
|
-
ratingMenu: _objectSpread(_objectSpread({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, value))
|
|
270
|
-
});
|
|
265
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
266
|
+
ratingMenu: _objectSpread(_objectSpread({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, typeof value === 'number' ? value : undefined))
|
|
267
|
+
}), attribute);
|
|
271
268
|
},
|
|
272
269
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref8) {
|
|
273
270
|
var uiState = _ref8.uiState;
|
|
@@ -284,5 +281,17 @@ var connectRatingMenu = function connectRatingMenu(renderFn) {
|
|
|
284
281
|
};
|
|
285
282
|
};
|
|
286
283
|
};
|
|
284
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
285
|
+
if (!indexUiState.ratingMenu) {
|
|
286
|
+
return indexUiState;
|
|
287
|
+
}
|
|
288
|
+
if (typeof indexUiState.ratingMenu[attribute] !== 'number') {
|
|
289
|
+
delete indexUiState.ratingMenu[attribute];
|
|
290
|
+
}
|
|
291
|
+
if (Object.keys(indexUiState.ratingMenu).length === 0) {
|
|
292
|
+
delete indexUiState.ratingMenu;
|
|
293
|
+
}
|
|
294
|
+
return indexUiState;
|
|
295
|
+
}
|
|
287
296
|
var _default = connectRatingMenu;
|
|
288
297
|
exports.default = _default;
|
|
@@ -249,12 +249,9 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
249
249
|
getWidgetUiState: function getWidgetUiState(uiState, _ref5) {
|
|
250
250
|
var searchParameters = _ref5.searchParameters;
|
|
251
251
|
var values = operator === 'or' ? searchParameters.getDisjunctiveRefinements(attribute) : searchParameters.getConjunctiveRefinements(attribute);
|
|
252
|
-
|
|
253
|
-
return uiState;
|
|
254
|
-
}
|
|
255
|
-
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
252
|
+
return removeEmptyRefinementsFromUiState(_objectSpread(_objectSpread({}, uiState), {}, {
|
|
256
253
|
refinementList: _objectSpread(_objectSpread({}, uiState.refinementList), {}, _defineProperty({}, attribute, values))
|
|
257
|
-
});
|
|
254
|
+
}), attribute);
|
|
258
255
|
},
|
|
259
256
|
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
|
|
260
257
|
var uiState = _ref6.uiState;
|
|
@@ -284,5 +281,17 @@ var connectRefinementList = function connectRefinementList(renderFn) {
|
|
|
284
281
|
};
|
|
285
282
|
};
|
|
286
283
|
};
|
|
284
|
+
function removeEmptyRefinementsFromUiState(indexUiState, attribute) {
|
|
285
|
+
if (!indexUiState.refinementList) {
|
|
286
|
+
return indexUiState;
|
|
287
|
+
}
|
|
288
|
+
if (!indexUiState.refinementList[attribute] || indexUiState.refinementList[attribute].length === 0) {
|
|
289
|
+
delete indexUiState.refinementList[attribute];
|
|
290
|
+
}
|
|
291
|
+
if (Object.keys(indexUiState.refinementList).length === 0) {
|
|
292
|
+
delete indexUiState.refinementList;
|
|
293
|
+
}
|
|
294
|
+
return indexUiState;
|
|
295
|
+
}
|
|
287
296
|
var _default = connectRefinementList;
|
|
288
297
|
exports.default = _default;
|
package/cjs/lib/InstantSearch.js
CHANGED
|
@@ -44,7 +44,8 @@ function defaultCreateURL() {
|
|
|
44
44
|
* Global options for an InstantSearch instance.
|
|
45
45
|
*/
|
|
46
46
|
var INSTANTSEARCH_FUTURE_DEFAULTS = {
|
|
47
|
-
preserveSharedStateOnUnmount: false
|
|
47
|
+
preserveSharedStateOnUnmount: false,
|
|
48
|
+
persistHierarchicalRootCount: false
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
/**
|
|
@@ -381,7 +382,9 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
381
382
|
// DerivedHelper scoped into the `index` widgets.
|
|
382
383
|
// In Vue InstantSearch' hydrate, a main helper gets set before start, so
|
|
383
384
|
// we need to respect this helper as a way to keep all listeners correct.
|
|
384
|
-
var mainHelper = this.mainHelper || (0, _algoliasearchHelper.default)(this.client, this.indexName
|
|
385
|
+
var mainHelper = this.mainHelper || (0, _algoliasearchHelper.default)(this.client, this.indexName, undefined, {
|
|
386
|
+
persistHierarchicalRootCount: this.future.persistHierarchicalRootCount
|
|
387
|
+
});
|
|
385
388
|
mainHelper.search = function () {
|
|
386
389
|
_this3.status = 'loading';
|
|
387
390
|
_this3.scheduleRender(false);
|
|
@@ -5,13 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.hydrateSearchClient = hydrateSearchClient;
|
|
7
7
|
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); }
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
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; }
|
|
9
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; }
|
|
10
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; }
|
|
11
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
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); }
|
|
13
|
-
// @ts-nocheck (types to be fixed during actual implementation)
|
|
14
|
-
|
|
15
19
|
function hydrateSearchClient(client, results) {
|
|
16
20
|
if (!results) {
|
|
17
21
|
return;
|
|
@@ -21,9 +25,22 @@ function hydrateSearchClient(client, results) {
|
|
|
21
25
|
// - Algoliasearch API Client < v4 with cache disabled
|
|
22
26
|
// - Third party clients (detected by the `addAlgoliaAgent` function missing)
|
|
23
27
|
|
|
24
|
-
if ((!
|
|
28
|
+
if ((!('transporter' in client) || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
31
|
+
var cachedRequest = Object.keys(results).map(function (key) {
|
|
32
|
+
return results[key].results.map(function (result) {
|
|
33
|
+
return {
|
|
34
|
+
indexName: result.index,
|
|
35
|
+
// We normalize the params received from the server as they can
|
|
36
|
+
// be serialized differently depending on the engine.
|
|
37
|
+
params: serializeQueryParameters(deserializeQueryParameters(result.params))
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var cachedResults = Object.keys(results).reduce(function (acc, key) {
|
|
42
|
+
return acc.concat(results[key].results);
|
|
43
|
+
}, []);
|
|
27
44
|
|
|
28
45
|
// Algoliasearch API Client >= v4
|
|
29
46
|
// To hydrate the client we need to populate the cache with the data from
|
|
@@ -32,9 +49,10 @@ function hydrateSearchClient(client, results) {
|
|
|
32
49
|
// for us to compute the key the same way as `algoliasearch-client` we need
|
|
33
50
|
// to populate it on a custom key and override the `search` method to
|
|
34
51
|
// search on it first.
|
|
35
|
-
if (
|
|
52
|
+
if ('transporter' in client && !client._cacheHydrated) {
|
|
36
53
|
client._cacheHydrated = true;
|
|
37
54
|
var baseMethod = client.search;
|
|
55
|
+
// @ts-ignore wanting type checks for v3 on this would make this too complex
|
|
38
56
|
client.search = function (requests) {
|
|
39
57
|
for (var _len = arguments.length, methodArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
40
58
|
methodArgs[_key - 1] = arguments[_key];
|
|
@@ -51,22 +69,11 @@ function hydrateSearchClient(client, results) {
|
|
|
51
69
|
return baseMethod.apply(void 0, [requests].concat(methodArgs));
|
|
52
70
|
});
|
|
53
71
|
};
|
|
54
|
-
|
|
55
|
-
// Populate the cache with the data from the server
|
|
56
72
|
client.transporter.responsesCache.set({
|
|
57
73
|
method: 'search',
|
|
58
|
-
args:
|
|
59
|
-
return acc.concat(results[key].results.map(function (request) {
|
|
60
|
-
return {
|
|
61
|
-
indexName: request.index,
|
|
62
|
-
params: request.params
|
|
63
|
-
};
|
|
64
|
-
}));
|
|
65
|
-
}, [])]
|
|
74
|
+
args: cachedRequest
|
|
66
75
|
}, {
|
|
67
|
-
results:
|
|
68
|
-
return acc.concat(results[key].results);
|
|
69
|
-
}, [])
|
|
76
|
+
results: cachedResults
|
|
70
77
|
});
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -76,24 +83,27 @@ function hydrateSearchClient(client, results) {
|
|
|
76
83
|
// a single-index result. You can find more information about the
|
|
77
84
|
// computation of the key inside the client (see link below).
|
|
78
85
|
// https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
|
|
79
|
-
if (!client
|
|
86
|
+
if (!('transporter' in client)) {
|
|
80
87
|
var cacheKey = "/1/indexes/*/queries_body_".concat(JSON.stringify({
|
|
81
|
-
requests:
|
|
82
|
-
return acc.concat(results[key].rawResults.map(function (request) {
|
|
83
|
-
return {
|
|
84
|
-
indexName: request.index,
|
|
85
|
-
params: request.params
|
|
86
|
-
};
|
|
87
|
-
}));
|
|
88
|
-
}, [])
|
|
88
|
+
requests: cachedRequest
|
|
89
89
|
}));
|
|
90
90
|
client.cache = _objectSpread(_objectSpread({}, client.cache), {}, _defineProperty({}, cacheKey, JSON.stringify({
|
|
91
|
-
results: Object.keys(results).
|
|
92
|
-
return
|
|
93
|
-
}
|
|
91
|
+
results: Object.keys(results).map(function (key) {
|
|
92
|
+
return results[key].results;
|
|
93
|
+
})
|
|
94
94
|
})));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
function deserializeQueryParameters(parameters) {
|
|
98
|
+
return parameters.split('&').reduce(function (acc, parameter) {
|
|
99
|
+
var _parameter$split = parameter.split('='),
|
|
100
|
+
_parameter$split2 = _slicedToArray(_parameter$split, 2),
|
|
101
|
+
key = _parameter$split2[0],
|
|
102
|
+
value = _parameter$split2[1];
|
|
103
|
+
acc[key] = value ? decodeURIComponent(value) : '';
|
|
104
|
+
return acc;
|
|
105
|
+
}, {});
|
|
106
|
+
}
|
|
97
107
|
|
|
98
108
|
// This function is copied from the algoliasearch v4 API Client. If modified,
|
|
99
109
|
// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
|
package/cjs/lib/version.js
CHANGED
|
@@ -13,12 +13,12 @@ var _ref4 = (0, _preact.h)("path", {
|
|
|
13
13
|
});
|
|
14
14
|
var _ref6 = (0, _preact.h)("g", {
|
|
15
15
|
fill: "none",
|
|
16
|
-
|
|
16
|
+
"fill-rule": "evenodd"
|
|
17
17
|
}, (0, _preact.h)("g", {
|
|
18
18
|
transform: "translate(1 1)",
|
|
19
|
-
|
|
19
|
+
"stroke-width": "2"
|
|
20
20
|
}, (0, _preact.h)("circle", {
|
|
21
|
-
|
|
21
|
+
"stroke-opacity": ".5",
|
|
22
22
|
cx: "18",
|
|
23
23
|
cy: "18",
|
|
24
24
|
r: "18"
|
|
@@ -55,7 +55,12 @@ var defaultTemplate = {
|
|
|
55
55
|
},
|
|
56
56
|
loadingIndicator: function loadingIndicator(_ref5) {
|
|
57
57
|
var cssClasses = _ref5.cssClasses;
|
|
58
|
+
/* eslint-disable react/no-unknown-property */
|
|
59
|
+
// Preact supports kebab case attributes, and using camel case would
|
|
60
|
+
// require using `preact/compat`.
|
|
61
|
+
// @TODO: reconsider using the `react` ESLint preset
|
|
58
62
|
return (0, _preact.h)("svg", {
|
|
63
|
+
"aria-label": "Results are loading",
|
|
59
64
|
className: cssClasses.loadingIcon,
|
|
60
65
|
width: "16",
|
|
61
66
|
height: "16",
|
|
@@ -63,6 +68,7 @@ var defaultTemplate = {
|
|
|
63
68
|
stroke: "#444",
|
|
64
69
|
"aria-hidden": "true"
|
|
65
70
|
}, _ref6);
|
|
71
|
+
/* eslint-enable react/no-unknown-property */
|
|
66
72
|
}
|
|
67
73
|
};
|
|
68
74
|
var _default = defaultTemplate;
|
|
@@ -1130,11 +1130,21 @@ declare type DynamicWidgetsConnectorParams = {
|
|
|
1130
1130
|
}>;
|
|
1131
1131
|
/**
|
|
1132
1132
|
* To prevent unneeded extra network requests when widgets mount or unmount,
|
|
1133
|
-
* we request all facet values.
|
|
1133
|
+
* we request all facet values by default. If you want to only request the
|
|
1134
|
+
* facet values that are needed, you can set this option to the list of
|
|
1135
|
+
* attributes you want to display.
|
|
1136
|
+
*
|
|
1137
|
+
* If `facets` is set to `['*']`, we request all facet values.
|
|
1138
|
+
*
|
|
1139
|
+
* Any facets that are requested due to the `facetOrdering` result are always
|
|
1140
|
+
* requested by the widget that mounted itself.
|
|
1141
|
+
*
|
|
1142
|
+
* Setting `facets` to a value other than `['*']` will only prevent extra
|
|
1143
|
+
* requests if all potential facets are listed.
|
|
1134
1144
|
*
|
|
1135
1145
|
* @default ['*']
|
|
1136
1146
|
*/
|
|
1137
|
-
facets?: ['*'] |
|
|
1147
|
+
facets?: ['*'] | string[];
|
|
1138
1148
|
/**
|
|
1139
1149
|
* If you have more than 20 facet values pinned, you need to increase the
|
|
1140
1150
|
* maxValuesPerFacet to at least that value.
|
|
@@ -2617,6 +2627,16 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2617
2627
|
* @default false
|
|
2618
2628
|
*/
|
|
2619
2629
|
preserveSharedStateOnUnmount?: boolean;
|
|
2630
|
+
/**
|
|
2631
|
+
* Changes the way root levels of hierarchical facets have their count displayed.
|
|
2632
|
+
*
|
|
2633
|
+
* If `false` (by default), the count of the refined root level is updated to match the count of the actively refined parent level.
|
|
2634
|
+
*
|
|
2635
|
+
* If `true`, the count of the root level stays the same as the count of all children levels.
|
|
2636
|
+
*
|
|
2637
|
+
* @default false
|
|
2638
|
+
*/
|
|
2639
|
+
persistHierarchicalRootCount?: boolean;
|
|
2620
2640
|
};
|
|
2621
2641
|
};
|
|
2622
2642
|
|
|
@@ -3965,7 +3985,7 @@ declare type RatingMenuWidgetDescription = {
|
|
|
3965
3985
|
};
|
|
3966
3986
|
indexUiState: {
|
|
3967
3987
|
ratingMenu: {
|
|
3968
|
-
[attribute: string]: number;
|
|
3988
|
+
[attribute: string]: number | undefined;
|
|
3969
3989
|
};
|
|
3970
3990
|
};
|
|
3971
3991
|
};
|