react-instantsearch 6.38.1 → 6.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,648 @@
1
+ /*! React InstantSearch UNRELEASED | © Algolia, inc. | https://github.com/algolia/instantsearch.js */
2
+ (function (global, factory) {
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
+ typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
5
+ (global = global || self, factory((global.ReactInstantSearch = global.ReactInstantSearch || {}, global.ReactInstantSearch.Core = {}), global.React));
6
+ }(this, (function (exports, React) { 'use strict';
7
+
8
+ var React__default = 'default' in React ? React['default'] : React;
9
+
10
+ /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
11
+
12
+ var hasElementType = typeof Element !== 'undefined';
13
+ var hasMap = typeof Map === 'function';
14
+ var hasSet = typeof Set === 'function';
15
+ var hasArrayBuffer = typeof ArrayBuffer === 'function';
16
+
17
+ // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
18
+
19
+ function equal(a, b) {
20
+ // START: fast-deep-equal es6/index.js 3.1.1
21
+ if (a === b) return true;
22
+
23
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
24
+ if (a.constructor !== b.constructor) return false;
25
+
26
+ var length, i, keys;
27
+ if (Array.isArray(a)) {
28
+ length = a.length;
29
+ if (length != b.length) return false;
30
+ for (i = length; i-- !== 0;)
31
+ if (!equal(a[i], b[i])) return false;
32
+ return true;
33
+ }
34
+
35
+ // START: Modifications:
36
+ // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
37
+ // to co-exist with es5.
38
+ // 2. Replace `for of` with es5 compliant iteration using `for`.
39
+ // Basically, take:
40
+ //
41
+ // ```js
42
+ // for (i of a.entries())
43
+ // if (!b.has(i[0])) return false;
44
+ // ```
45
+ //
46
+ // ... and convert to:
47
+ //
48
+ // ```js
49
+ // it = a.entries();
50
+ // while (!(i = it.next()).done)
51
+ // if (!b.has(i.value[0])) return false;
52
+ // ```
53
+ //
54
+ // **Note**: `i` access switches to `i.value`.
55
+ var it;
56
+ if (hasMap && (a instanceof Map) && (b instanceof Map)) {
57
+ if (a.size !== b.size) return false;
58
+ it = a.entries();
59
+ while (!(i = it.next()).done)
60
+ if (!b.has(i.value[0])) return false;
61
+ it = a.entries();
62
+ while (!(i = it.next()).done)
63
+ if (!equal(i.value[1], b.get(i.value[0]))) return false;
64
+ return true;
65
+ }
66
+
67
+ if (hasSet && (a instanceof Set) && (b instanceof Set)) {
68
+ if (a.size !== b.size) return false;
69
+ it = a.entries();
70
+ while (!(i = it.next()).done)
71
+ if (!b.has(i.value[0])) return false;
72
+ return true;
73
+ }
74
+ // END: Modifications
75
+
76
+ if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
77
+ length = a.length;
78
+ if (length != b.length) return false;
79
+ for (i = length; i-- !== 0;)
80
+ if (a[i] !== b[i]) return false;
81
+ return true;
82
+ }
83
+
84
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
85
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
86
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
87
+
88
+ keys = Object.keys(a);
89
+ length = keys.length;
90
+ if (length !== Object.keys(b).length) return false;
91
+
92
+ for (i = length; i-- !== 0;)
93
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
94
+ // END: fast-deep-equal
95
+
96
+ // START: react-fast-compare
97
+ // custom handling for DOM elements
98
+ if (hasElementType && a instanceof Element) return false;
99
+
100
+ // custom handling for React
101
+ for (i = length; i-- !== 0;) {
102
+ if (keys[i] === '_owner' && a.$$typeof) {
103
+ // React-specific: avoid traversing React elements' _owner.
104
+ // _owner contains circular references
105
+ // and is not needed when comparing the actual elements (and not their owners)
106
+ // .$$typeof and ._store on just reasonable markers of a react element
107
+ continue;
108
+ }
109
+
110
+ // all other properties should be traversed as usual
111
+ if (!equal(a[keys[i]], b[keys[i]])) return false;
112
+ }
113
+ // END: react-fast-compare
114
+
115
+ // START: fast-deep-equal
116
+ return true;
117
+ }
118
+
119
+ return a !== a && b !== b;
120
+ }
121
+ // end fast-deep-equal
122
+
123
+ var reactFastCompare = function isEqual(a, b) {
124
+ try {
125
+ return equal(a, b);
126
+ } catch (error) {
127
+ if (((error.message || '').match(/stack|recursion/i))) {
128
+ // warn on circular references, don't crash
129
+ // browsers give this different errors name and messages:
130
+ // chrome/safari: "RangeError", "Maximum call stack size exceeded"
131
+ // firefox: "InternalError", too much recursion"
132
+ // edge: "Error", "Out of stack space"
133
+ console.warn('react-fast-compare cannot handle circular refs');
134
+ return false;
135
+ }
136
+ // some other error. we should definitely know about these
137
+ throw error;
138
+ }
139
+ };
140
+
141
+ function _typeof(obj) {
142
+ "@babel/helpers - typeof";
143
+
144
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
145
+ return typeof obj;
146
+ } : function (obj) {
147
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
148
+ }, _typeof(obj);
149
+ }
150
+ // From https://github.com/reactjs/react-redux/blob/master/src/utils/shallowEqual.js
151
+ var shallowEqual = function shallowEqual(objA, objB) {
152
+ if (objA === objB) {
153
+ return true;
154
+ }
155
+ var keysA = Object.keys(objA);
156
+ var keysB = Object.keys(objB);
157
+ if (keysA.length !== keysB.length) {
158
+ return false;
159
+ }
160
+
161
+ // Test for A's keys different from B.
162
+ var hasOwn = Object.prototype.hasOwnProperty;
163
+ for (var i = 0; i < keysA.length; i++) {
164
+ if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
165
+ return false;
166
+ }
167
+ }
168
+ return true;
169
+ };
170
+ var getDisplayName = function getDisplayName(Component) {
171
+ return Component.displayName || Component.name || 'UnknownComponent';
172
+ };
173
+ var isPlainObject = function isPlainObject(value) {
174
+ return _typeof(value) === 'object' && value !== null && !Array.isArray(value);
175
+ };
176
+ var removeEmptyKey = function removeEmptyKey(obj) {
177
+ Object.keys(obj).forEach(function (key) {
178
+ var value = obj[key];
179
+ if (!isPlainObject(value)) {
180
+ return;
181
+ }
182
+ if (!objectHasKeys(value)) {
183
+ delete obj[key];
184
+ } else {
185
+ removeEmptyKey(value);
186
+ }
187
+ });
188
+ return obj;
189
+ };
190
+ function objectHasKeys(object) {
191
+ return object && Object.keys(object).length > 0;
192
+ }
193
+
194
+ var instantSearchContext = /*#__PURE__*/React.createContext({
195
+ onInternalStateUpdate: function onInternalStateUpdate() {
196
+ return undefined;
197
+ },
198
+ createHrefForState: function createHrefForState() {
199
+ return '#';
200
+ },
201
+ onSearchForFacetValues: function onSearchForFacetValues() {
202
+ return undefined;
203
+ },
204
+ onSearchStateChange: function onSearchStateChange() {
205
+ return undefined;
206
+ },
207
+ onSearchParameters: function onSearchParameters() {
208
+ return undefined;
209
+ },
210
+ store: {},
211
+ widgetsManager: {},
212
+ mainTargetedIndex: ''
213
+ });
214
+ var InstantSearchConsumer = instantSearchContext.Consumer,
215
+ InstantSearchProvider = instantSearchContext.Provider;
216
+ var _createContext = /*#__PURE__*/React.createContext(undefined),
217
+ IndexConsumer = _createContext.Consumer,
218
+ IndexProvider = _createContext.Provider;
219
+
220
+ var _excluded = ["contextValue"];
221
+ function _typeof$1(obj) {
222
+ "@babel/helpers - typeof";
223
+
224
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
225
+ return typeof obj;
226
+ } : function (obj) {
227
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
228
+ }, _typeof$1(obj);
229
+ }
230
+ function _extends() {
231
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
232
+ for (var i = 1; i < arguments.length; i++) {
233
+ var source = arguments[i];
234
+ for (var key in source) {
235
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
236
+ target[key] = source[key];
237
+ }
238
+ }
239
+ }
240
+ return target;
241
+ };
242
+ return _extends.apply(this, arguments);
243
+ }
244
+ function _objectWithoutProperties(source, excluded) {
245
+ if (source == null) return {};
246
+ var target = _objectWithoutPropertiesLoose(source, excluded);
247
+ var key, i;
248
+ if (Object.getOwnPropertySymbols) {
249
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
250
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
251
+ key = sourceSymbolKeys[i];
252
+ if (excluded.indexOf(key) >= 0) continue;
253
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
254
+ target[key] = source[key];
255
+ }
256
+ }
257
+ return target;
258
+ }
259
+ function _objectWithoutPropertiesLoose(source, excluded) {
260
+ if (source == null) return {};
261
+ var target = {};
262
+ var sourceKeys = Object.keys(source);
263
+ var key, i;
264
+ for (i = 0; i < sourceKeys.length; i++) {
265
+ key = sourceKeys[i];
266
+ if (excluded.indexOf(key) >= 0) continue;
267
+ target[key] = source[key];
268
+ }
269
+ return target;
270
+ }
271
+ function ownKeys(object, enumerableOnly) {
272
+ var keys = Object.keys(object);
273
+ if (Object.getOwnPropertySymbols) {
274
+ var symbols = Object.getOwnPropertySymbols(object);
275
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
276
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
277
+ })), keys.push.apply(keys, symbols);
278
+ }
279
+ return keys;
280
+ }
281
+ function _objectSpread(target) {
282
+ for (var i = 1; i < arguments.length; i++) {
283
+ var source = null != arguments[i] ? arguments[i] : {};
284
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
285
+ _defineProperty(target, key, source[key]);
286
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
287
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
288
+ });
289
+ }
290
+ return target;
291
+ }
292
+ function _classCallCheck(instance, Constructor) {
293
+ if (!(instance instanceof Constructor)) {
294
+ throw new TypeError("Cannot call a class as a function");
295
+ }
296
+ }
297
+ function _defineProperties(target, props) {
298
+ for (var i = 0; i < props.length; i++) {
299
+ var descriptor = props[i];
300
+ descriptor.enumerable = descriptor.enumerable || false;
301
+ descriptor.configurable = true;
302
+ if ("value" in descriptor) descriptor.writable = true;
303
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
304
+ }
305
+ }
306
+ function _createClass(Constructor, protoProps, staticProps) {
307
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
308
+ if (staticProps) _defineProperties(Constructor, staticProps);
309
+ Object.defineProperty(Constructor, "prototype", {
310
+ writable: false
311
+ });
312
+ return Constructor;
313
+ }
314
+ function _inherits(subClass, superClass) {
315
+ if (typeof superClass !== "function" && superClass !== null) {
316
+ throw new TypeError("Super expression must either be null or a function");
317
+ }
318
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
319
+ constructor: {
320
+ value: subClass,
321
+ writable: true,
322
+ configurable: true
323
+ }
324
+ });
325
+ Object.defineProperty(subClass, "prototype", {
326
+ writable: false
327
+ });
328
+ if (superClass) _setPrototypeOf(subClass, superClass);
329
+ }
330
+ function _setPrototypeOf(o, p) {
331
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
332
+ o.__proto__ = p;
333
+ return o;
334
+ };
335
+ return _setPrototypeOf(o, p);
336
+ }
337
+ function _createSuper(Derived) {
338
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
339
+ return function _createSuperInternal() {
340
+ var Super = _getPrototypeOf(Derived),
341
+ result;
342
+ if (hasNativeReflectConstruct) {
343
+ var NewTarget = _getPrototypeOf(this).constructor;
344
+ result = Reflect.construct(Super, arguments, NewTarget);
345
+ } else {
346
+ result = Super.apply(this, arguments);
347
+ }
348
+ return _possibleConstructorReturn(this, result);
349
+ };
350
+ }
351
+ function _possibleConstructorReturn(self, call) {
352
+ if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
353
+ return call;
354
+ } else if (call !== void 0) {
355
+ throw new TypeError("Derived constructors may only return object or undefined");
356
+ }
357
+ return _assertThisInitialized(self);
358
+ }
359
+ function _assertThisInitialized(self) {
360
+ if (self === void 0) {
361
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
362
+ }
363
+ return self;
364
+ }
365
+ function _isNativeReflectConstruct() {
366
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
367
+ if (Reflect.construct.sham) return false;
368
+ if (typeof Proxy === "function") return true;
369
+ try {
370
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
371
+ return true;
372
+ } catch (e) {
373
+ return false;
374
+ }
375
+ }
376
+ function _getPrototypeOf(o) {
377
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
378
+ return o.__proto__ || Object.getPrototypeOf(o);
379
+ };
380
+ return _getPrototypeOf(o);
381
+ }
382
+ function _defineProperty(obj, key, value) {
383
+ key = _toPropertyKey(key);
384
+ if (key in obj) {
385
+ Object.defineProperty(obj, key, {
386
+ value: value,
387
+ enumerable: true,
388
+ configurable: true,
389
+ writable: true
390
+ });
391
+ } else {
392
+ obj[key] = value;
393
+ }
394
+ return obj;
395
+ }
396
+ function _toPropertyKey(arg) {
397
+ var key = _toPrimitive(arg, "string");
398
+ return _typeof$1(key) === "symbol" ? key : String(key);
399
+ }
400
+ function _toPrimitive(input, hint) {
401
+ if (_typeof$1(input) !== "object" || input === null) return input;
402
+ var prim = input[Symbol.toPrimitive];
403
+ if (prim !== undefined) {
404
+ var res = prim.call(input, hint || "default");
405
+ if (_typeof$1(res) !== "object") return res;
406
+ throw new TypeError("@@toPrimitive must return a primitive value.");
407
+ }
408
+ return (hint === "string" ? String : Number)(input);
409
+ }
410
+ /**
411
+ * Connectors are the HOC used to transform React components
412
+ * into InstantSearch widgets.
413
+ * In order to simplify the construction of such connectors
414
+ * `createConnector` takes a description and transform it into
415
+ * a connector.
416
+ * @param {ConnectorDescription} connectorDesc the description of the connector
417
+ * @return {Connector} a function that wraps a component into
418
+ * an instantsearch connected one.
419
+ */
420
+ function createConnectorWithoutContext(connectorDesc) {
421
+ if (!connectorDesc.displayName) {
422
+ throw new Error('`createConnector` requires you to provide a `displayName` property.');
423
+ }
424
+ var isWidget = typeof connectorDesc.getSearchParameters === 'function' || typeof connectorDesc.getMetadata === 'function' || typeof connectorDesc.transitionState === 'function';
425
+ return function (Composed) {
426
+ var additionalWidgetProperties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
427
+ var Connector = /*#__PURE__*/function (_Component) {
428
+ _inherits(Connector, _Component);
429
+ var _super = _createSuper(Connector);
430
+ function Connector(props) {
431
+ var _this;
432
+ _classCallCheck(this, Connector);
433
+ _this = _super.call(this, props);
434
+ _defineProperty(_assertThisInitialized(_this), "unsubscribe", void 0);
435
+ _defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
436
+ _defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
437
+ _defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
438
+ _defineProperty(_assertThisInitialized(_this), "state", {
439
+ providedProps: _this.getProvidedProps(_this.props)
440
+ });
441
+ _defineProperty(_assertThisInitialized(_this), "refine", function () {
442
+ var _ref;
443
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
444
+ args[_key] = arguments[_key];
445
+ }
446
+ _this.props.contextValue.onInternalStateUpdate(
447
+ // refine will always be defined here because the prop is only given conditionally
448
+ (_ref = connectorDesc.refine).call.apply(_ref, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
449
+ });
450
+ _defineProperty(_assertThisInitialized(_this), "createURL", function () {
451
+ var _ref2;
452
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
453
+ args[_key2] = arguments[_key2];
454
+ }
455
+ return _this.props.contextValue.createHrefForState(
456
+ // refine will always be defined here because the prop is only given conditionally
457
+ (_ref2 = connectorDesc.refine).call.apply(_ref2, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
458
+ });
459
+ _defineProperty(_assertThisInitialized(_this), "searchForFacetValues", function () {
460
+ var _ref3;
461
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
462
+ args[_key3] = arguments[_key3];
463
+ }
464
+ _this.props.contextValue.onSearchForFacetValues(
465
+ // searchForFacetValues will always be defined here because the prop is only given conditionally
466
+ (_ref3 = connectorDesc.searchForFacetValues).call.apply(_ref3, [_assertThisInitialized(_this), _this.props, _this.props.contextValue.store.getState().widgets].concat(args)));
467
+ });
468
+ if (connectorDesc.getSearchParameters) {
469
+ _this.props.contextValue.onSearchParameters(connectorDesc.getSearchParameters.bind(_assertThisInitialized(_this)), {
470
+ ais: _this.props.contextValue,
471
+ multiIndexContext: _this.props.indexContextValue
472
+ }, _this.props, connectorDesc.getMetadata && connectorDesc.getMetadata.bind(_assertThisInitialized(_this)), connectorDesc.displayName);
473
+ }
474
+ return _this;
475
+ }
476
+ _createClass(Connector, [{
477
+ key: "componentDidMount",
478
+ value: function componentDidMount() {
479
+ var _this2 = this;
480
+ if (this.cleanupTimerRef) {
481
+ clearTimeout(this.cleanupTimerRef);
482
+ this.cleanupTimerRef = null;
483
+ }
484
+ this.unsubscribe = this.props.contextValue.store.subscribe(function () {
485
+ if (!_this2.isUnmounting) {
486
+ _this2.setState({
487
+ providedProps: _this2.getProvidedProps(_this2.props)
488
+ });
489
+ }
490
+ });
491
+ if (isWidget) {
492
+ this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
493
+ }
494
+ }
495
+ }, {
496
+ key: "shouldComponentUpdate",
497
+ value: function shouldComponentUpdate(nextProps, nextState) {
498
+ if (typeof connectorDesc.shouldComponentUpdate === 'function') {
499
+ return connectorDesc.shouldComponentUpdate.call(this, this.props, nextProps, this.state, nextState);
500
+ }
501
+ var propsEqual = shallowEqual(this.props, nextProps);
502
+ if (this.state.providedProps === null || nextState.providedProps === null) {
503
+ if (this.state.providedProps === nextState.providedProps) {
504
+ return !propsEqual;
505
+ }
506
+ return true;
507
+ }
508
+ return !propsEqual || !shallowEqual(this.state.providedProps, nextState.providedProps);
509
+ }
510
+ }, {
511
+ key: "componentDidUpdate",
512
+ value: function componentDidUpdate(prevProps) {
513
+ if (!reactFastCompare(prevProps, this.props)) {
514
+ this.setState({
515
+ providedProps: this.getProvidedProps(this.props)
516
+ });
517
+ if (isWidget) {
518
+ this.props.contextValue.widgetsManager.update();
519
+ if (typeof connectorDesc.transitionState === 'function') {
520
+ this.props.contextValue.onSearchStateChange(connectorDesc.transitionState.call(this, this.props, this.props.contextValue.store.getState().widgets, this.props.contextValue.store.getState().widgets));
521
+ }
522
+ }
523
+ }
524
+ }
525
+ }, {
526
+ key: "componentWillUnmount",
527
+ value: function componentWillUnmount() {
528
+ var _this3 = this;
529
+ this.cleanupTimerRef = setTimeout(function () {
530
+ _this3.isUnmounting = true;
531
+ if (_this3.unsubscribe) {
532
+ _this3.unsubscribe();
533
+ }
534
+ if (_this3.unregisterWidget) {
535
+ _this3.unregisterWidget();
536
+ if (typeof connectorDesc.cleanUp === 'function') {
537
+ var nextState = connectorDesc.cleanUp.call(_this3, _this3.props, _this3.props.contextValue.store.getState().widgets);
538
+ _this3.props.contextValue.store.setState(_objectSpread(_objectSpread({}, _this3.props.contextValue.store.getState()), {}, {
539
+ widgets: nextState
540
+ }));
541
+ _this3.props.contextValue.onSearchStateChange(removeEmptyKey(nextState));
542
+ }
543
+ }
544
+ });
545
+ }
546
+ }, {
547
+ key: "getProvidedProps",
548
+ value: function getProvidedProps(props) {
549
+ var _this$props$contextVa = this.props.contextValue.store.getState(),
550
+ widgets = _this$props$contextVa.widgets,
551
+ results = _this$props$contextVa.results,
552
+ resultsFacetValues = _this$props$contextVa.resultsFacetValues,
553
+ searching = _this$props$contextVa.searching,
554
+ searchingForFacetValues = _this$props$contextVa.searchingForFacetValues,
555
+ isSearchStalled = _this$props$contextVa.isSearchStalled,
556
+ metadata = _this$props$contextVa.metadata,
557
+ error = _this$props$contextVa.error;
558
+ var searchResults = {
559
+ results: results,
560
+ searching: searching,
561
+ searchingForFacetValues: searchingForFacetValues,
562
+ isSearchStalled: isSearchStalled,
563
+ error: error
564
+ };
565
+ return connectorDesc.getProvidedProps.call(this, props, widgets, searchResults, metadata,
566
+ // @MAJOR: move this attribute on the `searchResults` it doesn't
567
+ // makes sense to have it into a separate argument. The search
568
+ // flags are on the object why not the results?
569
+ resultsFacetValues);
570
+ }
571
+ }, {
572
+ key: "getSearchParameters",
573
+ value: function getSearchParameters(searchParameters) {
574
+ if (typeof connectorDesc.getSearchParameters === 'function') {
575
+ return connectorDesc.getSearchParameters.call(this, searchParameters, this.props, this.props.contextValue.store.getState().widgets);
576
+ }
577
+ return null;
578
+ }
579
+ }, {
580
+ key: "getMetadata",
581
+ value: function getMetadata(nextWidgetsState) {
582
+ if (typeof connectorDesc.getMetadata === 'function') {
583
+ return connectorDesc.getMetadata.call(this, this.props, nextWidgetsState);
584
+ }
585
+ return {};
586
+ }
587
+ }, {
588
+ key: "transitionState",
589
+ value: function transitionState(prevWidgetsState, nextWidgetsState) {
590
+ if (typeof connectorDesc.transitionState === 'function') {
591
+ return connectorDesc.transitionState.call(this, this.props, prevWidgetsState, nextWidgetsState);
592
+ }
593
+ return nextWidgetsState;
594
+ }
595
+ }, {
596
+ key: "render",
597
+ value: function render() {
598
+ var _this$props = this.props,
599
+ contextValue = _this$props.contextValue,
600
+ props = _objectWithoutProperties(_this$props, _excluded);
601
+ var providedProps = this.state.providedProps;
602
+ if (providedProps === null) {
603
+ return null;
604
+ }
605
+ var refineProps = typeof connectorDesc.refine === 'function' ? {
606
+ refine: this.refine,
607
+ createURL: this.createURL
608
+ } : {};
609
+ var searchForFacetValuesProps = typeof connectorDesc.searchForFacetValues === 'function' ? {
610
+ searchForItems: this.searchForFacetValues
611
+ } : {};
612
+ return /*#__PURE__*/React__default.createElement(Composed, _extends({}, props, providedProps, refineProps, searchForFacetValuesProps));
613
+ }
614
+ }]);
615
+ return Connector;
616
+ }(React.Component);
617
+ _defineProperty(Connector, "displayName", "".concat(connectorDesc.displayName, "(").concat(getDisplayName(Composed), ")"));
618
+ _defineProperty(Connector, "$$type", connectorDesc.$$type);
619
+ _defineProperty(Connector, "$$widgetType", additionalWidgetProperties.$$widgetType);
620
+ _defineProperty(Connector, "propTypes", connectorDesc.propTypes);
621
+ _defineProperty(Connector, "defaultProps", connectorDesc.defaultProps);
622
+ _defineProperty(Connector, "_connectorDesc", connectorDesc);
623
+ return Connector;
624
+ };
625
+ }
626
+ var createConnectorWithContext = function createConnectorWithContext(connectorDesc) {
627
+ return function (Composed, additionalWidgetProperties) {
628
+ var Connector = createConnectorWithoutContext(connectorDesc)(Composed, additionalWidgetProperties);
629
+ var ConnectorWrapper = function ConnectorWrapper(props) {
630
+ return /*#__PURE__*/React__default.createElement(InstantSearchConsumer, null, function (contextValue) {
631
+ return /*#__PURE__*/React__default.createElement(IndexConsumer, null, function (indexContextValue) {
632
+ return /*#__PURE__*/React__default.createElement(Connector, _extends({
633
+ contextValue: contextValue,
634
+ indexContextValue: indexContextValue
635
+ }, props));
636
+ });
637
+ });
638
+ };
639
+ return ConnectorWrapper;
640
+ };
641
+ };
642
+
643
+ exports.createConnector = createConnectorWithContext;
644
+
645
+ Object.defineProperty(exports, '__esModule', { value: true });
646
+
647
+ })));
648
+ //# sourceMappingURL=Core.js.map