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