@algolia/autocomplete-js 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/autocomplete.js +26 -54
- package/dist/esm/components/Highlight.js +4 -6
- package/dist/esm/components/ReverseHighlight.js +4 -6
- package/dist/esm/components/ReverseSnippet.js +4 -6
- package/dist/esm/components/Snippet.js +4 -6
- package/dist/esm/createAutocompleteDom.js +26 -22
- package/dist/esm/createEffectWrapper.js +0 -2
- package/dist/esm/createReactiveWrapper.js +0 -3
- package/dist/esm/elements/Input.js +11 -16
- package/dist/esm/getCreateDomElement.js +3 -13
- package/dist/esm/getDefaultOptions.d.ts +32 -31
- package/dist/esm/getDefaultOptions.js +25 -34
- package/dist/esm/getPanelPlacementStyle.js +5 -10
- package/dist/esm/render.js +30 -28
- package/dist/esm/requesters/createAlgoliaRequester.js +4 -4
- package/dist/esm/requesters/getAlgoliaFacets.js +5 -5
- package/dist/esm/requesters/getAlgoliaResults.js +1 -1
- package/dist/esm/types/AutocompleteApi.d.ts +1 -1
- package/dist/esm/types/AutocompleteDom.d.ts +2 -0
- package/dist/esm/types/index.d.ts +7 -12
- package/dist/esm/types/index.js +2 -12
- package/dist/esm/utils/getHTMLElement.js +0 -1
- package/dist/esm/utils/mergeClassNames.js +0 -2
- package/dist/esm/utils/mergeDeep.js +1 -11
- package/dist/esm/utils/pickBy.js +8 -16
- package/dist/esm/utils/setProperties.js +9 -12
- package/dist/umd/index.development.js +1548 -878
- package/dist/umd/index.development.js.map +1 -1
- package/dist/umd/index.production.js +2 -2
- package/dist/umd/index.production.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/types/AutocompleteClassNames.d.ts +0 -27
- package/dist/esm/types/AutocompleteClassNames.js +0 -1
- package/dist/esm/types/AutocompleteCollection.d.ts +0 -6
- package/dist/esm/types/AutocompleteCollection.js +0 -1
- package/dist/esm/types/AutocompleteComponents.d.ts +0 -23
- package/dist/esm/types/AutocompleteComponents.js +0 -1
- package/dist/esm/types/AutocompleteOptions.d.ts +0 -106
- package/dist/esm/types/AutocompleteOptions.js +0 -1
- package/dist/esm/types/AutocompletePlugin.d.ts +0 -12
- package/dist/esm/types/AutocompletePlugin.js +0 -1
- package/dist/esm/types/AutocompletePropGetters.d.ts +0 -33
- package/dist/esm/types/AutocompletePropGetters.js +0 -1
- package/dist/esm/types/AutocompleteRender.d.ts +0 -15
- package/dist/esm/types/AutocompleteRender.js +0 -1
- package/dist/esm/types/AutocompleteRenderer.d.ts +0 -33
- package/dist/esm/types/AutocompleteRenderer.js +0 -1
- package/dist/esm/types/AutocompleteSource.d.ts +0 -74
- package/dist/esm/types/AutocompleteSource.js +0 -1
- package/dist/esm/types/AutocompleteState.d.ts +0 -10
- package/dist/esm/types/AutocompleteState.js +0 -1
- package/dist/esm/types/AutocompleteTranslations.d.ts +0 -5
- package/dist/esm/types/AutocompleteTranslations.js +0 -1
- package/dist/esm/types/HighlightHitParams.d.ts +0 -18
- package/dist/esm/types/HighlightHitParams.js +0 -1
|
@@ -1,47 +1,69 @@
|
|
|
1
|
-
/*! @algolia/autocomplete-js 1.
|
|
1
|
+
/*! @algolia/autocomplete-js 1.9.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
5
5
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@algolia/autocomplete-js"] = {}));
|
|
6
6
|
})(this, (function (exports) { 'use strict';
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function _iterableToArrayLimit$2(arr, i) {
|
|
9
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
10
|
+
if (null != _i) {
|
|
11
|
+
var _s,
|
|
12
|
+
_e,
|
|
13
|
+
_x,
|
|
14
|
+
_r,
|
|
15
|
+
_arr = [],
|
|
16
|
+
_n = !0,
|
|
17
|
+
_d = !1;
|
|
18
|
+
try {
|
|
19
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
20
|
+
if (Object(_i) !== _i) return;
|
|
21
|
+
_n = !1;
|
|
22
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
_d = !0, _e = err;
|
|
25
|
+
} finally {
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
28
|
+
} finally {
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function ownKeys$i(object, enumerableOnly) {
|
|
9
36
|
var keys = Object.keys(object);
|
|
10
|
-
|
|
11
37
|
if (Object.getOwnPropertySymbols) {
|
|
12
38
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
13
39
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
14
40
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
15
41
|
})), keys.push.apply(keys, symbols);
|
|
16
42
|
}
|
|
17
|
-
|
|
18
43
|
return keys;
|
|
19
44
|
}
|
|
20
|
-
|
|
21
45
|
function _objectSpread2(target) {
|
|
22
46
|
for (var i = 1; i < arguments.length; i++) {
|
|
23
47
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
24
|
-
i % 2 ? ownKeys$
|
|
25
|
-
_defineProperty$
|
|
26
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$
|
|
48
|
+
i % 2 ? ownKeys$i(Object(source), !0).forEach(function (key) {
|
|
49
|
+
_defineProperty$i(target, key, source[key]);
|
|
50
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$i(Object(source)).forEach(function (key) {
|
|
27
51
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
28
52
|
});
|
|
29
53
|
}
|
|
30
|
-
|
|
31
54
|
return target;
|
|
32
55
|
}
|
|
33
|
-
|
|
34
|
-
function _typeof$3(obj) {
|
|
56
|
+
function _typeof$j(obj) {
|
|
35
57
|
"@babel/helpers - typeof";
|
|
36
58
|
|
|
37
|
-
return _typeof$
|
|
59
|
+
return _typeof$j = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
38
60
|
return typeof obj;
|
|
39
61
|
} : function (obj) {
|
|
40
62
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
41
|
-
}, _typeof$
|
|
63
|
+
}, _typeof$j(obj);
|
|
42
64
|
}
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
function _defineProperty$i(obj, key, value) {
|
|
66
|
+
key = _toPropertyKey$i(key);
|
|
45
67
|
if (key in obj) {
|
|
46
68
|
Object.defineProperty(obj, key, {
|
|
47
69
|
value: value,
|
|
@@ -52,53 +74,40 @@
|
|
|
52
74
|
} else {
|
|
53
75
|
obj[key] = value;
|
|
54
76
|
}
|
|
55
|
-
|
|
56
77
|
return obj;
|
|
57
78
|
}
|
|
58
|
-
|
|
59
79
|
function _extends() {
|
|
60
|
-
_extends = Object.assign
|
|
80
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
61
81
|
for (var i = 1; i < arguments.length; i++) {
|
|
62
82
|
var source = arguments[i];
|
|
63
|
-
|
|
64
83
|
for (var key in source) {
|
|
65
84
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
66
85
|
target[key] = source[key];
|
|
67
86
|
}
|
|
68
87
|
}
|
|
69
88
|
}
|
|
70
|
-
|
|
71
89
|
return target;
|
|
72
90
|
};
|
|
73
|
-
|
|
74
91
|
return _extends.apply(this, arguments);
|
|
75
92
|
}
|
|
76
|
-
|
|
77
|
-
function _objectWithoutPropertiesLoose$4(source, excluded) {
|
|
93
|
+
function _objectWithoutPropertiesLoose$5(source, excluded) {
|
|
78
94
|
if (source == null) return {};
|
|
79
95
|
var target = {};
|
|
80
96
|
var sourceKeys = Object.keys(source);
|
|
81
97
|
var key, i;
|
|
82
|
-
|
|
83
98
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
84
99
|
key = sourceKeys[i];
|
|
85
100
|
if (excluded.indexOf(key) >= 0) continue;
|
|
86
101
|
target[key] = source[key];
|
|
87
102
|
}
|
|
88
|
-
|
|
89
103
|
return target;
|
|
90
104
|
}
|
|
91
|
-
|
|
92
|
-
function _objectWithoutProperties$4(source, excluded) {
|
|
105
|
+
function _objectWithoutProperties$5(source, excluded) {
|
|
93
106
|
if (source == null) return {};
|
|
94
|
-
|
|
95
|
-
var target = _objectWithoutPropertiesLoose$4(source, excluded);
|
|
96
|
-
|
|
107
|
+
var target = _objectWithoutPropertiesLoose$5(source, excluded);
|
|
97
108
|
var key, i;
|
|
98
|
-
|
|
99
109
|
if (Object.getOwnPropertySymbols) {
|
|
100
110
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
101
|
-
|
|
102
111
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
103
112
|
key = sourceSymbolKeys[i];
|
|
104
113
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -106,84 +115,56 @@
|
|
|
106
115
|
target[key] = source[key];
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
|
-
|
|
110
118
|
return target;
|
|
111
119
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$6(arr, i) || _nonIterableRest$1();
|
|
120
|
+
function _slicedToArray$2(arr, i) {
|
|
121
|
+
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$9(arr, i) || _nonIterableRest$2();
|
|
115
122
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return _arrayWithoutHoles$5(arr) || _iterableToArray$5(arr) || _unsupportedIterableToArray$6(arr) || _nonIterableSpread$5();
|
|
123
|
+
function _toConsumableArray$7(arr) {
|
|
124
|
+
return _arrayWithoutHoles$7(arr) || _iterableToArray$7(arr) || _unsupportedIterableToArray$9(arr) || _nonIterableSpread$7();
|
|
119
125
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (Array.isArray(arr)) return _arrayLikeToArray$6(arr);
|
|
126
|
+
function _arrayWithoutHoles$7(arr) {
|
|
127
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$9(arr);
|
|
123
128
|
}
|
|
124
|
-
|
|
125
|
-
function _arrayWithHoles$1(arr) {
|
|
129
|
+
function _arrayWithHoles$2(arr) {
|
|
126
130
|
if (Array.isArray(arr)) return arr;
|
|
127
131
|
}
|
|
128
|
-
|
|
129
|
-
function _iterableToArray$5(iter) {
|
|
132
|
+
function _iterableToArray$7(iter) {
|
|
130
133
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
131
134
|
}
|
|
132
|
-
|
|
133
|
-
function _iterableToArrayLimit$1(arr, i) {
|
|
134
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
135
|
-
|
|
136
|
-
if (_i == null) return;
|
|
137
|
-
var _arr = [];
|
|
138
|
-
var _n = true;
|
|
139
|
-
var _d = false;
|
|
140
|
-
|
|
141
|
-
var _s, _e;
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
145
|
-
_arr.push(_s.value);
|
|
146
|
-
|
|
147
|
-
if (i && _arr.length === i) break;
|
|
148
|
-
}
|
|
149
|
-
} catch (err) {
|
|
150
|
-
_d = true;
|
|
151
|
-
_e = err;
|
|
152
|
-
} finally {
|
|
153
|
-
try {
|
|
154
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
155
|
-
} finally {
|
|
156
|
-
if (_d) throw _e;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return _arr;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function _unsupportedIterableToArray$6(o, minLen) {
|
|
135
|
+
function _unsupportedIterableToArray$9(o, minLen) {
|
|
164
136
|
if (!o) return;
|
|
165
|
-
if (typeof o === "string") return _arrayLikeToArray$
|
|
137
|
+
if (typeof o === "string") return _arrayLikeToArray$9(o, minLen);
|
|
166
138
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
167
139
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
168
140
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
169
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$
|
|
141
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$9(o, minLen);
|
|
170
142
|
}
|
|
171
|
-
|
|
172
|
-
function _arrayLikeToArray$6(arr, len) {
|
|
143
|
+
function _arrayLikeToArray$9(arr, len) {
|
|
173
144
|
if (len == null || len > arr.length) len = arr.length;
|
|
174
|
-
|
|
175
145
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
176
|
-
|
|
177
146
|
return arr2;
|
|
178
147
|
}
|
|
179
|
-
|
|
180
|
-
function _nonIterableSpread$5() {
|
|
148
|
+
function _nonIterableSpread$7() {
|
|
181
149
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
182
150
|
}
|
|
183
|
-
|
|
184
|
-
function _nonIterableRest$1() {
|
|
151
|
+
function _nonIterableRest$2() {
|
|
185
152
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
186
153
|
}
|
|
154
|
+
function _toPrimitive$i(input, hint) {
|
|
155
|
+
if (typeof input !== "object" || input === null) return input;
|
|
156
|
+
var prim = input[Symbol.toPrimitive];
|
|
157
|
+
if (prim !== undefined) {
|
|
158
|
+
var res = prim.call(input, hint || "default");
|
|
159
|
+
if (typeof res !== "object") return res;
|
|
160
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
161
|
+
}
|
|
162
|
+
return (hint === "string" ? String : Number)(input);
|
|
163
|
+
}
|
|
164
|
+
function _toPropertyKey$i(arg) {
|
|
165
|
+
var key = _toPrimitive$i(arg, "string");
|
|
166
|
+
return typeof key === "symbol" ? key : String(key);
|
|
167
|
+
}
|
|
187
168
|
|
|
188
169
|
function createRef(initialValue) {
|
|
189
170
|
return {
|
|
@@ -197,190 +178,863 @@
|
|
|
197
178
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
198
179
|
args[_key] = arguments[_key];
|
|
199
180
|
}
|
|
200
|
-
|
|
201
181
|
if (timerId) {
|
|
202
182
|
clearTimeout(timerId);
|
|
203
183
|
}
|
|
204
|
-
|
|
205
184
|
timerId = setTimeout(function () {
|
|
206
185
|
return fn.apply(void 0, args);
|
|
207
186
|
}, time);
|
|
208
187
|
};
|
|
209
188
|
}
|
|
210
189
|
|
|
211
|
-
function _slicedToArray(arr, i) {
|
|
212
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$
|
|
190
|
+
function _slicedToArray$1(arr, i) {
|
|
191
|
+
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$8(arr, i) || _nonIterableRest$1();
|
|
213
192
|
}
|
|
214
|
-
|
|
215
|
-
function _nonIterableRest() {
|
|
193
|
+
function _nonIterableRest$1() {
|
|
216
194
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
217
195
|
}
|
|
218
|
-
|
|
219
|
-
function _unsupportedIterableToArray$5(o, minLen) {
|
|
196
|
+
function _unsupportedIterableToArray$8(o, minLen) {
|
|
220
197
|
if (!o) return;
|
|
221
|
-
if (typeof o === "string") return _arrayLikeToArray$
|
|
198
|
+
if (typeof o === "string") return _arrayLikeToArray$8(o, minLen);
|
|
222
199
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
223
200
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
224
201
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
225
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$
|
|
202
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$8(o, minLen);
|
|
226
203
|
}
|
|
227
|
-
|
|
228
|
-
function _arrayLikeToArray$5(arr, len) {
|
|
204
|
+
function _arrayLikeToArray$8(arr, len) {
|
|
229
205
|
if (len == null || len > arr.length) len = arr.length;
|
|
230
|
-
|
|
231
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
232
|
-
arr2[i] = arr[i];
|
|
233
|
-
}
|
|
234
|
-
|
|
206
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
235
207
|
return arr2;
|
|
236
208
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
try {
|
|
249
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
250
|
-
_arr.push(_s.value);
|
|
251
|
-
|
|
252
|
-
if (i && _arr.length === i) break;
|
|
253
|
-
}
|
|
254
|
-
} catch (err) {
|
|
255
|
-
_d = true;
|
|
256
|
-
_e = err;
|
|
257
|
-
} finally {
|
|
209
|
+
function _iterableToArrayLimit$1(arr, i) {
|
|
210
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
211
|
+
if (null != _i) {
|
|
212
|
+
var _s,
|
|
213
|
+
_e,
|
|
214
|
+
_x,
|
|
215
|
+
_r,
|
|
216
|
+
_arr = [],
|
|
217
|
+
_n = !0,
|
|
218
|
+
_d = !1;
|
|
258
219
|
try {
|
|
259
|
-
if (
|
|
220
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
221
|
+
if (Object(_i) !== _i) return;
|
|
222
|
+
_n = !1;
|
|
223
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
_d = !0, _e = err;
|
|
260
226
|
} finally {
|
|
261
|
-
|
|
227
|
+
try {
|
|
228
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
229
|
+
} finally {
|
|
230
|
+
if (_d) throw _e;
|
|
231
|
+
}
|
|
262
232
|
}
|
|
233
|
+
return _arr;
|
|
263
234
|
}
|
|
264
|
-
|
|
265
|
-
return _arr;
|
|
266
235
|
}
|
|
267
|
-
|
|
268
|
-
function _arrayWithHoles(arr) {
|
|
236
|
+
function _arrayWithHoles$1(arr) {
|
|
269
237
|
if (Array.isArray(arr)) return arr;
|
|
270
238
|
}
|
|
271
|
-
|
|
272
|
-
function _typeof$2(obj) {
|
|
239
|
+
function _typeof$i(obj) {
|
|
273
240
|
"@babel/helpers - typeof";
|
|
274
241
|
|
|
275
|
-
return _typeof$
|
|
242
|
+
return _typeof$i = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
276
243
|
return typeof obj;
|
|
277
244
|
} : function (obj) {
|
|
278
245
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
279
|
-
}, _typeof$
|
|
246
|
+
}, _typeof$i(obj);
|
|
280
247
|
}
|
|
281
248
|
/**
|
|
282
249
|
* Decycles objects with circular references.
|
|
283
250
|
* This is used to print cyclic structures in development environment only.
|
|
284
251
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
252
|
function decycle(obj) {
|
|
288
253
|
var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
|
|
289
|
-
|
|
290
|
-
if (!obj || _typeof$2(obj) !== 'object') {
|
|
254
|
+
if (!obj || _typeof$i(obj) !== 'object') {
|
|
291
255
|
return obj;
|
|
292
256
|
}
|
|
293
|
-
|
|
294
257
|
if (seen.has(obj)) {
|
|
295
258
|
return '[Circular]';
|
|
296
259
|
}
|
|
297
|
-
|
|
298
260
|
var newSeen = seen.add(obj);
|
|
299
|
-
|
|
300
261
|
if (Array.isArray(obj)) {
|
|
301
262
|
return obj.map(function (x) {
|
|
302
263
|
return decycle(x, newSeen);
|
|
303
264
|
});
|
|
304
265
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
266
|
+
return Object.fromEntries(Object.entries(obj).map(function (_ref) {
|
|
267
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
268
|
+
key = _ref2[0],
|
|
269
|
+
value = _ref2[1];
|
|
270
|
+
return [key, decycle(value, newSeen)];
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function flatten(values) {
|
|
275
|
+
return values.reduce(function (a, b) {
|
|
276
|
+
return a.concat(b);
|
|
277
|
+
}, []);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
var autocompleteId = 0;
|
|
281
|
+
function generateAutocompleteId() {
|
|
282
|
+
return "autocomplete-".concat(autocompleteId++);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function getAttributeValueByPath(record, path) {
|
|
286
|
+
return path.reduce(function (current, key) {
|
|
287
|
+
return current && current[key];
|
|
288
|
+
}, record);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function getItemsCount(state) {
|
|
292
|
+
if (state.collections.length === 0) {
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
return state.collections.reduce(function (sum, collection) {
|
|
296
|
+
return sum + collection.items.length;
|
|
297
|
+
}, 0);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Throws an error if the condition is not met in development mode.
|
|
302
|
+
* This is used to make development a better experience to provide guidance as
|
|
303
|
+
* to where the error comes from.
|
|
304
|
+
*/
|
|
305
|
+
function invariant(condition, message) {
|
|
306
|
+
if (!condition) {
|
|
307
|
+
throw new Error("[Autocomplete] ".concat(typeof message === 'function' ? message() : message));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function isPrimitive(obj) {
|
|
312
|
+
return obj !== Object(obj);
|
|
313
|
+
}
|
|
314
|
+
function isEqual(first, second) {
|
|
315
|
+
if (first === second) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {
|
|
319
|
+
return first === second;
|
|
320
|
+
}
|
|
321
|
+
if (Object.keys(first).length !== Object.keys(second).length) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {
|
|
325
|
+
var key = _Object$keys[_i];
|
|
326
|
+
if (!(key in second)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (!isEqual(first[key], second[key])) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var noop = function noop() {};
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Safely runs code meant for browser environments only.
|
|
340
|
+
*/
|
|
341
|
+
function safelyRunOnBrowser(callback) {
|
|
342
|
+
if (typeof window !== 'undefined') {
|
|
343
|
+
return callback({
|
|
344
|
+
window: window
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var version = '1.9.0';
|
|
351
|
+
|
|
352
|
+
var userAgents$1 = [{
|
|
353
|
+
segment: 'autocomplete-core',
|
|
354
|
+
version: version
|
|
355
|
+
}];
|
|
356
|
+
|
|
357
|
+
var warnCache = {
|
|
358
|
+
current: {}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Logs a warning if the condition is not met.
|
|
363
|
+
* This is used to log issues in development environment only.
|
|
364
|
+
*/
|
|
365
|
+
function warn(condition, message) {
|
|
366
|
+
if (condition) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
var sanitizedMessage = message.trim();
|
|
370
|
+
var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
|
|
371
|
+
if (!hasAlreadyPrinted) {
|
|
372
|
+
warnCache.current[sanitizedMessage] = true;
|
|
373
|
+
|
|
374
|
+
// eslint-disable-next-line no-console
|
|
375
|
+
console.warn("[Autocomplete] ".concat(sanitizedMessage));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function createClickedEvent(_ref) {
|
|
380
|
+
var item = _ref.item,
|
|
381
|
+
items = _ref.items;
|
|
382
|
+
return {
|
|
383
|
+
index: item.__autocomplete_indexName,
|
|
384
|
+
items: [item],
|
|
385
|
+
positions: [1 + items.findIndex(function (x) {
|
|
386
|
+
return x.objectID === item.objectID;
|
|
387
|
+
})],
|
|
388
|
+
queryID: item.__autocomplete_queryID,
|
|
389
|
+
algoliaSource: ['autocomplete']
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function _slicedToArray(arr, i) {
|
|
394
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest();
|
|
395
|
+
}
|
|
396
|
+
function _nonIterableRest() {
|
|
397
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
398
|
+
}
|
|
399
|
+
function _unsupportedIterableToArray$7(o, minLen) {
|
|
400
|
+
if (!o) return;
|
|
401
|
+
if (typeof o === "string") return _arrayLikeToArray$7(o, minLen);
|
|
402
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
403
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
404
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
405
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen);
|
|
406
|
+
}
|
|
407
|
+
function _arrayLikeToArray$7(arr, len) {
|
|
408
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
409
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
410
|
+
return arr2;
|
|
411
|
+
}
|
|
412
|
+
function _iterableToArrayLimit(arr, i) {
|
|
413
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
414
|
+
if (null != _i) {
|
|
415
|
+
var _s,
|
|
416
|
+
_e,
|
|
417
|
+
_x,
|
|
418
|
+
_r,
|
|
419
|
+
_arr = [],
|
|
420
|
+
_n = !0,
|
|
421
|
+
_d = !1;
|
|
422
|
+
try {
|
|
423
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
424
|
+
if (Object(_i) !== _i) return;
|
|
425
|
+
_n = !1;
|
|
426
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
427
|
+
} catch (err) {
|
|
428
|
+
_d = !0, _e = err;
|
|
429
|
+
} finally {
|
|
430
|
+
try {
|
|
431
|
+
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
|
|
432
|
+
} finally {
|
|
433
|
+
if (_d) throw _e;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return _arr;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function _arrayWithHoles(arr) {
|
|
440
|
+
if (Array.isArray(arr)) return arr;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Determines if a given insights `client` supports the optional call to `init`
|
|
444
|
+
* and the ability to set credentials via extra parameters when sending events.
|
|
445
|
+
*/
|
|
446
|
+
function isModernInsightsClient(client) {
|
|
447
|
+
var _split$map = (client.version || '').split('.').map(Number),
|
|
448
|
+
_split$map2 = _slicedToArray(_split$map, 2),
|
|
449
|
+
major = _split$map2[0],
|
|
450
|
+
minor = _split$map2[1];
|
|
451
|
+
|
|
452
|
+
/* eslint-disable @typescript-eslint/camelcase */
|
|
453
|
+
var v3 = major >= 3;
|
|
454
|
+
var v2_4 = major === 2 && minor >= 4;
|
|
455
|
+
var v1_10 = major === 1 && minor >= 10;
|
|
456
|
+
return v3 || v2_4 || v1_10;
|
|
457
|
+
/* eslint-enable @typescript-eslint/camelcase */
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
var _excluded$8 = ["items"],
|
|
461
|
+
_excluded2$1 = ["items"];
|
|
462
|
+
function _typeof$h(obj) {
|
|
463
|
+
"@babel/helpers - typeof";
|
|
464
|
+
|
|
465
|
+
return _typeof$h = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
466
|
+
return typeof obj;
|
|
467
|
+
} : function (obj) {
|
|
468
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
469
|
+
}, _typeof$h(obj);
|
|
470
|
+
}
|
|
471
|
+
function _toConsumableArray$6(arr) {
|
|
472
|
+
return _arrayWithoutHoles$6(arr) || _iterableToArray$6(arr) || _unsupportedIterableToArray$6(arr) || _nonIterableSpread$6();
|
|
473
|
+
}
|
|
474
|
+
function _nonIterableSpread$6() {
|
|
475
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
476
|
+
}
|
|
477
|
+
function _unsupportedIterableToArray$6(o, minLen) {
|
|
478
|
+
if (!o) return;
|
|
479
|
+
if (typeof o === "string") return _arrayLikeToArray$6(o, minLen);
|
|
480
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
481
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
482
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
483
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen);
|
|
484
|
+
}
|
|
485
|
+
function _iterableToArray$6(iter) {
|
|
486
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
487
|
+
}
|
|
488
|
+
function _arrayWithoutHoles$6(arr) {
|
|
489
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$6(arr);
|
|
490
|
+
}
|
|
491
|
+
function _arrayLikeToArray$6(arr, len) {
|
|
492
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
493
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
494
|
+
return arr2;
|
|
495
|
+
}
|
|
496
|
+
function _objectWithoutProperties$4(source, excluded) {
|
|
497
|
+
if (source == null) return {};
|
|
498
|
+
var target = _objectWithoutPropertiesLoose$4(source, excluded);
|
|
499
|
+
var key, i;
|
|
500
|
+
if (Object.getOwnPropertySymbols) {
|
|
501
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
502
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
503
|
+
key = sourceSymbolKeys[i];
|
|
504
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
505
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
506
|
+
target[key] = source[key];
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return target;
|
|
510
|
+
}
|
|
511
|
+
function _objectWithoutPropertiesLoose$4(source, excluded) {
|
|
512
|
+
if (source == null) return {};
|
|
513
|
+
var target = {};
|
|
514
|
+
var sourceKeys = Object.keys(source);
|
|
515
|
+
var key, i;
|
|
516
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
517
|
+
key = sourceKeys[i];
|
|
518
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
519
|
+
target[key] = source[key];
|
|
520
|
+
}
|
|
521
|
+
return target;
|
|
522
|
+
}
|
|
523
|
+
function ownKeys$h(object, enumerableOnly) {
|
|
524
|
+
var keys = Object.keys(object);
|
|
525
|
+
if (Object.getOwnPropertySymbols) {
|
|
526
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
527
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
528
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
529
|
+
})), keys.push.apply(keys, symbols);
|
|
530
|
+
}
|
|
531
|
+
return keys;
|
|
532
|
+
}
|
|
533
|
+
function _objectSpread$h(target) {
|
|
534
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
535
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
536
|
+
i % 2 ? ownKeys$h(Object(source), !0).forEach(function (key) {
|
|
537
|
+
_defineProperty$h(target, key, source[key]);
|
|
538
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$h(Object(source)).forEach(function (key) {
|
|
539
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
return target;
|
|
543
|
+
}
|
|
544
|
+
function _defineProperty$h(obj, key, value) {
|
|
545
|
+
key = _toPropertyKey$h(key);
|
|
546
|
+
if (key in obj) {
|
|
547
|
+
Object.defineProperty(obj, key, {
|
|
548
|
+
value: value,
|
|
549
|
+
enumerable: true,
|
|
550
|
+
configurable: true,
|
|
551
|
+
writable: true
|
|
552
|
+
});
|
|
553
|
+
} else {
|
|
554
|
+
obj[key] = value;
|
|
555
|
+
}
|
|
556
|
+
return obj;
|
|
557
|
+
}
|
|
558
|
+
function _toPropertyKey$h(arg) {
|
|
559
|
+
var key = _toPrimitive$h(arg, "string");
|
|
560
|
+
return _typeof$h(key) === "symbol" ? key : String(key);
|
|
561
|
+
}
|
|
562
|
+
function _toPrimitive$h(input, hint) {
|
|
563
|
+
if (_typeof$h(input) !== "object" || input === null) return input;
|
|
564
|
+
var prim = input[Symbol.toPrimitive];
|
|
565
|
+
if (prim !== undefined) {
|
|
566
|
+
var res = prim.call(input, hint || "default");
|
|
567
|
+
if (_typeof$h(res) !== "object") return res;
|
|
568
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
569
|
+
}
|
|
570
|
+
return (hint === "string" ? String : Number)(input);
|
|
571
|
+
}
|
|
572
|
+
function chunk(item) {
|
|
573
|
+
var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
574
|
+
var chunks = [];
|
|
575
|
+
for (var i = 0; i < item.objectIDs.length; i += chunkSize) {
|
|
576
|
+
chunks.push(_objectSpread$h(_objectSpread$h({}, item), {}, {
|
|
577
|
+
objectIDs: item.objectIDs.slice(i, i + chunkSize)
|
|
578
|
+
}));
|
|
579
|
+
}
|
|
580
|
+
return chunks;
|
|
581
|
+
}
|
|
582
|
+
function mapToInsightsParamsApi(params) {
|
|
583
|
+
return params.map(function (_ref) {
|
|
584
|
+
var items = _ref.items,
|
|
585
|
+
param = _objectWithoutProperties$4(_ref, _excluded$8);
|
|
586
|
+
return _objectSpread$h(_objectSpread$h({}, param), {}, {
|
|
587
|
+
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref2) {
|
|
588
|
+
var objectID = _ref2.objectID;
|
|
589
|
+
return objectID;
|
|
590
|
+
})) || param.objectIDs
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
function createSearchInsightsApi(searchInsights) {
|
|
595
|
+
var canSendHeaders = isModernInsightsClient(searchInsights);
|
|
596
|
+
function sendToInsights(method, payloads, items) {
|
|
597
|
+
if (canSendHeaders && typeof items !== 'undefined') {
|
|
598
|
+
var _items$0$__autocomple = items[0].__autocomplete_algoliaCredentials,
|
|
599
|
+
appId = _items$0$__autocomple.appId,
|
|
600
|
+
apiKey = _items$0$__autocomple.apiKey;
|
|
601
|
+
var headers = {
|
|
602
|
+
'X-Algolia-Application-Id': appId,
|
|
603
|
+
'X-Algolia-API-Key': apiKey
|
|
604
|
+
};
|
|
605
|
+
searchInsights.apply(void 0, [method].concat(_toConsumableArray$6(payloads), [{
|
|
606
|
+
headers: headers
|
|
607
|
+
}]));
|
|
608
|
+
} else {
|
|
609
|
+
searchInsights.apply(void 0, [method].concat(_toConsumableArray$6(payloads)));
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return {
|
|
613
|
+
/**
|
|
614
|
+
* Initializes Insights with Algolia credentials.
|
|
615
|
+
*/
|
|
616
|
+
init: function init(appId, apiKey) {
|
|
617
|
+
searchInsights('init', {
|
|
618
|
+
appId: appId,
|
|
619
|
+
apiKey: apiKey
|
|
620
|
+
});
|
|
621
|
+
},
|
|
622
|
+
/**
|
|
623
|
+
* Sets the user token to attach to events.
|
|
624
|
+
*/
|
|
625
|
+
setUserToken: function setUserToken(userToken) {
|
|
626
|
+
searchInsights('setUserToken', userToken);
|
|
627
|
+
},
|
|
628
|
+
/**
|
|
629
|
+
* Sends click events to capture a query and its clicked items and positions.
|
|
630
|
+
*
|
|
631
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids-after-search/
|
|
632
|
+
*/
|
|
633
|
+
clickedObjectIDsAfterSearch: function clickedObjectIDsAfterSearch() {
|
|
634
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
635
|
+
params[_key] = arguments[_key];
|
|
636
|
+
}
|
|
637
|
+
if (params.length > 0) {
|
|
638
|
+
sendToInsights('clickedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items);
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
/**
|
|
642
|
+
* Sends click events to capture clicked items.
|
|
643
|
+
*
|
|
644
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids/
|
|
645
|
+
*/
|
|
646
|
+
clickedObjectIDs: function clickedObjectIDs() {
|
|
647
|
+
for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
648
|
+
params[_key2] = arguments[_key2];
|
|
649
|
+
}
|
|
650
|
+
if (params.length > 0) {
|
|
651
|
+
sendToInsights('clickedObjectIDs', mapToInsightsParamsApi(params), params[0].items);
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
/**
|
|
655
|
+
* Sends click events to capture the filters a user clicks on.
|
|
656
|
+
*
|
|
657
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/clicked-filters/
|
|
658
|
+
*/
|
|
659
|
+
clickedFilters: function clickedFilters() {
|
|
660
|
+
for (var _len3 = arguments.length, params = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
661
|
+
params[_key3] = arguments[_key3];
|
|
662
|
+
}
|
|
663
|
+
if (params.length > 0) {
|
|
664
|
+
searchInsights.apply(void 0, ['clickedFilters'].concat(params));
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
/**
|
|
668
|
+
* Sends conversion events to capture a query and its clicked items.
|
|
669
|
+
*
|
|
670
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids-after-search/
|
|
671
|
+
*/
|
|
672
|
+
convertedObjectIDsAfterSearch: function convertedObjectIDsAfterSearch() {
|
|
673
|
+
for (var _len4 = arguments.length, params = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
674
|
+
params[_key4] = arguments[_key4];
|
|
675
|
+
}
|
|
676
|
+
if (params.length > 0) {
|
|
677
|
+
sendToInsights('convertedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items);
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
/**
|
|
681
|
+
* Sends conversion events to capture clicked items.
|
|
682
|
+
*
|
|
683
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids/
|
|
684
|
+
*/
|
|
685
|
+
convertedObjectIDs: function convertedObjectIDs() {
|
|
686
|
+
for (var _len5 = arguments.length, params = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
687
|
+
params[_key5] = arguments[_key5];
|
|
688
|
+
}
|
|
689
|
+
if (params.length > 0) {
|
|
690
|
+
sendToInsights('convertedObjectIDs', mapToInsightsParamsApi(params), params[0].items);
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
/**
|
|
694
|
+
* Sends conversion events to capture the filters a user uses when converting.
|
|
695
|
+
*
|
|
696
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/converted-filters/
|
|
697
|
+
*/
|
|
698
|
+
convertedFilters: function convertedFilters() {
|
|
699
|
+
for (var _len6 = arguments.length, params = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
700
|
+
params[_key6] = arguments[_key6];
|
|
701
|
+
}
|
|
702
|
+
if (params.length > 0) {
|
|
703
|
+
searchInsights.apply(void 0, ['convertedFilters'].concat(params));
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
/**
|
|
707
|
+
* Sends view events to capture clicked items.
|
|
708
|
+
*
|
|
709
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/viewed-object-ids/
|
|
710
|
+
*/
|
|
711
|
+
viewedObjectIDs: function viewedObjectIDs() {
|
|
712
|
+
for (var _len7 = arguments.length, params = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
713
|
+
params[_key7] = arguments[_key7];
|
|
714
|
+
}
|
|
715
|
+
if (params.length > 0) {
|
|
716
|
+
params.reduce(function (acc, _ref3) {
|
|
717
|
+
var items = _ref3.items,
|
|
718
|
+
param = _objectWithoutProperties$4(_ref3, _excluded2$1);
|
|
719
|
+
return [].concat(_toConsumableArray$6(acc), _toConsumableArray$6(chunk(_objectSpread$h(_objectSpread$h({}, param), {}, {
|
|
720
|
+
objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref4) {
|
|
721
|
+
var objectID = _ref4.objectID;
|
|
722
|
+
return objectID;
|
|
723
|
+
})) || param.objectIDs
|
|
724
|
+
})).map(function (payload) {
|
|
725
|
+
return {
|
|
726
|
+
items: items,
|
|
727
|
+
payload: payload
|
|
728
|
+
};
|
|
729
|
+
})));
|
|
730
|
+
}, []).forEach(function (_ref5) {
|
|
731
|
+
var items = _ref5.items,
|
|
732
|
+
payload = _ref5.payload;
|
|
733
|
+
return sendToInsights('viewedObjectIDs', [payload], items);
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
/**
|
|
738
|
+
* Sends view events to capture the filters a user uses when viewing.
|
|
739
|
+
*
|
|
740
|
+
* @link https://www.algolia.com/doc/api-reference/api-methods/viewed-filters/
|
|
741
|
+
*/
|
|
742
|
+
viewedFilters: function viewedFilters() {
|
|
743
|
+
for (var _len8 = arguments.length, params = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
744
|
+
params[_key8] = arguments[_key8];
|
|
745
|
+
}
|
|
746
|
+
if (params.length > 0) {
|
|
747
|
+
searchInsights.apply(void 0, ['viewedFilters'].concat(params));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function createViewedEvents(_ref) {
|
|
754
|
+
var items = _ref.items;
|
|
755
|
+
var itemsByIndexName = items.reduce(function (acc, current) {
|
|
756
|
+
var _acc$current$__autoco;
|
|
757
|
+
acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current);
|
|
758
|
+
return acc;
|
|
759
|
+
}, {});
|
|
760
|
+
return Object.keys(itemsByIndexName).map(function (indexName) {
|
|
761
|
+
var items = itemsByIndexName[indexName];
|
|
762
|
+
return {
|
|
763
|
+
index: indexName,
|
|
764
|
+
items: items,
|
|
765
|
+
algoliaSource: ['autocomplete']
|
|
766
|
+
};
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function isAlgoliaInsightsHit(hit) {
|
|
771
|
+
return hit.objectID && hit.__autocomplete_indexName && hit.__autocomplete_queryID;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function _typeof$g(obj) {
|
|
775
|
+
"@babel/helpers - typeof";
|
|
776
|
+
|
|
777
|
+
return _typeof$g = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
778
|
+
return typeof obj;
|
|
779
|
+
} : function (obj) {
|
|
780
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
781
|
+
}, _typeof$g(obj);
|
|
782
|
+
}
|
|
783
|
+
function _toConsumableArray$5(arr) {
|
|
784
|
+
return _arrayWithoutHoles$5(arr) || _iterableToArray$5(arr) || _unsupportedIterableToArray$5(arr) || _nonIterableSpread$5();
|
|
785
|
+
}
|
|
786
|
+
function _nonIterableSpread$5() {
|
|
787
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
788
|
+
}
|
|
789
|
+
function _unsupportedIterableToArray$5(o, minLen) {
|
|
790
|
+
if (!o) return;
|
|
791
|
+
if (typeof o === "string") return _arrayLikeToArray$5(o, minLen);
|
|
792
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
793
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
794
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
795
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen);
|
|
796
|
+
}
|
|
797
|
+
function _iterableToArray$5(iter) {
|
|
798
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
799
|
+
}
|
|
800
|
+
function _arrayWithoutHoles$5(arr) {
|
|
801
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$5(arr);
|
|
802
|
+
}
|
|
803
|
+
function _arrayLikeToArray$5(arr, len) {
|
|
804
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
805
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
806
|
+
return arr2;
|
|
807
|
+
}
|
|
808
|
+
function ownKeys$g(object, enumerableOnly) {
|
|
809
|
+
var keys = Object.keys(object);
|
|
810
|
+
if (Object.getOwnPropertySymbols) {
|
|
811
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
812
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
813
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
814
|
+
})), keys.push.apply(keys, symbols);
|
|
815
|
+
}
|
|
816
|
+
return keys;
|
|
817
|
+
}
|
|
818
|
+
function _objectSpread$g(target) {
|
|
819
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
820
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
821
|
+
i % 2 ? ownKeys$g(Object(source), !0).forEach(function (key) {
|
|
822
|
+
_defineProperty$g(target, key, source[key]);
|
|
823
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$g(Object(source)).forEach(function (key) {
|
|
824
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
return target;
|
|
324
828
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
829
|
+
function _defineProperty$g(obj, key, value) {
|
|
830
|
+
key = _toPropertyKey$g(key);
|
|
831
|
+
if (key in obj) {
|
|
832
|
+
Object.defineProperty(obj, key, {
|
|
833
|
+
value: value,
|
|
834
|
+
enumerable: true,
|
|
835
|
+
configurable: true,
|
|
836
|
+
writable: true
|
|
837
|
+
});
|
|
838
|
+
} else {
|
|
839
|
+
obj[key] = value;
|
|
840
|
+
}
|
|
841
|
+
return obj;
|
|
330
842
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
843
|
+
function _toPropertyKey$g(arg) {
|
|
844
|
+
var key = _toPrimitive$g(arg, "string");
|
|
845
|
+
return _typeof$g(key) === "symbol" ? key : String(key);
|
|
846
|
+
}
|
|
847
|
+
function _toPrimitive$g(input, hint) {
|
|
848
|
+
if (_typeof$g(input) !== "object" || input === null) return input;
|
|
849
|
+
var prim = input[Symbol.toPrimitive];
|
|
850
|
+
if (prim !== undefined) {
|
|
851
|
+
var res = prim.call(input, hint || "default");
|
|
852
|
+
if (_typeof$g(res) !== "object") return res;
|
|
853
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
335
854
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
855
|
+
return (hint === "string" ? String : Number)(input);
|
|
856
|
+
}
|
|
857
|
+
var VIEW_EVENT_DELAY = 400;
|
|
858
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.4.0';
|
|
859
|
+
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
860
|
+
var sendViewedObjectIDs = debounce(function (_ref) {
|
|
861
|
+
var onItemsChange = _ref.onItemsChange,
|
|
862
|
+
items = _ref.items,
|
|
863
|
+
insights = _ref.insights,
|
|
864
|
+
state = _ref.state;
|
|
865
|
+
onItemsChange({
|
|
866
|
+
insights: insights,
|
|
867
|
+
insightsEvents: createViewedEvents({
|
|
868
|
+
items: items
|
|
869
|
+
}).map(function (event) {
|
|
870
|
+
return _objectSpread$g({
|
|
871
|
+
eventName: 'Items Viewed'
|
|
872
|
+
}, event);
|
|
873
|
+
}),
|
|
874
|
+
state: state
|
|
875
|
+
});
|
|
876
|
+
}, VIEW_EVENT_DELAY);
|
|
877
|
+
function createAlgoliaInsightsPlugin(options) {
|
|
878
|
+
var _getOptions = getOptions(options),
|
|
879
|
+
providedInsightsClient = _getOptions.insightsClient,
|
|
880
|
+
onItemsChange = _getOptions.onItemsChange,
|
|
881
|
+
onSelectEvent = _getOptions.onSelect,
|
|
882
|
+
onActiveEvent = _getOptions.onActive;
|
|
883
|
+
var insightsClient = providedInsightsClient;
|
|
884
|
+
if (!providedInsightsClient) {
|
|
885
|
+
safelyRunOnBrowser(function (_ref2) {
|
|
886
|
+
var window = _ref2.window;
|
|
887
|
+
var pointer = window.AlgoliaAnalyticsObject || 'aa';
|
|
888
|
+
if (typeof pointer === 'string') {
|
|
889
|
+
insightsClient = window[pointer];
|
|
890
|
+
}
|
|
891
|
+
if (!insightsClient) {
|
|
892
|
+
window.AlgoliaAnalyticsObject = pointer;
|
|
893
|
+
if (!window[pointer]) {
|
|
894
|
+
window[pointer] = function () {
|
|
895
|
+
if (!window[pointer].queue) {
|
|
896
|
+
window[pointer].queue = [];
|
|
897
|
+
}
|
|
898
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
899
|
+
args[_key] = arguments[_key];
|
|
900
|
+
}
|
|
901
|
+
window[pointer].queue.push(args);
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
window[pointer].version = ALGOLIA_INSIGHTS_VERSION;
|
|
905
|
+
insightsClient = window[pointer];
|
|
906
|
+
loadInsights(window);
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
var insights = createSearchInsightsApi(insightsClient);
|
|
911
|
+
var previousItems = createRef([]);
|
|
912
|
+
var debouncedOnStateChange = debounce(function (_ref3) {
|
|
913
|
+
var state = _ref3.state;
|
|
914
|
+
if (!state.isOpen) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
var items = state.collections.reduce(function (acc, current) {
|
|
918
|
+
return [].concat(_toConsumableArray$5(acc), _toConsumableArray$5(current.items));
|
|
919
|
+
}, []).filter(isAlgoliaInsightsHit);
|
|
920
|
+
if (!isEqual(previousItems.current.map(function (x) {
|
|
921
|
+
return x.objectID;
|
|
922
|
+
}), items.map(function (x) {
|
|
923
|
+
return x.objectID;
|
|
924
|
+
}))) {
|
|
925
|
+
previousItems.current = items;
|
|
926
|
+
if (items.length > 0) {
|
|
927
|
+
sendViewedObjectIDs({
|
|
928
|
+
onItemsChange: onItemsChange,
|
|
929
|
+
items: items,
|
|
930
|
+
insights: insights,
|
|
931
|
+
state: state
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
339
935
|
}, 0);
|
|
936
|
+
return {
|
|
937
|
+
name: 'aa.algoliaInsightsPlugin',
|
|
938
|
+
subscribe: function subscribe(_ref4) {
|
|
939
|
+
var setContext = _ref4.setContext,
|
|
940
|
+
onSelect = _ref4.onSelect,
|
|
941
|
+
onActive = _ref4.onActive;
|
|
942
|
+
insightsClient('addAlgoliaAgent', 'insights-plugin');
|
|
943
|
+
setContext({
|
|
944
|
+
algoliaInsightsPlugin: {
|
|
945
|
+
__algoliaSearchParameters: {
|
|
946
|
+
clickAnalytics: true
|
|
947
|
+
},
|
|
948
|
+
insights: insights
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
onSelect(function (_ref5) {
|
|
952
|
+
var item = _ref5.item,
|
|
953
|
+
state = _ref5.state,
|
|
954
|
+
event = _ref5.event;
|
|
955
|
+
if (!isAlgoliaInsightsHit(item)) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
onSelectEvent({
|
|
959
|
+
state: state,
|
|
960
|
+
event: event,
|
|
961
|
+
insights: insights,
|
|
962
|
+
item: item,
|
|
963
|
+
insightsEvents: [_objectSpread$g({
|
|
964
|
+
eventName: 'Item Selected'
|
|
965
|
+
}, createClickedEvent({
|
|
966
|
+
item: item,
|
|
967
|
+
items: previousItems.current
|
|
968
|
+
}))]
|
|
969
|
+
});
|
|
970
|
+
});
|
|
971
|
+
onActive(function (_ref6) {
|
|
972
|
+
var item = _ref6.item,
|
|
973
|
+
state = _ref6.state,
|
|
974
|
+
event = _ref6.event;
|
|
975
|
+
if (!isAlgoliaInsightsHit(item)) {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
onActiveEvent({
|
|
979
|
+
state: state,
|
|
980
|
+
event: event,
|
|
981
|
+
insights: insights,
|
|
982
|
+
item: item,
|
|
983
|
+
insightsEvents: [_objectSpread$g({
|
|
984
|
+
eventName: 'Item Active'
|
|
985
|
+
}, createClickedEvent({
|
|
986
|
+
item: item,
|
|
987
|
+
items: previousItems.current
|
|
988
|
+
}))]
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
onStateChange: function onStateChange(_ref7) {
|
|
993
|
+
var state = _ref7.state;
|
|
994
|
+
debouncedOnStateChange({
|
|
995
|
+
state: state
|
|
996
|
+
});
|
|
997
|
+
},
|
|
998
|
+
__autocomplete_pluginOptions: options
|
|
999
|
+
};
|
|
340
1000
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
1001
|
+
function getOptions(options) {
|
|
1002
|
+
return _objectSpread$g({
|
|
1003
|
+
onItemsChange: function onItemsChange(_ref8) {
|
|
1004
|
+
var insights = _ref8.insights,
|
|
1005
|
+
insightsEvents = _ref8.insightsEvents;
|
|
1006
|
+
insights.viewedObjectIDs.apply(insights, _toConsumableArray$5(insightsEvents.map(function (event) {
|
|
1007
|
+
return _objectSpread$g(_objectSpread$g({}, event), {}, {
|
|
1008
|
+
algoliaSource: [].concat(_toConsumableArray$5(event.algoliaSource || []), ['autocomplete-internal'])
|
|
1009
|
+
});
|
|
1010
|
+
})));
|
|
1011
|
+
},
|
|
1012
|
+
onSelect: function onSelect(_ref9) {
|
|
1013
|
+
var insights = _ref9.insights,
|
|
1014
|
+
insightsEvents = _ref9.insightsEvents;
|
|
1015
|
+
insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray$5(insightsEvents.map(function (event) {
|
|
1016
|
+
return _objectSpread$g(_objectSpread$g({}, event), {}, {
|
|
1017
|
+
algoliaSource: [].concat(_toConsumableArray$5(event.algoliaSource || []), ['autocomplete-internal'])
|
|
1018
|
+
});
|
|
1019
|
+
})));
|
|
1020
|
+
},
|
|
1021
|
+
onActive: noop
|
|
1022
|
+
}, options);
|
|
352
1023
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
* Logs a warning if the condition is not met.
|
|
368
|
-
* This is used to log issues in development environment only.
|
|
369
|
-
*/
|
|
370
|
-
|
|
371
|
-
function warn(condition, message) {
|
|
372
|
-
|
|
373
|
-
if (condition) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
var sanitizedMessage = message.trim();
|
|
378
|
-
var hasAlreadyPrinted = warnCache.current[sanitizedMessage];
|
|
379
|
-
|
|
380
|
-
if (!hasAlreadyPrinted) {
|
|
381
|
-
warnCache.current[sanitizedMessage] = true; // eslint-disable-next-line no-console
|
|
382
|
-
|
|
383
|
-
console.warn("[Autocomplete] ".concat(sanitizedMessage));
|
|
1024
|
+
function loadInsights(environment) {
|
|
1025
|
+
var errorMessage = "[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete";
|
|
1026
|
+
try {
|
|
1027
|
+
var script = environment.document.createElement('script');
|
|
1028
|
+
script.async = true;
|
|
1029
|
+
script.src = ALGOLIA_INSIGHTS_SRC;
|
|
1030
|
+
script.onerror = function () {
|
|
1031
|
+
// eslint-disable-next-line no-console
|
|
1032
|
+
console.error(errorMessage);
|
|
1033
|
+
};
|
|
1034
|
+
document.body.appendChild(script);
|
|
1035
|
+
} catch (cause) {
|
|
1036
|
+
// eslint-disable-next-line no-console
|
|
1037
|
+
console.error(errorMessage);
|
|
384
1038
|
}
|
|
385
1039
|
}
|
|
386
1040
|
|
|
@@ -401,7 +1055,6 @@
|
|
|
401
1055
|
if (onfinally) {
|
|
402
1056
|
state.onCancelList.push(onfinally);
|
|
403
1057
|
}
|
|
404
|
-
|
|
405
1058
|
return createInternalCancelablePromise(promise.finally(createCallback(onfinally && function () {
|
|
406
1059
|
state.onCancelList = [];
|
|
407
1060
|
return onfinally();
|
|
@@ -420,24 +1073,20 @@
|
|
|
420
1073
|
}
|
|
421
1074
|
};
|
|
422
1075
|
}
|
|
423
|
-
|
|
424
1076
|
function cancelable(promise) {
|
|
425
1077
|
return createInternalCancelablePromise(promise, {
|
|
426
1078
|
isCanceled: false,
|
|
427
1079
|
onCancelList: []
|
|
428
1080
|
});
|
|
429
1081
|
}
|
|
430
|
-
|
|
431
1082
|
function createCallback(onResult, state, fallback) {
|
|
432
1083
|
if (!onResult) {
|
|
433
1084
|
return fallback;
|
|
434
1085
|
}
|
|
435
|
-
|
|
436
1086
|
return function callback(arg) {
|
|
437
1087
|
if (state.isCanceled) {
|
|
438
1088
|
return arg;
|
|
439
1089
|
}
|
|
440
|
-
|
|
441
1090
|
return onResult(arg);
|
|
442
1091
|
};
|
|
443
1092
|
}
|
|
@@ -494,7 +1143,6 @@
|
|
|
494
1143
|
if (latestResolvedValue && currentPromiseId < latestResolvedId) {
|
|
495
1144
|
return latestResolvedValue;
|
|
496
1145
|
}
|
|
497
|
-
|
|
498
1146
|
latestResolvedId = currentPromiseId;
|
|
499
1147
|
latestResolvedValue = x;
|
|
500
1148
|
return x;
|
|
@@ -522,33 +1170,26 @@
|
|
|
522
1170
|
if (!itemCount) {
|
|
523
1171
|
return null;
|
|
524
1172
|
}
|
|
525
|
-
|
|
526
1173
|
if (moveAmount < 0 && (baseIndex === null || defaultActiveItemId !== null && baseIndex === 0)) {
|
|
527
1174
|
return itemCount + moveAmount;
|
|
528
1175
|
}
|
|
529
|
-
|
|
530
1176
|
var numericIndex = (baseIndex === null ? -1 : baseIndex) + moveAmount;
|
|
531
|
-
|
|
532
1177
|
if (numericIndex <= -1 || numericIndex >= itemCount) {
|
|
533
1178
|
return defaultActiveItemId === null ? null : 0;
|
|
534
1179
|
}
|
|
535
|
-
|
|
536
1180
|
return numericIndex;
|
|
537
1181
|
}
|
|
538
1182
|
|
|
539
1183
|
function ownKeys$f(object, enumerableOnly) {
|
|
540
1184
|
var keys = Object.keys(object);
|
|
541
|
-
|
|
542
1185
|
if (Object.getOwnPropertySymbols) {
|
|
543
1186
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
544
1187
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
545
1188
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
546
1189
|
})), keys.push.apply(keys, symbols);
|
|
547
1190
|
}
|
|
548
|
-
|
|
549
1191
|
return keys;
|
|
550
1192
|
}
|
|
551
|
-
|
|
552
1193
|
function _objectSpread$f(target) {
|
|
553
1194
|
for (var i = 1; i < arguments.length; i++) {
|
|
554
1195
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -558,11 +1199,10 @@
|
|
|
558
1199
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
559
1200
|
});
|
|
560
1201
|
}
|
|
561
|
-
|
|
562
1202
|
return target;
|
|
563
1203
|
}
|
|
564
|
-
|
|
565
1204
|
function _defineProperty$f(obj, key, value) {
|
|
1205
|
+
key = _toPropertyKey$f(key);
|
|
566
1206
|
if (key in obj) {
|
|
567
1207
|
Object.defineProperty(obj, key, {
|
|
568
1208
|
value: value,
|
|
@@ -573,37 +1213,48 @@
|
|
|
573
1213
|
} else {
|
|
574
1214
|
obj[key] = value;
|
|
575
1215
|
}
|
|
576
|
-
|
|
577
1216
|
return obj;
|
|
578
1217
|
}
|
|
579
|
-
|
|
580
|
-
|
|
1218
|
+
function _toPropertyKey$f(arg) {
|
|
1219
|
+
var key = _toPrimitive$f(arg, "string");
|
|
1220
|
+
return _typeof$f(key) === "symbol" ? key : String(key);
|
|
1221
|
+
}
|
|
1222
|
+
function _toPrimitive$f(input, hint) {
|
|
1223
|
+
if (_typeof$f(input) !== "object" || input === null) return input;
|
|
1224
|
+
var prim = input[Symbol.toPrimitive];
|
|
1225
|
+
if (prim !== undefined) {
|
|
1226
|
+
var res = prim.call(input, hint || "default");
|
|
1227
|
+
if (_typeof$f(res) !== "object") return res;
|
|
1228
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1229
|
+
}
|
|
1230
|
+
return (hint === "string" ? String : Number)(input);
|
|
1231
|
+
}
|
|
1232
|
+
function _typeof$f(obj) {
|
|
581
1233
|
"@babel/helpers - typeof";
|
|
582
1234
|
|
|
583
|
-
return _typeof$
|
|
1235
|
+
return _typeof$f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
584
1236
|
return typeof obj;
|
|
585
1237
|
} : function (obj) {
|
|
586
1238
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
587
|
-
}, _typeof$
|
|
1239
|
+
}, _typeof$f(obj);
|
|
588
1240
|
}
|
|
589
1241
|
function getNormalizedSources(getSources, params) {
|
|
590
1242
|
var seenSourceIds = [];
|
|
591
1243
|
return Promise.resolve(getSources(params)).then(function (sources) {
|
|
592
1244
|
invariant(Array.isArray(sources), function () {
|
|
593
|
-
return "The `getSources` function must return an array of sources but returned type ".concat(JSON.stringify(_typeof$
|
|
1245
|
+
return "The `getSources` function must return an array of sources but returned type ".concat(JSON.stringify(_typeof$f(sources)), ":\n\n").concat(JSON.stringify(decycle(sources), null, 2));
|
|
594
1246
|
});
|
|
595
|
-
return Promise.all(sources
|
|
1247
|
+
return Promise.all(sources
|
|
1248
|
+
// We allow `undefined` and `false` sources to allow users to use
|
|
596
1249
|
// `Boolean(query) && source` (=> `false`).
|
|
597
1250
|
// We need to remove these values at this point.
|
|
598
1251
|
.filter(function (maybeSource) {
|
|
599
1252
|
return Boolean(maybeSource);
|
|
600
1253
|
}).map(function (source) {
|
|
601
1254
|
invariant(typeof source.sourceId === 'string', 'A source must provide a `sourceId` string.');
|
|
602
|
-
|
|
603
1255
|
if (seenSourceIds.includes(source.sourceId)) {
|
|
604
1256
|
throw new Error("[Autocomplete] The `sourceId` ".concat(JSON.stringify(source.sourceId), " is not unique."));
|
|
605
1257
|
}
|
|
606
|
-
|
|
607
1258
|
seenSourceIds.push(source.sourceId);
|
|
608
1259
|
var defaultSource = {
|
|
609
1260
|
getItemInputValue: function getItemInputValue(_ref) {
|
|
@@ -623,9 +1274,7 @@
|
|
|
623
1274
|
Object.keys(defaultSource).forEach(function (key) {
|
|
624
1275
|
defaultSource[key].__default = true;
|
|
625
1276
|
});
|
|
626
|
-
|
|
627
1277
|
var normalizedSource = _objectSpread$f(_objectSpread$f({}, defaultSource), source);
|
|
628
|
-
|
|
629
1278
|
return Promise.resolve(normalizedSource);
|
|
630
1279
|
}));
|
|
631
1280
|
});
|
|
@@ -645,17 +1294,18 @@
|
|
|
645
1294
|
var nextValue = previousValue + collectionsCount;
|
|
646
1295
|
acc.push(nextValue);
|
|
647
1296
|
return acc;
|
|
648
|
-
}, []);
|
|
1297
|
+
}, []);
|
|
649
1298
|
|
|
1299
|
+
// Based on the accumulated counts, we can infer the index of the suggestion.
|
|
650
1300
|
var collectionIndex = accumulatedCollectionsCount.reduce(function (acc, current) {
|
|
651
1301
|
if (current <= state.activeItemId) {
|
|
652
1302
|
return acc + 1;
|
|
653
1303
|
}
|
|
654
|
-
|
|
655
1304
|
return acc;
|
|
656
1305
|
}, 0);
|
|
657
1306
|
return state.collections[collectionIndex];
|
|
658
1307
|
}
|
|
1308
|
+
|
|
659
1309
|
/**
|
|
660
1310
|
* Gets the highlighted index relative to a suggestion object (not the absolute
|
|
661
1311
|
* highlighted index).
|
|
@@ -665,37 +1315,28 @@
|
|
|
665
1315
|
* ↑
|
|
666
1316
|
* (absolute: 3, relative: 1)
|
|
667
1317
|
*/
|
|
668
|
-
|
|
669
|
-
|
|
670
1318
|
function getRelativeActiveItemId(_ref) {
|
|
671
1319
|
var state = _ref.state,
|
|
672
|
-
|
|
1320
|
+
collection = _ref.collection;
|
|
673
1321
|
var isOffsetFound = false;
|
|
674
1322
|
var counter = 0;
|
|
675
1323
|
var previousItemsOffset = 0;
|
|
676
|
-
|
|
677
1324
|
while (isOffsetFound === false) {
|
|
678
1325
|
var currentCollection = state.collections[counter];
|
|
679
|
-
|
|
680
1326
|
if (currentCollection === collection) {
|
|
681
1327
|
isOffsetFound = true;
|
|
682
1328
|
break;
|
|
683
1329
|
}
|
|
684
|
-
|
|
685
1330
|
previousItemsOffset += currentCollection.items.length;
|
|
686
1331
|
counter++;
|
|
687
1332
|
}
|
|
688
|
-
|
|
689
1333
|
return state.activeItemId - previousItemsOffset;
|
|
690
1334
|
}
|
|
691
|
-
|
|
692
1335
|
function getActiveItem(state) {
|
|
693
1336
|
var collection = getCollectionFromActiveItemId(state);
|
|
694
|
-
|
|
695
1337
|
if (!collection) {
|
|
696
1338
|
return null;
|
|
697
1339
|
}
|
|
698
|
-
|
|
699
1340
|
var item = collection.items[getRelativeActiveItemId({
|
|
700
1341
|
state: state,
|
|
701
1342
|
collection: collection
|
|
@@ -726,19 +1367,25 @@
|
|
|
726
1367
|
return Boolean(userAgent && userAgent.match(regex));
|
|
727
1368
|
}
|
|
728
1369
|
|
|
1370
|
+
function _typeof$e(obj) {
|
|
1371
|
+
"@babel/helpers - typeof";
|
|
1372
|
+
|
|
1373
|
+
return _typeof$e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1374
|
+
return typeof obj;
|
|
1375
|
+
} : function (obj) {
|
|
1376
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1377
|
+
}, _typeof$e(obj);
|
|
1378
|
+
}
|
|
729
1379
|
function ownKeys$e(object, enumerableOnly) {
|
|
730
1380
|
var keys = Object.keys(object);
|
|
731
|
-
|
|
732
1381
|
if (Object.getOwnPropertySymbols) {
|
|
733
1382
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
734
1383
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
735
1384
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
736
1385
|
})), keys.push.apply(keys, symbols);
|
|
737
1386
|
}
|
|
738
|
-
|
|
739
1387
|
return keys;
|
|
740
1388
|
}
|
|
741
|
-
|
|
742
1389
|
function _objectSpread$e(target) {
|
|
743
1390
|
for (var i = 1; i < arguments.length; i++) {
|
|
744
1391
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -748,11 +1395,10 @@
|
|
|
748
1395
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
749
1396
|
});
|
|
750
1397
|
}
|
|
751
|
-
|
|
752
1398
|
return target;
|
|
753
1399
|
}
|
|
754
|
-
|
|
755
1400
|
function _defineProperty$e(obj, key, value) {
|
|
1401
|
+
key = _toPropertyKey$e(key);
|
|
756
1402
|
if (key in obj) {
|
|
757
1403
|
Object.defineProperty(obj, key, {
|
|
758
1404
|
value: value,
|
|
@@ -763,14 +1409,25 @@
|
|
|
763
1409
|
} else {
|
|
764
1410
|
obj[key] = value;
|
|
765
1411
|
}
|
|
766
|
-
|
|
767
1412
|
return obj;
|
|
768
1413
|
}
|
|
769
|
-
|
|
1414
|
+
function _toPropertyKey$e(arg) {
|
|
1415
|
+
var key = _toPrimitive$e(arg, "string");
|
|
1416
|
+
return _typeof$e(key) === "symbol" ? key : String(key);
|
|
1417
|
+
}
|
|
1418
|
+
function _toPrimitive$e(input, hint) {
|
|
1419
|
+
if (_typeof$e(input) !== "object" || input === null) return input;
|
|
1420
|
+
var prim = input[Symbol.toPrimitive];
|
|
1421
|
+
if (prim !== undefined) {
|
|
1422
|
+
var res = prim.call(input, hint || "default");
|
|
1423
|
+
if (_typeof$e(res) !== "object") return res;
|
|
1424
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1425
|
+
}
|
|
1426
|
+
return (hint === "string" ? String : Number)(input);
|
|
1427
|
+
}
|
|
770
1428
|
function mapToAlgoliaResponse(rawResults) {
|
|
771
1429
|
var results = rawResults.map(function (result) {
|
|
772
1430
|
var _hits;
|
|
773
|
-
|
|
774
1431
|
return _objectSpread$e(_objectSpread$e({}, result), {}, {
|
|
775
1432
|
hits: (_hits = result.hits) === null || _hits === void 0 ? void 0 : _hits.map(function (hit) {
|
|
776
1433
|
// Bring support for the Insights plugin.
|
|
@@ -788,7 +1445,6 @@
|
|
|
788
1445
|
}).filter(Boolean),
|
|
789
1446
|
facetHits: results.map(function (result) {
|
|
790
1447
|
var _facetHits;
|
|
791
|
-
|
|
792
1448
|
return (_facetHits = result.facetHits) === null || _facetHits === void 0 ? void 0 : _facetHits.map(function (facetHit) {
|
|
793
1449
|
// Bring support for the highlighting components.
|
|
794
1450
|
return {
|
|
@@ -805,19 +1461,25 @@
|
|
|
805
1461
|
};
|
|
806
1462
|
}
|
|
807
1463
|
|
|
1464
|
+
function _typeof$d(obj) {
|
|
1465
|
+
"@babel/helpers - typeof";
|
|
1466
|
+
|
|
1467
|
+
return _typeof$d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1468
|
+
return typeof obj;
|
|
1469
|
+
} : function (obj) {
|
|
1470
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1471
|
+
}, _typeof$d(obj);
|
|
1472
|
+
}
|
|
808
1473
|
function ownKeys$d(object, enumerableOnly) {
|
|
809
1474
|
var keys = Object.keys(object);
|
|
810
|
-
|
|
811
1475
|
if (Object.getOwnPropertySymbols) {
|
|
812
1476
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
813
1477
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
814
1478
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
815
1479
|
})), keys.push.apply(keys, symbols);
|
|
816
1480
|
}
|
|
817
|
-
|
|
818
1481
|
return keys;
|
|
819
1482
|
}
|
|
820
|
-
|
|
821
1483
|
function _objectSpread$d(target) {
|
|
822
1484
|
for (var i = 1; i < arguments.length; i++) {
|
|
823
1485
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -827,11 +1489,10 @@
|
|
|
827
1489
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
828
1490
|
});
|
|
829
1491
|
}
|
|
830
|
-
|
|
831
1492
|
return target;
|
|
832
1493
|
}
|
|
833
|
-
|
|
834
1494
|
function _defineProperty$d(obj, key, value) {
|
|
1495
|
+
key = _toPropertyKey$d(key);
|
|
835
1496
|
if (key in obj) {
|
|
836
1497
|
Object.defineProperty(obj, key, {
|
|
837
1498
|
value: value,
|
|
@@ -842,9 +1503,22 @@
|
|
|
842
1503
|
} else {
|
|
843
1504
|
obj[key] = value;
|
|
844
1505
|
}
|
|
845
|
-
|
|
846
1506
|
return obj;
|
|
847
1507
|
}
|
|
1508
|
+
function _toPropertyKey$d(arg) {
|
|
1509
|
+
var key = _toPrimitive$d(arg, "string");
|
|
1510
|
+
return _typeof$d(key) === "symbol" ? key : String(key);
|
|
1511
|
+
}
|
|
1512
|
+
function _toPrimitive$d(input, hint) {
|
|
1513
|
+
if (_typeof$d(input) !== "object" || input === null) return input;
|
|
1514
|
+
var prim = input[Symbol.toPrimitive];
|
|
1515
|
+
if (prim !== undefined) {
|
|
1516
|
+
var res = prim.call(input, hint || "default");
|
|
1517
|
+
if (_typeof$d(res) !== "object") return res;
|
|
1518
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1519
|
+
}
|
|
1520
|
+
return (hint === "string" ? String : Number)(input);
|
|
1521
|
+
}
|
|
848
1522
|
function createStore(reducer, props, onStoreStateChange) {
|
|
849
1523
|
var state = props.initialState;
|
|
850
1524
|
return {
|
|
@@ -853,7 +1527,6 @@
|
|
|
853
1527
|
},
|
|
854
1528
|
dispatch: function dispatch(action, payload) {
|
|
855
1529
|
var prevState = _objectSpread$d({}, state);
|
|
856
|
-
|
|
857
1530
|
state = reducer(state, {
|
|
858
1531
|
type: action,
|
|
859
1532
|
props: props,
|
|
@@ -868,19 +1541,25 @@
|
|
|
868
1541
|
};
|
|
869
1542
|
}
|
|
870
1543
|
|
|
1544
|
+
function _typeof$c(obj) {
|
|
1545
|
+
"@babel/helpers - typeof";
|
|
1546
|
+
|
|
1547
|
+
return _typeof$c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1548
|
+
return typeof obj;
|
|
1549
|
+
} : function (obj) {
|
|
1550
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1551
|
+
}, _typeof$c(obj);
|
|
1552
|
+
}
|
|
871
1553
|
function ownKeys$c(object, enumerableOnly) {
|
|
872
1554
|
var keys = Object.keys(object);
|
|
873
|
-
|
|
874
1555
|
if (Object.getOwnPropertySymbols) {
|
|
875
1556
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
876
1557
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
877
1558
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
878
1559
|
})), keys.push.apply(keys, symbols);
|
|
879
1560
|
}
|
|
880
|
-
|
|
881
1561
|
return keys;
|
|
882
1562
|
}
|
|
883
|
-
|
|
884
1563
|
function _objectSpread$c(target) {
|
|
885
1564
|
for (var i = 1; i < arguments.length; i++) {
|
|
886
1565
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -890,11 +1569,10 @@
|
|
|
890
1569
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
891
1570
|
});
|
|
892
1571
|
}
|
|
893
|
-
|
|
894
1572
|
return target;
|
|
895
1573
|
}
|
|
896
|
-
|
|
897
1574
|
function _defineProperty$c(obj, key, value) {
|
|
1575
|
+
key = _toPropertyKey$c(key);
|
|
898
1576
|
if (key in obj) {
|
|
899
1577
|
Object.defineProperty(obj, key, {
|
|
900
1578
|
value: value,
|
|
@@ -905,20 +1583,30 @@
|
|
|
905
1583
|
} else {
|
|
906
1584
|
obj[key] = value;
|
|
907
1585
|
}
|
|
908
|
-
|
|
909
1586
|
return obj;
|
|
910
1587
|
}
|
|
1588
|
+
function _toPropertyKey$c(arg) {
|
|
1589
|
+
var key = _toPrimitive$c(arg, "string");
|
|
1590
|
+
return _typeof$c(key) === "symbol" ? key : String(key);
|
|
1591
|
+
}
|
|
1592
|
+
function _toPrimitive$c(input, hint) {
|
|
1593
|
+
if (_typeof$c(input) !== "object" || input === null) return input;
|
|
1594
|
+
var prim = input[Symbol.toPrimitive];
|
|
1595
|
+
if (prim !== undefined) {
|
|
1596
|
+
var res = prim.call(input, hint || "default");
|
|
1597
|
+
if (_typeof$c(res) !== "object") return res;
|
|
1598
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1599
|
+
}
|
|
1600
|
+
return (hint === "string" ? String : Number)(input);
|
|
1601
|
+
}
|
|
911
1602
|
function getAutocompleteSetters(_ref) {
|
|
912
1603
|
var store = _ref.store;
|
|
913
|
-
|
|
914
1604
|
var setActiveItemId = function setActiveItemId(value) {
|
|
915
1605
|
store.dispatch('setActiveItemId', value);
|
|
916
1606
|
};
|
|
917
|
-
|
|
918
1607
|
var setQuery = function setQuery(value) {
|
|
919
1608
|
store.dispatch('setQuery', value);
|
|
920
1609
|
};
|
|
921
|
-
|
|
922
1610
|
var setCollections = function setCollections(rawValue) {
|
|
923
1611
|
var baseItemId = 0;
|
|
924
1612
|
var value = rawValue.map(function (collection) {
|
|
@@ -934,19 +1622,15 @@
|
|
|
934
1622
|
});
|
|
935
1623
|
store.dispatch('setCollections', value);
|
|
936
1624
|
};
|
|
937
|
-
|
|
938
1625
|
var setIsOpen = function setIsOpen(value) {
|
|
939
1626
|
store.dispatch('setIsOpen', value);
|
|
940
1627
|
};
|
|
941
|
-
|
|
942
1628
|
var setStatus = function setStatus(value) {
|
|
943
1629
|
store.dispatch('setStatus', value);
|
|
944
1630
|
};
|
|
945
|
-
|
|
946
1631
|
var setContext = function setContext(value) {
|
|
947
1632
|
store.dispatch('setContext', value);
|
|
948
1633
|
};
|
|
949
|
-
|
|
950
1634
|
return {
|
|
951
1635
|
setActiveItemId: setActiveItemId,
|
|
952
1636
|
setQuery: setQuery,
|
|
@@ -957,14 +1641,21 @@
|
|
|
957
1641
|
};
|
|
958
1642
|
}
|
|
959
1643
|
|
|
1644
|
+
function _typeof$b(obj) {
|
|
1645
|
+
"@babel/helpers - typeof";
|
|
1646
|
+
|
|
1647
|
+
return _typeof$b = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1648
|
+
return typeof obj;
|
|
1649
|
+
} : function (obj) {
|
|
1650
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1651
|
+
}, _typeof$b(obj);
|
|
1652
|
+
}
|
|
960
1653
|
function _toConsumableArray$4(arr) {
|
|
961
1654
|
return _arrayWithoutHoles$4(arr) || _iterableToArray$4(arr) || _unsupportedIterableToArray$4(arr) || _nonIterableSpread$4();
|
|
962
1655
|
}
|
|
963
|
-
|
|
964
1656
|
function _nonIterableSpread$4() {
|
|
965
1657
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
966
1658
|
}
|
|
967
|
-
|
|
968
1659
|
function _unsupportedIterableToArray$4(o, minLen) {
|
|
969
1660
|
if (!o) return;
|
|
970
1661
|
if (typeof o === "string") return _arrayLikeToArray$4(o, minLen);
|
|
@@ -973,38 +1664,27 @@
|
|
|
973
1664
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
974
1665
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen);
|
|
975
1666
|
}
|
|
976
|
-
|
|
977
1667
|
function _iterableToArray$4(iter) {
|
|
978
1668
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
979
1669
|
}
|
|
980
|
-
|
|
981
1670
|
function _arrayWithoutHoles$4(arr) {
|
|
982
1671
|
if (Array.isArray(arr)) return _arrayLikeToArray$4(arr);
|
|
983
1672
|
}
|
|
984
|
-
|
|
985
1673
|
function _arrayLikeToArray$4(arr, len) {
|
|
986
1674
|
if (len == null || len > arr.length) len = arr.length;
|
|
987
|
-
|
|
988
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
989
|
-
arr2[i] = arr[i];
|
|
990
|
-
}
|
|
991
|
-
|
|
1675
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
992
1676
|
return arr2;
|
|
993
1677
|
}
|
|
994
|
-
|
|
995
1678
|
function ownKeys$b(object, enumerableOnly) {
|
|
996
1679
|
var keys = Object.keys(object);
|
|
997
|
-
|
|
998
1680
|
if (Object.getOwnPropertySymbols) {
|
|
999
1681
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1000
1682
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1001
1683
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1002
1684
|
})), keys.push.apply(keys, symbols);
|
|
1003
1685
|
}
|
|
1004
|
-
|
|
1005
1686
|
return keys;
|
|
1006
1687
|
}
|
|
1007
|
-
|
|
1008
1688
|
function _objectSpread$b(target) {
|
|
1009
1689
|
for (var i = 1; i < arguments.length; i++) {
|
|
1010
1690
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1014,11 +1694,10 @@
|
|
|
1014
1694
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1015
1695
|
});
|
|
1016
1696
|
}
|
|
1017
|
-
|
|
1018
1697
|
return target;
|
|
1019
1698
|
}
|
|
1020
|
-
|
|
1021
1699
|
function _defineProperty$b(obj, key, value) {
|
|
1700
|
+
key = _toPropertyKey$b(key);
|
|
1022
1701
|
if (key in obj) {
|
|
1023
1702
|
Object.defineProperty(obj, key, {
|
|
1024
1703
|
value: value,
|
|
@@ -1029,17 +1708,27 @@
|
|
|
1029
1708
|
} else {
|
|
1030
1709
|
obj[key] = value;
|
|
1031
1710
|
}
|
|
1032
|
-
|
|
1033
1711
|
return obj;
|
|
1034
1712
|
}
|
|
1713
|
+
function _toPropertyKey$b(arg) {
|
|
1714
|
+
var key = _toPrimitive$b(arg, "string");
|
|
1715
|
+
return _typeof$b(key) === "symbol" ? key : String(key);
|
|
1716
|
+
}
|
|
1717
|
+
function _toPrimitive$b(input, hint) {
|
|
1718
|
+
if (_typeof$b(input) !== "object" || input === null) return input;
|
|
1719
|
+
var prim = input[Symbol.toPrimitive];
|
|
1720
|
+
if (prim !== undefined) {
|
|
1721
|
+
var res = prim.call(input, hint || "default");
|
|
1722
|
+
if (_typeof$b(res) !== "object") return res;
|
|
1723
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1724
|
+
}
|
|
1725
|
+
return (hint === "string" ? String : Number)(input);
|
|
1726
|
+
}
|
|
1035
1727
|
function getDefaultProps(props, pluginSubscribers) {
|
|
1036
1728
|
var _props$id;
|
|
1037
1729
|
/* eslint-disable no-restricted-globals */
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
1730
|
var environment = typeof window !== 'undefined' ? window : {};
|
|
1041
1731
|
/* eslint-enable no-restricted-globals */
|
|
1042
|
-
|
|
1043
1732
|
var plugins = props.plugins || [];
|
|
1044
1733
|
return _objectSpread$b(_objectSpread$b({
|
|
1045
1734
|
debug: false,
|
|
@@ -1048,6 +1737,7 @@
|
|
|
1048
1737
|
autoFocus: false,
|
|
1049
1738
|
defaultActiveItemId: null,
|
|
1050
1739
|
stallThreshold: 300,
|
|
1740
|
+
insights: false,
|
|
1051
1741
|
environment: environment,
|
|
1052
1742
|
shouldPanelOpen: function shouldPanelOpen(_ref) {
|
|
1053
1743
|
var state = _ref.state;
|
|
@@ -1074,31 +1764,25 @@
|
|
|
1074
1764
|
}, props.initialState),
|
|
1075
1765
|
onStateChange: function onStateChange(params) {
|
|
1076
1766
|
var _props$onStateChange;
|
|
1077
|
-
|
|
1078
1767
|
(_props$onStateChange = props.onStateChange) === null || _props$onStateChange === void 0 ? void 0 : _props$onStateChange.call(props, params);
|
|
1079
1768
|
plugins.forEach(function (x) {
|
|
1080
1769
|
var _x$onStateChange;
|
|
1081
|
-
|
|
1082
1770
|
return (_x$onStateChange = x.onStateChange) === null || _x$onStateChange === void 0 ? void 0 : _x$onStateChange.call(x, params);
|
|
1083
1771
|
});
|
|
1084
1772
|
},
|
|
1085
1773
|
onSubmit: function onSubmit(params) {
|
|
1086
1774
|
var _props$onSubmit;
|
|
1087
|
-
|
|
1088
1775
|
(_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 ? void 0 : _props$onSubmit.call(props, params);
|
|
1089
1776
|
plugins.forEach(function (x) {
|
|
1090
1777
|
var _x$onSubmit;
|
|
1091
|
-
|
|
1092
1778
|
return (_x$onSubmit = x.onSubmit) === null || _x$onSubmit === void 0 ? void 0 : _x$onSubmit.call(x, params);
|
|
1093
1779
|
});
|
|
1094
1780
|
},
|
|
1095
1781
|
onReset: function onReset(params) {
|
|
1096
1782
|
var _props$onReset;
|
|
1097
|
-
|
|
1098
1783
|
(_props$onReset = props.onReset) === null || _props$onReset === void 0 ? void 0 : _props$onReset.call(props, params);
|
|
1099
1784
|
plugins.forEach(function (x) {
|
|
1100
1785
|
var _x$onReset;
|
|
1101
|
-
|
|
1102
1786
|
return (_x$onReset = x.onReset) === null || _x$onReset === void 0 ? void 0 : _x$onReset.call(x, params);
|
|
1103
1787
|
});
|
|
1104
1788
|
},
|
|
@@ -1116,7 +1800,6 @@
|
|
|
1116
1800
|
source.onSelect(params);
|
|
1117
1801
|
pluginSubscribers.forEach(function (x) {
|
|
1118
1802
|
var _x$onSelect;
|
|
1119
|
-
|
|
1120
1803
|
return (_x$onSelect = x.onSelect) === null || _x$onSelect === void 0 ? void 0 : _x$onSelect.call(x, params);
|
|
1121
1804
|
});
|
|
1122
1805
|
},
|
|
@@ -1124,7 +1807,6 @@
|
|
|
1124
1807
|
source.onActive(params);
|
|
1125
1808
|
pluginSubscribers.forEach(function (x) {
|
|
1126
1809
|
var _x$onActive;
|
|
1127
|
-
|
|
1128
1810
|
return (_x$onActive = x.onActive) === null || _x$onActive === void 0 ? void 0 : _x$onActive.call(x, params);
|
|
1129
1811
|
});
|
|
1130
1812
|
},
|
|
@@ -1132,7 +1814,6 @@
|
|
|
1132
1814
|
source.onResolve(params);
|
|
1133
1815
|
pluginSubscribers.forEach(function (x) {
|
|
1134
1816
|
var _x$onResolve;
|
|
1135
|
-
|
|
1136
1817
|
return (_x$onResolve = x.onResolve) === null || _x$onResolve === void 0 ? void 0 : _x$onResolve.call(x, params);
|
|
1137
1818
|
});
|
|
1138
1819
|
}
|
|
@@ -1158,19 +1839,25 @@
|
|
|
1158
1839
|
});
|
|
1159
1840
|
}
|
|
1160
1841
|
|
|
1842
|
+
function _typeof$a(obj) {
|
|
1843
|
+
"@babel/helpers - typeof";
|
|
1844
|
+
|
|
1845
|
+
return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1846
|
+
return typeof obj;
|
|
1847
|
+
} : function (obj) {
|
|
1848
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1849
|
+
}, _typeof$a(obj);
|
|
1850
|
+
}
|
|
1161
1851
|
function ownKeys$a(object, enumerableOnly) {
|
|
1162
1852
|
var keys = Object.keys(object);
|
|
1163
|
-
|
|
1164
1853
|
if (Object.getOwnPropertySymbols) {
|
|
1165
1854
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1166
1855
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1167
1856
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1168
1857
|
})), keys.push.apply(keys, symbols);
|
|
1169
1858
|
}
|
|
1170
|
-
|
|
1171
1859
|
return keys;
|
|
1172
1860
|
}
|
|
1173
|
-
|
|
1174
1861
|
function _objectSpread$a(target) {
|
|
1175
1862
|
for (var i = 1; i < arguments.length; i++) {
|
|
1176
1863
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1180,11 +1867,10 @@
|
|
|
1180
1867
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1181
1868
|
});
|
|
1182
1869
|
}
|
|
1183
|
-
|
|
1184
1870
|
return target;
|
|
1185
1871
|
}
|
|
1186
|
-
|
|
1187
1872
|
function _defineProperty$a(obj, key, value) {
|
|
1873
|
+
key = _toPropertyKey$a(key);
|
|
1188
1874
|
if (key in obj) {
|
|
1189
1875
|
Object.defineProperty(obj, key, {
|
|
1190
1876
|
value: value,
|
|
@@ -1195,15 +1881,28 @@
|
|
|
1195
1881
|
} else {
|
|
1196
1882
|
obj[key] = value;
|
|
1197
1883
|
}
|
|
1198
|
-
|
|
1199
1884
|
return obj;
|
|
1200
1885
|
}
|
|
1886
|
+
function _toPropertyKey$a(arg) {
|
|
1887
|
+
var key = _toPrimitive$a(arg, "string");
|
|
1888
|
+
return _typeof$a(key) === "symbol" ? key : String(key);
|
|
1889
|
+
}
|
|
1890
|
+
function _toPrimitive$a(input, hint) {
|
|
1891
|
+
if (_typeof$a(input) !== "object" || input === null) return input;
|
|
1892
|
+
var prim = input[Symbol.toPrimitive];
|
|
1893
|
+
if (prim !== undefined) {
|
|
1894
|
+
var res = prim.call(input, hint || "default");
|
|
1895
|
+
if (_typeof$a(res) !== "object") return res;
|
|
1896
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1897
|
+
}
|
|
1898
|
+
return (hint === "string" ? String : Number)(input);
|
|
1899
|
+
}
|
|
1201
1900
|
function reshape(_ref) {
|
|
1202
1901
|
var collections = _ref.collections,
|
|
1203
|
-
|
|
1204
|
-
|
|
1902
|
+
props = _ref.props,
|
|
1903
|
+
state = _ref.state;
|
|
1904
|
+
// Sources are grouped by `sourceId` to conveniently pick them via destructuring.
|
|
1205
1905
|
// Example: `const { recentSearchesPlugin } = sourcesBySourceId`
|
|
1206
|
-
|
|
1207
1906
|
var originalSourcesBySourceId = collections.reduce(function (acc, collection) {
|
|
1208
1907
|
return _objectSpread$a(_objectSpread$a({}, acc), {}, _defineProperty$a({}, collection.source.sourceId, _objectSpread$a(_objectSpread$a({}, collection.source), {}, {
|
|
1209
1908
|
getItems: function getItems() {
|
|
@@ -1212,25 +1911,23 @@
|
|
|
1212
1911
|
}
|
|
1213
1912
|
})));
|
|
1214
1913
|
}, {});
|
|
1215
|
-
|
|
1216
1914
|
var _props$plugins$reduce = props.plugins.reduce(function (acc, plugin) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
sourcesBySourceId = _props$plugins$reduce.sourcesBySourceId;
|
|
1227
|
-
|
|
1915
|
+
if (plugin.reshape) {
|
|
1916
|
+
return plugin.reshape(acc);
|
|
1917
|
+
}
|
|
1918
|
+
return acc;
|
|
1919
|
+
}, {
|
|
1920
|
+
sourcesBySourceId: originalSourcesBySourceId,
|
|
1921
|
+
state: state
|
|
1922
|
+
}),
|
|
1923
|
+
sourcesBySourceId = _props$plugins$reduce.sourcesBySourceId;
|
|
1228
1924
|
var reshapeSources = props.reshape({
|
|
1229
1925
|
sourcesBySourceId: sourcesBySourceId,
|
|
1230
1926
|
sources: Object.values(sourcesBySourceId),
|
|
1231
1927
|
state: state
|
|
1232
|
-
});
|
|
1928
|
+
});
|
|
1233
1929
|
|
|
1930
|
+
// We reconstruct the collections with the items modified by the `reshape` prop.
|
|
1234
1931
|
return flatten(reshapeSources).filter(Boolean).map(function (source) {
|
|
1235
1932
|
return {
|
|
1236
1933
|
source: source,
|
|
@@ -1239,29 +1936,25 @@
|
|
|
1239
1936
|
});
|
|
1240
1937
|
}
|
|
1241
1938
|
|
|
1242
|
-
function _typeof(obj) {
|
|
1939
|
+
function _typeof$9(obj) {
|
|
1243
1940
|
"@babel/helpers - typeof";
|
|
1244
1941
|
|
|
1245
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1942
|
+
return _typeof$9 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1246
1943
|
return typeof obj;
|
|
1247
1944
|
} : function (obj) {
|
|
1248
1945
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1249
|
-
}, _typeof(obj);
|
|
1946
|
+
}, _typeof$9(obj);
|
|
1250
1947
|
}
|
|
1251
|
-
|
|
1252
1948
|
function ownKeys$9(object, enumerableOnly) {
|
|
1253
1949
|
var keys = Object.keys(object);
|
|
1254
|
-
|
|
1255
1950
|
if (Object.getOwnPropertySymbols) {
|
|
1256
1951
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1257
1952
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1258
1953
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1259
1954
|
})), keys.push.apply(keys, symbols);
|
|
1260
1955
|
}
|
|
1261
|
-
|
|
1262
1956
|
return keys;
|
|
1263
1957
|
}
|
|
1264
|
-
|
|
1265
1958
|
function _objectSpread$9(target) {
|
|
1266
1959
|
for (var i = 1; i < arguments.length; i++) {
|
|
1267
1960
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1271,11 +1964,10 @@
|
|
|
1271
1964
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1272
1965
|
});
|
|
1273
1966
|
}
|
|
1274
|
-
|
|
1275
1967
|
return target;
|
|
1276
1968
|
}
|
|
1277
|
-
|
|
1278
1969
|
function _defineProperty$9(obj, key, value) {
|
|
1970
|
+
key = _toPropertyKey$9(key);
|
|
1279
1971
|
if (key in obj) {
|
|
1280
1972
|
Object.defineProperty(obj, key, {
|
|
1281
1973
|
value: value,
|
|
@@ -1286,18 +1978,28 @@
|
|
|
1286
1978
|
} else {
|
|
1287
1979
|
obj[key] = value;
|
|
1288
1980
|
}
|
|
1289
|
-
|
|
1290
1981
|
return obj;
|
|
1291
1982
|
}
|
|
1292
|
-
|
|
1983
|
+
function _toPropertyKey$9(arg) {
|
|
1984
|
+
var key = _toPrimitive$9(arg, "string");
|
|
1985
|
+
return _typeof$9(key) === "symbol" ? key : String(key);
|
|
1986
|
+
}
|
|
1987
|
+
function _toPrimitive$9(input, hint) {
|
|
1988
|
+
if (_typeof$9(input) !== "object" || input === null) return input;
|
|
1989
|
+
var prim = input[Symbol.toPrimitive];
|
|
1990
|
+
if (prim !== undefined) {
|
|
1991
|
+
var res = prim.call(input, hint || "default");
|
|
1992
|
+
if (_typeof$9(res) !== "object") return res;
|
|
1993
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1994
|
+
}
|
|
1995
|
+
return (hint === "string" ? String : Number)(input);
|
|
1996
|
+
}
|
|
1293
1997
|
function _toConsumableArray$3(arr) {
|
|
1294
1998
|
return _arrayWithoutHoles$3(arr) || _iterableToArray$3(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread$3();
|
|
1295
1999
|
}
|
|
1296
|
-
|
|
1297
2000
|
function _nonIterableSpread$3() {
|
|
1298
2001
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1299
2002
|
}
|
|
1300
|
-
|
|
1301
2003
|
function _unsupportedIterableToArray$3(o, minLen) {
|
|
1302
2004
|
if (!o) return;
|
|
1303
2005
|
if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
|
|
@@ -1306,38 +2008,27 @@
|
|
|
1306
2008
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1307
2009
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
|
|
1308
2010
|
}
|
|
1309
|
-
|
|
1310
2011
|
function _iterableToArray$3(iter) {
|
|
1311
2012
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1312
2013
|
}
|
|
1313
|
-
|
|
1314
2014
|
function _arrayWithoutHoles$3(arr) {
|
|
1315
2015
|
if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
|
|
1316
2016
|
}
|
|
1317
|
-
|
|
1318
2017
|
function _arrayLikeToArray$3(arr, len) {
|
|
1319
2018
|
if (len == null || len > arr.length) len = arr.length;
|
|
1320
|
-
|
|
1321
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1322
|
-
arr2[i] = arr[i];
|
|
1323
|
-
}
|
|
1324
|
-
|
|
2019
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
1325
2020
|
return arr2;
|
|
1326
2021
|
}
|
|
1327
|
-
|
|
1328
2022
|
function isDescription(item) {
|
|
1329
2023
|
return Boolean(item.execute);
|
|
1330
2024
|
}
|
|
1331
|
-
|
|
1332
2025
|
function isRequesterDescription(description) {
|
|
1333
2026
|
return Boolean(description === null || description === void 0 ? void 0 : description.execute);
|
|
1334
2027
|
}
|
|
1335
|
-
|
|
1336
2028
|
function preResolve(itemsOrDescription, sourceId, state) {
|
|
1337
2029
|
if (isRequesterDescription(itemsOrDescription)) {
|
|
1338
2030
|
var contextParameters = itemsOrDescription.requesterId === 'algolia' ? Object.assign.apply(Object, [{}].concat(_toConsumableArray$3(Object.keys(state.context).map(function (key) {
|
|
1339
2031
|
var _state$context$key;
|
|
1340
|
-
|
|
1341
2032
|
return (_state$context$key = state.context[key]) === null || _state$context$key === void 0 ? void 0 : _state$context$key.__algoliaSearchParameters;
|
|
1342
2033
|
})))) : {};
|
|
1343
2034
|
return _objectSpread$9(_objectSpread$9({}, itemsOrDescription), {}, {
|
|
@@ -1352,7 +2043,6 @@
|
|
|
1352
2043
|
})
|
|
1353
2044
|
});
|
|
1354
2045
|
}
|
|
1355
|
-
|
|
1356
2046
|
return {
|
|
1357
2047
|
items: itemsOrDescription,
|
|
1358
2048
|
sourceId: sourceId
|
|
@@ -1364,18 +2054,15 @@
|
|
|
1364
2054
|
acc.push(current);
|
|
1365
2055
|
return acc;
|
|
1366
2056
|
}
|
|
1367
|
-
|
|
1368
2057
|
var searchClient = current.searchClient,
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
2058
|
+
execute = current.execute,
|
|
2059
|
+
requesterId = current.requesterId,
|
|
2060
|
+
requests = current.requests;
|
|
1372
2061
|
var container = acc.find(function (item) {
|
|
1373
2062
|
return isDescription(current) && isDescription(item) && item.searchClient === searchClient && Boolean(requesterId) && item.requesterId === requesterId;
|
|
1374
2063
|
});
|
|
1375
|
-
|
|
1376
2064
|
if (container) {
|
|
1377
2065
|
var _container$items;
|
|
1378
|
-
|
|
1379
2066
|
(_container$items = container.items).push.apply(_container$items, _toConsumableArray$3(requests));
|
|
1380
2067
|
} else {
|
|
1381
2068
|
var request = {
|
|
@@ -1386,18 +2073,16 @@
|
|
|
1386
2073
|
};
|
|
1387
2074
|
acc.push(request);
|
|
1388
2075
|
}
|
|
1389
|
-
|
|
1390
2076
|
return acc;
|
|
1391
2077
|
}, []);
|
|
1392
2078
|
var values = packed.map(function (maybeDescription) {
|
|
1393
2079
|
if (!isDescription(maybeDescription)) {
|
|
1394
2080
|
return Promise.resolve(maybeDescription);
|
|
1395
2081
|
}
|
|
1396
|
-
|
|
1397
2082
|
var _ref = maybeDescription,
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2083
|
+
execute = _ref.execute,
|
|
2084
|
+
items = _ref.items,
|
|
2085
|
+
searchClient = _ref.searchClient;
|
|
1401
2086
|
return execute({
|
|
1402
2087
|
searchClient: searchClient,
|
|
1403
2088
|
requests: items
|
|
@@ -1425,7 +2110,7 @@
|
|
|
1425
2110
|
state: store.getState()
|
|
1426
2111
|
});
|
|
1427
2112
|
invariant(Array.isArray(items), function () {
|
|
1428
|
-
return "The `getItems` function from source \"".concat(source.sourceId, "\" must return an array of items but returned type ").concat(JSON.stringify(_typeof(items)), ":\n\n").concat(JSON.stringify(decycle(items), null, 2), ".\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems");
|
|
2113
|
+
return "The `getItems` function from source \"".concat(source.sourceId, "\" must return an array of items but returned type ").concat(JSON.stringify(_typeof$9(items)), ":\n\n").concat(JSON.stringify(decycle(items), null, 2), ".\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems");
|
|
1429
2114
|
});
|
|
1430
2115
|
invariant(items.every(Boolean), "The `getItems` function from source \"".concat(source.sourceId, "\" must return an array of items but returned ").concat(JSON.stringify(undefined), ".\n\nDid you forget to return items?\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems"));
|
|
1431
2116
|
return {
|
|
@@ -1435,21 +2120,26 @@
|
|
|
1435
2120
|
});
|
|
1436
2121
|
}
|
|
1437
2122
|
|
|
1438
|
-
|
|
2123
|
+
function _typeof$8(obj) {
|
|
2124
|
+
"@babel/helpers - typeof";
|
|
1439
2125
|
|
|
2126
|
+
return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
2127
|
+
return typeof obj;
|
|
2128
|
+
} : function (obj) {
|
|
2129
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2130
|
+
}, _typeof$8(obj);
|
|
2131
|
+
}
|
|
2132
|
+
var _excluded$7 = ["event", "nextState", "props", "query", "refresh", "store"];
|
|
1440
2133
|
function ownKeys$8(object, enumerableOnly) {
|
|
1441
2134
|
var keys = Object.keys(object);
|
|
1442
|
-
|
|
1443
2135
|
if (Object.getOwnPropertySymbols) {
|
|
1444
2136
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1445
2137
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1446
2138
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1447
2139
|
})), keys.push.apply(keys, symbols);
|
|
1448
2140
|
}
|
|
1449
|
-
|
|
1450
2141
|
return keys;
|
|
1451
2142
|
}
|
|
1452
|
-
|
|
1453
2143
|
function _objectSpread$8(target) {
|
|
1454
2144
|
for (var i = 1; i < arguments.length; i++) {
|
|
1455
2145
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1459,11 +2149,10 @@
|
|
|
1459
2149
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1460
2150
|
});
|
|
1461
2151
|
}
|
|
1462
|
-
|
|
1463
2152
|
return target;
|
|
1464
2153
|
}
|
|
1465
|
-
|
|
1466
2154
|
function _defineProperty$8(obj, key, value) {
|
|
2155
|
+
key = _toPropertyKey$8(key);
|
|
1467
2156
|
if (key in obj) {
|
|
1468
2157
|
Object.defineProperty(obj, key, {
|
|
1469
2158
|
value: value,
|
|
@@ -1474,20 +2163,28 @@
|
|
|
1474
2163
|
} else {
|
|
1475
2164
|
obj[key] = value;
|
|
1476
2165
|
}
|
|
1477
|
-
|
|
1478
2166
|
return obj;
|
|
1479
2167
|
}
|
|
1480
|
-
|
|
2168
|
+
function _toPropertyKey$8(arg) {
|
|
2169
|
+
var key = _toPrimitive$8(arg, "string");
|
|
2170
|
+
return _typeof$8(key) === "symbol" ? key : String(key);
|
|
2171
|
+
}
|
|
2172
|
+
function _toPrimitive$8(input, hint) {
|
|
2173
|
+
if (_typeof$8(input) !== "object" || input === null) return input;
|
|
2174
|
+
var prim = input[Symbol.toPrimitive];
|
|
2175
|
+
if (prim !== undefined) {
|
|
2176
|
+
var res = prim.call(input, hint || "default");
|
|
2177
|
+
if (_typeof$8(res) !== "object") return res;
|
|
2178
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2179
|
+
}
|
|
2180
|
+
return (hint === "string" ? String : Number)(input);
|
|
2181
|
+
}
|
|
1481
2182
|
function _objectWithoutProperties$3(source, excluded) {
|
|
1482
2183
|
if (source == null) return {};
|
|
1483
|
-
|
|
1484
2184
|
var target = _objectWithoutPropertiesLoose$3(source, excluded);
|
|
1485
|
-
|
|
1486
2185
|
var key, i;
|
|
1487
|
-
|
|
1488
2186
|
if (Object.getOwnPropertySymbols) {
|
|
1489
2187
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
1490
|
-
|
|
1491
2188
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
1492
2189
|
key = sourceSymbolKeys[i];
|
|
1493
2190
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -1495,51 +2192,43 @@
|
|
|
1495
2192
|
target[key] = source[key];
|
|
1496
2193
|
}
|
|
1497
2194
|
}
|
|
1498
|
-
|
|
1499
2195
|
return target;
|
|
1500
2196
|
}
|
|
1501
|
-
|
|
1502
2197
|
function _objectWithoutPropertiesLoose$3(source, excluded) {
|
|
1503
2198
|
if (source == null) return {};
|
|
1504
2199
|
var target = {};
|
|
1505
2200
|
var sourceKeys = Object.keys(source);
|
|
1506
2201
|
var key, i;
|
|
1507
|
-
|
|
1508
2202
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
1509
2203
|
key = sourceKeys[i];
|
|
1510
2204
|
if (excluded.indexOf(key) >= 0) continue;
|
|
1511
2205
|
target[key] = source[key];
|
|
1512
2206
|
}
|
|
1513
|
-
|
|
1514
2207
|
return target;
|
|
1515
2208
|
}
|
|
1516
2209
|
var lastStalledId = null;
|
|
1517
2210
|
var runConcurrentSafePromise = createConcurrentSafePromise();
|
|
1518
2211
|
function onInput(_ref) {
|
|
1519
2212
|
var event = _ref.event,
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
2213
|
+
_ref$nextState = _ref.nextState,
|
|
2214
|
+
nextState = _ref$nextState === void 0 ? {} : _ref$nextState,
|
|
2215
|
+
props = _ref.props,
|
|
2216
|
+
query = _ref.query,
|
|
2217
|
+
refresh = _ref.refresh,
|
|
2218
|
+
store = _ref.store,
|
|
2219
|
+
setters = _objectWithoutProperties$3(_ref, _excluded$7);
|
|
1528
2220
|
if (lastStalledId) {
|
|
1529
2221
|
props.environment.clearTimeout(lastStalledId);
|
|
1530
2222
|
}
|
|
1531
|
-
|
|
1532
2223
|
var setCollections = setters.setCollections,
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
2224
|
+
setIsOpen = setters.setIsOpen,
|
|
2225
|
+
setQuery = setters.setQuery,
|
|
2226
|
+
setActiveItemId = setters.setActiveItemId,
|
|
2227
|
+
setStatus = setters.setStatus;
|
|
1537
2228
|
setQuery(query);
|
|
1538
2229
|
setActiveItemId(props.defaultActiveItemId);
|
|
1539
|
-
|
|
1540
2230
|
if (!query && props.openOnFocus === false) {
|
|
1541
2231
|
var _nextState$isOpen;
|
|
1542
|
-
|
|
1543
2232
|
var collections = store.getState().collections.map(function (collection) {
|
|
1544
2233
|
return _objectSpread$8(_objectSpread$8({}, collection), {}, {
|
|
1545
2234
|
items: []
|
|
@@ -1549,28 +2238,28 @@
|
|
|
1549
2238
|
setCollections(collections);
|
|
1550
2239
|
setIsOpen((_nextState$isOpen = nextState.isOpen) !== null && _nextState$isOpen !== void 0 ? _nextState$isOpen : props.shouldPanelOpen({
|
|
1551
2240
|
state: store.getState()
|
|
1552
|
-
}));
|
|
2241
|
+
}));
|
|
2242
|
+
|
|
2243
|
+
// We make sure to update the latest resolved value of the tracked
|
|
1553
2244
|
// promises to keep late resolving promises from "cancelling" the state
|
|
1554
2245
|
// updates performed in this code path.
|
|
1555
2246
|
// We chain with a void promise to respect `onInput`'s expected return type.
|
|
1556
|
-
|
|
1557
2247
|
var _request = cancelable(runConcurrentSafePromise(collections).then(function () {
|
|
1558
2248
|
return Promise.resolve();
|
|
1559
2249
|
}));
|
|
1560
|
-
|
|
1561
2250
|
return store.pendingRequests.add(_request);
|
|
1562
2251
|
}
|
|
1563
|
-
|
|
1564
2252
|
setStatus('loading');
|
|
1565
2253
|
lastStalledId = props.environment.setTimeout(function () {
|
|
1566
2254
|
setStatus('stalled');
|
|
1567
|
-
}, props.stallThreshold);
|
|
2255
|
+
}, props.stallThreshold);
|
|
2256
|
+
|
|
2257
|
+
// We track the entire promise chain triggered by `onInput` before mutating
|
|
1568
2258
|
// the Autocomplete state to make sure that any state manipulation is based on
|
|
1569
2259
|
// fresh data regardless of when promises individually resolve.
|
|
1570
2260
|
// We don't track nested promises and only rely on the full chain resolution,
|
|
1571
2261
|
// meaning we should only ever manipulate the state once this concurrent-safe
|
|
1572
2262
|
// promise is resolved.
|
|
1573
|
-
|
|
1574
2263
|
var request = cancelable(runConcurrentSafePromise(props.getSources(_objectSpread$8({
|
|
1575
2264
|
query: query,
|
|
1576
2265
|
refresh: refresh,
|
|
@@ -1594,12 +2283,12 @@
|
|
|
1594
2283
|
});
|
|
1595
2284
|
});
|
|
1596
2285
|
}))).then(function (collections) {
|
|
1597
|
-
var _nextState$isOpen2;
|
|
2286
|
+
var _nextState$isOpen2;
|
|
2287
|
+
// Parameters passed to `onInput` could be stale when the following code
|
|
1598
2288
|
// executes, because `onInput` calls may not resolve in order.
|
|
1599
2289
|
// If it becomes a problem we'll need to save the last passed parameters.
|
|
1600
2290
|
// See: https://codesandbox.io/s/agitated-cookies-y290z
|
|
1601
2291
|
|
|
1602
|
-
|
|
1603
2292
|
setStatus('idle');
|
|
1604
2293
|
setCollections(collections);
|
|
1605
2294
|
var isPanelOpen = props.shouldPanelOpen({
|
|
@@ -1607,12 +2296,11 @@
|
|
|
1607
2296
|
});
|
|
1608
2297
|
setIsOpen((_nextState$isOpen2 = nextState.isOpen) !== null && _nextState$isOpen2 !== void 0 ? _nextState$isOpen2 : props.openOnFocus && !query && isPanelOpen || isPanelOpen);
|
|
1609
2298
|
var highlightedItem = getActiveItem(store.getState());
|
|
1610
|
-
|
|
1611
2299
|
if (store.getState().activeItemId !== null && highlightedItem) {
|
|
1612
2300
|
var item = highlightedItem.item,
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
2301
|
+
itemInputValue = highlightedItem.itemInputValue,
|
|
2302
|
+
itemUrl = highlightedItem.itemUrl,
|
|
2303
|
+
source = highlightedItem.source;
|
|
1616
2304
|
source.onActive(_objectSpread$8({
|
|
1617
2305
|
event: event,
|
|
1618
2306
|
item: item,
|
|
@@ -1625,7 +2313,6 @@
|
|
|
1625
2313
|
}
|
|
1626
2314
|
}).finally(function () {
|
|
1627
2315
|
setStatus('idle');
|
|
1628
|
-
|
|
1629
2316
|
if (lastStalledId) {
|
|
1630
2317
|
props.environment.clearTimeout(lastStalledId);
|
|
1631
2318
|
}
|
|
@@ -1633,21 +2320,26 @@
|
|
|
1633
2320
|
return store.pendingRequests.add(request);
|
|
1634
2321
|
}
|
|
1635
2322
|
|
|
1636
|
-
|
|
2323
|
+
function _typeof$7(obj) {
|
|
2324
|
+
"@babel/helpers - typeof";
|
|
1637
2325
|
|
|
2326
|
+
return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
2327
|
+
return typeof obj;
|
|
2328
|
+
} : function (obj) {
|
|
2329
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2330
|
+
}, _typeof$7(obj);
|
|
2331
|
+
}
|
|
2332
|
+
var _excluded$6 = ["event", "props", "refresh", "store"];
|
|
1638
2333
|
function ownKeys$7(object, enumerableOnly) {
|
|
1639
2334
|
var keys = Object.keys(object);
|
|
1640
|
-
|
|
1641
2335
|
if (Object.getOwnPropertySymbols) {
|
|
1642
2336
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1643
2337
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1644
2338
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1645
2339
|
})), keys.push.apply(keys, symbols);
|
|
1646
2340
|
}
|
|
1647
|
-
|
|
1648
2341
|
return keys;
|
|
1649
2342
|
}
|
|
1650
|
-
|
|
1651
2343
|
function _objectSpread$7(target) {
|
|
1652
2344
|
for (var i = 1; i < arguments.length; i++) {
|
|
1653
2345
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1657,11 +2349,10 @@
|
|
|
1657
2349
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1658
2350
|
});
|
|
1659
2351
|
}
|
|
1660
|
-
|
|
1661
2352
|
return target;
|
|
1662
2353
|
}
|
|
1663
|
-
|
|
1664
2354
|
function _defineProperty$7(obj, key, value) {
|
|
2355
|
+
key = _toPropertyKey$7(key);
|
|
1665
2356
|
if (key in obj) {
|
|
1666
2357
|
Object.defineProperty(obj, key, {
|
|
1667
2358
|
value: value,
|
|
@@ -1672,20 +2363,28 @@
|
|
|
1672
2363
|
} else {
|
|
1673
2364
|
obj[key] = value;
|
|
1674
2365
|
}
|
|
1675
|
-
|
|
1676
2366
|
return obj;
|
|
1677
2367
|
}
|
|
1678
|
-
|
|
2368
|
+
function _toPropertyKey$7(arg) {
|
|
2369
|
+
var key = _toPrimitive$7(arg, "string");
|
|
2370
|
+
return _typeof$7(key) === "symbol" ? key : String(key);
|
|
2371
|
+
}
|
|
2372
|
+
function _toPrimitive$7(input, hint) {
|
|
2373
|
+
if (_typeof$7(input) !== "object" || input === null) return input;
|
|
2374
|
+
var prim = input[Symbol.toPrimitive];
|
|
2375
|
+
if (prim !== undefined) {
|
|
2376
|
+
var res = prim.call(input, hint || "default");
|
|
2377
|
+
if (_typeof$7(res) !== "object") return res;
|
|
2378
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2379
|
+
}
|
|
2380
|
+
return (hint === "string" ? String : Number)(input);
|
|
2381
|
+
}
|
|
1679
2382
|
function _objectWithoutProperties$2(source, excluded) {
|
|
1680
2383
|
if (source == null) return {};
|
|
1681
|
-
|
|
1682
2384
|
var target = _objectWithoutPropertiesLoose$2(source, excluded);
|
|
1683
|
-
|
|
1684
2385
|
var key, i;
|
|
1685
|
-
|
|
1686
2386
|
if (Object.getOwnPropertySymbols) {
|
|
1687
2387
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
1688
|
-
|
|
1689
2388
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
1690
2389
|
key = sourceSymbolKeys[i];
|
|
1691
2390
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -1693,36 +2392,30 @@
|
|
|
1693
2392
|
target[key] = source[key];
|
|
1694
2393
|
}
|
|
1695
2394
|
}
|
|
1696
|
-
|
|
1697
2395
|
return target;
|
|
1698
2396
|
}
|
|
1699
|
-
|
|
1700
2397
|
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
1701
2398
|
if (source == null) return {};
|
|
1702
2399
|
var target = {};
|
|
1703
2400
|
var sourceKeys = Object.keys(source);
|
|
1704
2401
|
var key, i;
|
|
1705
|
-
|
|
1706
2402
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
1707
2403
|
key = sourceKeys[i];
|
|
1708
2404
|
if (excluded.indexOf(key) >= 0) continue;
|
|
1709
2405
|
target[key] = source[key];
|
|
1710
2406
|
}
|
|
1711
|
-
|
|
1712
2407
|
return target;
|
|
1713
2408
|
}
|
|
1714
2409
|
function onKeyDown(_ref) {
|
|
1715
2410
|
var event = _ref.event,
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
2411
|
+
props = _ref.props,
|
|
2412
|
+
refresh = _ref.refresh,
|
|
2413
|
+
store = _ref.store,
|
|
2414
|
+
setters = _objectWithoutProperties$2(_ref, _excluded$6);
|
|
1721
2415
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
1722
2416
|
// eslint-disable-next-line no-inner-declarations
|
|
1723
2417
|
var triggerScrollIntoView = function triggerScrollIntoView() {
|
|
1724
2418
|
var nodeItem = props.environment.document.getElementById("".concat(props.id, "-item-").concat(store.getState().activeItemId));
|
|
1725
|
-
|
|
1726
2419
|
if (nodeItem) {
|
|
1727
2420
|
if (nodeItem.scrollIntoViewIfNeeded) {
|
|
1728
2421
|
nodeItem.scrollIntoViewIfNeeded(false);
|
|
@@ -1731,16 +2424,13 @@
|
|
|
1731
2424
|
}
|
|
1732
2425
|
}
|
|
1733
2426
|
}; // eslint-disable-next-line no-inner-declarations
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
2427
|
var triggerOnActive = function triggerOnActive() {
|
|
1737
2428
|
var highlightedItem = getActiveItem(store.getState());
|
|
1738
|
-
|
|
1739
2429
|
if (store.getState().activeItemId !== null && highlightedItem) {
|
|
1740
2430
|
var item = highlightedItem.item,
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
2431
|
+
itemInputValue = highlightedItem.itemInputValue,
|
|
2432
|
+
itemUrl = highlightedItem.itemUrl,
|
|
2433
|
+
source = highlightedItem.source;
|
|
1744
2434
|
source.onActive(_objectSpread$7({
|
|
1745
2435
|
event: event,
|
|
1746
2436
|
item: item,
|
|
@@ -1753,11 +2443,10 @@
|
|
|
1753
2443
|
}
|
|
1754
2444
|
}; // Default browser behavior changes the caret placement on ArrowUp and
|
|
1755
2445
|
// ArrowDown.
|
|
2446
|
+
event.preventDefault();
|
|
1756
2447
|
|
|
1757
|
-
|
|
1758
|
-
event.preventDefault(); // When re-opening the panel, we need to split the logic to keep the actions
|
|
2448
|
+
// When re-opening the panel, we need to split the logic to keep the actions
|
|
1759
2449
|
// synchronized as `onInput` returns a promise.
|
|
1760
|
-
|
|
1761
2450
|
if (store.getState().isOpen === false && (props.openOnFocus || Boolean(store.getState().query))) {
|
|
1762
2451
|
onInput(_objectSpread$7({
|
|
1763
2452
|
event: event,
|
|
@@ -1769,10 +2458,10 @@
|
|
|
1769
2458
|
store.dispatch(event.key, {
|
|
1770
2459
|
nextActiveItemId: props.defaultActiveItemId
|
|
1771
2460
|
});
|
|
1772
|
-
triggerOnActive();
|
|
2461
|
+
triggerOnActive();
|
|
2462
|
+
// Since we rely on the DOM, we need to wait for all the micro tasks to
|
|
1773
2463
|
// finish (which include re-opening the panel) to make sure all the
|
|
1774
2464
|
// elements are available.
|
|
1775
|
-
|
|
1776
2465
|
setTimeout(triggerScrollIntoView, 0);
|
|
1777
2466
|
});
|
|
1778
2467
|
} else {
|
|
@@ -1785,18 +2474,20 @@
|
|
|
1785
2474
|
// from removing the query right away because we first want to close the
|
|
1786
2475
|
// panel.
|
|
1787
2476
|
event.preventDefault();
|
|
1788
|
-
store.dispatch(event.key, null);
|
|
2477
|
+
store.dispatch(event.key, null);
|
|
2478
|
+
|
|
2479
|
+
// Hitting the `Escape` key signals the end of a user interaction with the
|
|
1789
2480
|
// autocomplete. At this point, we should ignore any requests that are still
|
|
1790
2481
|
// pending and could reopen the panel once they resolve, because that would
|
|
1791
2482
|
// result in an unsolicited UI behavior.
|
|
1792
|
-
|
|
1793
2483
|
store.pendingRequests.cancelAll();
|
|
1794
2484
|
} else if (event.key === 'Tab') {
|
|
1795
|
-
store.dispatch('blur', null);
|
|
2485
|
+
store.dispatch('blur', null);
|
|
2486
|
+
|
|
2487
|
+
// Hitting the `Escape` key signals the end of a user interaction with the
|
|
1796
2488
|
// autocomplete. At this point, we should ignore any requests that are still
|
|
1797
2489
|
// pending and could reopen the panel once they resolve, because that would
|
|
1798
2490
|
// result in an unsolicited UI behavior.
|
|
1799
|
-
|
|
1800
2491
|
store.pendingRequests.cancelAll();
|
|
1801
2492
|
} else if (event.key === 'Enter') {
|
|
1802
2493
|
// No active item, so we let the browser handle the native `onSubmit` form
|
|
@@ -1811,20 +2502,17 @@
|
|
|
1811
2502
|
if (!props.debug) {
|
|
1812
2503
|
store.pendingRequests.cancelAll();
|
|
1813
2504
|
}
|
|
1814
|
-
|
|
1815
2505
|
return;
|
|
1816
|
-
}
|
|
1817
|
-
// highlighted.
|
|
1818
|
-
|
|
2506
|
+
}
|
|
1819
2507
|
|
|
2508
|
+
// This prevents the `onSubmit` event to be sent because an item is
|
|
2509
|
+
// highlighted.
|
|
1820
2510
|
event.preventDefault();
|
|
1821
|
-
|
|
1822
2511
|
var _ref2 = getActiveItem(store.getState()),
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
2512
|
+
item = _ref2.item,
|
|
2513
|
+
itemInputValue = _ref2.itemInputValue,
|
|
2514
|
+
itemUrl = _ref2.itemUrl,
|
|
2515
|
+
source = _ref2.source;
|
|
1828
2516
|
if (event.metaKey || event.ctrlKey) {
|
|
1829
2517
|
if (itemUrl !== undefined) {
|
|
1830
2518
|
source.onSelect(_objectSpread$7({
|
|
@@ -1877,7 +2565,6 @@
|
|
|
1877
2565
|
});
|
|
1878
2566
|
return;
|
|
1879
2567
|
}
|
|
1880
|
-
|
|
1881
2568
|
onInput(_objectSpread$7({
|
|
1882
2569
|
event: event,
|
|
1883
2570
|
nextState: {
|
|
@@ -1902,27 +2589,32 @@
|
|
|
1902
2589
|
}
|
|
1903
2590
|
}
|
|
1904
2591
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
_excluded3 = ["inputElement"],
|
|
1908
|
-
_excluded4 = ["inputElement", "maxLength"],
|
|
1909
|
-
_excluded5 = ["sourceIndex"],
|
|
1910
|
-
_excluded6 = ["sourceIndex"],
|
|
1911
|
-
_excluded7 = ["item", "source", "sourceIndex"];
|
|
2592
|
+
function _typeof$6(obj) {
|
|
2593
|
+
"@babel/helpers - typeof";
|
|
1912
2594
|
|
|
2595
|
+
return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
2596
|
+
return typeof obj;
|
|
2597
|
+
} : function (obj) {
|
|
2598
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2599
|
+
}, _typeof$6(obj);
|
|
2600
|
+
}
|
|
2601
|
+
var _excluded$5 = ["props", "refresh", "store"],
|
|
2602
|
+
_excluded2 = ["inputElement", "formElement", "panelElement"],
|
|
2603
|
+
_excluded3 = ["inputElement"],
|
|
2604
|
+
_excluded4 = ["inputElement", "maxLength"],
|
|
2605
|
+
_excluded5 = ["sourceIndex"],
|
|
2606
|
+
_excluded6 = ["sourceIndex"],
|
|
2607
|
+
_excluded7 = ["item", "source", "sourceIndex"];
|
|
1913
2608
|
function ownKeys$6(object, enumerableOnly) {
|
|
1914
2609
|
var keys = Object.keys(object);
|
|
1915
|
-
|
|
1916
2610
|
if (Object.getOwnPropertySymbols) {
|
|
1917
2611
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1918
2612
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1919
2613
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1920
2614
|
})), keys.push.apply(keys, symbols);
|
|
1921
2615
|
}
|
|
1922
|
-
|
|
1923
2616
|
return keys;
|
|
1924
2617
|
}
|
|
1925
|
-
|
|
1926
2618
|
function _objectSpread$6(target) {
|
|
1927
2619
|
for (var i = 1; i < arguments.length; i++) {
|
|
1928
2620
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1932,11 +2624,10 @@
|
|
|
1932
2624
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1933
2625
|
});
|
|
1934
2626
|
}
|
|
1935
|
-
|
|
1936
2627
|
return target;
|
|
1937
2628
|
}
|
|
1938
|
-
|
|
1939
2629
|
function _defineProperty$6(obj, key, value) {
|
|
2630
|
+
key = _toPropertyKey$6(key);
|
|
1940
2631
|
if (key in obj) {
|
|
1941
2632
|
Object.defineProperty(obj, key, {
|
|
1942
2633
|
value: value,
|
|
@@ -1947,20 +2638,28 @@
|
|
|
1947
2638
|
} else {
|
|
1948
2639
|
obj[key] = value;
|
|
1949
2640
|
}
|
|
1950
|
-
|
|
1951
2641
|
return obj;
|
|
1952
2642
|
}
|
|
1953
|
-
|
|
2643
|
+
function _toPropertyKey$6(arg) {
|
|
2644
|
+
var key = _toPrimitive$6(arg, "string");
|
|
2645
|
+
return _typeof$6(key) === "symbol" ? key : String(key);
|
|
2646
|
+
}
|
|
2647
|
+
function _toPrimitive$6(input, hint) {
|
|
2648
|
+
if (_typeof$6(input) !== "object" || input === null) return input;
|
|
2649
|
+
var prim = input[Symbol.toPrimitive];
|
|
2650
|
+
if (prim !== undefined) {
|
|
2651
|
+
var res = prim.call(input, hint || "default");
|
|
2652
|
+
if (_typeof$6(res) !== "object") return res;
|
|
2653
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2654
|
+
}
|
|
2655
|
+
return (hint === "string" ? String : Number)(input);
|
|
2656
|
+
}
|
|
1954
2657
|
function _objectWithoutProperties$1(source, excluded) {
|
|
1955
2658
|
if (source == null) return {};
|
|
1956
|
-
|
|
1957
2659
|
var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
|
1958
|
-
|
|
1959
2660
|
var key, i;
|
|
1960
|
-
|
|
1961
2661
|
if (Object.getOwnPropertySymbols) {
|
|
1962
2662
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
1963
|
-
|
|
1964
2663
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
1965
2664
|
key = sourceSymbolKeys[i];
|
|
1966
2665
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -1968,36 +2667,30 @@
|
|
|
1968
2667
|
target[key] = source[key];
|
|
1969
2668
|
}
|
|
1970
2669
|
}
|
|
1971
|
-
|
|
1972
2670
|
return target;
|
|
1973
2671
|
}
|
|
1974
|
-
|
|
1975
2672
|
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
1976
2673
|
if (source == null) return {};
|
|
1977
2674
|
var target = {};
|
|
1978
2675
|
var sourceKeys = Object.keys(source);
|
|
1979
2676
|
var key, i;
|
|
1980
|
-
|
|
1981
2677
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
1982
2678
|
key = sourceKeys[i];
|
|
1983
2679
|
if (excluded.indexOf(key) >= 0) continue;
|
|
1984
2680
|
target[key] = source[key];
|
|
1985
2681
|
}
|
|
1986
|
-
|
|
1987
2682
|
return target;
|
|
1988
2683
|
}
|
|
1989
2684
|
function getPropGetters(_ref) {
|
|
1990
2685
|
var props = _ref.props,
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2686
|
+
refresh = _ref.refresh,
|
|
2687
|
+
store = _ref.store,
|
|
2688
|
+
setters = _objectWithoutProperties$1(_ref, _excluded$5);
|
|
1995
2689
|
var getEnvironmentProps = function getEnvironmentProps(providedProps) {
|
|
1996
2690
|
var inputElement = providedProps.inputElement,
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2691
|
+
formElement = providedProps.formElement,
|
|
2692
|
+
panelElement = providedProps.panelElement,
|
|
2693
|
+
rest = _objectWithoutProperties$1(providedProps, _excluded2);
|
|
2001
2694
|
function onMouseDownOrTouchStart(event) {
|
|
2002
2695
|
// The `onTouchStart`/`onMouseDown` events shouldn't trigger the `blur`
|
|
2003
2696
|
// handler when it's not an interaction with Autocomplete.
|
|
@@ -2006,29 +2699,27 @@
|
|
|
2006
2699
|
// (no interaction with the autocomplete, no future state updates)
|
|
2007
2700
|
// - OR the touched target is the input element (should open the panel)
|
|
2008
2701
|
var isAutocompleteInteraction = store.getState().isOpen || !store.pendingRequests.isEmpty();
|
|
2009
|
-
|
|
2010
2702
|
if (!isAutocompleteInteraction || event.target === inputElement) {
|
|
2011
2703
|
return;
|
|
2012
|
-
}
|
|
2013
|
-
// Right now, a second instance makes this computation return false.
|
|
2014
|
-
|
|
2704
|
+
}
|
|
2015
2705
|
|
|
2706
|
+
// @TODO: support cases where there are multiple Autocomplete instances.
|
|
2707
|
+
// Right now, a second instance makes this computation return false.
|
|
2016
2708
|
var isTargetWithinAutocomplete = [formElement, panelElement].some(function (contextNode) {
|
|
2017
2709
|
return isOrContainsNode(contextNode, event.target);
|
|
2018
2710
|
});
|
|
2019
|
-
|
|
2020
2711
|
if (isTargetWithinAutocomplete === false) {
|
|
2021
|
-
store.dispatch('blur', null);
|
|
2712
|
+
store.dispatch('blur', null);
|
|
2713
|
+
|
|
2714
|
+
// If requests are still pending when the user closes the panel, they
|
|
2022
2715
|
// could reopen the panel once they resolve.
|
|
2023
2716
|
// We want to prevent any subsequent query from reopening the panel
|
|
2024
2717
|
// because it would result in an unsolicited UI behavior.
|
|
2025
|
-
|
|
2026
2718
|
if (!props.debug) {
|
|
2027
2719
|
store.pendingRequests.cancelAll();
|
|
2028
2720
|
}
|
|
2029
2721
|
}
|
|
2030
2722
|
}
|
|
2031
|
-
|
|
2032
2723
|
return _objectSpread$6({
|
|
2033
2724
|
// We do not rely on the native `blur` event of the input to close the
|
|
2034
2725
|
// panel, but rather on a custom `touchstart`/`mousedown` event outside
|
|
@@ -2049,12 +2740,10 @@
|
|
|
2049
2740
|
if (store.getState().isOpen === false || inputElement !== props.environment.document.activeElement || event.target === inputElement) {
|
|
2050
2741
|
return;
|
|
2051
2742
|
}
|
|
2052
|
-
|
|
2053
2743
|
inputElement.blur();
|
|
2054
2744
|
}
|
|
2055
2745
|
}, rest);
|
|
2056
2746
|
};
|
|
2057
|
-
|
|
2058
2747
|
var getRootProps = function getRootProps(rest) {
|
|
2059
2748
|
return _objectSpread$6({
|
|
2060
2749
|
role: 'combobox',
|
|
@@ -2064,18 +2753,15 @@
|
|
|
2064
2753
|
'aria-labelledby': "".concat(props.id, "-label")
|
|
2065
2754
|
}, rest);
|
|
2066
2755
|
};
|
|
2067
|
-
|
|
2068
2756
|
var getFormProps = function getFormProps(providedProps) {
|
|
2069
2757
|
providedProps.inputElement;
|
|
2070
|
-
|
|
2071
|
-
|
|
2758
|
+
var rest = _objectWithoutProperties$1(providedProps, _excluded3);
|
|
2072
2759
|
return _objectSpread$6({
|
|
2073
2760
|
action: '',
|
|
2074
2761
|
noValidate: true,
|
|
2075
2762
|
role: 'search',
|
|
2076
2763
|
onSubmit: function onSubmit(event) {
|
|
2077
2764
|
var _providedProps$inputE;
|
|
2078
|
-
|
|
2079
2765
|
event.preventDefault();
|
|
2080
2766
|
props.onSubmit(_objectSpread$6({
|
|
2081
2767
|
event: event,
|
|
@@ -2087,7 +2773,6 @@
|
|
|
2087
2773
|
},
|
|
2088
2774
|
onReset: function onReset(event) {
|
|
2089
2775
|
var _providedProps$inputE2;
|
|
2090
|
-
|
|
2091
2776
|
event.preventDefault();
|
|
2092
2777
|
props.onReset(_objectSpread$6({
|
|
2093
2778
|
event: event,
|
|
@@ -2099,10 +2784,8 @@
|
|
|
2099
2784
|
}
|
|
2100
2785
|
}, rest);
|
|
2101
2786
|
};
|
|
2102
|
-
|
|
2103
2787
|
var getInputProps = function getInputProps(providedProps) {
|
|
2104
2788
|
var _props$environment$na;
|
|
2105
|
-
|
|
2106
2789
|
function onFocus(event) {
|
|
2107
2790
|
// We want to trigger a query when `openOnFocus` is true
|
|
2108
2791
|
// because the panel should open with the current query.
|
|
@@ -2115,16 +2798,13 @@
|
|
|
2115
2798
|
store: store
|
|
2116
2799
|
}, setters));
|
|
2117
2800
|
}
|
|
2118
|
-
|
|
2119
2801
|
store.dispatch('focus', null);
|
|
2120
2802
|
}
|
|
2121
|
-
|
|
2122
2803
|
var _ref2 = providedProps || {};
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2804
|
+
_ref2.inputElement;
|
|
2805
|
+
var _ref2$maxLength = _ref2.maxLength,
|
|
2806
|
+
maxLength = _ref2$maxLength === void 0 ? 512 : _ref2$maxLength,
|
|
2807
|
+
rest = _objectWithoutProperties$1(_ref2, _excluded4);
|
|
2128
2808
|
var activeItem = getActiveItem(store.getState());
|
|
2129
2809
|
var userAgent = ((_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent) || '';
|
|
2130
2810
|
var shouldFallbackKeyHint = isSamsung(userAgent);
|
|
@@ -2181,34 +2861,28 @@
|
|
|
2181
2861
|
}
|
|
2182
2862
|
}, rest);
|
|
2183
2863
|
};
|
|
2184
|
-
|
|
2185
2864
|
var getAutocompleteId = function getAutocompleteId(instanceId, sourceId) {
|
|
2186
2865
|
return typeof sourceId !== 'undefined' ? "".concat(instanceId, "-").concat(sourceId) : instanceId;
|
|
2187
2866
|
};
|
|
2188
|
-
|
|
2189
2867
|
var getLabelProps = function getLabelProps(providedProps) {
|
|
2190
2868
|
var _ref3 = providedProps || {},
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2869
|
+
sourceIndex = _ref3.sourceIndex,
|
|
2870
|
+
rest = _objectWithoutProperties$1(_ref3, _excluded5);
|
|
2194
2871
|
return _objectSpread$6({
|
|
2195
2872
|
htmlFor: "".concat(getAutocompleteId(props.id, sourceIndex), "-input"),
|
|
2196
2873
|
id: "".concat(getAutocompleteId(props.id, sourceIndex), "-label")
|
|
2197
2874
|
}, rest);
|
|
2198
2875
|
};
|
|
2199
|
-
|
|
2200
2876
|
var getListProps = function getListProps(providedProps) {
|
|
2201
2877
|
var _ref4 = providedProps || {},
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2878
|
+
sourceIndex = _ref4.sourceIndex,
|
|
2879
|
+
rest = _objectWithoutProperties$1(_ref4, _excluded6);
|
|
2205
2880
|
return _objectSpread$6({
|
|
2206
2881
|
role: 'listbox',
|
|
2207
2882
|
'aria-labelledby': "".concat(getAutocompleteId(props.id, sourceIndex), "-label"),
|
|
2208
2883
|
id: "".concat(getAutocompleteId(props.id, sourceIndex), "-list")
|
|
2209
2884
|
}, rest);
|
|
2210
2885
|
};
|
|
2211
|
-
|
|
2212
2886
|
var getPanelProps = function getPanelProps(rest) {
|
|
2213
2887
|
return _objectSpread$6({
|
|
2214
2888
|
onMouseDown: function onMouseDown(event) {
|
|
@@ -2222,13 +2896,11 @@
|
|
|
2222
2896
|
}
|
|
2223
2897
|
}, rest);
|
|
2224
2898
|
};
|
|
2225
|
-
|
|
2226
2899
|
var getItemProps = function getItemProps(providedProps) {
|
|
2227
2900
|
var item = providedProps.item,
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2901
|
+
source = providedProps.source,
|
|
2902
|
+
sourceIndex = providedProps.sourceIndex,
|
|
2903
|
+
rest = _objectWithoutProperties$1(providedProps, _excluded7);
|
|
2232
2904
|
return _objectSpread$6({
|
|
2233
2905
|
id: "".concat(getAutocompleteId(props.id, sourceIndex), "-item-").concat(item.__autocomplete_id),
|
|
2234
2906
|
role: 'option',
|
|
@@ -2237,16 +2909,13 @@
|
|
|
2237
2909
|
if (item.__autocomplete_id === store.getState().activeItemId) {
|
|
2238
2910
|
return;
|
|
2239
2911
|
}
|
|
2240
|
-
|
|
2241
2912
|
store.dispatch('mousemove', item.__autocomplete_id);
|
|
2242
2913
|
var activeItem = getActiveItem(store.getState());
|
|
2243
|
-
|
|
2244
2914
|
if (store.getState().activeItemId !== null && activeItem) {
|
|
2245
2915
|
var _item = activeItem.item,
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2916
|
+
itemInputValue = activeItem.itemInputValue,
|
|
2917
|
+
itemUrl = activeItem.itemUrl,
|
|
2918
|
+
_source = activeItem.source;
|
|
2250
2919
|
_source.onActive(_objectSpread$6({
|
|
2251
2920
|
event: event,
|
|
2252
2921
|
item: _item,
|
|
@@ -2271,12 +2940,13 @@
|
|
|
2271
2940
|
var itemUrl = source.getItemUrl({
|
|
2272
2941
|
item: item,
|
|
2273
2942
|
state: store.getState()
|
|
2274
|
-
});
|
|
2943
|
+
});
|
|
2944
|
+
|
|
2945
|
+
// If `getItemUrl` is provided, it means that the suggestion
|
|
2275
2946
|
// is a link, not plain text that aims at updating the query.
|
|
2276
2947
|
// We can therefore skip the state change because it will update
|
|
2277
2948
|
// the `activeItemId`, resulting in a UI flash, especially
|
|
2278
2949
|
// noticeable on mobile.
|
|
2279
|
-
|
|
2280
2950
|
var runPreCommand = itemUrl ? Promise.resolve() : onInput(_objectSpread$6({
|
|
2281
2951
|
event: event,
|
|
2282
2952
|
nextState: {
|
|
@@ -2301,7 +2971,6 @@
|
|
|
2301
2971
|
}
|
|
2302
2972
|
}, rest);
|
|
2303
2973
|
};
|
|
2304
|
-
|
|
2305
2974
|
return {
|
|
2306
2975
|
getEnvironmentProps: getEnvironmentProps,
|
|
2307
2976
|
getRootProps: getRootProps,
|
|
@@ -2314,19 +2983,25 @@
|
|
|
2314
2983
|
};
|
|
2315
2984
|
}
|
|
2316
2985
|
|
|
2986
|
+
function _typeof$5(obj) {
|
|
2987
|
+
"@babel/helpers - typeof";
|
|
2988
|
+
|
|
2989
|
+
return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
2990
|
+
return typeof obj;
|
|
2991
|
+
} : function (obj) {
|
|
2992
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2993
|
+
}, _typeof$5(obj);
|
|
2994
|
+
}
|
|
2317
2995
|
function ownKeys$5(object, enumerableOnly) {
|
|
2318
2996
|
var keys = Object.keys(object);
|
|
2319
|
-
|
|
2320
2997
|
if (Object.getOwnPropertySymbols) {
|
|
2321
2998
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
2322
2999
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
2323
3000
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2324
3001
|
})), keys.push.apply(keys, symbols);
|
|
2325
3002
|
}
|
|
2326
|
-
|
|
2327
3003
|
return keys;
|
|
2328
3004
|
}
|
|
2329
|
-
|
|
2330
3005
|
function _objectSpread$5(target) {
|
|
2331
3006
|
for (var i = 1; i < arguments.length; i++) {
|
|
2332
3007
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -2336,11 +3011,10 @@
|
|
|
2336
3011
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2337
3012
|
});
|
|
2338
3013
|
}
|
|
2339
|
-
|
|
2340
3014
|
return target;
|
|
2341
3015
|
}
|
|
2342
|
-
|
|
2343
3016
|
function _defineProperty$5(obj, key, value) {
|
|
3017
|
+
key = _toPropertyKey$5(key);
|
|
2344
3018
|
if (key in obj) {
|
|
2345
3019
|
Object.defineProperty(obj, key, {
|
|
2346
3020
|
value: value,
|
|
@@ -2351,14 +3025,26 @@
|
|
|
2351
3025
|
} else {
|
|
2352
3026
|
obj[key] = value;
|
|
2353
3027
|
}
|
|
2354
|
-
|
|
2355
3028
|
return obj;
|
|
2356
3029
|
}
|
|
3030
|
+
function _toPropertyKey$5(arg) {
|
|
3031
|
+
var key = _toPrimitive$5(arg, "string");
|
|
3032
|
+
return _typeof$5(key) === "symbol" ? key : String(key);
|
|
3033
|
+
}
|
|
3034
|
+
function _toPrimitive$5(input, hint) {
|
|
3035
|
+
if (_typeof$5(input) !== "object" || input === null) return input;
|
|
3036
|
+
var prim = input[Symbol.toPrimitive];
|
|
3037
|
+
if (prim !== undefined) {
|
|
3038
|
+
var res = prim.call(input, hint || "default");
|
|
3039
|
+
if (_typeof$5(res) !== "object") return res;
|
|
3040
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3041
|
+
}
|
|
3042
|
+
return (hint === "string" ? String : Number)(input);
|
|
3043
|
+
}
|
|
2357
3044
|
function getMetadata(_ref) {
|
|
2358
3045
|
var _, _options$__autocomple, _options$__autocomple2, _options$__autocomple3;
|
|
2359
|
-
|
|
2360
3046
|
var plugins = _ref.plugins,
|
|
2361
|
-
|
|
3047
|
+
options = _ref.options;
|
|
2362
3048
|
var optionsKey = (_ = (((_options$__autocomple = options.__autocomplete_metadata) === null || _options$__autocomple === void 0 ? void 0 : _options$__autocomple.userAgents) || [])[0]) === null || _ === void 0 ? void 0 : _.segment;
|
|
2363
3049
|
var extraOptions = optionsKey ? _defineProperty$5({}, optionsKey, Object.keys(((_options$__autocomple2 = options.__autocomplete_metadata) === null || _options$__autocomple2 === void 0 ? void 0 : _options$__autocomple2.options) || {})) : {};
|
|
2364
3050
|
return {
|
|
@@ -2376,11 +3062,9 @@
|
|
|
2376
3062
|
}
|
|
2377
3063
|
function injectMetadata(_ref3) {
|
|
2378
3064
|
var _environment$navigato, _environment$navigato2;
|
|
2379
|
-
|
|
2380
3065
|
var metadata = _ref3.metadata,
|
|
2381
|
-
|
|
3066
|
+
environment = _ref3.environment;
|
|
2382
3067
|
var isMetadataEnabled = (_environment$navigato = environment.navigator) === null || _environment$navigato === void 0 ? void 0 : (_environment$navigato2 = _environment$navigato.userAgent) === null || _environment$navigato2 === void 0 ? void 0 : _environment$navigato2.includes('Algolia Crawler');
|
|
2383
|
-
|
|
2384
3068
|
if (isMetadataEnabled) {
|
|
2385
3069
|
var metadataContainer = environment.document.createElement('meta');
|
|
2386
3070
|
var headRef = environment.document.querySelector('head');
|
|
@@ -2394,29 +3078,32 @@
|
|
|
2394
3078
|
|
|
2395
3079
|
function getCompletion(_ref) {
|
|
2396
3080
|
var _getActiveItem;
|
|
2397
|
-
|
|
2398
3081
|
var state = _ref.state;
|
|
2399
|
-
|
|
2400
3082
|
if (state.isOpen === false || state.activeItemId === null) {
|
|
2401
3083
|
return null;
|
|
2402
3084
|
}
|
|
2403
|
-
|
|
2404
3085
|
return ((_getActiveItem = getActiveItem(state)) === null || _getActiveItem === void 0 ? void 0 : _getActiveItem.itemInputValue) || null;
|
|
2405
3086
|
}
|
|
2406
3087
|
|
|
3088
|
+
function _typeof$4(obj) {
|
|
3089
|
+
"@babel/helpers - typeof";
|
|
3090
|
+
|
|
3091
|
+
return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
3092
|
+
return typeof obj;
|
|
3093
|
+
} : function (obj) {
|
|
3094
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
3095
|
+
}, _typeof$4(obj);
|
|
3096
|
+
}
|
|
2407
3097
|
function ownKeys$4(object, enumerableOnly) {
|
|
2408
3098
|
var keys = Object.keys(object);
|
|
2409
|
-
|
|
2410
3099
|
if (Object.getOwnPropertySymbols) {
|
|
2411
3100
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
2412
3101
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
2413
3102
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2414
3103
|
})), keys.push.apply(keys, symbols);
|
|
2415
3104
|
}
|
|
2416
|
-
|
|
2417
3105
|
return keys;
|
|
2418
3106
|
}
|
|
2419
|
-
|
|
2420
3107
|
function _objectSpread$4(target) {
|
|
2421
3108
|
for (var i = 1; i < arguments.length; i++) {
|
|
2422
3109
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -2426,11 +3113,10 @@
|
|
|
2426
3113
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2427
3114
|
});
|
|
2428
3115
|
}
|
|
2429
|
-
|
|
2430
3116
|
return target;
|
|
2431
3117
|
}
|
|
2432
|
-
|
|
2433
3118
|
function _defineProperty$4(obj, key, value) {
|
|
3119
|
+
key = _toPropertyKey$4(key);
|
|
2434
3120
|
if (key in obj) {
|
|
2435
3121
|
Object.defineProperty(obj, key, {
|
|
2436
3122
|
value: value,
|
|
@@ -2441,9 +3127,22 @@
|
|
|
2441
3127
|
} else {
|
|
2442
3128
|
obj[key] = value;
|
|
2443
3129
|
}
|
|
2444
|
-
|
|
2445
3130
|
return obj;
|
|
2446
3131
|
}
|
|
3132
|
+
function _toPropertyKey$4(arg) {
|
|
3133
|
+
var key = _toPrimitive$4(arg, "string");
|
|
3134
|
+
return _typeof$4(key) === "symbol" ? key : String(key);
|
|
3135
|
+
}
|
|
3136
|
+
function _toPrimitive$4(input, hint) {
|
|
3137
|
+
if (_typeof$4(input) !== "object" || input === null) return input;
|
|
3138
|
+
var prim = input[Symbol.toPrimitive];
|
|
3139
|
+
if (prim !== undefined) {
|
|
3140
|
+
var res = prim.call(input, hint || "default");
|
|
3141
|
+
if (_typeof$4(res) !== "object") return res;
|
|
3142
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3143
|
+
}
|
|
3144
|
+
return (hint === "string" ? String : Number)(input);
|
|
3145
|
+
}
|
|
2447
3146
|
var stateReducer = function stateReducer(state, action) {
|
|
2448
3147
|
switch (action.type) {
|
|
2449
3148
|
case 'setActiveItemId':
|
|
@@ -2452,7 +3151,6 @@
|
|
|
2452
3151
|
activeItemId: action.payload
|
|
2453
3152
|
});
|
|
2454
3153
|
}
|
|
2455
|
-
|
|
2456
3154
|
case 'setQuery':
|
|
2457
3155
|
{
|
|
2458
3156
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
@@ -2460,61 +3158,52 @@
|
|
|
2460
3158
|
completion: null
|
|
2461
3159
|
});
|
|
2462
3160
|
}
|
|
2463
|
-
|
|
2464
3161
|
case 'setCollections':
|
|
2465
3162
|
{
|
|
2466
3163
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2467
3164
|
collections: action.payload
|
|
2468
3165
|
});
|
|
2469
3166
|
}
|
|
2470
|
-
|
|
2471
3167
|
case 'setIsOpen':
|
|
2472
3168
|
{
|
|
2473
3169
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2474
3170
|
isOpen: action.payload
|
|
2475
3171
|
});
|
|
2476
3172
|
}
|
|
2477
|
-
|
|
2478
3173
|
case 'setStatus':
|
|
2479
3174
|
{
|
|
2480
3175
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2481
3176
|
status: action.payload
|
|
2482
3177
|
});
|
|
2483
3178
|
}
|
|
2484
|
-
|
|
2485
3179
|
case 'setContext':
|
|
2486
3180
|
{
|
|
2487
3181
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2488
3182
|
context: _objectSpread$4(_objectSpread$4({}, state.context), action.payload)
|
|
2489
3183
|
});
|
|
2490
3184
|
}
|
|
2491
|
-
|
|
2492
3185
|
case 'ArrowDown':
|
|
2493
3186
|
{
|
|
2494
3187
|
var nextState = _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2495
3188
|
activeItemId: action.payload.hasOwnProperty('nextActiveItemId') ? action.payload.nextActiveItemId : getNextActiveItemId(1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)
|
|
2496
3189
|
});
|
|
2497
|
-
|
|
2498
3190
|
return _objectSpread$4(_objectSpread$4({}, nextState), {}, {
|
|
2499
3191
|
completion: getCompletion({
|
|
2500
3192
|
state: nextState
|
|
2501
3193
|
})
|
|
2502
3194
|
});
|
|
2503
3195
|
}
|
|
2504
|
-
|
|
2505
3196
|
case 'ArrowUp':
|
|
2506
3197
|
{
|
|
2507
3198
|
var _nextState = _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2508
3199
|
activeItemId: getNextActiveItemId(-1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)
|
|
2509
3200
|
});
|
|
2510
|
-
|
|
2511
3201
|
return _objectSpread$4(_objectSpread$4({}, _nextState), {}, {
|
|
2512
3202
|
completion: getCompletion({
|
|
2513
3203
|
state: _nextState
|
|
2514
3204
|
})
|
|
2515
3205
|
});
|
|
2516
3206
|
}
|
|
2517
|
-
|
|
2518
3207
|
case 'Escape':
|
|
2519
3208
|
{
|
|
2520
3209
|
if (state.isOpen) {
|
|
@@ -2524,7 +3213,6 @@
|
|
|
2524
3213
|
completion: null
|
|
2525
3214
|
});
|
|
2526
3215
|
}
|
|
2527
|
-
|
|
2528
3216
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2529
3217
|
activeItemId: null,
|
|
2530
3218
|
query: '',
|
|
@@ -2532,7 +3220,6 @@
|
|
|
2532
3220
|
collections: []
|
|
2533
3221
|
});
|
|
2534
3222
|
}
|
|
2535
|
-
|
|
2536
3223
|
case 'submit':
|
|
2537
3224
|
{
|
|
2538
3225
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
@@ -2541,12 +3228,13 @@
|
|
|
2541
3228
|
status: 'idle'
|
|
2542
3229
|
});
|
|
2543
3230
|
}
|
|
2544
|
-
|
|
2545
3231
|
case 'reset':
|
|
2546
3232
|
{
|
|
2547
3233
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2548
|
-
activeItemId:
|
|
3234
|
+
activeItemId:
|
|
3235
|
+
// Since we open the panel on reset when openOnFocus=true
|
|
2549
3236
|
// we need to restore the highlighted index to the defaultActiveItemId. (DocSearch use-case)
|
|
3237
|
+
|
|
2550
3238
|
// Since we close the panel when openOnFocus=false
|
|
2551
3239
|
// we lose track of the highlighted index. (Query-suggestions use-case)
|
|
2552
3240
|
action.props.openOnFocus === true ? action.props.defaultActiveItemId : null,
|
|
@@ -2554,7 +3242,6 @@
|
|
|
2554
3242
|
query: ''
|
|
2555
3243
|
});
|
|
2556
3244
|
}
|
|
2557
|
-
|
|
2558
3245
|
case 'focus':
|
|
2559
3246
|
{
|
|
2560
3247
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
@@ -2564,52 +3251,53 @@
|
|
|
2564
3251
|
})
|
|
2565
3252
|
});
|
|
2566
3253
|
}
|
|
2567
|
-
|
|
2568
3254
|
case 'blur':
|
|
2569
3255
|
{
|
|
2570
3256
|
if (action.props.debug) {
|
|
2571
3257
|
return state;
|
|
2572
3258
|
}
|
|
2573
|
-
|
|
2574
3259
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2575
3260
|
isOpen: false,
|
|
2576
3261
|
activeItemId: null
|
|
2577
3262
|
});
|
|
2578
3263
|
}
|
|
2579
|
-
|
|
2580
3264
|
case 'mousemove':
|
|
2581
3265
|
{
|
|
2582
3266
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2583
3267
|
activeItemId: action.payload
|
|
2584
3268
|
});
|
|
2585
3269
|
}
|
|
2586
|
-
|
|
2587
3270
|
case 'mouseleave':
|
|
2588
3271
|
{
|
|
2589
3272
|
return _objectSpread$4(_objectSpread$4({}, state), {}, {
|
|
2590
3273
|
activeItemId: action.props.defaultActiveItemId
|
|
2591
3274
|
});
|
|
2592
3275
|
}
|
|
2593
|
-
|
|
2594
3276
|
default:
|
|
2595
3277
|
invariant(false, "The reducer action ".concat(JSON.stringify(action.type), " is not supported."));
|
|
2596
3278
|
return state;
|
|
2597
3279
|
}
|
|
2598
3280
|
};
|
|
2599
3281
|
|
|
3282
|
+
function _typeof$3(obj) {
|
|
3283
|
+
"@babel/helpers - typeof";
|
|
3284
|
+
|
|
3285
|
+
return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
3286
|
+
return typeof obj;
|
|
3287
|
+
} : function (obj) {
|
|
3288
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
3289
|
+
}, _typeof$3(obj);
|
|
3290
|
+
}
|
|
2600
3291
|
function ownKeys$3(object, enumerableOnly) {
|
|
2601
3292
|
var keys = Object.keys(object);
|
|
2602
|
-
|
|
2603
3293
|
if (Object.getOwnPropertySymbols) {
|
|
2604
3294
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
2605
3295
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
2606
3296
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2607
3297
|
})), keys.push.apply(keys, symbols);
|
|
2608
3298
|
}
|
|
2609
|
-
|
|
2610
3299
|
return keys;
|
|
2611
3300
|
}
|
|
2612
|
-
|
|
2613
3301
|
function _objectSpread$3(target) {
|
|
2614
3302
|
for (var i = 1; i < arguments.length; i++) {
|
|
2615
3303
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -2619,11 +3307,10 @@
|
|
|
2619
3307
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2620
3308
|
});
|
|
2621
3309
|
}
|
|
2622
|
-
|
|
2623
3310
|
return target;
|
|
2624
3311
|
}
|
|
2625
|
-
|
|
2626
3312
|
function _defineProperty$3(obj, key, value) {
|
|
3313
|
+
key = _toPropertyKey$3(key);
|
|
2627
3314
|
if (key in obj) {
|
|
2628
3315
|
Object.defineProperty(obj, key, {
|
|
2629
3316
|
value: value,
|
|
@@ -2634,9 +3321,22 @@
|
|
|
2634
3321
|
} else {
|
|
2635
3322
|
obj[key] = value;
|
|
2636
3323
|
}
|
|
2637
|
-
|
|
2638
3324
|
return obj;
|
|
2639
3325
|
}
|
|
3326
|
+
function _toPropertyKey$3(arg) {
|
|
3327
|
+
var key = _toPrimitive$3(arg, "string");
|
|
3328
|
+
return _typeof$3(key) === "symbol" ? key : String(key);
|
|
3329
|
+
}
|
|
3330
|
+
function _toPrimitive$3(input, hint) {
|
|
3331
|
+
if (_typeof$3(input) !== "object" || input === null) return input;
|
|
3332
|
+
var prim = input[Symbol.toPrimitive];
|
|
3333
|
+
if (prim !== undefined) {
|
|
3334
|
+
var res = prim.call(input, hint || "default");
|
|
3335
|
+
if (_typeof$3(res) !== "object") return res;
|
|
3336
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3337
|
+
}
|
|
3338
|
+
return (hint === "string" ? String : Number)(input);
|
|
3339
|
+
}
|
|
2640
3340
|
function createAutocomplete(options) {
|
|
2641
3341
|
checkOptions(options);
|
|
2642
3342
|
var subscribers = [];
|
|
@@ -2651,10 +3351,9 @@
|
|
|
2651
3351
|
store: store,
|
|
2652
3352
|
navigator: props.navigator
|
|
2653
3353
|
}, setters));
|
|
2654
|
-
|
|
2655
3354
|
function onStoreStateChange(_ref) {
|
|
2656
3355
|
var prevState = _ref.prevState,
|
|
2657
|
-
|
|
3356
|
+
state = _ref.state;
|
|
2658
3357
|
props.onStateChange(_objectSpread$3({
|
|
2659
3358
|
prevState: prevState,
|
|
2660
3359
|
state: state,
|
|
@@ -2662,7 +3361,6 @@
|
|
|
2662
3361
|
navigator: props.navigator
|
|
2663
3362
|
}, setters));
|
|
2664
3363
|
}
|
|
2665
|
-
|
|
2666
3364
|
function refresh() {
|
|
2667
3365
|
return onInput(_objectSpread$3({
|
|
2668
3366
|
event: new Event('input'),
|
|
@@ -2676,10 +3374,14 @@
|
|
|
2676
3374
|
store: store
|
|
2677
3375
|
}, setters));
|
|
2678
3376
|
}
|
|
2679
|
-
|
|
3377
|
+
if (options.insights && !props.plugins.some(function (plugin) {
|
|
3378
|
+
return plugin.name === 'aa.algoliaInsightsPlugin';
|
|
3379
|
+
})) {
|
|
3380
|
+
var insightsParams = typeof options.insights === 'boolean' ? {} : options.insights;
|
|
3381
|
+
props.plugins.push(createAlgoliaInsightsPlugin(insightsParams));
|
|
3382
|
+
}
|
|
2680
3383
|
props.plugins.forEach(function (plugin) {
|
|
2681
3384
|
var _plugin$subscribe;
|
|
2682
|
-
|
|
2683
3385
|
return (_plugin$subscribe = plugin.subscribe) === null || _plugin$subscribe === void 0 ? void 0 : _plugin$subscribe.call(plugin, _objectSpread$3(_objectSpread$3({}, setters), {}, {
|
|
2684
3386
|
navigator: props.navigator,
|
|
2685
3387
|
refresh: refresh,
|
|
@@ -2735,7 +3437,6 @@
|
|
|
2735
3437
|
invariant(element !== null, "The element ".concat(JSON.stringify(value), " is not in the document."));
|
|
2736
3438
|
return element;
|
|
2737
3439
|
}
|
|
2738
|
-
|
|
2739
3440
|
return value;
|
|
2740
3441
|
}
|
|
2741
3442
|
|
|
@@ -2743,12 +3444,10 @@
|
|
|
2743
3444
|
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2744
3445
|
values[_key] = arguments[_key];
|
|
2745
3446
|
}
|
|
2746
|
-
|
|
2747
3447
|
return values.reduce(function (acc, current) {
|
|
2748
3448
|
Object.keys(current).forEach(function (key) {
|
|
2749
3449
|
var accValue = acc[key];
|
|
2750
3450
|
var currentValue = current[key];
|
|
2751
|
-
|
|
2752
3451
|
if (accValue !== currentValue) {
|
|
2753
3452
|
acc[key] = [accValue, currentValue].filter(Boolean).join(' ');
|
|
2754
3453
|
}
|
|
@@ -2758,21 +3457,18 @@
|
|
|
2758
3457
|
}
|
|
2759
3458
|
|
|
2760
3459
|
var isPlainObject = function isPlainObject(value) {
|
|
2761
|
-
return value && _typeof$
|
|
3460
|
+
return value && _typeof$j(value) === 'object' && Object.prototype.toString.call(value) === '[object Object]';
|
|
2762
3461
|
};
|
|
2763
|
-
|
|
2764
3462
|
function mergeDeep() {
|
|
2765
3463
|
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2766
3464
|
values[_key] = arguments[_key];
|
|
2767
3465
|
}
|
|
2768
|
-
|
|
2769
3466
|
return values.reduce(function (acc, current) {
|
|
2770
3467
|
Object.keys(current).forEach(function (key) {
|
|
2771
3468
|
var accValue = acc[key];
|
|
2772
3469
|
var currentValue = current[key];
|
|
2773
|
-
|
|
2774
3470
|
if (Array.isArray(accValue) && Array.isArray(currentValue)) {
|
|
2775
|
-
acc[key] = accValue.concat.apply(accValue, _toConsumableArray$
|
|
3471
|
+
acc[key] = accValue.concat.apply(accValue, _toConsumableArray$7(currentValue));
|
|
2776
3472
|
} else if (isPlainObject(accValue) && isPlainObject(currentValue)) {
|
|
2777
3473
|
acc[key] = mergeDeep(accValue, currentValue);
|
|
2778
3474
|
} else {
|
|
@@ -2785,17 +3481,15 @@
|
|
|
2785
3481
|
|
|
2786
3482
|
function pickBy(obj, predicate) {
|
|
2787
3483
|
return Object.entries(obj).reduce(function (acc, _ref) {
|
|
2788
|
-
var _ref2 = _slicedToArray$
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
3484
|
+
var _ref2 = _slicedToArray$2(_ref, 2),
|
|
3485
|
+
key = _ref2[0],
|
|
3486
|
+
value = _ref2[1];
|
|
2792
3487
|
if (predicate({
|
|
2793
3488
|
key: key,
|
|
2794
3489
|
value: value
|
|
2795
3490
|
})) {
|
|
2796
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty$
|
|
3491
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty$i({}, key, value));
|
|
2797
3492
|
}
|
|
2798
|
-
|
|
2799
3493
|
return acc;
|
|
2800
3494
|
}, {});
|
|
2801
3495
|
}
|
|
@@ -2808,6 +3502,7 @@
|
|
|
2808
3502
|
* See https://w3c.github.io/touch-events/#extensions-to-the-globaleventhandlers-mixin
|
|
2809
3503
|
*/
|
|
2810
3504
|
var TOUCH_EVENTS_ALIASES = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
|
|
3505
|
+
|
|
2811
3506
|
/*
|
|
2812
3507
|
* Taken from Preact
|
|
2813
3508
|
*
|
|
@@ -2823,24 +3518,21 @@
|
|
|
2823
3518
|
style[key] = value + 'px';
|
|
2824
3519
|
}
|
|
2825
3520
|
}
|
|
3521
|
+
|
|
2826
3522
|
/**
|
|
2827
3523
|
* Proxy an event to hooked event handlers
|
|
2828
3524
|
*/
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
3525
|
function eventProxy(event) {
|
|
2832
3526
|
this._listeners[event.type](event);
|
|
2833
3527
|
}
|
|
3528
|
+
|
|
2834
3529
|
/**
|
|
2835
3530
|
* Set a property value on a DOM node
|
|
2836
3531
|
*/
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
3532
|
function setProperty(dom, name, value) {
|
|
2840
3533
|
var useCapture;
|
|
2841
3534
|
var nameLower;
|
|
2842
3535
|
var oldValue = dom[name];
|
|
2843
|
-
|
|
2844
3536
|
if (name === 'style') {
|
|
2845
3537
|
if (typeof value == 'string') {
|
|
2846
3538
|
dom.style = value;
|
|
@@ -2855,7 +3547,8 @@
|
|
|
2855
3547
|
}
|
|
2856
3548
|
}
|
|
2857
3549
|
}
|
|
2858
|
-
}
|
|
3550
|
+
}
|
|
3551
|
+
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
|
|
2859
3552
|
else if (name[0] === 'o' && name[1] === 'n') {
|
|
2860
3553
|
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
|
2861
3554
|
nameLower = name.toLowerCase();
|
|
@@ -2863,18 +3556,19 @@
|
|
|
2863
3556
|
name = name.slice(2);
|
|
2864
3557
|
if (!dom._listeners) dom._listeners = {};
|
|
2865
3558
|
dom._listeners[name] = value;
|
|
2866
|
-
|
|
2867
3559
|
if (value) {
|
|
2868
3560
|
if (!oldValue) dom.addEventListener(name, eventProxy, useCapture);
|
|
2869
3561
|
} else {
|
|
2870
3562
|
dom.removeEventListener(name, eventProxy, useCapture);
|
|
2871
3563
|
}
|
|
2872
|
-
} else if (name !== 'list' && name !== 'tagName' &&
|
|
3564
|
+
} else if (name !== 'list' && name !== 'tagName' &&
|
|
3565
|
+
// HTMLButtonElement.form and HTMLInputElement.form are read-only but can be set using
|
|
2873
3566
|
// setAttribute
|
|
2874
3567
|
name !== 'form' && name !== 'type' && name !== 'size' && name !== 'download' && name !== 'href' && name in dom) {
|
|
2875
3568
|
dom[name] = value == null ? '' : value;
|
|
2876
3569
|
} else if (typeof value != 'function' && name !== 'dangerouslySetInnerHTML') {
|
|
2877
|
-
if (value == null || value === false &&
|
|
3570
|
+
if (value == null || value === false &&
|
|
3571
|
+
// ARIA-attributes have a different notion of boolean values.
|
|
2878
3572
|
// The value `false` is different from the attribute not
|
|
2879
3573
|
// existing on the DOM, so we can't remove it. For non-boolean
|
|
2880
3574
|
// ARIA-attributes we could treat false as a removal, but the
|
|
@@ -2887,17 +3581,14 @@
|
|
|
2887
3581
|
}
|
|
2888
3582
|
}
|
|
2889
3583
|
}
|
|
2890
|
-
|
|
2891
3584
|
function getNormalizedName(name) {
|
|
2892
3585
|
switch (name) {
|
|
2893
3586
|
case 'onChange':
|
|
2894
3587
|
return 'onInput';
|
|
2895
|
-
|
|
2896
3588
|
default:
|
|
2897
3589
|
return name;
|
|
2898
3590
|
}
|
|
2899
3591
|
}
|
|
2900
|
-
|
|
2901
3592
|
function setProperties(dom, props) {
|
|
2902
3593
|
for (var name in props) {
|
|
2903
3594
|
setProperty(dom, getNormalizedName(name), props[name]);
|
|
@@ -2915,12 +3606,11 @@
|
|
|
2915
3606
|
function getCreateDomElement(environment) {
|
|
2916
3607
|
return function createDomElement(tagName, _ref) {
|
|
2917
3608
|
var _ref$children = _ref.children,
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
3609
|
+
children = _ref$children === void 0 ? [] : _ref$children,
|
|
3610
|
+
props = _objectWithoutProperties$5(_ref, _excluded$4);
|
|
2921
3611
|
var element = environment.document.createElement(tagName);
|
|
2922
3612
|
setProperties(element, props);
|
|
2923
|
-
element.append.apply(element, _toConsumableArray$
|
|
3613
|
+
element.append.apply(element, _toConsumableArray$7(children));
|
|
2924
3614
|
return element;
|
|
2925
3615
|
};
|
|
2926
3616
|
}
|
|
@@ -2928,14 +3618,13 @@
|
|
|
2928
3618
|
var _excluded$3 = ["autocompleteScopeApi", "environment", "classNames", "getInputProps", "getInputPropsCore", "isDetached", "state"];
|
|
2929
3619
|
var Input = function Input(_ref) {
|
|
2930
3620
|
var autocompleteScopeApi = _ref.autocompleteScopeApi,
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3621
|
+
environment = _ref.environment;
|
|
3622
|
+
_ref.classNames;
|
|
3623
|
+
var getInputProps = _ref.getInputProps,
|
|
3624
|
+
getInputPropsCore = _ref.getInputPropsCore,
|
|
3625
|
+
isDetached = _ref.isDetached,
|
|
3626
|
+
state = _ref.state,
|
|
3627
|
+
props = _objectWithoutProperties$5(_ref, _excluded$3);
|
|
2939
3628
|
var createDomElement = getCreateDomElement(environment);
|
|
2940
3629
|
var element = createDomElement('input', props);
|
|
2941
3630
|
var inputProps = getInputProps(_objectSpread2({
|
|
@@ -2951,7 +3640,6 @@
|
|
|
2951
3640
|
if (isDetached && event.key === 'Tab') {
|
|
2952
3641
|
return;
|
|
2953
3642
|
}
|
|
2954
|
-
|
|
2955
3643
|
inputProps.onKeyDown(event);
|
|
2956
3644
|
}
|
|
2957
3645
|
}));
|
|
@@ -2985,16 +3673,16 @@
|
|
|
2985
3673
|
|
|
2986
3674
|
function createAutocompleteDom(_ref) {
|
|
2987
3675
|
var autocomplete = _ref.autocomplete,
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3676
|
+
autocompleteScopeApi = _ref.autocompleteScopeApi,
|
|
3677
|
+
classNames = _ref.classNames,
|
|
3678
|
+
environment = _ref.environment,
|
|
3679
|
+
isDetached = _ref.isDetached,
|
|
3680
|
+
_ref$placeholder = _ref.placeholder,
|
|
3681
|
+
placeholder = _ref$placeholder === void 0 ? 'Search' : _ref$placeholder,
|
|
3682
|
+
propGetters = _ref.propGetters,
|
|
3683
|
+
setIsModalOpen = _ref.setIsModalOpen,
|
|
3684
|
+
state = _ref.state,
|
|
3685
|
+
translations = _ref.translations;
|
|
2998
3686
|
var createDomElement = getCreateDomElement(environment);
|
|
2999
3687
|
var rootProps = propGetters.getRootProps(_objectSpread2({
|
|
3000
3688
|
state: state,
|
|
@@ -3085,13 +3773,20 @@
|
|
|
3085
3773
|
var panel = createDomElement('div', _objectSpread2({
|
|
3086
3774
|
class: classNames.panel
|
|
3087
3775
|
}, panelProps));
|
|
3088
|
-
|
|
3776
|
+
var detachedSearchButtonQuery = createDomElement('div', {
|
|
3777
|
+
class: classNames.detachedSearchButtonQuery,
|
|
3778
|
+
textContent: state.query
|
|
3779
|
+
});
|
|
3780
|
+
var detachedSearchButtonPlaceholder = createDomElement('div', {
|
|
3781
|
+
class: classNames.detachedSearchButtonPlaceholder,
|
|
3782
|
+
hidden: Boolean(state.query),
|
|
3783
|
+
textContent: placeholder
|
|
3784
|
+
});
|
|
3089
3785
|
if ("development" === 'test') {
|
|
3090
3786
|
setProperties(panel, {
|
|
3091
3787
|
'data-testid': 'panel'
|
|
3092
3788
|
});
|
|
3093
3789
|
}
|
|
3094
|
-
|
|
3095
3790
|
if (isDetached) {
|
|
3096
3791
|
var detachedSearchButtonIcon = createDomElement('div', {
|
|
3097
3792
|
class: classNames.detachedSearchButtonIcon,
|
|
@@ -3099,17 +3794,13 @@
|
|
|
3099
3794
|
environment: environment
|
|
3100
3795
|
})]
|
|
3101
3796
|
});
|
|
3102
|
-
var detachedSearchButtonPlaceholder = createDomElement('div', {
|
|
3103
|
-
class: classNames.detachedSearchButtonPlaceholder,
|
|
3104
|
-
textContent: placeholder
|
|
3105
|
-
});
|
|
3106
3797
|
var detachedSearchButton = createDomElement('button', {
|
|
3107
3798
|
type: 'button',
|
|
3108
3799
|
class: classNames.detachedSearchButton,
|
|
3109
3800
|
onClick: function onClick() {
|
|
3110
3801
|
setIsModalOpen(true);
|
|
3111
3802
|
},
|
|
3112
|
-
children: [detachedSearchButtonIcon, detachedSearchButtonPlaceholder]
|
|
3803
|
+
children: [detachedSearchButtonIcon, detachedSearchButtonPlaceholder, detachedSearchButtonQuery]
|
|
3113
3804
|
});
|
|
3114
3805
|
var detachedCancelButton = createDomElement('button', {
|
|
3115
3806
|
type: 'button',
|
|
@@ -3134,10 +3825,11 @@
|
|
|
3134
3825
|
} else {
|
|
3135
3826
|
root.appendChild(form);
|
|
3136
3827
|
}
|
|
3137
|
-
|
|
3138
3828
|
return {
|
|
3139
3829
|
detachedContainer: detachedContainer,
|
|
3140
3830
|
detachedOverlay: detachedOverlay,
|
|
3831
|
+
detachedSearchButtonQuery: detachedSearchButtonQuery,
|
|
3832
|
+
detachedSearchButtonPlaceholder: detachedSearchButtonPlaceholder,
|
|
3141
3833
|
inputWrapper: inputWrapper,
|
|
3142
3834
|
input: input,
|
|
3143
3835
|
root: root,
|
|
@@ -3153,13 +3845,11 @@
|
|
|
3153
3845
|
function createEffectWrapper() {
|
|
3154
3846
|
var effects = [];
|
|
3155
3847
|
var cleanups = [];
|
|
3156
|
-
|
|
3157
3848
|
function runEffect(fn) {
|
|
3158
3849
|
effects.push(fn);
|
|
3159
3850
|
var effectCleanup = fn();
|
|
3160
3851
|
cleanups.push(effectCleanup);
|
|
3161
3852
|
}
|
|
3162
|
-
|
|
3163
3853
|
return {
|
|
3164
3854
|
runEffect: runEffect,
|
|
3165
3855
|
cleanupEffects: function cleanupEffects() {
|
|
@@ -3189,15 +3879,12 @@
|
|
|
3189
3879
|
_ref: {
|
|
3190
3880
|
current: current
|
|
3191
3881
|
},
|
|
3192
|
-
|
|
3193
3882
|
get value() {
|
|
3194
3883
|
return this._ref.current;
|
|
3195
3884
|
},
|
|
3196
|
-
|
|
3197
3885
|
set value(value) {
|
|
3198
3886
|
this._ref.current = value;
|
|
3199
3887
|
}
|
|
3200
|
-
|
|
3201
3888
|
};
|
|
3202
3889
|
reactives.push(reactive);
|
|
3203
3890
|
return reactive;
|
|
@@ -3210,7 +3897,7 @@
|
|
|
3210
3897
|
};
|
|
3211
3898
|
}
|
|
3212
3899
|
|
|
3213
|
-
var n,l,u,t,r,o,
|
|
3900
|
+
var n,l,u,t,r,o,f,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(n,l){for(var u in l)n[u]=l[u];return n}function v(n){var l=n.parentNode;l&&l.removeChild(n);}function y(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return p(l,f,t,r,null)}function p(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u:o};return null==o&&null!=l.vnode&&l.vnode(f),f}function _(n){return n.children}function k(n,l){this.props=n,this.context=l;}function b(n,l){if(null==l)return n.__?b(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?b(n):null}function g(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return g(n)}}function m(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!w.__r++||r!==l.debounceRendering)&&((r=l.debounceRendering)||o)(w);}function w(){var n,l,u,i,r,o,e,c;for(t.sort(f);n=t.shift();)n.__d&&(l=t.length,i=void 0,r=void 0,e=(o=(u=n).__v).__e,(c=u.__P)&&(i=[],(r=h({},o)).__v=o.__v+1,L(c,o,r,u.__n,void 0!==c.ownerSVGElement,null!=o.__h?[e]:null,i,null==e?b(o):e,o.__h),M(i,o),o.__e!=e&&g(o)),t.length>l&&t.sort(f));w.__r=0;}function x(n,l,u,i,t,r,o,f,e,a){var h,v,y,d,k,g,m,w=i&&i.__k||s,x=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(d=u.__k[h]=null==(d=l[h])||"boolean"==typeof d||"function"==typeof d?null:"string"==typeof d||"number"==typeof d||"bigint"==typeof d?p(null,d,null,null,d):Array.isArray(d)?p(_,{children:d},null,null,null):d.__b>0?p(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d)){if(d.__=u,d.__b=u.__b+1,null===(y=w[h])||y&&d.key==y.key&&d.type===y.type)w[h]=void 0;else for(v=0;v<x;v++){if((y=w[v])&&d.key==y.key&&d.type===y.type){w[v]=void 0;break}y=null;}L(n,d,y=y||c,t,r,o,f,e,a),k=d.__e,(v=d.ref)&&y.ref!=v&&(m||(m=[]),y.ref&&m.push(y.ref,null,d),m.push(v,d.__c||k,d)),null!=k?(null==g&&(g=k),"function"==typeof d.type&&d.__k===y.__k?d.__d=e=A(d,e,n):e=C(n,d,y,w,k,e),"function"==typeof u.type&&(u.__d=e)):e&&y.__e==e&&e.parentNode!=n&&(e=b(y));}for(u.__e=g,h=x;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=$(i).nextSibling),S(w[h],w[h]));if(m)for(h=0;h<m.length;h++)O(m[h],m[++h],m[++h]);}function A(n,l,u){for(var i,t=n.__k,r=0;t&&r<t.length;r++)(i=t[r])&&(i.__=n,l="function"==typeof i.type?A(i,l,u):C(u,i,i,t,i.__e,l));return l}function C(n,l,u,i,t,r){var o,f,e;if(void 0!==l.__d)o=l.__d,l.__d=void 0;else if(null==u||t!=r||null==t.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(t),o=null;else {for(f=r,e=0;(f=f.nextSibling)&&e<i.length;e+=1)if(f==t)break n;n.insertBefore(t,r),o=r;}return void 0!==o?o:t.nextSibling}function $(n){var l,u,i;if(null==n.type||"string"==typeof n.type)return n.__e;if(n.__k)for(l=n.__k.length-1;l>=0;l--)if((u=n.__k[l])&&(i=$(u)))return i;return null}function H(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||T(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||T(n,r,l[r],u[r],i);}function I(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a.test(l)?u:u+"px";}function T(n,l,u,i,t){var r;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||I(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||I(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?z:j,r):n.removeEventListener(l,r?z:j,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u));}}function j(n){return this.l[n.type+!1](l.event?l.event(n):n)}function z(n){return this.l[n.type+!0](l.event?l.event(n):n)}function L(n,u,i,t,r,o,f,e,c){var s,a,v,y,p,d,b,g,m,w,A,P,C,$,H,I=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l.__b)&&s(u);try{n:if("function"==typeof I){if(g=u.props,m=(s=I.contextType)&&t[s.__c],w=s?m?m.props.value:s.__:t,i.__c?b=(a=u.__c=i.__c).__=a.__E:("prototype"in I&&I.prototype.render?u.__c=a=new I(g,w):(u.__c=a=new k(g,w),a.constructor=I,a.render=q),m&&m.sub(a),a.props=g,a.state||(a.state={}),a.context=w,a.__n=t,v=a.__d=!0,a.__h=[],a._sb=[]),null==a.__s&&(a.__s=a.state),null!=I.getDerivedStateFromProps&&(a.__s==a.state&&(a.__s=h({},a.__s)),h(a.__s,I.getDerivedStateFromProps(g,a.__s))),y=a.props,p=a.state,a.__v=u,v)null==I.getDerivedStateFromProps&&null!=a.componentWillMount&&a.componentWillMount(),null!=a.componentDidMount&&a.__h.push(a.componentDidMount);else {if(null==I.getDerivedStateFromProps&&g!==y&&null!=a.componentWillReceiveProps&&a.componentWillReceiveProps(g,w),!a.__e&&null!=a.shouldComponentUpdate&&!1===a.shouldComponentUpdate(g,a.__s,w)||u.__v===i.__v){for(u.__v!==i.__v&&(a.props=g,a.state=a.__s,a.__d=!1),a.__e=!1,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),A=0;A<a._sb.length;A++)a.__h.push(a._sb[A]);a._sb=[],a.__h.length&&f.push(a);break n}null!=a.componentWillUpdate&&a.componentWillUpdate(g,a.__s,w),null!=a.componentDidUpdate&&a.__h.push(function(){a.componentDidUpdate(y,p,d);});}if(a.context=w,a.props=g,a.__P=n,P=l.__r,C=0,"prototype"in I&&I.prototype.render){for(a.state=a.__s,a.__d=!1,P&&P(u),s=a.render(a.props,a.state,a.context),$=0;$<a._sb.length;$++)a.__h.push(a._sb[$]);a._sb=[];}else do{a.__d=!1,P&&P(u),s=a.render(a.props,a.state,a.context),a.state=a.__s;}while(a.__d&&++C<25);a.state=a.__s,null!=a.getChildContext&&(t=h(h({},t),a.getChildContext())),v||null==a.getSnapshotBeforeUpdate||(d=a.getSnapshotBeforeUpdate(y,p)),H=null!=s&&s.type===_&&null==s.key?s.props.children:s,x(n,Array.isArray(H)?H:[H],u,i,t,r,o,f,e,c),a.base=u.__e,u.__h=null,a.__h.length&&f.push(a),b&&(a.__E=a.__=null),a.__e=!1;}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=N(i.__e,u,i,t,r,o,f,c);(s=l.diffed)&&s(u);}catch(n){u.__v=null,(c||null!=o)&&(u.__e=e,u.__h=!!c,o[o.indexOf(e)]=null),l.__e(n,u,i);}}function M(n,u){l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l.__e(n,u.__v);}});}function N(l,u,i,t,r,o,f,e){var s,a,h,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(r=!0),null!=o)for(;_<o.length;_++)if((s=o[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,o[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=r?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),o=null,e=!1;}if(null===d)y===p||e&&l.data===p||(l.data=p);else {if(o=o&&n.call(l.childNodes),a=(y=i.props||c).dangerouslySetInnerHTML,h=p.dangerouslySetInnerHTML,!e){if(null!=o)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(h||a)&&(h&&(a&&h.__html==a.__html||h.__html===l.innerHTML)||(l.innerHTML=h&&h.__html||""));}if(H(l,p,y,r,e),h)u.__k=[];else if(_=u.props.children,x(l,Array.isArray(_)?_:[_],u,i,t,r&&"foreignObject"!==d,o,f,o?o[0]:i.__k&&b(i,0),e),null!=o)for(_=o.length;_--;)null!=o[_]&&v(o[_]);e||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&T(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&T(l,"checked",_,y.checked,!1));}return l}function O(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l.__e(n,i);}}function S(n,u,i){var t,r;if(l.unmount&&l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||O(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l.__e(n,u);}t.base=t.__P=null,n.__c=void 0;}if(t=n.__k)for(r=0;r<t.length;r++)t[r]&&S(t[r],u,i||"function"!=typeof n.type);i||null==n.__e||v(n.__e),n.__=n.__e=n.__d=void 0;}function q(n,l,u){return this.constructor(n,u)}function B(u,i,t){var r,o,f;l.__&&l.__(u,i),o=(r="function"==typeof t)?null:t&&t.__k||i.__k,f=[],L(i,u=(!r&&t||i).__k=y(_,null,[u]),o||c,c,void 0!==i.ownerSVGElement,!r&&t?[t]:o?null:i.firstChild?n.call(i.childNodes):null,f,!r&&t?t:o?o.__e:i.firstChild,r),M(f,u);}n=s.slice,l={__e:function(n,l,u,i){for(var t,r,o;l=l.__;)if((t=l.__c)&&!t.__)try{if((r=t.constructor)&&null!=r.getDerivedStateFromError&&(t.setState(r.getDerivedStateFromError(n)),o=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),o=t.__d),o)return t.__E=t}catch(l){n=l;}throw n}},u=0,k.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof n&&(n=n(h({},u),this.props)),n&&h(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),m(this));},k.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m(this));},k.prototype.render=_,t=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},w.__r=0;
|
|
3214
3901
|
|
|
3215
3902
|
var HIGHLIGHT_PRE_TAG = '__aa-highlight__';
|
|
3216
3903
|
var HIGHLIGHT_POST_TAG = '__/aa-highlight__';
|
|
@@ -3219,7 +3906,6 @@
|
|
|
3219
3906
|
* Creates a data structure that allows to concatenate similar highlighting
|
|
3220
3907
|
* parts in a single value.
|
|
3221
3908
|
*/
|
|
3222
|
-
|
|
3223
3909
|
function createAttributeSet() {
|
|
3224
3910
|
var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3225
3911
|
var value = initialValue;
|
|
@@ -3229,7 +3915,6 @@
|
|
|
3229
3915
|
},
|
|
3230
3916
|
add: function add(part) {
|
|
3231
3917
|
var lastPart = value[value.length - 1];
|
|
3232
|
-
|
|
3233
3918
|
if ((lastPart === null || lastPart === void 0 ? void 0 : lastPart.isHighlighted) === part.isHighlighted) {
|
|
3234
3919
|
value[value.length - 1] = {
|
|
3235
3920
|
value: lastPart.value + part.value,
|
|
@@ -3241,7 +3926,6 @@
|
|
|
3241
3926
|
}
|
|
3242
3927
|
};
|
|
3243
3928
|
}
|
|
3244
|
-
|
|
3245
3929
|
function parseAttribute(_ref) {
|
|
3246
3930
|
var highlightedValue = _ref.highlightedValue;
|
|
3247
3931
|
var preTagParts = highlightedValue.split(HIGHLIGHT_PRE_TAG);
|
|
@@ -3256,7 +3940,6 @@
|
|
|
3256
3940
|
value: postTagParts[0],
|
|
3257
3941
|
isHighlighted: true
|
|
3258
3942
|
});
|
|
3259
|
-
|
|
3260
3943
|
if (postTagParts[1] !== '') {
|
|
3261
3944
|
parts.add({
|
|
3262
3945
|
value: postTagParts[1],
|
|
@@ -3270,11 +3953,9 @@
|
|
|
3270
3953
|
function _toConsumableArray$2(arr) {
|
|
3271
3954
|
return _arrayWithoutHoles$2(arr) || _iterableToArray$2(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread$2();
|
|
3272
3955
|
}
|
|
3273
|
-
|
|
3274
3956
|
function _nonIterableSpread$2() {
|
|
3275
3957
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3276
3958
|
}
|
|
3277
|
-
|
|
3278
3959
|
function _unsupportedIterableToArray$2(o, minLen) {
|
|
3279
3960
|
if (!o) return;
|
|
3280
3961
|
if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
|
|
@@ -3283,35 +3964,26 @@
|
|
|
3283
3964
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3284
3965
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
|
|
3285
3966
|
}
|
|
3286
|
-
|
|
3287
3967
|
function _iterableToArray$2(iter) {
|
|
3288
3968
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3289
3969
|
}
|
|
3290
|
-
|
|
3291
3970
|
function _arrayWithoutHoles$2(arr) {
|
|
3292
3971
|
if (Array.isArray(arr)) return _arrayLikeToArray$2(arr);
|
|
3293
3972
|
}
|
|
3294
|
-
|
|
3295
3973
|
function _arrayLikeToArray$2(arr, len) {
|
|
3296
3974
|
if (len == null || len > arr.length) len = arr.length;
|
|
3297
|
-
|
|
3298
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3299
|
-
arr2[i] = arr[i];
|
|
3300
|
-
}
|
|
3301
|
-
|
|
3975
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
3302
3976
|
return arr2;
|
|
3303
3977
|
}
|
|
3304
3978
|
function parseAlgoliaHitHighlight(_ref) {
|
|
3305
3979
|
var hit = _ref.hit,
|
|
3306
|
-
|
|
3980
|
+
attribute = _ref.attribute;
|
|
3307
3981
|
var path = Array.isArray(attribute) ? attribute : [attribute];
|
|
3308
3982
|
var highlightedValue = getAttributeValueByPath(hit, ['_highlightResult'].concat(_toConsumableArray$2(path), ['value']));
|
|
3309
|
-
|
|
3310
3983
|
if (typeof highlightedValue !== 'string') {
|
|
3311
3984
|
"development" !== 'production' ? warn(false, "The attribute \"".concat(path.join('.'), "\" described by the path ").concat(JSON.stringify(path), " does not exist on the hit. Did you set it in `attributesToHighlight`?") + '\nSee https://www.algolia.com/doc/api-reference/api-parameters/attributesToHighlight/') : void 0 ;
|
|
3312
3985
|
highlightedValue = getAttributeValueByPath(hit, path) || '';
|
|
3313
3986
|
}
|
|
3314
|
-
|
|
3315
3987
|
return parseAttribute({
|
|
3316
3988
|
highlightedValue: highlightedValue
|
|
3317
3989
|
});
|
|
@@ -3327,40 +3999,41 @@
|
|
|
3327
3999
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
3328
4000
|
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
3329
4001
|
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
3330
|
-
|
|
3331
4002
|
function unescape(value) {
|
|
3332
4003
|
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
3333
4004
|
return htmlEscapes[character];
|
|
3334
4005
|
}) : value;
|
|
3335
4006
|
}
|
|
3336
|
-
|
|
3337
4007
|
function isPartHighlighted(parts, i) {
|
|
3338
4008
|
var _parts, _parts2;
|
|
3339
|
-
|
|
3340
4009
|
var current = parts[i];
|
|
3341
4010
|
var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true;
|
|
3342
4011
|
var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true;
|
|
3343
|
-
|
|
3344
4012
|
if (!hasAlphanumeric.test(unescape(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
3345
4013
|
return isPreviousHighlighted;
|
|
3346
4014
|
}
|
|
3347
|
-
|
|
3348
4015
|
return current.isHighlighted;
|
|
3349
4016
|
}
|
|
3350
4017
|
|
|
4018
|
+
function _typeof$2(obj) {
|
|
4019
|
+
"@babel/helpers - typeof";
|
|
4020
|
+
|
|
4021
|
+
return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
4022
|
+
return typeof obj;
|
|
4023
|
+
} : function (obj) {
|
|
4024
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
4025
|
+
}, _typeof$2(obj);
|
|
4026
|
+
}
|
|
3351
4027
|
function ownKeys$2(object, enumerableOnly) {
|
|
3352
4028
|
var keys = Object.keys(object);
|
|
3353
|
-
|
|
3354
4029
|
if (Object.getOwnPropertySymbols) {
|
|
3355
4030
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
3356
4031
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
3357
4032
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3358
4033
|
})), keys.push.apply(keys, symbols);
|
|
3359
4034
|
}
|
|
3360
|
-
|
|
3361
4035
|
return keys;
|
|
3362
4036
|
}
|
|
3363
|
-
|
|
3364
4037
|
function _objectSpread$2(target) {
|
|
3365
4038
|
for (var i = 1; i < arguments.length; i++) {
|
|
3366
4039
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -3370,11 +4043,10 @@
|
|
|
3370
4043
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3371
4044
|
});
|
|
3372
4045
|
}
|
|
3373
|
-
|
|
3374
4046
|
return target;
|
|
3375
4047
|
}
|
|
3376
|
-
|
|
3377
4048
|
function _defineProperty$2(obj, key, value) {
|
|
4049
|
+
key = _toPropertyKey$2(key);
|
|
3378
4050
|
if (key in obj) {
|
|
3379
4051
|
Object.defineProperty(obj, key, {
|
|
3380
4052
|
value: value,
|
|
@@ -3385,9 +4057,22 @@
|
|
|
3385
4057
|
} else {
|
|
3386
4058
|
obj[key] = value;
|
|
3387
4059
|
}
|
|
3388
|
-
|
|
3389
4060
|
return obj;
|
|
3390
4061
|
}
|
|
4062
|
+
function _toPropertyKey$2(arg) {
|
|
4063
|
+
var key = _toPrimitive$2(arg, "string");
|
|
4064
|
+
return _typeof$2(key) === "symbol" ? key : String(key);
|
|
4065
|
+
}
|
|
4066
|
+
function _toPrimitive$2(input, hint) {
|
|
4067
|
+
if (_typeof$2(input) !== "object" || input === null) return input;
|
|
4068
|
+
var prim = input[Symbol.toPrimitive];
|
|
4069
|
+
if (prim !== undefined) {
|
|
4070
|
+
var res = prim.call(input, hint || "default");
|
|
4071
|
+
if (_typeof$2(res) !== "object") return res;
|
|
4072
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4073
|
+
}
|
|
4074
|
+
return (hint === "string" ? String : Number)(input);
|
|
4075
|
+
}
|
|
3391
4076
|
function reverseHighlightedParts(parts) {
|
|
3392
4077
|
// We don't want to highlight the whole word when no parts match.
|
|
3393
4078
|
if (!parts.some(function (part) {
|
|
@@ -3399,7 +4084,6 @@
|
|
|
3399
4084
|
});
|
|
3400
4085
|
});
|
|
3401
4086
|
}
|
|
3402
|
-
|
|
3403
4087
|
return parts.map(function (part, i) {
|
|
3404
4088
|
return _objectSpread$2(_objectSpread$2({}, part), {}, {
|
|
3405
4089
|
isHighlighted: !isPartHighlighted(parts, i)
|
|
@@ -3414,11 +4098,9 @@
|
|
|
3414
4098
|
function _toConsumableArray$1(arr) {
|
|
3415
4099
|
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
|
|
3416
4100
|
}
|
|
3417
|
-
|
|
3418
4101
|
function _nonIterableSpread$1() {
|
|
3419
4102
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3420
4103
|
}
|
|
3421
|
-
|
|
3422
4104
|
function _unsupportedIterableToArray$1(o, minLen) {
|
|
3423
4105
|
if (!o) return;
|
|
3424
4106
|
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
@@ -3427,35 +4109,26 @@
|
|
|
3427
4109
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3428
4110
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
3429
4111
|
}
|
|
3430
|
-
|
|
3431
4112
|
function _iterableToArray$1(iter) {
|
|
3432
4113
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3433
4114
|
}
|
|
3434
|
-
|
|
3435
4115
|
function _arrayWithoutHoles$1(arr) {
|
|
3436
4116
|
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
|
|
3437
4117
|
}
|
|
3438
|
-
|
|
3439
4118
|
function _arrayLikeToArray$1(arr, len) {
|
|
3440
4119
|
if (len == null || len > arr.length) len = arr.length;
|
|
3441
|
-
|
|
3442
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3443
|
-
arr2[i] = arr[i];
|
|
3444
|
-
}
|
|
3445
|
-
|
|
4120
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
3446
4121
|
return arr2;
|
|
3447
4122
|
}
|
|
3448
4123
|
function parseAlgoliaHitSnippet(_ref) {
|
|
3449
4124
|
var hit = _ref.hit,
|
|
3450
|
-
|
|
4125
|
+
attribute = _ref.attribute;
|
|
3451
4126
|
var path = Array.isArray(attribute) ? attribute : [attribute];
|
|
3452
4127
|
var highlightedValue = getAttributeValueByPath(hit, ['_snippetResult'].concat(_toConsumableArray$1(path), ['value']));
|
|
3453
|
-
|
|
3454
4128
|
if (typeof highlightedValue !== 'string') {
|
|
3455
4129
|
"development" !== 'production' ? warn(false, "The attribute \"".concat(path.join('.'), "\" described by the path ").concat(JSON.stringify(path), " does not exist on the hit. Did you set it in `attributesToSnippet`?") + '\nSee https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/') : void 0 ;
|
|
3456
4130
|
highlightedValue = getAttributeValueByPath(hit, path) || '';
|
|
3457
4131
|
}
|
|
3458
|
-
|
|
3459
4132
|
return parseAttribute({
|
|
3460
4133
|
highlightedValue: highlightedValue
|
|
3461
4134
|
});
|
|
@@ -3465,19 +4138,25 @@
|
|
|
3465
4138
|
return reverseHighlightedParts(parseAlgoliaHitSnippet(props));
|
|
3466
4139
|
}
|
|
3467
4140
|
|
|
4141
|
+
function _typeof$1(obj) {
|
|
4142
|
+
"@babel/helpers - typeof";
|
|
4143
|
+
|
|
4144
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
4145
|
+
return typeof obj;
|
|
4146
|
+
} : function (obj) {
|
|
4147
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
4148
|
+
}, _typeof$1(obj);
|
|
4149
|
+
}
|
|
3468
4150
|
function ownKeys$1(object, enumerableOnly) {
|
|
3469
4151
|
var keys = Object.keys(object);
|
|
3470
|
-
|
|
3471
4152
|
if (Object.getOwnPropertySymbols) {
|
|
3472
4153
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
3473
4154
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
3474
4155
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3475
4156
|
})), keys.push.apply(keys, symbols);
|
|
3476
4157
|
}
|
|
3477
|
-
|
|
3478
4158
|
return keys;
|
|
3479
4159
|
}
|
|
3480
|
-
|
|
3481
4160
|
function _objectSpread$1(target) {
|
|
3482
4161
|
for (var i = 1; i < arguments.length; i++) {
|
|
3483
4162
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -3487,11 +4166,10 @@
|
|
|
3487
4166
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3488
4167
|
});
|
|
3489
4168
|
}
|
|
3490
|
-
|
|
3491
4169
|
return target;
|
|
3492
4170
|
}
|
|
3493
|
-
|
|
3494
4171
|
function _defineProperty$1(obj, key, value) {
|
|
4172
|
+
key = _toPropertyKey$1(key);
|
|
3495
4173
|
if (key in obj) {
|
|
3496
4174
|
Object.defineProperty(obj, key, {
|
|
3497
4175
|
value: value,
|
|
@@ -3502,10 +4180,22 @@
|
|
|
3502
4180
|
} else {
|
|
3503
4181
|
obj[key] = value;
|
|
3504
4182
|
}
|
|
3505
|
-
|
|
3506
4183
|
return obj;
|
|
3507
4184
|
}
|
|
3508
|
-
|
|
4185
|
+
function _toPropertyKey$1(arg) {
|
|
4186
|
+
var key = _toPrimitive$1(arg, "string");
|
|
4187
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
4188
|
+
}
|
|
4189
|
+
function _toPrimitive$1(input, hint) {
|
|
4190
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
4191
|
+
var prim = input[Symbol.toPrimitive];
|
|
4192
|
+
if (prim !== undefined) {
|
|
4193
|
+
var res = prim.call(input, hint || "default");
|
|
4194
|
+
if (_typeof$1(res) !== "object") return res;
|
|
4195
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4196
|
+
}
|
|
4197
|
+
return (hint === "string" ? String : Number)(input);
|
|
4198
|
+
}
|
|
3509
4199
|
function createRequester(fetcher, requesterId) {
|
|
3510
4200
|
function execute(fetcherParams) {
|
|
3511
4201
|
return fetcher({
|
|
@@ -3516,8 +4206,8 @@
|
|
|
3516
4206
|
}).then(function (responses) {
|
|
3517
4207
|
return responses.map(function (response, index) {
|
|
3518
4208
|
var _fetcherParams$reques = fetcherParams.requests[index],
|
|
3519
|
-
|
|
3520
|
-
|
|
4209
|
+
sourceId = _fetcherParams$reques.sourceId,
|
|
4210
|
+
transformResponse = _fetcherParams$reques.transformResponse;
|
|
3521
4211
|
return {
|
|
3522
4212
|
items: response,
|
|
3523
4213
|
sourceId: sourceId,
|
|
@@ -3526,7 +4216,6 @@
|
|
|
3526
4216
|
});
|
|
3527
4217
|
});
|
|
3528
4218
|
}
|
|
3529
|
-
|
|
3530
4219
|
return function createSpecifiedRequester(requesterParams) {
|
|
3531
4220
|
return function requester(requestParams) {
|
|
3532
4221
|
return _objectSpread$1(_objectSpread$1({
|
|
@@ -3537,21 +4226,40 @@
|
|
|
3537
4226
|
};
|
|
3538
4227
|
}
|
|
3539
4228
|
|
|
3540
|
-
|
|
4229
|
+
function getAppIdAndApiKey(searchClient) {
|
|
4230
|
+
var _searchClient$transpo = searchClient.transporter,
|
|
4231
|
+
headers = _searchClient$transpo.headers,
|
|
4232
|
+
queryParameters = _searchClient$transpo.queryParameters;
|
|
4233
|
+
var APP_ID = 'x-algolia-application-id';
|
|
4234
|
+
var API_KEY = 'x-algolia-api-key';
|
|
4235
|
+
var appId = headers[APP_ID] || queryParameters[APP_ID];
|
|
4236
|
+
var apiKey = headers[API_KEY] || queryParameters[API_KEY];
|
|
4237
|
+
return {
|
|
4238
|
+
appId: appId,
|
|
4239
|
+
apiKey: apiKey
|
|
4240
|
+
};
|
|
4241
|
+
}
|
|
4242
|
+
|
|
4243
|
+
function _typeof(obj) {
|
|
4244
|
+
"@babel/helpers - typeof";
|
|
3541
4245
|
|
|
4246
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
4247
|
+
return typeof obj;
|
|
4248
|
+
} : function (obj) {
|
|
4249
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
4250
|
+
}, _typeof(obj);
|
|
4251
|
+
}
|
|
4252
|
+
var _excluded$2 = ["params"];
|
|
3542
4253
|
function ownKeys(object, enumerableOnly) {
|
|
3543
4254
|
var keys = Object.keys(object);
|
|
3544
|
-
|
|
3545
4255
|
if (Object.getOwnPropertySymbols) {
|
|
3546
4256
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
3547
4257
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
3548
4258
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3549
4259
|
})), keys.push.apply(keys, symbols);
|
|
3550
4260
|
}
|
|
3551
|
-
|
|
3552
4261
|
return keys;
|
|
3553
4262
|
}
|
|
3554
|
-
|
|
3555
4263
|
function _objectSpread(target) {
|
|
3556
4264
|
for (var i = 1; i < arguments.length; i++) {
|
|
3557
4265
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -3561,11 +4269,10 @@
|
|
|
3561
4269
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3562
4270
|
});
|
|
3563
4271
|
}
|
|
3564
|
-
|
|
3565
4272
|
return target;
|
|
3566
4273
|
}
|
|
3567
|
-
|
|
3568
4274
|
function _defineProperty(obj, key, value) {
|
|
4275
|
+
key = _toPropertyKey(key);
|
|
3569
4276
|
if (key in obj) {
|
|
3570
4277
|
Object.defineProperty(obj, key, {
|
|
3571
4278
|
value: value,
|
|
@@ -3576,20 +4283,28 @@
|
|
|
3576
4283
|
} else {
|
|
3577
4284
|
obj[key] = value;
|
|
3578
4285
|
}
|
|
3579
|
-
|
|
3580
4286
|
return obj;
|
|
3581
4287
|
}
|
|
3582
|
-
|
|
4288
|
+
function _toPropertyKey(arg) {
|
|
4289
|
+
var key = _toPrimitive(arg, "string");
|
|
4290
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
4291
|
+
}
|
|
4292
|
+
function _toPrimitive(input, hint) {
|
|
4293
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
4294
|
+
var prim = input[Symbol.toPrimitive];
|
|
4295
|
+
if (prim !== undefined) {
|
|
4296
|
+
var res = prim.call(input, hint || "default");
|
|
4297
|
+
if (_typeof(res) !== "object") return res;
|
|
4298
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4299
|
+
}
|
|
4300
|
+
return (hint === "string" ? String : Number)(input);
|
|
4301
|
+
}
|
|
3583
4302
|
function _objectWithoutProperties(source, excluded) {
|
|
3584
4303
|
if (source == null) return {};
|
|
3585
|
-
|
|
3586
4304
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
3587
|
-
|
|
3588
4305
|
var key, i;
|
|
3589
|
-
|
|
3590
4306
|
if (Object.getOwnPropertySymbols) {
|
|
3591
4307
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
3592
|
-
|
|
3593
4308
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
3594
4309
|
key = sourceSymbolKeys[i];
|
|
3595
4310
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -3597,33 +4312,26 @@
|
|
|
3597
4312
|
target[key] = source[key];
|
|
3598
4313
|
}
|
|
3599
4314
|
}
|
|
3600
|
-
|
|
3601
4315
|
return target;
|
|
3602
4316
|
}
|
|
3603
|
-
|
|
3604
4317
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
3605
4318
|
if (source == null) return {};
|
|
3606
4319
|
var target = {};
|
|
3607
4320
|
var sourceKeys = Object.keys(source);
|
|
3608
4321
|
var key, i;
|
|
3609
|
-
|
|
3610
4322
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
3611
4323
|
key = sourceKeys[i];
|
|
3612
4324
|
if (excluded.indexOf(key) >= 0) continue;
|
|
3613
4325
|
target[key] = source[key];
|
|
3614
4326
|
}
|
|
3615
|
-
|
|
3616
4327
|
return target;
|
|
3617
4328
|
}
|
|
3618
|
-
|
|
3619
4329
|
function _toConsumableArray(arr) {
|
|
3620
4330
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
3621
4331
|
}
|
|
3622
|
-
|
|
3623
4332
|
function _nonIterableSpread() {
|
|
3624
4333
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3625
4334
|
}
|
|
3626
|
-
|
|
3627
4335
|
function _unsupportedIterableToArray(o, minLen) {
|
|
3628
4336
|
if (!o) return;
|
|
3629
4337
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -3632,43 +4340,36 @@
|
|
|
3632
4340
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3633
4341
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
3634
4342
|
}
|
|
3635
|
-
|
|
3636
4343
|
function _iterableToArray(iter) {
|
|
3637
4344
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3638
4345
|
}
|
|
3639
|
-
|
|
3640
4346
|
function _arrayWithoutHoles(arr) {
|
|
3641
4347
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
3642
4348
|
}
|
|
3643
|
-
|
|
3644
4349
|
function _arrayLikeToArray(arr, len) {
|
|
3645
4350
|
if (len == null || len > arr.length) len = arr.length;
|
|
3646
|
-
|
|
3647
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3648
|
-
arr2[i] = arr[i];
|
|
3649
|
-
}
|
|
3650
|
-
|
|
4351
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
3651
4352
|
return arr2;
|
|
3652
4353
|
}
|
|
3653
4354
|
function fetchAlgoliaResults(_ref) {
|
|
3654
4355
|
var searchClient = _ref.searchClient,
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
4356
|
+
queries = _ref.queries,
|
|
4357
|
+
_ref$userAgents = _ref.userAgents,
|
|
4358
|
+
userAgents = _ref$userAgents === void 0 ? [] : _ref$userAgents;
|
|
3659
4359
|
if (typeof searchClient.addAlgoliaAgent === 'function') {
|
|
3660
4360
|
var algoliaAgents = [].concat(_toConsumableArray(userAgents$1), _toConsumableArray(userAgents));
|
|
3661
4361
|
algoliaAgents.forEach(function (_ref2) {
|
|
3662
4362
|
var segment = _ref2.segment,
|
|
3663
|
-
|
|
4363
|
+
version = _ref2.version;
|
|
3664
4364
|
searchClient.addAlgoliaAgent(segment, version);
|
|
3665
4365
|
});
|
|
3666
4366
|
}
|
|
3667
|
-
|
|
4367
|
+
var _getAppIdAndApiKey = getAppIdAndApiKey(searchClient),
|
|
4368
|
+
appId = _getAppIdAndApiKey.appId,
|
|
4369
|
+
apiKey = _getAppIdAndApiKey.apiKey;
|
|
3668
4370
|
return searchClient.search(queries.map(function (searchParameters) {
|
|
3669
4371
|
var params = searchParameters.params,
|
|
3670
|
-
|
|
3671
|
-
|
|
4372
|
+
headers = _objectWithoutProperties(searchParameters, _excluded$2);
|
|
3672
4373
|
return _objectSpread(_objectSpread({}, headers), {}, {
|
|
3673
4374
|
params: _objectSpread({
|
|
3674
4375
|
hitsPerPage: 5,
|
|
@@ -3677,19 +4378,30 @@
|
|
|
3677
4378
|
}, params)
|
|
3678
4379
|
});
|
|
3679
4380
|
})).then(function (response) {
|
|
3680
|
-
return response.results
|
|
4381
|
+
return response.results.map(function (result) {
|
|
4382
|
+
var _result$hits;
|
|
4383
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
4384
|
+
hits: (_result$hits = result.hits) === null || _result$hits === void 0 ? void 0 : _result$hits.map(function (hit) {
|
|
4385
|
+
return _objectSpread(_objectSpread({}, hit), {}, {
|
|
4386
|
+
__autocomplete_algoliaCredentials: {
|
|
4387
|
+
appId: appId,
|
|
4388
|
+
apiKey: apiKey
|
|
4389
|
+
}
|
|
4390
|
+
});
|
|
4391
|
+
})
|
|
4392
|
+
});
|
|
4393
|
+
});
|
|
3681
4394
|
});
|
|
3682
4395
|
}
|
|
3683
4396
|
|
|
3684
4397
|
function createHighlightComponent(_ref) {
|
|
3685
4398
|
var createElement = _ref.createElement,
|
|
3686
|
-
|
|
3687
|
-
|
|
4399
|
+
Fragment = _ref.Fragment;
|
|
3688
4400
|
function Highlight(_ref2) {
|
|
3689
4401
|
var hit = _ref2.hit,
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
4402
|
+
attribute = _ref2.attribute,
|
|
4403
|
+
_ref2$tagName = _ref2.tagName,
|
|
4404
|
+
tagName = _ref2$tagName === void 0 ? 'mark' : _ref2$tagName;
|
|
3693
4405
|
return createElement(Fragment, {}, parseAlgoliaHitHighlight({
|
|
3694
4406
|
hit: hit,
|
|
3695
4407
|
attribute: attribute
|
|
@@ -3699,20 +4411,18 @@
|
|
|
3699
4411
|
}, x.value) : x.value;
|
|
3700
4412
|
}));
|
|
3701
4413
|
}
|
|
3702
|
-
|
|
3703
4414
|
Highlight.__autocomplete_componentName = 'Highlight';
|
|
3704
4415
|
return Highlight;
|
|
3705
4416
|
}
|
|
3706
4417
|
|
|
3707
4418
|
function createReverseHighlightComponent(_ref) {
|
|
3708
4419
|
var createElement = _ref.createElement,
|
|
3709
|
-
|
|
3710
|
-
|
|
4420
|
+
Fragment = _ref.Fragment;
|
|
3711
4421
|
function ReverseHighlight(_ref2) {
|
|
3712
4422
|
var hit = _ref2.hit,
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
4423
|
+
attribute = _ref2.attribute,
|
|
4424
|
+
_ref2$tagName = _ref2.tagName,
|
|
4425
|
+
tagName = _ref2$tagName === void 0 ? 'mark' : _ref2$tagName;
|
|
3716
4426
|
return createElement(Fragment, {}, parseAlgoliaHitReverseHighlight({
|
|
3717
4427
|
hit: hit,
|
|
3718
4428
|
attribute: attribute
|
|
@@ -3722,20 +4432,18 @@
|
|
|
3722
4432
|
}, x.value) : x.value;
|
|
3723
4433
|
}));
|
|
3724
4434
|
}
|
|
3725
|
-
|
|
3726
4435
|
ReverseHighlight.__autocomplete_componentName = 'ReverseHighlight';
|
|
3727
4436
|
return ReverseHighlight;
|
|
3728
4437
|
}
|
|
3729
4438
|
|
|
3730
4439
|
function createReverseSnippetComponent(_ref) {
|
|
3731
4440
|
var createElement = _ref.createElement,
|
|
3732
|
-
|
|
3733
|
-
|
|
4441
|
+
Fragment = _ref.Fragment;
|
|
3734
4442
|
function ReverseSnippet(_ref2) {
|
|
3735
4443
|
var hit = _ref2.hit,
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
4444
|
+
attribute = _ref2.attribute,
|
|
4445
|
+
_ref2$tagName = _ref2.tagName,
|
|
4446
|
+
tagName = _ref2$tagName === void 0 ? 'mark' : _ref2$tagName;
|
|
3739
4447
|
return createElement(Fragment, {}, parseAlgoliaHitReverseSnippet({
|
|
3740
4448
|
hit: hit,
|
|
3741
4449
|
attribute: attribute
|
|
@@ -3745,20 +4453,18 @@
|
|
|
3745
4453
|
}, x.value) : x.value;
|
|
3746
4454
|
}));
|
|
3747
4455
|
}
|
|
3748
|
-
|
|
3749
4456
|
ReverseSnippet.__autocomplete_componentName = 'ReverseSnippet';
|
|
3750
4457
|
return ReverseSnippet;
|
|
3751
4458
|
}
|
|
3752
4459
|
|
|
3753
4460
|
function createSnippetComponent(_ref) {
|
|
3754
4461
|
var createElement = _ref.createElement,
|
|
3755
|
-
|
|
3756
|
-
|
|
4462
|
+
Fragment = _ref.Fragment;
|
|
3757
4463
|
function Snippet(_ref2) {
|
|
3758
4464
|
var hit = _ref2.hit,
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
4465
|
+
attribute = _ref2.attribute,
|
|
4466
|
+
_ref2$tagName = _ref2.tagName,
|
|
4467
|
+
tagName = _ref2$tagName === void 0 ? 'mark' : _ref2$tagName;
|
|
3762
4468
|
return createElement(Fragment, {}, parseAlgoliaHitSnippet({
|
|
3763
4469
|
hit: hit,
|
|
3764
4470
|
attribute: attribute
|
|
@@ -3768,7 +4474,6 @@
|
|
|
3768
4474
|
}, x.value) : x.value;
|
|
3769
4475
|
}));
|
|
3770
4476
|
}
|
|
3771
|
-
|
|
3772
4477
|
Snippet.__autocomplete_componentName = 'Snippet';
|
|
3773
4478
|
return Snippet;
|
|
3774
4479
|
}
|
|
@@ -3783,6 +4488,7 @@
|
|
|
3783
4488
|
detachedSearchButton: 'aa-DetachedSearchButton',
|
|
3784
4489
|
detachedSearchButtonIcon: 'aa-DetachedSearchButtonIcon',
|
|
3785
4490
|
detachedSearchButtonPlaceholder: 'aa-DetachedSearchButtonPlaceholder',
|
|
4491
|
+
detachedSearchButtonQuery: 'aa-DetachedSearchButtonQuery',
|
|
3786
4492
|
form: 'aa-Form',
|
|
3787
4493
|
input: 'aa-Input',
|
|
3788
4494
|
inputWrapper: 'aa-InputWrapper',
|
|
@@ -3801,53 +4507,46 @@
|
|
|
3801
4507
|
sourceNoResults: 'aa-SourceNoResults',
|
|
3802
4508
|
submitButton: 'aa-SubmitButton'
|
|
3803
4509
|
};
|
|
3804
|
-
|
|
3805
4510
|
var defaultRender = function defaultRender(_ref, root) {
|
|
3806
4511
|
var children = _ref.children,
|
|
3807
|
-
|
|
4512
|
+
render = _ref.render;
|
|
3808
4513
|
render(children, root);
|
|
3809
4514
|
};
|
|
3810
|
-
|
|
3811
4515
|
var defaultRenderer = {
|
|
3812
|
-
createElement:
|
|
3813
|
-
Fragment:
|
|
3814
|
-
render:
|
|
4516
|
+
createElement: y,
|
|
4517
|
+
Fragment: _,
|
|
4518
|
+
render: B
|
|
3815
4519
|
};
|
|
3816
4520
|
function getDefaultOptions(options) {
|
|
3817
4521
|
var _core$id;
|
|
3818
|
-
|
|
3819
4522
|
var classNames = options.classNames,
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
/* eslint-disable no-restricted-globals */
|
|
3839
|
-
|
|
4523
|
+
container = options.container,
|
|
4524
|
+
getEnvironmentProps = options.getEnvironmentProps,
|
|
4525
|
+
getFormProps = options.getFormProps,
|
|
4526
|
+
getInputProps = options.getInputProps,
|
|
4527
|
+
getItemProps = options.getItemProps,
|
|
4528
|
+
getLabelProps = options.getLabelProps,
|
|
4529
|
+
getListProps = options.getListProps,
|
|
4530
|
+
getPanelProps = options.getPanelProps,
|
|
4531
|
+
getRootProps = options.getRootProps,
|
|
4532
|
+
panelContainer = options.panelContainer,
|
|
4533
|
+
panelPlacement = options.panelPlacement,
|
|
4534
|
+
render = options.render,
|
|
4535
|
+
renderNoResults = options.renderNoResults,
|
|
4536
|
+
renderer = options.renderer,
|
|
4537
|
+
detachedMediaQuery = options.detachedMediaQuery,
|
|
4538
|
+
components = options.components,
|
|
4539
|
+
translations = options.translations,
|
|
4540
|
+
core = _objectWithoutProperties$5(options, _excluded$1);
|
|
3840
4541
|
|
|
4542
|
+
/* eslint-disable no-restricted-globals */
|
|
3841
4543
|
var environment = typeof window !== 'undefined' ? window : {};
|
|
3842
4544
|
/* eslint-enable no-restricted-globals */
|
|
3843
|
-
|
|
3844
4545
|
var containerElement = getHTMLElement(environment, container);
|
|
3845
4546
|
invariant(containerElement.tagName !== 'INPUT', 'The `container` option does not support `input` elements. You need to change the container to a `div`.');
|
|
3846
4547
|
"development" !== 'production' ? warn(!(render && renderer && !(renderer !== null && renderer !== void 0 && renderer.render)), "You provided the `render` option but did not provide a `renderer.render`. Since v1.6.0, you can provide a `render` function directly in `renderer`." + "\nTo get rid of this warning, do any of the following depending on your use case." + "\n- If you are using the `render` option only to override Autocomplete's default `render` function, pass the `render` function into `renderer` and remove the `render` option." + '\n- If you are using the `render` option to customize the layout, pass your `render` function into `renderer` and use it from the provided parameters of the `render` option.' + '\n- If you are using the `render` option to work with React 18, pass an empty `render` function into `renderer`.' + '\nSee https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-render') : void 0;
|
|
3847
4548
|
"development" !== 'production' ? warn(!renderer || render || renderer.Fragment && renderer.createElement && renderer.render, "You provided an incomplete `renderer` (missing: ".concat([!(renderer !== null && renderer !== void 0 && renderer.createElement) && '`renderer.createElement`', !(renderer !== null && renderer !== void 0 && renderer.Fragment) && '`renderer.Fragment`', !(renderer !== null && renderer !== void 0 && renderer.render) && '`renderer.render`'].filter(Boolean).join(', '), "). This can cause rendering issues.") + '\nSee https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-renderer') : void 0;
|
|
3848
|
-
|
|
3849
4549
|
var defaultedRenderer = _objectSpread2(_objectSpread2({}, defaultRenderer), renderer);
|
|
3850
|
-
|
|
3851
4550
|
var defaultComponents = {
|
|
3852
4551
|
Highlight: createHighlightComponent(defaultedRenderer),
|
|
3853
4552
|
ReverseHighlight: createReverseHighlightComponent(defaultedRenderer),
|
|
@@ -3913,15 +4612,14 @@
|
|
|
3913
4612
|
|
|
3914
4613
|
function getPanelPlacementStyle(_ref) {
|
|
3915
4614
|
var panelPlacement = _ref.panelPlacement,
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
var containerRect = container.getBoundingClientRect();
|
|
4615
|
+
container = _ref.container,
|
|
4616
|
+
form = _ref.form,
|
|
4617
|
+
environment = _ref.environment;
|
|
4618
|
+
var containerRect = container.getBoundingClientRect();
|
|
4619
|
+
// Some browsers have specificities to retrieve the document scroll position.
|
|
3920
4620
|
// See https://stackoverflow.com/a/28633515/9940315
|
|
3921
|
-
|
|
3922
4621
|
var scrollTop = environment.pageYOffset || environment.document.documentElement.scrollTop || environment.document.body.scrollTop || 0;
|
|
3923
4622
|
var top = scrollTop + containerRect.top + containerRect.height;
|
|
3924
|
-
|
|
3925
4623
|
switch (panelPlacement) {
|
|
3926
4624
|
case 'start':
|
|
3927
4625
|
{
|
|
@@ -3930,7 +4628,6 @@
|
|
|
3930
4628
|
left: containerRect.left
|
|
3931
4629
|
};
|
|
3932
4630
|
}
|
|
3933
|
-
|
|
3934
4631
|
case 'end':
|
|
3935
4632
|
{
|
|
3936
4633
|
return {
|
|
@@ -3938,7 +4635,6 @@
|
|
|
3938
4635
|
right: environment.document.documentElement.clientWidth - (containerRect.left + containerRect.width)
|
|
3939
4636
|
};
|
|
3940
4637
|
}
|
|
3941
|
-
|
|
3942
4638
|
case 'full-width':
|
|
3943
4639
|
{
|
|
3944
4640
|
return {
|
|
@@ -3949,7 +4645,6 @@
|
|
|
3949
4645
|
maxWidth: 'unset'
|
|
3950
4646
|
};
|
|
3951
4647
|
}
|
|
3952
|
-
|
|
3953
4648
|
case 'input-wrapper-width':
|
|
3954
4649
|
{
|
|
3955
4650
|
var formRect = form.getBoundingClientRect();
|
|
@@ -3961,7 +4656,6 @@
|
|
|
3961
4656
|
maxWidth: 'unset'
|
|
3962
4657
|
};
|
|
3963
4658
|
}
|
|
3964
|
-
|
|
3965
4659
|
default:
|
|
3966
4660
|
{
|
|
3967
4661
|
throw new Error("[Autocomplete] The `panelPlacement` value ".concat(JSON.stringify(panelPlacement), " is not valid."));
|
|
@@ -3971,10 +4665,10 @@
|
|
|
3971
4665
|
|
|
3972
4666
|
function renderSearchBox(_ref) {
|
|
3973
4667
|
var autocomplete = _ref.autocomplete,
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
4668
|
+
autocompleteScopeApi = _ref.autocompleteScopeApi,
|
|
4669
|
+
dom = _ref.dom,
|
|
4670
|
+
propGetters = _ref.propGetters,
|
|
4671
|
+
state = _ref.state;
|
|
3978
4672
|
setPropertiesWithoutEvents(dom.root, propGetters.getRootProps(_objectSpread2({
|
|
3979
4673
|
state: state,
|
|
3980
4674
|
props: autocomplete.getRootProps({})
|
|
@@ -3995,41 +4689,44 @@
|
|
|
3995
4689
|
setProperties(dom.clearButton, {
|
|
3996
4690
|
hidden: !state.query
|
|
3997
4691
|
});
|
|
4692
|
+
setProperties(dom.detachedSearchButtonQuery, {
|
|
4693
|
+
textContent: state.query
|
|
4694
|
+
});
|
|
4695
|
+
setProperties(dom.detachedSearchButtonPlaceholder, {
|
|
4696
|
+
hidden: Boolean(state.query)
|
|
4697
|
+
});
|
|
3998
4698
|
}
|
|
3999
4699
|
function renderPanel(render, _ref2) {
|
|
4000
4700
|
var autocomplete = _ref2.autocomplete,
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4701
|
+
autocompleteScopeApi = _ref2.autocompleteScopeApi,
|
|
4702
|
+
classNames = _ref2.classNames,
|
|
4703
|
+
html = _ref2.html,
|
|
4704
|
+
dom = _ref2.dom,
|
|
4705
|
+
panelContainer = _ref2.panelContainer,
|
|
4706
|
+
propGetters = _ref2.propGetters,
|
|
4707
|
+
state = _ref2.state,
|
|
4708
|
+
components = _ref2.components,
|
|
4709
|
+
renderer = _ref2.renderer;
|
|
4011
4710
|
if (!state.isOpen) {
|
|
4012
4711
|
if (panelContainer.contains(dom.panel)) {
|
|
4013
4712
|
panelContainer.removeChild(dom.panel);
|
|
4014
4713
|
}
|
|
4015
|
-
|
|
4016
4714
|
return;
|
|
4017
|
-
}
|
|
4018
|
-
// items are fetched.
|
|
4019
|
-
|
|
4715
|
+
}
|
|
4020
4716
|
|
|
4717
|
+
// We add the panel element to the DOM when it's not yet appended and that the
|
|
4718
|
+
// items are fetched.
|
|
4021
4719
|
if (!panelContainer.contains(dom.panel) && state.status !== 'loading') {
|
|
4022
4720
|
panelContainer.appendChild(dom.panel);
|
|
4023
4721
|
}
|
|
4024
|
-
|
|
4025
4722
|
dom.panel.classList.toggle('aa-Panel--stalled', state.status === 'stalled');
|
|
4026
4723
|
var sections = state.collections.filter(function (_ref3) {
|
|
4027
4724
|
var source = _ref3.source,
|
|
4028
|
-
|
|
4725
|
+
items = _ref3.items;
|
|
4029
4726
|
return source.templates.noResults || items.length > 0;
|
|
4030
4727
|
}).map(function (_ref4, sourceIndex) {
|
|
4031
4728
|
var source = _ref4.source,
|
|
4032
|
-
|
|
4729
|
+
items = _ref4.items;
|
|
4033
4730
|
return renderer.createElement("section", {
|
|
4034
4731
|
key: sourceIndex,
|
|
4035
4732
|
className: classNames.source,
|
|
@@ -4118,16 +4815,15 @@
|
|
|
4118
4815
|
}];
|
|
4119
4816
|
|
|
4120
4817
|
var _excluded = ["components"];
|
|
4818
|
+
var instancesCount = 0;
|
|
4121
4819
|
function autocomplete(options) {
|
|
4122
4820
|
var _createEffectWrapper = createEffectWrapper(),
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4821
|
+
runEffect = _createEffectWrapper.runEffect,
|
|
4822
|
+
cleanupEffects = _createEffectWrapper.cleanupEffects,
|
|
4823
|
+
runEffects = _createEffectWrapper.runEffects;
|
|
4127
4824
|
var _createReactiveWrappe = createReactiveWrapper(),
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4825
|
+
reactive = _createReactiveWrappe.reactive,
|
|
4826
|
+
runReactives = _createReactiveWrappe.runReactives;
|
|
4131
4827
|
var hasNoResultsSourceTemplateRef = createRef(false);
|
|
4132
4828
|
var optionsRef = createRef(options);
|
|
4133
4829
|
var onStateChangeRef = createRef(undefined);
|
|
@@ -4141,7 +4837,6 @@
|
|
|
4141
4837
|
return createAutocomplete(_objectSpread2(_objectSpread2({}, props.value.core), {}, {
|
|
4142
4838
|
onStateChange: function onStateChange(params) {
|
|
4143
4839
|
var _onStateChangeRef$cur, _props$value$core$onS, _props$value$core;
|
|
4144
|
-
|
|
4145
4840
|
hasNoResultsSourceTemplateRef.current = params.state.collections.some(function (collection) {
|
|
4146
4841
|
return collection.source.templates.noResults;
|
|
4147
4842
|
});
|
|
@@ -4150,17 +4845,13 @@
|
|
|
4150
4845
|
},
|
|
4151
4846
|
shouldPanelOpen: optionsRef.current.shouldPanelOpen || function (_ref) {
|
|
4152
4847
|
var state = _ref.state;
|
|
4153
|
-
|
|
4154
4848
|
if (isDetached.value) {
|
|
4155
4849
|
return true;
|
|
4156
4850
|
}
|
|
4157
|
-
|
|
4158
4851
|
var hasItems = getItemsCount(state) > 0;
|
|
4159
|
-
|
|
4160
4852
|
if (!props.value.core.openOnFocus && !state.query) {
|
|
4161
4853
|
return hasItems;
|
|
4162
4854
|
}
|
|
4163
|
-
|
|
4164
4855
|
var hasNoResultsTemplate = Boolean(hasNoResultsSourceTemplateRef.current || props.value.renderer.renderNoResults);
|
|
4165
4856
|
return !hasItems && hasNoResultsTemplate || hasItems;
|
|
4166
4857
|
},
|
|
@@ -4216,7 +4907,6 @@
|
|
|
4216
4907
|
translations: props.value.renderer.translations
|
|
4217
4908
|
});
|
|
4218
4909
|
});
|
|
4219
|
-
|
|
4220
4910
|
function setPanelPosition() {
|
|
4221
4911
|
setProperties(dom.value.panel, {
|
|
4222
4912
|
style: isDetached.value ? {} : getPanelPlacementStyle({
|
|
@@ -4227,7 +4917,6 @@
|
|
|
4227
4917
|
})
|
|
4228
4918
|
});
|
|
4229
4919
|
}
|
|
4230
|
-
|
|
4231
4920
|
function scheduleRender(state) {
|
|
4232
4921
|
lastStateRef.current = state;
|
|
4233
4922
|
var renderProps = {
|
|
@@ -4247,7 +4936,6 @@
|
|
|
4247
4936
|
renderSearchBox(renderProps);
|
|
4248
4937
|
renderPanel(render, renderProps);
|
|
4249
4938
|
}
|
|
4250
|
-
|
|
4251
4939
|
runEffect(function () {
|
|
4252
4940
|
var environmentProps = autocomplete.value.getEnvironmentProps({
|
|
4253
4941
|
formElement: dom.value.form,
|
|
@@ -4257,18 +4945,16 @@
|
|
|
4257
4945
|
setProperties(props.value.core.environment, environmentProps);
|
|
4258
4946
|
return function () {
|
|
4259
4947
|
setProperties(props.value.core.environment, Object.keys(environmentProps).reduce(function (acc, key) {
|
|
4260
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty$
|
|
4948
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty$i({}, key, undefined));
|
|
4261
4949
|
}, {}));
|
|
4262
4950
|
};
|
|
4263
4951
|
});
|
|
4264
4952
|
runEffect(function () {
|
|
4265
4953
|
var panelContainerElement = isDetached.value ? props.value.core.environment.document.body : props.value.renderer.panelContainer;
|
|
4266
4954
|
var panelElement = isDetached.value ? dom.value.detachedOverlay : dom.value.panel;
|
|
4267
|
-
|
|
4268
4955
|
if (isDetached.value && lastStateRef.current.isOpen) {
|
|
4269
4956
|
setIsModalOpen(true);
|
|
4270
4957
|
}
|
|
4271
|
-
|
|
4272
4958
|
scheduleRender(lastStateRef.current);
|
|
4273
4959
|
return function () {
|
|
4274
4960
|
if (panelContainerElement.contains(panelElement)) {
|
|
@@ -4288,25 +4974,23 @@
|
|
|
4288
4974
|
var state = _ref2.state;
|
|
4289
4975
|
scheduleRender(state);
|
|
4290
4976
|
}, 0);
|
|
4291
|
-
|
|
4292
4977
|
onStateChangeRef.current = function (_ref3) {
|
|
4293
4978
|
var state = _ref3.state,
|
|
4294
|
-
|
|
4295
|
-
|
|
4979
|
+
prevState = _ref3.prevState;
|
|
4296
4980
|
if (isDetached.value && prevState.isOpen !== state.isOpen) {
|
|
4297
4981
|
setIsModalOpen(state.isOpen);
|
|
4298
|
-
}
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4984
|
+
// The outer DOM might have changed since the last time the panel was
|
|
4299
4985
|
// positioned. The layout might have shifted vertically for instance.
|
|
4300
4986
|
// It's therefore safer to re-calculate the panel position before opening
|
|
4301
4987
|
// it again.
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
4988
|
if (!isDetached.value && state.isOpen && !prevState.isOpen) {
|
|
4305
4989
|
setPanelPosition();
|
|
4306
|
-
}
|
|
4307
|
-
// results come in) so that users don't have to.
|
|
4308
|
-
|
|
4990
|
+
}
|
|
4309
4991
|
|
|
4992
|
+
// We scroll to the top of the panel whenever the query changes (i.e. new
|
|
4993
|
+
// results come in) so that users don't have to.
|
|
4310
4994
|
if (state.query !== prevState.query) {
|
|
4311
4995
|
var scrollablePanels = props.value.core.environment.document.querySelectorAll('.aa-Panel--scrollable');
|
|
4312
4996
|
scrollablePanels.forEach(function (scrollablePanel) {
|
|
@@ -4315,12 +4999,10 @@
|
|
|
4315
4999
|
}
|
|
4316
5000
|
});
|
|
4317
5001
|
}
|
|
4318
|
-
|
|
4319
5002
|
debouncedRender({
|
|
4320
5003
|
state: state
|
|
4321
5004
|
});
|
|
4322
5005
|
};
|
|
4323
|
-
|
|
4324
5006
|
return function () {
|
|
4325
5007
|
onStateChangeRef.current = undefined;
|
|
4326
5008
|
};
|
|
@@ -4329,7 +5011,6 @@
|
|
|
4329
5011
|
var onResize = debounce(function () {
|
|
4330
5012
|
var previousIsDetached = isDetached.value;
|
|
4331
5013
|
isDetached.value = props.value.core.environment.matchMedia(props.value.renderer.detachedMediaQuery).matches;
|
|
4332
|
-
|
|
4333
5014
|
if (previousIsDetached !== isDetached.value) {
|
|
4334
5015
|
update({});
|
|
4335
5016
|
} else {
|
|
@@ -4345,20 +5026,18 @@
|
|
|
4345
5026
|
if (!isDetached.value) {
|
|
4346
5027
|
return function () {};
|
|
4347
5028
|
}
|
|
4348
|
-
|
|
4349
5029
|
function toggleModalClassname(isActive) {
|
|
4350
5030
|
dom.value.detachedContainer.classList.toggle('aa-DetachedContainer--modal', isActive);
|
|
4351
5031
|
}
|
|
4352
|
-
|
|
4353
5032
|
function onChange(event) {
|
|
4354
5033
|
toggleModalClassname(event.matches);
|
|
4355
5034
|
}
|
|
4356
|
-
|
|
4357
5035
|
var isModalDetachedMql = props.value.core.environment.matchMedia(getComputedStyle(props.value.core.environment.document.documentElement).getPropertyValue('--aa-detached-modal-media-query'));
|
|
4358
|
-
toggleModalClassname(isModalDetachedMql.matches);
|
|
5036
|
+
toggleModalClassname(isModalDetachedMql.matches);
|
|
5037
|
+
|
|
5038
|
+
// Prior to Safari 14, `MediaQueryList` isn't based on `EventTarget`,
|
|
4359
5039
|
// so we must use `addListener` and `removeListener` to observe media query lists.
|
|
4360
5040
|
// See https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
|
|
4361
|
-
|
|
4362
5041
|
var hasModernEventListener = Boolean(isModalDetachedMql.addEventListener);
|
|
4363
5042
|
hasModernEventListener ? isModalDetachedMql.addEventListener('change', onChange) : isModalDetachedMql.addListener(onChange);
|
|
4364
5043
|
return function () {
|
|
@@ -4369,19 +5048,16 @@
|
|
|
4369
5048
|
requestAnimationFrame(setPanelPosition);
|
|
4370
5049
|
return function () {};
|
|
4371
5050
|
});
|
|
4372
|
-
|
|
4373
5051
|
function destroy() {
|
|
5052
|
+
instancesCount--;
|
|
4374
5053
|
cleanupEffects();
|
|
4375
5054
|
}
|
|
4376
|
-
|
|
4377
5055
|
function update() {
|
|
4378
5056
|
var updatedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
4379
5057
|
cleanupEffects();
|
|
4380
|
-
|
|
4381
5058
|
var _props$value$renderer = props.value.renderer,
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
5059
|
+
components = _props$value$renderer.components,
|
|
5060
|
+
rendererProps = _objectWithoutProperties$5(_props$value$renderer, _excluded);
|
|
4385
5061
|
optionsRef.current = mergeDeep(rendererProps, props.value.core, {
|
|
4386
5062
|
// We need to filter out default components so they can be replaced with
|
|
4387
5063
|
// a new `renderer`, without getting rid of user components.
|
|
@@ -4400,15 +5076,12 @@
|
|
|
4400
5076
|
scheduleRender(lastStateRef.current);
|
|
4401
5077
|
});
|
|
4402
5078
|
}
|
|
4403
|
-
|
|
4404
5079
|
function setIsModalOpen(value) {
|
|
4405
5080
|
requestAnimationFrame(function () {
|
|
4406
5081
|
var prevValue = props.value.core.environment.document.body.contains(dom.value.detachedOverlay);
|
|
4407
|
-
|
|
4408
5082
|
if (value === prevValue) {
|
|
4409
5083
|
return;
|
|
4410
5084
|
}
|
|
4411
|
-
|
|
4412
5085
|
if (value) {
|
|
4413
5086
|
props.value.core.environment.document.body.appendChild(dom.value.detachedOverlay);
|
|
4414
5087
|
props.value.core.environment.document.body.classList.add('aa-Detached');
|
|
@@ -4416,12 +5089,11 @@
|
|
|
4416
5089
|
} else {
|
|
4417
5090
|
props.value.core.environment.document.body.removeChild(dom.value.detachedOverlay);
|
|
4418
5091
|
props.value.core.environment.document.body.classList.remove('aa-Detached');
|
|
4419
|
-
autocomplete.value.setQuery('');
|
|
4420
|
-
autocomplete.value.refresh();
|
|
4421
5092
|
}
|
|
4422
5093
|
});
|
|
4423
5094
|
}
|
|
4424
|
-
|
|
5095
|
+
"development" !== 'production' ? warn(instancesCount === 0, "Autocomplete doesn't support multiple instances running at the same time. Make sure to destroy the previous instance before creating a new one.\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-destroy") : void 0;
|
|
5096
|
+
instancesCount++;
|
|
4425
5097
|
return _objectSpread2(_objectSpread2({}, autocompleteScopeApi), {}, {
|
|
4426
5098
|
update: update,
|
|
4427
5099
|
destroy: destroy
|
|
@@ -4437,7 +5109,6 @@
|
|
|
4437
5109
|
/**
|
|
4438
5110
|
* Retrieves Algolia facet hits from multiple indices.
|
|
4439
5111
|
*/
|
|
4440
|
-
|
|
4441
5112
|
function getAlgoliaFacets(requestParams) {
|
|
4442
5113
|
var requester = createAlgoliaRequester({
|
|
4443
5114
|
transformResponse: function transformResponse(response) {
|
|
@@ -4457,7 +5128,6 @@
|
|
|
4457
5128
|
/**
|
|
4458
5129
|
* Retrieves Algolia results from multiple indices.
|
|
4459
5130
|
*/
|
|
4460
|
-
|
|
4461
5131
|
var getAlgoliaResults = createAlgoliaRequester({
|
|
4462
5132
|
transformResponse: function transformResponse(response) {
|
|
4463
5133
|
return response.hits;
|