react-instantsearch-core 6.38.1 → 6.38.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +9 -1
- package/dist/cjs/connectors/connectAutoComplete.js +14 -33
- package/dist/cjs/connectors/connectBreadcrumb.js +9 -22
- package/dist/cjs/connectors/connectConfigure.js +17 -26
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +20 -33
- package/dist/cjs/connectors/connectCurrentRefinements.js +6 -13
- package/dist/cjs/connectors/connectDynamicWidgets.js +2 -13
- package/dist/cjs/connectors/connectGeoSearch.js +15 -34
- package/dist/cjs/connectors/connectHierarchicalMenu.js +22 -48
- package/dist/cjs/connectors/connectHighlight.js +8 -14
- package/dist/cjs/connectors/connectHitInsights.js +8 -20
- package/dist/cjs/connectors/connectHits.js +2 -11
- package/dist/cjs/connectors/connectHitsPerPage.js +8 -18
- package/dist/cjs/connectors/connectInfiniteHits.js +25 -43
- package/dist/cjs/connectors/connectMenu.js +14 -33
- package/dist/cjs/connectors/connectNumericMenu.js +24 -49
- package/dist/cjs/connectors/connectPagination.js +7 -17
- package/dist/cjs/connectors/connectPoweredBy.js +1 -5
- package/dist/cjs/connectors/connectQueryRules.js +11 -29
- package/dist/cjs/connectors/connectRange.js +33 -75
- package/dist/cjs/connectors/connectRefinementList.js +16 -34
- package/dist/cjs/connectors/connectRelevantSort.js +6 -13
- package/dist/cjs/connectors/connectScrollTo.js +6 -14
- package/dist/cjs/connectors/connectSearchBox.js +7 -17
- package/dist/cjs/connectors/connectSortBy.js +8 -18
- package/dist/cjs/connectors/connectStateResults.js +1 -6
- package/dist/cjs/connectors/connectStats.js +2 -8
- package/dist/cjs/connectors/connectToggleRefinement.js +14 -29
- package/dist/cjs/connectors/connectVoiceSearch.js +7 -24
- package/dist/cjs/core/context.js +3 -7
- package/dist/cjs/core/createConnector.js +60 -114
- package/dist/cjs/core/createInstantSearchManager.d.js +1 -0
- package/dist/cjs/core/createInstantSearchManager.js +67 -116
- package/dist/cjs/core/createStore.js +0 -1
- package/dist/cjs/core/createWidgetsManager.js +4 -7
- package/dist/cjs/core/highlight.js +11 -20
- package/dist/cjs/core/indexUtils.js +34 -77
- package/dist/cjs/core/metadata.js +7 -15
- package/dist/cjs/core/translatable.js +19 -46
- package/dist/cjs/core/utils.js +14 -52
- package/dist/cjs/core/version.js +1 -1
- package/dist/cjs/index.js +9 -44
- package/dist/cjs/types/index.js +0 -2
- package/dist/cjs/widgets/Configure.js +1 -5
- package/dist/cjs/widgets/ConfigureRelatedItems.js +1 -8
- package/dist/cjs/widgets/DynamicWidgets.js +12 -33
- package/dist/cjs/widgets/Index.js +26 -52
- package/dist/cjs/widgets/InstantSearch.js +28 -67
- package/dist/cjs/widgets/QueryRuleContext.js +1 -5
- package/dist/es/connectors/connectAutoComplete.js +11 -25
- package/dist/es/connectors/connectBreadcrumb.js +7 -13
- package/dist/es/connectors/connectConfigure.js +13 -22
- package/dist/es/connectors/connectConfigureRelatedItems.js +17 -25
- package/dist/es/connectors/connectCurrentRefinements.js +5 -7
- package/dist/es/connectors/connectDynamicWidgets.js +1 -6
- package/dist/es/connectors/connectGeoSearch.js +14 -27
- package/dist/es/connectors/connectHierarchicalMenu.js +19 -38
- package/dist/es/connectors/connectHighlight.js +7 -9
- package/dist/es/connectors/connectHitInsights.js +7 -14
- package/dist/es/connectors/connectHits.js +2 -5
- package/dist/es/connectors/connectHitsPerPage.js +5 -12
- package/dist/es/connectors/connectInfiniteHits.js +21 -31
- package/dist/es/connectors/connectMenu.js +12 -25
- package/dist/es/connectors/connectNumericMenu.js +22 -40
- package/dist/es/connectors/connectPagination.js +5 -12
- package/dist/es/connectors/connectPoweredBy.js +1 -1
- package/dist/es/connectors/connectQueryRules.js +9 -20
- package/dist/es/connectors/connectRange.js +31 -68
- package/dist/es/connectors/connectRefinementList.js +14 -24
- package/dist/es/connectors/connectRelevantSort.js +7 -8
- package/dist/es/connectors/connectScrollTo.js +6 -7
- package/dist/es/connectors/connectSearchBox.js +5 -11
- package/dist/es/connectors/connectSortBy.js +5 -12
- package/dist/es/connectors/connectStateResults.js +1 -1
- package/dist/es/connectors/connectStats.js +2 -3
- package/dist/es/connectors/connectToggleRefinement.js +12 -22
- package/dist/es/connectors/connectVoiceSearch.js +4 -16
- package/dist/es/core/context.js +3 -5
- package/dist/es/core/createConnector.js +33 -86
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +59 -100
- package/dist/es/core/createWidgetsManager.js +4 -5
- package/dist/es/core/highlight.js +11 -17
- package/dist/es/core/indexUtils.js +27 -62
- package/dist/es/core/metadata.js +6 -8
- package/dist/es/core/translatable.js +13 -29
- package/dist/es/core/utils.js +12 -29
- package/dist/es/core/version.js +1 -1
- package/dist/es/index.js +39 -6
- package/dist/es/widgets/Configure.js +1 -0
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -2
- package/dist/es/widgets/DynamicWidgets.js +9 -18
- package/dist/es/widgets/Index.js +13 -31
- package/dist/es/widgets/InstantSearch.js +13 -42
- package/dist/umd/ReactInstantSearchCore.js +507 -1078
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +2 -2
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +7 -5
|
@@ -1,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.2';
|
|
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);
|
|
@@ -6783,34 +6690,26 @@
|
|
|
6783
6690
|
|
|
6784
6691
|
var algoliasearchHelper_1 = algoliasearchHelper;
|
|
6785
6692
|
|
|
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
6693
|
function createOptionalFilter(_ref) {
|
|
6791
6694
|
var attributeName = _ref.attributeName,
|
|
6792
|
-
|
|
6793
|
-
|
|
6695
|
+
attributeValue = _ref.attributeValue,
|
|
6696
|
+
attributeScore = _ref.attributeScore;
|
|
6794
6697
|
return "".concat(attributeName, ":").concat(attributeValue, "<score=").concat(attributeScore || 1, ">");
|
|
6795
6698
|
}
|
|
6796
|
-
|
|
6797
6699
|
var defaultProps = {
|
|
6798
6700
|
transformSearchParameters: function transformSearchParameters(x) {
|
|
6799
|
-
return
|
|
6701
|
+
return _objectSpread2({}, x);
|
|
6800
6702
|
}
|
|
6801
6703
|
};
|
|
6802
|
-
|
|
6803
6704
|
function getId$1() {
|
|
6804
6705
|
// We store the search state of this widget in `configure`.
|
|
6805
6706
|
return 'configure';
|
|
6806
6707
|
}
|
|
6807
|
-
|
|
6808
6708
|
function getSearchParametersFromProps(props) {
|
|
6809
6709
|
var optionalFilters = Object.keys(props.matchingPatterns).reduce(function (acc, attributeName) {
|
|
6810
6710
|
var attributePattern = props.matchingPatterns[attributeName];
|
|
6811
6711
|
var attributeValue = getPropertyByPath(props.hit, attributeName);
|
|
6812
6712
|
var attributeScore = attributePattern.score;
|
|
6813
|
-
|
|
6814
6713
|
if (Array.isArray(attributeValue)) {
|
|
6815
6714
|
return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) {
|
|
6816
6715
|
return createOptionalFilter({
|
|
@@ -6820,7 +6719,6 @@
|
|
|
6820
6719
|
});
|
|
6821
6720
|
})]);
|
|
6822
6721
|
}
|
|
6823
|
-
|
|
6824
6722
|
if (typeof attributeValue === 'string') {
|
|
6825
6723
|
return [].concat(_toConsumableArray(acc), [createOptionalFilter({
|
|
6826
6724
|
attributeName: attributeName,
|
|
@@ -6828,7 +6726,6 @@
|
|
|
6828
6726
|
attributeScore: attributeScore
|
|
6829
6727
|
})]);
|
|
6830
6728
|
}
|
|
6831
|
-
|
|
6832
6729
|
return acc;
|
|
6833
6730
|
}, []);
|
|
6834
6731
|
return props.transformSearchParameters(new algoliasearchHelper_1.SearchParameters({
|
|
@@ -6840,7 +6737,6 @@
|
|
|
6840
6737
|
optionalFilters: optionalFilters
|
|
6841
6738
|
}));
|
|
6842
6739
|
}
|
|
6843
|
-
|
|
6844
6740
|
var connectConfigureRelatedItems = createConnectorWithContext({
|
|
6845
6741
|
displayName: 'AlgoliaConfigureRelatedItems',
|
|
6846
6742
|
$$type: 'ais.configureRelatedItems',
|
|
@@ -6852,19 +6748,17 @@
|
|
|
6852
6748
|
return searchParameters.setQueryParameters(getSearchParametersFromProps(props));
|
|
6853
6749
|
},
|
|
6854
6750
|
transitionState: function transitionState(props, _prevSearchState, nextSearchState) {
|
|
6855
|
-
var id = getId$1();
|
|
6751
|
+
var id = getId$1();
|
|
6752
|
+
// We need to transform the exhaustive search parameters back to clean
|
|
6856
6753
|
// search parameters without the empty default keys so we don't pollute the
|
|
6857
6754
|
// `configure` search state.
|
|
6858
|
-
|
|
6859
6755
|
var searchParameters = removeEmptyArraysFromObject(removeEmptyKey(getSearchParametersFromProps(props)));
|
|
6860
6756
|
var searchParametersKeys = Object.keys(searchParameters);
|
|
6861
6757
|
var nonPresentKeys = this._searchParameters ? Object.keys(this._searchParameters).filter(function (prop) {
|
|
6862
6758
|
return searchParametersKeys.indexOf(prop) === -1;
|
|
6863
6759
|
}) : [];
|
|
6864
6760
|
this._searchParameters = searchParameters;
|
|
6865
|
-
|
|
6866
|
-
var nextValue = _defineProperty({}, id, _objectSpread$4(_objectSpread$4({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
6867
|
-
|
|
6761
|
+
var nextValue = _defineProperty({}, id, _objectSpread2(_objectSpread2({}, omit(nextSearchState[id], nonPresentKeys)), searchParameters));
|
|
6868
6762
|
return refineValue(nextSearchState, nextValue, {
|
|
6869
6763
|
ais: props.contextValue,
|
|
6870
6764
|
multiIndexContext: props.indexContextValue
|
|
@@ -6872,7 +6766,6 @@
|
|
|
6872
6766
|
},
|
|
6873
6767
|
cleanUp: function cleanUp(props, searchState) {
|
|
6874
6768
|
var _this = this;
|
|
6875
|
-
|
|
6876
6769
|
var id = getId$1();
|
|
6877
6770
|
var indexId = getIndexId({
|
|
6878
6771
|
ais: props.contextValue,
|
|
@@ -6887,12 +6780,9 @@
|
|
|
6887
6780
|
if (!_this._searchParameters[item]) {
|
|
6888
6781
|
acc[item] = subState[id][item];
|
|
6889
6782
|
}
|
|
6890
|
-
|
|
6891
6783
|
return acc;
|
|
6892
6784
|
}, {});
|
|
6893
|
-
|
|
6894
6785
|
var nextValue = _defineProperty({}, id, configureState);
|
|
6895
|
-
|
|
6896
6786
|
return refineValue(searchState, nextValue, {
|
|
6897
6787
|
ais: props.contextValue,
|
|
6898
6788
|
multiIndexContext: props.indexContextValue
|
|
@@ -6904,9 +6794,6 @@
|
|
|
6904
6794
|
typeof self !== "undefined" ? self :
|
|
6905
6795
|
typeof window !== "undefined" ? window : {});
|
|
6906
6796
|
|
|
6907
|
-
if (typeof global$1.setTimeout === 'function') ;
|
|
6908
|
-
if (typeof global$1.clearTimeout === 'function') ;
|
|
6909
|
-
|
|
6910
6797
|
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
|
6911
6798
|
var performance = global$1.performance || {};
|
|
6912
6799
|
var performanceNow =
|
|
@@ -7087,7 +6974,6 @@
|
|
|
7087
6974
|
function ConfigureRelatedItems() {
|
|
7088
6975
|
return null;
|
|
7089
6976
|
}
|
|
7090
|
-
|
|
7091
6977
|
ConfigureRelatedItems.propTypes = {
|
|
7092
6978
|
hit: propTypes.object.isRequired,
|
|
7093
6979
|
matchingPatterns: propTypes.object.isRequired,
|
|
@@ -7117,32 +7003,26 @@
|
|
|
7117
7003
|
ais: props.contextValue,
|
|
7118
7004
|
multiIndexContext: props.indexContextValue
|
|
7119
7005
|
});
|
|
7120
|
-
|
|
7121
7006
|
if (props.facets && !(Array.isArray(props.facets) && props.facets.length <= 1 && (props.facets[0] === '*' || props.facets[0] === undefined))) {
|
|
7122
7007
|
throw new Error("The `facets` prop only accepts [] or [\"*\"], you passed ".concat(JSON.stringify(props.facets)));
|
|
7123
7008
|
}
|
|
7124
|
-
|
|
7125
7009
|
if (!results) {
|
|
7126
7010
|
return {
|
|
7127
7011
|
attributesToRender: []
|
|
7128
7012
|
};
|
|
7129
7013
|
}
|
|
7130
|
-
|
|
7131
7014
|
var facetOrder = results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.facets && results.renderingContent.facetOrdering.facets.order || [];
|
|
7132
7015
|
var attributesToRender = props.transformItems(facetOrder, {
|
|
7133
7016
|
results: results
|
|
7134
7017
|
});
|
|
7135
|
-
|
|
7136
7018
|
if (attributesToRender.length > MAX_WILDCARD_FACETS && !props.facets) {
|
|
7137
7019
|
// eslint-disable-next-line no-console
|
|
7138
7020
|
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
7021
|
}
|
|
7140
|
-
|
|
7141
7022
|
if (props.maxValuesPerFacet < results._state.maxValuesPerFacet) {
|
|
7142
7023
|
// eslint-disable-next-line no-console
|
|
7143
7024
|
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
7025
|
}
|
|
7145
|
-
|
|
7146
7026
|
return {
|
|
7147
7027
|
attributesToRender: attributesToRender
|
|
7148
7028
|
};
|
|
@@ -7159,46 +7039,39 @@
|
|
|
7159
7039
|
function isReactElement(element) {
|
|
7160
7040
|
return _typeof(element) === 'object' && element.props;
|
|
7161
7041
|
}
|
|
7162
|
-
|
|
7163
7042
|
function getAttribute(element) {
|
|
7164
7043
|
if (!isReactElement(element)) {
|
|
7165
7044
|
return undefined;
|
|
7166
7045
|
}
|
|
7167
|
-
|
|
7168
7046
|
if (element.props.attribute) {
|
|
7169
7047
|
return element.props.attribute;
|
|
7170
7048
|
}
|
|
7171
|
-
|
|
7172
7049
|
if (Array.isArray(element.props.attributes)) {
|
|
7173
7050
|
return element.props.attributes[0];
|
|
7174
7051
|
}
|
|
7175
|
-
|
|
7176
7052
|
if (element.props.children) {
|
|
7177
7053
|
return getAttribute(React__default.Children.only(element.props.children));
|
|
7178
7054
|
}
|
|
7179
|
-
|
|
7180
7055
|
return undefined;
|
|
7181
7056
|
}
|
|
7182
|
-
|
|
7183
7057
|
function DynamicWidgets(_ref) {
|
|
7184
7058
|
var children = _ref.children,
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7059
|
+
attributesToRender = _ref.attributesToRender,
|
|
7060
|
+
_ref$fallbackComponen = _ref.fallbackComponent,
|
|
7061
|
+
Fallback = _ref$fallbackComponen === void 0 ? function () {
|
|
7062
|
+
return null;
|
|
7063
|
+
} : _ref$fallbackComponen;
|
|
7190
7064
|
var widgets = new Map();
|
|
7191
7065
|
React__default.Children.forEach(children, function (child) {
|
|
7192
7066
|
var attribute = getAttribute(child);
|
|
7193
|
-
|
|
7194
7067
|
if (!attribute) {
|
|
7195
7068
|
throw new Error("Could not find \"attribute\" prop for ".concat(getDisplayName(child), "."));
|
|
7196
7069
|
}
|
|
7197
|
-
|
|
7198
7070
|
widgets.set(attribute, child);
|
|
7199
|
-
});
|
|
7200
|
-
// search state for unmounted components in place, so routing works.
|
|
7071
|
+
});
|
|
7201
7072
|
|
|
7073
|
+
// on initial render this will be empty, but React InstantSearch keeps
|
|
7074
|
+
// search state for unmounted components in place, so routing works.
|
|
7202
7075
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, attributesToRender.map(function (attribute) {
|
|
7203
7076
|
return /*#__PURE__*/React__default.createElement(React.Fragment, {
|
|
7204
7077
|
key: attribute
|
|
@@ -7207,7 +7080,6 @@
|
|
|
7207
7080
|
}));
|
|
7208
7081
|
}));
|
|
7209
7082
|
}
|
|
7210
|
-
|
|
7211
7083
|
var DynamicWidgets$1 = connectDynamicWidgets(DynamicWidgets, {
|
|
7212
7084
|
$$widgetType: 'ais.dynamicWidgets'
|
|
7213
7085
|
});
|
|
@@ -7217,36 +7089,27 @@
|
|
|
7217
7089
|
function escapeRuleContext(ruleName) {
|
|
7218
7090
|
return ruleName.replace(/[^a-z0-9-_]+/gi, '_');
|
|
7219
7091
|
}
|
|
7220
|
-
|
|
7221
7092
|
function getWidgetRefinements(attribute, widgetKey, searchState) {
|
|
7222
7093
|
var widgetState = searchState[widgetKey];
|
|
7223
|
-
|
|
7224
7094
|
switch (widgetKey) {
|
|
7225
7095
|
case 'range':
|
|
7226
7096
|
return Object.keys(widgetState[attribute]).map(function (rangeKey) {
|
|
7227
7097
|
return widgetState[attribute][rangeKey];
|
|
7228
7098
|
});
|
|
7229
|
-
|
|
7230
7099
|
case 'refinementList':
|
|
7231
7100
|
return widgetState[attribute];
|
|
7232
|
-
|
|
7233
7101
|
case 'hierarchicalMenu':
|
|
7234
7102
|
return [widgetState[attribute]];
|
|
7235
|
-
|
|
7236
7103
|
case 'menu':
|
|
7237
7104
|
return [widgetState[attribute]];
|
|
7238
|
-
|
|
7239
7105
|
case 'multiRange':
|
|
7240
7106
|
return widgetState[attribute].split(':');
|
|
7241
|
-
|
|
7242
7107
|
case 'toggle':
|
|
7243
7108
|
return [widgetState[attribute]];
|
|
7244
|
-
|
|
7245
7109
|
default:
|
|
7246
7110
|
return [];
|
|
7247
7111
|
}
|
|
7248
7112
|
}
|
|
7249
|
-
|
|
7250
7113
|
function getRefinements$1(attribute) {
|
|
7251
7114
|
var searchState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7252
7115
|
var refinements = Object.keys(searchState).filter(function (widgetKey) {
|
|
@@ -7259,10 +7122,9 @@
|
|
|
7259
7122
|
|
|
7260
7123
|
return refinements;
|
|
7261
7124
|
}
|
|
7262
|
-
|
|
7263
7125
|
function getRuleContextsFromTrackedFilters(_ref) {
|
|
7264
7126
|
var searchState = _ref.searchState,
|
|
7265
|
-
|
|
7127
|
+
trackedFilters = _ref.trackedFilters;
|
|
7266
7128
|
var ruleContexts = Object.keys(trackedFilters).reduce(function (facets, facetName) {
|
|
7267
7129
|
var facetRefinements = getRefinements$1(facetName, searchState);
|
|
7268
7130
|
var getTrackedFacetValues = trackedFilters[facetName];
|
|
@@ -7275,7 +7137,6 @@
|
|
|
7275
7137
|
}, []);
|
|
7276
7138
|
return ruleContexts;
|
|
7277
7139
|
}
|
|
7278
|
-
|
|
7279
7140
|
var defaultProps$1 = {
|
|
7280
7141
|
transformItems: function transformItems(items) {
|
|
7281
7142
|
return items;
|
|
@@ -7294,16 +7155,14 @@
|
|
|
7294
7155
|
ais: props.contextValue,
|
|
7295
7156
|
multiIndexContext: props.indexContextValue
|
|
7296
7157
|
});
|
|
7297
|
-
|
|
7298
7158
|
if (results === null) {
|
|
7299
7159
|
return {
|
|
7300
7160
|
items: [],
|
|
7301
7161
|
canRefine: false
|
|
7302
7162
|
};
|
|
7303
7163
|
}
|
|
7304
|
-
|
|
7305
7164
|
var _results$userData = results.userData,
|
|
7306
|
-
|
|
7165
|
+
userData = _results$userData === void 0 ? [] : _results$userData;
|
|
7307
7166
|
var transformItems = props.transformItems;
|
|
7308
7167
|
var transformedItems = transformItems(userData);
|
|
7309
7168
|
return {
|
|
@@ -7315,7 +7174,6 @@
|
|
|
7315
7174
|
if (Object.keys(props.trackedFilters).length === 0) {
|
|
7316
7175
|
return searchParameters;
|
|
7317
7176
|
}
|
|
7318
|
-
|
|
7319
7177
|
var indexSearchState = hasMultipleIndices({
|
|
7320
7178
|
ais: props.contextValue,
|
|
7321
7179
|
multiIndexContext: props.indexContextValue
|
|
@@ -7329,7 +7187,6 @@
|
|
|
7329
7187
|
});
|
|
7330
7188
|
var initialRuleContexts = searchParameters.ruleContexts || [];
|
|
7331
7189
|
var nextRuleContexts = [].concat(_toConsumableArray(initialRuleContexts), _toConsumableArray(newRuleContexts));
|
|
7332
|
-
|
|
7333
7190
|
var ruleContexts = props.transformRuleContexts(nextRuleContexts).slice(0, 10);
|
|
7334
7191
|
return searchParameters.setQueryParameter('ruleContexts', ruleContexts);
|
|
7335
7192
|
}
|
|
@@ -7341,16 +7198,11 @@
|
|
|
7341
7198
|
$$widgetType: 'ais.queryRuleContext'
|
|
7342
7199
|
});
|
|
7343
7200
|
|
|
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
7201
|
function getIndexContext(props) {
|
|
7349
7202
|
return {
|
|
7350
7203
|
targetedIndex: props.indexId
|
|
7351
7204
|
};
|
|
7352
7205
|
}
|
|
7353
|
-
|
|
7354
7206
|
/**
|
|
7355
7207
|
* The component that allows you to apply widgets to a dedicated index. It's
|
|
7356
7208
|
* useful if you want to build an interface that targets multiple indices.
|
|
@@ -7383,30 +7235,21 @@
|
|
|
7383
7235
|
*/
|
|
7384
7236
|
var Index = /*#__PURE__*/function (_Component) {
|
|
7385
7237
|
_inherits(Index, _Component);
|
|
7386
|
-
|
|
7387
|
-
var _super = _createSuper$2(Index);
|
|
7388
|
-
|
|
7238
|
+
var _super = _createSuper(Index);
|
|
7389
7239
|
function Index(props) {
|
|
7390
7240
|
var _this;
|
|
7391
|
-
|
|
7392
7241
|
_classCallCheck(this, Index);
|
|
7393
|
-
|
|
7394
7242
|
_this = _super.call(this, props);
|
|
7395
|
-
|
|
7396
7243
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
7397
7244
|
indexContext: getIndexContext(_this.props)
|
|
7398
7245
|
});
|
|
7399
|
-
|
|
7400
7246
|
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
7401
|
-
|
|
7402
7247
|
_this.props.contextValue.onSearchParameters(_this.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
7403
7248
|
ais: _this.props.contextValue,
|
|
7404
7249
|
multiIndexContext: _this.state.indexContext
|
|
7405
7250
|
}, _this.props, undefined, Index.displayName);
|
|
7406
|
-
|
|
7407
7251
|
return _this;
|
|
7408
7252
|
}
|
|
7409
|
-
|
|
7410
7253
|
_createClass(Index, [{
|
|
7411
7254
|
key: "componentDidMount",
|
|
7412
7255
|
value: function componentDidMount() {
|
|
@@ -7435,11 +7278,9 @@
|
|
|
7435
7278
|
key: "render",
|
|
7436
7279
|
value: function render() {
|
|
7437
7280
|
var childrenCount = React.Children.count(this.props.children);
|
|
7438
|
-
|
|
7439
7281
|
if (childrenCount === 0) {
|
|
7440
7282
|
return null;
|
|
7441
7283
|
}
|
|
7442
|
-
|
|
7443
7284
|
return /*#__PURE__*/React__default.createElement(IndexProvider, {
|
|
7444
7285
|
value: this.state.indexContext
|
|
7445
7286
|
}, this.props.children);
|
|
@@ -7452,16 +7293,11 @@
|
|
|
7452
7293
|
};
|
|
7453
7294
|
}
|
|
7454
7295
|
}]);
|
|
7455
|
-
|
|
7456
7296
|
return Index;
|
|
7457
7297
|
}(React.Component);
|
|
7458
|
-
|
|
7459
7298
|
_defineProperty(Index, "displayName", 'AlgoliaIndex');
|
|
7460
|
-
|
|
7461
7299
|
_defineProperty(Index, "$$type", 'ais.index');
|
|
7462
|
-
|
|
7463
7300
|
_defineProperty(Index, "$$widgetType", 'ais.index');
|
|
7464
|
-
|
|
7465
7301
|
var IndexWrapper = function IndexWrapper(props) {
|
|
7466
7302
|
var inferredIndexId = props.indexName;
|
|
7467
7303
|
return /*#__PURE__*/React__default.createElement(InstantSearchConsumer, null, function (contextValue) {
|
|
@@ -7473,23 +7309,22 @@
|
|
|
7473
7309
|
};
|
|
7474
7310
|
|
|
7475
7311
|
function createWidgetsManager(onWidgetsUpdate) {
|
|
7476
|
-
var widgets = [];
|
|
7312
|
+
var widgets = [];
|
|
7313
|
+
// Is an update scheduled?
|
|
7314
|
+
var scheduled = false;
|
|
7477
7315
|
|
|
7478
|
-
|
|
7316
|
+
// The state manager's updates need to be batched since more than one
|
|
7479
7317
|
// component can register or unregister widgets during the same tick.
|
|
7480
|
-
|
|
7481
7318
|
function scheduleUpdate() {
|
|
7482
7319
|
if (scheduled) {
|
|
7483
7320
|
return;
|
|
7484
7321
|
}
|
|
7485
|
-
|
|
7486
7322
|
scheduled = true;
|
|
7487
7323
|
defer(function () {
|
|
7488
7324
|
scheduled = false;
|
|
7489
7325
|
onWidgetsUpdate();
|
|
7490
7326
|
});
|
|
7491
7327
|
}
|
|
7492
|
-
|
|
7493
7328
|
return {
|
|
7494
7329
|
registerWidget: function registerWidget(widget) {
|
|
7495
7330
|
widgets.push(widget);
|
|
@@ -7529,79 +7364,65 @@
|
|
|
7529
7364
|
}
|
|
7530
7365
|
|
|
7531
7366
|
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
|
-
|
|
7367
|
+
_excluded2$1 = ["resultsFacetValues"],
|
|
7368
|
+
_excluded3 = ["resultsFacetValues"];
|
|
7539
7369
|
function addAlgoliaAgents(searchClient) {
|
|
7540
7370
|
if (typeof searchClient.addAlgoliaAgent === 'function') {
|
|
7541
7371
|
searchClient.addAlgoliaAgent("react (".concat(React.version, ")"));
|
|
7542
7372
|
searchClient.addAlgoliaAgent("react-instantsearch (".concat(version, ")"));
|
|
7543
7373
|
}
|
|
7544
7374
|
}
|
|
7545
|
-
|
|
7546
7375
|
var isMultiIndexContext = function isMultiIndexContext(widget) {
|
|
7547
7376
|
return hasMultipleIndices({
|
|
7548
7377
|
ais: widget.props.contextValue,
|
|
7549
7378
|
multiIndexContext: widget.props.indexContextValue
|
|
7550
7379
|
});
|
|
7551
7380
|
};
|
|
7552
|
-
|
|
7553
7381
|
var isTargetedIndexEqualIndex = function isTargetedIndexEqualIndex(widget, indexId) {
|
|
7554
7382
|
return widget.props.indexContextValue.targetedIndex === indexId;
|
|
7555
|
-
};
|
|
7383
|
+
};
|
|
7384
|
+
|
|
7385
|
+
// Relying on the `indexId` is a bit brittle to detect the `Index` widget.
|
|
7556
7386
|
// Since it's a class we could rely on `instanceof` or similar. We never
|
|
7557
7387
|
// had an issue though. Works for now.
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
7388
|
var isIndexWidget = function isIndexWidget(widget) {
|
|
7561
7389
|
return Boolean(widget.props.indexId);
|
|
7562
7390
|
};
|
|
7563
|
-
|
|
7564
7391
|
var isIndexWidgetEqualIndex = function isIndexWidgetEqualIndex(widget, indexId) {
|
|
7565
7392
|
return widget.props.indexId === indexId;
|
|
7566
7393
|
};
|
|
7567
|
-
|
|
7568
7394
|
var sortIndexWidgetsFirst = function sortIndexWidgetsFirst(firstWidget, secondWidget) {
|
|
7569
7395
|
var isFirstWidgetIndex = isIndexWidget(firstWidget);
|
|
7570
7396
|
var isSecondWidgetIndex = isIndexWidget(secondWidget);
|
|
7571
|
-
|
|
7572
7397
|
if (isFirstWidgetIndex && !isSecondWidgetIndex) {
|
|
7573
7398
|
return -1;
|
|
7574
7399
|
}
|
|
7575
|
-
|
|
7576
7400
|
if (!isFirstWidgetIndex && isSecondWidgetIndex) {
|
|
7577
7401
|
return 1;
|
|
7578
7402
|
}
|
|
7579
|
-
|
|
7580
7403
|
return 0;
|
|
7581
|
-
};
|
|
7582
|
-
// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
|
|
7583
|
-
|
|
7404
|
+
};
|
|
7584
7405
|
|
|
7406
|
+
// This function is copied from the algoliasearch v4 API Client. If modified,
|
|
7407
|
+
// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.
|
|
7585
7408
|
function serializeQueryParameters(parameters) {
|
|
7586
7409
|
var isObjectOrArray = function isObjectOrArray(value) {
|
|
7587
7410
|
return Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
7588
7411
|
};
|
|
7589
|
-
|
|
7590
7412
|
var encode = function encode(format) {
|
|
7591
7413
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
7592
7414
|
args[_key - 1] = arguments[_key];
|
|
7593
7415
|
}
|
|
7594
|
-
|
|
7595
7416
|
var i = 0;
|
|
7596
7417
|
return format.replace(/%s/g, function () {
|
|
7597
7418
|
return encodeURIComponent(args[i++]);
|
|
7598
7419
|
});
|
|
7599
7420
|
};
|
|
7600
|
-
|
|
7601
7421
|
return Object.keys(parameters).map(function (key) {
|
|
7602
7422
|
return encode('%s=%s', key, isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]);
|
|
7603
7423
|
}).join('&');
|
|
7604
7424
|
}
|
|
7425
|
+
|
|
7605
7426
|
/**
|
|
7606
7427
|
* Creates a new instance of the InstantSearchManager which controls the widgets and
|
|
7607
7428
|
* trigger the search when the widgets are updated.
|
|
@@ -7611,16 +7432,14 @@
|
|
|
7611
7432
|
* @param {number} stalledSearchDelay - time (in ms) after the search is stalled
|
|
7612
7433
|
* @return {InstantSearchManager} a new instance of InstantSearchManager
|
|
7613
7434
|
*/
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
7435
|
function createInstantSearchManager(_ref) {
|
|
7617
7436
|
var indexName = _ref.indexName,
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
var helper = algoliasearchHelper_1(searchClient, indexName,
|
|
7437
|
+
_ref$initialState = _ref.initialState,
|
|
7438
|
+
initialState = _ref$initialState === void 0 ? {} : _ref$initialState,
|
|
7439
|
+
searchClient = _ref.searchClient,
|
|
7440
|
+
resultsState = _ref.resultsState,
|
|
7441
|
+
stalledSearchDelay = _ref.stalledSearchDelay;
|
|
7442
|
+
var helper = algoliasearchHelper_1(searchClient, indexName, _objectSpread2({}, HIGHLIGHT_TAGS));
|
|
7624
7443
|
addAlgoliaAgents(searchClient);
|
|
7625
7444
|
helper.on('search', handleNewSearch).on('result', handleSearchSuccess({
|
|
7626
7445
|
indexId: indexName
|
|
@@ -7640,22 +7459,18 @@
|
|
|
7640
7459
|
isSearchStalled: true,
|
|
7641
7460
|
searchingForFacetValues: false
|
|
7642
7461
|
});
|
|
7643
|
-
|
|
7644
7462
|
function skipSearch() {
|
|
7645
7463
|
skip = true;
|
|
7646
7464
|
}
|
|
7647
|
-
|
|
7648
7465
|
function updateClient(client) {
|
|
7649
7466
|
addAlgoliaAgents(client);
|
|
7650
7467
|
helper.setClient(client);
|
|
7651
7468
|
search();
|
|
7652
7469
|
}
|
|
7653
|
-
|
|
7654
7470
|
function clearCache() {
|
|
7655
7471
|
helper.clearCache();
|
|
7656
7472
|
search();
|
|
7657
7473
|
}
|
|
7658
|
-
|
|
7659
7474
|
function getMetadata(state) {
|
|
7660
7475
|
return widgetsManager.getWidgets().filter(function (widget) {
|
|
7661
7476
|
return Boolean(widget.getMetadata);
|
|
@@ -7663,7 +7478,6 @@
|
|
|
7663
7478
|
return widget.getMetadata(state);
|
|
7664
7479
|
});
|
|
7665
7480
|
}
|
|
7666
|
-
|
|
7667
7481
|
function getSearchParameters() {
|
|
7668
7482
|
var sharedParameters = widgetsManager.getWidgets().filter(function (widget) {
|
|
7669
7483
|
return Boolean(widget.getSearchParameters);
|
|
@@ -7678,7 +7492,8 @@
|
|
|
7678
7492
|
var targetedIndexEqualMainIndex = isMultiIndexContext(widget) && isTargetedIndexEqualIndex(widget, indexName);
|
|
7679
7493
|
var subIndexEqualMainIndex = isIndexWidget(widget) && isIndexWidgetEqualIndex(widget, indexName);
|
|
7680
7494
|
return targetedIndexEqualMainIndex || subIndexEqualMainIndex;
|
|
7681
|
-
})
|
|
7495
|
+
})
|
|
7496
|
+
// We have to sort the `Index` widgets first so the `index` parameter
|
|
7682
7497
|
// is correctly set in the `reduce` function for the following widgets
|
|
7683
7498
|
.sort(sortIndexWidgetsFirst).reduce(function (res, widget) {
|
|
7684
7499
|
return widget.getSearchParameters(res);
|
|
@@ -7689,12 +7504,13 @@
|
|
|
7689
7504
|
var targetedIndexNotEqualMainIndex = isMultiIndexContext(widget) && !isTargetedIndexEqualIndex(widget, indexName);
|
|
7690
7505
|
var subIndexNotEqualMainIndex = isIndexWidget(widget) && !isIndexWidgetEqualIndex(widget, indexName);
|
|
7691
7506
|
return targetedIndexNotEqualMainIndex || subIndexNotEqualMainIndex;
|
|
7692
|
-
})
|
|
7507
|
+
})
|
|
7508
|
+
// We have to sort the `Index` widgets first so the `index` parameter
|
|
7693
7509
|
// is correctly set in the `reduce` function for the following widgets
|
|
7694
7510
|
.sort(sortIndexWidgetsFirst).reduce(function (indices, widget) {
|
|
7695
7511
|
var indexId = isMultiIndexContext(widget) ? widget.props.indexContextValue.targetedIndex : widget.props.indexId;
|
|
7696
7512
|
var widgets = indices[indexId] || [];
|
|
7697
|
-
return
|
|
7513
|
+
return _objectSpread2(_objectSpread2({}, indices), {}, _defineProperty({}, indexId, widgets.concat(widget)));
|
|
7698
7514
|
}, {});
|
|
7699
7515
|
var derivedParameters = Object.keys(derivedIndices).map(function (indexId) {
|
|
7700
7516
|
return {
|
|
@@ -7709,18 +7525,17 @@
|
|
|
7709
7525
|
derivedParameters: derivedParameters
|
|
7710
7526
|
};
|
|
7711
7527
|
}
|
|
7712
|
-
|
|
7713
7528
|
function search() {
|
|
7714
7529
|
if (!skip) {
|
|
7715
7530
|
var _getSearchParameters = getSearchParameters(),
|
|
7716
|
-
|
|
7717
|
-
|
|
7531
|
+
mainParameters = _getSearchParameters.mainParameters,
|
|
7532
|
+
derivedParameters = _getSearchParameters.derivedParameters;
|
|
7533
|
+
searchCounter = derivedParameters.length + 1;
|
|
7718
7534
|
|
|
7719
|
-
|
|
7535
|
+
// We have to call `slice` because the method `detach` on the derived
|
|
7720
7536
|
// helpers mutates the value `derivedHelpers`. The `forEach` loop does
|
|
7721
7537
|
// not iterate on each value and we're not able to correctly clear the
|
|
7722
7538
|
// previous derived helpers (memory leak + useless requests).
|
|
7723
|
-
|
|
7724
7539
|
helper.derivedHelpers.slice().forEach(function (derivedHelper) {
|
|
7725
7540
|
// Since we detach the derived helpers on **every** new search they
|
|
7726
7541
|
// won't receive intermediate results in case of a stalled search.
|
|
@@ -7740,7 +7555,7 @@
|
|
|
7740
7555
|
});
|
|
7741
7556
|
derivedParameters.forEach(function (_ref2) {
|
|
7742
7557
|
var indexId = _ref2.indexId,
|
|
7743
|
-
|
|
7558
|
+
parameters = _ref2.parameters;
|
|
7744
7559
|
var derivedHelper = helper.derive(function () {
|
|
7745
7560
|
return parameters;
|
|
7746
7561
|
});
|
|
@@ -7752,38 +7567,33 @@
|
|
|
7752
7567
|
helper.search();
|
|
7753
7568
|
}
|
|
7754
7569
|
}
|
|
7755
|
-
|
|
7756
7570
|
function handleSearchSuccess(_ref3) {
|
|
7757
7571
|
var indexId = _ref3.indexId;
|
|
7758
7572
|
return function (event) {
|
|
7759
7573
|
searchCounter--;
|
|
7760
7574
|
var state = store.getState();
|
|
7761
7575
|
var isDerivedHelpersEmpty = !helper.derivedHelpers.length;
|
|
7762
|
-
var results = state.results ? state.results : {};
|
|
7576
|
+
var results = state.results ? state.results : {};
|
|
7577
|
+
|
|
7578
|
+
// Switching from mono index to multi index and vice versa must reset the
|
|
7763
7579
|
// results to an empty object, otherwise we keep reference of stalled and
|
|
7764
7580
|
// unused results.
|
|
7765
|
-
|
|
7766
7581
|
results = !isDerivedHelpersEmpty && results.getFacetByName ? {} : results;
|
|
7767
|
-
|
|
7768
7582
|
if (!isDerivedHelpersEmpty) {
|
|
7769
|
-
results =
|
|
7583
|
+
results = _objectSpread2(_objectSpread2({}, results), {}, _defineProperty({}, indexId, event.results));
|
|
7770
7584
|
} else {
|
|
7771
7585
|
results = event.results;
|
|
7772
7586
|
}
|
|
7773
|
-
|
|
7774
7587
|
var currentState = store.getState();
|
|
7775
7588
|
var nextIsSearchStalled = currentState.isSearchStalled;
|
|
7776
|
-
|
|
7777
7589
|
if (!helper.hasPendingRequests()) {
|
|
7778
7590
|
clearTimeout(stalledSearchTimer);
|
|
7779
7591
|
stalledSearchTimer = null;
|
|
7780
7592
|
nextIsSearchStalled = false;
|
|
7781
7593
|
}
|
|
7782
|
-
|
|
7783
7594
|
var resultsFacetValues = currentState.resultsFacetValues,
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7595
|
+
partialState = _objectWithoutProperties(currentState, _excluded$2);
|
|
7596
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7787
7597
|
results: results,
|
|
7788
7598
|
isSearchStalled: nextIsSearchStalled,
|
|
7789
7599
|
searching: searchCounter > 0,
|
|
@@ -7791,71 +7601,63 @@
|
|
|
7791
7601
|
}));
|
|
7792
7602
|
};
|
|
7793
7603
|
}
|
|
7794
|
-
|
|
7795
7604
|
function handleSearchError(_ref4) {
|
|
7796
7605
|
var error = _ref4.error;
|
|
7797
7606
|
var currentState = store.getState();
|
|
7798
7607
|
var nextIsSearchStalled = currentState.isSearchStalled;
|
|
7799
|
-
|
|
7800
7608
|
if (!helper.hasPendingRequests()) {
|
|
7801
7609
|
clearTimeout(stalledSearchTimer);
|
|
7802
7610
|
nextIsSearchStalled = false;
|
|
7803
7611
|
}
|
|
7804
|
-
|
|
7805
7612
|
var resultsFacetValues = currentState.resultsFacetValues,
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7613
|
+
partialState = _objectWithoutProperties(currentState, _excluded2$1);
|
|
7614
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7809
7615
|
isSearchStalled: nextIsSearchStalled,
|
|
7810
7616
|
error: error,
|
|
7811
7617
|
searching: false
|
|
7812
7618
|
}));
|
|
7813
7619
|
}
|
|
7814
|
-
|
|
7815
7620
|
function handleNewSearch() {
|
|
7816
7621
|
if (!stalledSearchTimer) {
|
|
7817
7622
|
stalledSearchTimer = setTimeout(function () {
|
|
7818
7623
|
var _store$getState = store.getState(),
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, partialState), {}, {
|
|
7624
|
+
resultsFacetValues = _store$getState.resultsFacetValues,
|
|
7625
|
+
partialState = _objectWithoutProperties(_store$getState, _excluded3);
|
|
7626
|
+
store.setState(_objectSpread2(_objectSpread2({}, partialState), {}, {
|
|
7823
7627
|
isSearchStalled: true
|
|
7824
7628
|
}));
|
|
7825
7629
|
}, stalledSearchDelay);
|
|
7826
7630
|
}
|
|
7827
7631
|
}
|
|
7828
|
-
|
|
7829
7632
|
function hydrateSearchClient(client, results) {
|
|
7830
7633
|
if (!results) {
|
|
7831
7634
|
return;
|
|
7832
|
-
}
|
|
7635
|
+
}
|
|
7636
|
+
|
|
7637
|
+
// Disable cache hydration on:
|
|
7833
7638
|
// - Algoliasearch API Client < v4 with cache disabled
|
|
7834
7639
|
// - Third party clients (detected by the `addAlgoliaAgent` function missing)
|
|
7835
7640
|
|
|
7836
|
-
|
|
7837
7641
|
if ((!client.transporter || client._cacheHydrated) && (!client._useCache || typeof client.addAlgoliaAgent !== 'function')) {
|
|
7838
7642
|
return;
|
|
7839
|
-
}
|
|
7643
|
+
}
|
|
7644
|
+
|
|
7645
|
+
// Algoliasearch API Client >= v4
|
|
7840
7646
|
// To hydrate the client we need to populate the cache with the data from
|
|
7841
7647
|
// the server (done in `hydrateSearchClientWithMultiIndexRequest` or
|
|
7842
7648
|
// `hydrateSearchClientWithSingleIndexRequest`). But since there is no way
|
|
7843
7649
|
// for us to compute the key the same way as `algoliasearch-client` we need
|
|
7844
7650
|
// to populate it on a custom key and override the `search` method to
|
|
7845
7651
|
// search on it first.
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
7652
|
if (client.transporter && !client._cacheHydrated) {
|
|
7849
7653
|
client._cacheHydrated = true;
|
|
7850
7654
|
var baseMethod = client.search;
|
|
7851
|
-
|
|
7852
7655
|
client.search = function (requests) {
|
|
7853
7656
|
for (var _len2 = arguments.length, methodArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
7854
7657
|
methodArgs[_key2 - 1] = arguments[_key2];
|
|
7855
7658
|
}
|
|
7856
|
-
|
|
7857
7659
|
var requestsWithSerializedParams = requests.map(function (request) {
|
|
7858
|
-
return
|
|
7660
|
+
return _objectSpread2(_objectSpread2({}, request), {}, {
|
|
7859
7661
|
params: serializeQueryParameters(request.params)
|
|
7860
7662
|
});
|
|
7861
7663
|
});
|
|
@@ -7867,15 +7669,12 @@
|
|
|
7867
7669
|
});
|
|
7868
7670
|
};
|
|
7869
7671
|
}
|
|
7870
|
-
|
|
7871
7672
|
if (Array.isArray(results.results)) {
|
|
7872
7673
|
hydrateSearchClientWithMultiIndexRequest(client, results.results);
|
|
7873
7674
|
return;
|
|
7874
7675
|
}
|
|
7875
|
-
|
|
7876
7676
|
hydrateSearchClientWithSingleIndexRequest(client, results);
|
|
7877
7677
|
}
|
|
7878
|
-
|
|
7879
7678
|
function hydrateSearchClientWithMultiIndexRequest(client, results) {
|
|
7880
7679
|
// Algoliasearch API Client >= v4
|
|
7881
7680
|
// Populate the cache with the data from the server
|
|
@@ -7896,14 +7695,14 @@
|
|
|
7896
7695
|
}, [])
|
|
7897
7696
|
});
|
|
7898
7697
|
return;
|
|
7899
|
-
}
|
|
7698
|
+
}
|
|
7699
|
+
|
|
7700
|
+
// Algoliasearch API Client < v4
|
|
7900
7701
|
// Prior to client v4 we didn't have a proper API to hydrate the client
|
|
7901
7702
|
// cache from the outside. The following code populates the cache with
|
|
7902
7703
|
// a single-index result. You can find more information about the
|
|
7903
7704
|
// computation of the key inside the client (see link below).
|
|
7904
7705
|
// https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
7706
|
var key = "/1/indexes/*/queries_body_".concat(JSON.stringify({
|
|
7908
7707
|
requests: results.reduce(function (acc, result) {
|
|
7909
7708
|
return acc.concat(result.rawResults.map(function (request) {
|
|
@@ -7914,13 +7713,12 @@
|
|
|
7914
7713
|
}));
|
|
7915
7714
|
}, [])
|
|
7916
7715
|
}));
|
|
7917
|
-
client.cache =
|
|
7716
|
+
client.cache = _objectSpread2(_objectSpread2({}, client.cache), {}, _defineProperty({}, key, JSON.stringify({
|
|
7918
7717
|
results: results.reduce(function (acc, result) {
|
|
7919
7718
|
return acc.concat(result.rawResults);
|
|
7920
7719
|
}, [])
|
|
7921
7720
|
})));
|
|
7922
7721
|
}
|
|
7923
|
-
|
|
7924
7722
|
function hydrateSearchClientWithSingleIndexRequest(client, results) {
|
|
7925
7723
|
// Algoliasearch API Client >= v4
|
|
7926
7724
|
// Populate the cache with the data from the server
|
|
@@ -7937,14 +7735,13 @@
|
|
|
7937
7735
|
results: results.rawResults
|
|
7938
7736
|
});
|
|
7939
7737
|
return;
|
|
7940
|
-
}
|
|
7738
|
+
}
|
|
7739
|
+
// Algoliasearch API Client < v4
|
|
7941
7740
|
// Prior to client v4 we didn't have a proper API to hydrate the client
|
|
7942
7741
|
// cache from the outside. The following code populates the cache with
|
|
7943
7742
|
// a single-index result. You can find more information about the
|
|
7944
7743
|
// computation of the key inside the client (see link below).
|
|
7945
7744
|
// https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
7745
|
var key = "/1/indexes/*/queries_body_".concat(JSON.stringify({
|
|
7949
7746
|
requests: results.rawResults.map(function (request) {
|
|
7950
7747
|
return {
|
|
@@ -7953,37 +7750,34 @@
|
|
|
7953
7750
|
};
|
|
7954
7751
|
})
|
|
7955
7752
|
}));
|
|
7956
|
-
client.cache =
|
|
7753
|
+
client.cache = _objectSpread2(_objectSpread2({}, client.cache), {}, _defineProperty({}, key, JSON.stringify({
|
|
7957
7754
|
results: results.rawResults
|
|
7958
7755
|
})));
|
|
7959
7756
|
}
|
|
7960
|
-
|
|
7961
7757
|
function hydrateResultsState(results) {
|
|
7962
7758
|
if (!results) {
|
|
7963
7759
|
return null;
|
|
7964
7760
|
}
|
|
7965
|
-
|
|
7966
7761
|
if (Array.isArray(results.results)) {
|
|
7967
7762
|
return results.results.reduce(function (acc, result) {
|
|
7968
|
-
return
|
|
7763
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, result._internalIndexId, new algoliasearchHelper_1.SearchResults(new algoliasearchHelper_1.SearchParameters(result.state), result.rawResults)));
|
|
7969
7764
|
}, {});
|
|
7970
7765
|
}
|
|
7971
|
-
|
|
7972
7766
|
return new algoliasearchHelper_1.SearchResults(new algoliasearchHelper_1.SearchParameters(results.state), results.rawResults);
|
|
7973
|
-
}
|
|
7974
|
-
|
|
7767
|
+
}
|
|
7975
7768
|
|
|
7769
|
+
// Called whenever a widget has been rendered with new props.
|
|
7976
7770
|
function onWidgetsUpdate() {
|
|
7977
7771
|
var metadata = getMetadata(store.getState().widgets);
|
|
7978
|
-
store.setState(
|
|
7772
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
7979
7773
|
metadata: metadata,
|
|
7980
7774
|
searching: true
|
|
7981
|
-
}));
|
|
7982
|
-
// the result search parameters might have changed.
|
|
7775
|
+
}));
|
|
7983
7776
|
|
|
7777
|
+
// Since the `getSearchParameters` method of widgets also depends on props,
|
|
7778
|
+
// the result search parameters might have changed.
|
|
7984
7779
|
search();
|
|
7985
7780
|
}
|
|
7986
|
-
|
|
7987
7781
|
function transitionState(nextSearchState) {
|
|
7988
7782
|
var searchState = store.getState().widgets;
|
|
7989
7783
|
return widgetsManager.getWidgets().filter(function (widget) {
|
|
@@ -7992,38 +7786,35 @@
|
|
|
7992
7786
|
return widget.transitionState(searchState, res);
|
|
7993
7787
|
}, nextSearchState);
|
|
7994
7788
|
}
|
|
7995
|
-
|
|
7996
7789
|
function onExternalStateUpdate(nextSearchState) {
|
|
7997
7790
|
var metadata = getMetadata(nextSearchState);
|
|
7998
|
-
store.setState(
|
|
7791
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
7999
7792
|
widgets: nextSearchState,
|
|
8000
7793
|
metadata: metadata,
|
|
8001
7794
|
searching: true
|
|
8002
7795
|
}));
|
|
8003
7796
|
search();
|
|
8004
7797
|
}
|
|
8005
|
-
|
|
8006
7798
|
function onSearchForFacetValues(_ref5) {
|
|
8007
7799
|
var facetName = _ref5.facetName,
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
7800
|
+
query = _ref5.query,
|
|
7801
|
+
_ref5$maxFacetHits = _ref5.maxFacetHits,
|
|
7802
|
+
maxFacetHits = _ref5$maxFacetHits === void 0 ? 10 : _ref5$maxFacetHits;
|
|
8011
7803
|
// The values 1, 100 are the min / max values that the engine accepts.
|
|
8012
7804
|
// see: https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits
|
|
8013
7805
|
var maxFacetHitsWithinRange = Math.max(1, Math.min(maxFacetHits, 100));
|
|
8014
|
-
store.setState(
|
|
7806
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8015
7807
|
searchingForFacetValues: true
|
|
8016
7808
|
}));
|
|
8017
7809
|
helper.searchForFacetValues(facetName, query, maxFacetHitsWithinRange).then(function (content) {
|
|
8018
7810
|
var _objectSpread7;
|
|
8019
|
-
|
|
8020
|
-
store.setState(_objectSpread$5(_objectSpread$5({}, store.getState()), {}, {
|
|
7811
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8021
7812
|
error: null,
|
|
8022
7813
|
searchingForFacetValues: false,
|
|
8023
|
-
resultsFacetValues:
|
|
7814
|
+
resultsFacetValues: _objectSpread2(_objectSpread2({}, store.getState().resultsFacetValues), {}, (_objectSpread7 = {}, _defineProperty(_objectSpread7, facetName, content.facetHits), _defineProperty(_objectSpread7, "query", query), _objectSpread7))
|
|
8024
7815
|
}));
|
|
8025
7816
|
}, function (error) {
|
|
8026
|
-
store.setState(
|
|
7817
|
+
store.setState(_objectSpread2(_objectSpread2({}, store.getState()), {}, {
|
|
8027
7818
|
searchingForFacetValues: false,
|
|
8028
7819
|
error: error
|
|
8029
7820
|
}));
|
|
@@ -8037,9 +7828,9 @@
|
|
|
8037
7828
|
});
|
|
8038
7829
|
});
|
|
8039
7830
|
}
|
|
8040
|
-
|
|
8041
7831
|
function updateIndex(newIndex) {
|
|
8042
|
-
initialSearchParameters = initialSearchParameters.setIndex(newIndex);
|
|
7832
|
+
initialSearchParameters = initialSearchParameters.setIndex(newIndex);
|
|
7833
|
+
// No need to trigger a new search here as the widgets will also update and trigger it if needed.
|
|
8043
7834
|
}
|
|
8044
7835
|
|
|
8045
7836
|
function getWidgetsIds() {
|
|
@@ -8047,7 +7838,6 @@
|
|
|
8047
7838
|
return typeof meta.id !== 'undefined' ? res.concat(meta.id) : res;
|
|
8048
7839
|
}, []);
|
|
8049
7840
|
}
|
|
8050
|
-
|
|
8051
7841
|
return {
|
|
8052
7842
|
store: store,
|
|
8053
7843
|
widgetsManager: widgetsManager,
|
|
@@ -8062,27 +7852,26 @@
|
|
|
8062
7852
|
skipSearch: skipSearch
|
|
8063
7853
|
};
|
|
8064
7854
|
}
|
|
8065
|
-
|
|
8066
7855
|
function hydrateMetadata(resultsState) {
|
|
8067
7856
|
if (!resultsState) {
|
|
8068
7857
|
return [];
|
|
8069
|
-
}
|
|
8070
|
-
|
|
7858
|
+
}
|
|
8071
7859
|
|
|
7860
|
+
// add a value noop, which gets replaced once the widgets are mounted
|
|
8072
7861
|
return resultsState.metadata.map(function (datum) {
|
|
8073
|
-
return
|
|
7862
|
+
return _objectSpread2(_objectSpread2({
|
|
8074
7863
|
value: function value() {
|
|
8075
7864
|
return {};
|
|
8076
7865
|
}
|
|
8077
7866
|
}, datum), {}, {
|
|
8078
7867
|
items: datum.items && datum.items.map(function (item) {
|
|
8079
|
-
return
|
|
7868
|
+
return _objectSpread2(_objectSpread2({
|
|
8080
7869
|
value: function value() {
|
|
8081
7870
|
return {};
|
|
8082
7871
|
}
|
|
8083
7872
|
}, item), {}, {
|
|
8084
7873
|
items: item.items && item.items.map(function (nestedItem) {
|
|
8085
|
-
return
|
|
7874
|
+
return _objectSpread2({
|
|
8086
7875
|
value: function value() {
|
|
8087
7876
|
return {};
|
|
8088
7877
|
}
|
|
@@ -8101,14 +7890,12 @@
|
|
|
8101
7890
|
var internalProps = ['contextValue', 'indexContextValue'];
|
|
8102
7891
|
var widgetsPayload = widgets.map(function (_ref) {
|
|
8103
7892
|
var props = _ref.props,
|
|
8104
|
-
|
|
8105
|
-
|
|
7893
|
+
constructor = _ref.constructor;
|
|
8106
7894
|
var _ref2 = constructor._connectorDesc || {},
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
7895
|
+
_ref2$defaultProps = _ref2.defaultProps,
|
|
7896
|
+
defaultProps = _ref2$defaultProps === void 0 ? {} : _ref2$defaultProps,
|
|
7897
|
+
_ref2$displayName = _ref2.displayName,
|
|
7898
|
+
displayName = _ref2$displayName === void 0 ? constructor.displayName : _ref2$displayName;
|
|
8112
7899
|
return {
|
|
8113
7900
|
displayName: displayName,
|
|
8114
7901
|
$$type: constructor.$$type,
|
|
@@ -8134,17 +7921,10 @@
|
|
|
8134
7921
|
refNode.appendChild(payloadContainer);
|
|
8135
7922
|
}
|
|
8136
7923
|
|
|
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
7924
|
function isControlled(props) {
|
|
8146
7925
|
return Boolean(props.searchState);
|
|
8147
7926
|
}
|
|
7927
|
+
|
|
8148
7928
|
/**
|
|
8149
7929
|
* @description
|
|
8150
7930
|
* `<InstantSearch>` is the root component of all React InstantSearch implementations.
|
|
@@ -8183,24 +7963,15 @@
|
|
|
8183
7963
|
* </InstantSearch>
|
|
8184
7964
|
* );
|
|
8185
7965
|
*/
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
7966
|
var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
8189
7967
|
_inherits(InstantSearch, _Component);
|
|
8190
|
-
|
|
8191
|
-
var _super = _createSuper$3(InstantSearch);
|
|
8192
|
-
|
|
7968
|
+
var _super = _createSuper(InstantSearch);
|
|
8193
7969
|
function InstantSearch(props) {
|
|
8194
7970
|
var _this;
|
|
8195
|
-
|
|
8196
7971
|
_classCallCheck(this, InstantSearch);
|
|
8197
|
-
|
|
8198
7972
|
_this = _super.call(this, props);
|
|
8199
|
-
|
|
8200
7973
|
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
8201
|
-
|
|
8202
7974
|
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
8203
|
-
|
|
8204
7975
|
var instantSearchManager = createInstantSearchManager({
|
|
8205
7976
|
indexName: _this.props.indexName,
|
|
8206
7977
|
searchClient: _this.props.searchClient,
|
|
@@ -8225,28 +7996,22 @@
|
|
|
8225
7996
|
};
|
|
8226
7997
|
return _this;
|
|
8227
7998
|
}
|
|
8228
|
-
|
|
8229
7999
|
_createClass(InstantSearch, [{
|
|
8230
8000
|
key: "componentDidUpdate",
|
|
8231
8001
|
value: function componentDidUpdate(prevProps) {
|
|
8232
8002
|
var prevIsControlled = isControlled(prevProps);
|
|
8233
|
-
|
|
8234
8003
|
if (prevIsControlled && !this.state.isControlled) {
|
|
8235
8004
|
throw new Error("You can't switch <InstantSearch> from being controlled to uncontrolled");
|
|
8236
8005
|
}
|
|
8237
|
-
|
|
8238
8006
|
if (!prevIsControlled && this.state.isControlled) {
|
|
8239
8007
|
throw new Error("You can't switch <InstantSearch> from being uncontrolled to controlled");
|
|
8240
8008
|
}
|
|
8241
|
-
|
|
8242
8009
|
if (this.props.refresh !== prevProps.refresh && this.props.refresh) {
|
|
8243
8010
|
this.state.instantSearchManager.clearCache();
|
|
8244
8011
|
}
|
|
8245
|
-
|
|
8246
8012
|
if (prevProps.indexName !== this.props.indexName) {
|
|
8247
8013
|
this.state.instantSearchManager.updateIndex(this.props.indexName);
|
|
8248
8014
|
}
|
|
8249
|
-
|
|
8250
8015
|
if (prevProps.searchClient !== this.props.searchClient) {
|
|
8251
8016
|
this.state.instantSearchManager.updateClient(this.props.searchClient);
|
|
8252
8017
|
}
|
|
@@ -8258,7 +8023,6 @@
|
|
|
8258
8023
|
clearTimeout(this.cleanupTimerRef);
|
|
8259
8024
|
this.cleanupTimerRef = null;
|
|
8260
8025
|
}
|
|
8261
|
-
|
|
8262
8026
|
if (isMetadataEnabled()) {
|
|
8263
8027
|
injectMetadata(this.state.instantSearchManager.widgetsManager.getWidgets(), this.props.searchClient);
|
|
8264
8028
|
}
|
|
@@ -8267,10 +8031,8 @@
|
|
|
8267
8031
|
key: "componentWillUnmount",
|
|
8268
8032
|
value: function componentWillUnmount() {
|
|
8269
8033
|
var _this2 = this;
|
|
8270
|
-
|
|
8271
8034
|
this.cleanupTimerRef = setTimeout(function () {
|
|
8272
8035
|
_this2.isUnmounting = true;
|
|
8273
|
-
|
|
8274
8036
|
_this2.state.instantSearchManager.skipSearch();
|
|
8275
8037
|
});
|
|
8276
8038
|
}
|
|
@@ -8285,7 +8047,6 @@
|
|
|
8285
8047
|
value: function onWidgetsInternalStateUpdate(searchState) {
|
|
8286
8048
|
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
8287
8049
|
this.onSearchStateChange(searchState);
|
|
8288
|
-
|
|
8289
8050
|
if (!this.state.isControlled) {
|
|
8290
8051
|
this.state.instantSearchManager.onExternalStateUpdate(searchState);
|
|
8291
8052
|
}
|
|
@@ -8302,13 +8063,10 @@
|
|
|
8302
8063
|
value: function onSearchParameters(getSearchParameters, context, props, getMetadata, displayName) {
|
|
8303
8064
|
if (this.props.onSearchParameters) {
|
|
8304
8065
|
var _searchState = this.props.searchState ? this.props.searchState : {};
|
|
8305
|
-
|
|
8306
8066
|
this.props.onSearchParameters(getSearchParameters, context, props, _searchState);
|
|
8307
8067
|
}
|
|
8308
|
-
|
|
8309
8068
|
if (this.props.widgetsCollector) {
|
|
8310
8069
|
var _searchState2 = this.props.searchState ? this.props.searchState : {};
|
|
8311
|
-
|
|
8312
8070
|
this.props.widgetsCollector({
|
|
8313
8071
|
getSearchParameters: getSearchParameters,
|
|
8314
8072
|
getMetadata: getMetadata,
|
|
@@ -8335,7 +8093,6 @@
|
|
|
8335
8093
|
if (React.Children.count(this.props.children) === 0) {
|
|
8336
8094
|
return null;
|
|
8337
8095
|
}
|
|
8338
|
-
|
|
8339
8096
|
return /*#__PURE__*/React__default.createElement(InstantSearchProvider, {
|
|
8340
8097
|
value: this.state.contextValue
|
|
8341
8098
|
}, this.props.children);
|
|
@@ -8346,23 +8103,19 @@
|
|
|
8346
8103
|
var nextIsControlled = isControlled(nextProps);
|
|
8347
8104
|
var previousSearchState = prevState.instantSearchManager.store.getState().widgets;
|
|
8348
8105
|
var nextSearchState = nextProps.searchState;
|
|
8349
|
-
|
|
8350
8106
|
if (nextIsControlled && !reactFastCompare(previousSearchState, nextSearchState)) {
|
|
8351
8107
|
prevState.instantSearchManager.onExternalStateUpdate(nextProps.searchState);
|
|
8352
8108
|
}
|
|
8353
|
-
|
|
8354
8109
|
return {
|
|
8355
8110
|
isControlled: nextIsControlled,
|
|
8356
|
-
contextValue:
|
|
8111
|
+
contextValue: _objectSpread2(_objectSpread2({}, prevState.contextValue), {}, {
|
|
8357
8112
|
mainTargetedIndex: nextProps.indexName
|
|
8358
8113
|
})
|
|
8359
8114
|
};
|
|
8360
8115
|
}
|
|
8361
8116
|
}]);
|
|
8362
|
-
|
|
8363
8117
|
return InstantSearch;
|
|
8364
8118
|
}(React.Component);
|
|
8365
|
-
|
|
8366
8119
|
_defineProperty(InstantSearch, "defaultProps", {
|
|
8367
8120
|
stalledSearchDelay: 200,
|
|
8368
8121
|
refresh: false
|
|
@@ -8371,18 +8124,14 @@
|
|
|
8371
8124
|
var getId$2 = function getId() {
|
|
8372
8125
|
return 'query';
|
|
8373
8126
|
};
|
|
8374
|
-
|
|
8375
8127
|
function getCurrentRefinement(props, searchState, context) {
|
|
8376
8128
|
var id = getId$2();
|
|
8377
8129
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
8378
|
-
|
|
8379
8130
|
if (currentRefinement) {
|
|
8380
8131
|
return currentRefinement;
|
|
8381
8132
|
}
|
|
8382
|
-
|
|
8383
8133
|
return '';
|
|
8384
8134
|
}
|
|
8385
|
-
|
|
8386
8135
|
function getHits(searchResults) {
|
|
8387
8136
|
if (searchResults.results) {
|
|
8388
8137
|
if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
|
|
@@ -8399,19 +8148,16 @@
|
|
|
8399
8148
|
return [];
|
|
8400
8149
|
}
|
|
8401
8150
|
}
|
|
8402
|
-
|
|
8403
8151
|
function _refine(props, searchState, nextRefinement, context) {
|
|
8404
8152
|
var id = getId$2();
|
|
8405
|
-
|
|
8406
8153
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
8407
|
-
|
|
8408
8154
|
var resetPage = true;
|
|
8409
8155
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
8410
8156
|
}
|
|
8411
|
-
|
|
8412
8157
|
function _cleanUp(props, searchState, context) {
|
|
8413
8158
|
return cleanUpValue(searchState, context, getId$2());
|
|
8414
8159
|
}
|
|
8160
|
+
|
|
8415
8161
|
/**
|
|
8416
8162
|
* connectAutoComplete connector provides the logic to create connected
|
|
8417
8163
|
* components that will render the results retrieved from
|
|
@@ -8427,8 +8173,6 @@
|
|
|
8427
8173
|
* @providedPropType {function} refine - a function to change the query
|
|
8428
8174
|
* @providedPropType {string} currentRefinement - the query to search for
|
|
8429
8175
|
*/
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
8176
|
var connectAutoComplete = createConnectorWithContext({
|
|
8433
8177
|
displayName: 'AlgoliaAutoComplete',
|
|
8434
8178
|
$$type: 'ais.autoComplete',
|
|
@@ -8453,18 +8197,6 @@
|
|
|
8453
8197
|
multiIndexContext: props.indexContextValue
|
|
8454
8198
|
});
|
|
8455
8199
|
},
|
|
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
8200
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
8469
8201
|
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
8470
8202
|
ais: props.contextValue,
|
|
@@ -8477,16 +8209,12 @@
|
|
|
8477
8209
|
return props.attributes[0];
|
|
8478
8210
|
};
|
|
8479
8211
|
var namespace = 'hierarchicalMenu';
|
|
8480
|
-
|
|
8481
8212
|
function _refine$1(props, searchState, nextRefinement, context) {
|
|
8482
8213
|
var id = getId$3(props);
|
|
8483
|
-
|
|
8484
8214
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
8485
|
-
|
|
8486
8215
|
var resetPage = true;
|
|
8487
8216
|
return refineValue(searchState, nextValue, context, resetPage, namespace);
|
|
8488
8217
|
}
|
|
8489
|
-
|
|
8490
8218
|
function transformValue(values) {
|
|
8491
8219
|
return values.reduce(function (acc, item) {
|
|
8492
8220
|
if (item.isRefined) {
|
|
@@ -8495,16 +8223,16 @@
|
|
|
8495
8223
|
// If dealing with a nested "items", "value" is equal to the previous value concatenated with the current value
|
|
8496
8224
|
// If dealing with the first level, "value" is equal to the current value
|
|
8497
8225
|
value: item.escapedValue
|
|
8498
|
-
});
|
|
8499
|
-
|
|
8226
|
+
});
|
|
8227
|
+
// Create a variable in order to keep the same acc for the recursion, otherwise "reduce" returns a new one
|
|
8500
8228
|
if (item.data) {
|
|
8501
8229
|
acc = acc.concat(transformValue(item.data));
|
|
8502
8230
|
}
|
|
8503
8231
|
}
|
|
8504
|
-
|
|
8505
8232
|
return acc;
|
|
8506
8233
|
}, []);
|
|
8507
8234
|
}
|
|
8235
|
+
|
|
8508
8236
|
/**
|
|
8509
8237
|
* The breadcrumb component is s a type of secondary navigation scheme that
|
|
8510
8238
|
* reveals the user’s location in a website or web application.
|
|
@@ -8542,7 +8270,6 @@
|
|
|
8542
8270
|
* @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.
|
|
8543
8271
|
*/
|
|
8544
8272
|
|
|
8545
|
-
|
|
8546
8273
|
var connectBreadcrumb = createConnectorWithContext({
|
|
8547
8274
|
displayName: 'AlgoliaBreadcrumb',
|
|
8548
8275
|
$$type: 'ais.breadcrumb',
|
|
@@ -8551,11 +8278,9 @@
|
|
|
8551
8278
|
var isNotString = function isNotString(val) {
|
|
8552
8279
|
return typeof val !== 'string';
|
|
8553
8280
|
};
|
|
8554
|
-
|
|
8555
8281
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
8556
8282
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
8557
8283
|
}
|
|
8558
|
-
|
|
8559
8284
|
return undefined;
|
|
8560
8285
|
},
|
|
8561
8286
|
transformItems: propTypes.func
|
|
@@ -8567,14 +8292,12 @@
|
|
|
8567
8292
|
multiIndexContext: props.indexContextValue
|
|
8568
8293
|
});
|
|
8569
8294
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
8570
|
-
|
|
8571
8295
|
if (!isFacetPresent) {
|
|
8572
8296
|
return {
|
|
8573
8297
|
items: [],
|
|
8574
8298
|
canRefine: false
|
|
8575
8299
|
};
|
|
8576
8300
|
}
|
|
8577
|
-
|
|
8578
8301
|
var values = results.getFacetValues(id);
|
|
8579
8302
|
var items = values.data ? transformValue(values.data) : [];
|
|
8580
8303
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -8591,9 +8314,6 @@
|
|
|
8591
8314
|
}
|
|
8592
8315
|
});
|
|
8593
8316
|
|
|
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
8317
|
/**
|
|
8598
8318
|
* connectCurrentRefinements connector provides the logic to build a widget that will
|
|
8599
8319
|
* give the user the ability to remove all or some of the filters that were
|
|
@@ -8606,7 +8326,6 @@
|
|
|
8606
8326
|
* @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
8327
|
* @providedPropType {string} query - the search query
|
|
8608
8328
|
*/
|
|
8609
|
-
|
|
8610
8329
|
var connectCurrentRefinements = createConnectorWithContext({
|
|
8611
8330
|
displayName: 'AlgoliaCurrentRefinements',
|
|
8612
8331
|
$$type: 'ais.currentRefinements',
|
|
@@ -8622,16 +8341,14 @@
|
|
|
8622
8341
|
if (props.clearsQuery && meta.id === 'query' && meta.items[0].currentRefinement === '') {
|
|
8623
8342
|
return res;
|
|
8624
8343
|
}
|
|
8625
|
-
|
|
8626
8344
|
return res.concat(meta.items.map(function (item) {
|
|
8627
|
-
return
|
|
8345
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
8628
8346
|
id: meta.id,
|
|
8629
8347
|
index: meta.index
|
|
8630
8348
|
});
|
|
8631
8349
|
}));
|
|
8632
8350
|
}
|
|
8633
8351
|
}
|
|
8634
|
-
|
|
8635
8352
|
return res;
|
|
8636
8353
|
}, []);
|
|
8637
8354
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
@@ -8652,6 +8369,7 @@
|
|
|
8652
8369
|
});
|
|
8653
8370
|
|
|
8654
8371
|
var _excluded$3 = ["defaultRefinement"];
|
|
8372
|
+
|
|
8655
8373
|
/**
|
|
8656
8374
|
* The GeoSearch connector provides the logic to build a widget that will display the results on a map.
|
|
8657
8375
|
* 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 +8386,21 @@
|
|
|
8668
8386
|
* @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied
|
|
8669
8387
|
* @providedPropType {{ lat: number, lng: number }} [position] - the position of the search
|
|
8670
8388
|
*/
|
|
8389
|
+
|
|
8671
8390
|
// To control the map with an external widget the other widget
|
|
8672
8391
|
// **must** write the value in the attribute `aroundLatLng`
|
|
8673
|
-
|
|
8674
8392
|
var getBoundingBoxId = function getBoundingBoxId() {
|
|
8675
8393
|
return 'boundingBox';
|
|
8676
8394
|
};
|
|
8677
|
-
|
|
8678
8395
|
var getAroundLatLngId = function getAroundLatLngId() {
|
|
8679
8396
|
return 'aroundLatLng';
|
|
8680
8397
|
};
|
|
8681
|
-
|
|
8682
8398
|
var getConfigureAroundLatLngId = function getConfigureAroundLatLngId() {
|
|
8683
8399
|
return 'configure.aroundLatLng';
|
|
8684
8400
|
};
|
|
8685
|
-
|
|
8686
8401
|
var currentRefinementToString = function currentRefinementToString(currentRefinement) {
|
|
8687
8402
|
return [currentRefinement.northEast.lat, currentRefinement.northEast.lng, currentRefinement.southWest.lat, currentRefinement.southWest.lng].join();
|
|
8688
8403
|
};
|
|
8689
|
-
|
|
8690
8404
|
var stringToCurrentRefinement = function stringToCurrentRefinement(value) {
|
|
8691
8405
|
var values = value.split(',');
|
|
8692
8406
|
return {
|
|
@@ -8700,9 +8414,7 @@
|
|
|
8700
8414
|
}
|
|
8701
8415
|
};
|
|
8702
8416
|
};
|
|
8703
|
-
|
|
8704
8417
|
var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
|
|
8705
|
-
|
|
8706
8418
|
var stringToPosition = function stringToPosition(value) {
|
|
8707
8419
|
var pattern = value.match(latLngRegExp);
|
|
8708
8420
|
return {
|
|
@@ -8710,15 +8422,13 @@
|
|
|
8710
8422
|
lng: parseFloat(pattern[2])
|
|
8711
8423
|
};
|
|
8712
8424
|
};
|
|
8713
|
-
|
|
8714
8425
|
var getCurrentRefinement$1 = function getCurrentRefinement(props, searchState, context) {
|
|
8715
8426
|
var refinement = getCurrentRefinementValue(props, searchState, context, getBoundingBoxId(), {});
|
|
8716
|
-
|
|
8717
8427
|
if (!objectHasKeys(refinement)) {
|
|
8718
8428
|
return;
|
|
8719
|
-
}
|
|
8720
|
-
|
|
8429
|
+
}
|
|
8721
8430
|
|
|
8431
|
+
// eslint-disable-next-line consistent-return
|
|
8722
8432
|
return {
|
|
8723
8433
|
northEast: {
|
|
8724
8434
|
lat: parseFloat(refinement.northEast.lat),
|
|
@@ -8730,30 +8440,22 @@
|
|
|
8730
8440
|
}
|
|
8731
8441
|
};
|
|
8732
8442
|
};
|
|
8733
|
-
|
|
8734
8443
|
var getCurrentPosition = function getCurrentPosition(props, searchState, context) {
|
|
8735
8444
|
var defaultRefinement = props.defaultRefinement,
|
|
8736
|
-
|
|
8737
|
-
|
|
8445
|
+
propsWithoutDefaultRefinement = _objectWithoutProperties(props, _excluded$3);
|
|
8738
8446
|
var aroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getAroundLatLngId());
|
|
8739
|
-
|
|
8740
8447
|
if (!aroundLatLng) {
|
|
8741
8448
|
// Fallback on `configure.aroundLatLng`
|
|
8742
8449
|
var configureAroundLatLng = getCurrentRefinementValue(propsWithoutDefaultRefinement, searchState, context, getConfigureAroundLatLngId());
|
|
8743
8450
|
return configureAroundLatLng && stringToPosition(configureAroundLatLng);
|
|
8744
8451
|
}
|
|
8745
|
-
|
|
8746
8452
|
return aroundLatLng;
|
|
8747
8453
|
};
|
|
8748
|
-
|
|
8749
8454
|
var _refine$2 = function refine(searchState, nextValue, context) {
|
|
8750
8455
|
var resetPage = true;
|
|
8751
|
-
|
|
8752
8456
|
var nextRefinement = _defineProperty({}, getBoundingBoxId(), nextValue);
|
|
8753
|
-
|
|
8754
8457
|
return refineValue(searchState, nextRefinement, context, resetPage);
|
|
8755
8458
|
};
|
|
8756
|
-
|
|
8757
8459
|
var connectGeoSearch = createConnectorWithContext({
|
|
8758
8460
|
displayName: 'AlgoliaGeoSearch',
|
|
8759
8461
|
$$type: 'ais.geoSearch',
|
|
@@ -8762,7 +8464,9 @@
|
|
|
8762
8464
|
ais: props.contextValue,
|
|
8763
8465
|
multiIndexContext: props.indexContextValue
|
|
8764
8466
|
};
|
|
8765
|
-
var results = getResults(searchResults, context);
|
|
8467
|
+
var results = getResults(searchResults, context);
|
|
8468
|
+
|
|
8469
|
+
// We read it from both because the SearchParameters & the searchState are not always
|
|
8766
8470
|
// in sync. When we set the refinement the searchState is used but when we clear the refinement
|
|
8767
8471
|
// the SearchParameters is used. In the first case when we render, the results are not there
|
|
8768
8472
|
// so we can't find the value from the results. The most up to date value is the searchState.
|
|
@@ -8797,11 +8501,9 @@
|
|
|
8797
8501
|
ais: props.contextValue,
|
|
8798
8502
|
multiIndexContext: props.indexContextValue
|
|
8799
8503
|
});
|
|
8800
|
-
|
|
8801
8504
|
if (!currentRefinement) {
|
|
8802
8505
|
return searchParameters;
|
|
8803
8506
|
}
|
|
8804
|
-
|
|
8805
8507
|
return searchParameters.setQueryParameter('insideBoundingBox', currentRefinementToString(currentRefinement));
|
|
8806
8508
|
},
|
|
8807
8509
|
cleanUp: function cleanUp(props, searchState) {
|
|
@@ -8820,7 +8522,6 @@
|
|
|
8820
8522
|
var index = getIndexId(context);
|
|
8821
8523
|
var nextRefinement = {};
|
|
8822
8524
|
var currentRefinement = getCurrentRefinement$1(props, searchState, context);
|
|
8823
|
-
|
|
8824
8525
|
if (currentRefinement) {
|
|
8825
8526
|
items.push({
|
|
8826
8527
|
label: "".concat(id, ": ").concat(currentRefinementToString(currentRefinement)),
|
|
@@ -8830,7 +8531,6 @@
|
|
|
8830
8531
|
currentRefinement: currentRefinement
|
|
8831
8532
|
});
|
|
8832
8533
|
}
|
|
8833
|
-
|
|
8834
8534
|
return {
|
|
8835
8535
|
id: id,
|
|
8836
8536
|
index: index,
|
|
@@ -8842,33 +8542,25 @@
|
|
|
8842
8542
|
}
|
|
8843
8543
|
});
|
|
8844
8544
|
|
|
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
8545
|
var getId$4 = function getId(props) {
|
|
8849
8546
|
return props.attributes[0];
|
|
8850
8547
|
};
|
|
8851
8548
|
var namespace$1 = 'hierarchicalMenu';
|
|
8852
|
-
|
|
8853
8549
|
function getCurrentRefinement$2(props, searchState, context) {
|
|
8854
8550
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$1, ".").concat(getId$4(props)), null);
|
|
8855
|
-
|
|
8856
8551
|
if (currentRefinement === '') {
|
|
8857
8552
|
return null;
|
|
8858
8553
|
}
|
|
8859
|
-
|
|
8860
8554
|
return currentRefinement;
|
|
8861
8555
|
}
|
|
8862
|
-
|
|
8863
8556
|
function getValue(value, props, searchState, context) {
|
|
8864
8557
|
var id = props.id,
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8558
|
+
attributes = props.attributes,
|
|
8559
|
+
separator = props.separator,
|
|
8560
|
+
rootPath = props.rootPath,
|
|
8561
|
+
showParentLevel = props.showParentLevel;
|
|
8869
8562
|
var currentRefinement = getCurrentRefinement$2(props, searchState, context);
|
|
8870
8563
|
var nextRefinement;
|
|
8871
|
-
|
|
8872
8564
|
if (currentRefinement === null) {
|
|
8873
8565
|
nextRefinement = value;
|
|
8874
8566
|
} else {
|
|
@@ -8883,10 +8575,8 @@
|
|
|
8883
8575
|
});
|
|
8884
8576
|
nextRefinement = tmpSearchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement).toggleHierarchicalFacetRefinement(id, value).getHierarchicalRefinement(id)[0];
|
|
8885
8577
|
}
|
|
8886
|
-
|
|
8887
8578
|
return nextRefinement;
|
|
8888
8579
|
}
|
|
8889
|
-
|
|
8890
8580
|
function transformValue$1(value, props, searchState, context) {
|
|
8891
8581
|
return value.map(function (v) {
|
|
8892
8582
|
return {
|
|
@@ -8898,32 +8588,27 @@
|
|
|
8898
8588
|
};
|
|
8899
8589
|
});
|
|
8900
8590
|
}
|
|
8901
|
-
|
|
8902
8591
|
var truncate = function truncate() {
|
|
8903
8592
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
8904
8593
|
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
8905
8594
|
return items.slice(0, limit).map(function () {
|
|
8906
8595
|
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8907
|
-
return Array.isArray(item.items) ?
|
|
8596
|
+
return Array.isArray(item.items) ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
8908
8597
|
items: truncate(item.items, limit)
|
|
8909
8598
|
}) : item;
|
|
8910
8599
|
});
|
|
8911
8600
|
};
|
|
8912
|
-
|
|
8913
8601
|
function _refine$3(props, searchState, nextRefinement, context) {
|
|
8914
8602
|
var id = getId$4(props);
|
|
8915
|
-
|
|
8916
8603
|
var nextValue = _defineProperty({}, id, nextRefinement || '');
|
|
8917
|
-
|
|
8918
8604
|
var resetPage = true;
|
|
8919
8605
|
return refineValue(searchState, nextValue, context, resetPage, namespace$1);
|
|
8920
8606
|
}
|
|
8921
|
-
|
|
8922
8607
|
function _cleanUp$1(props, searchState, context) {
|
|
8923
8608
|
return cleanUpValue(searchState, context, "".concat(namespace$1, ".").concat(getId$4(props)));
|
|
8924
8609
|
}
|
|
8925
|
-
|
|
8926
8610
|
var sortBy = ['name:asc'];
|
|
8611
|
+
|
|
8927
8612
|
/**
|
|
8928
8613
|
* connectHierarchicalMenu connector provides the logic to build a widget that will
|
|
8929
8614
|
* give the user the ability to explore a tree-like structure.
|
|
@@ -8969,7 +8654,6 @@
|
|
|
8969
8654
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
8970
8655
|
* @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
8656
|
*/
|
|
8972
|
-
|
|
8973
8657
|
var connectHierarchicalMenu = createConnectorWithContext({
|
|
8974
8658
|
displayName: 'AlgoliaHierarchicalMenu',
|
|
8975
8659
|
$$type: 'ais.hierarchicalMenu',
|
|
@@ -8978,11 +8662,9 @@
|
|
|
8978
8662
|
var isNotString = function isNotString(val) {
|
|
8979
8663
|
return typeof val !== 'string';
|
|
8980
8664
|
};
|
|
8981
|
-
|
|
8982
8665
|
if (!Array.isArray(props[propName]) || props[propName].some(isNotString) || props[propName].length < 1) {
|
|
8983
8666
|
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an Array of Strings"));
|
|
8984
8667
|
}
|
|
8985
|
-
|
|
8986
8668
|
return undefined;
|
|
8987
8669
|
},
|
|
8988
8670
|
separator: propTypes.string,
|
|
@@ -9006,16 +8688,15 @@
|
|
|
9006
8688
|
},
|
|
9007
8689
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
9008
8690
|
var showMore = props.showMore,
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
8691
|
+
limit = props.limit,
|
|
8692
|
+
showMoreLimit = props.showMoreLimit,
|
|
8693
|
+
facetOrdering = props.facetOrdering;
|
|
9012
8694
|
var id = getId$4(props);
|
|
9013
8695
|
var results = getResults(searchResults, {
|
|
9014
8696
|
ais: props.contextValue,
|
|
9015
8697
|
multiIndexContext: props.indexContextValue
|
|
9016
8698
|
});
|
|
9017
8699
|
var isFacetPresent = Boolean(results) && Boolean(results.getFacetByName(id));
|
|
9018
|
-
|
|
9019
8700
|
if (!isFacetPresent) {
|
|
9020
8701
|
return {
|
|
9021
8702
|
items: [],
|
|
@@ -9026,7 +8707,6 @@
|
|
|
9026
8707
|
canRefine: false
|
|
9027
8708
|
};
|
|
9028
8709
|
}
|
|
9029
|
-
|
|
9030
8710
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
9031
8711
|
var value = results.getFacetValues(id, {
|
|
9032
8712
|
sortBy: sortBy,
|
|
@@ -9060,13 +8740,13 @@
|
|
|
9060
8740
|
},
|
|
9061
8741
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
9062
8742
|
var attributes = props.attributes,
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
8743
|
+
separator = props.separator,
|
|
8744
|
+
rootPath = props.rootPath,
|
|
8745
|
+
showParentLevel = props.showParentLevel,
|
|
8746
|
+
showMore = props.showMore,
|
|
8747
|
+
limit = props.limit,
|
|
8748
|
+
showMoreLimit = props.showMoreLimit,
|
|
8749
|
+
contextValue = props.contextValue;
|
|
9070
8750
|
var id = getId$4(props);
|
|
9071
8751
|
var itemsLimit = showMore ? showMoreLimit : limit;
|
|
9072
8752
|
searchParameters = searchParameters.addHierarchicalFacet({
|
|
@@ -9082,11 +8762,9 @@
|
|
|
9082
8762
|
ais: contextValue,
|
|
9083
8763
|
multiIndexContext: props.indexContextValue
|
|
9084
8764
|
});
|
|
9085
|
-
|
|
9086
8765
|
if (currentRefinement !== null) {
|
|
9087
8766
|
searchParameters = searchParameters.toggleHierarchicalFacetRefinement(id, currentRefinement);
|
|
9088
8767
|
}
|
|
9089
|
-
|
|
9090
8768
|
return searchParameters;
|
|
9091
8769
|
},
|
|
9092
8770
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9120,12 +8798,12 @@
|
|
|
9120
8798
|
|
|
9121
8799
|
var highlight = function highlight(_ref) {
|
|
9122
8800
|
var attribute = _ref.attribute,
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
8801
|
+
hit = _ref.hit,
|
|
8802
|
+
highlightProperty = _ref.highlightProperty,
|
|
8803
|
+
_ref$preTag = _ref.preTag,
|
|
8804
|
+
preTag = _ref$preTag === void 0 ? HIGHLIGHT_TAGS.highlightPreTag : _ref$preTag,
|
|
8805
|
+
_ref$postTag = _ref.postTag,
|
|
8806
|
+
postTag = _ref$postTag === void 0 ? HIGHLIGHT_TAGS.highlightPostTag : _ref$postTag;
|
|
9129
8807
|
return parseAlgoliaHit({
|
|
9130
8808
|
attribute: attribute,
|
|
9131
8809
|
highlightProperty: highlightProperty,
|
|
@@ -9134,6 +8812,7 @@
|
|
|
9134
8812
|
postTag: postTag
|
|
9135
8813
|
});
|
|
9136
8814
|
};
|
|
8815
|
+
|
|
9137
8816
|
/**
|
|
9138
8817
|
* connectHighlight connector provides the logic to create an highlighter
|
|
9139
8818
|
* component that will retrieve, parse and render an highlighted attribute
|
|
@@ -9184,8 +8863,6 @@
|
|
|
9184
8863
|
* </InstantSearch>
|
|
9185
8864
|
* );
|
|
9186
8865
|
*/
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
8866
|
var connectHighlight = createConnectorWithContext({
|
|
9190
8867
|
displayName: 'AlgoliaHighlighter',
|
|
9191
8868
|
$$type: 'ais.highlighter',
|
|
@@ -9240,7 +8917,6 @@
|
|
|
9240
8917
|
* </InstantSearch>
|
|
9241
8918
|
* );
|
|
9242
8919
|
*/
|
|
9243
|
-
|
|
9244
8920
|
var connectHits = createConnectorWithContext({
|
|
9245
8921
|
displayName: 'AlgoliaHits',
|
|
9246
8922
|
$$type: 'ais.hits',
|
|
@@ -9249,21 +8925,18 @@
|
|
|
9249
8925
|
ais: props.contextValue,
|
|
9250
8926
|
multiIndexContext: props.indexContextValue
|
|
9251
8927
|
});
|
|
9252
|
-
|
|
9253
8928
|
if (!results) {
|
|
9254
8929
|
return {
|
|
9255
8930
|
hits: []
|
|
9256
8931
|
};
|
|
9257
8932
|
}
|
|
9258
|
-
|
|
9259
8933
|
var hitsWithPositions = addAbsolutePositions(results.hits, results.hitsPerPage, results.page);
|
|
9260
8934
|
var hitsWithPositionsAndQueryID = addQueryID(hitsWithPositions, results.queryID);
|
|
9261
8935
|
return {
|
|
9262
8936
|
hits: hitsWithPositionsAndQueryID
|
|
9263
8937
|
};
|
|
9264
8938
|
},
|
|
9265
|
-
|
|
9266
|
-
/**
|
|
8939
|
+
/*
|
|
9267
8940
|
* Hits needs to be considered as a widget to trigger a search,
|
|
9268
8941
|
* even if no other widgets are used.
|
|
9269
8942
|
*
|
|
@@ -9279,24 +8952,18 @@
|
|
|
9279
8952
|
}
|
|
9280
8953
|
});
|
|
9281
8954
|
|
|
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
8955
|
function getId$5() {
|
|
9287
8956
|
return 'hitsPerPage';
|
|
9288
8957
|
}
|
|
9289
|
-
|
|
9290
8958
|
function getCurrentRefinement$3(props, searchState, context) {
|
|
9291
8959
|
var id = getId$5();
|
|
9292
8960
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
9293
|
-
|
|
9294
8961
|
if (typeof currentRefinement === 'string') {
|
|
9295
8962
|
return parseInt(currentRefinement, 10);
|
|
9296
8963
|
}
|
|
9297
|
-
|
|
9298
8964
|
return currentRefinement;
|
|
9299
8965
|
}
|
|
8966
|
+
|
|
9300
8967
|
/**
|
|
9301
8968
|
* connectHitsPerPage connector provides the logic to create connected
|
|
9302
8969
|
* components that will allow a user to choose to display more or less results from Algolia.
|
|
@@ -9310,8 +8977,6 @@
|
|
|
9310
8977
|
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
9311
8978
|
* @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
8979
|
*/
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
8980
|
var connectHitsPerPage = createConnectorWithContext({
|
|
9316
8981
|
displayName: 'AlgoliaHitsPerPage',
|
|
9317
8982
|
$$type: 'ais.hitsPerPage',
|
|
@@ -9329,9 +8994,9 @@
|
|
|
9329
8994
|
multiIndexContext: props.indexContextValue
|
|
9330
8995
|
});
|
|
9331
8996
|
var items = props.items.map(function (item) {
|
|
9332
|
-
return item.value === currentRefinement ?
|
|
8997
|
+
return item.value === currentRefinement ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9333
8998
|
isRefined: true
|
|
9334
|
-
}) :
|
|
8999
|
+
}) : _objectSpread2(_objectSpread2({}, item), {}, {
|
|
9335
9000
|
isRefined: false
|
|
9336
9001
|
});
|
|
9337
9002
|
});
|
|
@@ -9342,9 +9007,7 @@
|
|
|
9342
9007
|
},
|
|
9343
9008
|
refine: function refine(props, searchState, nextRefinement) {
|
|
9344
9009
|
var id = getId$5();
|
|
9345
|
-
|
|
9346
9010
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
9347
|
-
|
|
9348
9011
|
var resetPage = true;
|
|
9349
9012
|
return refineValue(searchState, nextValue, {
|
|
9350
9013
|
ais: props.contextValue,
|
|
@@ -9371,31 +9034,24 @@
|
|
|
9371
9034
|
});
|
|
9372
9035
|
|
|
9373
9036
|
var _excluded$4 = ["page"];
|
|
9374
|
-
|
|
9375
9037
|
function getId$6() {
|
|
9376
9038
|
return 'page';
|
|
9377
9039
|
}
|
|
9378
|
-
|
|
9379
9040
|
function getCurrentRefinement$4(props, searchState, context) {
|
|
9380
9041
|
var id = getId$6();
|
|
9381
9042
|
var page = 1;
|
|
9382
9043
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, page);
|
|
9383
|
-
|
|
9384
9044
|
if (typeof currentRefinement === 'string') {
|
|
9385
9045
|
return parseInt(currentRefinement, 10);
|
|
9386
9046
|
}
|
|
9387
|
-
|
|
9388
9047
|
return currentRefinement;
|
|
9389
9048
|
}
|
|
9390
|
-
|
|
9391
9049
|
function getStateWithoutPage(state) {
|
|
9392
9050
|
var _ref = state || {},
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9051
|
+
page = _ref.page,
|
|
9052
|
+
rest = _objectWithoutProperties(_ref, _excluded$4);
|
|
9396
9053
|
return rest;
|
|
9397
9054
|
}
|
|
9398
|
-
|
|
9399
9055
|
function getInMemoryCache() {
|
|
9400
9056
|
var cachedHits = undefined;
|
|
9401
9057
|
var cachedState = undefined;
|
|
@@ -9406,13 +9062,12 @@
|
|
|
9406
9062
|
},
|
|
9407
9063
|
write: function write(_ref3) {
|
|
9408
9064
|
var state = _ref3.state,
|
|
9409
|
-
|
|
9065
|
+
hits = _ref3.hits;
|
|
9410
9066
|
cachedState = getStateWithoutPage(state);
|
|
9411
9067
|
cachedHits = hits;
|
|
9412
9068
|
}
|
|
9413
9069
|
};
|
|
9414
9070
|
}
|
|
9415
|
-
|
|
9416
9071
|
function extractHitsFromCachedHits(cachedHits) {
|
|
9417
9072
|
return Object.keys(cachedHits).map(Number).sort(function (a, b) {
|
|
9418
9073
|
return a - b;
|
|
@@ -9420,6 +9075,7 @@
|
|
|
9420
9075
|
return acc.concat(cachedHits[page]);
|
|
9421
9076
|
}, []);
|
|
9422
9077
|
}
|
|
9078
|
+
|
|
9423
9079
|
/**
|
|
9424
9080
|
* InfiniteHits connector provides the logic to create connected
|
|
9425
9081
|
* components that will render an continuous list of results retrieved from
|
|
@@ -9430,19 +9086,15 @@
|
|
|
9430
9086
|
* @providedPropType {boolean} hasMore - indicates if there are more pages to load
|
|
9431
9087
|
* @providedPropType {function} refine - call to load more results
|
|
9432
9088
|
*/
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
9089
|
var connectInfiniteHits = createConnectorWithContext({
|
|
9436
9090
|
displayName: 'AlgoliaInfiniteHits',
|
|
9437
9091
|
$$type: 'ais.infiniteHits',
|
|
9438
9092
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
9439
9093
|
var _this = this;
|
|
9440
|
-
|
|
9441
9094
|
var results = getResults(searchResults, {
|
|
9442
9095
|
ais: props.contextValue,
|
|
9443
9096
|
multiIndexContext: props.indexContextValue
|
|
9444
9097
|
});
|
|
9445
|
-
|
|
9446
9098
|
if (!results) {
|
|
9447
9099
|
return {
|
|
9448
9100
|
hits: [],
|
|
@@ -9453,12 +9105,11 @@
|
|
|
9453
9105
|
refineNext: function refineNext() {}
|
|
9454
9106
|
};
|
|
9455
9107
|
}
|
|
9456
|
-
|
|
9457
9108
|
var page = results.page,
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9109
|
+
hits = results.hits,
|
|
9110
|
+
hitsPerPage = results.hitsPerPage,
|
|
9111
|
+
nbPages = results.nbPages,
|
|
9112
|
+
state = results._state;
|
|
9462
9113
|
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache();
|
|
9463
9114
|
var cachedHits = this._cache.read({
|
|
9464
9115
|
state: state
|
|
@@ -9466,31 +9117,26 @@
|
|
|
9466
9117
|
var hitsWithPositions = addAbsolutePositions(hits, hitsPerPage, page);
|
|
9467
9118
|
var hitsWithPositionsAndQueryID = addQueryID(hitsWithPositions, results.queryID);
|
|
9468
9119
|
cachedHits[page] = hitsWithPositionsAndQueryID;
|
|
9469
|
-
|
|
9470
9120
|
this._cache.write({
|
|
9471
9121
|
state: state,
|
|
9472
9122
|
hits: cachedHits
|
|
9473
9123
|
});
|
|
9124
|
+
|
|
9474
9125
|
/*
|
|
9475
9126
|
Math.min() and Math.max() returns Infinity or -Infinity when no argument is given.
|
|
9476
9127
|
But there is always something in this point because of `cachedHits[page]`.
|
|
9477
9128
|
*/
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
9129
|
var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
9481
9130
|
var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
9482
9131
|
var hasPrevious = firstReceivedPage > 0;
|
|
9483
9132
|
var lastPageIndex = nbPages - 1;
|
|
9484
9133
|
var hasMore = lastReceivedPage < lastPageIndex;
|
|
9485
|
-
|
|
9486
9134
|
var refinePrevious = function refinePrevious(event) {
|
|
9487
9135
|
return _this.refine(event, firstReceivedPage - 1);
|
|
9488
9136
|
};
|
|
9489
|
-
|
|
9490
9137
|
var refineNext = function refineNext(event) {
|
|
9491
9138
|
return _this.refine(event, lastReceivedPage + 1);
|
|
9492
9139
|
};
|
|
9493
|
-
|
|
9494
9140
|
return {
|
|
9495
9141
|
hits: extractHitsFromCachedHits(cachedHits),
|
|
9496
9142
|
hasPrevious: hasPrevious,
|
|
@@ -9509,9 +9155,7 @@
|
|
|
9509
9155
|
},
|
|
9510
9156
|
refine: function refine(props, searchState, event, index) {
|
|
9511
9157
|
var id = getId$6();
|
|
9512
|
-
|
|
9513
9158
|
var nextValue = _defineProperty({}, id, index + 1);
|
|
9514
|
-
|
|
9515
9159
|
var resetPage = false;
|
|
9516
9160
|
return refineValue(searchState, nextValue, {
|
|
9517
9161
|
ais: props.contextValue,
|
|
@@ -9521,47 +9165,37 @@
|
|
|
9521
9165
|
});
|
|
9522
9166
|
|
|
9523
9167
|
var namespace$2 = 'menu';
|
|
9524
|
-
|
|
9525
9168
|
function getId$7(props) {
|
|
9526
9169
|
return props.attribute;
|
|
9527
9170
|
}
|
|
9528
|
-
|
|
9529
9171
|
function getCurrentRefinement$5(props, searchState, context) {
|
|
9530
9172
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$2, ".").concat(getId$7(props)), null);
|
|
9531
|
-
|
|
9532
9173
|
if (currentRefinement === '') {
|
|
9533
9174
|
return null;
|
|
9534
9175
|
}
|
|
9535
|
-
|
|
9536
9176
|
return currentRefinement;
|
|
9537
9177
|
}
|
|
9538
|
-
|
|
9539
9178
|
function getValue$1(value, props, searchState, context) {
|
|
9540
9179
|
var currentRefinement = getCurrentRefinement$5(props, searchState, context);
|
|
9541
9180
|
return value === currentRefinement ? '' : value;
|
|
9542
9181
|
}
|
|
9543
|
-
|
|
9544
9182
|
function getLimit(_ref) {
|
|
9545
9183
|
var showMore = _ref.showMore,
|
|
9546
|
-
|
|
9547
|
-
|
|
9184
|
+
limit = _ref.limit,
|
|
9185
|
+
showMoreLimit = _ref.showMoreLimit;
|
|
9548
9186
|
return showMore ? showMoreLimit : limit;
|
|
9549
9187
|
}
|
|
9550
|
-
|
|
9551
9188
|
function _refine$4(props, searchState, nextRefinement, context) {
|
|
9552
9189
|
var id = getId$7(props);
|
|
9553
|
-
|
|
9554
9190
|
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : '');
|
|
9555
|
-
|
|
9556
9191
|
var resetPage = true;
|
|
9557
9192
|
return refineValue(searchState, nextValue, context, resetPage, namespace$2);
|
|
9558
9193
|
}
|
|
9559
|
-
|
|
9560
9194
|
function _cleanUp$2(props, searchState, context) {
|
|
9561
9195
|
return cleanUpValue(searchState, context, "".concat(namespace$2, ".").concat(getId$7(props)));
|
|
9562
9196
|
}
|
|
9563
|
-
|
|
9564
9197
|
var defaultSortBy = ['count:desc', 'name:asc'];
|
|
9198
|
+
|
|
9565
9199
|
/**
|
|
9566
9200
|
* connectMenu connector provides the logic to build a widget that will
|
|
9567
9201
|
* give the user the ability to choose a single value for a specific facet.
|
|
@@ -9582,7 +9216,6 @@
|
|
|
9582
9216
|
* @providedPropType {function} searchForItems - a function to toggle a search inside items values
|
|
9583
9217
|
* @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
9218
|
*/
|
|
9585
|
-
|
|
9586
9219
|
var connectMenu = createConnectorWithContext({
|
|
9587
9220
|
displayName: 'AlgoliaMenu',
|
|
9588
9221
|
$$type: 'ais.menu',
|
|
@@ -9604,20 +9237,20 @@
|
|
|
9604
9237
|
},
|
|
9605
9238
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults, meta, searchForFacetValuesResults) {
|
|
9606
9239
|
var attribute = props.attribute,
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9240
|
+
searchable = props.searchable,
|
|
9241
|
+
indexContextValue = props.indexContextValue,
|
|
9242
|
+
facetOrdering = props.facetOrdering;
|
|
9610
9243
|
var results = getResults(searchResults, {
|
|
9611
9244
|
ais: props.contextValue,
|
|
9612
9245
|
multiIndexContext: props.indexContextValue
|
|
9613
9246
|
});
|
|
9614
9247
|
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
9615
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
9248
|
+
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
9616
9249
|
|
|
9250
|
+
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
9617
9251
|
if (searchable && indexContextValue) {
|
|
9618
9252
|
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
9619
9253
|
}
|
|
9620
|
-
|
|
9621
9254
|
if (!canRefine) {
|
|
9622
9255
|
return {
|
|
9623
9256
|
items: [],
|
|
@@ -9630,9 +9263,7 @@
|
|
|
9630
9263
|
canRefine: canRefine
|
|
9631
9264
|
};
|
|
9632
9265
|
}
|
|
9633
|
-
|
|
9634
9266
|
var items;
|
|
9635
|
-
|
|
9636
9267
|
if (isFromSearch) {
|
|
9637
9268
|
items = searchForFacetValuesResults[attribute].map(function (v) {
|
|
9638
9269
|
return {
|
|
@@ -9666,7 +9297,6 @@
|
|
|
9666
9297
|
};
|
|
9667
9298
|
});
|
|
9668
9299
|
}
|
|
9669
|
-
|
|
9670
9300
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
9671
9301
|
return {
|
|
9672
9302
|
items: transformedItems.slice(0, getLimit(props)),
|
|
@@ -9708,11 +9338,9 @@
|
|
|
9708
9338
|
ais: props.contextValue,
|
|
9709
9339
|
multiIndexContext: props.indexContextValue
|
|
9710
9340
|
});
|
|
9711
|
-
|
|
9712
9341
|
if (currentRefinement !== null) {
|
|
9713
9342
|
searchParameters = searchParameters.addDisjunctiveFacetRefinement(attribute, currentRefinement);
|
|
9714
9343
|
}
|
|
9715
|
-
|
|
9716
9344
|
return searchParameters;
|
|
9717
9345
|
},
|
|
9718
9346
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9742,58 +9370,14 @@
|
|
|
9742
9370
|
}
|
|
9743
9371
|
});
|
|
9744
9372
|
|
|
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
9373
|
function stringifyItem(item) {
|
|
9788
9374
|
if (typeof item.start === 'undefined' && typeof item.end === 'undefined') {
|
|
9789
9375
|
return '';
|
|
9790
9376
|
}
|
|
9791
|
-
|
|
9792
9377
|
var start = typeof item.start !== 'undefined' ? item.start : '';
|
|
9793
9378
|
var end = typeof item.end !== 'undefined' ? item.end : '';
|
|
9794
9379
|
return "".concat(start, ":").concat(end);
|
|
9795
9380
|
}
|
|
9796
|
-
|
|
9797
9381
|
function parseItem(value) {
|
|
9798
9382
|
if (value.length === 0) {
|
|
9799
9383
|
return {
|
|
@@ -9801,36 +9385,28 @@
|
|
|
9801
9385
|
end: null
|
|
9802
9386
|
};
|
|
9803
9387
|
}
|
|
9804
|
-
|
|
9805
9388
|
var _value$split = value.split(':'),
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9389
|
+
_value$split2 = _slicedToArray(_value$split, 2),
|
|
9390
|
+
startStr = _value$split2[0],
|
|
9391
|
+
endStr = _value$split2[1];
|
|
9810
9392
|
return {
|
|
9811
9393
|
start: startStr.length > 0 ? parseFloat(startStr) : null,
|
|
9812
9394
|
end: endStr.length > 0 ? parseFloat(endStr) : null
|
|
9813
9395
|
};
|
|
9814
9396
|
}
|
|
9815
|
-
|
|
9816
9397
|
var namespace$3 = 'multiRange';
|
|
9817
|
-
|
|
9818
9398
|
function getId$8(props) {
|
|
9819
9399
|
return props.attribute;
|
|
9820
9400
|
}
|
|
9821
|
-
|
|
9822
9401
|
function getCurrentRefinement$6(props, searchState, context) {
|
|
9823
9402
|
return getCurrentRefinementValue(props, searchState, context, "".concat(namespace$3, ".").concat(getId$8(props)), '');
|
|
9824
9403
|
}
|
|
9825
|
-
|
|
9826
9404
|
function isRefinementsRangeIncludesInsideItemRange(stats, start, end) {
|
|
9827
9405
|
return stats.min >= start && stats.min <= end || stats.max >= start && stats.max <= end;
|
|
9828
9406
|
}
|
|
9829
|
-
|
|
9830
9407
|
function isItemRangeIncludedInsideRefinementsRange(stats, start, end) {
|
|
9831
9408
|
return start >= stats.min && start <= stats.max || end >= stats.min && end <= stats.max;
|
|
9832
9409
|
}
|
|
9833
|
-
|
|
9834
9410
|
function itemHasRefinement(attribute, results, value) {
|
|
9835
9411
|
var stats = results.getFacetByName(attribute) ? results.getFacetStats(attribute) : null;
|
|
9836
9412
|
var range = value.split(':');
|
|
@@ -9838,17 +9414,15 @@
|
|
|
9838
9414
|
var end = Number(range[1]) === 0 || value === '' ? Number.POSITIVE_INFINITY : Number(range[1]);
|
|
9839
9415
|
return !(Boolean(stats) && (isRefinementsRangeIncludesInsideItemRange(stats, start, end) || isItemRangeIncludedInsideRefinementsRange(stats, start, end)));
|
|
9840
9416
|
}
|
|
9841
|
-
|
|
9842
9417
|
function _refine$5(props, searchState, nextRefinement, context) {
|
|
9843
9418
|
var nextValue = _defineProperty({}, getId$8(props), nextRefinement);
|
|
9844
|
-
|
|
9845
9419
|
var resetPage = true;
|
|
9846
9420
|
return refineValue(searchState, nextValue, context, resetPage, namespace$3);
|
|
9847
9421
|
}
|
|
9848
|
-
|
|
9849
9422
|
function _cleanUp$3(props, searchState, context) {
|
|
9850
9423
|
return cleanUpValue(searchState, context, "".concat(namespace$3, ".").concat(getId$8(props)));
|
|
9851
9424
|
}
|
|
9425
|
+
|
|
9852
9426
|
/**
|
|
9853
9427
|
* connectNumericMenu connector provides the logic to build a widget that will
|
|
9854
9428
|
* give the user the ability to select a range value for a numeric attribute.
|
|
@@ -9865,8 +9439,6 @@
|
|
|
9865
9439
|
* @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
9440
|
* @providedPropType {array.<{isRefined: boolean, label: string, value: string, isRefined: boolean, noRefinement: boolean}>} items - the list of ranges the NumericMenu can display.
|
|
9867
9441
|
*/
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
9442
|
var connectNumericMenu = createConnectorWithContext({
|
|
9871
9443
|
displayName: 'AlgoliaNumericMenu',
|
|
9872
9444
|
$$type: 'ais.numericMenu',
|
|
@@ -9903,7 +9475,6 @@
|
|
|
9903
9475
|
var refinedItem = find(items, function (item) {
|
|
9904
9476
|
return item.isRefined === true;
|
|
9905
9477
|
});
|
|
9906
|
-
|
|
9907
9478
|
if (!items.some(function (item) {
|
|
9908
9479
|
return item.value === '';
|
|
9909
9480
|
})) {
|
|
@@ -9914,7 +9485,6 @@
|
|
|
9914
9485
|
label: 'All'
|
|
9915
9486
|
});
|
|
9916
9487
|
}
|
|
9917
|
-
|
|
9918
9488
|
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
9919
9489
|
return {
|
|
9920
9490
|
items: transformedItems,
|
|
@@ -9938,24 +9508,19 @@
|
|
|
9938
9508
|
},
|
|
9939
9509
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
9940
9510
|
var attribute = props.attribute;
|
|
9941
|
-
|
|
9942
9511
|
var _parseItem = parseItem(getCurrentRefinement$6(props, searchState, {
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9512
|
+
ais: props.contextValue,
|
|
9513
|
+
multiIndexContext: props.indexContextValue
|
|
9514
|
+
})),
|
|
9515
|
+
start = _parseItem.start,
|
|
9516
|
+
end = _parseItem.end;
|
|
9949
9517
|
searchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
9950
|
-
|
|
9951
9518
|
if (typeof start === 'number') {
|
|
9952
9519
|
searchParameters = searchParameters.addNumericRefinement(attribute, '>=', start);
|
|
9953
9520
|
}
|
|
9954
|
-
|
|
9955
9521
|
if (typeof end === 'number') {
|
|
9956
9522
|
searchParameters = searchParameters.addNumericRefinement(attribute, '<=', end);
|
|
9957
9523
|
}
|
|
9958
|
-
|
|
9959
9524
|
return searchParameters;
|
|
9960
9525
|
},
|
|
9961
9526
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -9969,13 +9534,11 @@
|
|
|
9969
9534
|
ais: props.contextValue,
|
|
9970
9535
|
multiIndexContext: props.indexContextValue
|
|
9971
9536
|
});
|
|
9972
|
-
|
|
9973
9537
|
if (value !== '') {
|
|
9974
9538
|
var _find = find(props.items, function (item) {
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9539
|
+
return stringifyItem(item) === value;
|
|
9540
|
+
}),
|
|
9541
|
+
label = _find.label;
|
|
9979
9542
|
items.push({
|
|
9980
9543
|
label: "".concat(props.attribute, ": ").concat(label),
|
|
9981
9544
|
attribute: props.attribute,
|
|
@@ -9988,7 +9551,6 @@
|
|
|
9988
9551
|
}
|
|
9989
9552
|
});
|
|
9990
9553
|
}
|
|
9991
|
-
|
|
9992
9554
|
return {
|
|
9993
9555
|
id: id,
|
|
9994
9556
|
index: index,
|
|
@@ -10000,27 +9562,22 @@
|
|
|
10000
9562
|
function getId$9() {
|
|
10001
9563
|
return 'page';
|
|
10002
9564
|
}
|
|
10003
|
-
|
|
10004
9565
|
function getCurrentRefinement$7(props, searchState, context) {
|
|
10005
9566
|
var id = getId$9();
|
|
10006
9567
|
var page = 1;
|
|
10007
9568
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, page);
|
|
10008
|
-
|
|
10009
9569
|
if (typeof currentRefinement === 'string') {
|
|
10010
9570
|
return parseInt(currentRefinement, 10);
|
|
10011
9571
|
}
|
|
10012
|
-
|
|
10013
9572
|
return currentRefinement;
|
|
10014
9573
|
}
|
|
10015
|
-
|
|
10016
9574
|
function _refine$6(props, searchState, nextPage, context) {
|
|
10017
9575
|
var id = getId$9();
|
|
10018
|
-
|
|
10019
9576
|
var nextValue = _defineProperty({}, id, nextPage);
|
|
10020
|
-
|
|
10021
9577
|
var resetPage = false;
|
|
10022
9578
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
10023
9579
|
}
|
|
9580
|
+
|
|
10024
9581
|
/**
|
|
10025
9582
|
* connectPagination connector provides the logic to build a widget that will
|
|
10026
9583
|
* let the user displays hits corresponding to a certain page.
|
|
@@ -10037,8 +9594,6 @@
|
|
|
10037
9594
|
* @providedPropType {number} nbPages - the total of existing pages
|
|
10038
9595
|
* @providedPropType {number} currentRefinement - the page refinement currently applied
|
|
10039
9596
|
*/
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
9597
|
var connectPagination = createConnectorWithContext({
|
|
10043
9598
|
displayName: 'AlgoliaPagination',
|
|
10044
9599
|
$$type: 'ais.pagination',
|
|
@@ -10047,11 +9602,9 @@
|
|
|
10047
9602
|
ais: props.contextValue,
|
|
10048
9603
|
multiIndexContext: props.indexContextValue
|
|
10049
9604
|
});
|
|
10050
|
-
|
|
10051
9605
|
if (!results) {
|
|
10052
9606
|
return null;
|
|
10053
9607
|
}
|
|
10054
|
-
|
|
10055
9608
|
var nbPages = results.nbPages;
|
|
10056
9609
|
return {
|
|
10057
9610
|
nbPages: nbPages,
|
|
@@ -10094,7 +9647,6 @@
|
|
|
10094
9647
|
* @kind connector
|
|
10095
9648
|
* @providedPropType {string} url - the url to redirect to algolia
|
|
10096
9649
|
*/
|
|
10097
|
-
|
|
10098
9650
|
var connectPoweredBy = createConnectorWithContext({
|
|
10099
9651
|
displayName: 'AlgoliaPoweredBy',
|
|
10100
9652
|
$$type: 'ais.poweredBy',
|
|
@@ -10132,13 +9684,10 @@
|
|
|
10132
9684
|
function getId$a(props) {
|
|
10133
9685
|
return props.attribute;
|
|
10134
9686
|
}
|
|
10135
|
-
|
|
10136
9687
|
var namespace$4 = 'range';
|
|
10137
|
-
|
|
10138
9688
|
function getCurrentRange(boundaries, stats, precision) {
|
|
10139
9689
|
var pow = Math.pow(10, precision);
|
|
10140
9690
|
var min;
|
|
10141
|
-
|
|
10142
9691
|
if (typeof boundaries.min === 'number' && isFinite(boundaries.min)) {
|
|
10143
9692
|
min = boundaries.min;
|
|
10144
9693
|
} else if (typeof stats.min === 'number' && isFinite(stats.min)) {
|
|
@@ -10146,9 +9695,7 @@
|
|
|
10146
9695
|
} else {
|
|
10147
9696
|
min = undefined;
|
|
10148
9697
|
}
|
|
10149
|
-
|
|
10150
9698
|
var max;
|
|
10151
|
-
|
|
10152
9699
|
if (typeof boundaries.max === 'number' && isFinite(boundaries.max)) {
|
|
10153
9700
|
max = boundaries.max;
|
|
10154
9701
|
} else if (typeof stats.max === 'number' && isFinite(stats.max)) {
|
|
@@ -10156,31 +9703,24 @@
|
|
|
10156
9703
|
} else {
|
|
10157
9704
|
max = undefined;
|
|
10158
9705
|
}
|
|
10159
|
-
|
|
10160
9706
|
return {
|
|
10161
9707
|
min: min !== undefined ? Math.floor(min * pow) / pow : min,
|
|
10162
9708
|
max: max !== undefined ? Math.ceil(max * pow) / pow : max
|
|
10163
9709
|
};
|
|
10164
9710
|
}
|
|
10165
|
-
|
|
10166
9711
|
function getCurrentRefinement$8(props, searchState, currentRange, context) {
|
|
10167
9712
|
var _getCurrentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$4, ".").concat(getId$a(props)), {}),
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
9713
|
+
min = _getCurrentRefinement.min,
|
|
9714
|
+
max = _getCurrentRefinement.max;
|
|
10171
9715
|
var isFloatPrecision = Boolean(props.precision);
|
|
10172
9716
|
var nextMin = min;
|
|
10173
|
-
|
|
10174
9717
|
if (typeof nextMin === 'string') {
|
|
10175
9718
|
nextMin = isFloatPrecision ? parseFloat(nextMin) : parseInt(nextMin, 10);
|
|
10176
9719
|
}
|
|
10177
|
-
|
|
10178
9720
|
var nextMax = max;
|
|
10179
|
-
|
|
10180
9721
|
if (typeof nextMax === 'string') {
|
|
10181
9722
|
nextMax = isFloatPrecision ? parseFloat(nextMax) : parseInt(nextMax, 10);
|
|
10182
9723
|
}
|
|
10183
|
-
|
|
10184
9724
|
var refinement = {
|
|
10185
9725
|
min: nextMin,
|
|
10186
9726
|
max: nextMax
|
|
@@ -10189,36 +9729,28 @@
|
|
|
10189
9729
|
var hasMaxBound = props.max !== undefined;
|
|
10190
9730
|
var hasMinRefinment = refinement.min !== undefined;
|
|
10191
9731
|
var hasMaxRefinment = refinement.max !== undefined;
|
|
10192
|
-
|
|
10193
9732
|
if (hasMinBound && hasMinRefinment && refinement.min < currentRange.min) {
|
|
10194
9733
|
throw Error("You can't provide min value lower than range.");
|
|
10195
9734
|
}
|
|
10196
|
-
|
|
10197
9735
|
if (hasMaxBound && hasMaxRefinment && refinement.max > currentRange.max) {
|
|
10198
9736
|
throw Error("You can't provide max value greater than range.");
|
|
10199
9737
|
}
|
|
10200
|
-
|
|
10201
9738
|
if (hasMinBound && !hasMinRefinment) {
|
|
10202
9739
|
refinement.min = currentRange.min;
|
|
10203
9740
|
}
|
|
10204
|
-
|
|
10205
9741
|
if (hasMaxBound && !hasMaxRefinment) {
|
|
10206
9742
|
refinement.max = currentRange.max;
|
|
10207
9743
|
}
|
|
10208
|
-
|
|
10209
9744
|
return refinement;
|
|
10210
9745
|
}
|
|
10211
|
-
|
|
10212
9746
|
function getCurrentRefinementWithRange(refinement, range) {
|
|
10213
9747
|
return {
|
|
10214
9748
|
min: refinement.min !== undefined ? refinement.min : range.min,
|
|
10215
9749
|
max: refinement.max !== undefined ? refinement.max : range.max
|
|
10216
9750
|
};
|
|
10217
9751
|
}
|
|
10218
|
-
|
|
10219
9752
|
function nextValueForRefinement(hasBound, isReset, range, value) {
|
|
10220
9753
|
var next;
|
|
10221
|
-
|
|
10222
9754
|
if (!hasBound && range === value) {
|
|
10223
9755
|
next = undefined;
|
|
10224
9756
|
} else if (hasBound && isReset) {
|
|
@@ -10226,49 +9758,39 @@
|
|
|
10226
9758
|
} else {
|
|
10227
9759
|
next = value;
|
|
10228
9760
|
}
|
|
10229
|
-
|
|
10230
9761
|
return next;
|
|
10231
9762
|
}
|
|
10232
|
-
|
|
10233
9763
|
function _refine$7(props, searchState, nextRefinement, currentRange, context) {
|
|
10234
9764
|
var nextMin = nextRefinement.min,
|
|
10235
|
-
|
|
9765
|
+
nextMax = nextRefinement.max;
|
|
10236
9766
|
var currentMinRange = currentRange.min,
|
|
10237
|
-
|
|
9767
|
+
currentMaxRange = currentRange.max;
|
|
10238
9768
|
var isMinReset = nextMin === undefined || nextMin === '';
|
|
10239
9769
|
var isMaxReset = nextMax === undefined || nextMax === '';
|
|
10240
9770
|
var nextMinAsNumber = !isMinReset ? parseFloat(nextMin) : undefined;
|
|
10241
9771
|
var nextMaxAsNumber = !isMaxReset ? parseFloat(nextMax) : undefined;
|
|
10242
9772
|
var isNextMinValid = isMinReset || isFinite(nextMinAsNumber);
|
|
10243
9773
|
var isNextMaxValid = isMaxReset || isFinite(nextMaxAsNumber);
|
|
10244
|
-
|
|
10245
9774
|
if (!isNextMinValid || !isNextMaxValid) {
|
|
10246
9775
|
throw Error("You can't provide non finite values to the range connector.");
|
|
10247
9776
|
}
|
|
10248
|
-
|
|
10249
9777
|
if (nextMinAsNumber < currentMinRange) {
|
|
10250
9778
|
throw Error("You can't provide min value lower than range.");
|
|
10251
9779
|
}
|
|
10252
|
-
|
|
10253
9780
|
if (nextMaxAsNumber > currentMaxRange) {
|
|
10254
9781
|
throw Error("You can't provide max value greater than range.");
|
|
10255
9782
|
}
|
|
10256
|
-
|
|
10257
9783
|
var id = getId$a(props);
|
|
10258
9784
|
var resetPage = true;
|
|
10259
|
-
|
|
10260
9785
|
var nextValue = _defineProperty({}, id, {
|
|
10261
9786
|
min: nextValueForRefinement(props.min !== undefined, isMinReset, currentMinRange, nextMinAsNumber),
|
|
10262
9787
|
max: nextValueForRefinement(props.max !== undefined, isMaxReset, currentMaxRange, nextMaxAsNumber)
|
|
10263
9788
|
});
|
|
10264
|
-
|
|
10265
9789
|
return refineValue(searchState, nextValue, context, resetPage, namespace$4);
|
|
10266
9790
|
}
|
|
10267
|
-
|
|
10268
9791
|
function _cleanUp$4(props, searchState, context) {
|
|
10269
9792
|
return cleanUpValue(searchState, context, "".concat(namespace$4, ".").concat(getId$a(props)));
|
|
10270
9793
|
}
|
|
10271
|
-
|
|
10272
9794
|
var connectRange = createConnectorWithContext({
|
|
10273
9795
|
displayName: 'AlgoliaRange',
|
|
10274
9796
|
$$type: 'ais.range',
|
|
@@ -10290,9 +9812,9 @@
|
|
|
10290
9812
|
},
|
|
10291
9813
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
10292
9814
|
var attribute = props.attribute,
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
9815
|
+
precision = props.precision,
|
|
9816
|
+
minBound = props.min,
|
|
9817
|
+
maxBound = props.max;
|
|
10296
9818
|
var results = getResults(searchResults, {
|
|
10297
9819
|
ais: props.contextValue,
|
|
10298
9820
|
multiIndexContext: props.indexContextValue
|
|
@@ -10306,18 +9828,17 @@
|
|
|
10306
9828
|
count: v.count
|
|
10307
9829
|
};
|
|
10308
9830
|
});
|
|
10309
|
-
|
|
10310
9831
|
var _getCurrentRange = getCurrentRange({
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
9832
|
+
min: minBound,
|
|
9833
|
+
max: maxBound
|
|
9834
|
+
}, stats, precision),
|
|
9835
|
+
rangeMin = _getCurrentRange.min,
|
|
9836
|
+
rangeMax = _getCurrentRange.max;
|
|
9837
|
+
|
|
9838
|
+
// The searchState is not always in sync with the helper state. For example
|
|
10316
9839
|
// when we set boundaries on the first render the searchState don't have
|
|
10317
9840
|
// the correct refinement. If this behavior change in the upcoming version
|
|
10318
9841
|
// we could store the range inside the searchState instead of rely on `this`.
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
9842
|
this._currentRange = {
|
|
10322
9843
|
min: rangeMin,
|
|
10323
9844
|
max: rangeMax
|
|
@@ -10349,46 +9870,37 @@
|
|
|
10349
9870
|
},
|
|
10350
9871
|
getSearchParameters: function getSearchParameters(params, props, searchState) {
|
|
10351
9872
|
var attribute = props.attribute;
|
|
10352
|
-
|
|
10353
9873
|
var _getCurrentRefinement2 = getCurrentRefinement$8(props, searchState, this._currentRange, {
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
9874
|
+
ais: props.contextValue,
|
|
9875
|
+
multiIndexContext: props.indexContextValue
|
|
9876
|
+
}),
|
|
9877
|
+
min = _getCurrentRefinement2.min,
|
|
9878
|
+
max = _getCurrentRefinement2.max;
|
|
10360
9879
|
params = params.addDisjunctiveFacet(attribute);
|
|
10361
|
-
|
|
10362
9880
|
if (min !== undefined) {
|
|
10363
9881
|
params = params.addNumericRefinement(attribute, '>=', min);
|
|
10364
9882
|
}
|
|
10365
|
-
|
|
10366
9883
|
if (max !== undefined) {
|
|
10367
9884
|
params = params.addNumericRefinement(attribute, '<=', max);
|
|
10368
9885
|
}
|
|
10369
|
-
|
|
10370
9886
|
return params;
|
|
10371
9887
|
},
|
|
10372
9888
|
getMetadata: function getMetadata(props, searchState) {
|
|
10373
9889
|
var _this = this;
|
|
10374
|
-
|
|
10375
9890
|
var _this$_currentRange = this._currentRange,
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
9891
|
+
minRange = _this$_currentRange.min,
|
|
9892
|
+
maxRange = _this$_currentRange.max;
|
|
10379
9893
|
var _getCurrentRefinement3 = getCurrentRefinement$8(props, searchState, this._currentRange, {
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
9894
|
+
ais: props.contextValue,
|
|
9895
|
+
multiIndexContext: props.indexContextValue
|
|
9896
|
+
}),
|
|
9897
|
+
minValue = _getCurrentRefinement3.min,
|
|
9898
|
+
maxValue = _getCurrentRefinement3.max;
|
|
10386
9899
|
var items = [];
|
|
10387
9900
|
var hasMin = minValue !== undefined;
|
|
10388
9901
|
var hasMax = maxValue !== undefined;
|
|
10389
9902
|
var shouldDisplayMinLabel = hasMin && minValue !== minRange;
|
|
10390
9903
|
var shouldDisplayMaxLabel = hasMax && maxValue !== maxRange;
|
|
10391
|
-
|
|
10392
9904
|
if (shouldDisplayMinLabel || shouldDisplayMaxLabel) {
|
|
10393
9905
|
var fragments = [hasMin ? "".concat(minValue, " <= ") : '', props.attribute, hasMax ? " <= ".concat(maxValue) : ''];
|
|
10394
9906
|
items.push({
|
|
@@ -10409,7 +9921,6 @@
|
|
|
10409
9921
|
})
|
|
10410
9922
|
});
|
|
10411
9923
|
}
|
|
10412
|
-
|
|
10413
9924
|
return {
|
|
10414
9925
|
id: getId$a(props),
|
|
10415
9926
|
index: getIndexId({
|
|
@@ -10422,25 +9933,19 @@
|
|
|
10422
9933
|
});
|
|
10423
9934
|
|
|
10424
9935
|
var namespace$5 = 'refinementList';
|
|
10425
|
-
|
|
10426
9936
|
function getId$b(props) {
|
|
10427
9937
|
return props.attribute;
|
|
10428
9938
|
}
|
|
10429
|
-
|
|
10430
9939
|
function getCurrentRefinement$9(props, searchState, context) {
|
|
10431
9940
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$5, ".").concat(getId$b(props)), []);
|
|
10432
|
-
|
|
10433
9941
|
if (typeof currentRefinement !== 'string') {
|
|
10434
9942
|
return currentRefinement;
|
|
10435
9943
|
}
|
|
10436
|
-
|
|
10437
9944
|
if (currentRefinement) {
|
|
10438
9945
|
return [currentRefinement];
|
|
10439
9946
|
}
|
|
10440
|
-
|
|
10441
9947
|
return [];
|
|
10442
9948
|
}
|
|
10443
|
-
|
|
10444
9949
|
function getValue$2(value, props, searchState, context) {
|
|
10445
9950
|
var currentRefinement = getCurrentRefinement$9(props, searchState, context);
|
|
10446
9951
|
var isAnewValue = currentRefinement.indexOf(value) === -1;
|
|
@@ -10448,32 +9953,27 @@
|
|
|
10448
9953
|
: currentRefinement.filter(function (selectedValue) {
|
|
10449
9954
|
return selectedValue !== value;
|
|
10450
9955
|
}); // cannot use .splice(), it mutates
|
|
10451
|
-
|
|
10452
9956
|
return nextRefinement;
|
|
10453
9957
|
}
|
|
10454
|
-
|
|
10455
9958
|
function getLimit$1(_ref) {
|
|
10456
9959
|
var showMore = _ref.showMore,
|
|
10457
|
-
|
|
10458
|
-
|
|
9960
|
+
limit = _ref.limit,
|
|
9961
|
+
showMoreLimit = _ref.showMoreLimit;
|
|
10459
9962
|
return showMore ? showMoreLimit : limit;
|
|
10460
9963
|
}
|
|
10461
|
-
|
|
10462
9964
|
function _refine$8(props, searchState, nextRefinement, context) {
|
|
10463
|
-
var id = getId$b(props);
|
|
9965
|
+
var id = getId$b(props);
|
|
9966
|
+
// Setting the value to an empty string ensures that it is persisted in
|
|
10464
9967
|
// the URL as an empty value.
|
|
10465
9968
|
// This is necessary in the case where `defaultRefinement` contains one
|
|
10466
9969
|
// item and we try to deselect it. `nextSelected` would be an empty array,
|
|
10467
9970
|
// which would not be persisted to the URL.
|
|
10468
9971
|
// {foo: ['bar']} => "foo[0]=bar"
|
|
10469
9972
|
// {foo: []} => ""
|
|
10470
|
-
|
|
10471
9973
|
var nextValue = _defineProperty({}, id, nextRefinement.length > 0 ? nextRefinement : '');
|
|
10472
|
-
|
|
10473
9974
|
var resetPage = true;
|
|
10474
9975
|
return refineValue(searchState, nextValue, context, resetPage, namespace$5);
|
|
10475
9976
|
}
|
|
10476
|
-
|
|
10477
9977
|
function _cleanUp$5(props, searchState, context) {
|
|
10478
9978
|
return cleanUpValue(searchState, context, "".concat(namespace$5, ".").concat(getId$b(props)));
|
|
10479
9979
|
}
|
|
@@ -10501,7 +10001,6 @@
|
|
|
10501
10001
|
* @providedPropType {boolean} canRefine - a boolean that says whether you can refine
|
|
10502
10002
|
*/
|
|
10503
10003
|
|
|
10504
|
-
|
|
10505
10004
|
var sortBy$1 = ['isRefined', 'count:desc', 'name:asc'];
|
|
10506
10005
|
var connectRefinementList = createConnectorWithContext({
|
|
10507
10006
|
displayName: 'AlgoliaRefinementList',
|
|
@@ -10527,20 +10026,20 @@
|
|
|
10527
10026
|
},
|
|
10528
10027
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults, metadata, searchForFacetValuesResults) {
|
|
10529
10028
|
var attribute = props.attribute,
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10029
|
+
searchable = props.searchable,
|
|
10030
|
+
indexContextValue = props.indexContextValue,
|
|
10031
|
+
facetOrdering = props.facetOrdering;
|
|
10533
10032
|
var results = getResults(searchResults, {
|
|
10534
10033
|
ais: props.contextValue,
|
|
10535
10034
|
multiIndexContext: props.indexContextValue
|
|
10536
10035
|
});
|
|
10537
10036
|
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
10538
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
10037
|
+
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
10539
10038
|
|
|
10039
|
+
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
10540
10040
|
if (searchable && indexContextValue) {
|
|
10541
10041
|
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
10542
10042
|
}
|
|
10543
|
-
|
|
10544
10043
|
if (!canRefine) {
|
|
10545
10044
|
return {
|
|
10546
10045
|
items: [],
|
|
@@ -10553,7 +10052,6 @@
|
|
|
10553
10052
|
searchable: searchable
|
|
10554
10053
|
};
|
|
10555
10054
|
}
|
|
10556
|
-
|
|
10557
10055
|
var items = isFromSearch ? searchForFacetValuesResults[attribute].map(function (v) {
|
|
10558
10056
|
return {
|
|
10559
10057
|
label: v.value,
|
|
@@ -10616,7 +10114,7 @@
|
|
|
10616
10114
|
},
|
|
10617
10115
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
10618
10116
|
var attribute = props.attribute,
|
|
10619
|
-
|
|
10117
|
+
operator = props.operator;
|
|
10620
10118
|
var addKey = operator === 'and' ? 'addFacet' : 'addDisjunctiveFacet';
|
|
10621
10119
|
var addRefinementKey = "".concat(addKey, "Refinement");
|
|
10622
10120
|
searchParameters = searchParameters.setQueryParameters({
|
|
@@ -10671,7 +10169,6 @@
|
|
|
10671
10169
|
* @providedPropType {any} value - the current refinement applied to the widget listened by scrollTo
|
|
10672
10170
|
* @providedPropType {boolean} hasNotChanged - indicates whether the refinement came from the scrollOn argument (for instance page by default)
|
|
10673
10171
|
*/
|
|
10674
|
-
|
|
10675
10172
|
var connectScrollTo = createConnectorWithContext({
|
|
10676
10173
|
displayName: 'AlgoliaScrollTo',
|
|
10677
10174
|
$$type: 'ais.scrollTo',
|
|
@@ -10687,12 +10184,11 @@
|
|
|
10687
10184
|
ais: props.contextValue,
|
|
10688
10185
|
multiIndexContext: props.indexContextValue
|
|
10689
10186
|
}, id, null);
|
|
10690
|
-
|
|
10691
10187
|
if (!this._prevSearchState) {
|
|
10692
10188
|
this._prevSearchState = {};
|
|
10693
|
-
}
|
|
10694
|
-
|
|
10189
|
+
}
|
|
10695
10190
|
|
|
10191
|
+
// Get the subpart of the state that interest us
|
|
10696
10192
|
if (hasMultipleIndices({
|
|
10697
10193
|
ais: props.contextValue,
|
|
10698
10194
|
multiIndexContext: props.indexContextValue
|
|
@@ -10701,7 +10197,9 @@
|
|
|
10701
10197
|
ais: props.contextValue,
|
|
10702
10198
|
multiIndexContext: props.indexContextValue
|
|
10703
10199
|
})] : {};
|
|
10704
|
-
}
|
|
10200
|
+
}
|
|
10201
|
+
|
|
10202
|
+
// if there is a change in the app that has been triggered by another element
|
|
10705
10203
|
// than "props.scrollOn (id) or the Configure widget, we need to keep track of
|
|
10706
10204
|
// the search state to know if there's a change in the app that was not triggered
|
|
10707
10205
|
// by the props.scrollOn (id) or the Configure widget. This is useful when
|
|
@@ -10711,8 +10209,6 @@
|
|
|
10711
10209
|
// do this comparison because for now configure values are not present in the
|
|
10712
10210
|
// search state before a first refinement has been made and will false the results.
|
|
10713
10211
|
// See: https://github.com/algolia/react-instantsearch/issues/164
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
10212
|
var cleanedSearchState = omit(searchState, ['configure', id]);
|
|
10717
10213
|
var hasNotChanged = shallowEqual(this._prevSearchState, cleanedSearchState);
|
|
10718
10214
|
this._prevSearchState = cleanedSearchState;
|
|
@@ -10726,30 +10222,24 @@
|
|
|
10726
10222
|
function getId$c() {
|
|
10727
10223
|
return 'query';
|
|
10728
10224
|
}
|
|
10729
|
-
|
|
10730
10225
|
function getCurrentRefinement$a(props, searchState, context) {
|
|
10731
10226
|
var id = getId$c();
|
|
10732
10227
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
10733
|
-
|
|
10734
10228
|
if (currentRefinement) {
|
|
10735
10229
|
return currentRefinement;
|
|
10736
10230
|
}
|
|
10737
|
-
|
|
10738
10231
|
return '';
|
|
10739
10232
|
}
|
|
10740
|
-
|
|
10741
10233
|
function _refine$9(props, searchState, nextRefinement, context) {
|
|
10742
10234
|
var id = getId$c();
|
|
10743
|
-
|
|
10744
10235
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
10745
|
-
|
|
10746
10236
|
var resetPage = true;
|
|
10747
10237
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
10748
10238
|
}
|
|
10749
|
-
|
|
10750
10239
|
function _cleanUp$6(props, searchState, context) {
|
|
10751
10240
|
return cleanUpValue(searchState, context, getId$c());
|
|
10752
10241
|
}
|
|
10242
|
+
|
|
10753
10243
|
/**
|
|
10754
10244
|
* connectSearchBox connector provides the logic to build a widget that will
|
|
10755
10245
|
* let the user search for a query
|
|
@@ -10760,8 +10250,6 @@
|
|
|
10760
10250
|
* @providedPropType {string} currentRefinement - the current query used
|
|
10761
10251
|
* @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled
|
|
10762
10252
|
*/
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
10253
|
var connectSearchBox = createConnectorWithContext({
|
|
10766
10254
|
displayName: 'AlgoliaSearchBox',
|
|
10767
10255
|
$$type: 'ais.searchBox',
|
|
@@ -10824,13 +10312,11 @@
|
|
|
10824
10312
|
function getId$d() {
|
|
10825
10313
|
return 'relevancyStrictness';
|
|
10826
10314
|
}
|
|
10827
|
-
|
|
10828
10315
|
function getCurrentRefinement$b(props, searchState, context) {
|
|
10829
10316
|
var id = getId$d();
|
|
10830
10317
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id);
|
|
10831
10318
|
return currentRefinement;
|
|
10832
10319
|
}
|
|
10833
|
-
|
|
10834
10320
|
var connectRelevantSort = createConnectorWithContext({
|
|
10835
10321
|
displayName: 'AlgoliaRelevantSort',
|
|
10836
10322
|
$$type: 'ais.relevantSort',
|
|
@@ -10839,14 +10325,12 @@
|
|
|
10839
10325
|
ais: props.contextValue,
|
|
10840
10326
|
multiIndexContext: props.indexContextValue
|
|
10841
10327
|
});
|
|
10842
|
-
|
|
10843
10328
|
if (!results) {
|
|
10844
10329
|
return {
|
|
10845
10330
|
isVirtualReplica: false,
|
|
10846
10331
|
isRelevantSorted: false
|
|
10847
10332
|
};
|
|
10848
10333
|
}
|
|
10849
|
-
|
|
10850
10334
|
return {
|
|
10851
10335
|
isVirtualReplica: results.appliedRelevancyStrictness !== undefined,
|
|
10852
10336
|
isRelevantSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0
|
|
@@ -10860,7 +10344,6 @@
|
|
|
10860
10344
|
},
|
|
10861
10345
|
refine: function refine(props, searchState, nextRefinement) {
|
|
10862
10346
|
var nextValue = _defineProperty({}, getId$d(), nextRefinement);
|
|
10863
|
-
|
|
10864
10347
|
var resetPage = true;
|
|
10865
10348
|
return refineValue(searchState, nextValue, {
|
|
10866
10349
|
ais: props.contextValue,
|
|
@@ -10869,24 +10352,18 @@
|
|
|
10869
10352
|
}
|
|
10870
10353
|
});
|
|
10871
10354
|
|
|
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
10355
|
function getId$e() {
|
|
10877
10356
|
return 'sortBy';
|
|
10878
10357
|
}
|
|
10879
|
-
|
|
10880
10358
|
function getCurrentRefinement$c(props, searchState, context) {
|
|
10881
10359
|
var id = getId$e();
|
|
10882
10360
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, null);
|
|
10883
|
-
|
|
10884
10361
|
if (currentRefinement) {
|
|
10885
10362
|
return currentRefinement;
|
|
10886
10363
|
}
|
|
10887
|
-
|
|
10888
10364
|
return null;
|
|
10889
10365
|
}
|
|
10366
|
+
|
|
10890
10367
|
/**
|
|
10891
10368
|
* The connectSortBy connector provides the logic to build a widget that will
|
|
10892
10369
|
* display a list of indices. This allows a user to change how the hits are being sorted.
|
|
@@ -10902,8 +10379,6 @@
|
|
|
10902
10379
|
* @providedPropType {string[]} currentRefinement - the refinement currently applied
|
|
10903
10380
|
* @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
10381
|
*/
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
10382
|
var connectSortBy = createConnectorWithContext({
|
|
10908
10383
|
displayName: 'AlgoliaSortBy',
|
|
10909
10384
|
$$type: 'ais.sortBy',
|
|
@@ -10921,9 +10396,9 @@
|
|
|
10921
10396
|
multiIndexContext: props.indexContextValue
|
|
10922
10397
|
});
|
|
10923
10398
|
var items = props.items.map(function (item) {
|
|
10924
|
-
return item.value === currentRefinement ?
|
|
10399
|
+
return item.value === currentRefinement ? _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10925
10400
|
isRefined: true
|
|
10926
|
-
}) :
|
|
10401
|
+
}) : _objectSpread2(_objectSpread2({}, item), {}, {
|
|
10927
10402
|
isRefined: false
|
|
10928
10403
|
});
|
|
10929
10404
|
});
|
|
@@ -10934,9 +10409,7 @@
|
|
|
10934
10409
|
},
|
|
10935
10410
|
refine: function refine(props, searchState, nextRefinement) {
|
|
10936
10411
|
var id = getId$e();
|
|
10937
|
-
|
|
10938
10412
|
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
10939
|
-
|
|
10940
10413
|
var resetPage = true;
|
|
10941
10414
|
return refineValue(searchState, nextValue, {
|
|
10942
10415
|
ais: props.contextValue,
|
|
@@ -11012,7 +10485,6 @@
|
|
|
11012
10485
|
* </InstantSearch>
|
|
11013
10486
|
* );
|
|
11014
10487
|
*/
|
|
11015
|
-
|
|
11016
10488
|
var connectStateResults = createConnectorWithContext({
|
|
11017
10489
|
displayName: 'AlgoliaStateResults',
|
|
11018
10490
|
$$type: 'ais.stateResults',
|
|
@@ -11043,7 +10515,6 @@
|
|
|
11043
10515
|
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia.
|
|
11044
10516
|
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results.
|
|
11045
10517
|
*/
|
|
11046
|
-
|
|
11047
10518
|
var connectStats = createConnectorWithContext({
|
|
11048
10519
|
displayName: 'AlgoliaStats',
|
|
11049
10520
|
$$type: 'ais.stats',
|
|
@@ -11052,11 +10523,9 @@
|
|
|
11052
10523
|
ais: props.contextValue,
|
|
11053
10524
|
multiIndexContext: props.indexContextValue
|
|
11054
10525
|
});
|
|
11055
|
-
|
|
11056
10526
|
if (!results) {
|
|
11057
10527
|
return null;
|
|
11058
10528
|
}
|
|
11059
|
-
|
|
11060
10529
|
return {
|
|
11061
10530
|
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits,
|
|
11062
10531
|
nbHits: results.nbHits,
|
|
@@ -11069,32 +10538,25 @@
|
|
|
11069
10538
|
function getId$f(props) {
|
|
11070
10539
|
return props.attribute;
|
|
11071
10540
|
}
|
|
11072
|
-
|
|
11073
10541
|
var namespace$6 = 'toggle';
|
|
11074
10542
|
var falsyStrings = ['0', 'false', 'null', 'undefined'];
|
|
11075
|
-
|
|
11076
10543
|
function getCurrentRefinement$d(props, searchState, context) {
|
|
11077
10544
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, "".concat(namespace$6, ".").concat(getId$f(props)), false);
|
|
11078
|
-
|
|
11079
10545
|
if (falsyStrings.indexOf(currentRefinement) !== -1) {
|
|
11080
10546
|
return false;
|
|
11081
10547
|
}
|
|
11082
|
-
|
|
11083
10548
|
return Boolean(currentRefinement);
|
|
11084
10549
|
}
|
|
11085
|
-
|
|
11086
10550
|
function _refine$a(props, searchState, nextRefinement, context) {
|
|
11087
10551
|
var id = getId$f(props);
|
|
11088
|
-
|
|
11089
10552
|
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : false);
|
|
11090
|
-
|
|
11091
10553
|
var resetPage = true;
|
|
11092
10554
|
return refineValue(searchState, nextValue, context, resetPage, namespace$6);
|
|
11093
10555
|
}
|
|
11094
|
-
|
|
11095
10556
|
function _cleanUp$7(props, searchState, context) {
|
|
11096
10557
|
return cleanUpValue(searchState, context, "".concat(namespace$6, ".").concat(getId$f(props)));
|
|
11097
10558
|
}
|
|
10559
|
+
|
|
11098
10560
|
/**
|
|
11099
10561
|
* connectToggleRefinement connector provides the logic to build a widget that will
|
|
11100
10562
|
* provides an on/off filtering feature based on an attribute value.
|
|
@@ -11114,8 +10576,6 @@
|
|
|
11114
10576
|
* @providedPropType {function} refine - a function to toggle a refinement
|
|
11115
10577
|
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
11116
10578
|
*/
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
10579
|
var connectToggleRefinement = createConnectorWithContext({
|
|
11120
10580
|
displayName: 'AlgoliaToggle',
|
|
11121
10581
|
$$type: 'ais.toggle',
|
|
@@ -11128,7 +10588,7 @@
|
|
|
11128
10588
|
},
|
|
11129
10589
|
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
11130
10590
|
var attribute = props.attribute,
|
|
11131
|
-
|
|
10591
|
+
value = props.value;
|
|
11132
10592
|
var results = getResults(searchResults, {
|
|
11133
10593
|
ais: props.contextValue,
|
|
11134
10594
|
multiIndexContext: props.indexContextValue
|
|
@@ -11138,13 +10598,15 @@
|
|
|
11138
10598
|
multiIndexContext: props.indexContextValue
|
|
11139
10599
|
});
|
|
11140
10600
|
var allFacetValues = results && results.getFacetByName(attribute) ? results.getFacetValues(attribute) : null;
|
|
11141
|
-
var facetValue =
|
|
10601
|
+
var facetValue =
|
|
10602
|
+
// Use null to always be consistent with type of the value
|
|
11142
10603
|
// count: number | null
|
|
11143
10604
|
allFacetValues && allFacetValues.length ? find(allFacetValues, function (item) {
|
|
11144
10605
|
return item.name === value.toString();
|
|
11145
10606
|
}) : null;
|
|
11146
10607
|
var facetValueCount = facetValue && facetValue.count;
|
|
11147
|
-
var allFacetValuesCount =
|
|
10608
|
+
var allFacetValuesCount =
|
|
10609
|
+
// Use null to always be consistent with type of the value
|
|
11148
10610
|
// count: number | null
|
|
11149
10611
|
allFacetValues && allFacetValues.length ? allFacetValues.reduce(function (acc, item) {
|
|
11150
10612
|
return acc + item.count;
|
|
@@ -11174,22 +10636,19 @@
|
|
|
11174
10636
|
},
|
|
11175
10637
|
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
11176
10638
|
var attribute = props.attribute,
|
|
11177
|
-
|
|
11178
|
-
|
|
10639
|
+
value = props.value,
|
|
10640
|
+
filter = props.filter;
|
|
11179
10641
|
var checked = getCurrentRefinement$d(props, searchState, {
|
|
11180
10642
|
ais: props.contextValue,
|
|
11181
10643
|
multiIndexContext: props.indexContextValue
|
|
11182
10644
|
});
|
|
11183
10645
|
var nextSearchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
11184
|
-
|
|
11185
10646
|
if (checked) {
|
|
11186
10647
|
nextSearchParameters = nextSearchParameters.addDisjunctiveFacetRefinement(attribute, value);
|
|
11187
|
-
|
|
11188
10648
|
if (filter) {
|
|
11189
10649
|
nextSearchParameters = filter(nextSearchParameters);
|
|
11190
10650
|
}
|
|
11191
10651
|
}
|
|
11192
|
-
|
|
11193
10652
|
return nextSearchParameters;
|
|
11194
10653
|
},
|
|
11195
10654
|
getMetadata: function getMetadata(props, searchState) {
|
|
@@ -11203,7 +10662,6 @@
|
|
|
11203
10662
|
ais: props.contextValue,
|
|
11204
10663
|
multiIndexContext: props.indexContextValue
|
|
11205
10664
|
});
|
|
11206
|
-
|
|
11207
10665
|
if (checked) {
|
|
11208
10666
|
items.push({
|
|
11209
10667
|
label: props.label,
|
|
@@ -11217,7 +10675,6 @@
|
|
|
11217
10675
|
}
|
|
11218
10676
|
});
|
|
11219
10677
|
}
|
|
11220
|
-
|
|
11221
10678
|
return {
|
|
11222
10679
|
id: id,
|
|
11223
10680
|
index: index,
|
|
@@ -11226,22 +10683,16 @@
|
|
|
11226
10683
|
}
|
|
11227
10684
|
});
|
|
11228
10685
|
|
|
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
10686
|
function inferPayload(_ref) {
|
|
11234
10687
|
var method = _ref.method,
|
|
11235
|
-
|
|
11236
|
-
|
|
10688
|
+
results = _ref.results,
|
|
10689
|
+
currentHit = _ref.currentHit;
|
|
11237
10690
|
var index = results.index;
|
|
11238
10691
|
var queryID = currentHit.__queryID;
|
|
11239
10692
|
var objectIDs = [currentHit.objectID];
|
|
11240
|
-
|
|
11241
10693
|
if (!queryID) {
|
|
11242
10694
|
throw new Error("Could not infer `queryID`. Ensure `clickAnalytics: true` was added with the Configure widget.\nSee: https://alg.li/VpPpLt");
|
|
11243
10695
|
}
|
|
11244
|
-
|
|
11245
10696
|
switch (method) {
|
|
11246
10697
|
case 'clickedObjectIDsAfterSearch':
|
|
11247
10698
|
{
|
|
@@ -11253,34 +10704,29 @@
|
|
|
11253
10704
|
positions: positions
|
|
11254
10705
|
};
|
|
11255
10706
|
}
|
|
11256
|
-
|
|
11257
10707
|
case 'convertedObjectIDsAfterSearch':
|
|
11258
10708
|
return {
|
|
11259
10709
|
index: index,
|
|
11260
10710
|
queryID: queryID,
|
|
11261
10711
|
objectIDs: objectIDs
|
|
11262
10712
|
};
|
|
11263
|
-
|
|
11264
10713
|
default:
|
|
11265
10714
|
throw new Error("Unsupported method \"".concat(method, "\" passed to the insights function. The supported methods are: \"clickedObjectIDsAfterSearch\", \"convertedObjectIDsAfterSearch\"."));
|
|
11266
10715
|
}
|
|
11267
10716
|
}
|
|
11268
|
-
|
|
11269
10717
|
var wrapInsightsClient = function wrapInsightsClient(aa, results, currentHit) {
|
|
11270
10718
|
return function (method, payload) {
|
|
11271
10719
|
if (typeof aa !== 'function') {
|
|
11272
10720
|
throw new TypeError("Expected insightsClient to be a Function");
|
|
11273
10721
|
}
|
|
11274
|
-
|
|
11275
10722
|
var inferredPayload = inferPayload({
|
|
11276
10723
|
method: method,
|
|
11277
10724
|
results: results,
|
|
11278
10725
|
currentHit: currentHit
|
|
11279
10726
|
});
|
|
11280
|
-
aa(method,
|
|
10727
|
+
aa(method, _objectSpread2(_objectSpread2({}, inferredPayload), payload));
|
|
11281
10728
|
};
|
|
11282
10729
|
};
|
|
11283
|
-
|
|
11284
10730
|
var connectHitInsights = (function (insightsClient) {
|
|
11285
10731
|
return createConnectorWithContext({
|
|
11286
10732
|
displayName: 'AlgoliaInsights',
|
|
@@ -11298,65 +10744,50 @@
|
|
|
11298
10744
|
});
|
|
11299
10745
|
});
|
|
11300
10746
|
|
|
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
10747
|
function getId$g() {
|
|
11306
10748
|
return 'query';
|
|
11307
10749
|
}
|
|
11308
|
-
|
|
11309
10750
|
function getAdditionalId() {
|
|
11310
10751
|
return 'additionalVoiceParameters';
|
|
11311
10752
|
}
|
|
11312
|
-
|
|
11313
10753
|
function getCurrentRefinementQuery(props, searchState, context) {
|
|
11314
10754
|
var id = getId$g();
|
|
11315
10755
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
11316
|
-
|
|
11317
10756
|
if (currentRefinement) {
|
|
11318
10757
|
return currentRefinement;
|
|
11319
10758
|
}
|
|
11320
|
-
|
|
11321
10759
|
return '';
|
|
11322
10760
|
}
|
|
11323
|
-
|
|
11324
10761
|
function getCurrentRefinementAdditional(props, searchState, context) {
|
|
11325
10762
|
var id = getAdditionalId();
|
|
11326
10763
|
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
11327
|
-
|
|
11328
10764
|
if (currentRefinement) {
|
|
11329
10765
|
return currentRefinement;
|
|
11330
10766
|
}
|
|
11331
|
-
|
|
11332
10767
|
return {};
|
|
11333
10768
|
}
|
|
11334
|
-
|
|
11335
10769
|
function _refine$b(props, searchState, nextRefinement, context) {
|
|
11336
10770
|
var _nextValue;
|
|
11337
|
-
|
|
11338
10771
|
var id = getId$g();
|
|
11339
10772
|
var voiceParams = getAdditionalId();
|
|
11340
10773
|
var queryLanguages = props.language ? {
|
|
11341
10774
|
queryLanguages: [props.language.split('-')[0]]
|
|
11342
10775
|
} : {};
|
|
11343
|
-
var additionalQueryParameters = typeof props.additionalQueryParameters === 'function' ?
|
|
10776
|
+
var additionalQueryParameters = typeof props.additionalQueryParameters === 'function' ? _objectSpread2({
|
|
11344
10777
|
ignorePlurals: true,
|
|
11345
10778
|
removeStopWords: true,
|
|
11346
10779
|
optionalWords: nextRefinement
|
|
11347
10780
|
}, props.additionalQueryParameters({
|
|
11348
10781
|
query: nextRefinement
|
|
11349
10782
|
})) : {};
|
|
11350
|
-
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams,
|
|
10783
|
+
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams, _objectSpread2(_objectSpread2({}, queryLanguages), additionalQueryParameters)), _nextValue);
|
|
11351
10784
|
var resetPage = true;
|
|
11352
10785
|
return refineValue(searchState, nextValue, context, resetPage);
|
|
11353
10786
|
}
|
|
11354
|
-
|
|
11355
10787
|
function _cleanUp$8(props, searchState, context) {
|
|
11356
10788
|
var interimState = cleanUpValue(searchState, context, getId$g());
|
|
11357
10789
|
return cleanUpValue(interimState, context, getAdditionalId());
|
|
11358
10790
|
}
|
|
11359
|
-
|
|
11360
10791
|
var connectVoiceSearch = createConnectorWithContext({
|
|
11361
10792
|
displayName: 'AlgoliaVoiceSearch',
|
|
11362
10793
|
$$type: 'ais.voiceSearch',
|
|
@@ -11423,10 +10854,8 @@
|
|
|
11423
10854
|
|
|
11424
10855
|
// Core
|
|
11425
10856
|
/** @deprecated use DynamicWidgets */
|
|
11426
|
-
|
|
11427
10857
|
var ExperimentalDynamicWidgets = DynamicWidgets$1;
|
|
11428
10858
|
/** @deprecated use connectDynamicWidgets */
|
|
11429
|
-
|
|
11430
10859
|
var EXPERIMENTAL_connectDynamicWidgets = connectDynamicWidgets;
|
|
11431
10860
|
|
|
11432
10861
|
exports.Configure = Configure;
|
|
@@ -11475,5 +10904,5 @@
|
|
|
11475
10904
|
|
|
11476
10905
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11477
10906
|
|
|
11478
|
-
}));
|
|
10907
|
+
})));
|
|
11479
10908
|
//# sourceMappingURL=ReactInstantSearchCore.js.map
|