react-instantsearch-core 6.28.0 → 6.30.1
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/es/core/version.js +1 -1
- package/dist/umd/ReactInstantSearchCore.js +122 -62
- 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
package/dist/es/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '6.
|
|
1
|
+
export default '6.30.1';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearchCore 6.
|
|
1
|
+
/*! React InstantSearchCore 6.30.1 | © 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.30.1';
|
|
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
|
|
|
@@ -3984,7 +3984,7 @@
|
|
|
3984
3984
|
nextDisjunctiveResult++;
|
|
3985
3985
|
});
|
|
3986
3986
|
|
|
3987
|
-
// if we have some
|
|
3987
|
+
// if we have some parent level values for hierarchical facets, merge them
|
|
3988
3988
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
3989
3989
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
3990
3990
|
var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
|
|
@@ -3996,47 +3996,49 @@
|
|
|
3996
3996
|
return;
|
|
3997
3997
|
}
|
|
3998
3998
|
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
Object.keys(facets).forEach(function(dfacet) {
|
|
4004
|
-
var facetResults = facets[dfacet];
|
|
4005
|
-
var position = findIndex(state.hierarchicalFacets, function(f) {
|
|
4006
|
-
return f.name === hierarchicalFacet.name;
|
|
4007
|
-
});
|
|
4008
|
-
var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {
|
|
4009
|
-
return f.attribute === dfacet;
|
|
4010
|
-
});
|
|
3999
|
+
results.slice(nextDisjunctiveResult).forEach(function(result) {
|
|
4000
|
+
var facets = result && result.facets
|
|
4001
|
+
? result.facets
|
|
4002
|
+
: {};
|
|
4011
4003
|
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
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
|
+
});
|
|
4016
4012
|
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
// > IPA (5)
|
|
4022
|
-
// We want
|
|
4023
|
-
// | beers (5)
|
|
4024
|
-
// > IPA (5)
|
|
4025
|
-
var defaultData = {};
|
|
4026
|
-
|
|
4027
|
-
if (currentRefinement.length > 0) {
|
|
4028
|
-
var root = currentRefinement[0].split(separator)[0];
|
|
4029
|
-
defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
|
|
4030
|
-
}
|
|
4013
|
+
// previous refinements and no results so not able to find it
|
|
4014
|
+
if (attributeIndex === -1) {
|
|
4015
|
+
return;
|
|
4016
|
+
}
|
|
4031
4017
|
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
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
|
+
}
|
|
4038
4032
|
|
|
4039
|
-
|
|
4033
|
+
self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(
|
|
4034
|
+
defaultData,
|
|
4035
|
+
facetResults,
|
|
4036
|
+
self.hierarchicalFacets[position][attributeIndex].data
|
|
4037
|
+
);
|
|
4038
|
+
});
|
|
4039
|
+
|
|
4040
|
+
nextDisjunctiveResult++;
|
|
4041
|
+
});
|
|
4040
4042
|
});
|
|
4041
4043
|
|
|
4042
4044
|
// add the excludes
|
|
@@ -4840,6 +4842,17 @@
|
|
|
4840
4842
|
|
|
4841
4843
|
var DerivedHelper_1 = DerivedHelper;
|
|
4842
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
|
+
|
|
4843
4856
|
var requestBuilder = {
|
|
4844
4857
|
/**
|
|
4845
4858
|
* Get all the queries to send to the client, those queries can used directly
|
|
@@ -4864,18 +4877,38 @@
|
|
|
4864
4877
|
});
|
|
4865
4878
|
});
|
|
4866
4879
|
|
|
4867
|
-
//
|
|
4880
|
+
// More to get the parent levels of the hierarchical facets when refined
|
|
4868
4881
|
state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {
|
|
4869
4882
|
var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
|
|
4870
|
-
|
|
4871
4883
|
var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
|
|
4872
|
-
// if we are deeper than level 0 (starting from `beer > IPA`)
|
|
4873
|
-
// we want to get the root values
|
|
4874
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
|
|
4875
4888
|
if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {
|
|
4876
|
-
queries
|
|
4877
|
-
|
|
4878
|
-
|
|
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});
|
|
4879
4912
|
});
|
|
4880
4913
|
}
|
|
4881
4914
|
});
|
|
@@ -4910,7 +4943,7 @@
|
|
|
4910
4943
|
additionalParams.numericFilters = numericFilters;
|
|
4911
4944
|
}
|
|
4912
4945
|
|
|
4913
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
4946
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
4914
4947
|
},
|
|
4915
4948
|
|
|
4916
4949
|
/**
|
|
@@ -4925,16 +4958,16 @@
|
|
|
4925
4958
|
var numericFilters = requestBuilder._getNumericFilters(state, facet);
|
|
4926
4959
|
var tagFilters = requestBuilder._getTagFilters(state);
|
|
4927
4960
|
var additionalParams = {
|
|
4928
|
-
hitsPerPage:
|
|
4961
|
+
hitsPerPage: 0,
|
|
4929
4962
|
page: 0,
|
|
4930
|
-
attributesToRetrieve: [],
|
|
4931
|
-
attributesToHighlight: [],
|
|
4932
|
-
attributesToSnippet: [],
|
|
4933
|
-
tagFilters: tagFilters,
|
|
4934
4963
|
analytics: false,
|
|
4935
4964
|
clickAnalytics: false
|
|
4936
4965
|
};
|
|
4937
4966
|
|
|
4967
|
+
if (tagFilters.length > 0) {
|
|
4968
|
+
additionalParams.tagFilters = tagFilters;
|
|
4969
|
+
}
|
|
4970
|
+
|
|
4938
4971
|
var hierarchicalFacet = state.getHierarchicalFacetByName(facet);
|
|
4939
4972
|
|
|
4940
4973
|
if (hierarchicalFacet) {
|
|
@@ -4955,7 +4988,7 @@
|
|
|
4955
4988
|
additionalParams.facetFilters = facetFilters;
|
|
4956
4989
|
}
|
|
4957
4990
|
|
|
4958
|
-
return merge_1({}, state.getQueryParams(), additionalParams);
|
|
4991
|
+
return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
|
|
4959
4992
|
},
|
|
4960
4993
|
|
|
4961
4994
|
/**
|
|
@@ -5148,17 +5181,17 @@
|
|
|
5148
5181
|
if (typeof maxFacetHits === 'number') {
|
|
5149
5182
|
searchForFacetSearchParameters.maxFacetHits = maxFacetHits;
|
|
5150
5183
|
}
|
|
5151
|
-
return merge_1(
|
|
5184
|
+
return sortObject(merge_1(
|
|
5152
5185
|
{},
|
|
5153
5186
|
requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),
|
|
5154
5187
|
searchForFacetSearchParameters
|
|
5155
|
-
);
|
|
5188
|
+
));
|
|
5156
5189
|
}
|
|
5157
5190
|
};
|
|
5158
5191
|
|
|
5159
5192
|
var requestBuilder_1 = requestBuilder;
|
|
5160
5193
|
|
|
5161
|
-
var version$1 = '3.
|
|
5194
|
+
var version$1 = '3.10.0';
|
|
5162
5195
|
|
|
5163
5196
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
5164
5197
|
|
|
@@ -5478,20 +5511,51 @@
|
|
|
5478
5511
|
*/
|
|
5479
5512
|
AlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {
|
|
5480
5513
|
var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';
|
|
5514
|
+
var clientHasInitIndex = typeof this.client.initIndex === 'function';
|
|
5481
5515
|
if (
|
|
5482
5516
|
!clientHasSFFV &&
|
|
5483
|
-
|
|
5517
|
+
!clientHasInitIndex &&
|
|
5518
|
+
typeof this.client.search !== 'function'
|
|
5484
5519
|
) {
|
|
5485
5520
|
throw new Error(
|
|
5486
5521
|
'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'
|
|
5487
5522
|
);
|
|
5488
5523
|
}
|
|
5524
|
+
|
|
5489
5525
|
var state = this.state.setQueryParameters(userState || {});
|
|
5490
5526
|
var isDisjunctive = state.isDisjunctiveFacet(facet);
|
|
5491
5527
|
var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(facet, query, maxFacetHits, state);
|
|
5492
5528
|
|
|
5493
5529
|
this._currentNbQueries++;
|
|
5494
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
|
+
}
|
|
5495
5559
|
|
|
5496
5560
|
this.emit('searchForFacetValues', {
|
|
5497
5561
|
state: state,
|
|
@@ -5499,10 +5563,6 @@
|
|
|
5499
5563
|
query: query
|
|
5500
5564
|
});
|
|
5501
5565
|
|
|
5502
|
-
var searchForFacetValuesPromise = clientHasSFFV
|
|
5503
|
-
? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])
|
|
5504
|
-
: this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);
|
|
5505
|
-
|
|
5506
5566
|
return searchForFacetValuesPromise.then(function addIsRefined(content) {
|
|
5507
5567
|
self._currentNbQueries--;
|
|
5508
5568
|
if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
|