react-instantsearch-core 6.23.0 → 6.23.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/connectors/connectBreadcrumb.js +3 -3
- package/dist/cjs/connectors/connectHierarchicalMenu.js +8 -6
- package/dist/cjs/connectors/connectMenu.js +7 -5
- package/dist/cjs/connectors/connectRefinementList.js +9 -7
- package/dist/cjs/core/createInstantSearchManager.js +6 -3
- package/dist/cjs/core/utils.js +5 -0
- package/dist/cjs/core/version.js +1 -1
- package/dist/es/connectors/connectBreadcrumb.js +3 -3
- package/dist/es/connectors/connectHierarchicalMenu.js +7 -6
- package/dist/es/connectors/connectMenu.js +6 -5
- package/dist/es/connectors/connectRefinementList.js +8 -7
- package/dist/es/core/createInstantSearchManager.js +6 -3
- package/dist/es/core/utils.js +3 -0
- package/dist/es/core/version.js +1 -1
- package/dist/umd/ReactInstantSearchCore.js +81 -33
- 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 +3 -3
|
@@ -34,9 +34,9 @@ function transformValue(values) {
|
|
|
34
34
|
if (item.isRefined) {
|
|
35
35
|
acc.push({
|
|
36
36
|
label: item.name,
|
|
37
|
-
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current
|
|
38
|
-
// If dealing with the first level, "value" is equal to the current
|
|
39
|
-
value: item.
|
|
37
|
+
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
38
|
+
// If dealing with the first level, "value" is equal to the current value
|
|
39
|
+
value: item.escapedValue
|
|
40
40
|
}); // Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
41
41
|
|
|
42
42
|
if (item.data) {
|
|
@@ -17,6 +17,8 @@ var _createConnector = _interopRequireDefault(require("../core/createConnector")
|
|
|
17
17
|
|
|
18
18
|
var _indexUtils = require("../core/indexUtils");
|
|
19
19
|
|
|
20
|
+
var _utils = require("../core/utils");
|
|
21
|
+
|
|
20
22
|
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; }
|
|
21
23
|
|
|
22
24
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -38,7 +40,7 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
38
40
|
return currentRefinement;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
function getValue(
|
|
43
|
+
function getValue(value, props, searchState, context) {
|
|
42
44
|
var id = props.id,
|
|
43
45
|
attributes = props.attributes,
|
|
44
46
|
separator = props.separator,
|
|
@@ -48,7 +50,7 @@ function getValue(path, props, searchState, context) {
|
|
|
48
50
|
var nextRefinement;
|
|
49
51
|
|
|
50
52
|
if (currentRefinement === null) {
|
|
51
|
-
nextRefinement =
|
|
53
|
+
nextRefinement = value;
|
|
52
54
|
} else {
|
|
53
55
|
var tmpSearchParameters = new _algoliasearchHelper.default.SearchParameters({
|
|
54
56
|
hierarchicalFacets: [{
|
|
@@ -59,7 +61,7 @@ function getValue(path, props, searchState, context) {
|
|
|
59
61
|
showParentLevel: showParentLevel
|
|
60
62
|
}]
|
|
61
63
|
});
|
|
62
|
-
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id,
|
|
64
|
+
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
return nextRefinement;
|
|
@@ -69,7 +71,7 @@ function transformValue(value, props, searchState, context) {
|
|
|
69
71
|
return value.map(function (v) {
|
|
70
72
|
return {
|
|
71
73
|
label: v.name,
|
|
72
|
-
value: getValue(v.
|
|
74
|
+
value: getValue(v.escapedValue, props, searchState, context),
|
|
73
75
|
count: v.count,
|
|
74
76
|
isRefined: v.isRefined,
|
|
75
77
|
items: v.data && transformValue(v.data, props, searchState, context)
|
|
@@ -107,7 +109,7 @@ var sortBy = ['name:asc'];
|
|
|
107
109
|
* websites. From a UX point of view, we suggest not displaying more than two levels deep.
|
|
108
110
|
* @name connectHierarchicalMenu
|
|
109
111
|
* @requirements To use this widget, your attributes must be formatted in a specific way.
|
|
110
|
-
* If you want for example to have a
|
|
112
|
+
* If you want for example to have a hierarchical menu of categories, objects in your index
|
|
111
113
|
* should be formatted this way:
|
|
112
114
|
*
|
|
113
115
|
* ```json
|
|
@@ -272,7 +274,7 @@ var _default = (0, _createConnector.default)({
|
|
|
272
274
|
multiIndexContext: props.indexContextValue
|
|
273
275
|
});
|
|
274
276
|
var items = !currentRefinement ? [] : [{
|
|
275
|
-
label: "".concat(rootAttribute, ": ").concat(currentRefinement),
|
|
277
|
+
label: "".concat(rootAttribute, ": ").concat((0, _utils.unescapeFacetValue)(currentRefinement)),
|
|
276
278
|
attribute: rootAttribute,
|
|
277
279
|
value: function value(nextState) {
|
|
278
280
|
return _refine(props, nextState, '', {
|
|
@@ -15,6 +15,8 @@ var _createConnector = _interopRequireDefault(require("../core/createConnector")
|
|
|
15
15
|
|
|
16
16
|
var _indexUtils = require("../core/indexUtils");
|
|
17
17
|
|
|
18
|
+
var _utils = require("../core/utils");
|
|
19
|
+
|
|
18
20
|
var namespace = 'menu';
|
|
19
21
|
|
|
20
22
|
function getId(props) {
|
|
@@ -31,9 +33,9 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
31
33
|
return currentRefinement;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
function getValue(
|
|
36
|
+
function getValue(value, props, searchState, context) {
|
|
35
37
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
36
|
-
return
|
|
38
|
+
return value === currentRefinement ? '' : value;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
function getLimit(_ref) {
|
|
@@ -129,7 +131,7 @@ var _default = (0, _createConnector.default)({
|
|
|
129
131
|
items = searchForFacetValuesResults[attribute].map(function (v) {
|
|
130
132
|
return {
|
|
131
133
|
label: v.value,
|
|
132
|
-
value: getValue(v.
|
|
134
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
133
135
|
ais: props.contextValue,
|
|
134
136
|
multiIndexContext: props.indexContextValue
|
|
135
137
|
}),
|
|
@@ -149,7 +151,7 @@ var _default = (0, _createConnector.default)({
|
|
|
149
151
|
}).map(function (v) {
|
|
150
152
|
return {
|
|
151
153
|
label: v.name,
|
|
152
|
-
value: getValue(v.
|
|
154
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
153
155
|
ais: props.contextValue,
|
|
154
156
|
multiIndexContext: props.indexContextValue
|
|
155
157
|
}),
|
|
@@ -220,7 +222,7 @@ var _default = (0, _createConnector.default)({
|
|
|
220
222
|
multiIndexContext: props.indexContextValue
|
|
221
223
|
}),
|
|
222
224
|
items: currentRefinement === null ? [] : [{
|
|
223
|
-
label: "".concat(props.attribute, ": ").concat(currentRefinement),
|
|
225
|
+
label: "".concat(props.attribute, ": ").concat((0, _utils.unescapeFacetValue)(currentRefinement)),
|
|
224
226
|
attribute: props.attribute,
|
|
225
227
|
value: function value(nextState) {
|
|
226
228
|
return _refine(props, nextState, '', {
|
|
@@ -15,6 +15,8 @@ var _createConnector = _interopRequireDefault(require("../core/createConnector")
|
|
|
15
15
|
|
|
16
16
|
var _indexUtils = require("../core/indexUtils");
|
|
17
17
|
|
|
18
|
+
var _utils = require("../core/utils");
|
|
19
|
+
|
|
18
20
|
var namespace = 'refinementList';
|
|
19
21
|
|
|
20
22
|
function getId(props) {
|
|
@@ -35,12 +37,12 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
35
37
|
return [];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
function getValue(
|
|
40
|
+
function getValue(value, props, searchState, context) {
|
|
39
41
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
40
|
-
var isAnewValue = currentRefinement.indexOf(
|
|
41
|
-
var nextRefinement = isAnewValue ? currentRefinement.concat([
|
|
42
|
+
var isAnewValue = currentRefinement.indexOf(value) === -1;
|
|
43
|
+
var nextRefinement = isAnewValue ? currentRefinement.concat([value]) // cannot use .push(), it mutates
|
|
42
44
|
: currentRefinement.filter(function (selectedValue) {
|
|
43
|
-
return selectedValue !==
|
|
45
|
+
return selectedValue !== value;
|
|
44
46
|
}); // cannot use .splice(), it mutates
|
|
45
47
|
|
|
46
48
|
return nextRefinement;
|
|
@@ -150,7 +152,7 @@ var _default = (0, _createConnector.default)({
|
|
|
150
152
|
var items = isFromSearch ? searchForFacetValuesResults[attribute].map(function (v) {
|
|
151
153
|
return {
|
|
152
154
|
label: v.value,
|
|
153
|
-
value: getValue(v.
|
|
155
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
154
156
|
ais: props.contextValue,
|
|
155
157
|
multiIndexContext: props.indexContextValue
|
|
156
158
|
}),
|
|
@@ -168,7 +170,7 @@ var _default = (0, _createConnector.default)({
|
|
|
168
170
|
}).map(function (v) {
|
|
169
171
|
return {
|
|
170
172
|
label: v.name,
|
|
171
|
-
value: getValue(v.
|
|
173
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
172
174
|
ais: props.contextValue,
|
|
173
175
|
multiIndexContext: props.indexContextValue
|
|
174
176
|
}),
|
|
@@ -241,7 +243,7 @@ var _default = (0, _createConnector.default)({
|
|
|
241
243
|
},
|
|
242
244
|
items: getCurrentRefinement(props, searchState, context).map(function (item) {
|
|
243
245
|
return {
|
|
244
|
-
label: "".concat(item),
|
|
246
|
+
label: (0, _utils.unescapeFacetValue)("".concat(item)),
|
|
245
247
|
value: function value(nextState) {
|
|
246
248
|
var nextSelectedItems = getCurrentRefinement(props, nextState, context).filter(function (other) {
|
|
247
249
|
return other !== item;
|
|
@@ -125,6 +125,7 @@ function createInstantSearchManager(_ref) {
|
|
|
125
125
|
var skip = false;
|
|
126
126
|
var stalledSearchTimer = null;
|
|
127
127
|
var initialSearchParameters = helper.state;
|
|
128
|
+
var searchCounter;
|
|
128
129
|
var widgetsManager = (0, _createWidgetsManager.default)(onWidgetsUpdate);
|
|
129
130
|
hydrateSearchClient(searchClient, resultsState);
|
|
130
131
|
var store = (0, _createStore.default)({
|
|
@@ -210,12 +211,13 @@ function createInstantSearchManager(_ref) {
|
|
|
210
211
|
if (!skip) {
|
|
211
212
|
var _getSearchParameters = getSearchParameters(helper.state),
|
|
212
213
|
mainParameters = _getSearchParameters.mainParameters,
|
|
213
|
-
derivedParameters = _getSearchParameters.derivedParameters;
|
|
214
|
+
derivedParameters = _getSearchParameters.derivedParameters;
|
|
215
|
+
|
|
216
|
+
searchCounter = derivedParameters.length + 1; // We have to call `slice` because the method `detach` on the derived
|
|
214
217
|
// helpers mutates the value `derivedHelpers`. The `forEach` loop does
|
|
215
218
|
// not iterate on each value and we're not able to correctly clear the
|
|
216
219
|
// previous derived helpers (memory leak + useless requests).
|
|
217
220
|
|
|
218
|
-
|
|
219
221
|
helper.derivedHelpers.slice().forEach(function (derivedHelper) {
|
|
220
222
|
// Since we detach the derived helpers on **every** new search they
|
|
221
223
|
// won't receive intermediate results in case of a stalled search.
|
|
@@ -251,6 +253,7 @@ function createInstantSearchManager(_ref) {
|
|
|
251
253
|
function handleSearchSuccess(_ref3) {
|
|
252
254
|
var indexId = _ref3.indexId;
|
|
253
255
|
return function (event) {
|
|
256
|
+
searchCounter--;
|
|
254
257
|
var state = store.getState();
|
|
255
258
|
var isDerivedHelpersEmpty = !helper.derivedHelpers.length;
|
|
256
259
|
var results = state.results ? state.results : {}; // Switching from mono index to multi index and vice versa must reset the
|
|
@@ -279,7 +282,7 @@ function createInstantSearchManager(_ref) {
|
|
|
279
282
|
store.setState(_objectSpread(_objectSpread({}, partialState), {}, {
|
|
280
283
|
results: results,
|
|
281
284
|
isSearchStalled: nextIsSearchStalled,
|
|
282
|
-
searching:
|
|
285
|
+
searching: searchCounter > 0,
|
|
283
286
|
error: null
|
|
284
287
|
}));
|
|
285
288
|
};
|
package/dist/cjs/core/utils.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.getPropertyByPath = void 0;
|
|
|
15
15
|
exports.objectHasKeys = objectHasKeys;
|
|
16
16
|
exports.omit = omit;
|
|
17
17
|
exports.shallowEqual = exports.removeEmptyKey = exports.removeEmptyArraysFromObject = void 0;
|
|
18
|
+
exports.unescapeFacetValue = unescapeFacetValue;
|
|
18
19
|
|
|
19
20
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
21
|
|
|
@@ -189,4 +190,8 @@ exports.getPropertyByPath = getPropertyByPath;
|
|
|
189
190
|
|
|
190
191
|
function getObjectType(object) {
|
|
191
192
|
return Object.prototype.toString.call(object).slice(8, -1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function unescapeFacetValue(value) {
|
|
196
|
+
return value.replace(/^\\-/, '-');
|
|
192
197
|
}
|
package/dist/cjs/core/version.js
CHANGED
|
@@ -21,9 +21,9 @@ function transformValue(values) {
|
|
|
21
21
|
if (item.isRefined) {
|
|
22
22
|
acc.push({
|
|
23
23
|
label: item.name,
|
|
24
|
-
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current
|
|
25
|
-
// If dealing with the first level, "value" is equal to the current
|
|
26
|
-
value: item.
|
|
24
|
+
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
25
|
+
// If dealing with the first level, "value" is equal to the current value
|
|
26
|
+
value: item.escapedValue
|
|
27
27
|
}); // Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
28
28
|
|
|
29
29
|
if (item.data) {
|
|
@@ -8,6 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import algoliasearchHelper from 'algoliasearch-helper';
|
|
9
9
|
import createConnector from "../core/createConnector.js";
|
|
10
10
|
import { cleanUpValue, getIndexId, refineValue, getCurrentRefinementValue, getResults } from "../core/indexUtils.js";
|
|
11
|
+
import { unescapeFacetValue } from "../core/utils.js";
|
|
11
12
|
export var getId = function getId(props) {
|
|
12
13
|
return props.attributes[0];
|
|
13
14
|
};
|
|
@@ -23,7 +24,7 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
23
24
|
return currentRefinement;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
function getValue(
|
|
27
|
+
function getValue(value, props, searchState, context) {
|
|
27
28
|
var id = props.id,
|
|
28
29
|
attributes = props.attributes,
|
|
29
30
|
separator = props.separator,
|
|
@@ -33,7 +34,7 @@ function getValue(path, props, searchState, context) {
|
|
|
33
34
|
var nextRefinement;
|
|
34
35
|
|
|
35
36
|
if (currentRefinement === null) {
|
|
36
|
-
nextRefinement =
|
|
37
|
+
nextRefinement = value;
|
|
37
38
|
} else {
|
|
38
39
|
var tmpSearchParameters = new algoliasearchHelper.SearchParameters({
|
|
39
40
|
hierarchicalFacets: [{
|
|
@@ -44,7 +45,7 @@ function getValue(path, props, searchState, context) {
|
|
|
44
45
|
showParentLevel: showParentLevel
|
|
45
46
|
}]
|
|
46
47
|
});
|
|
47
|
-
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id,
|
|
48
|
+
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
return nextRefinement;
|
|
@@ -54,7 +55,7 @@ function transformValue(value, props, searchState, context) {
|
|
|
54
55
|
return value.map(function (v) {
|
|
55
56
|
return {
|
|
56
57
|
label: v.name,
|
|
57
|
-
value: getValue(v.
|
|
58
|
+
value: getValue(v.escapedValue, props, searchState, context),
|
|
58
59
|
count: v.count,
|
|
59
60
|
isRefined: v.isRefined,
|
|
60
61
|
items: v.data && transformValue(v.data, props, searchState, context)
|
|
@@ -94,7 +95,7 @@ var sortBy = ['name:asc'];
|
|
|
94
95
|
* websites. From a UX point of view, we suggest not displaying more than two levels deep.
|
|
95
96
|
* @name connectHierarchicalMenu
|
|
96
97
|
* @requirements To use this widget, your attributes must be formatted in a specific way.
|
|
97
|
-
* If you want for example to have a
|
|
98
|
+
* If you want for example to have a hierarchical menu of categories, objects in your index
|
|
98
99
|
* should be formatted this way:
|
|
99
100
|
*
|
|
100
101
|
* ```json
|
|
@@ -259,7 +260,7 @@ export default createConnector({
|
|
|
259
260
|
multiIndexContext: props.indexContextValue
|
|
260
261
|
});
|
|
261
262
|
var items = !currentRefinement ? [] : [{
|
|
262
|
-
label: "".concat(rootAttribute, ": ").concat(currentRefinement),
|
|
263
|
+
label: "".concat(rootAttribute, ": ").concat(unescapeFacetValue(currentRefinement)),
|
|
263
264
|
attribute: rootAttribute,
|
|
264
265
|
value: function value(nextState) {
|
|
265
266
|
return _refine(props, nextState, '', {
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import createConnector from "../core/createConnector.js";
|
|
4
4
|
import { getIndexId, cleanUpValue, refineValue, getCurrentRefinementValue, getResults } from "../core/indexUtils.js";
|
|
5
|
+
import { unescapeFacetValue } from "../core/utils.js";
|
|
5
6
|
var namespace = 'menu';
|
|
6
7
|
|
|
7
8
|
function getId(props) {
|
|
@@ -18,9 +19,9 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
18
19
|
return currentRefinement;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
function getValue(
|
|
22
|
+
function getValue(value, props, searchState, context) {
|
|
22
23
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
23
|
-
return
|
|
24
|
+
return value === currentRefinement ? '' : value;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function getLimit(_ref) {
|
|
@@ -118,7 +119,7 @@ export default createConnector({
|
|
|
118
119
|
items = searchForFacetValuesResults[attribute].map(function (v) {
|
|
119
120
|
return {
|
|
120
121
|
label: v.value,
|
|
121
|
-
value: getValue(v.
|
|
122
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
122
123
|
ais: props.contextValue,
|
|
123
124
|
multiIndexContext: props.indexContextValue
|
|
124
125
|
}),
|
|
@@ -138,7 +139,7 @@ export default createConnector({
|
|
|
138
139
|
}).map(function (v) {
|
|
139
140
|
return {
|
|
140
141
|
label: v.name,
|
|
141
|
-
value: getValue(v.
|
|
142
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
142
143
|
ais: props.contextValue,
|
|
143
144
|
multiIndexContext: props.indexContextValue
|
|
144
145
|
}),
|
|
@@ -209,7 +210,7 @@ export default createConnector({
|
|
|
209
210
|
multiIndexContext: props.indexContextValue
|
|
210
211
|
}),
|
|
211
212
|
items: currentRefinement === null ? [] : [{
|
|
212
|
-
label: "".concat(props.attribute, ": ").concat(currentRefinement),
|
|
213
|
+
label: "".concat(props.attribute, ": ").concat(unescapeFacetValue(currentRefinement)),
|
|
213
214
|
attribute: props.attribute,
|
|
214
215
|
value: function value(nextState) {
|
|
215
216
|
return _refine(props, nextState, '', {
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import createConnector from "../core/createConnector.js";
|
|
4
4
|
import { cleanUpValue, getIndexId, refineValue, getCurrentRefinementValue, getResults } from "../core/indexUtils.js";
|
|
5
|
+
import { unescapeFacetValue } from "../core/utils.js";
|
|
5
6
|
var namespace = 'refinementList';
|
|
6
7
|
|
|
7
8
|
function getId(props) {
|
|
@@ -22,12 +23,12 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
22
23
|
return [];
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
function getValue(
|
|
26
|
+
function getValue(value, props, searchState, context) {
|
|
26
27
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
27
|
-
var isAnewValue = currentRefinement.indexOf(
|
|
28
|
-
var nextRefinement = isAnewValue ? currentRefinement.concat([
|
|
28
|
+
var isAnewValue = currentRefinement.indexOf(value) === -1;
|
|
29
|
+
var nextRefinement = isAnewValue ? currentRefinement.concat([value]) // cannot use .push(), it mutates
|
|
29
30
|
: currentRefinement.filter(function (selectedValue) {
|
|
30
|
-
return selectedValue !==
|
|
31
|
+
return selectedValue !== value;
|
|
31
32
|
}); // cannot use .splice(), it mutates
|
|
32
33
|
|
|
33
34
|
return nextRefinement;
|
|
@@ -137,7 +138,7 @@ export default createConnector({
|
|
|
137
138
|
var items = isFromSearch ? searchForFacetValuesResults[attribute].map(function (v) {
|
|
138
139
|
return {
|
|
139
140
|
label: v.value,
|
|
140
|
-
value: getValue(v.
|
|
141
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
141
142
|
ais: props.contextValue,
|
|
142
143
|
multiIndexContext: props.indexContextValue
|
|
143
144
|
}),
|
|
@@ -155,7 +156,7 @@ export default createConnector({
|
|
|
155
156
|
}).map(function (v) {
|
|
156
157
|
return {
|
|
157
158
|
label: v.name,
|
|
158
|
-
value: getValue(v.
|
|
159
|
+
value: getValue(v.escapedValue, props, searchState, {
|
|
159
160
|
ais: props.contextValue,
|
|
160
161
|
multiIndexContext: props.indexContextValue
|
|
161
162
|
}),
|
|
@@ -228,7 +229,7 @@ export default createConnector({
|
|
|
228
229
|
},
|
|
229
230
|
items: getCurrentRefinement(props, searchState, context).map(function (item) {
|
|
230
231
|
return {
|
|
231
|
-
label: "".concat(item),
|
|
232
|
+
label: unescapeFacetValue("".concat(item)),
|
|
232
233
|
value: function value(nextState) {
|
|
233
234
|
var nextSelectedItems = getCurrentRefinement(props, nextState, context).filter(function (other) {
|
|
234
235
|
return other !== item;
|
|
@@ -108,6 +108,7 @@ export default function createInstantSearchManager(_ref) {
|
|
|
108
108
|
var skip = false;
|
|
109
109
|
var stalledSearchTimer = null;
|
|
110
110
|
var initialSearchParameters = helper.state;
|
|
111
|
+
var searchCounter;
|
|
111
112
|
var widgetsManager = createWidgetsManager(onWidgetsUpdate);
|
|
112
113
|
hydrateSearchClient(searchClient, resultsState);
|
|
113
114
|
var store = createStore({
|
|
@@ -193,12 +194,13 @@ export default function createInstantSearchManager(_ref) {
|
|
|
193
194
|
if (!skip) {
|
|
194
195
|
var _getSearchParameters = getSearchParameters(helper.state),
|
|
195
196
|
mainParameters = _getSearchParameters.mainParameters,
|
|
196
|
-
derivedParameters = _getSearchParameters.derivedParameters;
|
|
197
|
+
derivedParameters = _getSearchParameters.derivedParameters;
|
|
198
|
+
|
|
199
|
+
searchCounter = derivedParameters.length + 1; // We have to call `slice` because the method `detach` on the derived
|
|
197
200
|
// helpers mutates the value `derivedHelpers`. The `forEach` loop does
|
|
198
201
|
// not iterate on each value and we're not able to correctly clear the
|
|
199
202
|
// previous derived helpers (memory leak + useless requests).
|
|
200
203
|
|
|
201
|
-
|
|
202
204
|
helper.derivedHelpers.slice().forEach(function (derivedHelper) {
|
|
203
205
|
// Since we detach the derived helpers on **every** new search they
|
|
204
206
|
// won't receive intermediate results in case of a stalled search.
|
|
@@ -234,6 +236,7 @@ export default function createInstantSearchManager(_ref) {
|
|
|
234
236
|
function handleSearchSuccess(_ref3) {
|
|
235
237
|
var indexId = _ref3.indexId;
|
|
236
238
|
return function (event) {
|
|
239
|
+
searchCounter--;
|
|
237
240
|
var state = store.getState();
|
|
238
241
|
var isDerivedHelpersEmpty = !helper.derivedHelpers.length;
|
|
239
242
|
var results = state.results ? state.results : {}; // Switching from mono index to multi index and vice versa must reset the
|
|
@@ -263,7 +266,7 @@ export default function createInstantSearchManager(_ref) {
|
|
|
263
266
|
store.setState(_objectSpread(_objectSpread({}, partialState), {}, {
|
|
264
267
|
results: results,
|
|
265
268
|
isSearchStalled: nextIsSearchStalled,
|
|
266
|
-
searching:
|
|
269
|
+
searching: searchCounter > 0,
|
|
267
270
|
error: null
|
|
268
271
|
}));
|
|
269
272
|
};
|
package/dist/es/core/utils.js
CHANGED
|
@@ -148,4 +148,7 @@ export var getPropertyByPath = function getPropertyByPath(object, path) {
|
|
|
148
148
|
};
|
|
149
149
|
export function getObjectType(object) {
|
|
150
150
|
return Object.prototype.toString.call(object).slice(8, -1);
|
|
151
|
+
}
|
|
152
|
+
export function unescapeFacetValue(value) {
|
|
153
|
+
return value.replace(/^\\-/, '-');
|
|
151
154
|
}
|
package/dist/es/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '6.23.
|
|
1
|
+
export default '6.23.3';
|