react-instantsearch-core 7.16.1 → 7.16.3
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/dist/cjs/version.js +1 -1
- package/dist/es/version.d.ts +1 -1
- package/dist/es/version.js +1 -1
- package/dist/umd/ReactInstantSearchCore.js +96 -49
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/version.js
CHANGED
package/dist/es/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.16.
|
|
1
|
+
declare const _default: "7.16.3";
|
|
2
2
|
export default _default;
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '7.16.
|
|
1
|
+
export default '7.16.3';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
var version = '7.16.
|
|
10
|
+
var version = '7.16.3';
|
|
11
11
|
|
|
12
12
|
function _iterableToArrayLimit(r, l) {
|
|
13
13
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
@@ -10067,12 +10067,18 @@
|
|
|
10067
10067
|
}, []);
|
|
10068
10068
|
}
|
|
10069
10069
|
var index = function index(widgetParams) {
|
|
10070
|
-
if (widgetParams === undefined || widgetParams.indexName === undefined) {
|
|
10070
|
+
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
|
|
10071
10071
|
throw new Error(withUsage$2('The `indexName` option is required.'));
|
|
10072
10072
|
}
|
|
10073
|
-
|
|
10073
|
+
|
|
10074
|
+
// When isolated=true, we use an empty string as the default indexName.
|
|
10075
|
+
// This is intentional: isolated indices do not require a real index name.
|
|
10076
|
+
var _widgetParams$indexNa = widgetParams.indexName,
|
|
10077
|
+
indexName = _widgetParams$indexNa === void 0 ? '' : _widgetParams$indexNa,
|
|
10074
10078
|
_widgetParams$indexId = widgetParams.indexId,
|
|
10075
|
-
indexId = _widgetParams$indexId === void 0 ? indexName : _widgetParams$indexId
|
|
10079
|
+
indexId = _widgetParams$indexId === void 0 ? indexName : _widgetParams$indexId,
|
|
10080
|
+
_widgetParams$EXPERIM = widgetParams.EXPERIMENTAL_isolated,
|
|
10081
|
+
isolated = _widgetParams$EXPERIM === void 0 ? false : _widgetParams$EXPERIM;
|
|
10076
10082
|
var localWidgets = [];
|
|
10077
10083
|
var localUiState = {};
|
|
10078
10084
|
var localInstantSearchInstance = null;
|
|
@@ -10085,6 +10091,7 @@
|
|
|
10085
10091
|
return {
|
|
10086
10092
|
$$type: 'ais.index',
|
|
10087
10093
|
$$widgetType: 'ais.index',
|
|
10094
|
+
_isolated: isolated,
|
|
10088
10095
|
getIndexName: function getIndexName() {
|
|
10089
10096
|
return indexName;
|
|
10090
10097
|
},
|
|
@@ -10136,7 +10143,7 @@
|
|
|
10136
10143
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
10137
10144
|
},
|
|
10138
10145
|
getParent: function getParent() {
|
|
10139
|
-
return localParent;
|
|
10146
|
+
return isolated ? null : localParent;
|
|
10140
10147
|
},
|
|
10141
10148
|
createURL: function createURL(nextState) {
|
|
10142
10149
|
if (typeof nextState === 'function') {
|
|
@@ -10155,12 +10162,15 @@
|
|
|
10155
10162
|
if (!Array.isArray(widgets)) {
|
|
10156
10163
|
throw new Error(withUsage$2('The `addWidgets` method expects an array of widgets.'));
|
|
10157
10164
|
}
|
|
10158
|
-
|
|
10165
|
+
var flatWidgets = widgets.reduce(function (acc, w) {
|
|
10166
|
+
return acc.concat(Array.isArray(w) ? w : [w]);
|
|
10167
|
+
}, []);
|
|
10168
|
+
if (flatWidgets.some(function (widget) {
|
|
10159
10169
|
return typeof widget.init !== 'function' && typeof widget.render !== 'function';
|
|
10160
10170
|
})) {
|
|
10161
10171
|
throw new Error(withUsage$2('The widget definition expects a `render` and/or an `init` method.'));
|
|
10162
10172
|
}
|
|
10163
|
-
|
|
10173
|
+
flatWidgets.forEach(function (widget) {
|
|
10164
10174
|
if (isIndexWidget(widget)) {
|
|
10165
10175
|
return;
|
|
10166
10176
|
}
|
|
@@ -10175,8 +10185,8 @@
|
|
|
10175
10185
|
}
|
|
10176
10186
|
addWidgetId(widget);
|
|
10177
10187
|
});
|
|
10178
|
-
localWidgets = localWidgets.concat(
|
|
10179
|
-
if (localInstantSearchInstance && Boolean(
|
|
10188
|
+
localWidgets = localWidgets.concat(flatWidgets);
|
|
10189
|
+
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
10180
10190
|
privateHelperSetState(helper, {
|
|
10181
10191
|
state: getLocalWidgetsSearchParameters(localWidgets, {
|
|
10182
10192
|
uiState: localUiState,
|
|
@@ -10192,7 +10202,7 @@
|
|
|
10192
10202
|
// We compute the render state before calling `init` in a separate loop
|
|
10193
10203
|
// to construct the whole render state object that is then passed to
|
|
10194
10204
|
// `init`.
|
|
10195
|
-
|
|
10205
|
+
flatWidgets.forEach(function (widget) {
|
|
10196
10206
|
if (widget.getRenderState) {
|
|
10197
10207
|
var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
10198
10208
|
storeRenderState({
|
|
@@ -10202,12 +10212,17 @@
|
|
|
10202
10212
|
});
|
|
10203
10213
|
}
|
|
10204
10214
|
});
|
|
10205
|
-
|
|
10215
|
+
flatWidgets.forEach(function (widget) {
|
|
10206
10216
|
if (widget.init) {
|
|
10207
10217
|
widget.init(createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
10208
10218
|
}
|
|
10209
10219
|
});
|
|
10210
|
-
|
|
10220
|
+
if (isolated) {
|
|
10221
|
+
var _helper2;
|
|
10222
|
+
(_helper2 = helper) === null || _helper2 === void 0 ? void 0 : _helper2.search();
|
|
10223
|
+
} else {
|
|
10224
|
+
localInstantSearchInstance.scheduleSearch();
|
|
10225
|
+
}
|
|
10211
10226
|
}
|
|
10212
10227
|
return this;
|
|
10213
10228
|
},
|
|
@@ -10216,13 +10231,16 @@
|
|
|
10216
10231
|
if (!Array.isArray(widgets)) {
|
|
10217
10232
|
throw new Error(withUsage$2('The `removeWidgets` method expects an array of widgets.'));
|
|
10218
10233
|
}
|
|
10219
|
-
|
|
10234
|
+
var flatWidgets = widgets.reduce(function (acc, w) {
|
|
10235
|
+
return acc.concat(Array.isArray(w) ? w : [w]);
|
|
10236
|
+
}, []);
|
|
10237
|
+
if (flatWidgets.some(function (widget) {
|
|
10220
10238
|
return typeof widget.dispose !== 'function';
|
|
10221
10239
|
})) {
|
|
10222
10240
|
throw new Error(withUsage$2('The widget definition expects a `dispose` method.'));
|
|
10223
10241
|
}
|
|
10224
10242
|
localWidgets = localWidgets.filter(function (widget) {
|
|
10225
|
-
return
|
|
10243
|
+
return flatWidgets.indexOf(widget) === -1;
|
|
10226
10244
|
});
|
|
10227
10245
|
localWidgets.forEach(function (widget) {
|
|
10228
10246
|
if (isIndexWidget(widget)) {
|
|
@@ -10238,8 +10256,8 @@
|
|
|
10238
10256
|
hasSearchWidget = true;
|
|
10239
10257
|
}
|
|
10240
10258
|
});
|
|
10241
|
-
if (localInstantSearchInstance && Boolean(
|
|
10242
|
-
var
|
|
10259
|
+
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
10260
|
+
var _flatWidgets$reduce = flatWidgets.reduce(function (states, widget) {
|
|
10243
10261
|
// the `dispose` method exists at this point we already assert it
|
|
10244
10262
|
var next = widget.dispose({
|
|
10245
10263
|
helper: helper,
|
|
@@ -10257,8 +10275,8 @@
|
|
|
10257
10275
|
cleanedSearchState: helper.state,
|
|
10258
10276
|
cleanedRecommendState: helper.recommendState
|
|
10259
10277
|
}),
|
|
10260
|
-
cleanedSearchState =
|
|
10261
|
-
cleanedRecommendState =
|
|
10278
|
+
cleanedSearchState = _flatWidgets$reduce.cleanedSearchState,
|
|
10279
|
+
cleanedRecommendState = _flatWidgets$reduce.cleanedRecommendState;
|
|
10262
10280
|
var newState = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? getLocalWidgetsSearchParameters(localWidgets, {
|
|
10263
10281
|
uiState: localUiState,
|
|
10264
10282
|
initialSearchParameters: new algoliasearchHelper_1.SearchParameters({
|
|
@@ -10278,7 +10296,12 @@
|
|
|
10278
10296
|
helper.setState(newState);
|
|
10279
10297
|
helper.recommendState = cleanedRecommendState;
|
|
10280
10298
|
if (localWidgets.length) {
|
|
10281
|
-
|
|
10299
|
+
if (isolated) {
|
|
10300
|
+
var _helper3;
|
|
10301
|
+
(_helper3 = helper) === null || _helper3 === void 0 ? void 0 : _helper3.search();
|
|
10302
|
+
} else {
|
|
10303
|
+
localInstantSearchInstance.scheduleSearch();
|
|
10304
|
+
}
|
|
10282
10305
|
}
|
|
10283
10306
|
}
|
|
10284
10307
|
return this;
|
|
@@ -10316,13 +10339,20 @@
|
|
|
10316
10339
|
// This Helper is only used for state management we do not care about the
|
|
10317
10340
|
// `searchClient`. Only the "main" Helper created at the `InstantSearch`
|
|
10318
10341
|
// level is aware of the client.
|
|
10319
|
-
helper = algoliasearchHelper_1(
|
|
10342
|
+
helper = algoliasearchHelper_1(mainHelper.getClient(), parameters.index, parameters);
|
|
10320
10343
|
helper.recommendState = recommendParameters;
|
|
10321
10344
|
|
|
10322
10345
|
// We forward the call to `search` to the "main" instance of the Helper
|
|
10323
10346
|
// which is responsible for managing the queries (it's the only one that is
|
|
10324
10347
|
// aware of the `searchClient`).
|
|
10325
10348
|
helper.search = function () {
|
|
10349
|
+
if (isolated) {
|
|
10350
|
+
instantSearchInstance.status = 'loading';
|
|
10351
|
+
_this3.render({
|
|
10352
|
+
instantSearchInstance: instantSearchInstance
|
|
10353
|
+
});
|
|
10354
|
+
return instantSearchInstance.compositionID ? helper.searchWithComposition() : helper.searchOnlyWithDerivedHelpers();
|
|
10355
|
+
}
|
|
10326
10356
|
if (instantSearchInstance.onStateChange) {
|
|
10327
10357
|
instantSearchInstance.onStateChange({
|
|
10328
10358
|
uiState: instantSearchInstance.mainIndex.getWidgetUiState({}),
|
|
@@ -10346,7 +10376,9 @@
|
|
|
10346
10376
|
var state = helper.state.setQueryParameters(userState);
|
|
10347
10377
|
return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);
|
|
10348
10378
|
};
|
|
10349
|
-
|
|
10379
|
+
var isolatedHelper = indexName ? helper : algoliasearchHelper_1({}, '__empty_index__', {});
|
|
10380
|
+
var derivingHelper = isolated ? isolatedHelper : nearestIsolatedHelper(parent, mainHelper);
|
|
10381
|
+
derivedHelper = derivingHelper.derive(function () {
|
|
10350
10382
|
return mergeSearchParameters.apply(void 0, [mainHelper.state].concat(_toConsumableArray$1(resolveSearchParameters(_this3))));
|
|
10351
10383
|
}, function () {
|
|
10352
10384
|
return _this3.getHelper().recommendState;
|
|
@@ -10478,7 +10510,9 @@
|
|
|
10478
10510
|
|
|
10479
10511
|
// We only render index widgets if there are no results.
|
|
10480
10512
|
// This makes sure `render` is never called with `results` being `null`.
|
|
10481
|
-
|
|
10513
|
+
// If it's an isolated index without an index name, we render all widgets,
|
|
10514
|
+
// as there are no results to display for the isolated index itself.
|
|
10515
|
+
var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(isIndexWidget);
|
|
10482
10516
|
widgetsToRender = widgetsToRender.filter(function (widget) {
|
|
10483
10517
|
if (!widget.shouldRender) {
|
|
10484
10518
|
return true;
|
|
@@ -10512,7 +10546,7 @@
|
|
|
10512
10546
|
},
|
|
10513
10547
|
dispose: function dispose() {
|
|
10514
10548
|
var _this5 = this,
|
|
10515
|
-
|
|
10549
|
+
_helper4,
|
|
10516
10550
|
_derivedHelper3;
|
|
10517
10551
|
localWidgets.forEach(function (widget) {
|
|
10518
10552
|
if (widget.dispose && helper) {
|
|
@@ -10532,13 +10566,15 @@
|
|
|
10532
10566
|
});
|
|
10533
10567
|
localInstantSearchInstance = null;
|
|
10534
10568
|
localParent = null;
|
|
10535
|
-
(
|
|
10569
|
+
(_helper4 = helper) === null || _helper4 === void 0 ? void 0 : _helper4.removeAllListeners();
|
|
10536
10570
|
helper = null;
|
|
10537
10571
|
(_derivedHelper3 = derivedHelper) === null || _derivedHelper3 === void 0 ? void 0 : _derivedHelper3.detach();
|
|
10538
10572
|
derivedHelper = null;
|
|
10539
10573
|
},
|
|
10540
10574
|
getWidgetUiState: function getWidgetUiState(uiState) {
|
|
10541
|
-
return localWidgets.filter(isIndexWidget).
|
|
10575
|
+
return localWidgets.filter(isIndexWidget).filter(function (w) {
|
|
10576
|
+
return !w._isolated;
|
|
10577
|
+
}).reduce(function (previousUiState, innerIndex) {
|
|
10542
10578
|
return innerIndex.getWidgetUiState(previousUiState);
|
|
10543
10579
|
}, _objectSpread$b(_objectSpread$b({}, uiState), {}, _defineProperty$c({}, indexId, _objectSpread$b(_objectSpread$b({}, uiState[indexId]), localUiState))));
|
|
10544
10580
|
},
|
|
@@ -10574,6 +10610,19 @@
|
|
|
10574
10610
|
instantSearchInstance.renderState = _objectSpread$b(_objectSpread$b({}, instantSearchInstance.renderState), {}, _defineProperty$c({}, parentIndexName, _objectSpread$b(_objectSpread$b({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
|
|
10575
10611
|
}
|
|
10576
10612
|
|
|
10613
|
+
/**
|
|
10614
|
+
* Walk up the parent chain to find the closest isolated index, or fall back to mainHelper
|
|
10615
|
+
*/
|
|
10616
|
+
function nearestIsolatedHelper(current, mainHelper) {
|
|
10617
|
+
while (current) {
|
|
10618
|
+
if (current._isolated) {
|
|
10619
|
+
return current.getHelper();
|
|
10620
|
+
}
|
|
10621
|
+
current = current.getParent();
|
|
10622
|
+
}
|
|
10623
|
+
return mainHelper;
|
|
10624
|
+
}
|
|
10625
|
+
|
|
10577
10626
|
/**
|
|
10578
10627
|
* Forces a React update that triggers a rerender.
|
|
10579
10628
|
* @link https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
|
|
@@ -12912,7 +12961,7 @@
|
|
|
12912
12961
|
};
|
|
12913
12962
|
}
|
|
12914
12963
|
|
|
12915
|
-
var version$2 = '4.
|
|
12964
|
+
var version$2 = '4.80.0';
|
|
12916
12965
|
|
|
12917
12966
|
function _typeof$l(o) {
|
|
12918
12967
|
"@babel/helpers - typeof";
|
|
@@ -13346,12 +13395,9 @@
|
|
|
13346
13395
|
if (!Array.isArray(widgets)) {
|
|
13347
13396
|
throw new Error(withUsage$3('The `addWidgets` method expects an array of widgets. Please use `addWidget`.'));
|
|
13348
13397
|
}
|
|
13349
|
-
if (widgets.some(function (
|
|
13350
|
-
return
|
|
13398
|
+
if (this.compositionID && widgets.some(function (w) {
|
|
13399
|
+
return !Array.isArray(w) && isIndexWidget(w) && !w._isolated;
|
|
13351
13400
|
})) {
|
|
13352
|
-
throw new Error(withUsage$3('The widget definition expects a `render` and/or an `init` method.'));
|
|
13353
|
-
}
|
|
13354
|
-
if (this.compositionID && widgets.some(isIndexWidget)) {
|
|
13355
13401
|
throw new Error(withUsage$3('The `index` widget cannot be used with a composition-based InstantSearch implementation.'));
|
|
13356
13402
|
}
|
|
13357
13403
|
this.mainIndex.addWidgets(widgets);
|
|
@@ -13383,11 +13429,6 @@
|
|
|
13383
13429
|
if (!Array.isArray(widgets)) {
|
|
13384
13430
|
throw new Error(withUsage$3('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'));
|
|
13385
13431
|
}
|
|
13386
|
-
if (widgets.some(function (widget) {
|
|
13387
|
-
return typeof widget.dispose !== 'function';
|
|
13388
|
-
})) {
|
|
13389
|
-
throw new Error(withUsage$3('The widget definition expects a `dispose` method.'));
|
|
13390
|
-
}
|
|
13391
13432
|
this.mainIndex.removeWidgets(widgets);
|
|
13392
13433
|
return this;
|
|
13393
13434
|
}
|
|
@@ -16066,22 +16107,20 @@
|
|
|
16066
16107
|
return Math.max.apply(Math, [page].concat(_toConsumableArray$6(pages)));
|
|
16067
16108
|
}
|
|
16068
16109
|
};
|
|
16069
|
-
var getShowPrevious = function getShowPrevious(helper) {
|
|
16110
|
+
var getShowPrevious = function getShowPrevious(helper, getCachedHits) {
|
|
16070
16111
|
return function () {
|
|
16112
|
+
var cachedHits = getCachedHits();
|
|
16071
16113
|
// Using the helper's `overrideStateWithoutTriggeringChangeEvent` method
|
|
16072
16114
|
// avoid updating the browser URL when the user displays the previous page.
|
|
16073
16115
|
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread$p(_objectSpread$p({}, helper.state), {}, {
|
|
16074
|
-
page: getFirstReceivedPage(helper.state,
|
|
16075
|
-
state: normalizeState(helper.state)
|
|
16076
|
-
}) || {}) - 1
|
|
16116
|
+
page: getFirstReceivedPage(helper.state, cachedHits) - 1
|
|
16077
16117
|
})).searchWithoutTriggeringOnStateChange();
|
|
16078
16118
|
};
|
|
16079
16119
|
};
|
|
16080
|
-
var getShowMore = function getShowMore(helper) {
|
|
16120
|
+
var getShowMore = function getShowMore(helper, getCachedHits) {
|
|
16081
16121
|
return function () {
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
}) || {}) + 1).search();
|
|
16122
|
+
var cachedHits = getCachedHits();
|
|
16123
|
+
helper.setPage(getLastReceivedPage(helper.state, cachedHits) + 1).search();
|
|
16085
16124
|
};
|
|
16086
16125
|
};
|
|
16087
16126
|
return {
|
|
@@ -16113,6 +16152,12 @@
|
|
|
16113
16152
|
parent = _ref6.parent,
|
|
16114
16153
|
existingState = _ref6.state,
|
|
16115
16154
|
instantSearchInstance = _ref6.instantSearchInstance;
|
|
16155
|
+
var getCacheHits = function getCacheHits() {
|
|
16156
|
+
var state = parent.getPreviousState() || existingState;
|
|
16157
|
+
return cache.read({
|
|
16158
|
+
state: normalizeState(state)
|
|
16159
|
+
}) || {};
|
|
16160
|
+
};
|
|
16116
16161
|
var isFirstPage;
|
|
16117
16162
|
var currentPageHits = [];
|
|
16118
16163
|
/**
|
|
@@ -16121,13 +16166,15 @@
|
|
|
16121
16166
|
* is loading.
|
|
16122
16167
|
*/
|
|
16123
16168
|
var state = parent.getPreviousState() || existingState;
|
|
16124
|
-
var cachedHits =
|
|
16125
|
-
state: normalizeState(state)
|
|
16126
|
-
}) || {};
|
|
16169
|
+
var cachedHits = getCacheHits();
|
|
16127
16170
|
var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
|
|
16128
16171
|
if (!showPrevious) {
|
|
16129
|
-
showPrevious =
|
|
16130
|
-
|
|
16172
|
+
showPrevious = function showPrevious() {
|
|
16173
|
+
return getShowPrevious(helper, getCacheHits)();
|
|
16174
|
+
};
|
|
16175
|
+
showMore = function showMore() {
|
|
16176
|
+
return getShowMore(helper, getCacheHits)();
|
|
16177
|
+
};
|
|
16131
16178
|
}
|
|
16132
16179
|
if (!sendEvent) {
|
|
16133
16180
|
sendEvent = createSendEventForHits({
|