react-instantsearch-core 6.38.1 → 6.38.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/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 +512 -1080
- 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 +8 -6
|
@@ -1,80 +1,83 @@
|
|
|
1
|
-
/*! React InstantSearchCore
|
|
1
|
+
/*! React InstantSearchCore UNRELEASED | © Algolia, inc. | https://github.com/algolia/instantsearch.js */
|
|
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) :
|
|
5
5
|
(global = global || self, factory(global.ReactInstantSearchCore = {}, global.React));
|
|
6
|
-
}(this, function (exports, React) { 'use strict';
|
|
6
|
+
}(this, (function (exports, React) { 'use strict';
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
function _iterableToArrayLimit(arr, i) {
|
|
11
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (null != _i) {
|
|
13
|
+
var _s,
|
|
14
|
+
_e,
|
|
15
|
+
_x,
|
|
16
|
+
_r,
|
|
17
|
+
_arr = [],
|
|
18
|
+
_n = !0,
|
|
19
|
+
_d = !1;
|
|
20
|
+
try {
|
|
21
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
22
|
+
if (Object(_i) !== _i) return;
|
|
23
|
+
_n = !1;
|
|
24
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
_d = !0, _e = err;
|
|
27
|
+
} finally {
|
|
28
|
+
try {
|
|
29
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
30
|
+
} finally {
|
|
31
|
+
if (_d) throw _e;
|
|
19
32
|
}
|
|
20
33
|
}
|
|
21
|
-
|
|
22
|
-
return target;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return _extends.apply(this, arguments);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
29
|
-
if (source == null) return {};
|
|
30
|
-
var target = {};
|
|
31
|
-
var sourceKeys = Object.keys(source);
|
|
32
|
-
var key, i;
|
|
33
|
-
|
|
34
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
35
|
-
key = sourceKeys[i];
|
|
36
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
37
|
-
target[key] = source[key];
|
|
34
|
+
return _arr;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
return target;
|
|
41
36
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (source == null) return {};
|
|
45
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
46
|
-
var key, i;
|
|
47
|
-
|
|
37
|
+
function ownKeys(object, enumerableOnly) {
|
|
38
|
+
var keys = Object.keys(object);
|
|
48
39
|
if (Object.getOwnPropertySymbols) {
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
41
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
42
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
43
|
+
})), keys.push.apply(keys, symbols);
|
|
44
|
+
}
|
|
45
|
+
return keys;
|
|
46
|
+
}
|
|
47
|
+
function _objectSpread2(target) {
|
|
48
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
49
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
50
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
51
|
+
_defineProperty(target, key, source[key]);
|
|
52
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
53
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
54
|
+
});
|
|
57
55
|
}
|
|
58
|
-
|
|
59
56
|
return target;
|
|
60
57
|
}
|
|
58
|
+
function _typeof(obj) {
|
|
59
|
+
"@babel/helpers - typeof";
|
|
61
60
|
|
|
61
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
62
|
+
return typeof obj;
|
|
63
|
+
} : function (obj) {
|
|
64
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
65
|
+
}, _typeof(obj);
|
|
66
|
+
}
|
|
62
67
|
function _classCallCheck(instance, Constructor) {
|
|
63
68
|
if (!(instance instanceof Constructor)) {
|
|
64
69
|
throw new TypeError("Cannot call a class as a function");
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
|
-
|
|
68
72
|
function _defineProperties(target, props) {
|
|
69
73
|
for (var i = 0; i < props.length; i++) {
|
|
70
74
|
var descriptor = props[i];
|
|
71
75
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
72
76
|
descriptor.configurable = true;
|
|
73
77
|
if ("value" in descriptor) descriptor.writable = true;
|
|
74
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
78
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
|
|
78
81
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
79
82
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
80
83
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
@@ -83,29 +86,38 @@
|
|
|
83
86
|
});
|
|
84
87
|
return Constructor;
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
|
|
89
|
+
function _defineProperty(obj, key, value) {
|
|
90
|
+
key = _toPropertyKey(key);
|
|
91
|
+
if (key in obj) {
|
|
92
|
+
Object.defineProperty(obj, key, {
|
|
93
|
+
value: value,
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
obj[key] = value;
|
|
90
100
|
}
|
|
91
|
-
|
|
92
|
-
return self;
|
|
101
|
+
return obj;
|
|
93
102
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
function _extends() {
|
|
104
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
105
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
106
|
+
var source = arguments[i];
|
|
107
|
+
for (var key in source) {
|
|
108
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
109
|
+
target[key] = source[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return target;
|
|
99
114
|
};
|
|
100
|
-
|
|
101
|
-
return _setPrototypeOf(o, p);
|
|
115
|
+
return _extends.apply(this, arguments);
|
|
102
116
|
}
|
|
103
|
-
|
|
104
117
|
function _inherits(subClass, superClass) {
|
|
105
118
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
106
119
|
throw new TypeError("Super expression must either be null or a function");
|
|
107
120
|
}
|
|
108
|
-
|
|
109
121
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
110
122
|
constructor: {
|
|
111
123
|
value: subClass,
|
|
@@ -118,47 +130,132 @@
|
|
|
118
130
|
});
|
|
119
131
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
120
132
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
function _getPrototypeOf(o) {
|
|
134
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
135
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
136
|
+
};
|
|
137
|
+
return _getPrototypeOf(o);
|
|
138
|
+
}
|
|
139
|
+
function _setPrototypeOf(o, p) {
|
|
140
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
141
|
+
o.__proto__ = p;
|
|
142
|
+
return o;
|
|
143
|
+
};
|
|
144
|
+
return _setPrototypeOf(o, p);
|
|
145
|
+
}
|
|
146
|
+
function _isNativeReflectConstruct() {
|
|
147
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
148
|
+
if (Reflect.construct.sham) return false;
|
|
149
|
+
if (typeof Proxy === "function") return true;
|
|
150
|
+
try {
|
|
151
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
152
|
+
return true;
|
|
153
|
+
} catch (e) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
158
|
+
if (source == null) return {};
|
|
159
|
+
var target = {};
|
|
160
|
+
var sourceKeys = Object.keys(source);
|
|
161
|
+
var key, i;
|
|
162
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
163
|
+
key = sourceKeys[i];
|
|
164
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
165
|
+
target[key] = source[key];
|
|
166
|
+
}
|
|
167
|
+
return target;
|
|
168
|
+
}
|
|
169
|
+
function _objectWithoutProperties(source, excluded) {
|
|
170
|
+
if (source == null) return {};
|
|
171
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
172
|
+
var key, i;
|
|
173
|
+
if (Object.getOwnPropertySymbols) {
|
|
174
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
175
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
176
|
+
key = sourceSymbolKeys[i];
|
|
177
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
178
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
179
|
+
target[key] = source[key];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return target;
|
|
183
|
+
}
|
|
184
|
+
function _assertThisInitialized(self) {
|
|
185
|
+
if (self === void 0) {
|
|
186
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
187
|
+
}
|
|
188
|
+
return self;
|
|
130
189
|
}
|
|
131
|
-
|
|
132
190
|
function _possibleConstructorReturn(self, call) {
|
|
133
|
-
if (call && (
|
|
191
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
134
192
|
return call;
|
|
135
193
|
} else if (call !== void 0) {
|
|
136
194
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
137
195
|
}
|
|
138
|
-
|
|
139
196
|
return _assertThisInitialized(self);
|
|
140
197
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
198
|
+
function _createSuper(Derived) {
|
|
199
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
200
|
+
return function _createSuperInternal() {
|
|
201
|
+
var Super = _getPrototypeOf(Derived),
|
|
202
|
+
result;
|
|
203
|
+
if (hasNativeReflectConstruct) {
|
|
204
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
205
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
206
|
+
} else {
|
|
207
|
+
result = Super.apply(this, arguments);
|
|
208
|
+
}
|
|
209
|
+
return _possibleConstructorReturn(this, result);
|
|
145
210
|
};
|
|
146
|
-
return _getPrototypeOf(o);
|
|
147
211
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
212
|
+
function _slicedToArray(arr, i) {
|
|
213
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
214
|
+
}
|
|
215
|
+
function _toConsumableArray(arr) {
|
|
216
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
217
|
+
}
|
|
218
|
+
function _arrayWithoutHoles(arr) {
|
|
219
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
220
|
+
}
|
|
221
|
+
function _arrayWithHoles(arr) {
|
|
222
|
+
if (Array.isArray(arr)) return arr;
|
|
223
|
+
}
|
|
224
|
+
function _iterableToArray(iter) {
|
|
225
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
226
|
+
}
|
|
227
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
228
|
+
if (!o) return;
|
|
229
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
230
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
231
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
232
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
233
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
234
|
+
}
|
|
235
|
+
function _arrayLikeToArray(arr, len) {
|
|
236
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
237
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
238
|
+
return arr2;
|
|
239
|
+
}
|
|
240
|
+
function _nonIterableSpread() {
|
|
241
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
242
|
+
}
|
|
243
|
+
function _nonIterableRest() {
|
|
244
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
245
|
+
}
|
|
246
|
+
function _toPrimitive(input, hint) {
|
|
247
|
+
if (typeof input !== "object" || input === null) return input;
|
|
248
|
+
var prim = input[Symbol.toPrimitive];
|
|
249
|
+
if (prim !== undefined) {
|
|
250
|
+
var res = prim.call(input, hint || "default");
|
|
251
|
+
if (typeof res !== "object") return res;
|
|
252
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
159
253
|
}
|
|
160
|
-
|
|
161
|
-
|
|
254
|
+
return (hint === "string" ? String : Number)(input);
|
|
255
|
+
}
|
|
256
|
+
function _toPropertyKey(arg) {
|
|
257
|
+
var key = _toPrimitive(arg, "string");
|
|
258
|
+
return typeof key === "symbol" ? key : String(key);
|
|
162
259
|
}
|
|
163
260
|
|
|
164
261
|
/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
|
|
@@ -292,32 +389,24 @@
|
|
|
292
389
|
}
|
|
293
390
|
};
|
|
294
391
|
|
|
295
|
-
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; }
|
|
296
|
-
|
|
297
|
-
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; }
|
|
298
|
-
|
|
299
392
|
// From https://github.com/reactjs/react-redux/blob/master/src/utils/shallowEqual.js
|
|
300
393
|
var shallowEqual = function shallowEqual(objA, objB) {
|
|
301
394
|
if (objA === objB) {
|
|
302
395
|
return true;
|
|
303
396
|
}
|
|
304
|
-
|
|
305
397
|
var keysA = Object.keys(objA);
|
|
306
398
|
var keysB = Object.keys(objB);
|
|
307
|
-
|
|
308
399
|
if (keysA.length !== keysB.length) {
|
|
309
400
|
return false;
|
|
310
|
-
}
|
|
311
|
-
|
|
401
|
+
}
|
|
312
402
|
|
|
403
|
+
// Test for A's keys different from B.
|
|
313
404
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
314
|
-
|
|
315
405
|
for (var i = 0; i < keysA.length; i++) {
|
|
316
406
|
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
317
407
|
return false;
|
|
318
408
|
}
|
|
319
409
|
}
|
|
320
|
-
|
|
321
410
|
return true;
|
|
322
411
|
};
|
|
323
412
|
var getDisplayName = function getDisplayName(Component) {
|
|
@@ -327,19 +416,15 @@
|
|
|
327
416
|
var defer = function defer(f) {
|
|
328
417
|
resolved.then(f);
|
|
329
418
|
};
|
|
330
|
-
|
|
331
419
|
var isPlainObject = function isPlainObject(value) {
|
|
332
420
|
return _typeof(value) === 'object' && value !== null && !Array.isArray(value);
|
|
333
421
|
};
|
|
334
|
-
|
|
335
422
|
var removeEmptyKey = function removeEmptyKey(obj) {
|
|
336
423
|
Object.keys(obj).forEach(function (key) {
|
|
337
424
|
var value = obj[key];
|
|
338
|
-
|
|
339
425
|
if (!isPlainObject(value)) {
|
|
340
426
|
return;
|
|
341
427
|
}
|
|
342
|
-
|
|
343
428
|
if (!objectHasKeys(value)) {
|
|
344
429
|
delete obj[key];
|
|
345
430
|
} else {
|
|
@@ -351,7 +436,6 @@
|
|
|
351
436
|
var removeEmptyArraysFromObject = function removeEmptyArraysFromObject(obj) {
|
|
352
437
|
Object.keys(obj).forEach(function (key) {
|
|
353
438
|
var value = obj[key];
|
|
354
|
-
|
|
355
439
|
if (Array.isArray(value) && value.length === 0) {
|
|
356
440
|
delete obj[key];
|
|
357
441
|
}
|
|
@@ -360,7 +444,7 @@
|
|
|
360
444
|
};
|
|
361
445
|
function addAbsolutePositions(hits, hitsPerPage, page) {
|
|
362
446
|
return hits.map(function (hit, index) {
|
|
363
|
-
return
|
|
447
|
+
return _objectSpread2(_objectSpread2({}, hit), {}, {
|
|
364
448
|
__position: hitsPerPage * page + index + 1
|
|
365
449
|
});
|
|
366
450
|
});
|
|
@@ -369,9 +453,8 @@
|
|
|
369
453
|
if (!queryID) {
|
|
370
454
|
return hits;
|
|
371
455
|
}
|
|
372
|
-
|
|
373
456
|
return hits.map(function (hit) {
|
|
374
|
-
return
|
|
457
|
+
return _objectSpread2(_objectSpread2({}, hit), {}, {
|
|
375
458
|
__queryID: queryID
|
|
376
459
|
});
|
|
377
460
|
});
|
|
@@ -380,40 +463,35 @@
|
|
|
380
463
|
if (!Array.isArray(array)) {
|
|
381
464
|
return undefined;
|
|
382
465
|
}
|
|
383
|
-
|
|
384
466
|
for (var i = 0; i < array.length; i++) {
|
|
385
467
|
if (comparator(array[i])) {
|
|
386
468
|
return array[i];
|
|
387
469
|
}
|
|
388
470
|
}
|
|
389
|
-
|
|
390
471
|
return undefined;
|
|
391
472
|
}
|
|
392
473
|
function objectHasKeys(object) {
|
|
393
474
|
return object && Object.keys(object).length > 0;
|
|
394
|
-
}
|
|
475
|
+
}
|
|
395
476
|
|
|
477
|
+
// https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620
|
|
396
478
|
function omit(source, excluded) {
|
|
397
479
|
if (source === null || source === undefined) {
|
|
398
480
|
return {};
|
|
399
481
|
}
|
|
400
|
-
|
|
401
482
|
var target = {};
|
|
402
483
|
var sourceKeys = Object.keys(source);
|
|
403
|
-
|
|
404
484
|
for (var i = 0; i < sourceKeys.length; i++) {
|
|
405
|
-
var
|
|
406
|
-
|
|
407
|
-
if (excluded.indexOf(_key) >= 0) {
|
|
485
|
+
var key = sourceKeys[i];
|
|
486
|
+
if (excluded.indexOf(key) >= 0) {
|
|
408
487
|
// eslint-disable-next-line no-continue
|
|
409
488
|
continue;
|
|
410
489
|
}
|
|
411
|
-
|
|
412
|
-
target[_key] = source[_key];
|
|
490
|
+
target[key] = source[key];
|
|
413
491
|
}
|
|
414
|
-
|
|
415
492
|
return target;
|
|
416
493
|
}
|
|
494
|
+
|
|
417
495
|
/**
|
|
418
496
|
* Retrieve the value at a path of the object:
|
|
419
497
|
*
|
|
@@ -431,7 +509,6 @@
|
|
|
431
509
|
* @param object Source object to query
|
|
432
510
|
* @param path either an array of properties, or a string form of the properties, separated by .
|
|
433
511
|
*/
|
|
434
|
-
|
|
435
512
|
var getPropertyByPath = function getPropertyByPath(object, path) {
|
|
436
513
|
return (Array.isArray(path) ? path : path.replace(/\[(\d+)]/g, '.$1').split('.')).reduce(function (current, key) {
|
|
437
514
|
return current ? current[key] : undefined;
|
|
@@ -462,22 +539,12 @@
|
|
|
462
539
|
mainTargetedIndex: ''
|
|
463
540
|
});
|
|
464
541
|
var InstantSearchConsumer = instantSearchContext.Consumer,
|
|
465
|
-
|
|
466
|
-
|
|
542
|
+
InstantSearchProvider = instantSearchContext.Provider;
|
|
467
543
|
var _createContext = /*#__PURE__*/React.createContext(undefined),
|
|
468
|
-
|
|
469
|
-
|
|
544
|
+
IndexConsumer = _createContext.Consumer,
|
|
545
|
+
IndexProvider = _createContext.Provider;
|
|
470
546
|
|
|
471
547
|
var _excluded = ["contextValue"];
|
|
472
|
-
|
|
473
|
-
function ownKeys$1(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; }
|
|
474
|
-
|
|
475
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
476
|
-
|
|
477
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); 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); }; }
|
|
478
|
-
|
|
479
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
480
|
-
|
|
481
548
|
/**
|
|
482
549
|
* Connectors are the HOC used to transform React components
|
|
483
550
|
* into InstantSearch widgets.
|
|
@@ -492,88 +559,66 @@
|
|
|
492
559
|
if (!connectorDesc.displayName) {
|
|
493
560
|
throw new Error('`createConnector` requires you to provide a `displayName` property.');
|
|
494
561
|
}
|
|
495
|
-
|
|
496
562
|
var isWidget = typeof connectorDesc.getSearchParameters === 'function' || typeof connectorDesc.getMetadata === 'function' || typeof connectorDesc.transitionState === 'function';
|
|
497
563
|
return function (Composed) {
|
|
498
564
|
var additionalWidgetProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
499
|
-
|
|
500
565
|
var Connector = /*#__PURE__*/function (_Component) {
|
|
501
566
|
_inherits(Connector, _Component);
|
|
502
|
-
|
|
503
567
|
var _super = _createSuper(Connector);
|
|
504
|
-
|
|
505
568
|
function Connector(props) {
|
|
506
569
|
var _this;
|
|
507
|
-
|
|
508
570
|
_classCallCheck(this, Connector);
|
|
509
|
-
|
|
510
571
|
_this = _super.call(this, props);
|
|
511
|
-
|
|
512
572
|
_defineProperty(_assertThisInitialized(_this), "unsubscribe", void 0);
|
|
513
|
-
|
|
514
573
|
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
515
|
-
|
|
516
574
|
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
517
|
-
|
|
518
575
|
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
519
|
-
|
|
520
576
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
521
577
|
providedProps: _this.getProvidedProps(_this.props)
|
|
522
578
|
});
|
|
523
|
-
|
|
524
579
|
_defineProperty(_assertThisInitialized(_this), "refine", function () {
|
|
525
580
|
var _ref;
|
|
526
|
-
|
|
527
581
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
528
582
|
args[_key] = arguments[_key];
|
|
529
583
|
}
|
|
530
|
-
|
|
531
|
-
|
|
584
|
+
_this.props.contextValue.onInternalStateUpdate(
|
|
585
|
+
// refine will always be defined here because the prop is only given conditionally
|
|
532
586
|
(_ref = connectorDesc.refine).call.apply(_ref, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
533
587
|
});
|
|
534
|
-
|
|
535
588
|
_defineProperty(_assertThisInitialized(_this), "createURL", function () {
|
|
536
589
|
var _ref2;
|
|
537
|
-
|
|
538
590
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
539
591
|
args[_key2] = arguments[_key2];
|
|
540
592
|
}
|
|
541
|
-
|
|
542
|
-
|
|
593
|
+
return _this.props.contextValue.createHrefForState(
|
|
594
|
+
// refine will always be defined here because the prop is only given conditionally
|
|
543
595
|
(_ref2 = connectorDesc.refine).call.apply(_ref2, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
544
596
|
});
|
|
545
|
-
|
|
546
597
|
_defineProperty(_assertThisInitialized(_this), "searchForFacetValues", function () {
|
|
547
598
|
var _ref3;
|
|
548
|
-
|
|
549
599
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
550
600
|
args[_key3] = arguments[_key3];
|
|
551
601
|
}
|
|
552
|
-
|
|
553
|
-
|
|
602
|
+
_this.props.contextValue.onSearchForFacetValues(
|
|
603
|
+
// searchForFacetValues will always be defined here because the prop is only given conditionally
|
|
554
604
|
(_ref3 = connectorDesc.searchForFacetValues).call.apply(_ref3, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
|
|
555
605
|
});
|
|
556
|
-
|
|
557
606
|
if (connectorDesc.getSearchParameters) {
|
|
558
607
|
_this.props.contextValue.onSearchParameters(connectorDesc.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
559
608
|
ais: _this.props.contextValue,
|
|
560
609
|
multiIndexContext: _this.props.indexContextValue
|
|
561
610
|
}, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind(_assertThisInitialized(_this)), connectorDesc.displayName);
|
|
562
611
|
}
|
|
563
|
-
|
|
564
612
|
return _this;
|
|
565
613
|
}
|
|
566
|
-
|
|
567
614
|
_createClass(Connector, [{
|
|
568
615
|
key: "componentDidMount",
|
|
569
616
|
value: function componentDidMount() {
|
|
570
617
|
var _this2 = this;
|
|
571
|
-
|
|
572
618
|
if (this.cleanupTimerRef) {
|
|
573
619
|
clearTimeout(this.cleanupTimerRef);
|
|
574
620
|
this.cleanupTimerRef = null;
|
|
575
621
|
}
|
|
576
|
-
|
|
577
622
|
this.unsubscribe = this.props.contextValue.store.subscribe(function () {
|
|
578
623
|
if (!_this2.isUnmounting) {
|
|
579
624
|
_this2.setState({
|
|
@@ -581,7 +626,6 @@
|
|
|
581
626
|
});
|
|
582
627
|
}
|
|
583
628
|
});
|
|
584
|
-
|
|
585
629
|
if (isWidget) {
|
|
586
630
|
this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
|
|
587
631
|
}
|
|
@@ -592,17 +636,13 @@
|
|
|
592
636
|
if (typeof connectorDesc.shouldComponentUpdate === 'function') {
|
|
593
637
|
return connectorDesc.shouldComponentUpdate.call(this, this.props, nextProps, this.state, nextState);
|
|
594
638
|
}
|
|
595
|
-
|
|
596
639
|
var propsEqual = shallowEqual(this.props, nextProps);
|
|
597
|
-
|
|
598
640
|
if (this.state.providedProps === null || nextState.providedProps === null) {
|
|
599
641
|
if (this.state.providedProps === nextState.providedProps) {
|
|
600
642
|
return !propsEqual;
|
|
601
643
|
}
|
|
602
|
-
|
|
603
644
|
return true;
|
|
604
645
|
}
|
|
605
|
-
|
|
606
646
|
return !propsEqual || !shallowEqual(this.state.providedProps, nextState.providedProps);
|
|
607
647
|
}
|
|
608
648
|
}, {
|
|
@@ -612,10 +652,8 @@
|
|
|
612
652
|
this.setState({
|
|
613
653
|
providedProps: this.getProvidedProps(this.props)
|
|
614
654
|
});
|
|
615
|
-
|
|
616
655
|
if (isWidget) {
|
|
617
656
|
this.props.contextValue.widgetsManager.update();
|
|
618
|
-
|
|
619
657
|
if (typeof connectorDesc.transitionState === 'function') {
|
|
620
658
|
this.props.contextValue.onSearchStateChange(connectorDesc.transitionState.call(this, this.props, this.props.contextValue.store.getState().widgets, this.props.contextValue.store.getState().widgets));
|
|
621
659
|
}
|
|
@@ -626,24 +664,18 @@
|
|
|
626
664
|
key: "componentWillUnmount",
|
|
627
665
|
value: function componentWillUnmount() {
|
|
628
666
|
var _this3 = this;
|
|
629
|
-
|
|
630
667
|
this.cleanupTimerRef = setTimeout(function () {
|
|
631
668
|
_this3.isUnmounting = true;
|
|
632
|
-
|
|
633
669
|
if (_this3.unsubscribe) {
|
|
634
670
|
_this3.unsubscribe();
|
|
635
671
|
}
|
|
636
|
-
|
|
637
672
|
if (_this3.unregisterWidget) {
|
|
638
673
|
_this3.unregisterWidget();
|
|
639
|
-
|
|
640
674
|
if (typeof connectorDesc.cleanUp === 'function') {
|
|
641
675
|
var nextState = connectorDesc.cleanUp.call(_this3, _this3.props, _this3.props.contextValue.store.getState().widgets);
|
|
642
|
-
|
|
643
|
-
_this3.props.contextValue.store.setState(_objectSpread$1(_objectSpread$1({}, _this3.props.contextValue.store.getState()), {}, {
|
|
676
|
+
_this3.props.contextValue.store.setState(_objectSpread2(_objectSpread2({}, _this3.props.contextValue.store.getState()), {}, {
|
|
644
677
|
widgets: nextState
|
|
645
678
|
}));
|
|
646
|
-
|
|
647
679
|
_this3.props.contextValue.onSearchStateChange(removeEmptyKey(nextState));
|
|
648
680
|
}
|
|
649
681
|
}
|
|
@@ -653,15 +685,14 @@
|
|
|
653
685
|
key: "getProvidedProps",
|
|
654
686
|
value: function getProvidedProps(props) {
|
|
655
687
|
var _this$props$contextVa = this.props.contextValue.store.getState(),
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
688
|
+
widgets = _this$props$contextVa.widgets,
|
|
689
|
+
results = _this$props$contextVa.results,
|
|
690
|
+
resultsFacetValues = _this$props$contextVa.resultsFacetValues,
|
|
691
|
+
searching = _this$props$contextVa.searching,
|
|
692
|
+
searchingForFacetValues = _this$props$contextVa.searchingForFacetValues,
|
|
693
|
+
isSearchStalled = _this$props$contextVa.isSearchStalled,
|
|
694
|
+
metadata = _this$props$contextVa.metadata,
|
|
695
|
+
error = _this$props$contextVa.error;
|
|
665
696
|
var searchResults = {
|
|
666
697
|
results: results,
|
|
667
698
|
searching: searching,
|
|
@@ -669,7 +700,8 @@
|
|
|
669
700
|
isSearchStalled: isSearchStalled,
|
|
670
701
|
error: error
|
|
671
702
|
};
|
|
672
|
-
return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
|
|
703
|
+
return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
|
|
704
|
+
// @MAJOR: move this attribute on the `searchResults` it doesn't
|
|
673
705
|
// makes sense to have it into a separate argument. The search
|
|
674
706
|
// flags are on the object why not the results?
|
|
675
707
|
resultsFacetValues);
|
|
@@ -680,7 +712,6 @@
|
|
|
680
712
|
if (typeof connectorDesc.getSearchParameters === 'function') {
|
|
681
713
|
return connectorDesc.getSearchParameters.call(this, searchParameters, this.props, this.props.contextValue.store.getState().widgets);
|
|
682
714
|
}
|
|
683
|
-
|
|
684
715
|
return null;
|
|
685
716
|
}
|
|
686
717
|
}, {
|
|
@@ -689,7 +720,6 @@
|
|
|
689
720
|
if (typeof connectorDesc.getMetadata === 'function') {
|
|
690
721
|
return connectorDesc.getMetadata.call(this, this.props, nextWidgetsState);
|
|
691
722
|
}
|
|
692
|
-
|
|
693
723
|
return {};
|
|
694
724
|
}
|
|
695
725
|
}, {
|
|
@@ -698,22 +728,18 @@
|
|
|
698
728
|
if (typeof connectorDesc.transitionState === 'function') {
|
|
699
729
|
return connectorDesc.transitionState.call(this, this.props, prevWidgetsState, nextWidgetsState);
|
|
700
730
|
}
|
|
701
|
-
|
|
702
731
|
return nextWidgetsState;
|
|
703
732
|
}
|
|
704
733
|
}, {
|
|
705
734
|
key: "render",
|
|
706
735
|
value: function render() {
|
|
707
736
|
var _this$props = this.props,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
737
|
+
contextValue = _this$props.contextValue,
|
|
738
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
711
739
|
var providedProps = this.state.providedProps;
|
|
712
|
-
|
|
713
740
|
if (providedProps === null) {
|
|
714
741
|
return null;
|
|
715
742
|
}
|
|
716
|
-
|
|
717
743
|
var refineProps = typeof connectorDesc.refine === 'function' ? {
|
|
718
744
|
refine: this.refine,
|
|
719
745
|
createURL: this.createURL
|
|
@@ -724,28 +750,19 @@
|
|
|
724
750
|
return /*#__PURE__*/React__default.createElement(Composed, _extends({}, props, providedProps, refineProps, searchForFacetValuesProps));
|
|
725
751
|
}
|
|
726
752
|
}]);
|
|
727
|
-
|
|
728
753
|
return Connector;
|
|
729
754
|
}(React.Component);
|
|
730
|
-
|
|
731
755
|
_defineProperty(Connector, "displayName", "".concat(connectorDesc.displayName, "(").concat(getDisplayName(Composed), ")"));
|
|
732
|
-
|
|
733
756
|
_defineProperty(Connector, "$$type", connectorDesc.$$type);
|
|
734
|
-
|
|
735
757
|
_defineProperty(Connector, "$$widgetType", additionalWidgetProperties.$$widgetType);
|
|
736
|
-
|
|
737
758
|
_defineProperty(Connector, "defaultProps", connectorDesc.defaultProps);
|
|
738
|
-
|
|
739
759
|
_defineProperty(Connector, "_connectorDesc", connectorDesc);
|
|
740
|
-
|
|
741
760
|
return Connector;
|
|
742
761
|
};
|
|
743
762
|
}
|
|
744
|
-
|
|
745
763
|
var createConnectorWithContext = function createConnectorWithContext(connectorDesc) {
|
|
746
764
|
return function (Composed, additionalWidgetProperties) {
|
|
747
765
|
var Connector = createConnectorWithoutContext(connectorDesc)(Composed, additionalWidgetProperties);
|
|
748
|
-
|
|
749
766
|
var ConnectorWrapper = function ConnectorWrapper(props) {
|
|
750
767
|
return /*#__PURE__*/React__default.createElement(InstantSearchConsumer, null, function (contextValue) {
|
|
751
768
|
return /*#__PURE__*/React__default.createElement(IndexConsumer, null, function (indexContextValue) {
|
|
@@ -756,7 +773,6 @@
|
|
|
756
773
|
});
|
|
757
774
|
});
|
|
758
775
|
};
|
|
759
|
-
|
|
760
776
|
return ConnectorWrapper;
|
|
761
777
|
};
|
|
762
778
|
};
|
|
@@ -765,6 +781,7 @@
|
|
|
765
781
|
highlightPreTag: "<ais-highlight-0000000000>",
|
|
766
782
|
highlightPostTag: "</ais-highlight-0000000000>"
|
|
767
783
|
};
|
|
784
|
+
|
|
768
785
|
/**
|
|
769
786
|
* Parses an highlighted attribute into an array of objects with the string value, and
|
|
770
787
|
* a boolean that indicated if this part is highlighted.
|
|
@@ -774,19 +791,17 @@
|
|
|
774
791
|
* @param {string} highlightedValue - highlighted attribute as returned by Algolia highlight feature
|
|
775
792
|
* @return {object[]} - An array of {value: string, isHighlighted: boolean}.
|
|
776
793
|
*/
|
|
777
|
-
|
|
778
794
|
function parseHighlightedAttribute(_ref) {
|
|
779
795
|
var preTag = _ref.preTag,
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
796
|
+
postTag = _ref.postTag,
|
|
797
|
+
_ref$highlightedValue = _ref.highlightedValue,
|
|
798
|
+
highlightedValue = _ref$highlightedValue === void 0 ? '' : _ref$highlightedValue;
|
|
783
799
|
var splitByPreTag = highlightedValue.split(preTag);
|
|
784
800
|
var firstValue = splitByPreTag.shift();
|
|
785
801
|
var elements = firstValue === '' ? [] : [{
|
|
786
802
|
value: firstValue,
|
|
787
803
|
isHighlighted: false
|
|
788
804
|
}];
|
|
789
|
-
|
|
790
805
|
if (postTag === preTag) {
|
|
791
806
|
var isHighlighted = true;
|
|
792
807
|
splitByPreTag.forEach(function (split) {
|
|
@@ -803,7 +818,6 @@
|
|
|
803
818
|
value: splitByPostTag[0],
|
|
804
819
|
isHighlighted: true
|
|
805
820
|
});
|
|
806
|
-
|
|
807
821
|
if (splitByPostTag[1] !== '') {
|
|
808
822
|
elements.push({
|
|
809
823
|
value: splitByPostTag[1],
|
|
@@ -812,9 +826,9 @@
|
|
|
812
826
|
}
|
|
813
827
|
});
|
|
814
828
|
}
|
|
815
|
-
|
|
816
829
|
return elements;
|
|
817
830
|
}
|
|
831
|
+
|
|
818
832
|
/**
|
|
819
833
|
* Find an highlighted attribute given an `attribute` and an `highlightProperty`, parses it,
|
|
820
834
|
* and provided an array of objects with the string value and a boolean if this
|
|
@@ -831,19 +845,16 @@
|
|
|
831
845
|
* @param {object} hit - the actual hit returned by Algolia.
|
|
832
846
|
* @return {object[]} - An array of {value: string, isHighlighted: boolean}.
|
|
833
847
|
*/
|
|
834
|
-
|
|
835
|
-
|
|
836
848
|
function parseAlgoliaHit(_ref2) {
|
|
837
849
|
var _ref2$preTag = _ref2.preTag,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
850
|
+
preTag = _ref2$preTag === void 0 ? '<em>' : _ref2$preTag,
|
|
851
|
+
_ref2$postTag = _ref2.postTag,
|
|
852
|
+
postTag = _ref2$postTag === void 0 ? '</em>' : _ref2$postTag,
|
|
853
|
+
highlightProperty = _ref2.highlightProperty,
|
|
854
|
+
attribute = _ref2.attribute,
|
|
855
|
+
hit = _ref2.hit;
|
|
844
856
|
if (!hit) throw new Error('`hit`, the matching record, must be provided');
|
|
845
857
|
var highlightObject = getPropertyByPath(hit[highlightProperty], attribute) || {};
|
|
846
|
-
|
|
847
858
|
if (Array.isArray(highlightObject)) {
|
|
848
859
|
return highlightObject.map(function (item) {
|
|
849
860
|
return parseHighlightedAttribute({
|
|
@@ -853,7 +864,6 @@
|
|
|
853
864
|
});
|
|
854
865
|
});
|
|
855
866
|
}
|
|
856
|
-
|
|
857
867
|
return parseHighlightedAttribute({
|
|
858
868
|
preTag: preTag,
|
|
859
869
|
postTag: postTag,
|
|
@@ -861,47 +871,33 @@
|
|
|
861
871
|
});
|
|
862
872
|
}
|
|
863
873
|
|
|
864
|
-
var version = '6.38.
|
|
874
|
+
var version = '6.38.3';
|
|
865
875
|
|
|
866
|
-
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); }; }
|
|
867
|
-
|
|
868
|
-
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
869
876
|
function translatable(defaultTranslations) {
|
|
870
877
|
return function (Composed) {
|
|
871
878
|
var Translatable = /*#__PURE__*/function (_Component) {
|
|
872
879
|
_inherits(Translatable, _Component);
|
|
873
|
-
|
|
874
|
-
var _super = _createSuper$1(Translatable);
|
|
875
|
-
|
|
880
|
+
var _super = _createSuper(Translatable);
|
|
876
881
|
function Translatable() {
|
|
877
882
|
var _this;
|
|
878
|
-
|
|
879
883
|
_classCallCheck(this, Translatable);
|
|
880
|
-
|
|
881
884
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
882
885
|
args[_key] = arguments[_key];
|
|
883
886
|
}
|
|
884
|
-
|
|
885
887
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
886
|
-
|
|
887
888
|
_defineProperty(_assertThisInitialized(_this), "translate", function (key) {
|
|
888
889
|
var translations = _this.props.translations;
|
|
889
890
|
var translation = translations && translations.hasOwnProperty(key) ? translations[key] : defaultTranslations[key];
|
|
890
|
-
|
|
891
891
|
if (typeof translation === 'function') {
|
|
892
892
|
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
893
893
|
params[_key2 - 1] = arguments[_key2];
|
|
894
894
|
}
|
|
895
|
-
|
|
896
895
|
return translation.apply(void 0, params);
|
|
897
896
|
}
|
|
898
|
-
|
|
899
897
|
return translation;
|
|
900
898
|
});
|
|
901
|
-
|
|
902
899
|
return _this;
|
|
903
900
|
}
|
|
904
|
-
|
|
905
901
|
_createClass(Translatable, [{
|
|
906
902
|
key: "render",
|
|
907
903
|
value: function render() {
|
|
@@ -910,39 +906,32 @@
|
|
|
910
906
|
}, this.props));
|
|
911
907
|
}
|
|
912
908
|
}]);
|
|
913
|
-
|
|
914
909
|
return Translatable;
|
|
915
910
|
}(React.Component);
|
|
916
|
-
|
|
917
911
|
var name = Composed.displayName || Composed.name || 'UnknownComponent';
|
|
918
912
|
Translatable.displayName = "Translatable(".concat(name, ")");
|
|
919
913
|
return Translatable;
|
|
920
914
|
};
|
|
921
915
|
}
|
|
922
916
|
|
|
923
|
-
function ownKeys$2(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; }
|
|
924
|
-
|
|
925
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
926
917
|
function getIndexId(context) {
|
|
927
918
|
return hasMultipleIndices(context) ? context.multiIndexContext.targetedIndex : context.ais.mainTargetedIndex;
|
|
928
919
|
}
|
|
920
|
+
|
|
921
|
+
// eslint-disable-next-line valid-jsdoc
|
|
929
922
|
/**
|
|
930
923
|
* @returns {import('algoliasearch-helper').SearchResults} results
|
|
931
924
|
*/
|
|
932
|
-
|
|
933
925
|
function getResults(searchResults, context) {
|
|
934
926
|
if (searchResults.results) {
|
|
935
927
|
if (searchResults.results.hits) {
|
|
936
928
|
return searchResults.results;
|
|
937
929
|
}
|
|
938
|
-
|
|
939
930
|
var indexId = getIndexId(context);
|
|
940
|
-
|
|
941
931
|
if (searchResults.results[indexId]) {
|
|
942
932
|
return searchResults.results[indexId];
|
|
943
933
|
}
|
|
944
934
|
}
|
|
945
|
-
|
|
946
935
|
return null;
|
|
947
936
|
}
|
|
948
937
|
function hasMultipleIndices(context) {
|
|
@@ -969,47 +958,40 @@
|
|
|
969
958
|
}, true, namespace);
|
|
970
959
|
});
|
|
971
960
|
}
|
|
972
|
-
|
|
973
961
|
return namespace ? refineSingleIndexWithNamespace(searchState, nextRefinement, resetPage, namespace) : refineSingleIndex(searchState, nextRefinement, resetPage);
|
|
974
962
|
}
|
|
975
963
|
}
|
|
976
|
-
|
|
977
964
|
function refineMultiIndex(searchState, nextRefinement, indexId, resetPage) {
|
|
978
965
|
var page = resetPage ? {
|
|
979
966
|
page: 1
|
|
980
967
|
} : undefined;
|
|
981
|
-
var state = searchState.indices && searchState.indices[indexId] ?
|
|
982
|
-
return
|
|
968
|
+
var state = searchState.indices && searchState.indices[indexId] ? _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread2(_objectSpread2(_objectSpread2({}, searchState.indices[indexId]), nextRefinement), page))) : _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread2(_objectSpread2({}, nextRefinement), page)));
|
|
969
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, {
|
|
983
970
|
indices: state
|
|
984
971
|
});
|
|
985
972
|
}
|
|
986
|
-
|
|
987
973
|
function refineSingleIndex(searchState, nextRefinement, resetPage) {
|
|
988
974
|
var page = resetPage ? {
|
|
989
975
|
page: 1
|
|
990
976
|
} : undefined;
|
|
991
|
-
return
|
|
977
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, searchState), nextRefinement), page);
|
|
992
978
|
}
|
|
993
|
-
|
|
994
979
|
function refineMultiIndexWithNamespace(searchState, nextRefinement, indexId, resetPage, namespace) {
|
|
995
980
|
var _objectSpread4;
|
|
996
|
-
|
|
997
981
|
var page = resetPage ? {
|
|
998
982
|
page: 1
|
|
999
983
|
} : undefined;
|
|
1000
|
-
var state = searchState.indices && searchState.indices[indexId] ?
|
|
1001
|
-
return
|
|
984
|
+
var state = searchState.indices && searchState.indices[indexId] ? _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread2(_objectSpread2({}, searchState.indices[indexId]), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, namespace, _objectSpread2(_objectSpread2({}, searchState.indices[indexId][namespace]), nextRefinement)), _defineProperty(_objectSpread4, "page", 1), _objectSpread4)))) : _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread2(_defineProperty({}, namespace, nextRefinement), page)));
|
|
985
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, {
|
|
1002
986
|
indices: state
|
|
1003
987
|
});
|
|
1004
988
|
}
|
|
1005
|
-
|
|
1006
989
|
function refineSingleIndexWithNamespace(searchState, nextRefinement, resetPage, namespace) {
|
|
1007
990
|
var page = resetPage ? {
|
|
1008
991
|
page: 1
|
|
1009
992
|
} : undefined;
|
|
1010
|
-
return
|
|
993
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, _defineProperty({}, namespace, _objectSpread2(_objectSpread2({}, searchState[namespace]), nextRefinement)), page);
|
|
1011
994
|
}
|
|
1012
|
-
|
|
1013
995
|
function getNamespaceAndAttributeName(id) {
|
|
1014
996
|
var parts = id.match(/^([^.]*)\.(.*)/);
|
|
1015
997
|
var namespace = parts && parts[1];
|
|
@@ -1019,60 +1001,47 @@
|
|
|
1019
1001
|
attributeName: attributeName
|
|
1020
1002
|
};
|
|
1021
1003
|
}
|
|
1022
|
-
|
|
1023
1004
|
function hasRefinements(_ref) {
|
|
1024
1005
|
var multiIndex = _ref.multiIndex,
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1006
|
+
indexId = _ref.indexId,
|
|
1007
|
+
namespace = _ref.namespace,
|
|
1008
|
+
attributeName = _ref.attributeName,
|
|
1009
|
+
id = _ref.id,
|
|
1010
|
+
searchState = _ref.searchState;
|
|
1031
1011
|
if (multiIndex && namespace) {
|
|
1032
1012
|
return searchState.indices && searchState.indices[indexId] && searchState.indices[indexId][namespace] && Object.hasOwnProperty.call(searchState.indices[indexId][namespace], attributeName);
|
|
1033
1013
|
}
|
|
1034
|
-
|
|
1035
1014
|
if (multiIndex) {
|
|
1036
1015
|
return searchState.indices && searchState.indices[indexId] && Object.hasOwnProperty.call(searchState.indices[indexId], id);
|
|
1037
1016
|
}
|
|
1038
|
-
|
|
1039
1017
|
if (namespace) {
|
|
1040
1018
|
return searchState[namespace] && Object.hasOwnProperty.call(searchState[namespace], attributeName);
|
|
1041
1019
|
}
|
|
1042
|
-
|
|
1043
1020
|
return Object.hasOwnProperty.call(searchState, id);
|
|
1044
1021
|
}
|
|
1045
|
-
|
|
1046
1022
|
function getRefinements(_ref2) {
|
|
1047
1023
|
var multiIndex = _ref2.multiIndex,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1024
|
+
indexId = _ref2.indexId,
|
|
1025
|
+
namespace = _ref2.namespace,
|
|
1026
|
+
attributeName = _ref2.attributeName,
|
|
1027
|
+
id = _ref2.id,
|
|
1028
|
+
searchState = _ref2.searchState;
|
|
1054
1029
|
if (multiIndex && namespace) {
|
|
1055
1030
|
return searchState.indices[indexId][namespace][attributeName];
|
|
1056
1031
|
}
|
|
1057
|
-
|
|
1058
1032
|
if (multiIndex) {
|
|
1059
1033
|
return searchState.indices[indexId][id];
|
|
1060
1034
|
}
|
|
1061
|
-
|
|
1062
1035
|
if (namespace) {
|
|
1063
1036
|
return searchState[namespace][attributeName];
|
|
1064
1037
|
}
|
|
1065
|
-
|
|
1066
1038
|
return searchState[id];
|
|
1067
1039
|
}
|
|
1068
|
-
|
|
1069
1040
|
function getCurrentRefinementValue(props, searchState, context, id, defaultValue) {
|
|
1070
1041
|
var indexId = getIndexId(context);
|
|
1071
|
-
|
|
1072
1042
|
var _getNamespaceAndAttri = getNamespaceAndAttributeName(id),
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1043
|
+
namespace = _getNamespaceAndAttri.namespace,
|
|
1044
|
+
attributeName = _getNamespaceAndAttri.attributeName;
|
|
1076
1045
|
var multiIndex = hasMultipleIndices(context);
|
|
1077
1046
|
var args = {
|
|
1078
1047
|
multiIndex: multiIndex,
|
|
@@ -1083,24 +1052,19 @@
|
|
|
1083
1052
|
searchState: searchState
|
|
1084
1053
|
};
|
|
1085
1054
|
var hasRefinementsValue = hasRefinements(args);
|
|
1086
|
-
|
|
1087
1055
|
if (hasRefinementsValue) {
|
|
1088
1056
|
return getRefinements(args);
|
|
1089
1057
|
}
|
|
1090
|
-
|
|
1091
1058
|
if (props.defaultRefinement) {
|
|
1092
1059
|
return props.defaultRefinement;
|
|
1093
1060
|
}
|
|
1094
|
-
|
|
1095
1061
|
return defaultValue;
|
|
1096
1062
|
}
|
|
1097
1063
|
function cleanUpValue(searchState, context, id) {
|
|
1098
1064
|
var indexId = getIndexId(context);
|
|
1099
|
-
|
|
1100
1065
|
var _getNamespaceAndAttri2 = getNamespaceAndAttributeName(id),
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1066
|
+
namespace = _getNamespaceAndAttri2.namespace,
|
|
1067
|
+
attributeName = _getNamespaceAndAttri2.attributeName;
|
|
1104
1068
|
if (hasMultipleIndices(context) && Boolean(searchState.indices)) {
|
|
1105
1069
|
return cleanUpValueWithMultiIndex({
|
|
1106
1070
|
attribute: attributeName,
|
|
@@ -1110,7 +1074,6 @@
|
|
|
1110
1074
|
namespace: namespace
|
|
1111
1075
|
});
|
|
1112
1076
|
}
|
|
1113
|
-
|
|
1114
1077
|
return cleanUpValueWithSingleIndex({
|
|
1115
1078
|
attribute: attributeName,
|
|
1116
1079
|
searchState: searchState,
|
|
@@ -1118,54 +1081,41 @@
|
|
|
1118
1081
|
namespace: namespace
|
|
1119
1082
|
});
|
|
1120
1083
|
}
|
|
1121
|
-
|
|
1122
1084
|
function cleanUpValueWithSingleIndex(_ref3) {
|
|
1123
1085
|
var searchState = _ref3.searchState,
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1086
|
+
id = _ref3.id,
|
|
1087
|
+
namespace = _ref3.namespace,
|
|
1088
|
+
attribute = _ref3.attribute;
|
|
1128
1089
|
if (namespace) {
|
|
1129
|
-
return
|
|
1090
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, _defineProperty({}, namespace, omit(searchState[namespace], [attribute])));
|
|
1130
1091
|
}
|
|
1131
|
-
|
|
1132
1092
|
return omit(searchState, [id]);
|
|
1133
1093
|
}
|
|
1134
|
-
|
|
1135
1094
|
function cleanUpValueWithMultiIndex(_ref4) {
|
|
1136
1095
|
var searchState = _ref4.searchState,
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1096
|
+
indexId = _ref4.indexId,
|
|
1097
|
+
id = _ref4.id,
|
|
1098
|
+
namespace = _ref4.namespace,
|
|
1099
|
+
attribute = _ref4.attribute;
|
|
1141
1100
|
var indexSearchState = searchState.indices[indexId];
|
|
1142
|
-
|
|
1143
1101
|
if (namespace && indexSearchState) {
|
|
1144
|
-
return
|
|
1145
|
-
indices:
|
|
1102
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, {
|
|
1103
|
+
indices: _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread2(_objectSpread2({}, indexSearchState), {}, _defineProperty({}, namespace, omit(indexSearchState[namespace], [attribute])))))
|
|
1146
1104
|
});
|
|
1147
1105
|
}
|
|
1148
|
-
|
|
1149
1106
|
if (indexSearchState) {
|
|
1150
|
-
return
|
|
1151
|
-
indices:
|
|
1107
|
+
return _objectSpread2(_objectSpread2({}, searchState), {}, {
|
|
1108
|
+
indices: _objectSpread2(_objectSpread2({}, searchState.indices), {}, _defineProperty({}, indexId, omit(indexSearchState, [id])))
|
|
1152
1109
|
});
|
|
1153
1110
|
}
|
|
1154
|
-
|
|
1155
1111
|
return searchState;
|
|
1156
1112
|
}
|
|
1157
1113
|
|
|
1158
1114
|
var _excluded$1 = ["children", "contextValue", "indexContextValue"],
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
function ownKeys$3(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; }
|
|
1162
|
-
|
|
1163
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1164
|
-
|
|
1115
|
+
_excluded2 = ["children", "contextValue", "indexContextValue"];
|
|
1165
1116
|
function getId() {
|
|
1166
1117
|
return 'configure';
|
|
1167
1118
|
}
|
|
1168
|
-
|
|
1169
1119
|
var connectConfigure = createConnectorWithContext({
|
|
1170
1120
|
displayName: 'AlgoliaConfigure',
|
|
1171
1121
|
$$type: 'ais.configure',
|
|
@@ -1174,28 +1124,23 @@
|
|
|
1174
1124
|
},
|
|
1175
1125
|
getSearchParameters: function getSearchParameters(searchParameters, props) {
|
|
1176
1126
|
var children = props.children,
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1127
|
+
contextValue = props.contextValue,
|
|
1128
|
+
indexContextValue = props.indexContextValue,
|
|
1129
|
+
items = _objectWithoutProperties(props, _excluded$1);
|
|
1181
1130
|
return searchParameters.setQueryParameters(items);
|
|
1182
1131
|
},
|
|
1183
1132
|
transitionState: function transitionState(props, prevSearchState, nextSearchState) {
|
|
1184
1133
|
var id = getId();
|
|
1185
|
-
|
|
1186
1134
|
var children = props.children,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1135
|
+
contextValue = props.contextValue,
|
|
1136
|
+
indexContextValue = props.indexContextValue,
|
|
1137
|
+
items = _objectWithoutProperties(props, _excluded2);
|
|
1191
1138
|
var propKeys = Object.keys(props);
|
|
1192
1139
|
var nonPresentKeys = this._props ? Object.keys(this._props).filter(function (prop) {
|
|
1193
1140
|
return propKeys.indexOf(prop) === -1;
|
|
1194
1141
|
}) : [];
|
|
1195
1142
|
this._props = props;
|
|
1196
|
-
|
|
1197
|
-
var nextValue = _defineProperty({}, id, _objectSpread$3(_objectSpread$3({}, omit(nextSearchState[id], nonPresentKeys)), items));
|
|
1198
|
-
|
|
1143
|
+
var nextValue = _defineProperty({}, id, _objectSpread2(_objectSpread2({}, omit(nextSearchState[id], nonPresentKeys)), items));
|
|
1199
1144
|
return refineValue(nextSearchState, nextValue, {
|
|
1200
1145
|
ais: props.contextValue,
|
|
1201
1146
|
multiIndexContext: props.indexContextValue
|
|
@@ -1216,12 +1161,9 @@
|
|
|
1216
1161
|
if (!props[item]) {
|
|
1217
1162
|
acc[item] = subState[id][item];
|
|
1218
1163
|
}
|
|
1219
|
-
|
|
1220
1164
|
return acc;
|
|
1221
1165
|
}, {});
|
|
1222
|
-
|
|
1223
1166
|
var nextValue = _defineProperty({}, id, configureState);
|
|
1224
|
-
|
|
1225
1167
|
return refineValue(searchState, nextValue, {
|
|
1226
1168
|
ais: props.contextValue,
|
|
1227
1169
|
multiIndexContext: props.indexContextValue
|
|
@@ -1270,41 +1212,6 @@
|
|
|
1270
1212
|
$$widgetType: 'ais.configure'
|
|
1271
1213
|
});
|
|
1272
1214
|
|
|
1273
|
-
function _arrayLikeToArray(arr, len) {
|
|
1274
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1275
|
-
|
|
1276
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1277
|
-
arr2[i] = arr[i];
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
return arr2;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
function _arrayWithoutHoles(arr) {
|
|
1284
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
function _iterableToArray(iter) {
|
|
1288
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1292
|
-
if (!o) return;
|
|
1293
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1294
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1295
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1296
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1297
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
function _nonIterableSpread() {
|
|
1301
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
function _toConsumableArray(arr) {
|
|
1305
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
1215
|
function clone(value) {
|
|
1309
1216
|
if (typeof value === 'object' && value !== null) {
|
|
1310
1217
|
return _merge(Array.isArray(value) ? [] : {}, value);
|
|
@@ -1328,7 +1235,8 @@
|
|
|
1328
1235
|
for (var key in source) {
|
|
1329
1236
|
if (
|
|
1330
1237
|
!Object.prototype.hasOwnProperty.call(source, key) ||
|
|
1331
|
-
key === '__proto__'
|
|
1238
|
+
key === '__proto__' ||
|
|
1239
|
+
key === 'constructor'
|
|
1332
1240
|
) {
|
|
1333
1241
|
continue;
|
|
1334
1242
|
}
|
|
@@ -5233,7 +5141,7 @@
|
|
|
5233
5141
|
|
|
5234
5142
|
var requestBuilder_1 = requestBuilder;
|
|
5235
5143
|
|
|
5236
|
-
var version$1 = '3.11.
|
|
5144
|
+
var version$1 = '3.11.2';
|
|
5237
5145
|
|
|
5238
5146
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
5239
5147
|
|
|
@@ -5483,8 +5391,10 @@
|
|
|
5483
5391
|
* @param {number} options.nbHits - Maximum number of answers to retrieve from the Answers Engine. Cannot be greater than 1000.
|
|
5484
5392
|
*
|
|
5485
5393
|
* @return {promise} the answer results
|
|
5394
|
+
* @deprecated answers is deprecated and will be replaced with new initiatives
|
|
5486
5395
|
*/
|
|
5487
5396
|
AlgoliaSearchHelper.prototype.findAnswers = function(options) {
|
|
5397
|
+
console.warn('[algoliasearch-helper] answers is no longer supported');
|
|
5488
5398
|
var state = this.state;
|
|
5489
5399
|
var derivedHelper = this.derivedHelpers[0];
|
|
5490
5400
|
if (!derivedHelper) {
|
|
@@ -6783,34 +6693,26 @@
|
|
|
6783
6693
|
|
|
6784
6694
|
var algoliasearchHelper_1 = algoliasearchHelper;
|
|
6785
6695
|
|
|
6786
|
-
function ownKeys$4(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; }
|
|
6787
|
-
|
|
6788
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6789
|
-
|
|
6790
6696
|
function createOptionalFilter(_ref) {
|
|
6791
6697
|
var attributeName = _ref.attributeName,
|
|
6792
|
-
|
|
6793
|
-
|
|
6698
|
+
attributeValue = _ref.attributeValue,
|
|
6699
|
+
attributeScore = _ref.attributeScore;
|
|
6794
6700
|
return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
|
|
6795
6701
|
}
|
|
6796
|
-
|
|
6797
6702
|
var defaultProps = {
|
|
6798
6703
|
transformSearchParameters: function transformSearchParameters(x) {
|
|
6799
|
-
return
|
|
6704
|
+
return _objectSpread2({}, x);
|
|
6800
6705
|
}
|
|
6801
6706
|
};
|
|
6802
|
-
|
|
6803
6707
|
function getId$1() {
|
|
6804
6708
|
// We store the search state of this widget in `configure`.
|
|
6805
6709
|
return 'configure';
|
|
6806
6710
|
}
|
|
6807
|
-
|
|
6808
6711
|
function getSearchParametersFromProps(props) {
|
|
6809
6712
|
var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
|
|
6810
6713
|
var attributePattern = props.matchingPatterns[attributeName];
|
|
6811
6714
|
var attributeValue = getPropertyByPath(props.hit, attributeName);
|
|
6812
6715
|
var attributeScore = attributePattern.score;
|
|
6813
|
-
|
|
6814
6716
|
if (Array.isArray(attributeValue)) {
|
|
6815
6717
|
return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
|
|
6816
6718
|
return createOptionalFilter({
|
|
@@ -6820,7 +6722,6 @@
|
|
|
6820
6722
|
});
|
|
6821
6723
|
})]);
|
|
6822
6724
|
}
|
|
6823
|
-
|
|
6824
6725
|
if (typeof attributeValue === 'string') {
|
|
6825
6726
|
return [].concat(_toConsumableArray(acc), [createOptionalFilter({
|
|
6826
6727
|
attributeName: attributeName,
|
|
@@ -6828,7 +6729,6 @@
|
|
|
6828
6729
|
attributeScore: attributeScore
|
|
6829
6730
|
})]);
|
|
6830
6731
|
}
|
|
6831
|
-
|
|
6832
6732
|
return acc;
|
|
6833
6733
|
}, []);
|
|
6834
6734
|
return props.transformSearchParameters(new algoliasearchHelper_1.SearchParameters({
|
|
@@ -6840,7 +6740,6 @@
|
|
|
6840
6740
|
optionalFilters: optionalFilters
|
|
6841
6741
|
}));
|
|
6842
6742
|
}
|
|
6843
|
-
|
|
6844
6743
|
var connectConfigureRelatedItems = createConnectorWithContext({
|
|
6845
6744
|
displayName: 'AlgoliaConfigureRelatedItems',
|
|
6846
6745
|
$$type: 'ais.configureRelatedItems',
|
|
@@ -6852,19 +6751,17 @@
|
|
|
6852
6751
|
return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
|
|
6853
6752
|
},
|
|
6854
6753
|
transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
|
|
6855
|
-
var id = getId$1();
|
|
6754
|
+
var id = getId$1();
|
|
6755
|
+
// We need to transform the exhaustive search parameters back to clean
|
|
6856
6756
|
// search parameters without the empty default keys so we don't pollute the
|
|
6857
6757
|
// `configure` search state.
|
|
6858
|
-
|
|
6859
6758
|
var searchParameters = removeEmptyArraysFromObject(removeEmptyKey(getSearchParametersFromProps(props)));
|
|
6860
6759
|
var searchParametersKeys = Object.keys(searchParameters);
|
|
6861
6760
|
var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
|
|
6862
6761
|
return searchParametersKeys.indexOf(prop) === -1;
|
|
6863
6762
|
}) : [];
|
|
6864
6763
|
this._searchParameters = searchParameters;
|
|
6865
|
-
|
|
6866
|
-
var nextValue = _defineProperty({}, id, _objectSpread$4(_objectSpread$4({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
6867
|
-
|
|
6764
|
+
var nextValue = _defineProperty({}, id, _objectSpread2(_objectSpread2({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
6868
6765
|
return refineValue(nextSearchState, nextValue, {
|
|
6869
6766
|
ais: props.contextValue,
|
|
6870
6767
|
multiIndexContext: props.indexContextValue
|
|
@@ -6872,7 +6769,6 @@
|
|
|
6872
6769
|
},
|
|
6873
6770
|
cleanUp: function cleanUp(props, searchState) {
|
|
6874
6771
|
var _this = this;
|
|
6875
|
-
|
|
6876
6772
|
var id = getId$1();
|
|
6877
6773
|
var indexId = getIndexId({
|
|
6878
6774
|
ais: props.contextValue,
|
|
@@ -6887,12 +6783,9 @@
|
|
|
6887
6783
|
if (!_this._searchParameters[item]) {
|
|
6888
6784
|
acc[item] = subState[id][item];
|
|
6889
6785
|
}
|
|
6890
|
-
|
|
6891
6786
|
return acc;
|
|
6892
6787
|
}, {});
|
|
6893
|
-
|
|
6894
6788
|
var nextValue = _defineProperty({}, id, configureState);
|
|
6895
|
-
|
|
6896
6789
|
return refineValue(searchState, nextValue, {
|
|
6897
6790
|
ais: props.contextValue,
|
|
6898
6791
|
multiIndexContext: props.indexContextValue
|
|
@@ -6904,9 +6797,6 @@
|
|
|
6904
6797
|
typeof self !== "undefined" ? self :
|
|
6905
6798
|
typeof window !== "undefined" ? window : {});
|
|
6906
6799
|
|
|
6907
|
-
if (typeof global$1.setTimeout === 'function') ;
|
|
6908
|
-
if (typeof global$1.clearTimeout === 'function') ;
|
|
6909
|
-
|
|
6910
6800
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
6911
6801
|
var performance = global$1.performance || {};
|
|
6912
6802
|
var performanceNow =
|
|
@@ -7087,7 +6977,6 @@
|
|
|
7087
6977
|
function ConfigureRelatedItems() {
|
|
7088
6978
|
return null;
|
|
7089
6979
|
}
|
|
7090
|
-
|
|
7091
6980
|
ConfigureRelatedItems.propTypes = {
|
|
7092
6981
|
hit: propTypes.object.isRequired,
|
|
7093
6982
|
matchingPatterns: propTypes.object.isRequired,
|
|
@@ -7117,32 +7006,26 @@
|
|
|
7117
7006
|
ais: props.contextValue,
|
|
7118
7007
|
multiIndexContext: props.indexContextValue
|
|
7119
7008
|
});
|
|
7120
|
-
|
|
7121
7009
|
if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
|
|
7122
7010
|
throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
|
|
7123
7011
|
}
|
|
7124
|
-
|
|
7125
7012
|
if (!results) {
|
|
7126
7013
|
return {
|
|
7127
7014
|
attributesToRender: []
|
|
7128
7015
|
};
|
|
7129
7016
|
}
|
|
7130
|
-
|
|
7131
7017
|
var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
|
|
7132
7018
|
var attributesToRender = props.transformItems(facetOrder, {
|
|
7133
7019
|
results: results
|
|
7134
7020
|
});
|
|
7135
|
-
|
|
7136
7021
|
if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
|
|
7137
7022
|
// eslint-disable-next-line no-console
|
|
7138
7023
|
console.warn("More than ".concat(MAX_WILDCARD_FACETS, " facets are requested to be displayed without explicitly setting which facets to retrieve. This could have a performance impact. Set \"facets\" to [] to do two smaller network requests, or explicitly to ['*'] to avoid this warning."));
|
|
7139
7024
|
}
|
|
7140
|
-
|
|
7141
7025
|
if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
|
|
7142
7026
|
// eslint-disable-next-line no-console
|
|
7143
7027
|
console.warn("The maxValuesPerFacet set by dynamic widgets (".concat(props.maxValuesPerFacet, ") is smaller than one of the limits set by a widget (").concat(results._state.maxValuesPerFacet, "). This causes a mismatch in query parameters and thus an extra network request when that widget is mounted."));
|
|
7144
7028
|
}
|
|
7145
|
-
|
|
7146
7029
|
return {
|
|
7147
7030
|
attributesToRender: attributesToRender
|
|
7148
7031
|
};
|
|
@@ -7159,46 +7042,39 @@
|
|
|
7159
7042
|
function isReactElement(element) {
|
|
7160
7043
|
return _typeof(element) === 'object' && element.props;
|
|
7161
7044
|
}
|
|
7162
|
-
|
|
7163
7045
|
function getAttribute(element) {
|
|
7164
7046
|
if (!isReactElement(element)) {
|
|
7165
7047
|
return undefined;
|
|
7166
7048
|
}
|
|
7167
|
-
|
|
7168
7049
|
if (element.props.attribute) {
|
|
7169
7050
|
return element.props.attribute;
|
|
7170
7051
|
}
|
|
7171
|
-
|
|
7172
7052
|
if (Array.isArray(element.props.attributes)) {
|
|
7173
7053
|
return element.props.attributes[0];
|
|
7174
7054
|
}
|
|
7175
|
-
|
|
7176
7055
|
if (element.props.children) {
|
|
7177
7056
|
return getAttribute(React__default.Children.only(element.props.children));
|
|
7178
7057
|
}
|
|
7179
|
-
|
|
7180
7058
|
return undefined;
|
|
7181
7059
|
}
|
|
7182
|
-
|
|
7183
7060
|
function DynamicWidgets(_ref) {
|
|
7184
7061
|
var children = _ref.children,
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7062
|
+
attributesToRender = _ref.attributesToRender,
|
|
7063
|
+
_ref$fallbackComponen = _ref.fallbackComponent,
|
|
7064
|
+
Fallback = _ref$fallbackComponen === void 0 ? function () {
|
|
7065
|
+
return null;
|
|
7066
|
+
} : _ref$fallbackComponen;
|
|
7190
7067
|
var widgets = new Map();
|
|
7191
7068
|
React__default.Children.forEach(children, function (child) {
|
|
7192
7069
|
var attribute = getAttribute(child);
|
|
7193
|
-
|
|
7194
7070
|
if (!attribute) {
|
|
7195
7071
|
throw new Error("Could not find \"attribute\" prop for ".concat(getDisplayName(child), "."));
|
|
7196
7072
|
}
|
|
7197
|
-
|
|
7198
7073
|
widgets.set(attribute, child);
|
|
7199
|
-
});
|
|
7200
|
-
// search state for unmounted components in place, so routing works.
|
|
7074
|
+
});
|
|
7201
7075
|
|
|
7076
|
+
// on initial render this will be empty, but React InstantSearch keeps
|
|
7077
|
+
// search state for unmounted components in place, so routing works.
|
|
7202
7078
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, attributesToRender.map(function (attribute) {
|
|
7203
7079
|
return /*#__PURE__*/React__default.createElement(React.Fragment, {
|
|
7204
7080
|
key: attribute
|
|
@@ -7207,7 +7083,6 @@
|
|
|
7207
7083
|
}));
|
|
7208
7084
|
}));
|
|
7209
7085
|
}
|
|
7210
|
-
|
|
7211
7086
|
var DynamicWidgets$1 = connectDynamicWidgets(DynamicWidgets, {
|
|
7212
7087
|
$$widgetType: 'ais.dynamicWidgets'
|
|
7213
7088
|
});
|
|
@@ -7217,36 +7092,27 @@
|
|
|
7217
7092
|
function escapeRuleContext(ruleName) {
|
|
7218
7093
|
return ruleName.replace(/[^a-z0-9-_]+/gi, '_');
|
|
7219
7094
|
}
|
|
7220
|
-
|
|
7221
7095
|
function getWidgetRefinements(attribute, widgetKey, searchState) {
|
|
7222
7096
|
var widgetState = searchState[widgetKey];
|
|
7223
|
-
|
|
7224
7097
|
switch (widgetKey) {
|
|
7225
7098
|
case 'range':
|
|
7226
7099
|
return Object.keys(widgetState[attribute]).map(function (rangeKey) {
|
|
7227
7100
|
return widgetState[attribute][rangeKey];
|
|
7228
7101
|
});
|
|
7229
|
-
|
|
7230
7102
|
case 'refinementList':
|
|
7231
7103
|
return widgetState[attribute];
|
|
7232
|
-
|
|
7233
7104
|
case 'hierarchicalMenu':
|
|
7234
7105
|
return [widgetState[attribute]];
|
|
7235
|
-
|
|
7236
7106
|
case 'menu':
|
|
7237
7107
|
return [widgetState[attribute]];
|
|
7238
|
-
|
|
7239
7108
|
case 'multiRange':
|
|
7240
7109
|
return widgetState[attribute].split(':');
|
|
7241
|
-
|
|
7242
7110
|
case 'toggle':
|
|
7243
7111
|
return [widgetState[attribute]];
|
|
7244
|
-
|
|
7245
7112
|
default:
|
|
7246
7113
|
return [];
|
|
7247
7114
|
}
|
|
7248
7115
|
}
|
|
7249
|
-
|
|
7250
7116
|
function getRefinements$1(attribute) {
|
|
7251
7117
|
var searchState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7252
7118
|
var refinements = Object.keys(searchState).filter(function (widgetKey) {
|
|
@@ -7259,10 +7125,9 @@
|
|
|
7259
7125
|
|
|
7260
7126
|
return refinements;
|
|
7261
7127
|
}
|
|
7262
|
-
|
|
7263
7128
|
function getRuleContextsFromTrackedFilters(_ref) {
|
|
7264
7129
|
var searchState = _ref.searchState,
|
|
7265
|
-
|
|
7130
|
+
trackedFilters = _ref.trackedFilters;
|
|
7266
7131
|
var ruleContexts = Object.keys(trackedFilters).reduce(function (facets, facetName) {
|
|
7267
7132
|
var facetRefinements = getRefinements$1(facetName, searchState);
|
|
7268
7133
|
var getTrackedFacetValues = trackedFilters[facetName];
|
|
@@ -7275,7 +7140,6 @@
|
|
|
7275
7140
|
}, []);
|
|
7276
7141
|
return ruleContexts;
|
|
7277
7142
|
}
|
|
7278
|
-
|
|
7279
7143
|
var defaultProps$1 = {
|
|
7280
7144
|
transformItems: function transformItems(items) {
|
|
7281
7145
|
return items;
|
|
@@ -7294,16 +7158,14 @@
|
|
|
7294
7158
|
ais: props.contextValue,
|
|
7295
7159
|
multiIndexContext: props.indexContextValue
|
|
7296
7160
|
});
|
|
7297
|
-
|
|
7298
7161
|
if (results === null) {
|
|
7299
7162
|
return {
|
|
7300
7163
|
items: [],
|
|
7301
7164
|
canRefine: false
|
|
7302
7165
|
};
|
|
7303
7166
|
}
|
|
7304
|
-
|
|
7305
7167
|
var _results$userData = results.userData,
|
|
7306
|
-
|
|
7168
|
+
userData = _results$userData === void 0 ? [] : _results$userData;
|
|
7307
7169
|
var transformItems = props.transformItems;
|
|
7308
7170
|
var transformedItems = transformItems(userData);
|
|
7309
7171
|
return {
|
|
@@ -7315,7 +7177,6 @@
|
|
|
7315
7177
|
if (Object.keys(props.trackedFilters).length === 0) {
|
|
7316
7178
|
return searchParameters;
|
|
7317
7179
|
}
|
|
7318
|
-
|
|
7319
7180
|
var indexSearchState = hasMultipleIndices({
|
|
7320
7181
|
ais: props.contextValue,
|
|
7321
7182
|
multiIndexContext: props.indexContextValue
|
|
@@ -7329,7 +7190,6 @@
|
|
|
7329
7190
|
});
|
|
7330
7191
|
var initialRuleContexts = searchParameters.ruleContexts || [];
|
|
7331
7192
|
var nextRuleContexts = [].concat(_toConsumableArray(initialRuleContexts), _toConsumableArray(newRuleContexts));
|
|
7332
|
-
|
|
7333
7193
|
var ruleContexts = props.transformRuleContexts(nextRuleContexts).slice(0, 10);
|
|
7334
7194
|
return searchParameters.setQueryParameter('ruleContexts', ruleContexts);
|
|
7335
7195
|
}
|
|
@@ -7341,16 +7201,11 @@
|
|
|
7341
7201
|
$$widgetType: 'ais.queryRuleContext'
|
|
7342
7202
|
});
|
|
7343
7203
|
|
|
7344
|
-
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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); }; }
|
|
7345
|
-
|
|
7346
|
-
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
7347
|
-
|
|
7348
7204
|
function getIndexContext(props) {
|
|
7349
7205
|
return {
|
|
7350
7206
|
targetedIndex: props.indexId
|
|
7351
7207
|
};
|
|
7352
7208
|
}
|
|
7353
|
-
|
|
7354
7209
|
/**
|
|
7355
7210
|
* The component that allows you to apply widgets to a dedicated index. It's
|
|
7356
7211
|
* useful if you want to build an interface that targets multiple indices.
|
|
@@ -7383,30 +7238,21 @@
|
|
|
7383
7238
|
*/
|
|
7384
7239
|
var Index = /*#__PURE__*/function (_Component) {
|
|
7385
7240
|
_inherits(Index, _Component);
|
|
7386
|
-
|
|
7387
|
-
var _super = _createSuper$2(Index);
|
|
7388
|
-
|
|
7241
|
+
var _super = _createSuper(Index);
|
|
7389
7242
|
function Index(props) {
|
|
7390
7243
|
var _this;
|
|
7391
|
-
|
|
7392
7244
|
_classCallCheck(this, Index);
|
|
7393
|
-
|
|
7394
7245
|
_this = _super.call(this, props);
|
|
7395
|
-
|
|
7396
7246
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
7397
7247
|
indexContext: getIndexContext(_this.props)
|
|
7398
7248
|
});
|
|
7399
|
-
|
|
7400
7249
|
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
7401
|
-
|
|
7402
7250
|
_this.props.contextValue.onSearchParameters(_this.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
7403
7251
|
ais: _this.props.contextValue,
|
|
7404
7252
|
multiIndexContext: _this.state.indexContext
|
|
7405
7253
|
}, _this.props, undefined, Index.displayName);
|
|
7406
|
-
|
|
7407
7254
|
return _this;
|
|
7408
7255
|
}
|
|
7409
|
-
|
|
7410
7256
|
_createClass(Index, [{
|
|
7411
7257
|
key: "componentDidMount",
|
|
7412
7258
|
value: function componentDidMount() {
|
|
@@ -7435,11 +7281,9 @@
|
|
|
7435
7281
|
key: "render",
|
|
7436
7282
|
value: function render() {
|
|
7437
7283
|
var childrenCount = React.Children.count(this.props.children);
|
|
7438
|
-
|
|
7439
7284
|
if (childrenCount === 0) {
|
|
7440
7285
|
return null;
|
|
7441
7286
|
}
|
|
7442
|
-
|
|
7443
7287
|
return /*#__PURE__*/React__default.createElement(IndexProvider, {
|
|
7444
7288
|
value: this.state.indexContext
|
|
7445
7289
|
}, this.props.children);
|
|
@@ -7452,16 +7296,11 @@
|
|
|
7452
7296
|
};
|
|
7453
7297
|
}
|
|
7454
7298
|
}]);
|
|
7455
|
-
|
|
7456
7299
|
return Index;
|
|
7457
7300
|
}(React.Component);
|
|
7458
|
-
|
|
7459
7301
|
_defineProperty(Index, "displayName", 'AlgoliaIndex');
|
|
7460
|
-
|
|
7461
7302
|
_defineProperty(Index, "$$type", 'ais.index');
|
|
7462
|
-
|
|
7463
7303
|
_defineProperty(Index, "$$widgetType", 'ais.index');
|
|
7464
|
-
|
|
7465
7304
|
var IndexWrapper = function IndexWrapper(props) {
|
|
7466
7305
|
var inferredIndexId = props.indexName;
|
|
7467
7306
|
return /*#__PURE__*/React__default.createElement(InstantSearchConsumer, null, function (contextValue) {
|
|
@@ -7473,23 +7312,22 @@
|
|
|
7473
7312
|
};
|
|
7474
7313
|
|
|
7475
7314
|
function createWidgetsManager(onWidgetsUpdate) {
|
|
7476
|
-
var widgets = [];
|
|
7315
|
+
var widgets = [];
|
|
7316
|
+
// Is an update scheduled?
|
|
7317
|
+
var scheduled = false;
|
|
7477
7318
|
|
|
7478
|
-
|
|
7319
|
+
// The state manager's updates need to be batched since more than one
|
|
7479
7320
|
// component can register or unregister widgets during the same tick.
|
|
7480
|
-
|
|
7481
7321
|
function scheduleUpdate() {
|
|
7482
7322
|
if (scheduled) {
|
|
7483
7323
|
return;
|
|
7484
7324
|
}
|
|
7485
|
-
|
|
7486
7325
|
scheduled = true;
|
|
7487
7326
|
defer(function () {
|
|
7488
7327
|
scheduled = false;
|
|
7489
7328
|
onWidgetsUpdate();
|
|
7490
7329
|
});
|
|
7491
7330
|
}
|
|
7492
|
-
|
|
7493
7331
|
return {
|
|
7494
7332
|
registerWidget: function registerWidget(widget) {
|
|
7495
7333
|
widgets.push(widget);
|
|
@@ -7529,79 +7367,65 @@
|
|
|
7529
7367
|
}
|
|
7530
7368
|
|
|
7531
7369
|
var _excluded$2 = ["resultsFacetValues"],
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
function ownKeys$5(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; }
|
|
7536
|
-
|
|
7537
|
-
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7538
|
-
|
|
7370
|
+
_excluded2$1 = ["resultsFacetValues"],
|
|
7371
|
+
_excluded3 = ["resultsFacetValues"];
|
|
7539
7372
|
function addAlgoliaAgents(searchClient) {
|
|
7540
7373
|
if (typeof searchClient.addAlgoliaAgent === 'function') {
|
|
7541
7374
|
searchClient.addAlgoliaAgent("react (".concat(React.version, ")"));
|
|
7542
7375
|
searchClient.addAlgoliaAgent("react-instantsearch (".concat(version, ")"));
|
|
7543
7376
|
}
|
|
7544
7377
|
}
|
|
7545
|
-
|
|
7546
7378
|
var isMultiIndexContext = function isMultiIndexContext(widget) {
|
|
7547
7379
|
return hasMultipleIndices({
|
|
7548
7380
|
ais: widget.props.contextValue,
|
|
7549
7381
|
multiIndexContext: widget.props.indexContextValue
|
|
7550
7382
|
});
|
|
7551
7383
|
};
|
|
7552
|
-
|
|
7553
7384
|
var isTargetedIndexEqualIndex = function isTargetedIndexEqualIndex(widget, indexId) {
|
|
7554
7385
|
return widget.props.indexContextValue.targetedIndex === indexId;
|
|
7555
|
-
};
|
|
7386
|
+
};
|
|
7387
|
+
|
|
7388
|
+
// Relying on the `indexId` is a bit brittle to detect the `Index` widget.
|
|
7556
7389
|
// Since it's a class we could rely on `instanceof` or similar. We never
|
|
7557
7390
|
// had an issue though. Works for now.
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
7391
|
var isIndexWidget = function isIndexWidget(widget) {
|
|
7561
7392
|
return Boolean(widget.props.indexId);
|
|
7562
7393
|
};
|
|
7563
|
-
|
|
7564
7394
|
var isIndexWidgetEqualIndex = function isIndexWidgetEqualIndex(widget, indexId) {
|
|
7565
7395
|
return widget.props.indexId === indexId;
|
|
7566
7396
|
};
|
|
7567
|
-
|
|
7568
7397
|
var sortIndexWidgetsFirst = function sortIndexWidgetsFirst(firstWidget, secondWidget) {
|
|
7569
7398
|
var isFirstWidgetIndex = isIndexWidget(firstWidget);
|
|
7570
7399
|
var isSecondWidgetIndex = isIndexWidget(secondWidget);
|
|
7571
|
-
|
|
7572
7400
|
if (isFirstWidgetIndex && !isSecondWidgetIndex) {
|
|
7573
7401
|
return -1;
|
|
7574
7402
|
}
|
|
7575
|
-
|
|
7576
7403
|
if (!isFirstWidgetIndex && isSecondWidgetIndex) {
|
|
7577
7404
|
return 1;
|
|
7578
7405
|
}
|
|
7579
|
-
|
|
7580
7406
|
return 0;
|
|
7581
|
-
};
|
|
7582
|
-
// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
|
|
7583
|
-
|
|
7407
|
+
};
|
|
7584
7408
|
|
|
7409
|
+
// This function is copied from the algoliasearch v4 API Client. If modified,
|
|
7410
|
+
// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
|
|
7585
7411
|
function serializeQueryParameters(parameters) {
|
|
7586
7412
|
var isObjectOrArray = function isObjectOrArray(value) {
|
|
7587
7413
|
return Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
7588
7414
|
};
|
|
7589
|
-
|
|
7590
7415
|
var encode = function encode(format) {
|
|
7591
7416
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
7592
7417
|
args[_key - 1] = arguments[_key];
|
|
7593
7418
|
}
|
|
7594
|
-
|
|
7595
7419
|
var i = 0;
|
|
7596
7420
|
return format.replace(/%s/g, function () {
|
|
7597
7421
|
return encodeURIComponent(args[i++]);
|
|
7598
7422
|
});
|
|
7599
7423
|
};
|
|
7600
|
-
|
|
7601
7424
|
return Object.keys(parameters).map(function (key) {
|
|
7602
7425
|
return encode('%s=%s', key, isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]);
|
|
7603
7426
|
}).join('&');
|
|
7604
7427
|
}
|
|
7428
|
+
|
|
7605
7429
|
/**
|
|
7606
7430
|
* Creates a new instance of the InstantSearchManager which controls the widgets and
|
|
7607
7431
|
* trigger the search when the widgets are updated.
|
|
@@ -7611,16 +7435,14 @@
|
|
|
7611
7435
|
* @param {number} stalledSearchDelay - time (in ms) after the search is stalled
|
|
7612
7436
|
* @return {InstantSearchManager} a new instance of InstantSearchManager
|
|
7613
7437
|
*/
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
7438
|
function createInstantSearchManager(_ref) {
|
|
7617
7439
|
var indexName = _ref.indexName,
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
var helper = algoliasearchHelper_1(searchClient, indexName,
|
|
7440
|
+
_ref$initialState = _ref.initialState,
|
|
7441
|
+
initialState = _ref$initialState === void 0 ? {} : _ref$initialState,
|
|
7442
|
+
searchClient = _ref.searchClient,
|
|
7443
|
+
resultsState = _ref.resultsState,
|
|
7444
|
+
stalledSearchDelay = _ref.stalledSearchDelay;
|
|
7445
|
+
var helper = algoliasearchHelper_1(searchClient, indexName, _objectSpread2({}, HIGHLIGHT_TAGS));
|
|
7624
7446
|
addAlgoliaAgents(searchClient);
|
|
7625
7447
|
helper.on('search', handleNewSearch).on('result', handleSearchSuccess({
|
|
7626
7448
|
indexId: indexName
|
|
@@ -7640,22 +7462,18 @@
|
|
|
7640
7462
|
isSearchStalled: true,
|
|
7641
7463
|
searchingForFacetValues: false
|
|
7642
7464
|
});
|
|
7643
|
-
|
|
7644
7465
|
function skipSearch() {
|
|
7645
7466
|
skip = true;
|
|
7646
7467
|
}
|
|
7647
|
-
|
|
7648
7468
|
function updateClient(client) {
|
|
7649
7469
|
addAlgoliaAgents(client);
|
|
7650
7470
|
helper.setClient(client);
|
|
7651
7471
|
search();
|
|
7652
7472
|
}
|
|
7653
|
-
|
|
7654
7473
|
function clearCache() {
|
|
7655
7474
|
helper.clearCache();
|
|
7656
7475
|
search();
|
|
7657
7476
|
}
|
|
7658
|
-
|
|
7659
7477
|
function getMetadata(state) {
|
|
7660
7478
|
return widgetsManager.getWidgets().filter(function (widget) {
|
|
7661
7479
|
return Boolean(widget.getMetadata);
|
|
@@ -7663,7 +7481,6 @@
|
|
|
7663
7481
|
return widget.getMetadata(state);
|
|
7664
7482
|
});
|
|
7665
7483
|
}
|
|
7666
|
-
|
|
7667
7484
|
function getSearchParameters() {
|
|
7668
7485
|
var sharedParameters = widgetsManager.getWidgets().filter(function (widget) {
|
|
7669
7486
|
return Boolean(widget.getSearchParameters);
|
|
@@ -7678,7 +7495,8 @@
|
|
|
7678
7495
|
var targetedIndexEqualMainIndex = isMultiIndexContext(widget) && isTargetedIndexEqualIndex(widget, indexName);
|
|
7679
7496
|
var subIndexEqualMainIndex = isIndexWidget(widget) && isIndexWidgetEqualIndex(widget, indexName);
|
|
7680
7497
|
return targetedIndexEqualMainIndex || subIndexEqualMainIndex;
|
|
7681
|
-
})
|
|
7498
|
+
})
|
|
7499
|
+
// We have to sort the `Index` widgets first so the `index` parameter
|
|
7682
7500
|
// is correctly set in the `reduce` function for the following widgets
|
|
7683
7501
|
.sort(sortIndexWidgetsFirst).reduce(function (res, widget) {
|
|
7684
7502
|
return widget.getSearchParameters(res);
|
|
@@ -7689,12 +7507,13 @@
|
|
|
7689
7507
|
var targetedIndexNotEqualMainIndex = isMultiIndexContext(widget) && !isTargetedIndexEqualIndex(widget, indexName);
|
|
7690
7508
|
var subIndexNotEqualMainIndex = isIndexWidget(widget) && !isIndexWidgetEqualIndex(widget, indexName);
|
|
7691
7509
|
return targetedIndexNotEqualMainIndex || subIndexNotEqualMainIndex;
|
|
7692
|
-
})
|
|
7510
|
+
})
|
|
7511
|
+
// We have to sort the `Index` widgets first so the `index` parameter
|
|
7693
7512
|
// is correctly set in the `reduce` function for the following widgets
|
|
7694
7513
|
.sort(sortIndexWidgetsFirst).reduce(function (indices, widget) {
|
|
7695
7514
|
var indexId = isMultiIndexContext(widget) ? widget.props.indexContextValue.targetedIndex : widget.props.indexId;
|
|
7696
7515
|
var widgets = indices[indexId] || [];
|
|
7697
|
-
return
|
|
7516
|
+
return _objectSpread2(_objectSpread2({}, indices), {}, _defineProperty({}, indexId, widgets.concat(widget)));
|
|
7698
7517
|
}, {});
|
|
7699
7518
|
var derivedParameters = Object.keys(derivedIndices).map(function (indexId) {
|
|
7700
7519
|
return {
|
|
@@ -7709,18 +7528,17 @@
|
|
|
7709
7528
|
derivedParameters: derivedParameters
|
|
7710
7529
|
};
|
|
7711
7530
|
}
|
|
7712
|
-
|
|
7713
7531
|
function search() {
|
|
7714
7532
|
if (!skip) {
|
|
7715
7533
|
var _getSearchParameters = getSearchParameters(),
|
|
7716
|
-
|
|
7717
|
-
|
|
7534
|
+
mainParameters = _getSearchParameters.mainParameters,
|
|
7535
|
+
derivedParameters = _getSearchParameters.derivedParameters;
|
|
7536
|
+
searchCounter = derivedParameters.length + 1;
|
|
7718
7537
|
|
|
7719
|
-
|
|
7538
|
+
// We have to call `slice` because the method `detach` on the derived
|
|
7720
7539
|
// helpers mutates the value `derivedHelpers`. The `forEach` loop does
|
|
7721
7540
|
// not iterate on each value and we're not able to correctly clear the
|
|
7722
7541
|
// previous derived helpers (memory leak + useless requests).
|
|
7723
|
-
|
|
7724
7542
|
helper.derivedHelpers.slice().forEach(function (derivedHelper) {
|
|
7725
7543
|
// Since we detach the derived helpers on **every** new search they
|
|
7726
7544
|
// won't receive intermediate results in case of a stalled search.
|
|
@@ -7740,7 +7558,7 @@
|
|
|
7740
7558
|
});
|
|
7741
7559
|
derivedParameters.forEach(function (_ref2) {
|
|
7742
7560
|
var indexId = _ref2.indexId,
|
|
7743
|
-
|
|
7561
|
+
parameters = _ref2.parameters;
|
|
7744
7562
|
var derivedHelper = helper.derive(function () {
|
|
7745
7563
|
return parameters;
|
|
7746
7564
|
});
|
|
@@ -7752,38 +7570,33 @@
|
|
|
7752
7570
|
helper.search();
|
|
7753
7571
|
}
|
|
7754
7572
|
}
|
|
7755
|
-
|
|
7756
7573
|
function handleSearchSuccess(_ref3) {
|
|
7757
7574
|
var indexId = _ref3.indexId;
|
|
7758
7575
|
return function (event) {
|
|
7759
7576
|
searchCounter--;
|
|
7760
7577
|
var state = store.getState();
|
|
7761
7578
|
var isDerivedHelpersEmpty = !helper.derivedHelpers.length;
|
|
7762
|
-
var results = state.results ? state.results : {};
|
|
7579
|
+
var results = state.results ? state.results : {};
|
|
7580
|
+
|
|
7581
|
+
// Switching from mono index to multi index and vice versa must reset the
|
|
7763
7582
|
// results to an empty object, otherwise we keep reference of stalled and
|
|
7764
7583
|
// unused results.
|
|
7765
|
-
|
|
7766
7584
|
results = !isDerivedHelpersEmpty && results.getFacetByName ? {} : results;
|
|
7767
|
-
|
|
7768
7585
|
if (!isDerivedHelpersEmpty) {
|
|
7769
|
-
results =
|
|
7586
|
+
results = _objectSpread2(_objectSpread2({}, results), {}, _defineProperty({}, indexId, event.results));
|
|
7770
7587
|
} else {
|
|
7771
7588
|
results = event.results;
|
|
7772
7589
|
}
|
|
7773
|
-
|
|
7774
7590
|
var currentState = store.getState();
|
|
7775
7591
|
var nextIsSearchStalled = currentState.isSearchStalled;
|
|
7776
|
-
|
|
7777
7592
|
if (!helper.hasPendingRequests()) {
|
|
7778
7593
|
clearTimeout(stalledSearchTimer);
|
|
7779
7594
|
stalledSearchTimer = null;
|
|
7780
7595
|
nextIsSearchStalled = false;
|
|
7781
7596
|
}
|
|
7782
|
-
|
|
7783
7597
|
var resultsFacetValues = currentState.resultsFacetValues,
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7598
|
+
partialState = _objectWithoutProperties(currentState, _excluded$2);
|
|
7599
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7787
7600
|
results: results,
|
|
7788
7601
|
isSearchStalled: nextIsSearchStalled,
|
|
7789
7602
|
searching: searchCounter > 0,
|
|
@@ -7791,71 +7604,63 @@
|
|
|
7791
7604
|
}));
|
|
7792
7605
|
};
|
|
7793
7606
|
}
|
|
7794
|
-
|
|
7795
7607
|
function handleSearchError(_ref4) {
|
|
7796
7608
|
var error = _ref4.error;
|
|
7797
7609
|
var currentState = store.getState();
|
|
7798
7610
|
var nextIsSearchStalled = currentState.isSearchStalled;
|
|
7799
|
-
|
|
7800
7611
|
if (!helper.hasPendingRequests()) {
|
|
7801
7612
|
clearTimeout(stalledSearchTimer);
|
|
7802
7613
|
nextIsSearchStalled = false;
|
|
7803
7614
|
}
|
|
7804
|
-
|
|
7805
7615
|
var resultsFacetValues = currentState.resultsFacetValues,
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7616
|
+
partialState = _objectWithoutProperties(currentState, _excluded2$1);
|
|
7617
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7809
7618
|
isSearchStalled: nextIsSearchStalled,
|
|
7810
7619
|
error: error,
|
|
7811
7620
|
searching: false
|
|
7812
7621
|
}));
|
|
7813
7622
|
}
|
|
7814
|
-
|
|
7815
7623
|
function handleNewSearch() {
|
|
7816
7624
|
if (!stalledSearchTimer) {
|
|
7817
7625
|
stalledSearchTimer = setTimeout(function () {
|
|
7818
7626
|
var _store$getState = store.getState(),
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7627
|
+
resultsFacetValues = _store$getState.resultsFacetValues,
|
|
7628
|
+
partialState = _objectWithoutProperties(_store$getState, _excluded3);
|
|
7629
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7823
7630
|
isSearchStalled: true
|
|
7824
7631
|
}));
|
|
7825
7632
|
}, stalledSearchDelay);
|
|
7826
7633
|
}
|
|
7827
7634
|
}
|
|
7828
|
-
|
|
7829
7635
|
function hydrateSearchClient(client, results) {
|
|
7830
7636
|
if (!results) {
|
|
7831
7637
|
return;
|
|
7832
|
-
}
|
|
7638
|
+
}
|
|
7639
|
+
|
|
7640
|
+
// Disable cache hydration on:
|
|
7833
7641
|
// - Algoliasearch API Client < v4 with cache disabled
|
|
7834
7642
|
// - Third party clients (detected by the `addAlgoliaAgent` function missing)
|
|
7835
7643
|
|
|
7836
|
-
|
|
7837
7644
|
if ((!client.transporter || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
|
|
7838
7645
|
return;
|
|
7839
|
-
}
|
|
7646
|
+
}
|
|
7647
|
+
|
|
7648
|
+
// Algoliasearch API Client >= v4
|
|
7840
7649
|
// To hydrate the client we need to populate the cache with the data from
|
|
7841
7650
|
// the server (done in `hydrateSearchClientWithMultiIndexRequest` or
|
|
7842
7651
|
// `hydrateSearchClientWithSingleIndexRequest`). But since there is no way
|
|
7843
7652
|
// for us to compute the key the same way as `algoliasearch-client` we need
|
|
7844
7653
|
// to populate it on a custom key and override the `search` method to
|
|
7845
7654
|
// search on it first.
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
7655
|
if (client.transporter && !client._cacheHydrated) {
|
|
7849
7656
|
client._cacheHydrated = true;
|
|
7850
7657
|
var baseMethod = client.search;
|
|
7851
|
-
|
|
7852
7658
|
client.search = function (requests) {
|
|
7853
7659
|
for (var _len2 = arguments.length, methodArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
7854
7660
|
methodArgs[_key2 - 1] = arguments[_key2];
|
|
7855
7661
|
}
|
|
7856
|
-
|
|
7857
7662
|
var requestsWithSerializedParams = requests.map(function (request) {
|
|
7858
|
-
return
|
|
7663
|
+
return _objectSpread2(_objectSpread2({}, request), {}, {
|
|
7859
7664
|
params: serializeQueryParameters(request.params)
|
|
7860
7665
|
});
|
|
7861
7666
|
});
|
|
@@ -7867,15 +7672,12 @@
|
|
|
7867
7672
|
});
|
|
7868
7673
|
};
|
|
7869
7674
|
}
|
|
7870
|
-
|
|
7871
7675
|
if (Array.isArray(results.results)) {
|
|
7872
7676
|
hydrateSearchClientWithMultiIndexRequest(client, results.results);
|
|
7873
7677
|
return;
|
|
7874
7678
|
}
|
|
7875
|
-
|
|
7876
7679
|
hydrateSearchClientWithSingleIndexRequest(client, results);
|
|
7877
7680
|
}
|
|
7878
|
-
|
|
7879
7681
|
function hydrateSearchClientWithMultiIndexRequest(client, results) {
|
|
7880
7682
|
// Algoliasearch API Client >= v4
|
|
7881
7683
|
// Populate the cache with the data from the server
|
|
@@ -7896,14 +7698,14 @@
|
|
|
7896
7698
|
}, [])
|
|
7897
7699
|
});
|
|
7898
7700
|
return;
|
|
7899
|
-
}
|
|
7701
|
+
}
|
|
7702
|
+
|
|
7703
|
+
// Algoliasearch API Client < v4
|
|
7900
7704
|
// Prior to client v4 we didn't have a proper API to hydrate the client
|
|
7901
7705
|
// cache from the outside. The following code populates the cache with
|
|
7902
7706
|
// a single-index result. You can find more information about the
|
|
7903
7707
|
// computation of the key inside the client (see link below).
|
|
7904
7708
|
// https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
7709
|
var key = "/1/indexes/*/queries_body_".concat(JSON.stringify({
|
|
7908
7710
|
requests: results.reduce(function (acc, result) {
|
|
7909
7711
|
return acc.concat(result.rawResults.map(function (request) {
|
|
@@ -7914,13 +7716,12 @@
|
|
|
7914
7716
|
}));
|
|
7915
7717
|
}, [])
|
|
7916
7718
|
}));
|
|
7917
|
-
client.cache =
|
|
7719
|
+
client.cache = _objectSpread2(_objectSpread2({}, client.cache), {}, _defineProperty({}, key, JSON.stringify({
|
|
7918
7720
|
results: results.reduce(function (acc, result) {
|
|
7919
7721
|
return acc.concat(result.rawResults);
|
|
7920
7722
|
}, [])
|
|
7921
7723
|
})));
|
|
7922
7724
|
}
|
|
7923
|
-
|
|
7924
7725
|
function hydrateSearchClientWithSingleIndexRequest(client, results) {
|
|
7925
7726
|
// Algoliasearch API Client >= v4
|
|
7926
7727
|
// Populate the cache with the data from the server
|
|
@@ -7937,14 +7738,13 @@
|
|
|
7937
7738
|
results: results.rawResults
|
|
7938
7739
|
});
|
|
7939
7740
|
return;
|
|
7940
|
-
}
|
|
7741
|
+
}
|
|
7742
|
+
// Algoliasearch API Client < v4
|
|
7941
7743
|
// Prior to client v4 we didn't have a proper API to hydrate the client
|
|
7942
7744
|
// cache from the outside. The following code populates the cache with
|
|
7943
7745
|
// a single-index result. You can find more information about the
|
|
7944
7746
|
// computation of the key inside the client (see link below).
|
|
7945
7747
|
// https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
7748
|
var key = "/1/indexes/*/queries_body_".concat(JSON.stringify({
|
|
7949
7749
|
requests: results.rawResults.map(function (request) {
|
|
7950
7750
|
return {
|
|
@@ -7953,37 +7753,34 @@
|
|
|
7953
7753
|
};
|
|
7954
7754
|
})
|
|
7955
7755
|
}));
|
|
7956
|
-
client.cache =
|
|
7756
|
+
client.cache = _objectSpread2(_objectSpread2({}, client.cache), {}, _defineProperty({}, key, JSON.stringify({
|
|
7957
7757
|
results: results.rawResults
|
|
7958
7758
|
})));
|
|
7959
7759
|
}
|
|
7960
|
-
|
|
7961
7760
|
function hydrateResultsState(results) {
|
|
7962
7761
|
if (!results) {
|
|
7963
7762
|
return null;
|
|
7964
7763
|
}
|
|
7965
|
-
|
|
7966
7764
|
if (Array.isArray(results.results)) {
|
|
7967
7765
|
return results.results.reduce(function (acc, result) {
|
|
7968
|
-
return
|
|
7766
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, result._internalIndexId, new algoliasearchHelper_1.SearchResults(new algoliasearchHelper_1.SearchParameters(result.state), result.rawResults)));
|
|
7969
7767
|
}, {});
|
|
7970
7768
|
}
|
|
7971
|
-
|
|
7972
7769
|
return new algoliasearchHelper_1.SearchResults(new algoliasearchHelper_1.SearchParameters(results.state), results.rawResults);
|
|
7973
|
-
}
|
|
7974
|
-
|
|
7770
|
+
}
|
|
7975
7771
|
|
|
7772
|
+
// Called whenever a widget has been rendered with new props.
|
|
7976
7773
|
function onWidgetsUpdate() {
|
|
7977
7774
|
var metadata = getMetadata(store.getState().widgets);
|
|
7978
|
-
store.setState(
|
|
7775
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
7979
7776
|
metadata: metadata,
|
|
7980
7777
|
searching: true
|
|
7981
|
-
}));
|
|
7982
|
-
// the result search parameters might have changed.
|
|
7778
|
+
}));
|
|
7983
7779
|
|
|
7780
|
+
// Since the `getSearchParameters` method of widgets also depends on props,
|
|
7781
|
+
// the result search parameters might have changed.
|
|
7984
7782
|
search();
|
|
7985
7783
|
}
|
|
7986
|
-
|
|
7987
7784
|
function transitionState(nextSearchState) {
|
|
7988
7785
|
var searchState = store.getState().widgets;
|
|
7989
7786
|
return widgetsManager.getWidgets().filter(function (widget) {
|
|
@@ -7992,38 +7789,35 @@
|
|
|
7992
7789
|
return widget.transitionState(searchState, res);
|
|
7993
7790
|
}, nextSearchState);
|
|
7994
7791
|
}
|
|
7995
|
-
|
|
7996
7792
|
function onExternalStateUpdate(nextSearchState) {
|
|
7997
7793
|
var metadata = getMetadata(nextSearchState);
|
|
7998
|
-
store.setState(
|
|
7794
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
7999
7795
|
widgets: nextSearchState,
|
|
8000
7796
|
metadata: metadata,
|
|
8001
7797
|
searching: true
|
|
8002
7798
|
}));
|
|
8003
7799
|
search();
|
|
8004
7800
|
}
|
|
8005
|
-
|
|
8006
7801
|
function onSearchForFacetValues(_ref5) {
|
|
8007
7802
|
var facetName = _ref5.facetName,
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
7803
|
+
query = _ref5.query,
|
|
7804
|
+
_ref5$maxFacetHits = _ref5.maxFacetHits,
|
|
7805
|
+
maxFacetHits = _ref5$maxFacetHits === void 0 ? 10 : _ref5$maxFacetHits;
|
|
8011
7806
|
// The values 1, 100 are the min / max values that the engine accepts.
|
|
8012
7807
|
// see: https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits
|
|
8013
7808
|
var maxFacetHitsWithinRange = Math.max(1, Math.min(maxFacetHits, 100));
|
|
8014
|
-
store.setState(
|
|
7809
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8015
7810
|
searchingForFacetValues: true
|
|
8016
7811
|
}));
|
|
8017
7812
|
helper.searchForFacetValues(facetName, query, maxFacetHitsWithinRange).then(function (content) {
|
|
8018
7813
|
var _objectSpread7;
|
|
8019
|
-
|
|
8020
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, store.getState()), {}, {
|
|
7814
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8021
7815
|
error: null,
|
|
8022
7816
|
searchingForFacetValues: false,
|
|
8023
|
-
resultsFacetValues:
|
|
7817
|
+
resultsFacetValues: _objectSpread2(_objectSpread2({}, store.getState().resultsFacetValues), {}, (_objectSpread7 = {}, _defineProperty(_objectSpread7, facetName, content.facetHits), _defineProperty(_objectSpread7, "query", query), _objectSpread7))
|
|
8024
7818
|
}));
|
|
8025
7819
|
}, function (error) {
|
|
8026
|
-
store.setState(
|
|
7820
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8027
7821
|
searchingForFacetValues: false,
|
|
8028
7822
|
error: error
|
|
8029
7823
|
}));
|
|
@@ -8037,9 +7831,9 @@
|
|
|
8037
7831
|
});
|
|
8038
7832
|
});
|
|
8039
7833
|
}
|
|
8040
|
-
|
|
8041
7834
|
function updateIndex(newIndex) {
|
|
8042
|
-
initialSearchParameters = initialSearchParameters.setIndex(newIndex);
|
|
7835
|
+
initialSearchParameters = initialSearchParameters.setIndex(newIndex);
|
|
7836
|
+
// No need to trigger a new search here as the widgets will also update and trigger it if needed.
|
|
8043
7837
|
}
|
|
8044
7838
|
|
|
8045
7839
|
function getWidgetsIds() {
|
|
@@ -8047,7 +7841,6 @@
|
|
|
8047
7841
|
return typeof meta.id !== 'undefined' ? res.concat(meta.id) : res;
|
|
8048
7842
|
}, []);
|
|
8049
7843
|
}
|
|
8050
|
-
|
|
8051
7844
|
return {
|
|
8052
7845
|
store: store,
|
|
8053
7846
|
widgetsManager: widgetsManager,
|
|
@@ -8062,27 +7855,26 @@
|
|
|
8062
7855
|
skipSearch: skipSearch
|
|
8063
7856
|
};
|
|
8064
7857
|
}
|
|
8065
|
-
|
|
8066
7858
|
function hydrateMetadata(resultsState) {
|
|
8067
7859
|
if (!resultsState) {
|
|
8068
7860
|
return [];
|
|
8069
|
-
}
|
|
8070
|
-
|
|
7861
|
+
}
|
|
8071
7862
|
|
|
7863
|
+
// add a value noop, which gets replaced once the widgets are mounted
|
|
8072
7864
|
return resultsState.metadata.map(function (datum) {
|
|
8073
|
-
return
|
|
7865
|
+
return _objectSpread2(_objectSpread2({
|
|
8074
7866
|
value: function value() {
|
|
8075
7867
|
return {};
|
|
8076
7868
|
}
|
|
8077
7869
|
}, datum), {}, {
|
|
8078
7870
|
items: datum.items && datum.items.map(function (item) {
|
|
8079
|
-
return
|
|
7871
|
+
return _objectSpread2(_objectSpread2({
|
|
8080
7872
|
value: function value() {
|
|
8081
7873
|
return {};
|
|
8082
7874
|
}
|
|
8083
7875
|
}, item), {}, {
|
|
8084
7876
|
items: item.items && item.items.map(function (nestedItem) {
|
|
8085
|
-
return
|
|
7877
|
+
return _objectSpread2({
|
|
8086
7878
|
value: function value() {
|
|
8087
7879
|
return {};
|
|
8088
7880
|
}
|
|
@@ -8101,14 +7893,12 @@
|
|
|
8101
7893
|
var internalProps = ['contextValue', 'indexContextValue'];
|
|
8102
7894
|
var widgetsPayload = widgets.map(function (_ref) {
|
|
8103
7895
|
var props = _ref.props,
|
|
8104
|
-
|
|
8105
|
-
|
|
7896
|
+
constructor = _ref.constructor;
|
|
8106
7897
|
var _ref2 = constructor._connectorDesc || {},
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
7898
|
+
_ref2$defaultProps = _ref2.defaultProps,
|
|
7899
|
+
defaultProps = _ref2$defaultProps === void 0 ? {} : _ref2$defaultProps,
|
|
7900
|
+
_ref2$displayName = _ref2.displayName,
|
|
7901
|
+
displayName = _ref2$displayName === void 0 ? constructor.displayName : _ref2$displayName;
|
|
8112
7902
|
return {
|
|
8113
7903
|
displayName: displayName,
|
|
8114
7904
|
$$type: constructor.$$type,
|
|
@@ -8134,17 +7924,10 @@
|
|
|
8134
7924
|
refNode.appendChild(payloadContainer);
|
|
8135
7925
|
}
|
|
8136
7926
|
|
|
8137
|
-
function ownKeys$6(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; }
|
|
8138
|
-
|
|
8139
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8140
|
-
|
|
8141
|
-
function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); 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); }; }
|
|
8142
|
-
|
|
8143
|
-
function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8144
|
-
|
|
8145
7927
|
function isControlled(props) {
|
|
8146
7928
|
return Boolean(props.searchState);
|
|
8147
7929
|
}
|
|
7930
|
+
|
|
8148
7931
|
/**
|
|
8149
7932
|
* @description
|
|
8150
7933
|
* `<InstantSearch>` is the root component of all React InstantSearch implementations.
|
|
@@ -8183,24 +7966,15 @@
|
|
|
8183
7966
|
* </InstantSearch>
|
|
8184
7967
|
* );
|
|
8185
7968
|
*/
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
7969
|
var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
8189
7970
|
_inherits(InstantSearch, _Component);
|
|
8190
|
-
|
|
8191
|
-
var _super = _createSuper$3(InstantSearch);
|
|
8192
|
-
|
|
7971
|
+
var _super = _createSuper(InstantSearch);
|
|
8193
7972
|
function InstantSearch(props) {
|
|
8194
7973
|
var _this;
|
|
8195
|
-
|
|
8196
7974
|
_classCallCheck(this, InstantSearch);
|
|
8197
|
-
|
|
8198
7975
|
_this = _super.call(this, props);
|
|
8199
|
-
|
|
8200
7976
|
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
8201
|
-
|
|
8202
7977
|
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
8203
|
-
|
|
8204
7978
|
var instantSearchManager = createInstantSearchManager({
|
|
8205
7979
|
indexName: _this.props.indexName,
|
|
8206
7980
|
searchClient: _this.props.searchClient,
|
|
@@ -8225,28 +7999,22 @@
|
|
|
8225
7999
|
};
|
|
8226
8000
|
return _this;
|
|
8227
8001
|
}
|
|
8228
|
-
|
|
8229
8002
|
_createClass(InstantSearch, [{
|
|
8230
8003
|
key: "componentDidUpdate",
|
|
8231
8004
|
value: function componentDidUpdate(prevProps) {
|
|
8232
8005
|
var prevIsControlled = isControlled(prevProps);
|
|
8233
|
-
|
|
8234
8006
|
if (prevIsControlled && !this.state.isControlled) {
|
|
8235
8007
|
throw new Error("You can't switch <InstantSearch> from being controlled to uncontrolled");
|
|
8236
8008
|
}
|
|
8237
|
-
|
|
8238
8009
|
if (!prevIsControlled && this.state.isControlled) {
|
|
8239
8010
|
throw new Error("You can't switch <InstantSearch> from being uncontrolled to controlled");
|
|
8240
8011
|
}
|
|
8241
|
-
|
|
8242
8012
|
if (this.props.refresh !== prevProps.refresh && this.props.refresh) {
|
|
8243
8013
|
this.state.instantSearchManager.clearCache();
|
|
8244
8014
|
}
|
|
8245
|
-
|
|
8246
8015
|
if (prevProps.indexName !== this.props.indexName) {
|
|
8247
8016
|
this.state.instantSearchManager.updateIndex(this.props.indexName);
|
|
8248
8017
|
}
|
|
8249
|
-
|
|
8250
8018
|
if (prevProps.searchClient !== this.props.searchClient) {
|
|
8251
8019
|
this.state.instantSearchManager.updateClient(this.props.searchClient);
|
|
8252
8020
|
}
|
|
@@ -8258,7 +8026,6 @@
|
|
|
8258
8026
|
clearTimeout(this.cleanupTimerRef);
|
|
8259
8027
|
this.cleanupTimerRef = null;
|
|
8260
8028
|
}
|
|
8261
|
-
|
|
8262
8029
|
if (isMetadataEnabled()) {
|
|
8263
8030
|
injectMetadata(this.state.instantSearchManager.widgetsManager.getWidgets(), this.props.searchClient);
|
|
8264
8031
|
}
|
|
@@ -8267,10 +8034,8 @@
|
|
|
8267
8034
|
key: "componentWillUnmount",
|
|
8268
8035
|
value: function componentWillUnmount() {
|
|
8269
8036
|
var _this2 = this;
|
|
8270
|
-
|
|
8271
8037
|
this.cleanupTimerRef = setTimeout(function () {
|
|
8272
8038
|
_this2.isUnmounting = true;
|
|
8273
|
-
|
|
8274
8039
|
_this2.state.instantSearchManager.skipSearch();
|
|
8275
8040
|
});
|
|
8276
8041
|
}
|
|
@@ -8285,7 +8050,6 @@
|
|
|
8285
8050
|
value: function onWidgetsInternalStateUpdate(searchState) {
|
|
8286
8051
|
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
8287
8052
|
this.onSearchStateChange(searchState);
|
|
8288
|
-
|
|
8289
8053
|
if (!this.state.isControlled) {
|
|
8290
8054
|
this.state.instantSearchManager.onExternalStateUpdate(searchState);
|
|
8291
8055
|
}
|
|
@@ -8302,13 +8066,10 @@
|
|
|
8302
8066
|
value: function onSearchParameters(getSearchParameters, context, props, getMetadata, displayName) {
|
|
8303
8067
|
if (this.props.onSearchParameters) {
|
|
8304
8068
|
var _searchState = this.props.searchState ? this.props.searchState : {};
|
|
8305
|
-
|
|
8306
8069
|
this.props.onSearchParameters(getSearchParameters, context, props, _searchState);
|
|
8307
8070
|
}
|
|
8308
|
-
|
|
8309
8071
|
if (this.props.widgetsCollector) {
|
|
8310
8072
|
var _searchState2 = this.props.searchState ? this.props.searchState : {};
|
|
8311
|
-
|
|
8312
8073
|
this.props.widgetsCollector({
|
|
8313
8074
|
getSearchParameters: getSearchParameters,
|
|
8314
8075
|
getMetadata: getMetadata,
|
|
@@ -8335,7 +8096,6 @@
|
|
|
8335
8096
|
if (React.Children.count(this.props.children) === 0) {
|
|
8336
8097
|
return null;
|
|
8337
8098
|
}
|
|
8338
|
-
|
|
8339
8099
|
return /*#__PURE__*/React__default.createElement(InstantSearchProvider, {
|
|
8340
8100
|
value: this.state.contextValue
|
|
8341
8101
|
}, this.props.children);
|
|
@@ -8346,23 +8106,19 @@
|
|
|
8346
8106
|
var nextIsControlled = isControlled(nextProps);
|
|
8347
8107
|
var previousSearchState = prevState.instantSearchManager.store.getState().widgets;
|
|
8348
8108
|
var nextSearchState = nextProps.searchState;
|
|
8349
|
-
|
|
8350
8109
|
if (nextIsControlled && !reactFastCompare(previousSearchState, nextSearchState)) {
|
|
8351
8110
|
prevState.instantSearchManager.onExternalStateUpdate(nextProps.searchState);
|
|
8352
8111
|
}
|
|
8353
|
-
|
|
8354
8112
|
return {
|
|
8355
8113
|
isControlled: nextIsControlled,
|
|
8356
|
-
contextValue:
|
|
8114
|
+
contextValue: _objectSpread2(_objectSpread2({}, prevState.contextValue), {}, {
|
|
8357
8115
|
mainTargetedIndex: nextProps.indexName
|
|
8358
8116
|
})
|
|
8359
8117
|
};
|
|
8360
8118
|
}
|
|
8361
8119
|
}]);
|
|
8362
|
-
|
|
8363
8120
|
return InstantSearch;
|
|
8364
8121
|
}(React.Component);
|
|
8365
|
-
|
|
8366
8122
|
_defineProperty(InstantSearch, "defaultProps", {
|
|
8367
8123
|
stalledSearchDelay: 200,
|
|
8368
8124
|
refresh: false
|
|
@@ -8371,18 +8127,14 @@
|
|
|
8371
8127
|
var getId$2 = function getId() {
|
|
8372
8128
|
return 'query';
|
|
8373
8129
|
};
|
|
8374
|
-
|
|
8375
8130
|
function getCurrentRefinement(props, searchState, context) {
|
|
8376
8131
|
var id = getId$2();
|
|
8377
8132
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
8378
|
-
|
|
8379
8133
|
if (currentRefinement) {
|
|
8380
8134
|
return currentRefinement;
|
|
8381
8135
|
}
|
|
8382
|
-
|
|
8383
8136
|
return '';
|
|
8384
8137
|
}
|
|
8385
|
-
|
|
8386
8138
|
function getHits(searchResults) {
|
|
8387
8139
|
if (searchResults.results) {
|
|
8388
8140
|
if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
|
|
@@ -8399,19 +8151,16 @@
|
|
|
8399
8151
|
return [];
|
|
8400
8152
|
}
|
|
8401
8153
|
}
|
|
8402
|
-
|
|
8403
8154
|
function _refine(props, searchState, nextRefinement, context) {
|
|
8404
8155
|
var id = getId$2();
|
|
8405
|
-
|
|
8406
8156
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
8407
|
-
|
|
8408
8157
|
var resetPage = true;
|
|
8409
8158
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
8410
8159
|
}
|
|
8411
|
-
|
|
8412
8160
|
function _cleanUp(props, searchState, context) {
|
|
8413
8161
|
return cleanUpValue(searchState, context, getId$2());
|
|
8414
8162
|
}
|
|
8163
|
+
|
|
8415
8164
|
/**
|
|
8416
8165
|
* connectAutoComplete connector provides the logic to create connected
|
|
8417
8166
|
* components that will render the results retrieved from
|
|
@@ -8427,8 +8176,6 @@
|
|
|
8427
8176
|
* @providedPropType {function} refine - a function to change the query
|
|
8428
8177
|
* @providedPropType {string} currentRefinement - the query to search for
|
|
8429
8178
|
*/
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
8179
|
var connectAutoComplete = createConnectorWithContext({
|
|
8433
8180
|
displayName: 'AlgoliaAutoComplete',
|
|
8434
8181
|
$$type: 'ais.autoComplete',
|
|
@@ -8453,18 +8200,6 @@
|
|
|
8453
8200
|
multiIndexContext: props.indexContextValue
|
|
8454
8201
|
});
|
|
8455
8202
|
},
|
|
8456
|
-
|
|
8457
|
-
/**
|
|
8458
|
-
* AutoComplete needs to be considered as a widget to trigger a search,
|
|
8459
|
-
* even if no other widgets are used.
|
|
8460
|
-
*
|
|
8461
|
-
* To be considered as a widget you need either:
|
|
8462
|
-
* - getSearchParameters
|
|
8463
|
-
* - getMetadata
|
|
8464
|
-
* - transitionState
|
|
8465
|
-
*
|
|
8466
|
-
* See: createConnector.tsx
|
|
8467
|
-
*/
|
|
8468
8203
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
8469
8204
|
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
8470
8205
|
ais: props.contextValue,
|
|
@@ -8477,16 +8212,12 @@
|
|
|
8477
8212
|
return props.attributes[0];
|
|
8478
8213
|
};
|
|
8479
8214
|
var namespace = 'hierarchicalMenu';
|
|
8480
|
-
|
|
8481
8215
|
function _refine$1(props, searchState, nextRefinement, context) {
|
|
8482
8216
|
var id = getId$3(props);
|
|
8483
|
-
|
|
8484
8217
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
8485
|
-
|
|
8486
8218
|
var resetPage = true;
|
|
8487
8219
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
8488
8220
|
}
|
|
8489
|
-
|
|
8490
8221
|
function transformValue(values) {
|
|
8491
8222
|
return values.reduce(function (acc, item) {
|
|
8492
8223
|
if (item.isRefined) {
|
|
@@ -8495,16 +8226,16 @@
|
|
|
8495
8226
|
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
8496
8227
|
// If dealing with the first level, "value" is equal to the current value
|
|
8497
8228
|
value: item.escapedValue
|
|
8498
|
-
});
|
|
8499
|
-
|
|
8229
|
+
});
|
|
8230
|
+
// Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
8500
8231
|
if (item.data) {
|
|
8501
8232
|
acc = acc.concat(transformValue(item.data));
|
|
8502
8233
|
}
|
|
8503
8234
|
}
|
|
8504
|
-
|
|
8505
8235
|
return acc;
|
|
8506
8236
|
}, []);
|
|
8507
8237
|
}
|
|
8238
|
+
|
|
8508
8239
|
/**
|
|
8509
8240
|
* The breadcrumb component is s a type of secondary navigation scheme that
|
|
8510
8241
|
* reveals the user’s location in a website or web application.
|
|
@@ -8542,7 +8273,6 @@
|
|
|
8542
8273
|
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
|
|
8543
8274
|
*/
|
|
8544
8275
|
|
|
8545
|
-
|
|
8546
8276
|
var connectBreadcrumb = createConnectorWithContext({
|
|
8547
8277
|
displayName: 'AlgoliaBreadcrumb',
|
|
8548
8278
|
$$type: 'ais.breadcrumb',
|
|
@@ -8551,11 +8281,9 @@
|
|
|
8551
8281
|
var isNotString = function isNotString(val) {
|
|
8552
8282
|
return typeof val !== 'string';
|
|
8553
8283
|
};
|
|
8554
|
-
|
|
8555
8284
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
8556
8285
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
8557
8286
|
}
|
|
8558
|
-
|
|
8559
8287
|
return undefined;
|
|
8560
8288
|
},
|
|
8561
8289
|
transformItems: propTypes.func
|
|
@@ -8567,14 +8295,12 @@
|
|
|
8567
8295
|
multiIndexContext: props.indexContextValue
|
|
8568
8296
|
});
|
|
8569
8297
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
8570
|
-
|
|
8571
8298
|
if (!isFacetPresent) {
|
|
8572
8299
|
return {
|
|
8573
8300
|
items: [],
|
|
8574
8301
|
canRefine: false
|
|
8575
8302
|
};
|
|
8576
8303
|
}
|
|
8577
|
-
|
|
8578
8304
|
var values = results.getFacetValues(id);
|
|
8579
8305
|
var items = values.data ? transformValue(values.data) : [];
|
|
8580
8306
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -8591,9 +8317,6 @@
|
|
|
8591
8317
|
}
|
|
8592
8318
|
});
|
|
8593
8319
|
|
|
8594
|
-
function ownKeys$7(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; }
|
|
8595
|
-
|
|
8596
|
-
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8597
8320
|
/**
|
|
8598
8321
|
* connectCurrentRefinements connector provides the logic to build a widget that will
|
|
8599
8322
|
* give the user the ability to remove all or some of the filters that were
|
|
@@ -8606,7 +8329,6 @@
|
|
|
8606
8329
|
* @providedPropType {array.<{label: string, attribute: string, currentRefinement: string || object, items: array, value: function}>} items - all the filters, the `value` is to pass to the `refine` function for removing all currentrefinements, `label` is for the display. When existing several refinements for the same atribute name, then you get a nested `items` object that contains a `label` and a `value` function to use to remove a single filter. `attribute` and `currentRefinement` are metadata containing row values.
|
|
8607
8330
|
* @providedPropType {string} query - the search query
|
|
8608
8331
|
*/
|
|
8609
|
-
|
|
8610
8332
|
var connectCurrentRefinements = createConnectorWithContext({
|
|
8611
8333
|
displayName: 'AlgoliaCurrentRefinements',
|
|
8612
8334
|
$$type: 'ais.currentRefinements',
|
|
@@ -8622,16 +8344,14 @@
|
|
|
8622
8344
|
if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
|
|
8623
8345
|
return res;
|
|
8624
8346
|
}
|
|
8625
|
-
|
|
8626
8347
|
return res.concat(meta.items.map(function (item) {
|
|
8627
|
-
return
|
|
8348
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
8628
8349
|
id: meta.id,
|
|
8629
8350
|
index: meta.index
|
|
8630
8351
|
});
|
|
8631
8352
|
}));
|
|
8632
8353
|
}
|
|
8633
8354
|
}
|
|
8634
|
-
|
|
8635
8355
|
return res;
|
|
8636
8356
|
}, []);
|
|
8637
8357
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -8652,6 +8372,7 @@
|
|
|
8652
8372
|
});
|
|
8653
8373
|
|
|
8654
8374
|
var _excluded$3 = ["defaultRefinement"];
|
|
8375
|
+
|
|
8655
8376
|
/**
|
|
8656
8377
|
* The GeoSearch connector provides the logic to build a widget that will display the results on a map.
|
|
8657
8378
|
* It also provides a way to search for results based on their position. The connector provides function to manage the search experience (search on map interaction).
|
|
@@ -8668,25 +8389,21 @@
|
|
|
8668
8389
|
* @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied
|
|
8669
8390
|
* @providedPropType {{ lat: number, lng: number }} [position] - the position of the search
|
|
8670
8391
|
*/
|
|
8392
|
+
|
|
8671
8393
|
// To control the map with an external widget the other widget
|
|
8672
8394
|
// **must** write the value in the attribute `aroundLatLng`
|
|
8673
|
-
|
|
8674
8395
|
var getBoundingBoxId = function getBoundingBoxId() {
|
|
8675
8396
|
return 'boundingBox';
|
|
8676
8397
|
};
|
|
8677
|
-
|
|
8678
8398
|
var getAroundLatLngId = function getAroundLatLngId() {
|
|
8679
8399
|
return 'aroundLatLng';
|
|
8680
8400
|
};
|
|
8681
|
-
|
|
8682
8401
|
var getConfigureAroundLatLngId = function getConfigureAroundLatLngId() {
|
|
8683
8402
|
return 'configure.aroundLatLng';
|
|
8684
8403
|
};
|
|
8685
|
-
|
|
8686
8404
|
var currentRefinementToString = function currentRefinementToString(currentRefinement) {
|
|
8687
8405
|
return [currentRefinement.northEast.lat, currentRefinement.northEast.lng, currentRefinement.southWest.lat, currentRefinement.southWest.lng].join();
|
|
8688
8406
|
};
|
|
8689
|
-
|
|
8690
8407
|
var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
|
|
8691
8408
|
var values = value.split(',');
|
|
8692
8409
|
return {
|
|
@@ -8700,9 +8417,7 @@
|
|
|
8700
8417
|
}
|
|
8701
8418
|
};
|
|
8702
8419
|
};
|
|
8703
|
-
|
|
8704
8420
|
var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
|
|
8705
|
-
|
|
8706
8421
|
var stringToPosition = function stringToPosition(value) {
|
|
8707
8422
|
var pattern = value.match(latLngRegExp);
|
|
8708
8423
|
return {
|
|
@@ -8710,15 +8425,13 @@
|
|
|
8710
8425
|
lng: parseFloat(pattern[2])
|
|
8711
8426
|
};
|
|
8712
8427
|
};
|
|
8713
|
-
|
|
8714
8428
|
var getCurrentRefinement$1 = function getCurrentRefinement(props, searchState, context) {
|
|
8715
8429
|
var refinement = getCurrentRefinementValue(props, searchState, context, getBoundingBoxId(), {});
|
|
8716
|
-
|
|
8717
8430
|
if (!objectHasKeys(refinement)) {
|
|
8718
8431
|
return;
|
|
8719
|
-
}
|
|
8720
|
-
|
|
8432
|
+
}
|
|
8721
8433
|
|
|
8434
|
+
// eslint-disable-next-line consistent-return
|
|
8722
8435
|
return {
|
|
8723
8436
|
northEast: {
|
|
8724
8437
|
lat: parseFloat(refinement.northEast.lat),
|
|
@@ -8730,30 +8443,22 @@
|
|
|
8730
8443
|
}
|
|
8731
8444
|
};
|
|
8732
8445
|
};
|
|
8733
|
-
|
|
8734
8446
|
var getCurrentPosition = function getCurrentPosition(props, searchState, context) {
|
|
8735
8447
|
var defaultRefinement = props.defaultRefinement,
|
|
8736
|
-
|
|
8737
|
-
|
|
8448
|
+
propsWithoutDefaultRefinement = _objectWithoutProperties(props, _excluded$3);
|
|
8738
8449
|
var aroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getAroundLatLngId());
|
|
8739
|
-
|
|
8740
8450
|
if (!aroundLatLng) {
|
|
8741
8451
|
// Fallback on `configure.aroundLatLng`
|
|
8742
8452
|
var configureAroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getConfigureAroundLatLngId());
|
|
8743
8453
|
return configureAroundLatLng && stringToPosition(configureAroundLatLng);
|
|
8744
8454
|
}
|
|
8745
|
-
|
|
8746
8455
|
return aroundLatLng;
|
|
8747
8456
|
};
|
|
8748
|
-
|
|
8749
8457
|
var _refine$2 = function refine(searchState, nextValue, context) {
|
|
8750
8458
|
var resetPage = true;
|
|
8751
|
-
|
|
8752
8459
|
var nextRefinement = _defineProperty({}, getBoundingBoxId(), nextValue);
|
|
8753
|
-
|
|
8754
8460
|
return refineValue(searchState, nextRefinement, context, resetPage);
|
|
8755
8461
|
};
|
|
8756
|
-
|
|
8757
8462
|
var connectGeoSearch = createConnectorWithContext({
|
|
8758
8463
|
displayName: 'AlgoliaGeoSearch',
|
|
8759
8464
|
$$type: 'ais.geoSearch',
|
|
@@ -8762,7 +8467,9 @@
|
|
|
8762
8467
|
ais: props.contextValue,
|
|
8763
8468
|
multiIndexContext: props.indexContextValue
|
|
8764
8469
|
};
|
|
8765
|
-
var results = getResults(searchResults, context);
|
|
8470
|
+
var results = getResults(searchResults, context);
|
|
8471
|
+
|
|
8472
|
+
// We read it from both because the SearchParameters & the searchState are not always
|
|
8766
8473
|
// in sync. When we set the refinement the searchState is used but when we clear the refinement
|
|
8767
8474
|
// the SearchParameters is used. In the first case when we render, the results are not there
|
|
8768
8475
|
// so we can't find the value from the results. The most up to date value is the searchState.
|
|
@@ -8797,11 +8504,9 @@
|
|
|
8797
8504
|
ais: props.contextValue,
|
|
8798
8505
|
multiIndexContext: props.indexContextValue
|
|
8799
8506
|
});
|
|
8800
|
-
|
|
8801
8507
|
if (!currentRefinement) {
|
|
8802
8508
|
return searchParameters;
|
|
8803
8509
|
}
|
|
8804
|
-
|
|
8805
8510
|
return searchParameters.setQueryParameter('insideBoundingBox', currentRefinementToString(currentRefinement));
|
|
8806
8511
|
},
|
|
8807
8512
|
cleanUp: function cleanUp(props, searchState) {
|
|
@@ -8820,7 +8525,6 @@
|
|
|
8820
8525
|
var index = getIndexId(context);
|
|
8821
8526
|
var nextRefinement = {};
|
|
8822
8527
|
var currentRefinement = getCurrentRefinement$1(props, searchState, context);
|
|
8823
|
-
|
|
8824
8528
|
if (currentRefinement) {
|
|
8825
8529
|
items.push({
|
|
8826
8530
|
label: "".concat(id, ": ").concat(currentRefinementToString(currentRefinement)),
|
|
@@ -8830,7 +8534,6 @@
|
|
|
8830
8534
|
currentRefinement: currentRefinement
|
|
8831
8535
|
});
|
|
8832
8536
|
}
|
|
8833
|
-
|
|
8834
8537
|
return {
|
|
8835
8538
|
id: id,
|
|
8836
8539
|
index: index,
|
|
@@ -8842,33 +8545,25 @@
|
|
|
8842
8545
|
}
|
|
8843
8546
|
});
|
|
8844
8547
|
|
|
8845
|
-
function ownKeys$8(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; }
|
|
8846
|
-
|
|
8847
|
-
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8848
8548
|
var getId$4 = function getId(props) {
|
|
8849
8549
|
return props.attributes[0];
|
|
8850
8550
|
};
|
|
8851
8551
|
var namespace$1 = 'hierarchicalMenu';
|
|
8852
|
-
|
|
8853
8552
|
function getCurrentRefinement$2(props, searchState, context) {
|
|
8854
8553
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$1, ".").concat(getId$4(props)), null);
|
|
8855
|
-
|
|
8856
8554
|
if (currentRefinement === '') {
|
|
8857
8555
|
return null;
|
|
8858
8556
|
}
|
|
8859
|
-
|
|
8860
8557
|
return currentRefinement;
|
|
8861
8558
|
}
|
|
8862
|
-
|
|
8863
8559
|
function getValue(value, props, searchState, context) {
|
|
8864
8560
|
var id = props.id,
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8561
|
+
attributes = props.attributes,
|
|
8562
|
+
separator = props.separator,
|
|
8563
|
+
rootPath = props.rootPath,
|
|
8564
|
+
showParentLevel = props.showParentLevel;
|
|
8869
8565
|
var currentRefinement = getCurrentRefinement$2(props, searchState, context);
|
|
8870
8566
|
var nextRefinement;
|
|
8871
|
-
|
|
8872
8567
|
if (currentRefinement === null) {
|
|
8873
8568
|
nextRefinement = value;
|
|
8874
8569
|
} else {
|
|
@@ -8883,10 +8578,8 @@
|
|
|
8883
8578
|
});
|
|
8884
8579
|
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
|
|
8885
8580
|
}
|
|
8886
|
-
|
|
8887
8581
|
return nextRefinement;
|
|
8888
8582
|
}
|
|
8889
|
-
|
|
8890
8583
|
function transformValue$1(value, props, searchState, context) {
|
|
8891
8584
|
return value.map(function (v) {
|
|
8892
8585
|
return {
|
|
@@ -8898,32 +8591,27 @@
|
|
|
8898
8591
|
};
|
|
8899
8592
|
});
|
|
8900
8593
|
}
|
|
8901
|
-
|
|
8902
8594
|
var truncate = function truncate() {
|
|
8903
8595
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
8904
8596
|
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
8905
8597
|
return items.slice(0, limit).map(function () {
|
|
8906
8598
|
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8907
|
-
return Array.isArray(item.items) ?
|
|
8599
|
+
return Array.isArray(item.items) ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
8908
8600
|
items: truncate(item.items, limit)
|
|
8909
8601
|
}) : item;
|
|
8910
8602
|
});
|
|
8911
8603
|
};
|
|
8912
|
-
|
|
8913
8604
|
function _refine$3(props, searchState, nextRefinement, context) {
|
|
8914
8605
|
var id = getId$4(props);
|
|
8915
|
-
|
|
8916
8606
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
8917
|
-
|
|
8918
8607
|
var resetPage = true;
|
|
8919
8608
|
return refineValue(searchState, nextValue, context, resetPage, namespace$1);
|
|
8920
8609
|
}
|
|
8921
|
-
|
|
8922
8610
|
function _cleanUp$1(props, searchState, context) {
|
|
8923
8611
|
return cleanUpValue(searchState, context, "".concat(namespace$1, ".").concat(getId$4(props)));
|
|
8924
8612
|
}
|
|
8925
|
-
|
|
8926
8613
|
var sortBy = ['name:asc'];
|
|
8614
|
+
|
|
8927
8615
|
/**
|
|
8928
8616
|
* connectHierarchicalMenu connector provides the logic to build a widget that will
|
|
8929
8617
|
* give the user the ability to explore a tree-like structure.
|
|
@@ -8969,7 +8657,6 @@
|
|
|
8969
8657
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
8970
8658
|
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the HierarchicalMenu can display. items has the same shape as parent items.
|
|
8971
8659
|
*/
|
|
8972
|
-
|
|
8973
8660
|
var connectHierarchicalMenu = createConnectorWithContext({
|
|
8974
8661
|
displayName: 'AlgoliaHierarchicalMenu',
|
|
8975
8662
|
$$type: 'ais.hierarchicalMenu',
|
|
@@ -8978,11 +8665,9 @@
|
|
|
8978
8665
|
var isNotString = function isNotString(val) {
|
|
8979
8666
|
return typeof val !== 'string';
|
|
8980
8667
|
};
|
|
8981
|
-
|
|
8982
8668
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
8983
8669
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
8984
8670
|
}
|
|
8985
|
-
|
|
8986
8671
|
return undefined;
|
|
8987
8672
|
},
|
|
8988
8673
|
separator: propTypes.string,
|
|
@@ -9006,16 +8691,15 @@
|
|
|
9006
8691
|
},
|
|
9007
8692
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
9008
8693
|
var showMore = props.showMore,
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
8694
|
+
limit = props.limit,
|
|
8695
|
+
showMoreLimit = props.showMoreLimit,
|
|
8696
|
+
facetOrdering = props.facetOrdering;
|
|
9012
8697
|
var id = getId$4(props);
|
|
9013
8698
|
var results = getResults(searchResults, {
|
|
9014
8699
|
ais: props.contextValue,
|
|
9015
8700
|
multiIndexContext: props.indexContextValue
|
|
9016
8701
|
});
|
|
9017
8702
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
9018
|
-
|
|
9019
8703
|
if (!isFacetPresent) {
|
|
9020
8704
|
return {
|
|
9021
8705
|
items: [],
|
|
@@ -9026,7 +8710,6 @@
|
|
|
9026
8710
|
canRefine: false
|
|
9027
8711
|
};
|
|
9028
8712
|
}
|
|
9029
|
-
|
|
9030
8713
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
9031
8714
|
var value = results.getFacetValues(id, {
|
|
9032
8715
|
sortBy: sortBy,
|
|
@@ -9060,13 +8743,13 @@
|
|
|
9060
8743
|
},
|
|
9061
8744
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
9062
8745
|
var attributes = props.attributes,
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
8746
|
+
separator = props.separator,
|
|
8747
|
+
rootPath = props.rootPath,
|
|
8748
|
+
showParentLevel = props.showParentLevel,
|
|
8749
|
+
showMore = props.showMore,
|
|
8750
|
+
limit = props.limit,
|
|
8751
|
+
showMoreLimit = props.showMoreLimit,
|
|
8752
|
+
contextValue = props.contextValue;
|
|
9070
8753
|
var id = getId$4(props);
|
|
9071
8754
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
9072
8755
|
searchParameters = searchParameters.addHierarchicalFacet({
|
|
@@ -9082,11 +8765,9 @@
|
|
|
9082
8765
|
ais: contextValue,
|
|
9083
8766
|
multiIndexContext: props.indexContextValue
|
|
9084
8767
|
});
|
|
9085
|
-
|
|
9086
8768
|
if (currentRefinement !== null) {
|
|
9087
8769
|
searchParameters = searchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement);
|
|
9088
8770
|
}
|
|
9089
|
-
|
|
9090
8771
|
return searchParameters;
|
|
9091
8772
|
},
|
|
9092
8773
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9120,12 +8801,12 @@
|
|
|
9120
8801
|
|
|
9121
8802
|
var highlight = function highlight(_ref) {
|
|
9122
8803
|
var attribute = _ref.attribute,
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
8804
|
+
hit = _ref.hit,
|
|
8805
|
+
highlightProperty = _ref.highlightProperty,
|
|
8806
|
+
_ref$preTag = _ref.preTag,
|
|
8807
|
+
preTag = _ref$preTag === void 0 ? HIGHLIGHT_TAGS.highlightPreTag : _ref$preTag,
|
|
8808
|
+
_ref$postTag = _ref.postTag,
|
|
8809
|
+
postTag = _ref$postTag === void 0 ? HIGHLIGHT_TAGS.highlightPostTag : _ref$postTag;
|
|
9129
8810
|
return parseAlgoliaHit({
|
|
9130
8811
|
attribute: attribute,
|
|
9131
8812
|
highlightProperty: highlightProperty,
|
|
@@ -9134,6 +8815,7 @@
|
|
|
9134
8815
|
postTag: postTag
|
|
9135
8816
|
});
|
|
9136
8817
|
};
|
|
8818
|
+
|
|
9137
8819
|
/**
|
|
9138
8820
|
* connectHighlight connector provides the logic to create an highlighter
|
|
9139
8821
|
* component that will retrieve, parse and render an highlighted attribute
|
|
@@ -9184,8 +8866,6 @@
|
|
|
9184
8866
|
* </InstantSearch>
|
|
9185
8867
|
* );
|
|
9186
8868
|
*/
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
8869
|
var connectHighlight = createConnectorWithContext({
|
|
9190
8870
|
displayName: 'AlgoliaHighlighter',
|
|
9191
8871
|
$$type: 'ais.highlighter',
|
|
@@ -9240,7 +8920,6 @@
|
|
|
9240
8920
|
* </InstantSearch>
|
|
9241
8921
|
* );
|
|
9242
8922
|
*/
|
|
9243
|
-
|
|
9244
8923
|
var connectHits = createConnectorWithContext({
|
|
9245
8924
|
displayName: 'AlgoliaHits',
|
|
9246
8925
|
$$type: 'ais.hits',
|
|
@@ -9249,21 +8928,18 @@
|
|
|
9249
8928
|
ais: props.contextValue,
|
|
9250
8929
|
multiIndexContext: props.indexContextValue
|
|
9251
8930
|
});
|
|
9252
|
-
|
|
9253
8931
|
if (!results) {
|
|
9254
8932
|
return {
|
|
9255
8933
|
hits: []
|
|
9256
8934
|
};
|
|
9257
8935
|
}
|
|
9258
|
-
|
|
9259
8936
|
var hitsWithPositions = addAbsolutePositions(results.hits, results.hitsPerPage, results.page);
|
|
9260
8937
|
var hitsWithPositionsAndQueryID = addQueryID(hitsWithPositions, results.queryID);
|
|
9261
8938
|
return {
|
|
9262
8939
|
hits: hitsWithPositionsAndQueryID
|
|
9263
8940
|
};
|
|
9264
8941
|
},
|
|
9265
|
-
|
|
9266
|
-
/**
|
|
8942
|
+
/*
|
|
9267
8943
|
* Hits needs to be considered as a widget to trigger a search,
|
|
9268
8944
|
* even if no other widgets are used.
|
|
9269
8945
|
*
|
|
@@ -9279,24 +8955,18 @@
|
|
|
9279
8955
|
}
|
|
9280
8956
|
});
|
|
9281
8957
|
|
|
9282
|
-
function ownKeys$9(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; }
|
|
9283
|
-
|
|
9284
|
-
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9285
|
-
|
|
9286
8958
|
function getId$5() {
|
|
9287
8959
|
return 'hitsPerPage';
|
|
9288
8960
|
}
|
|
9289
|
-
|
|
9290
8961
|
function getCurrentRefinement$3(props, searchState, context) {
|
|
9291
8962
|
var id = getId$5();
|
|
9292
8963
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
9293
|
-
|
|
9294
8964
|
if (typeof currentRefinement === 'string') {
|
|
9295
8965
|
return parseInt(currentRefinement, 10);
|
|
9296
8966
|
}
|
|
9297
|
-
|
|
9298
8967
|
return currentRefinement;
|
|
9299
8968
|
}
|
|
8969
|
+
|
|
9300
8970
|
/**
|
|
9301
8971
|
* connectHitsPerPage connector provides the logic to create connected
|
|
9302
8972
|
* components that will allow a user to choose to display more or less results from Algolia.
|
|
@@ -9310,8 +8980,6 @@
|
|
|
9310
8980
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
9311
8981
|
* @providedPropType {array.<{isRefined: boolean, label?: string, value: number}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
9312
8982
|
*/
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
8983
|
var connectHitsPerPage = createConnectorWithContext({
|
|
9316
8984
|
displayName: 'AlgoliaHitsPerPage',
|
|
9317
8985
|
$$type: 'ais.hitsPerPage',
|
|
@@ -9329,9 +8997,9 @@
|
|
|
9329
8997
|
multiIndexContext: props.indexContextValue
|
|
9330
8998
|
});
|
|
9331
8999
|
var items = props.items.map(function (item) {
|
|
9332
|
-
return item.value === currentRefinement ?
|
|
9000
|
+
return item.value === currentRefinement ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9333
9001
|
isRefined: true
|
|
9334
|
-
}) :
|
|
9002
|
+
}) : _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9335
9003
|
isRefined: false
|
|
9336
9004
|
});
|
|
9337
9005
|
});
|
|
@@ -9342,9 +9010,7 @@
|
|
|
9342
9010
|
},
|
|
9343
9011
|
refine: function refine(props, searchState, nextRefinement) {
|
|
9344
9012
|
var id = getId$5();
|
|
9345
|
-
|
|
9346
9013
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
9347
|
-
|
|
9348
9014
|
var resetPage = true;
|
|
9349
9015
|
return refineValue(searchState, nextValue, {
|
|
9350
9016
|
ais: props.contextValue,
|
|
@@ -9371,31 +9037,24 @@
|
|
|
9371
9037
|
});
|
|
9372
9038
|
|
|
9373
9039
|
var _excluded$4 = ["page"];
|
|
9374
|
-
|
|
9375
9040
|
function getId$6() {
|
|
9376
9041
|
return 'page';
|
|
9377
9042
|
}
|
|
9378
|
-
|
|
9379
9043
|
function getCurrentRefinement$4(props, searchState, context) {
|
|
9380
9044
|
var id = getId$6();
|
|
9381
9045
|
var page = 1;
|
|
9382
9046
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, page);
|
|
9383
|
-
|
|
9384
9047
|
if (typeof currentRefinement === 'string') {
|
|
9385
9048
|
return parseInt(currentRefinement, 10);
|
|
9386
9049
|
}
|
|
9387
|
-
|
|
9388
9050
|
return currentRefinement;
|
|
9389
9051
|
}
|
|
9390
|
-
|
|
9391
9052
|
function getStateWithoutPage(state) {
|
|
9392
9053
|
var _ref = state || {},
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9054
|
+
page = _ref.page,
|
|
9055
|
+
rest = _objectWithoutProperties(_ref, _excluded$4);
|
|
9396
9056
|
return rest;
|
|
9397
9057
|
}
|
|
9398
|
-
|
|
9399
9058
|
function getInMemoryCache() {
|
|
9400
9059
|
var cachedHits = undefined;
|
|
9401
9060
|
var cachedState = undefined;
|
|
@@ -9406,13 +9065,12 @@
|
|
|
9406
9065
|
},
|
|
9407
9066
|
write: function write(_ref3) {
|
|
9408
9067
|
var state = _ref3.state,
|
|
9409
|
-
|
|
9068
|
+
hits = _ref3.hits;
|
|
9410
9069
|
cachedState = getStateWithoutPage(state);
|
|
9411
9070
|
cachedHits = hits;
|
|
9412
9071
|
}
|
|
9413
9072
|
};
|
|
9414
9073
|
}
|
|
9415
|
-
|
|
9416
9074
|
function extractHitsFromCachedHits(cachedHits) {
|
|
9417
9075
|
return Object.keys(cachedHits).map(Number).sort(function (a, b) {
|
|
9418
9076
|
return a - b;
|
|
@@ -9420,6 +9078,7 @@
|
|
|
9420
9078
|
return acc.concat(cachedHits[page]);
|
|
9421
9079
|
}, []);
|
|
9422
9080
|
}
|
|
9081
|
+
|
|
9423
9082
|
/**
|
|
9424
9083
|
* InfiniteHits connector provides the logic to create connected
|
|
9425
9084
|
* components that will render an continuous list of results retrieved from
|
|
@@ -9430,19 +9089,15 @@
|
|
|
9430
9089
|
* @providedPropType {boolean} hasMore - indicates if there are more pages to load
|
|
9431
9090
|
* @providedPropType {function} refine - call to load more results
|
|
9432
9091
|
*/
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
9092
|
var connectInfiniteHits = createConnectorWithContext({
|
|
9436
9093
|
displayName: 'AlgoliaInfiniteHits',
|
|
9437
9094
|
$$type: 'ais.infiniteHits',
|
|
9438
9095
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
9439
9096
|
var _this = this;
|
|
9440
|
-
|
|
9441
9097
|
var results = getResults(searchResults, {
|
|
9442
9098
|
ais: props.contextValue,
|
|
9443
9099
|
multiIndexContext: props.indexContextValue
|
|
9444
9100
|
});
|
|
9445
|
-
|
|
9446
9101
|
if (!results) {
|
|
9447
9102
|
return {
|
|
9448
9103
|
hits: [],
|
|
@@ -9453,12 +9108,11 @@
|
|
|
9453
9108
|
refineNext: function refineNext() {}
|
|
9454
9109
|
};
|
|
9455
9110
|
}
|
|
9456
|
-
|
|
9457
9111
|
var page = results.page,
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9112
|
+
hits = results.hits,
|
|
9113
|
+
hitsPerPage = results.hitsPerPage,
|
|
9114
|
+
nbPages = results.nbPages,
|
|
9115
|
+
state = results._state;
|
|
9462
9116
|
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache();
|
|
9463
9117
|
var cachedHits = this._cache.read({
|
|
9464
9118
|
state: state
|
|
@@ -9466,31 +9120,26 @@
|
|
|
9466
9120
|
var hitsWithPositions = addAbsolutePositions(hits, hitsPerPage, page);
|
|
9467
9121
|
var hitsWithPositionsAndQueryID = addQueryID(hitsWithPositions, results.queryID);
|
|
9468
9122
|
cachedHits[page] = hitsWithPositionsAndQueryID;
|
|
9469
|
-
|
|
9470
9123
|
this._cache.write({
|
|
9471
9124
|
state: state,
|
|
9472
9125
|
hits: cachedHits
|
|
9473
9126
|
});
|
|
9127
|
+
|
|
9474
9128
|
/*
|
|
9475
9129
|
Math.min() and Math.max() returns Infinity or -Infinity when no argument is given.
|
|
9476
9130
|
But there is always something in this point because of `cachedHits[page]`.
|
|
9477
9131
|
*/
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
9132
|
var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
9481
9133
|
var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
9482
9134
|
var hasPrevious = firstReceivedPage > 0;
|
|
9483
9135
|
var lastPageIndex = nbPages - 1;
|
|
9484
9136
|
var hasMore = lastReceivedPage < lastPageIndex;
|
|
9485
|
-
|
|
9486
9137
|
var refinePrevious = function refinePrevious(event) {
|
|
9487
9138
|
return _this.refine(event, firstReceivedPage - 1);
|
|
9488
9139
|
};
|
|
9489
|
-
|
|
9490
9140
|
var refineNext = function refineNext(event) {
|
|
9491
9141
|
return _this.refine(event, lastReceivedPage + 1);
|
|
9492
9142
|
};
|
|
9493
|
-
|
|
9494
9143
|
return {
|
|
9495
9144
|
hits: extractHitsFromCachedHits(cachedHits),
|
|
9496
9145
|
hasPrevious: hasPrevious,
|
|
@@ -9509,9 +9158,7 @@
|
|
|
9509
9158
|
},
|
|
9510
9159
|
refine: function refine(props, searchState, event, index) {
|
|
9511
9160
|
var id = getId$6();
|
|
9512
|
-
|
|
9513
9161
|
var nextValue = _defineProperty({}, id, index + 1);
|
|
9514
|
-
|
|
9515
9162
|
var resetPage = false;
|
|
9516
9163
|
return refineValue(searchState, nextValue, {
|
|
9517
9164
|
ais: props.contextValue,
|
|
@@ -9521,47 +9168,37 @@
|
|
|
9521
9168
|
});
|
|
9522
9169
|
|
|
9523
9170
|
var namespace$2 = 'menu';
|
|
9524
|
-
|
|
9525
9171
|
function getId$7(props) {
|
|
9526
9172
|
return props.attribute;
|
|
9527
9173
|
}
|
|
9528
|
-
|
|
9529
9174
|
function getCurrentRefinement$5(props, searchState, context) {
|
|
9530
9175
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$2, ".").concat(getId$7(props)), null);
|
|
9531
|
-
|
|
9532
9176
|
if (currentRefinement === '') {
|
|
9533
9177
|
return null;
|
|
9534
9178
|
}
|
|
9535
|
-
|
|
9536
9179
|
return currentRefinement;
|
|
9537
9180
|
}
|
|
9538
|
-
|
|
9539
9181
|
function getValue$1(value, props, searchState, context) {
|
|
9540
9182
|
var currentRefinement = getCurrentRefinement$5(props, searchState, context);
|
|
9541
9183
|
return value === currentRefinement ? '' : value;
|
|
9542
9184
|
}
|
|
9543
|
-
|
|
9544
9185
|
function getLimit(_ref) {
|
|
9545
9186
|
var showMore = _ref.showMore,
|
|
9546
|
-
|
|
9547
|
-
|
|
9187
|
+
limit = _ref.limit,
|
|
9188
|
+
showMoreLimit = _ref.showMoreLimit;
|
|
9548
9189
|
return showMore ? showMoreLimit : limit;
|
|
9549
9190
|
}
|
|
9550
|
-
|
|
9551
9191
|
function _refine$4(props, searchState, nextRefinement, context) {
|
|
9552
9192
|
var id = getId$7(props);
|
|
9553
|
-
|
|
9554
9193
|
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : '');
|
|
9555
|
-
|
|
9556
9194
|
var resetPage = true;
|
|
9557
9195
|
return refineValue(searchState, nextValue, context, resetPage, namespace$2);
|
|
9558
9196
|
}
|
|
9559
|
-
|
|
9560
9197
|
function _cleanUp$2(props, searchState, context) {
|
|
9561
9198
|
return cleanUpValue(searchState, context, "".concat(namespace$2, ".").concat(getId$7(props)));
|
|
9562
9199
|
}
|
|
9563
|
-
|
|
9564
9200
|
var defaultSortBy = ['count:desc', 'name:asc'];
|
|
9201
|
+
|
|
9565
9202
|
/**
|
|
9566
9203
|
* connectMenu connector provides the logic to build a widget that will
|
|
9567
9204
|
* give the user the ability to choose a single value for a specific facet.
|
|
@@ -9582,7 +9219,6 @@
|
|
|
9582
9219
|
* @providedPropType {function} searchForItems - a function to toggle a search inside items values
|
|
9583
9220
|
* @providedPropType {boolean} isFromSearch - a boolean that says if the `items` props contains facet values from the global search or from the search inside items.
|
|
9584
9221
|
*/
|
|
9585
|
-
|
|
9586
9222
|
var connectMenu = createConnectorWithContext({
|
|
9587
9223
|
displayName: 'AlgoliaMenu',
|
|
9588
9224
|
$$type: 'ais.menu',
|
|
@@ -9604,20 +9240,20 @@
|
|
|
9604
9240
|
},
|
|
9605
9241
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults, meta, searchForFacetValuesResults) {
|
|
9606
9242
|
var attribute = props.attribute,
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9243
|
+
searchable = props.searchable,
|
|
9244
|
+
indexContextValue = props.indexContextValue,
|
|
9245
|
+
facetOrdering = props.facetOrdering;
|
|
9610
9246
|
var results = getResults(searchResults, {
|
|
9611
9247
|
ais: props.contextValue,
|
|
9612
9248
|
multiIndexContext: props.indexContextValue
|
|
9613
9249
|
});
|
|
9614
9250
|
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
9615
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
9251
|
+
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
9616
9252
|
|
|
9253
|
+
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
9617
9254
|
if (searchable && indexContextValue) {
|
|
9618
9255
|
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
9619
9256
|
}
|
|
9620
|
-
|
|
9621
9257
|
if (!canRefine) {
|
|
9622
9258
|
return {
|
|
9623
9259
|
items: [],
|
|
@@ -9630,9 +9266,7 @@
|
|
|
9630
9266
|
canRefine: canRefine
|
|
9631
9267
|
};
|
|
9632
9268
|
}
|
|
9633
|
-
|
|
9634
9269
|
var items;
|
|
9635
|
-
|
|
9636
9270
|
if (isFromSearch) {
|
|
9637
9271
|
items = searchForFacetValuesResults[attribute].map(function (v) {
|
|
9638
9272
|
return {
|
|
@@ -9666,7 +9300,6 @@
|
|
|
9666
9300
|
};
|
|
9667
9301
|
});
|
|
9668
9302
|
}
|
|
9669
|
-
|
|
9670
9303
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
9671
9304
|
return {
|
|
9672
9305
|
items: transformedItems.slice(0, getLimit(props)),
|
|
@@ -9708,11 +9341,9 @@
|
|
|
9708
9341
|
ais: props.contextValue,
|
|
9709
9342
|
multiIndexContext: props.indexContextValue
|
|
9710
9343
|
});
|
|
9711
|
-
|
|
9712
9344
|
if (currentRefinement !== null) {
|
|
9713
9345
|
searchParameters = searchParameters.addDisjunctiveFacetRefinement(attribute, currentRefinement);
|
|
9714
9346
|
}
|
|
9715
|
-
|
|
9716
9347
|
return searchParameters;
|
|
9717
9348
|
},
|
|
9718
9349
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9742,58 +9373,14 @@
|
|
|
9742
9373
|
}
|
|
9743
9374
|
});
|
|
9744
9375
|
|
|
9745
|
-
function _arrayWithHoles(arr) {
|
|
9746
|
-
if (Array.isArray(arr)) return arr;
|
|
9747
|
-
}
|
|
9748
|
-
|
|
9749
|
-
function _iterableToArrayLimit(arr, i) {
|
|
9750
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
9751
|
-
|
|
9752
|
-
if (_i == null) return;
|
|
9753
|
-
var _arr = [];
|
|
9754
|
-
var _n = true;
|
|
9755
|
-
var _d = false;
|
|
9756
|
-
|
|
9757
|
-
var _s, _e;
|
|
9758
|
-
|
|
9759
|
-
try {
|
|
9760
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
9761
|
-
_arr.push(_s.value);
|
|
9762
|
-
|
|
9763
|
-
if (i && _arr.length === i) break;
|
|
9764
|
-
}
|
|
9765
|
-
} catch (err) {
|
|
9766
|
-
_d = true;
|
|
9767
|
-
_e = err;
|
|
9768
|
-
} finally {
|
|
9769
|
-
try {
|
|
9770
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
9771
|
-
} finally {
|
|
9772
|
-
if (_d) throw _e;
|
|
9773
|
-
}
|
|
9774
|
-
}
|
|
9775
|
-
|
|
9776
|
-
return _arr;
|
|
9777
|
-
}
|
|
9778
|
-
|
|
9779
|
-
function _nonIterableRest() {
|
|
9780
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
9781
|
-
}
|
|
9782
|
-
|
|
9783
|
-
function _slicedToArray(arr, i) {
|
|
9784
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
9785
|
-
}
|
|
9786
|
-
|
|
9787
9376
|
function stringifyItem(item) {
|
|
9788
9377
|
if (typeof item.start === 'undefined' && typeof item.end === 'undefined') {
|
|
9789
9378
|
return '';
|
|
9790
9379
|
}
|
|
9791
|
-
|
|
9792
9380
|
var start = typeof item.start !== 'undefined' ? item.start : '';
|
|
9793
9381
|
var end = typeof item.end !== 'undefined' ? item.end : '';
|
|
9794
9382
|
return "".concat(start, ":").concat(end);
|
|
9795
9383
|
}
|
|
9796
|
-
|
|
9797
9384
|
function parseItem(value) {
|
|
9798
9385
|
if (value.length === 0) {
|
|
9799
9386
|
return {
|
|
@@ -9801,36 +9388,28 @@
|
|
|
9801
9388
|
end: null
|
|
9802
9389
|
};
|
|
9803
9390
|
}
|
|
9804
|
-
|
|
9805
9391
|
var _value$split = value.split(':'),
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9392
|
+
_value$split2 = _slicedToArray(_value$split, 2),
|
|
9393
|
+
startStr = _value$split2[0],
|
|
9394
|
+
endStr = _value$split2[1];
|
|
9810
9395
|
return {
|
|
9811
9396
|
start: startStr.length > 0 ? parseFloat(startStr) : null,
|
|
9812
9397
|
end: endStr.length > 0 ? parseFloat(endStr) : null
|
|
9813
9398
|
};
|
|
9814
9399
|
}
|
|
9815
|
-
|
|
9816
9400
|
var namespace$3 = 'multiRange';
|
|
9817
|
-
|
|
9818
9401
|
function getId$8(props) {
|
|
9819
9402
|
return props.attribute;
|
|
9820
9403
|
}
|
|
9821
|
-
|
|
9822
9404
|
function getCurrentRefinement$6(props, searchState, context) {
|
|
9823
9405
|
return getCurrentRefinementValue(props, searchState, context, "".concat(namespace$3, ".").concat(getId$8(props)), '');
|
|
9824
9406
|
}
|
|
9825
|
-
|
|
9826
9407
|
function isRefinementsRangeIncludesInsideItemRange(stats, start, end) {
|
|
9827
9408
|
return stats.min >= start && stats.min <= end || stats.max >= start && stats.max <= end;
|
|
9828
9409
|
}
|
|
9829
|
-
|
|
9830
9410
|
function isItemRangeIncludedInsideRefinementsRange(stats, start, end) {
|
|
9831
9411
|
return start >= stats.min && start <= stats.max || end >= stats.min && end <= stats.max;
|
|
9832
9412
|
}
|
|
9833
|
-
|
|
9834
9413
|
function itemHasRefinement(attribute, results, value) {
|
|
9835
9414
|
var stats = results.getFacetByName(attribute) ? results.getFacetStats(attribute) : null;
|
|
9836
9415
|
var range = value.split(':');
|
|
@@ -9838,17 +9417,15 @@
|
|
|
9838
9417
|
var end = Number(range[1]) === 0 || value === '' ? Number.POSITIVE_INFINITY : Number(range[1]);
|
|
9839
9418
|
return !(Boolean(stats) && (isRefinementsRangeIncludesInsideItemRange(stats, start, end) || isItemRangeIncludedInsideRefinementsRange(stats, start, end)));
|
|
9840
9419
|
}
|
|
9841
|
-
|
|
9842
9420
|
function _refine$5(props, searchState, nextRefinement, context) {
|
|
9843
9421
|
var nextValue = _defineProperty({}, getId$8(props), nextRefinement);
|
|
9844
|
-
|
|
9845
9422
|
var resetPage = true;
|
|
9846
9423
|
return refineValue(searchState, nextValue, context, resetPage, namespace$3);
|
|
9847
9424
|
}
|
|
9848
|
-
|
|
9849
9425
|
function _cleanUp$3(props, searchState, context) {
|
|
9850
9426
|
return cleanUpValue(searchState, context, "".concat(namespace$3, ".").concat(getId$8(props)));
|
|
9851
9427
|
}
|
|
9428
|
+
|
|
9852
9429
|
/**
|
|
9853
9430
|
* connectNumericMenu connector provides the logic to build a widget that will
|
|
9854
9431
|
* give the user the ability to select a range value for a numeric attribute.
|
|
@@ -9865,8 +9442,6 @@
|
|
|
9865
9442
|
* @providedPropType {string} currentRefinement - the refinement currently applied. follow the shape of a `string` with a pattern of `'{start}:{end}'` which corresponds to the current selected item. For instance, when the selected item is `{start: 10, end: 20}`, the searchState of the widget is `'10:20'`. When `start` isn't defined, the searchState of the widget is `':{end}'`, and the same way around when `end` isn't defined. However, when neither `start` nor `end` are defined, the searchState is an empty string.
|
|
9866
9443
|
* @providedPropType {array.<{isRefined: boolean, label: string, value: string, isRefined: boolean, noRefinement: boolean}>} items - the list of ranges the NumericMenu can display.
|
|
9867
9444
|
*/
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
9445
|
var connectNumericMenu = createConnectorWithContext({
|
|
9871
9446
|
displayName: 'AlgoliaNumericMenu',
|
|
9872
9447
|
$$type: 'ais.numericMenu',
|
|
@@ -9903,7 +9478,6 @@
|
|
|
9903
9478
|
var refinedItem = find(items, function (item) {
|
|
9904
9479
|
return item.isRefined === true;
|
|
9905
9480
|
});
|
|
9906
|
-
|
|
9907
9481
|
if (!items.some(function (item) {
|
|
9908
9482
|
return item.value === '';
|
|
9909
9483
|
})) {
|
|
@@ -9914,7 +9488,6 @@
|
|
|
9914
9488
|
label: 'All'
|
|
9915
9489
|
});
|
|
9916
9490
|
}
|
|
9917
|
-
|
|
9918
9491
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
9919
9492
|
return {
|
|
9920
9493
|
items: transformedItems,
|
|
@@ -9938,24 +9511,19 @@
|
|
|
9938
9511
|
},
|
|
9939
9512
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
9940
9513
|
var attribute = props.attribute;
|
|
9941
|
-
|
|
9942
9514
|
var _parseItem = parseItem(getCurrentRefinement$6(props, searchState, {
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9515
|
+
ais: props.contextValue,
|
|
9516
|
+
multiIndexContext: props.indexContextValue
|
|
9517
|
+
})),
|
|
9518
|
+
start = _parseItem.start,
|
|
9519
|
+
end = _parseItem.end;
|
|
9949
9520
|
searchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
9950
|
-
|
|
9951
9521
|
if (typeof start === 'number') {
|
|
9952
9522
|
searchParameters = searchParameters.addNumericRefinement(attribute, '>=', start);
|
|
9953
9523
|
}
|
|
9954
|
-
|
|
9955
9524
|
if (typeof end === 'number') {
|
|
9956
9525
|
searchParameters = searchParameters.addNumericRefinement(attribute, '<=', end);
|
|
9957
9526
|
}
|
|
9958
|
-
|
|
9959
9527
|
return searchParameters;
|
|
9960
9528
|
},
|
|
9961
9529
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9969,13 +9537,11 @@
|
|
|
9969
9537
|
ais: props.contextValue,
|
|
9970
9538
|
multiIndexContext: props.indexContextValue
|
|
9971
9539
|
});
|
|
9972
|
-
|
|
9973
9540
|
if (value !== '') {
|
|
9974
9541
|
var _find = find(props.items, function (item) {
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9542
|
+
return stringifyItem(item) === value;
|
|
9543
|
+
}),
|
|
9544
|
+
label = _find.label;
|
|
9979
9545
|
items.push({
|
|
9980
9546
|
label: "".concat(props.attribute, ": ").concat(label),
|
|
9981
9547
|
attribute: props.attribute,
|
|
@@ -9988,7 +9554,6 @@
|
|
|
9988
9554
|
}
|
|
9989
9555
|
});
|
|
9990
9556
|
}
|
|
9991
|
-
|
|
9992
9557
|
return {
|
|
9993
9558
|
id: id,
|
|
9994
9559
|
index: index,
|
|
@@ -10000,27 +9565,22 @@
|
|
|
10000
9565
|
function getId$9() {
|
|
10001
9566
|
return 'page';
|
|
10002
9567
|
}
|
|
10003
|
-
|
|
10004
9568
|
function getCurrentRefinement$7(props, searchState, context) {
|
|
10005
9569
|
var id = getId$9();
|
|
10006
9570
|
var page = 1;
|
|
10007
9571
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, page);
|
|
10008
|
-
|
|
10009
9572
|
if (typeof currentRefinement === 'string') {
|
|
10010
9573
|
return parseInt(currentRefinement, 10);
|
|
10011
9574
|
}
|
|
10012
|
-
|
|
10013
9575
|
return currentRefinement;
|
|
10014
9576
|
}
|
|
10015
|
-
|
|
10016
9577
|
function _refine$6(props, searchState, nextPage, context) {
|
|
10017
9578
|
var id = getId$9();
|
|
10018
|
-
|
|
10019
9579
|
var nextValue = _defineProperty({}, id, nextPage);
|
|
10020
|
-
|
|
10021
9580
|
var resetPage = false;
|
|
10022
9581
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
10023
9582
|
}
|
|
9583
|
+
|
|
10024
9584
|
/**
|
|
10025
9585
|
* connectPagination connector provides the logic to build a widget that will
|
|
10026
9586
|
* let the user displays hits corresponding to a certain page.
|
|
@@ -10037,8 +9597,6 @@
|
|
|
10037
9597
|
* @providedPropType {number} nbPages - the total of existing pages
|
|
10038
9598
|
* @providedPropType {number} currentRefinement - the page refinement currently applied
|
|
10039
9599
|
*/
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
9600
|
var connectPagination = createConnectorWithContext({
|
|
10043
9601
|
displayName: 'AlgoliaPagination',
|
|
10044
9602
|
$$type: 'ais.pagination',
|
|
@@ -10047,11 +9605,9 @@
|
|
|
10047
9605
|
ais: props.contextValue,
|
|
10048
9606
|
multiIndexContext: props.indexContextValue
|
|
10049
9607
|
});
|
|
10050
|
-
|
|
10051
9608
|
if (!results) {
|
|
10052
9609
|
return null;
|
|
10053
9610
|
}
|
|
10054
|
-
|
|
10055
9611
|
var nbPages = results.nbPages;
|
|
10056
9612
|
return {
|
|
10057
9613
|
nbPages: nbPages,
|
|
@@ -10094,7 +9650,6 @@
|
|
|
10094
9650
|
* @kind connector
|
|
10095
9651
|
* @providedPropType {string} url - the url to redirect to algolia
|
|
10096
9652
|
*/
|
|
10097
|
-
|
|
10098
9653
|
var connectPoweredBy = createConnectorWithContext({
|
|
10099
9654
|
displayName: 'AlgoliaPoweredBy',
|
|
10100
9655
|
$$type: 'ais.poweredBy',
|
|
@@ -10132,13 +9687,10 @@
|
|
|
10132
9687
|
function getId$a(props) {
|
|
10133
9688
|
return props.attribute;
|
|
10134
9689
|
}
|
|
10135
|
-
|
|
10136
9690
|
var namespace$4 = 'range';
|
|
10137
|
-
|
|
10138
9691
|
function getCurrentRange(boundaries, stats, precision) {
|
|
10139
9692
|
var pow = Math.pow(10, precision);
|
|
10140
9693
|
var min;
|
|
10141
|
-
|
|
10142
9694
|
if (typeof boundaries.min === 'number' && isFinite(boundaries.min)) {
|
|
10143
9695
|
min = boundaries.min;
|
|
10144
9696
|
} else if (typeof stats.min === 'number' && isFinite(stats.min)) {
|
|
@@ -10146,9 +9698,7 @@
|
|
|
10146
9698
|
} else {
|
|
10147
9699
|
min = undefined;
|
|
10148
9700
|
}
|
|
10149
|
-
|
|
10150
9701
|
var max;
|
|
10151
|
-
|
|
10152
9702
|
if (typeof boundaries.max === 'number' && isFinite(boundaries.max)) {
|
|
10153
9703
|
max = boundaries.max;
|
|
10154
9704
|
} else if (typeof stats.max === 'number' && isFinite(stats.max)) {
|
|
@@ -10156,31 +9706,24 @@
|
|
|
10156
9706
|
} else {
|
|
10157
9707
|
max = undefined;
|
|
10158
9708
|
}
|
|
10159
|
-
|
|
10160
9709
|
return {
|
|
10161
9710
|
min: min !== undefined ? Math.floor(min * pow) / pow : min,
|
|
10162
9711
|
max: max !== undefined ? Math.ceil(max * pow) / pow : max
|
|
10163
9712
|
};
|
|
10164
9713
|
}
|
|
10165
|
-
|
|
10166
9714
|
function getCurrentRefinement$8(props, searchState, currentRange, context) {
|
|
10167
9715
|
var _getCurrentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$4, ".").concat(getId$a(props)), {}),
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
9716
|
+
min = _getCurrentRefinement.min,
|
|
9717
|
+
max = _getCurrentRefinement.max;
|
|
10171
9718
|
var isFloatPrecision = Boolean(props.precision);
|
|
10172
9719
|
var nextMin = min;
|
|
10173
|
-
|
|
10174
9720
|
if (typeof nextMin === 'string') {
|
|
10175
9721
|
nextMin = isFloatPrecision ? parseFloat(nextMin) : parseInt(nextMin, 10);
|
|
10176
9722
|
}
|
|
10177
|
-
|
|
10178
9723
|
var nextMax = max;
|
|
10179
|
-
|
|
10180
9724
|
if (typeof nextMax === 'string') {
|
|
10181
9725
|
nextMax = isFloatPrecision ? parseFloat(nextMax) : parseInt(nextMax, 10);
|
|
10182
9726
|
}
|
|
10183
|
-
|
|
10184
9727
|
var refinement = {
|
|
10185
9728
|
min: nextMin,
|
|
10186
9729
|
max: nextMax
|
|
@@ -10189,36 +9732,28 @@
|
|
|
10189
9732
|
var hasMaxBound = props.max !== undefined;
|
|
10190
9733
|
var hasMinRefinment = refinement.min !== undefined;
|
|
10191
9734
|
var hasMaxRefinment = refinement.max !== undefined;
|
|
10192
|
-
|
|
10193
9735
|
if (hasMinBound && hasMinRefinment && refinement.min < currentRange.min) {
|
|
10194
9736
|
throw Error("You can't provide min value lower than range.");
|
|
10195
9737
|
}
|
|
10196
|
-
|
|
10197
9738
|
if (hasMaxBound && hasMaxRefinment && refinement.max > currentRange.max) {
|
|
10198
9739
|
throw Error("You can't provide max value greater than range.");
|
|
10199
9740
|
}
|
|
10200
|
-
|
|
10201
9741
|
if (hasMinBound && !hasMinRefinment) {
|
|
10202
9742
|
refinement.min = currentRange.min;
|
|
10203
9743
|
}
|
|
10204
|
-
|
|
10205
9744
|
if (hasMaxBound && !hasMaxRefinment) {
|
|
10206
9745
|
refinement.max = currentRange.max;
|
|
10207
9746
|
}
|
|
10208
|
-
|
|
10209
9747
|
return refinement;
|
|
10210
9748
|
}
|
|
10211
|
-
|
|
10212
9749
|
function getCurrentRefinementWithRange(refinement, range) {
|
|
10213
9750
|
return {
|
|
10214
9751
|
min: refinement.min !== undefined ? refinement.min : range.min,
|
|
10215
9752
|
max: refinement.max !== undefined ? refinement.max : range.max
|
|
10216
9753
|
};
|
|
10217
9754
|
}
|
|
10218
|
-
|
|
10219
9755
|
function nextValueForRefinement(hasBound, isReset, range, value) {
|
|
10220
9756
|
var next;
|
|
10221
|
-
|
|
10222
9757
|
if (!hasBound && range === value) {
|
|
10223
9758
|
next = undefined;
|
|
10224
9759
|
} else if (hasBound && isReset) {
|
|
@@ -10226,49 +9761,39 @@
|
|
|
10226
9761
|
} else {
|
|
10227
9762
|
next = value;
|
|
10228
9763
|
}
|
|
10229
|
-
|
|
10230
9764
|
return next;
|
|
10231
9765
|
}
|
|
10232
|
-
|
|
10233
9766
|
function _refine$7(props, searchState, nextRefinement, currentRange, context) {
|
|
10234
9767
|
var nextMin = nextRefinement.min,
|
|
10235
|
-
|
|
9768
|
+
nextMax = nextRefinement.max;
|
|
10236
9769
|
var currentMinRange = currentRange.min,
|
|
10237
|
-
|
|
9770
|
+
currentMaxRange = currentRange.max;
|
|
10238
9771
|
var isMinReset = nextMin === undefined || nextMin === '';
|
|
10239
9772
|
var isMaxReset = nextMax === undefined || nextMax === '';
|
|
10240
9773
|
var nextMinAsNumber = !isMinReset ? parseFloat(nextMin) : undefined;
|
|
10241
9774
|
var nextMaxAsNumber = !isMaxReset ? parseFloat(nextMax) : undefined;
|
|
10242
9775
|
var isNextMinValid = isMinReset || isFinite(nextMinAsNumber);
|
|
10243
9776
|
var isNextMaxValid = isMaxReset || isFinite(nextMaxAsNumber);
|
|
10244
|
-
|
|
10245
9777
|
if (!isNextMinValid || !isNextMaxValid) {
|
|
10246
9778
|
throw Error("You can't provide non finite values to the range connector.");
|
|
10247
9779
|
}
|
|
10248
|
-
|
|
10249
9780
|
if (nextMinAsNumber < currentMinRange) {
|
|
10250
9781
|
throw Error("You can't provide min value lower than range.");
|
|
10251
9782
|
}
|
|
10252
|
-
|
|
10253
9783
|
if (nextMaxAsNumber > currentMaxRange) {
|
|
10254
9784
|
throw Error("You can't provide max value greater than range.");
|
|
10255
9785
|
}
|
|
10256
|
-
|
|
10257
9786
|
var id = getId$a(props);
|
|
10258
9787
|
var resetPage = true;
|
|
10259
|
-
|
|
10260
9788
|
var nextValue = _defineProperty({}, id, {
|
|
10261
9789
|
min: nextValueForRefinement(props.min !== undefined, isMinReset, currentMinRange, nextMinAsNumber),
|
|
10262
9790
|
max: nextValueForRefinement(props.max !== undefined, isMaxReset, currentMaxRange, nextMaxAsNumber)
|
|
10263
9791
|
});
|
|
10264
|
-
|
|
10265
9792
|
return refineValue(searchState, nextValue, context, resetPage, namespace$4);
|
|
10266
9793
|
}
|
|
10267
|
-
|
|
10268
9794
|
function _cleanUp$4(props, searchState, context) {
|
|
10269
9795
|
return cleanUpValue(searchState, context, "".concat(namespace$4, ".").concat(getId$a(props)));
|
|
10270
9796
|
}
|
|
10271
|
-
|
|
10272
9797
|
var connectRange = createConnectorWithContext({
|
|
10273
9798
|
displayName: 'AlgoliaRange',
|
|
10274
9799
|
$$type: 'ais.range',
|
|
@@ -10290,9 +9815,9 @@
|
|
|
10290
9815
|
},
|
|
10291
9816
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
10292
9817
|
var attribute = props.attribute,
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
9818
|
+
precision = props.precision,
|
|
9819
|
+
minBound = props.min,
|
|
9820
|
+
maxBound = props.max;
|
|
10296
9821
|
var results = getResults(searchResults, {
|
|
10297
9822
|
ais: props.contextValue,
|
|
10298
9823
|
multiIndexContext: props.indexContextValue
|
|
@@ -10306,18 +9831,17 @@
|
|
|
10306
9831
|
count: v.count
|
|
10307
9832
|
};
|
|
10308
9833
|
});
|
|
10309
|
-
|
|
10310
9834
|
var _getCurrentRange = getCurrentRange({
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
9835
|
+
min: minBound,
|
|
9836
|
+
max: maxBound
|
|
9837
|
+
}, stats, precision),
|
|
9838
|
+
rangeMin = _getCurrentRange.min,
|
|
9839
|
+
rangeMax = _getCurrentRange.max;
|
|
9840
|
+
|
|
9841
|
+
// The searchState is not always in sync with the helper state. For example
|
|
10316
9842
|
// when we set boundaries on the first render the searchState don't have
|
|
10317
9843
|
// the correct refinement. If this behavior change in the upcoming version
|
|
10318
9844
|
// we could store the range inside the searchState instead of rely on `this`.
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
9845
|
this._currentRange = {
|
|
10322
9846
|
min: rangeMin,
|
|
10323
9847
|
max: rangeMax
|
|
@@ -10349,46 +9873,37 @@
|
|
|
10349
9873
|
},
|
|
10350
9874
|
getSearchParameters: function getSearchParameters(params, props, searchState) {
|
|
10351
9875
|
var attribute = props.attribute;
|
|
10352
|
-
|
|
10353
9876
|
var _getCurrentRefinement2 = getCurrentRefinement$8(props, searchState, this._currentRange, {
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
9877
|
+
ais: props.contextValue,
|
|
9878
|
+
multiIndexContext: props.indexContextValue
|
|
9879
|
+
}),
|
|
9880
|
+
min = _getCurrentRefinement2.min,
|
|
9881
|
+
max = _getCurrentRefinement2.max;
|
|
10360
9882
|
params = params.addDisjunctiveFacet(attribute);
|
|
10361
|
-
|
|
10362
9883
|
if (min !== undefined) {
|
|
10363
9884
|
params = params.addNumericRefinement(attribute, '>=', min);
|
|
10364
9885
|
}
|
|
10365
|
-
|
|
10366
9886
|
if (max !== undefined) {
|
|
10367
9887
|
params = params.addNumericRefinement(attribute, '<=', max);
|
|
10368
9888
|
}
|
|
10369
|
-
|
|
10370
9889
|
return params;
|
|
10371
9890
|
},
|
|
10372
9891
|
getMetadata: function getMetadata(props, searchState) {
|
|
10373
9892
|
var _this = this;
|
|
10374
|
-
|
|
10375
9893
|
var _this$_currentRange = this._currentRange,
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
9894
|
+
minRange = _this$_currentRange.min,
|
|
9895
|
+
maxRange = _this$_currentRange.max;
|
|
10379
9896
|
var _getCurrentRefinement3 = getCurrentRefinement$8(props, searchState, this._currentRange, {
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
9897
|
+
ais: props.contextValue,
|
|
9898
|
+
multiIndexContext: props.indexContextValue
|
|
9899
|
+
}),
|
|
9900
|
+
minValue = _getCurrentRefinement3.min,
|
|
9901
|
+
maxValue = _getCurrentRefinement3.max;
|
|
10386
9902
|
var items = [];
|
|
10387
9903
|
var hasMin = minValue !== undefined;
|
|
10388
9904
|
var hasMax = maxValue !== undefined;
|
|
10389
9905
|
var shouldDisplayMinLabel = hasMin && minValue !== minRange;
|
|
10390
9906
|
var shouldDisplayMaxLabel = hasMax && maxValue !== maxRange;
|
|
10391
|
-
|
|
10392
9907
|
if (shouldDisplayMinLabel || shouldDisplayMaxLabel) {
|
|
10393
9908
|
var fragments = [hasMin ? "".concat(minValue, " <= ") : '', props.attribute, hasMax ? " <= ".concat(maxValue) : ''];
|
|
10394
9909
|
items.push({
|
|
@@ -10409,7 +9924,6 @@
|
|
|
10409
9924
|
})
|
|
10410
9925
|
});
|
|
10411
9926
|
}
|
|
10412
|
-
|
|
10413
9927
|
return {
|
|
10414
9928
|
id: getId$a(props),
|
|
10415
9929
|
index: getIndexId({
|
|
@@ -10422,25 +9936,19 @@
|
|
|
10422
9936
|
});
|
|
10423
9937
|
|
|
10424
9938
|
var namespace$5 = 'refinementList';
|
|
10425
|
-
|
|
10426
9939
|
function getId$b(props) {
|
|
10427
9940
|
return props.attribute;
|
|
10428
9941
|
}
|
|
10429
|
-
|
|
10430
9942
|
function getCurrentRefinement$9(props, searchState, context) {
|
|
10431
9943
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$5, ".").concat(getId$b(props)), []);
|
|
10432
|
-
|
|
10433
9944
|
if (typeof currentRefinement !== 'string') {
|
|
10434
9945
|
return currentRefinement;
|
|
10435
9946
|
}
|
|
10436
|
-
|
|
10437
9947
|
if (currentRefinement) {
|
|
10438
9948
|
return [currentRefinement];
|
|
10439
9949
|
}
|
|
10440
|
-
|
|
10441
9950
|
return [];
|
|
10442
9951
|
}
|
|
10443
|
-
|
|
10444
9952
|
function getValue$2(value, props, searchState, context) {
|
|
10445
9953
|
var currentRefinement = getCurrentRefinement$9(props, searchState, context);
|
|
10446
9954
|
var isAnewValue = currentRefinement.indexOf(value) === -1;
|
|
@@ -10448,32 +9956,27 @@
|
|
|
10448
9956
|
: currentRefinement.filter(function (selectedValue) {
|
|
10449
9957
|
return selectedValue !== value;
|
|
10450
9958
|
}); // cannot use .splice(), it mutates
|
|
10451
|
-
|
|
10452
9959
|
return nextRefinement;
|
|
10453
9960
|
}
|
|
10454
|
-
|
|
10455
9961
|
function getLimit$1(_ref) {
|
|
10456
9962
|
var showMore = _ref.showMore,
|
|
10457
|
-
|
|
10458
|
-
|
|
9963
|
+
limit = _ref.limit,
|
|
9964
|
+
showMoreLimit = _ref.showMoreLimit;
|
|
10459
9965
|
return showMore ? showMoreLimit : limit;
|
|
10460
9966
|
}
|
|
10461
|
-
|
|
10462
9967
|
function _refine$8(props, searchState, nextRefinement, context) {
|
|
10463
|
-
var id = getId$b(props);
|
|
9968
|
+
var id = getId$b(props);
|
|
9969
|
+
// Setting the value to an empty string ensures that it is persisted in
|
|
10464
9970
|
// the URL as an empty value.
|
|
10465
9971
|
// This is necessary in the case where `defaultRefinement` contains one
|
|
10466
9972
|
// item and we try to deselect it. `nextSelected` would be an empty array,
|
|
10467
9973
|
// which would not be persisted to the URL.
|
|
10468
9974
|
// {foo: ['bar']} => "foo[0]=bar"
|
|
10469
9975
|
// {foo: []} => ""
|
|
10470
|
-
|
|
10471
9976
|
var nextValue = _defineProperty({}, id, nextRefinement.length > 0 ? nextRefinement : '');
|
|
10472
|
-
|
|
10473
9977
|
var resetPage = true;
|
|
10474
9978
|
return refineValue(searchState, nextValue, context, resetPage, namespace$5);
|
|
10475
9979
|
}
|
|
10476
|
-
|
|
10477
9980
|
function _cleanUp$5(props, searchState, context) {
|
|
10478
9981
|
return cleanUpValue(searchState, context, "".concat(namespace$5, ".").concat(getId$b(props)));
|
|
10479
9982
|
}
|
|
@@ -10501,7 +10004,6 @@
|
|
|
10501
10004
|
* @providedPropType {boolean} canRefine - a boolean that says whether you can refine
|
|
10502
10005
|
*/
|
|
10503
10006
|
|
|
10504
|
-
|
|
10505
10007
|
var sortBy$1 = ['isRefined', 'count:desc', 'name:asc'];
|
|
10506
10008
|
var connectRefinementList = createConnectorWithContext({
|
|
10507
10009
|
displayName: 'AlgoliaRefinementList',
|
|
@@ -10527,20 +10029,20 @@
|
|
|
10527
10029
|
},
|
|
10528
10030
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults, metadata, searchForFacetValuesResults) {
|
|
10529
10031
|
var attribute = props.attribute,
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10032
|
+
searchable = props.searchable,
|
|
10033
|
+
indexContextValue = props.indexContextValue,
|
|
10034
|
+
facetOrdering = props.facetOrdering;
|
|
10533
10035
|
var results = getResults(searchResults, {
|
|
10534
10036
|
ais: props.contextValue,
|
|
10535
10037
|
multiIndexContext: props.indexContextValue
|
|
10536
10038
|
});
|
|
10537
10039
|
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
10538
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
10040
|
+
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
10539
10041
|
|
|
10042
|
+
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
10540
10043
|
if (searchable && indexContextValue) {
|
|
10541
10044
|
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
10542
10045
|
}
|
|
10543
|
-
|
|
10544
10046
|
if (!canRefine) {
|
|
10545
10047
|
return {
|
|
10546
10048
|
items: [],
|
|
@@ -10553,7 +10055,6 @@
|
|
|
10553
10055
|
searchable: searchable
|
|
10554
10056
|
};
|
|
10555
10057
|
}
|
|
10556
|
-
|
|
10557
10058
|
var items = isFromSearch ? searchForFacetValuesResults[attribute].map(function (v) {
|
|
10558
10059
|
return {
|
|
10559
10060
|
label: v.value,
|
|
@@ -10616,7 +10117,7 @@
|
|
|
10616
10117
|
},
|
|
10617
10118
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
10618
10119
|
var attribute = props.attribute,
|
|
10619
|
-
|
|
10120
|
+
operator = props.operator;
|
|
10620
10121
|
var addKey = operator === 'and' ? 'addFacet' : 'addDisjunctiveFacet';
|
|
10621
10122
|
var addRefinementKey = "".concat(addKey, "Refinement");
|
|
10622
10123
|
searchParameters = searchParameters.setQueryParameters({
|
|
@@ -10671,7 +10172,6 @@
|
|
|
10671
10172
|
* @providedPropType {any} value - the current refinement applied to the widget listened by scrollTo
|
|
10672
10173
|
* @providedPropType {boolean} hasNotChanged - indicates whether the refinement came from the scrollOn argument (for instance page by default)
|
|
10673
10174
|
*/
|
|
10674
|
-
|
|
10675
10175
|
var connectScrollTo = createConnectorWithContext({
|
|
10676
10176
|
displayName: 'AlgoliaScrollTo',
|
|
10677
10177
|
$$type: 'ais.scrollTo',
|
|
@@ -10687,12 +10187,11 @@
|
|
|
10687
10187
|
ais: props.contextValue,
|
|
10688
10188
|
multiIndexContext: props.indexContextValue
|
|
10689
10189
|
}, id, null);
|
|
10690
|
-
|
|
10691
10190
|
if (!this._prevSearchState) {
|
|
10692
10191
|
this._prevSearchState = {};
|
|
10693
|
-
}
|
|
10694
|
-
|
|
10192
|
+
}
|
|
10695
10193
|
|
|
10194
|
+
// Get the subpart of the state that interest us
|
|
10696
10195
|
if (hasMultipleIndices({
|
|
10697
10196
|
ais: props.contextValue,
|
|
10698
10197
|
multiIndexContext: props.indexContextValue
|
|
@@ -10701,7 +10200,9 @@
|
|
|
10701
10200
|
ais: props.contextValue,
|
|
10702
10201
|
multiIndexContext: props.indexContextValue
|
|
10703
10202
|
})] : {};
|
|
10704
|
-
}
|
|
10203
|
+
}
|
|
10204
|
+
|
|
10205
|
+
// if there is a change in the app that has been triggered by another element
|
|
10705
10206
|
// than "props.scrollOn (id) or the Configure widget, we need to keep track of
|
|
10706
10207
|
// the search state to know if there's a change in the app that was not triggered
|
|
10707
10208
|
// by the props.scrollOn (id) or the Configure widget. This is useful when
|
|
@@ -10711,8 +10212,6 @@
|
|
|
10711
10212
|
// do this comparison because for now configure values are not present in the
|
|
10712
10213
|
// search state before a first refinement has been made and will false the results.
|
|
10713
10214
|
// See: https://github.com/algolia/react-instantsearch/issues/164
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
10215
|
var cleanedSearchState = omit(searchState, ['configure', id]);
|
|
10717
10216
|
var hasNotChanged = shallowEqual(this._prevSearchState, cleanedSearchState);
|
|
10718
10217
|
this._prevSearchState = cleanedSearchState;
|
|
@@ -10726,30 +10225,24 @@
|
|
|
10726
10225
|
function getId$c() {
|
|
10727
10226
|
return 'query';
|
|
10728
10227
|
}
|
|
10729
|
-
|
|
10730
10228
|
function getCurrentRefinement$a(props, searchState, context) {
|
|
10731
10229
|
var id = getId$c();
|
|
10732
10230
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
10733
|
-
|
|
10734
10231
|
if (currentRefinement) {
|
|
10735
10232
|
return currentRefinement;
|
|
10736
10233
|
}
|
|
10737
|
-
|
|
10738
10234
|
return '';
|
|
10739
10235
|
}
|
|
10740
|
-
|
|
10741
10236
|
function _refine$9(props, searchState, nextRefinement, context) {
|
|
10742
10237
|
var id = getId$c();
|
|
10743
|
-
|
|
10744
10238
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
10745
|
-
|
|
10746
10239
|
var resetPage = true;
|
|
10747
10240
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
10748
10241
|
}
|
|
10749
|
-
|
|
10750
10242
|
function _cleanUp$6(props, searchState, context) {
|
|
10751
10243
|
return cleanUpValue(searchState, context, getId$c());
|
|
10752
10244
|
}
|
|
10245
|
+
|
|
10753
10246
|
/**
|
|
10754
10247
|
* connectSearchBox connector provides the logic to build a widget that will
|
|
10755
10248
|
* let the user search for a query
|
|
@@ -10760,8 +10253,6 @@
|
|
|
10760
10253
|
* @providedPropType {string} currentRefinement - the current query used
|
|
10761
10254
|
* @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled
|
|
10762
10255
|
*/
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
10256
|
var connectSearchBox = createConnectorWithContext({
|
|
10766
10257
|
displayName: 'AlgoliaSearchBox',
|
|
10767
10258
|
$$type: 'ais.searchBox',
|
|
@@ -10824,13 +10315,11 @@
|
|
|
10824
10315
|
function getId$d() {
|
|
10825
10316
|
return 'relevancyStrictness';
|
|
10826
10317
|
}
|
|
10827
|
-
|
|
10828
10318
|
function getCurrentRefinement$b(props, searchState, context) {
|
|
10829
10319
|
var id = getId$d();
|
|
10830
10320
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id);
|
|
10831
10321
|
return currentRefinement;
|
|
10832
10322
|
}
|
|
10833
|
-
|
|
10834
10323
|
var connectRelevantSort = createConnectorWithContext({
|
|
10835
10324
|
displayName: 'AlgoliaRelevantSort',
|
|
10836
10325
|
$$type: 'ais.relevantSort',
|
|
@@ -10839,14 +10328,12 @@
|
|
|
10839
10328
|
ais: props.contextValue,
|
|
10840
10329
|
multiIndexContext: props.indexContextValue
|
|
10841
10330
|
});
|
|
10842
|
-
|
|
10843
10331
|
if (!results) {
|
|
10844
10332
|
return {
|
|
10845
10333
|
isVirtualReplica: false,
|
|
10846
10334
|
isRelevantSorted: false
|
|
10847
10335
|
};
|
|
10848
10336
|
}
|
|
10849
|
-
|
|
10850
10337
|
return {
|
|
10851
10338
|
isVirtualReplica: results.appliedRelevancyStrictness !== undefined,
|
|
10852
10339
|
isRelevantSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0
|
|
@@ -10860,7 +10347,6 @@
|
|
|
10860
10347
|
},
|
|
10861
10348
|
refine: function refine(props, searchState, nextRefinement) {
|
|
10862
10349
|
var nextValue = _defineProperty({}, getId$d(), nextRefinement);
|
|
10863
|
-
|
|
10864
10350
|
var resetPage = true;
|
|
10865
10351
|
return refineValue(searchState, nextValue, {
|
|
10866
10352
|
ais: props.contextValue,
|
|
@@ -10869,24 +10355,18 @@
|
|
|
10869
10355
|
}
|
|
10870
10356
|
});
|
|
10871
10357
|
|
|
10872
|
-
function ownKeys$a(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; }
|
|
10873
|
-
|
|
10874
|
-
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10875
|
-
|
|
10876
10358
|
function getId$e() {
|
|
10877
10359
|
return 'sortBy';
|
|
10878
10360
|
}
|
|
10879
|
-
|
|
10880
10361
|
function getCurrentRefinement$c(props, searchState, context) {
|
|
10881
10362
|
var id = getId$e();
|
|
10882
10363
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
10883
|
-
|
|
10884
10364
|
if (currentRefinement) {
|
|
10885
10365
|
return currentRefinement;
|
|
10886
10366
|
}
|
|
10887
|
-
|
|
10888
10367
|
return null;
|
|
10889
10368
|
}
|
|
10369
|
+
|
|
10890
10370
|
/**
|
|
10891
10371
|
* The connectSortBy connector provides the logic to build a widget that will
|
|
10892
10372
|
* display a list of indices. This allows a user to change how the hits are being sorted.
|
|
@@ -10902,8 +10382,6 @@
|
|
|
10902
10382
|
* @providedPropType {string[]} currentRefinement - the refinement currently applied
|
|
10903
10383
|
* @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.
|
|
10904
10384
|
*/
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
10385
|
var connectSortBy = createConnectorWithContext({
|
|
10908
10386
|
displayName: 'AlgoliaSortBy',
|
|
10909
10387
|
$$type: 'ais.sortBy',
|
|
@@ -10921,9 +10399,9 @@
|
|
|
10921
10399
|
multiIndexContext: props.indexContextValue
|
|
10922
10400
|
});
|
|
10923
10401
|
var items = props.items.map(function (item) {
|
|
10924
|
-
return item.value === currentRefinement ?
|
|
10402
|
+
return item.value === currentRefinement ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10925
10403
|
isRefined: true
|
|
10926
|
-
}) :
|
|
10404
|
+
}) : _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10927
10405
|
isRefined: false
|
|
10928
10406
|
});
|
|
10929
10407
|
});
|
|
@@ -10934,9 +10412,7 @@
|
|
|
10934
10412
|
},
|
|
10935
10413
|
refine: function refine(props, searchState, nextRefinement) {
|
|
10936
10414
|
var id = getId$e();
|
|
10937
|
-
|
|
10938
10415
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
10939
|
-
|
|
10940
10416
|
var resetPage = true;
|
|
10941
10417
|
return refineValue(searchState, nextValue, {
|
|
10942
10418
|
ais: props.contextValue,
|
|
@@ -11012,7 +10488,6 @@
|
|
|
11012
10488
|
* </InstantSearch>
|
|
11013
10489
|
* );
|
|
11014
10490
|
*/
|
|
11015
|
-
|
|
11016
10491
|
var connectStateResults = createConnectorWithContext({
|
|
11017
10492
|
displayName: 'AlgoliaStateResults',
|
|
11018
10493
|
$$type: 'ais.stateResults',
|
|
@@ -11043,7 +10518,6 @@
|
|
|
11043
10518
|
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia.
|
|
11044
10519
|
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results.
|
|
11045
10520
|
*/
|
|
11046
|
-
|
|
11047
10521
|
var connectStats = createConnectorWithContext({
|
|
11048
10522
|
displayName: 'AlgoliaStats',
|
|
11049
10523
|
$$type: 'ais.stats',
|
|
@@ -11052,11 +10526,9 @@
|
|
|
11052
10526
|
ais: props.contextValue,
|
|
11053
10527
|
multiIndexContext: props.indexContextValue
|
|
11054
10528
|
});
|
|
11055
|
-
|
|
11056
10529
|
if (!results) {
|
|
11057
10530
|
return null;
|
|
11058
10531
|
}
|
|
11059
|
-
|
|
11060
10532
|
return {
|
|
11061
10533
|
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits,
|
|
11062
10534
|
nbHits: results.nbHits,
|
|
@@ -11069,32 +10541,25 @@
|
|
|
11069
10541
|
function getId$f(props) {
|
|
11070
10542
|
return props.attribute;
|
|
11071
10543
|
}
|
|
11072
|
-
|
|
11073
10544
|
var namespace$6 = 'toggle';
|
|
11074
10545
|
var falsyStrings = ['0', 'false', 'null', 'undefined'];
|
|
11075
|
-
|
|
11076
10546
|
function getCurrentRefinement$d(props, searchState, context) {
|
|
11077
10547
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$6, ".").concat(getId$f(props)), false);
|
|
11078
|
-
|
|
11079
10548
|
if (falsyStrings.indexOf(currentRefinement) !== -1) {
|
|
11080
10549
|
return false;
|
|
11081
10550
|
}
|
|
11082
|
-
|
|
11083
10551
|
return Boolean(currentRefinement);
|
|
11084
10552
|
}
|
|
11085
|
-
|
|
11086
10553
|
function _refine$a(props, searchState, nextRefinement, context) {
|
|
11087
10554
|
var id = getId$f(props);
|
|
11088
|
-
|
|
11089
10555
|
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : false);
|
|
11090
|
-
|
|
11091
10556
|
var resetPage = true;
|
|
11092
10557
|
return refineValue(searchState, nextValue, context, resetPage, namespace$6);
|
|
11093
10558
|
}
|
|
11094
|
-
|
|
11095
10559
|
function _cleanUp$7(props, searchState, context) {
|
|
11096
10560
|
return cleanUpValue(searchState, context, "".concat(namespace$6, ".").concat(getId$f(props)));
|
|
11097
10561
|
}
|
|
10562
|
+
|
|
11098
10563
|
/**
|
|
11099
10564
|
* connectToggleRefinement connector provides the logic to build a widget that will
|
|
11100
10565
|
* provides an on/off filtering feature based on an attribute value.
|
|
@@ -11114,8 +10579,6 @@
|
|
|
11114
10579
|
* @providedPropType {function} refine - a function to toggle a refinement
|
|
11115
10580
|
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
11116
10581
|
*/
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
10582
|
var connectToggleRefinement = createConnectorWithContext({
|
|
11120
10583
|
displayName: 'AlgoliaToggle',
|
|
11121
10584
|
$$type: 'ais.toggle',
|
|
@@ -11128,7 +10591,7 @@
|
|
|
11128
10591
|
},
|
|
11129
10592
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
11130
10593
|
var attribute = props.attribute,
|
|
11131
|
-
|
|
10594
|
+
value = props.value;
|
|
11132
10595
|
var results = getResults(searchResults, {
|
|
11133
10596
|
ais: props.contextValue,
|
|
11134
10597
|
multiIndexContext: props.indexContextValue
|
|
@@ -11138,13 +10601,15 @@
|
|
|
11138
10601
|
multiIndexContext: props.indexContextValue
|
|
11139
10602
|
});
|
|
11140
10603
|
var allFacetValues = results && results.getFacetByName(attribute) ? results.getFacetValues(attribute) : null;
|
|
11141
|
-
var facetValue =
|
|
10604
|
+
var facetValue =
|
|
10605
|
+
// Use null to always be consistent with type of the value
|
|
11142
10606
|
// count: number | null
|
|
11143
10607
|
allFacetValues && allFacetValues.length ? find(allFacetValues, function (item) {
|
|
11144
10608
|
return item.name === value.toString();
|
|
11145
10609
|
}) : null;
|
|
11146
10610
|
var facetValueCount = facetValue && facetValue.count;
|
|
11147
|
-
var allFacetValuesCount =
|
|
10611
|
+
var allFacetValuesCount =
|
|
10612
|
+
// Use null to always be consistent with type of the value
|
|
11148
10613
|
// count: number | null
|
|
11149
10614
|
allFacetValues && allFacetValues.length ? allFacetValues.reduce(function (acc, item) {
|
|
11150
10615
|
return acc + item.count;
|
|
@@ -11174,22 +10639,19 @@
|
|
|
11174
10639
|
},
|
|
11175
10640
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
11176
10641
|
var attribute = props.attribute,
|
|
11177
|
-
|
|
11178
|
-
|
|
10642
|
+
value = props.value,
|
|
10643
|
+
filter = props.filter;
|
|
11179
10644
|
var checked = getCurrentRefinement$d(props, searchState, {
|
|
11180
10645
|
ais: props.contextValue,
|
|
11181
10646
|
multiIndexContext: props.indexContextValue
|
|
11182
10647
|
});
|
|
11183
10648
|
var nextSearchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
11184
|
-
|
|
11185
10649
|
if (checked) {
|
|
11186
10650
|
nextSearchParameters = nextSearchParameters.addDisjunctiveFacetRefinement(attribute, value);
|
|
11187
|
-
|
|
11188
10651
|
if (filter) {
|
|
11189
10652
|
nextSearchParameters = filter(nextSearchParameters);
|
|
11190
10653
|
}
|
|
11191
10654
|
}
|
|
11192
|
-
|
|
11193
10655
|
return nextSearchParameters;
|
|
11194
10656
|
},
|
|
11195
10657
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -11203,7 +10665,6 @@
|
|
|
11203
10665
|
ais: props.contextValue,
|
|
11204
10666
|
multiIndexContext: props.indexContextValue
|
|
11205
10667
|
});
|
|
11206
|
-
|
|
11207
10668
|
if (checked) {
|
|
11208
10669
|
items.push({
|
|
11209
10670
|
label: props.label,
|
|
@@ -11217,7 +10678,6 @@
|
|
|
11217
10678
|
}
|
|
11218
10679
|
});
|
|
11219
10680
|
}
|
|
11220
|
-
|
|
11221
10681
|
return {
|
|
11222
10682
|
id: id,
|
|
11223
10683
|
index: index,
|
|
@@ -11226,22 +10686,16 @@
|
|
|
11226
10686
|
}
|
|
11227
10687
|
});
|
|
11228
10688
|
|
|
11229
|
-
function ownKeys$b(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; }
|
|
11230
|
-
|
|
11231
|
-
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11232
|
-
|
|
11233
10689
|
function inferPayload(_ref) {
|
|
11234
10690
|
var method = _ref.method,
|
|
11235
|
-
|
|
11236
|
-
|
|
10691
|
+
results = _ref.results,
|
|
10692
|
+
currentHit = _ref.currentHit;
|
|
11237
10693
|
var index = results.index;
|
|
11238
10694
|
var queryID = currentHit.__queryID;
|
|
11239
10695
|
var objectIDs = [currentHit.objectID];
|
|
11240
|
-
|
|
11241
10696
|
if (!queryID) {
|
|
11242
10697
|
throw new Error("Could not infer `queryID`. Ensure `clickAnalytics: true` was added with the Configure widget.\nSee: https://alg.li/VpPpLt");
|
|
11243
10698
|
}
|
|
11244
|
-
|
|
11245
10699
|
switch (method) {
|
|
11246
10700
|
case 'clickedObjectIDsAfterSearch':
|
|
11247
10701
|
{
|
|
@@ -11253,34 +10707,29 @@
|
|
|
11253
10707
|
positions: positions
|
|
11254
10708
|
};
|
|
11255
10709
|
}
|
|
11256
|
-
|
|
11257
10710
|
case 'convertedObjectIDsAfterSearch':
|
|
11258
10711
|
return {
|
|
11259
10712
|
index: index,
|
|
11260
10713
|
queryID: queryID,
|
|
11261
10714
|
objectIDs: objectIDs
|
|
11262
10715
|
};
|
|
11263
|
-
|
|
11264
10716
|
default:
|
|
11265
10717
|
throw new Error("Unsupported method \"".concat(method, "\" passed to the insights function. The supported methods are: \"clickedObjectIDsAfterSearch\", \"convertedObjectIDsAfterSearch\"."));
|
|
11266
10718
|
}
|
|
11267
10719
|
}
|
|
11268
|
-
|
|
11269
10720
|
var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
|
|
11270
10721
|
return function (method, payload) {
|
|
11271
10722
|
if (typeof aa !== 'function') {
|
|
11272
10723
|
throw new TypeError("Expected insightsClient to be a Function");
|
|
11273
10724
|
}
|
|
11274
|
-
|
|
11275
10725
|
var inferredPayload = inferPayload({
|
|
11276
10726
|
method: method,
|
|
11277
10727
|
results: results,
|
|
11278
10728
|
currentHit: currentHit
|
|
11279
10729
|
});
|
|
11280
|
-
aa(method,
|
|
10730
|
+
aa(method, _objectSpread2(_objectSpread2({}, inferredPayload), payload));
|
|
11281
10731
|
};
|
|
11282
10732
|
};
|
|
11283
|
-
|
|
11284
10733
|
var connectHitInsights = (function (insightsClient) {
|
|
11285
10734
|
return createConnectorWithContext({
|
|
11286
10735
|
displayName: 'AlgoliaInsights',
|
|
@@ -11298,65 +10747,50 @@
|
|
|
11298
10747
|
});
|
|
11299
10748
|
});
|
|
11300
10749
|
|
|
11301
|
-
function ownKeys$c(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; }
|
|
11302
|
-
|
|
11303
|
-
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11304
|
-
|
|
11305
10750
|
function getId$g() {
|
|
11306
10751
|
return 'query';
|
|
11307
10752
|
}
|
|
11308
|
-
|
|
11309
10753
|
function getAdditionalId() {
|
|
11310
10754
|
return 'additionalVoiceParameters';
|
|
11311
10755
|
}
|
|
11312
|
-
|
|
11313
10756
|
function getCurrentRefinementQuery(props, searchState, context) {
|
|
11314
10757
|
var id = getId$g();
|
|
11315
10758
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
11316
|
-
|
|
11317
10759
|
if (currentRefinement) {
|
|
11318
10760
|
return currentRefinement;
|
|
11319
10761
|
}
|
|
11320
|
-
|
|
11321
10762
|
return '';
|
|
11322
10763
|
}
|
|
11323
|
-
|
|
11324
10764
|
function getCurrentRefinementAdditional(props, searchState, context) {
|
|
11325
10765
|
var id = getAdditionalId();
|
|
11326
10766
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
11327
|
-
|
|
11328
10767
|
if (currentRefinement) {
|
|
11329
10768
|
return currentRefinement;
|
|
11330
10769
|
}
|
|
11331
|
-
|
|
11332
10770
|
return {};
|
|
11333
10771
|
}
|
|
11334
|
-
|
|
11335
10772
|
function _refine$b(props, searchState, nextRefinement, context) {
|
|
11336
10773
|
var _nextValue;
|
|
11337
|
-
|
|
11338
10774
|
var id = getId$g();
|
|
11339
10775
|
var voiceParams = getAdditionalId();
|
|
11340
10776
|
var queryLanguages = props.language ? {
|
|
11341
10777
|
queryLanguages: [props.language.split('-')[0]]
|
|
11342
10778
|
} : {};
|
|
11343
|
-
var additionalQueryParameters = typeof props.additionalQueryParameters === 'function' ?
|
|
10779
|
+
var additionalQueryParameters = typeof props.additionalQueryParameters === 'function' ? _objectSpread2({
|
|
11344
10780
|
ignorePlurals: true,
|
|
11345
10781
|
removeStopWords: true,
|
|
11346
10782
|
optionalWords: nextRefinement
|
|
11347
10783
|
}, props.additionalQueryParameters({
|
|
11348
10784
|
query: nextRefinement
|
|
11349
10785
|
})) : {};
|
|
11350
|
-
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams,
|
|
10786
|
+
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams, _objectSpread2(_objectSpread2({}, queryLanguages), additionalQueryParameters)), _nextValue);
|
|
11351
10787
|
var resetPage = true;
|
|
11352
10788
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
11353
10789
|
}
|
|
11354
|
-
|
|
11355
10790
|
function _cleanUp$8(props, searchState, context) {
|
|
11356
10791
|
var interimState = cleanUpValue(searchState, context, getId$g());
|
|
11357
10792
|
return cleanUpValue(interimState, context, getAdditionalId());
|
|
11358
10793
|
}
|
|
11359
|
-
|
|
11360
10794
|
var connectVoiceSearch = createConnectorWithContext({
|
|
11361
10795
|
displayName: 'AlgoliaVoiceSearch',
|
|
11362
10796
|
$$type: 'ais.voiceSearch',
|
|
@@ -11423,10 +10857,8 @@
|
|
|
11423
10857
|
|
|
11424
10858
|
// Core
|
|
11425
10859
|
/** @deprecated use DynamicWidgets */
|
|
11426
|
-
|
|
11427
10860
|
var ExperimentalDynamicWidgets = DynamicWidgets$1;
|
|
11428
10861
|
/** @deprecated use connectDynamicWidgets */
|
|
11429
|
-
|
|
11430
10862
|
var EXPERIMENTAL_connectDynamicWidgets = connectDynamicWidgets;
|
|
11431
10863
|
|
|
11432
10864
|
exports.Configure = Configure;
|
|
@@ -11475,5 +10907,5 @@
|
|
|
11475
10907
|
|
|
11476
10908
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11477
10909
|
|
|
11478
|
-
}));
|
|
10910
|
+
})));
|
|
11479
10911
|
//# sourceMappingURL=ReactInstantSearchCore.js.map
|