react-instantsearch-core 6.38.1 → 6.38.2
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/LICENSE +21 -0
- package/README.md +9 -1
- package/dist/cjs/connectors/connectAutoComplete.js +14 -33
- package/dist/cjs/connectors/connectBreadcrumb.js +9 -22
- package/dist/cjs/connectors/connectConfigure.js +17 -26
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +20 -33
- package/dist/cjs/connectors/connectCurrentRefinements.js +6 -13
- package/dist/cjs/connectors/connectDynamicWidgets.js +2 -13
- package/dist/cjs/connectors/connectGeoSearch.js +15 -34
- package/dist/cjs/connectors/connectHierarchicalMenu.js +22 -48
- package/dist/cjs/connectors/connectHighlight.js +8 -14
- package/dist/cjs/connectors/connectHitInsights.js +8 -20
- package/dist/cjs/connectors/connectHits.js +2 -11
- package/dist/cjs/connectors/connectHitsPerPage.js +8 -18
- package/dist/cjs/connectors/connectInfiniteHits.js +25 -43
- package/dist/cjs/connectors/connectMenu.js +14 -33
- package/dist/cjs/connectors/connectNumericMenu.js +24 -49
- package/dist/cjs/connectors/connectPagination.js +7 -17
- package/dist/cjs/connectors/connectPoweredBy.js +1 -5
- package/dist/cjs/connectors/connectQueryRules.js +11 -29
- package/dist/cjs/connectors/connectRange.js +33 -75
- package/dist/cjs/connectors/connectRefinementList.js +16 -34
- package/dist/cjs/connectors/connectRelevantSort.js +6 -13
- package/dist/cjs/connectors/connectScrollTo.js +6 -14
- package/dist/cjs/connectors/connectSearchBox.js +7 -17
- package/dist/cjs/connectors/connectSortBy.js +8 -18
- package/dist/cjs/connectors/connectStateResults.js +1 -6
- package/dist/cjs/connectors/connectStats.js +2 -8
- package/dist/cjs/connectors/connectToggleRefinement.js +14 -29
- package/dist/cjs/connectors/connectVoiceSearch.js +7 -24
- package/dist/cjs/core/context.js +3 -7
- package/dist/cjs/core/createConnector.js +60 -114
- package/dist/cjs/core/createInstantSearchManager.d.js +1 -0
- package/dist/cjs/core/createInstantSearchManager.js +67 -116
- package/dist/cjs/core/createStore.js +0 -1
- package/dist/cjs/core/createWidgetsManager.js +4 -7
- package/dist/cjs/core/highlight.js +11 -20
- package/dist/cjs/core/indexUtils.js +34 -77
- package/dist/cjs/core/metadata.js +7 -15
- package/dist/cjs/core/translatable.js +19 -46
- package/dist/cjs/core/utils.js +14 -52
- package/dist/cjs/core/version.js +1 -1
- package/dist/cjs/index.js +9 -44
- package/dist/cjs/types/index.js +0 -2
- package/dist/cjs/widgets/Configure.js +1 -5
- package/dist/cjs/widgets/ConfigureRelatedItems.js +1 -8
- package/dist/cjs/widgets/DynamicWidgets.js +12 -33
- package/dist/cjs/widgets/Index.js +26 -52
- package/dist/cjs/widgets/InstantSearch.js +28 -67
- package/dist/cjs/widgets/QueryRuleContext.js +1 -5
- package/dist/es/connectors/connectAutoComplete.js +11 -25
- package/dist/es/connectors/connectBreadcrumb.js +7 -13
- package/dist/es/connectors/connectConfigure.js +13 -22
- package/dist/es/connectors/connectConfigureRelatedItems.js +17 -25
- package/dist/es/connectors/connectCurrentRefinements.js +5 -7
- package/dist/es/connectors/connectDynamicWidgets.js +1 -6
- package/dist/es/connectors/connectGeoSearch.js +14 -27
- package/dist/es/connectors/connectHierarchicalMenu.js +19 -38
- package/dist/es/connectors/connectHighlight.js +7 -9
- package/dist/es/connectors/connectHitInsights.js +7 -14
- package/dist/es/connectors/connectHits.js +2 -5
- package/dist/es/connectors/connectHitsPerPage.js +5 -12
- package/dist/es/connectors/connectInfiniteHits.js +21 -31
- package/dist/es/connectors/connectMenu.js +12 -25
- package/dist/es/connectors/connectNumericMenu.js +22 -40
- package/dist/es/connectors/connectPagination.js +5 -12
- package/dist/es/connectors/connectPoweredBy.js +1 -1
- package/dist/es/connectors/connectQueryRules.js +9 -20
- package/dist/es/connectors/connectRange.js +31 -68
- package/dist/es/connectors/connectRefinementList.js +14 -24
- package/dist/es/connectors/connectRelevantSort.js +7 -8
- package/dist/es/connectors/connectScrollTo.js +6 -7
- package/dist/es/connectors/connectSearchBox.js +5 -11
- package/dist/es/connectors/connectSortBy.js +5 -12
- package/dist/es/connectors/connectStateResults.js +1 -1
- package/dist/es/connectors/connectStats.js +2 -3
- package/dist/es/connectors/connectToggleRefinement.js +12 -22
- package/dist/es/connectors/connectVoiceSearch.js +4 -16
- package/dist/es/core/context.js +3 -5
- package/dist/es/core/createConnector.js +33 -86
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +59 -100
- package/dist/es/core/createWidgetsManager.js +4 -5
- package/dist/es/core/highlight.js +11 -17
- package/dist/es/core/indexUtils.js +27 -62
- package/dist/es/core/metadata.js +6 -8
- package/dist/es/core/translatable.js +13 -29
- package/dist/es/core/utils.js +12 -29
- package/dist/es/core/version.js +1 -1
- package/dist/es/index.js +39 -6
- package/dist/es/widgets/Configure.js +1 -0
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -2
- package/dist/es/widgets/DynamicWidgets.js +9 -18
- package/dist/es/widgets/Index.js +13 -31
- package/dist/es/widgets/InstantSearch.js +13 -42
- package/dist/umd/ReactInstantSearchCore.js +507 -1078
- 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 +7 -5
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import createConnector from "../core/createConnector.js";
|
|
4
7
|
import { cleanUpValue, getIndexId, refineValue, getCurrentRefinementValue, getResults } from "../core/indexUtils.js";
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* connectRange connector provides the logic to create connected
|
|
7
11
|
* components that will give the ability for a user to refine results using
|
|
@@ -27,13 +31,10 @@ import { cleanUpValue, getIndexId, refineValue, getCurrentRefinementValue, getRe
|
|
|
27
31
|
function getId(props) {
|
|
28
32
|
return props.attribute;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
34
|
var namespace = 'range';
|
|
32
|
-
|
|
33
35
|
function getCurrentRange(boundaries, stats, precision) {
|
|
34
36
|
var pow = Math.pow(10, precision);
|
|
35
37
|
var min;
|
|
36
|
-
|
|
37
38
|
if (typeof boundaries.min === 'number' && isFinite(boundaries.min)) {
|
|
38
39
|
min = boundaries.min;
|
|
39
40
|
} else if (typeof stats.min === 'number' && isFinite(stats.min)) {
|
|
@@ -41,9 +42,7 @@ function getCurrentRange(boundaries, stats, precision) {
|
|
|
41
42
|
} else {
|
|
42
43
|
min = undefined;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
45
|
var max;
|
|
46
|
-
|
|
47
46
|
if (typeof boundaries.max === 'number' && isFinite(boundaries.max)) {
|
|
48
47
|
max = boundaries.max;
|
|
49
48
|
} else if (typeof stats.max === 'number' && isFinite(stats.max)) {
|
|
@@ -51,31 +50,24 @@ function getCurrentRange(boundaries, stats, precision) {
|
|
|
51
50
|
} else {
|
|
52
51
|
max = undefined;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
53
|
return {
|
|
56
54
|
min: min !== undefined ? Math.floor(min * pow) / pow : min,
|
|
57
55
|
max: max !== undefined ? Math.ceil(max * pow) / pow : max
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
|
-
|
|
61
58
|
function getCurrentRefinement(props, searchState, currentRange, context) {
|
|
62
59
|
var _getCurrentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), {}),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
min = _getCurrentRefinement.min,
|
|
61
|
+
max = _getCurrentRefinement.max;
|
|
66
62
|
var isFloatPrecision = Boolean(props.precision);
|
|
67
63
|
var nextMin = min;
|
|
68
|
-
|
|
69
64
|
if (typeof nextMin === 'string') {
|
|
70
65
|
nextMin = isFloatPrecision ? parseFloat(nextMin) : parseInt(nextMin, 10);
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
var nextMax = max;
|
|
74
|
-
|
|
75
68
|
if (typeof nextMax === 'string') {
|
|
76
69
|
nextMax = isFloatPrecision ? parseFloat(nextMax) : parseInt(nextMax, 10);
|
|
77
70
|
}
|
|
78
|
-
|
|
79
71
|
var refinement = {
|
|
80
72
|
min: nextMin,
|
|
81
73
|
max: nextMax
|
|
@@ -84,36 +76,28 @@ function getCurrentRefinement(props, searchState, currentRange, context) {
|
|
|
84
76
|
var hasMaxBound = props.max !== undefined;
|
|
85
77
|
var hasMinRefinment = refinement.min !== undefined;
|
|
86
78
|
var hasMaxRefinment = refinement.max !== undefined;
|
|
87
|
-
|
|
88
79
|
if (hasMinBound && hasMinRefinment && refinement.min < currentRange.min) {
|
|
89
80
|
throw Error("You can't provide min value lower than range.");
|
|
90
81
|
}
|
|
91
|
-
|
|
92
82
|
if (hasMaxBound && hasMaxRefinment && refinement.max > currentRange.max) {
|
|
93
83
|
throw Error("You can't provide max value greater than range.");
|
|
94
84
|
}
|
|
95
|
-
|
|
96
85
|
if (hasMinBound && !hasMinRefinment) {
|
|
97
86
|
refinement.min = currentRange.min;
|
|
98
87
|
}
|
|
99
|
-
|
|
100
88
|
if (hasMaxBound && !hasMaxRefinment) {
|
|
101
89
|
refinement.max = currentRange.max;
|
|
102
90
|
}
|
|
103
|
-
|
|
104
91
|
return refinement;
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
function getCurrentRefinementWithRange(refinement, range) {
|
|
108
94
|
return {
|
|
109
95
|
min: refinement.min !== undefined ? refinement.min : range.min,
|
|
110
96
|
max: refinement.max !== undefined ? refinement.max : range.max
|
|
111
97
|
};
|
|
112
98
|
}
|
|
113
|
-
|
|
114
99
|
function nextValueForRefinement(hasBound, isReset, range, value) {
|
|
115
100
|
var next;
|
|
116
|
-
|
|
117
101
|
if (!hasBound && range === value) {
|
|
118
102
|
next = undefined;
|
|
119
103
|
} else if (hasBound && isReset) {
|
|
@@ -121,49 +105,39 @@ function nextValueForRefinement(hasBound, isReset, range, value) {
|
|
|
121
105
|
} else {
|
|
122
106
|
next = value;
|
|
123
107
|
}
|
|
124
|
-
|
|
125
108
|
return next;
|
|
126
109
|
}
|
|
127
|
-
|
|
128
110
|
function _refine(props, searchState, nextRefinement, currentRange, context) {
|
|
129
111
|
var nextMin = nextRefinement.min,
|
|
130
|
-
|
|
112
|
+
nextMax = nextRefinement.max;
|
|
131
113
|
var currentMinRange = currentRange.min,
|
|
132
|
-
|
|
114
|
+
currentMaxRange = currentRange.max;
|
|
133
115
|
var isMinReset = nextMin === undefined || nextMin === '';
|
|
134
116
|
var isMaxReset = nextMax === undefined || nextMax === '';
|
|
135
117
|
var nextMinAsNumber = !isMinReset ? parseFloat(nextMin) : undefined;
|
|
136
118
|
var nextMaxAsNumber = !isMaxReset ? parseFloat(nextMax) : undefined;
|
|
137
119
|
var isNextMinValid = isMinReset || isFinite(nextMinAsNumber);
|
|
138
120
|
var isNextMaxValid = isMaxReset || isFinite(nextMaxAsNumber);
|
|
139
|
-
|
|
140
121
|
if (!isNextMinValid || !isNextMaxValid) {
|
|
141
122
|
throw Error("You can't provide non finite values to the range connector.");
|
|
142
123
|
}
|
|
143
|
-
|
|
144
124
|
if (nextMinAsNumber < currentMinRange) {
|
|
145
125
|
throw Error("You can't provide min value lower than range.");
|
|
146
126
|
}
|
|
147
|
-
|
|
148
127
|
if (nextMaxAsNumber > currentMaxRange) {
|
|
149
128
|
throw Error("You can't provide max value greater than range.");
|
|
150
129
|
}
|
|
151
|
-
|
|
152
130
|
var id = getId(props);
|
|
153
131
|
var resetPage = true;
|
|
154
|
-
|
|
155
132
|
var nextValue = _defineProperty({}, id, {
|
|
156
133
|
min: nextValueForRefinement(props.min !== undefined, isMinReset, currentMinRange, nextMinAsNumber),
|
|
157
134
|
max: nextValueForRefinement(props.max !== undefined, isMaxReset, currentMaxRange, nextMaxAsNumber)
|
|
158
135
|
});
|
|
159
|
-
|
|
160
136
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
161
137
|
}
|
|
162
|
-
|
|
163
138
|
function _cleanUp(props, searchState, context) {
|
|
164
139
|
return cleanUpValue(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
165
140
|
}
|
|
166
|
-
|
|
167
141
|
export default createConnector({
|
|
168
142
|
displayName: 'AlgoliaRange',
|
|
169
143
|
$$type: 'ais.range',
|
|
@@ -185,9 +159,9 @@ export default createConnector({
|
|
|
185
159
|
},
|
|
186
160
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
187
161
|
var attribute = props.attribute,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
162
|
+
precision = props.precision,
|
|
163
|
+
minBound = props.min,
|
|
164
|
+
maxBound = props.max;
|
|
191
165
|
var results = getResults(searchResults, {
|
|
192
166
|
ais: props.contextValue,
|
|
193
167
|
multiIndexContext: props.indexContextValue
|
|
@@ -201,18 +175,17 @@ export default createConnector({
|
|
|
201
175
|
count: v.count
|
|
202
176
|
};
|
|
203
177
|
});
|
|
204
|
-
|
|
205
178
|
var _getCurrentRange = getCurrentRange({
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
179
|
+
min: minBound,
|
|
180
|
+
max: maxBound
|
|
181
|
+
}, stats, precision),
|
|
182
|
+
rangeMin = _getCurrentRange.min,
|
|
183
|
+
rangeMax = _getCurrentRange.max;
|
|
184
|
+
|
|
185
|
+
// The searchState is not always in sync with the helper state. For example
|
|
211
186
|
// when we set boundaries on the first render the searchState don't have
|
|
212
187
|
// the correct refinement. If this behavior change in the upcoming version
|
|
213
188
|
// we could store the range inside the searchState instead of rely on `this`.
|
|
214
|
-
|
|
215
|
-
|
|
216
189
|
this._currentRange = {
|
|
217
190
|
min: rangeMin,
|
|
218
191
|
max: rangeMax
|
|
@@ -244,46 +217,37 @@ export default createConnector({
|
|
|
244
217
|
},
|
|
245
218
|
getSearchParameters: function getSearchParameters(params, props, searchState) {
|
|
246
219
|
var attribute = props.attribute;
|
|
247
|
-
|
|
248
220
|
var _getCurrentRefinement2 = getCurrentRefinement(props, searchState, this._currentRange, {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
221
|
+
ais: props.contextValue,
|
|
222
|
+
multiIndexContext: props.indexContextValue
|
|
223
|
+
}),
|
|
224
|
+
min = _getCurrentRefinement2.min,
|
|
225
|
+
max = _getCurrentRefinement2.max;
|
|
255
226
|
params = params.addDisjunctiveFacet(attribute);
|
|
256
|
-
|
|
257
227
|
if (min !== undefined) {
|
|
258
228
|
params = params.addNumericRefinement(attribute, '>=', min);
|
|
259
229
|
}
|
|
260
|
-
|
|
261
230
|
if (max !== undefined) {
|
|
262
231
|
params = params.addNumericRefinement(attribute, '<=', max);
|
|
263
232
|
}
|
|
264
|
-
|
|
265
233
|
return params;
|
|
266
234
|
},
|
|
267
235
|
getMetadata: function getMetadata(props, searchState) {
|
|
268
236
|
var _this = this;
|
|
269
|
-
|
|
270
237
|
var _this$_currentRange = this._currentRange,
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
238
|
+
minRange = _this$_currentRange.min,
|
|
239
|
+
maxRange = _this$_currentRange.max;
|
|
274
240
|
var _getCurrentRefinement3 = getCurrentRefinement(props, searchState, this._currentRange, {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
241
|
+
ais: props.contextValue,
|
|
242
|
+
multiIndexContext: props.indexContextValue
|
|
243
|
+
}),
|
|
244
|
+
minValue = _getCurrentRefinement3.min,
|
|
245
|
+
maxValue = _getCurrentRefinement3.max;
|
|
281
246
|
var items = [];
|
|
282
247
|
var hasMin = minValue !== undefined;
|
|
283
248
|
var hasMax = maxValue !== undefined;
|
|
284
249
|
var shouldDisplayMinLabel = hasMin && minValue !== minRange;
|
|
285
250
|
var shouldDisplayMaxLabel = hasMax && maxValue !== maxRange;
|
|
286
|
-
|
|
287
251
|
if (shouldDisplayMinLabel || shouldDisplayMaxLabel) {
|
|
288
252
|
var fragments = [hasMin ? "".concat(minValue, " <= ") : '', props.attribute, hasMax ? " <= ".concat(maxValue) : ''];
|
|
289
253
|
items.push({
|
|
@@ -304,7 +268,6 @@ export default createConnector({
|
|
|
304
268
|
})
|
|
305
269
|
});
|
|
306
270
|
}
|
|
307
|
-
|
|
308
271
|
return {
|
|
309
272
|
id: getId(props),
|
|
310
273
|
index: getIndexId({
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import createConnector from "../core/createConnector.js";
|
|
4
7
|
import { cleanUpValue, getIndexId, refineValue, getCurrentRefinementValue, getResults } from "../core/indexUtils.js";
|
|
5
8
|
import { unescapeFacetValue } from "../core/utils.js";
|
|
6
9
|
var namespace = 'refinementList';
|
|
7
|
-
|
|
8
10
|
function getId(props) {
|
|
9
11
|
return props.attribute;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
13
|
function getCurrentRefinement(props, searchState, context) {
|
|
13
14
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), []);
|
|
14
|
-
|
|
15
15
|
if (typeof currentRefinement !== 'string') {
|
|
16
16
|
return currentRefinement;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
if (currentRefinement) {
|
|
20
19
|
return [currentRefinement];
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return [];
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
function getValue(value, props, searchState, context) {
|
|
27
24
|
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
28
25
|
var isAnewValue = currentRefinement.indexOf(value) === -1;
|
|
@@ -30,32 +27,27 @@ function getValue(value, props, searchState, context) {
|
|
|
30
27
|
: currentRefinement.filter(function (selectedValue) {
|
|
31
28
|
return selectedValue !== value;
|
|
32
29
|
}); // cannot use .splice(), it mutates
|
|
33
|
-
|
|
34
30
|
return nextRefinement;
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
function getLimit(_ref) {
|
|
38
33
|
var showMore = _ref.showMore,
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
limit = _ref.limit,
|
|
35
|
+
showMoreLimit = _ref.showMoreLimit;
|
|
41
36
|
return showMore ? showMoreLimit : limit;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
function _refine(props, searchState, nextRefinement, context) {
|
|
45
|
-
var id = getId(props);
|
|
39
|
+
var id = getId(props);
|
|
40
|
+
// Setting the value to an empty string ensures that it is persisted in
|
|
46
41
|
// the URL as an empty value.
|
|
47
42
|
// This is necessary in the case where `defaultRefinement` contains one
|
|
48
43
|
// item and we try to deselect it. `nextSelected` would be an empty array,
|
|
49
44
|
// which would not be persisted to the URL.
|
|
50
45
|
// {foo: ['bar']} => "foo[0]=bar"
|
|
51
46
|
// {foo: []} => ""
|
|
52
|
-
|
|
53
47
|
var nextValue = _defineProperty({}, id, nextRefinement.length > 0 ? nextRefinement : '');
|
|
54
|
-
|
|
55
48
|
var resetPage = true;
|
|
56
49
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
57
50
|
}
|
|
58
|
-
|
|
59
51
|
function _cleanUp(props, searchState, context) {
|
|
60
52
|
return cleanUpValue(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
61
53
|
}
|
|
@@ -83,7 +75,6 @@ function _cleanUp(props, searchState, context) {
|
|
|
83
75
|
* @providedPropType {boolean} canRefine - a boolean that says whether you can refine
|
|
84
76
|
*/
|
|
85
77
|
|
|
86
|
-
|
|
87
78
|
var sortBy = ['isRefined', 'count:desc', 'name:asc'];
|
|
88
79
|
export default createConnector({
|
|
89
80
|
displayName: 'AlgoliaRefinementList',
|
|
@@ -109,20 +100,20 @@ export default createConnector({
|
|
|
109
100
|
},
|
|
110
101
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults, metadata, searchForFacetValuesResults) {
|
|
111
102
|
var attribute = props.attribute,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
searchable = props.searchable,
|
|
104
|
+
indexContextValue = props.indexContextValue,
|
|
105
|
+
facetOrdering = props.facetOrdering;
|
|
115
106
|
var results = getResults(searchResults, {
|
|
116
107
|
ais: props.contextValue,
|
|
117
108
|
multiIndexContext: props.indexContextValue
|
|
118
109
|
});
|
|
119
110
|
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
120
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
111
|
+
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
121
112
|
|
|
113
|
+
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
122
114
|
if (searchable && indexContextValue) {
|
|
123
115
|
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
124
116
|
}
|
|
125
|
-
|
|
126
117
|
if (!canRefine) {
|
|
127
118
|
return {
|
|
128
119
|
items: [],
|
|
@@ -135,7 +126,6 @@ export default createConnector({
|
|
|
135
126
|
searchable: searchable
|
|
136
127
|
};
|
|
137
128
|
}
|
|
138
|
-
|
|
139
129
|
var items = isFromSearch ? searchForFacetValuesResults[attribute].map(function (v) {
|
|
140
130
|
return {
|
|
141
131
|
label: v.value,
|
|
@@ -198,7 +188,7 @@ export default createConnector({
|
|
|
198
188
|
},
|
|
199
189
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
200
190
|
var attribute = props.attribute,
|
|
201
|
-
|
|
191
|
+
operator = props.operator;
|
|
202
192
|
var addKey = operator === 'and' ? 'addFacet' : 'addDisjunctiveFacet';
|
|
203
193
|
var addRefinementKey = "".concat(addKey, "Refinement");
|
|
204
194
|
searchParameters = searchParameters.setQueryParameters({
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2
5
|
import createConnector from "../core/createConnector.js";
|
|
3
|
-
import { refineValue, getCurrentRefinementValue, getResults
|
|
4
|
-
|
|
6
|
+
import { refineValue, getCurrentRefinementValue, getResults
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
} from "../core/indexUtils.js";
|
|
5
9
|
function getId() {
|
|
6
10
|
return 'relevancyStrictness';
|
|
7
11
|
}
|
|
8
|
-
|
|
9
12
|
function getCurrentRefinement(props, searchState, context) {
|
|
10
13
|
var id = getId();
|
|
11
14
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id);
|
|
12
15
|
return currentRefinement;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
17
|
export default createConnector({
|
|
16
18
|
displayName: 'AlgoliaRelevantSort',
|
|
17
19
|
$$type: 'ais.relevantSort',
|
|
@@ -20,14 +22,12 @@ export default createConnector({
|
|
|
20
22
|
ais: props.contextValue,
|
|
21
23
|
multiIndexContext: props.indexContextValue
|
|
22
24
|
});
|
|
23
|
-
|
|
24
25
|
if (!results) {
|
|
25
26
|
return {
|
|
26
27
|
isVirtualReplica: false,
|
|
27
28
|
isRelevantSorted: false
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
|
|
31
31
|
return {
|
|
32
32
|
isVirtualReplica: results.appliedRelevancyStrictness !== undefined,
|
|
33
33
|
isRelevantSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0
|
|
@@ -41,7 +41,6 @@ export default createConnector({
|
|
|
41
41
|
},
|
|
42
42
|
refine: function refine(props, searchState, nextRefinement) {
|
|
43
43
|
var nextValue = _defineProperty({}, getId(), nextRefinement);
|
|
44
|
-
|
|
45
44
|
var resetPage = true;
|
|
46
45
|
return refineValue(searchState, nextValue, {
|
|
47
46
|
ais: props.contextValue,
|
|
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import createConnector from "../core/createConnector.js";
|
|
3
3
|
import { getCurrentRefinementValue, hasMultipleIndices, getIndexId } from "../core/indexUtils.js";
|
|
4
4
|
import { shallowEqual, omit } from "../core/utils.js";
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* connectScrollTo connector provides the logic to build a widget that will
|
|
7
8
|
* let the page scroll to a certain point.
|
|
@@ -11,7 +12,6 @@ import { shallowEqual, omit } from "../core/utils.js";
|
|
|
11
12
|
* @providedPropType {any} value - the current refinement applied to the widget listened by scrollTo
|
|
12
13
|
* @providedPropType {boolean} hasNotChanged - indicates whether the refinement came from the scrollOn argument (for instance page by default)
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
export default createConnector({
|
|
16
16
|
displayName: 'AlgoliaScrollTo',
|
|
17
17
|
$$type: 'ais.scrollTo',
|
|
@@ -27,12 +27,11 @@ export default createConnector({
|
|
|
27
27
|
ais: props.contextValue,
|
|
28
28
|
multiIndexContext: props.indexContextValue
|
|
29
29
|
}, id, null);
|
|
30
|
-
|
|
31
30
|
if (!this._prevSearchState) {
|
|
32
31
|
this._prevSearchState = {};
|
|
33
|
-
}
|
|
34
|
-
|
|
32
|
+
}
|
|
35
33
|
|
|
34
|
+
// Get the subpart of the state that interest us
|
|
36
35
|
if (hasMultipleIndices({
|
|
37
36
|
ais: props.contextValue,
|
|
38
37
|
multiIndexContext: props.indexContextValue
|
|
@@ -41,7 +40,9 @@ export default createConnector({
|
|
|
41
40
|
ais: props.contextValue,
|
|
42
41
|
multiIndexContext: props.indexContextValue
|
|
43
42
|
})] : {};
|
|
44
|
-
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// if there is a change in the app that has been triggered by another element
|
|
45
46
|
// than "props.scrollOn (id) or the Configure widget, we need to keep track of
|
|
46
47
|
// the search state to know if there's a change in the app that was not triggered
|
|
47
48
|
// by the props.scrollOn (id) or the Configure widget. This is useful when
|
|
@@ -51,8 +52,6 @@ export default createConnector({
|
|
|
51
52
|
// do this comparison because for now configure values are not present in the
|
|
52
53
|
// search state before a first refinement has been made and will false the results.
|
|
53
54
|
// See: https://github.com/algolia/react-instantsearch/issues/164
|
|
54
|
-
|
|
55
|
-
|
|
56
55
|
var cleanedSearchState = omit(searchState, ['configure', id]);
|
|
57
56
|
var hasNotChanged = shallowEqual(this._prevSearchState, cleanedSearchState);
|
|
58
57
|
this._prevSearchState = cleanedSearchState;
|
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import createConnector from "../core/createConnector.js";
|
|
4
7
|
import { cleanUpValue, refineValue, getCurrentRefinementValue, getIndexId } from "../core/indexUtils.js";
|
|
5
|
-
|
|
6
8
|
function getId() {
|
|
7
9
|
return 'query';
|
|
8
10
|
}
|
|
9
|
-
|
|
10
11
|
function getCurrentRefinement(props, searchState, context) {
|
|
11
12
|
var id = getId(props);
|
|
12
13
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
13
|
-
|
|
14
14
|
if (currentRefinement) {
|
|
15
15
|
return currentRefinement;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
return '';
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
function _refine(props, searchState, nextRefinement, context) {
|
|
22
20
|
var id = getId();
|
|
23
|
-
|
|
24
21
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
25
|
-
|
|
26
22
|
var resetPage = true;
|
|
27
23
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
function _cleanUp(props, searchState, context) {
|
|
31
26
|
return cleanUpValue(searchState, context, getId());
|
|
32
27
|
}
|
|
28
|
+
|
|
33
29
|
/**
|
|
34
30
|
* connectSearchBox connector provides the logic to build a widget that will
|
|
35
31
|
* let the user search for a query
|
|
@@ -40,8 +36,6 @@ function _cleanUp(props, searchState, context) {
|
|
|
40
36
|
* @providedPropType {string} currentRefinement - the current query used
|
|
41
37
|
* @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled
|
|
42
38
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
39
|
export default createConnector({
|
|
46
40
|
displayName: 'AlgoliaSearchBox',
|
|
47
41
|
$$type: 'ais.searchBox',
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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) { _defineProperty(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; }
|
|
6
|
-
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import createConnector from "../core/createConnector.js";
|
|
9
9
|
import { cleanUpValue, refineValue, getCurrentRefinementValue } from "../core/indexUtils.js";
|
|
10
|
-
|
|
11
10
|
function getId() {
|
|
12
11
|
return 'sortBy';
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function getCurrentRefinement(props, searchState, context) {
|
|
16
14
|
var id = getId(props);
|
|
17
15
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
18
|
-
|
|
19
16
|
if (currentRefinement) {
|
|
20
17
|
return currentRefinement;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
return null;
|
|
24
20
|
}
|
|
21
|
+
|
|
25
22
|
/**
|
|
26
23
|
* The connectSortBy connector provides the logic to build a widget that will
|
|
27
24
|
* display a list of indices. This allows a user to change how the hits are being sorted.
|
|
@@ -37,8 +34,6 @@ function getCurrentRefinement(props, searchState, context) {
|
|
|
37
34
|
* @providedPropType {string[]} currentRefinement - the refinement currently applied
|
|
38
35
|
* @providedPropType {array.<{isRefined: boolean, label?: string, value: string}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
39
36
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
37
|
export default createConnector({
|
|
43
38
|
displayName: 'AlgoliaSortBy',
|
|
44
39
|
$$type: 'ais.sortBy',
|
|
@@ -69,9 +64,7 @@ export default createConnector({
|
|
|
69
64
|
},
|
|
70
65
|
refine: function refine(props, searchState, nextRefinement) {
|
|
71
66
|
var id = getId();
|
|
72
|
-
|
|
73
67
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
74
|
-
|
|
75
68
|
var resetPage = true;
|
|
76
69
|
return refineValue(searchState, nextValue, {
|
|
77
70
|
ais: props.contextValue,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import createConnector from "../core/createConnector.js";
|
|
2
2
|
import { getResults } from "../core/indexUtils.js";
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* The `connectStateResults` connector provides a way to access the `searchState` and the `searchResults`
|
|
5
6
|
* of InstantSearch.
|
|
@@ -49,7 +50,6 @@ import { getResults } from "../core/indexUtils.js";
|
|
|
49
50
|
* </InstantSearch>
|
|
50
51
|
* );
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
53
|
export default createConnector({
|
|
54
54
|
displayName: 'AlgoliaStateResults',
|
|
55
55
|
$$type: 'ais.stateResults',
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import createConnector from "../core/createConnector.js";
|
|
2
|
+
// @ts-ignore
|
|
2
3
|
import { getResults } from "../core/indexUtils.js";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* connectStats connector provides the logic to build a widget that will
|
|
5
7
|
* displays algolia search statistics (hits number and processing time).
|
|
@@ -9,7 +11,6 @@ import { getResults } from "../core/indexUtils.js";
|
|
|
9
11
|
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia.
|
|
10
12
|
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results.
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
14
|
export default createConnector({
|
|
14
15
|
displayName: 'AlgoliaStats',
|
|
15
16
|
$$type: 'ais.stats',
|
|
@@ -18,11 +19,9 @@ export default createConnector({
|
|
|
18
19
|
ais: props.contextValue,
|
|
19
20
|
multiIndexContext: props.indexContextValue
|
|
20
21
|
});
|
|
21
|
-
|
|
22
22
|
if (!results) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
25
|
return {
|
|
27
26
|
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits,
|
|
28
27
|
nbHits: results.nbHits,
|