react-instantsearch-core 6.26.0 → 6.29.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/dist/cjs/core/version.js +1 -1
- package/dist/cjs/widgets/DynamicWidgets.js +12 -8
- package/dist/es/core/version.js +1 -1
- package/dist/es/widgets/DynamicWidgets.js +12 -8
- package/dist/umd/ReactInstantSearchCore.js +138 -70
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +2 -2
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/core/version.js
CHANGED
|
@@ -21,21 +21,25 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
23
|
|
|
24
|
-
function
|
|
25
|
-
|
|
24
|
+
function isReactElement(element) {
|
|
25
|
+
return (0, _typeof2.default)(element) === 'object' && element.props;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getAttribute(element) {
|
|
29
|
+
if (!isReactElement(element)) {
|
|
26
30
|
return undefined;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
33
|
+
if (element.props.attribute) {
|
|
34
|
+
return element.props.attribute;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
if (Array.isArray(
|
|
34
|
-
return
|
|
37
|
+
if (Array.isArray(element.props.attributes)) {
|
|
38
|
+
return element.props.attributes[0];
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
if (
|
|
38
|
-
return getAttribute(_react.default.Children.only(
|
|
41
|
+
if (element.props.children) {
|
|
42
|
+
return getAttribute(_react.default.Children.only(element.props.children));
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
return undefined;
|
package/dist/es/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '6.
|
|
1
|
+
export default '6.29.0';
|
|
@@ -3,21 +3,25 @@ import React, { Fragment } from 'react';
|
|
|
3
3
|
import { getDisplayName } from "../core/utils.js";
|
|
4
4
|
import connectDynamicWidgets from "../connectors/connectDynamicWidgets.js";
|
|
5
5
|
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
function isReactElement(element) {
|
|
7
|
+
return _typeof(element) === 'object' && element.props;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getAttribute(element) {
|
|
11
|
+
if (!isReactElement(element)) {
|
|
8
12
|
return undefined;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
15
|
+
if (element.props.attribute) {
|
|
16
|
+
return element.props.attribute;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
if (Array.isArray(
|
|
16
|
-
return
|
|
19
|
+
if (Array.isArray(element.props.attributes)) {
|
|
20
|
+
return element.props.attributes[0];
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
if (
|
|
20
|
-
return getAttribute(React.Children.only(
|
|
23
|
+
if (element.props.children) {
|
|
24
|
+
return getAttribute(React.Children.only(element.props.children));
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
return undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearchCore 6.
|
|
1
|
+
/*! React InstantSearchCore 6.29.0 | © Algolia, inc. | https://github.com/algolia/react-instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
@@ -848,7 +848,7 @@
|
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
-
var version = '6.
|
|
851
|
+
var version = '6.29.0';
|
|
852
852
|
|
|
853
853
|
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
854
854
|
|
|
@@ -3242,20 +3242,24 @@
|
|
|
3242
3242
|
/**
|
|
3243
3243
|
* Replaces a leading - with \-
|
|
3244
3244
|
* @private
|
|
3245
|
-
* @param {
|
|
3246
|
-
* @returns
|
|
3245
|
+
* @param {any} value the facet value to replace
|
|
3246
|
+
* @returns any
|
|
3247
3247
|
*/
|
|
3248
3248
|
function escapeFacetValue(value) {
|
|
3249
|
-
|
|
3249
|
+
if (typeof value !== 'string') return value;
|
|
3250
|
+
|
|
3251
|
+
return String(value).replace(/^-/, '\\-');
|
|
3250
3252
|
}
|
|
3251
3253
|
|
|
3252
3254
|
/**
|
|
3253
3255
|
* Replaces a leading \- with -
|
|
3254
3256
|
* @private
|
|
3255
|
-
* @param {
|
|
3256
|
-
* @returns
|
|
3257
|
+
* @param {any} value the escaped facet value
|
|
3258
|
+
* @returns any
|
|
3257
3259
|
*/
|
|
3258
3260
|
function unescapeFacetValue$1(value) {
|
|
3261
|
+
if (typeof value !== 'string') return value;
|
|
3262
|
+
|
|
3259
3263
|
return value.replace(/^\\-/, '-');
|
|
3260
3264
|
}
|
|
3261
3265
|
|
|
@@ -3980,7 +3984,7 @@
|
|
|
3980
3984
|
nextDisjunctiveResult++;
|
|
3981
3985
|
});
|
|
3982
3986
|
|
|
3983
|
-
// if we have some
|
|
3987
|
+
// if we have some parent level values for hierarchical facets, merge them
|
|
3984
3988
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
3985
3989
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
3986
3990
|
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
|
|
@@ -3992,47 +3996,49 @@
|
|
|
3992
3996
|
return;
|
|
3993
3997
|
}
|
|
3994
3998
|
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
Object.keys(facets).forEach(function(dfacet) {
|
|
4000
|
-
var facetResults = facets[dfacet];
|
|
4001
|
-
var position = findIndex(state.hierarchicalFacets, function(f) {
|
|
4002
|
-
return f.name === hierarchicalFacet.name;
|
|
4003
|
-
});
|
|
4004
|
-
var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {
|
|
4005
|
-
return f.attribute === dfacet;
|
|
4006
|
-
});
|
|
3999
|
+
results.slice(nextDisjunctiveResult).forEach(function(result) {
|
|
4000
|
+
var facets = result && result.facets
|
|
4001
|
+
? result.facets
|
|
4002
|
+
: {};
|
|
4007
4003
|
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4004
|
+
Object.keys(facets).forEach(function(dfacet) {
|
|
4005
|
+
var facetResults = facets[dfacet];
|
|
4006
|
+
var position = findIndex(state.hierarchicalFacets, function(f) {
|
|
4007
|
+
return f.name === hierarchicalFacet.name;
|
|
4008
|
+
});
|
|
4009
|
+
var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {
|
|
4010
|
+
return f.attribute === dfacet;
|
|
4011
|
+
});
|
|
4012
4012
|
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
// > IPA (5)
|
|
4018
|
-
// We want
|
|
4019
|
-
// | beers (5)
|
|
4020
|
-
// > IPA (5)
|
|
4021
|
-
var defaultData = {};
|
|
4022
|
-
|
|
4023
|
-
if (currentRefinement.length > 0) {
|
|
4024
|
-
var root = currentRefinement[0].split(separator)[0];
|
|
4025
|
-
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
|
|
4026
|
-
}
|
|
4013
|
+
// previous refinements and no results so not able to find it
|
|
4014
|
+
if (attributeIndex === -1) {
|
|
4015
|
+
return;
|
|
4016
|
+
}
|
|
4027
4017
|
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4018
|
+
// when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),
|
|
4019
|
+
// then the disjunctive values will be `beers` (count: 100),
|
|
4020
|
+
// but we do not want to display
|
|
4021
|
+
// | beers (100)
|
|
4022
|
+
// > IPA (5)
|
|
4023
|
+
// We want
|
|
4024
|
+
// | beers (5)
|
|
4025
|
+
// > IPA (5)
|
|
4026
|
+
var defaultData = {};
|
|
4027
|
+
|
|
4028
|
+
if (currentRefinement.length > 0) {
|
|
4029
|
+
var root = currentRefinement[0].split(separator)[0];
|
|
4030
|
+
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
|
|
4031
|
+
}
|
|
4034
4032
|
|
|
4035
|
-
|
|
4033
|
+
self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(
|
|
4034
|
+
defaultData,
|
|
4035
|
+
facetResults,
|
|
4036
|
+
self.hierarchicalFacets[position][attributeIndex].data
|
|
4037
|
+
);
|
|
4038
|
+
});
|
|
4039
|
+
|
|
4040
|
+
nextDisjunctiveResult++;
|
|
4041
|
+
});
|
|
4036
4042
|
});
|
|
4037
4043
|
|
|
4038
4044
|
// add the excludes
|
|
@@ -4836,6 +4842,17 @@
|
|
|
4836
4842
|
|
|
4837
4843
|
var DerivedHelper_1 = DerivedHelper;
|
|
4838
4844
|
|
|
4845
|
+
function sortObject(obj) {
|
|
4846
|
+
return Object.keys(obj)
|
|
4847
|
+
.sort(function(a, b) {
|
|
4848
|
+
return a.localeCompare(b);
|
|
4849
|
+
})
|
|
4850
|
+
.reduce(function(acc, curr) {
|
|
4851
|
+
acc[curr] = obj[curr];
|
|
4852
|
+
return acc;
|
|
4853
|
+
}, {});
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4839
4856
|
var requestBuilder = {
|
|
4840
4857
|
/**
|
|
4841
4858
|
* Get all the queries to send to the client, those queries can used directly
|
|
@@ -4860,18 +4877,38 @@
|
|
|
4860
4877
|
});
|
|
4861
4878
|
});
|
|
4862
4879
|
|
|
4863
|
-
//
|
|
4880
|
+
// More to get the parent levels of the hierarchical facets when refined
|
|
4864
4881
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
4865
4882
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
4866
|
-
|
|
4867
4883
|
var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
|
|
4868
|
-
// if we are deeper than level 0 (starting from `beer > IPA`)
|
|
4869
|
-
// we want to get the root values
|
|
4870
4884
|
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
|
|
4885
|
+
|
|
4886
|
+
// If we are deeper than level 0 (starting from `beer > IPA`)
|
|
4887
|
+
// we want to get all parent values
|
|
4871
4888
|
if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {
|
|
4872
|
-
queries
|
|
4873
|
-
|
|
4874
|
-
|
|
4889
|
+
// We generate a map of the filters we will use for our facet values queries
|
|
4890
|
+
var filtersMap = currentRefinement[0].split(separator).slice(0, -1).reduce(
|
|
4891
|
+
function createFiltersMap(map, segment, level) {
|
|
4892
|
+
return map.concat({
|
|
4893
|
+
attribute: hierarchicalFacet.attributes[level],
|
|
4894
|
+
value: level === 0
|
|
4895
|
+
? segment
|
|
4896
|
+
: [map[map.length - 1].value, segment].join(separator)
|
|
4897
|
+
});
|
|
4898
|
+
}
|
|
4899
|
+
, []);
|
|
4900
|
+
|
|
4901
|
+
filtersMap.forEach(function(filter, level) {
|
|
4902
|
+
var params = requestBuilder._getDisjunctiveFacetSearchParams(
|
|
4903
|
+
state,
|
|
4904
|
+
filter.attribute,
|
|
4905
|
+
level === 0
|
|
4906
|
+
);
|
|
4907
|
+
|
|
4908
|
+
var parent = filtersMap[level - 1];
|
|
4909
|
+
params.facetFilters = level > 0 ? [parent.attribute + ':' + parent.value] : undefined;
|
|
4910
|
+
|
|
4911
|
+
queries.push({indexName: index, params: params});
|
|
4875
4912
|
});
|
|
4876
4913
|
}
|
|
4877
4914
|
});
|
|
@@ -4906,7 +4943,7 @@
|
|
|
4906
4943
|
additionalParams.numericFilters = numericFilters;
|
|
4907
4944
|
}
|
|
4908
4945
|
|
|
4909
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
4946
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
4910
4947
|
},
|
|
4911
4948
|
|
|
4912
4949
|
/**
|
|
@@ -4951,7 +4988,7 @@
|
|
|
4951
4988
|
additionalParams.facetFilters = facetFilters;
|
|
4952
4989
|
}
|
|
4953
4990
|
|
|
4954
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
4991
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
4955
4992
|
},
|
|
4956
4993
|
|
|
4957
4994
|
/**
|
|
@@ -5144,17 +5181,17 @@
|
|
|
5144
5181
|
if (typeof maxFacetHits === 'number') {
|
|
5145
5182
|
searchForFacetSearchParameters.maxFacetHits = maxFacetHits;
|
|
5146
5183
|
}
|
|
5147
|
-
return merge_1(
|
|
5184
|
+
return sortObject(merge_1(
|
|
5148
5185
|
{},
|
|
5149
5186
|
requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),
|
|
5150
5187
|
searchForFacetSearchParameters
|
|
5151
|
-
);
|
|
5188
|
+
));
|
|
5152
5189
|
}
|
|
5153
5190
|
};
|
|
5154
5191
|
|
|
5155
5192
|
var requestBuilder_1 = requestBuilder;
|
|
5156
5193
|
|
|
5157
|
-
var version$1 = '3.
|
|
5194
|
+
var version$1 = '3.9.0';
|
|
5158
5195
|
|
|
5159
5196
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
5160
5197
|
|
|
@@ -5474,20 +5511,51 @@
|
|
|
5474
5511
|
*/
|
|
5475
5512
|
AlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {
|
|
5476
5513
|
var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';
|
|
5514
|
+
var clientHasInitIndex = typeof this.client.initIndex === 'function';
|
|
5477
5515
|
if (
|
|
5478
5516
|
!clientHasSFFV &&
|
|
5479
|
-
|
|
5517
|
+
!clientHasInitIndex &&
|
|
5518
|
+
typeof this.client.search !== 'function'
|
|
5480
5519
|
) {
|
|
5481
5520
|
throw new Error(
|
|
5482
5521
|
'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'
|
|
5483
5522
|
);
|
|
5484
5523
|
}
|
|
5524
|
+
|
|
5485
5525
|
var state = this.state.setQueryParameters(userState || {});
|
|
5486
5526
|
var isDisjunctive = state.isDisjunctiveFacet(facet);
|
|
5487
5527
|
var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(facet, query, maxFacetHits, state);
|
|
5488
5528
|
|
|
5489
5529
|
this._currentNbQueries++;
|
|
5490
5530
|
var self = this;
|
|
5531
|
+
var searchForFacetValuesPromise;
|
|
5532
|
+
// newer algoliasearch ^3.27.1 - ~4.0.0
|
|
5533
|
+
if (clientHasSFFV) {
|
|
5534
|
+
searchForFacetValuesPromise = this.client.searchForFacetValues([
|
|
5535
|
+
{indexName: state.index, params: algoliaQuery}
|
|
5536
|
+
]);
|
|
5537
|
+
// algoliasearch < 3.27.1
|
|
5538
|
+
} else if (clientHasInitIndex) {
|
|
5539
|
+
searchForFacetValuesPromise = this.client
|
|
5540
|
+
.initIndex(state.index)
|
|
5541
|
+
.searchForFacetValues(algoliaQuery);
|
|
5542
|
+
// algoliasearch ~5.0.0
|
|
5543
|
+
} else {
|
|
5544
|
+
// @MAJOR only use client.search
|
|
5545
|
+
delete algoliaQuery.facetName;
|
|
5546
|
+
searchForFacetValuesPromise = this.client
|
|
5547
|
+
.search([
|
|
5548
|
+
{
|
|
5549
|
+
type: 'facet',
|
|
5550
|
+
facet: facet,
|
|
5551
|
+
indexName: state.index,
|
|
5552
|
+
params: algoliaQuery
|
|
5553
|
+
}
|
|
5554
|
+
])
|
|
5555
|
+
.then(function processResponse(response) {
|
|
5556
|
+
return response.results[0];
|
|
5557
|
+
});
|
|
5558
|
+
}
|
|
5491
5559
|
|
|
5492
5560
|
this.emit('searchForFacetValues', {
|
|
5493
5561
|
state: state,
|
|
@@ -5495,10 +5563,6 @@
|
|
|
5495
5563
|
query: query
|
|
5496
5564
|
});
|
|
5497
5565
|
|
|
5498
|
-
var searchForFacetValuesPromise = clientHasSFFV
|
|
5499
|
-
? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])
|
|
5500
|
-
: this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);
|
|
5501
|
-
|
|
5502
5566
|
return searchForFacetValuesPromise.then(function addIsRefined(content) {
|
|
5503
5567
|
self._currentNbQueries--;
|
|
5504
5568
|
if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
|
|
@@ -7050,21 +7114,25 @@
|
|
|
7050
7114
|
}
|
|
7051
7115
|
});
|
|
7052
7116
|
|
|
7053
|
-
function
|
|
7054
|
-
|
|
7117
|
+
function isReactElement(element) {
|
|
7118
|
+
return _typeof(element) === 'object' && element.props;
|
|
7119
|
+
}
|
|
7120
|
+
|
|
7121
|
+
function getAttribute(element) {
|
|
7122
|
+
if (!isReactElement(element)) {
|
|
7055
7123
|
return undefined;
|
|
7056
7124
|
}
|
|
7057
7125
|
|
|
7058
|
-
if (
|
|
7059
|
-
return
|
|
7126
|
+
if (element.props.attribute) {
|
|
7127
|
+
return element.props.attribute;
|
|
7060
7128
|
}
|
|
7061
7129
|
|
|
7062
|
-
if (Array.isArray(
|
|
7063
|
-
return
|
|
7130
|
+
if (Array.isArray(element.props.attributes)) {
|
|
7131
|
+
return element.props.attributes[0];
|
|
7064
7132
|
}
|
|
7065
7133
|
|
|
7066
|
-
if (
|
|
7067
|
-
return getAttribute(React__default.Children.only(
|
|
7134
|
+
if (element.props.children) {
|
|
7135
|
+
return getAttribute(React__default.Children.only(element.props.children));
|
|
7068
7136
|
}
|
|
7069
7137
|
|
|
7070
7138
|
return undefined;
|