react-instantsearch-core 7.7.2 → 7.7.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/lib/useSearchResults.js +9 -0
- package/dist/cjs/version.js +1 -1
- package/dist/es/lib/useSearchResults.js +9 -0
- package/dist/es/version.d.ts +1 -1
- package/dist/es/version.js +1 -1
- package/dist/umd/ReactInstantSearchCore.js +27 -6
- 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 +4 -4
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useSearchResults = useSearchResults;
|
|
7
|
+
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
7
8
|
var _react = require("react");
|
|
8
9
|
var _getIndexSearchResults = require("./getIndexSearchResults");
|
|
9
10
|
var _useIndexContext = require("./useIndexContext");
|
|
@@ -35,6 +36,14 @@ function useSearchResults() {
|
|
|
35
36
|
results: results,
|
|
36
37
|
scopedResults: searchIndex.getScopedResults()
|
|
37
38
|
});
|
|
39
|
+
} else if (search.mainIndex.getIndexName().length === 0) {
|
|
40
|
+
// If the main index has no name, we get the scoped results from
|
|
41
|
+
// the first child index instead.
|
|
42
|
+
var childIndex = search.mainIndex.getWidgets().find(_utils.isIndexWidget);
|
|
43
|
+
childIndex && setSearchResults({
|
|
44
|
+
results: (0, _getIndexSearchResults.getIndexSearchResults)(searchIndex).results,
|
|
45
|
+
scopedResults: childIndex.getScopedResults()
|
|
46
|
+
});
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
search.addListener('render', handleRender);
|
package/dist/cjs/version.js
CHANGED
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
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; }
|
|
5
5
|
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; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { isIndexWidget } from "instantsearch.js/es/lib/utils/index.js";
|
|
7
8
|
import { useEffect, useState } from 'react';
|
|
8
9
|
import { getIndexSearchResults } from "./getIndexSearchResults.js";
|
|
9
10
|
import { useIndexContext } from "./useIndexContext.js";
|
|
@@ -29,6 +30,14 @@ export function useSearchResults() {
|
|
|
29
30
|
results: results,
|
|
30
31
|
scopedResults: searchIndex.getScopedResults()
|
|
31
32
|
});
|
|
33
|
+
} else if (search.mainIndex.getIndexName().length === 0) {
|
|
34
|
+
// If the main index has no name, we get the scoped results from
|
|
35
|
+
// the first child index instead.
|
|
36
|
+
var childIndex = search.mainIndex.getWidgets().find(isIndexWidget);
|
|
37
|
+
childIndex && setSearchResults({
|
|
38
|
+
results: getIndexSearchResults(searchIndex).results,
|
|
39
|
+
scopedResults: childIndex.getScopedResults()
|
|
40
|
+
});
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
search.addListener('render', handleRender);
|
package/dist/es/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.7.
|
|
1
|
+
declare const _default: "7.7.3";
|
|
2
2
|
export default _default;
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '7.7.
|
|
1
|
+
export default '7.7.3';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
var version = '7.7.
|
|
10
|
+
var version = '7.7.3';
|
|
11
11
|
|
|
12
12
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
13
13
|
//
|
|
@@ -4437,7 +4437,7 @@
|
|
|
4437
4437
|
|
|
4438
4438
|
var SearchResults_1 = SearchResults;
|
|
4439
4439
|
|
|
4440
|
-
var version$1 = '3.
|
|
4440
|
+
var version$1 = '3.19.0';
|
|
4441
4441
|
|
|
4442
4442
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4443
4443
|
|
|
@@ -9565,9 +9565,18 @@
|
|
|
9565
9565
|
},
|
|
9566
9566
|
getScopedResults: function getScopedResults() {
|
|
9567
9567
|
var widgetParent = this.getParent();
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9568
|
+
var widgetSiblings;
|
|
9569
|
+
if (widgetParent) {
|
|
9570
|
+
widgetSiblings = widgetParent.getWidgets();
|
|
9571
|
+
} else if (indexName.length === 0) {
|
|
9572
|
+
// The widget is the root but has no index name:
|
|
9573
|
+
// we resolve results from its children index widgets
|
|
9574
|
+
widgetSiblings = this.getWidgets();
|
|
9575
|
+
} else {
|
|
9576
|
+
// The widget is the root and has an index name:
|
|
9577
|
+
// we consider itself as the only sibling
|
|
9578
|
+
widgetSiblings = [this];
|
|
9579
|
+
}
|
|
9571
9580
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
9572
9581
|
},
|
|
9573
9582
|
getParent: function getParent() {
|
|
@@ -12213,7 +12222,7 @@
|
|
|
12213
12222
|
};
|
|
12214
12223
|
}
|
|
12215
12224
|
|
|
12216
|
-
var version$2 = '4.
|
|
12225
|
+
var version$2 = '4.68.0';
|
|
12217
12226
|
|
|
12218
12227
|
function _typeof$k(obj) {
|
|
12219
12228
|
"@babel/helpers - typeof";
|
|
@@ -14667,6 +14676,7 @@
|
|
|
14667
14676
|
});
|
|
14668
14677
|
},
|
|
14669
14678
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
14679
|
+
var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
|
|
14670
14680
|
var results = _ref2.results,
|
|
14671
14681
|
helper = _ref2.helper,
|
|
14672
14682
|
instantSearchInstance = _ref2.instantSearchInstance;
|
|
@@ -14692,6 +14702,7 @@
|
|
|
14692
14702
|
return {
|
|
14693
14703
|
hits: [],
|
|
14694
14704
|
results: undefined,
|
|
14705
|
+
banner: undefined,
|
|
14695
14706
|
sendEvent: sendEvent,
|
|
14696
14707
|
bindEvent: bindEvent,
|
|
14697
14708
|
widgetParams: widgetParams
|
|
@@ -14705,9 +14716,11 @@
|
|
|
14705
14716
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
14706
14717
|
results: results
|
|
14707
14718
|
});
|
|
14719
|
+
var banner = (_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];
|
|
14708
14720
|
return {
|
|
14709
14721
|
hits: transformedHits,
|
|
14710
14722
|
results: results,
|
|
14723
|
+
banner: banner,
|
|
14711
14724
|
sendEvent: sendEvent,
|
|
14712
14725
|
bindEvent: bindEvent,
|
|
14713
14726
|
widgetParams: widgetParams
|
|
@@ -18255,6 +18268,14 @@
|
|
|
18255
18268
|
results: results,
|
|
18256
18269
|
scopedResults: searchIndex.getScopedResults()
|
|
18257
18270
|
});
|
|
18271
|
+
} else if (search.mainIndex.getIndexName().length === 0) {
|
|
18272
|
+
// If the main index has no name, we get the scoped results from
|
|
18273
|
+
// the first child index instead.
|
|
18274
|
+
var childIndex = search.mainIndex.getWidgets().find(isIndexWidget);
|
|
18275
|
+
childIndex && setSearchResults({
|
|
18276
|
+
results: getIndexSearchResults(searchIndex).results,
|
|
18277
|
+
scopedResults: childIndex.getScopedResults()
|
|
18278
|
+
});
|
|
18258
18279
|
}
|
|
18259
18280
|
}
|
|
18260
18281
|
search.addListener('render', handleRender);
|