@appbaseio/reactivesearch-vue 1.33.0 → 1.33.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.
Files changed (91) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +1916 -6072
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +3 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-0673191e.js → Button-841fd06d.js} +1 -7
  6. package/dist/cjs/{CancelSvg-9f258f4f.js → CancelSvg-220a7cc3.js} +24 -58
  7. package/dist/cjs/{Card-642547a8.js → Card-240f283d.js} +2 -2
  8. package/dist/cjs/{ComponentWrapper-981ab977.js → ComponentWrapper-9318cece.js} +21 -41
  9. package/dist/cjs/{Container-daf30918.js → Container-e699ea95.js} +1 -1
  10. package/dist/cjs/{DataSearch-708b183d.js → DataSearch-99a6a2e8.js} +121 -293
  11. package/dist/cjs/DataSearch.js +11 -11
  12. package/dist/cjs/{DropDown-c479bbb0.js → DropDown-8984b544.js} +27 -48
  13. package/dist/cjs/DynamicRangeSlider.js +44 -93
  14. package/dist/cjs/{Flex-aa517a13.js → Flex-ddd7cb6b.js} +1 -3
  15. package/dist/cjs/{FormControlList-c195a592.js → FormControlList-bbb5cd24.js} +1 -3
  16. package/dist/cjs/{Input-e6603a7e.js → Input-ead4cd84.js} +14 -16
  17. package/dist/cjs/{ListItem-8c9e0d68.js → ListItem-5088bd6a.js} +2 -3
  18. package/dist/cjs/MultiDropdownList.js +41 -102
  19. package/dist/cjs/MultiList.js +35 -98
  20. package/dist/cjs/MultiRange.js +20 -52
  21. package/dist/cjs/{Pagination-3d73e1b3.js → Pagination-07f4dbad.js} +10 -30
  22. package/dist/cjs/{PreferencesConsumer-7be03476.js → PreferencesConsumer-5d67b486.js} +13 -16
  23. package/dist/cjs/RangeInput.js +36 -52
  24. package/dist/cjs/RangeSlider.js +24 -48
  25. package/dist/cjs/ReactiveBase.js +34 -79
  26. package/dist/cjs/{ReactiveComponent-5ff98cce.js → ReactiveComponent-805201c6.js} +118 -301
  27. package/dist/cjs/ReactiveComponent.js +20 -20
  28. package/dist/cjs/ReactiveGoogleMap.js +167 -353
  29. package/dist/cjs/ReactiveList.js +88 -176
  30. package/dist/cjs/ResultCard.js +10 -18
  31. package/dist/cjs/ResultList.js +13 -24
  32. package/dist/cjs/SelectedFilters.js +16 -34
  33. package/dist/cjs/SingleDropdownList.js +35 -75
  34. package/dist/cjs/SingleList.js +29 -75
  35. package/dist/cjs/SingleRange.js +17 -40
  36. package/dist/cjs/StateProvider.js +6 -26
  37. package/dist/cjs/{Title-1de7d0f4.js → Title-16042ea0.js} +1 -1
  38. package/dist/cjs/ToggleButton.js +20 -58
  39. package/dist/cjs/{_rollupPluginBabelHelpers-c705cbe6.js → _rollupPluginBabelHelpers-f8b843f8.js} +0 -15
  40. package/dist/cjs/{index-08f8dfa3.js → index-30126fd0.js} +39 -75
  41. package/dist/cjs/index.js +20 -21
  42. package/dist/cjs/initReactivesearch.js +49 -120
  43. package/dist/cjs/install.js +20 -20
  44. package/dist/cjs/{ssr-3027b848.js → ssr-f2fc1bf6.js} +1 -4
  45. package/dist/cjs/{utils-d6a52588.js → utils-83fd01e9.js} +7 -16
  46. package/dist/cjs/version.js +1 -1
  47. package/dist/cjs/{vueTypes-727b7c63.js → vueTypes-7cfc2f98.js} +6 -11
  48. package/dist/es/{Button-35aa984e.js → Button-153cd885.js} +1 -7
  49. package/dist/es/{CancelSvg-4cfae5fd.js → CancelSvg-e40552a5.js} +24 -58
  50. package/dist/es/{Card-450683f1.js → Card-19ad6d90.js} +2 -2
  51. package/dist/es/{ComponentWrapper-d5e814a4.js → ComponentWrapper-240450cc.js} +21 -41
  52. package/dist/es/{Container-ba826e96.js → Container-d00219f7.js} +1 -1
  53. package/dist/es/{DataSearch-5376d39a.js → DataSearch-20f0d8f1.js} +121 -293
  54. package/dist/es/DataSearch.js +11 -11
  55. package/dist/es/{DropDown-05a644a5.js → DropDown-28ddce07.js} +27 -48
  56. package/dist/es/DynamicRangeSlider.js +44 -93
  57. package/dist/es/{Flex-1f0795c3.js → Flex-7c177a10.js} +1 -3
  58. package/dist/es/{FormControlList-c22d64f6.js → FormControlList-99797d0a.js} +1 -3
  59. package/dist/es/{Input-7a2a9fac.js → Input-c09c0b56.js} +14 -16
  60. package/dist/es/{ListItem-cad14c5e.js → ListItem-07888a65.js} +2 -3
  61. package/dist/es/MultiDropdownList.js +41 -102
  62. package/dist/es/MultiList.js +35 -98
  63. package/dist/es/MultiRange.js +20 -52
  64. package/dist/es/{Pagination-af9de08f.js → Pagination-28e56c5c.js} +10 -30
  65. package/dist/es/{PreferencesConsumer-c30605fe.js → PreferencesConsumer-bc097ebb.js} +13 -16
  66. package/dist/es/RangeInput.js +36 -52
  67. package/dist/es/RangeSlider.js +24 -48
  68. package/dist/es/ReactiveBase.js +34 -79
  69. package/dist/es/{ReactiveComponent-ee01562d.js → ReactiveComponent-dd85aa9c.js} +118 -301
  70. package/dist/es/ReactiveComponent.js +20 -20
  71. package/dist/es/ReactiveGoogleMap.js +167 -353
  72. package/dist/es/ReactiveList.js +88 -176
  73. package/dist/es/ResultCard.js +10 -18
  74. package/dist/es/ResultList.js +13 -24
  75. package/dist/es/SelectedFilters.js +16 -34
  76. package/dist/es/SingleDropdownList.js +35 -75
  77. package/dist/es/SingleList.js +29 -75
  78. package/dist/es/SingleRange.js +17 -40
  79. package/dist/es/StateProvider.js +6 -26
  80. package/dist/es/{Title-3342664a.js → Title-863dfa42.js} +1 -1
  81. package/dist/es/ToggleButton.js +20 -58
  82. package/dist/es/{_rollupPluginBabelHelpers-76660dab.js → _rollupPluginBabelHelpers-ded08042.js} +0 -15
  83. package/dist/es/{index-99c5f9c9.js → index-0444a498.js} +39 -75
  84. package/dist/es/index.js +20 -21
  85. package/dist/es/initReactivesearch.js +49 -120
  86. package/dist/es/install.js +20 -20
  87. package/dist/es/{ssr-b2c0b401.js → ssr-03607d84.js} +1 -4
  88. package/dist/es/{utils-9e68acee.js → utils-9e5a16a1.js} +7 -16
  89. package/dist/es/version.js +1 -1
  90. package/dist/es/{vueTypes-b8146772.js → vueTypes-8986b709.js} +6 -11
  91. package/package.json +1 -1
@@ -7,26 +7,26 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var configureStore = require('@appbaseio/reactivecore');
8
8
  var configureStore__default = _interopDefault(configureStore);
9
9
  var constants = require('@appbaseio/reactivecore/lib/utils/constants');
10
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-c705cbe6.js');
10
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
11
11
  var VueTypes = _interopDefault(require('vue-types'));
12
12
  var helper = require('@appbaseio/reactivecore/lib/utils/helper');
13
13
  var emotion = require('emotion');
14
14
  var styled = require('@appbaseio/vue-emotion');
15
15
  var styled__default = _interopDefault(styled);
16
16
  require('polished');
17
- require('./Button-0673191e.js');
18
- var vueTypes = require('./vueTypes-727b7c63.js');
19
- var Pagination = require('./Pagination-3d73e1b3.js');
17
+ require('./Button-841fd06d.js');
18
+ var vueTypes = require('./vueTypes-7cfc2f98.js');
19
+ var Pagination = require('./Pagination-07f4dbad.js');
20
20
  require('@appbaseio/reactivecore/lib/utils/transform');
21
21
  require('redux');
22
- var index = require('./index-08f8dfa3.js');
23
- var ComponentWrapper = require('./ComponentWrapper-981ab977.js');
24
- var PreferencesConsumer = require('./PreferencesConsumer-7be03476.js');
22
+ var index = require('./index-30126fd0.js');
23
+ var ComponentWrapper = require('./ComponentWrapper-9318cece.js');
24
+ var PreferencesConsumer = require('./PreferencesConsumer-5d67b486.js');
25
25
  var _mergeJSXProps = _interopDefault(require('@vue/babel-helper-vue-jsx-merge-props'));
26
- require('./Title-1de7d0f4.js');
27
- var ListItem = require('./ListItem-8c9e0d68.js');
28
- var Card = require('./Card-642547a8.js');
29
- var Flex = require('./Flex-aa517a13.js');
26
+ require('./Title-16042ea0.js');
27
+ var ListItem = require('./ListItem-5088bd6a.js');
28
+ var Card = require('./Card-240f283d.js');
29
+ var Flex = require('./Flex-ddd7cb6b.js');
30
30
 
31
31
  var _templateObject;
32
32
  var PoweredByImage = styled__default('img')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\twidth: 110px;\n"])));
@@ -53,7 +53,7 @@ var ResultListWrapper = {
53
53
  functional: true,
54
54
  render: function render(_, _ref) {
55
55
  var props = _ref.props,
56
- children = _ref.children;
56
+ children = _ref.children;
57
57
  var h = arguments[0];
58
58
  return h("div", _mergeJSXProps([{
59
59
  "attrs": {
@@ -62,7 +62,6 @@ var ResultListWrapper = {
62
62
  }, props]), [children]);
63
63
  }
64
64
  };
65
-
66
65
  ResultListWrapper.install = function (Vue) {
67
66
  Vue.component(ResultListWrapper.name, ResultListWrapper);
68
67
  };
@@ -72,7 +71,7 @@ var ResultCardsWrapper = {
72
71
  functional: true,
73
72
  render: function render(_, _ref) {
74
73
  var props = _ref.props,
75
- children = _ref.children;
74
+ children = _ref.children;
76
75
  var h = arguments[0];
77
76
  return h("div", _mergeJSXProps([{
78
77
  "attrs": {
@@ -81,7 +80,6 @@ var ResultCardsWrapper = {
81
80
  }, props]), [children]);
82
81
  }
83
82
  };
84
-
85
83
  ResultCardsWrapper.install = function (Vue) {
86
84
  Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
87
85
  };
@@ -92,15 +90,13 @@ var sortOptions = emotion.css(_templateObject2 || (_templateObject2 = _rollupPlu
92
90
 
93
91
  var recordImpressions = configureStore.Actions.recordImpressions;
94
92
  var isEqual = configureStore.helper.isEqual;
95
-
96
93
  var debounce = function debounce(method, delay) {
97
- clearTimeout(method._tId); // eslint-disable-next-line
98
-
94
+ clearTimeout(method._tId);
95
+ // eslint-disable-next-line
99
96
  method._tId = setTimeout(function () {
100
97
  method();
101
98
  }, delay);
102
99
  };
103
-
104
100
  var ImpressionTracker = {
105
101
  name: 'ImpressionTracker',
106
102
  inject: ['$$store'],
@@ -113,16 +109,15 @@ var ImpressionTracker = {
113
109
  // An object to track the recorded impressions
114
110
  // It can have the values in following shape
115
111
  // { "hit_id": { "index": "test" }}
116
-
117
- this.trackedIds = {}; // An object to know the the un-tracked impression i.e not recorded by BE
112
+ this.trackedIds = {};
113
+ // An object to know the the un-tracked impression i.e not recorded by BE
118
114
  // It can have the values in following shape
119
115
  // { "query_id": [{ "id": "hit_id", "index": "test"}]}
120
-
121
116
  this.waitingToBeTracked = {};
122
117
  },
123
118
  mounted: function mounted() {
124
- this.setCurrentHits(this.hits); // Add scroll events to track the impressions
125
-
119
+ this.setCurrentHits(this.hits);
120
+ // Add scroll events to track the impressions
126
121
  if (window) {
127
122
  window.addEventListener('scroll', this.tracker);
128
123
  }
@@ -141,7 +136,6 @@ var ImpressionTracker = {
141
136
  var currentHitIds = newVal.map(function (hit) {
142
137
  return hit._id;
143
138
  });
144
-
145
139
  if (!isEqual(currentHitIds, prevHitIds)) {
146
140
  this.setCurrentHits(newVal);
147
141
  }
@@ -154,28 +148,24 @@ var ImpressionTracker = {
154
148
  return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
155
149
  },
156
150
  setCurrentHits: function setCurrentHits(hits) {
157
- this.currentHits = hits; // Reset the tracked Ids for new hits
158
-
151
+ this.currentHits = hits;
152
+ // Reset the tracked Ids for new hits
159
153
  this.trackedIds = {};
160
-
161
154
  if (hits && hits.length) {
162
- this.tracker(); // Run the tracker function on an interval of 1s to track the impressions for
155
+ this.tracker();
156
+ // Run the tracker function on an interval of 1s to track the impressions for
163
157
  // non-scroll views for e.g on tab change
164
-
165
158
  this.setTrackerInterval();
166
159
  }
167
160
  },
168
161
  recordImpression: function recordImpression() {
169
162
  var _this = this;
170
-
171
163
  if (Object.keys(this.waitingToBeTracked).length) {
172
164
  var unTrackedHits = _rollupPluginBabelHelpers._extends({}, this.waitingToBeTracked);
173
-
174
165
  Object.keys(unTrackedHits).forEach(function (queryId) {
175
166
  if (unTrackedHits[queryId] && unTrackedHits[queryId].length) {
176
- _this.trackImpressions(queryId, unTrackedHits[queryId]); // Removed tracked impressions from waiting list
177
-
178
-
167
+ _this.trackImpressions(queryId, unTrackedHits[queryId]);
168
+ // Removed tracked impressions from waiting list
179
169
  delete _this.waitingToBeTracked[queryId];
180
170
  }
181
171
  });
@@ -183,13 +173,12 @@ var ImpressionTracker = {
183
173
  },
184
174
  addToWaitingList: function addToWaitingList(hitObject) {
185
175
  var queryId = this.getQueryId();
186
-
187
176
  if (hitObject && queryId) {
188
177
  var impression = {
189
178
  id: hitObject._id,
190
179
  index: hitObject._index
191
- }; // Check if query id already present in waiting list
192
-
180
+ };
181
+ // Check if query id already present in waiting list
193
182
  if (this.waitingToBeTracked[queryId]) {
194
183
  this.waitingToBeTracked[queryId].push(impression);
195
184
  } else {
@@ -199,32 +188,27 @@ var ImpressionTracker = {
199
188
  },
200
189
  tracker: function tracker() {
201
190
  var _this2 = this;
202
-
203
191
  if (!this.getHitIds().length) {
204
192
  this.clearTrackerInterval();
205
193
  return;
206
- } // only run at client-side
207
-
208
-
194
+ }
195
+ // only run at client-side
209
196
  if (window && document) {
210
197
  this.getHitIds().forEach(function (id) {
211
198
  var element = document.getElementById(id);
212
-
213
199
  if (element) {
214
200
  if (_this2.inViewPort(element)) {
215
201
  // Add the hit id in the list of tracked ids
216
202
  var hitObject = _this2.currentHits.find(function (hit) {
217
203
  return hit._id === id;
218
204
  });
219
-
220
- _this2.trackedIds[id] = true; // Add hit to waiting list to be recorded
221
-
205
+ _this2.trackedIds[id] = true;
206
+ // Add hit to waiting list to be recorded
222
207
  _this2.addToWaitingList(hitObject);
223
208
  }
224
209
  }
225
210
  });
226
211
  }
227
-
228
212
  debounce(this.recordImpression, 300);
229
213
  },
230
214
  setTrackerInterval: function setTrackerInterval() {
@@ -232,8 +216,8 @@ var ImpressionTracker = {
232
216
  },
233
217
  clearTrackerInterval: function clearTrackerInterval() {
234
218
  if (this.intervalID) {
235
- clearInterval(this.intervalID); // Reset interval ID
236
-
219
+ clearInterval(this.intervalID);
220
+ // Reset interval ID
237
221
  this.intervalID = null;
238
222
  }
239
223
  },
@@ -243,7 +227,6 @@ var ImpressionTracker = {
243
227
  },
244
228
  getHitIds: function getHitIds() {
245
229
  var _this3 = this;
246
-
247
230
  return this.currentHits.map(function (hit) {
248
231
  return hit._id;
249
232
  }).filter(function (id) {
@@ -263,20 +246,20 @@ var ImpressionTracker$1 = index.connect(function () {
263
246
  }, mapDispatchToProps)(ImpressionTracker);
264
247
 
265
248
  var setQueryOptions = configureStore.Actions.setQueryOptions,
266
- updateQuery = configureStore.Actions.updateQuery,
267
- loadMore = configureStore.Actions.loadMore,
268
- setValue = configureStore.Actions.setValue,
269
- updateComponentProps = configureStore.Actions.updateComponentProps,
270
- setDefaultQuery = configureStore.Actions.setDefaultQuery,
271
- recordResultClick = configureStore.Actions.recordResultClick;
249
+ updateQuery = configureStore.Actions.updateQuery,
250
+ loadMore = configureStore.Actions.loadMore,
251
+ setValue = configureStore.Actions.setValue,
252
+ updateComponentProps = configureStore.Actions.updateComponentProps,
253
+ setDefaultQuery = configureStore.Actions.setDefaultQuery,
254
+ recordResultClick = configureStore.Actions.recordResultClick;
272
255
  var isEqual$1 = configureStore.helper.isEqual,
273
- getQueryOptions = configureStore.helper.getQueryOptions,
274
- getClassName = configureStore.helper.getClassName,
275
- parseHits = configureStore.helper.parseHits,
276
- getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
277
- getResultStats = configureStore.helper.getResultStats,
278
- extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
279
- getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
256
+ getQueryOptions = configureStore.helper.getQueryOptions,
257
+ getClassName = configureStore.helper.getClassName,
258
+ parseHits = configureStore.helper.parseHits,
259
+ getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
260
+ getResultStats = configureStore.helper.getResultStats,
261
+ extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
262
+ getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
280
263
  var ReactiveList = {
281
264
  name: 'ReactiveList',
282
265
  components: {
@@ -286,13 +269,11 @@ var ReactiveList = {
286
269
  data: function data() {
287
270
  var currentPageState = 0;
288
271
  var defaultPage = this.defaultPage || -1;
289
-
290
272
  if (defaultPage >= 0) {
291
273
  currentPageState = defaultPage;
292
274
  } else if (this.currentPage) {
293
275
  currentPageState = Math.max(this.currentPage - 1, 0);
294
276
  }
295
-
296
277
  this.__state = {
297
278
  from: currentPageState * this.size,
298
279
  currentPageState: currentPageState
@@ -301,50 +282,40 @@ var ReactiveList = {
301
282
  },
302
283
  created: function created() {
303
284
  var _this = this;
304
-
305
285
  var _this$$props = this.$props,
306
- distinctField = _this$$props.distinctField,
307
- distinctFieldConfig = _this$$props.distinctFieldConfig,
308
- index = _this$$props.index; // no support for pagination and aggregationField together
309
-
286
+ distinctField = _this$$props.distinctField,
287
+ distinctFieldConfig = _this$$props.distinctFieldConfig,
288
+ index = _this$$props.index;
289
+ // no support for pagination and aggregationField together
310
290
  if (this.pagination && this.aggregationField) {
311
291
  console.warn('Pagination is not supported when aggregationField is present. The list will be rendered with infinite scroll');
312
292
  }
313
-
314
293
  if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
315
294
  console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
316
295
  }
317
-
318
296
  if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
319
297
  console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
320
298
  }
321
-
322
299
  if (!this.enableAppbase && index) {
323
300
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
324
301
  }
325
-
326
302
  var defaultPage = this.defaultPage || -1;
327
-
328
303
  if (defaultPage >= 0) {
329
304
  this.currentPageState = defaultPage;
330
305
  this.from = this.currentPageState * this.$props.size;
331
306
  }
332
-
333
307
  this.internalComponent = this.$props.componentId + "__internal";
334
308
  this.sortOptionIndex = 0;
335
-
336
309
  if (this.defaultSortOption && this.sortOptions && Array.isArray(this.sortOptions)) {
337
310
  this.sortOptionIndex = this.sortOptions.findIndex(function (s) {
338
311
  return s.label === _this.defaultSortOption;
339
312
  });
340
313
  }
341
-
342
314
  if (this.urlSortOption) {
343
315
  this.sortOptionIndex = this.$props.sortOptions.findIndex(function (s) {
344
316
  return s.label === _this.urlSortOption;
345
317
  }) || 0;
346
318
  }
347
-
348
319
  this.updateComponentProps(this.componentId, {
349
320
  from: this.from
350
321
  }, constants.componentTypes.reactiveList);
@@ -421,21 +392,17 @@ var ReactiveList = {
421
392
  var results = parseHits(this.hits) || [];
422
393
  var parsedPromotedResults = parseHits(this.promotedResults) || [];
423
394
  var filteredResults = results;
424
-
425
395
  if (parsedPromotedResults.length) {
426
396
  var ids = parsedPromotedResults.map(function (item) {
427
397
  return item._id;
428
398
  }).filter(Boolean);
429
-
430
399
  if (ids) {
431
400
  filteredResults = filteredResults.filter(function (item) {
432
401
  return !ids.includes(item._id);
433
402
  });
434
403
  }
435
-
436
404
  filteredResults = [].concat(parsedPromotedResults, filteredResults);
437
405
  }
438
-
439
406
  return helper.withClickIds(filteredResults);
440
407
  }
441
408
  },
@@ -477,19 +444,16 @@ var ReactiveList = {
477
444
  this.$defaultQuery = newVal(null, this.$props);
478
445
  var query = extractQueryFromCustomQuery(this.$defaultQuery);
479
446
  var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
480
-
481
447
  if (queryOptions) {
482
448
  options = _rollupPluginBabelHelpers._extends({}, options, queryOptions);
483
- } // Update calculated default query in store
484
-
485
-
449
+ }
450
+ // Update calculated default query in store
486
451
  index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
487
452
  this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, this.getAggsQuery()), !query);
488
453
  this.updateQuery({
489
454
  componentId: this.internalComponent,
490
455
  query: query
491
456
  }, true); // reset page because of query change
492
-
493
457
  this.currentPageState = 0;
494
458
  this.from = 0;
495
459
  }
@@ -511,7 +475,6 @@ var ReactiveList = {
511
475
  },
512
476
  hits: function hits(newVal, oldVal) {
513
477
  this.$emit('data', this.getData());
514
-
515
478
  if (this.shouldRenderPagination) {
516
479
  // called when page is changed
517
480
  if (this.isLoading && (oldVal || newVal)) {
@@ -529,7 +492,6 @@ var ReactiveList = {
529
492
  if (this.scrollOnChange) {
530
493
  window.scrollTo(0, 0);
531
494
  }
532
-
533
495
  this.from = 0;
534
496
  }
535
497
  }
@@ -553,7 +515,6 @@ var ReactiveList = {
553
515
  window.removeEventListener('scroll', this.scrollHandler);
554
516
  }
555
517
  } // handle window url history change (on native back and forth interactions)
556
-
557
518
  },
558
519
  defaultPage: function defaultPage(newVal, oldVal) {
559
520
  if (this.currentPageState !== newVal && oldVal !== newVal) {
@@ -565,46 +526,39 @@ var ReactiveList = {
565
526
  if (this.defaultPage < 0 && this.currentPage > 0) {
566
527
  this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, this.URLParams);
567
528
  }
568
-
569
529
  var options = getQueryOptions(this.$props);
570
530
  options.from = this.$data.from;
571
-
572
531
  if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
573
532
  var _ref;
574
-
575
533
  var sortField = this.sortOptions[this.sortOptionIndex].dataField;
576
534
  var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
577
535
  options.sort = [(_ref = {}, _ref[sortField] = {
578
536
  order: sortBy
579
- }, _ref)]; // To handle sort options for RS API
580
-
537
+ }, _ref)];
538
+ // To handle sort options for RS API
581
539
  this.updateComponentProps(this.componentId, {
582
540
  dataField: sortField,
583
541
  sortBy: sortBy
584
542
  }, constants.componentTypes.reactiveList);
585
543
  } else if (this.$props.sortBy) {
586
544
  var _ref2;
587
-
588
545
  options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
589
546
  order: this.$props.sortBy
590
547
  }, _ref2)];
591
548
  } // Override sort query with defaultQuery's sort if defined
592
549
 
593
-
594
550
  this.$defaultQuery = null;
595
-
596
551
  if (this.$props.defaultQuery) {
597
552
  this.$defaultQuery = this.$props.defaultQuery();
598
- options = _rollupPluginBabelHelpers._extends({}, options, getOptionsForCustomQuery(this.$defaultQuery)); // Update calculated default query in store
553
+ options = _rollupPluginBabelHelpers._extends({}, options, getOptionsForCustomQuery(this.$defaultQuery));
599
554
 
555
+ // Update calculated default query in store
600
556
  index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
601
- } // execute is set to false at the time of mount
602
-
603
-
557
+ }
558
+ // execute is set to false at the time of mount
604
559
  var query = extractQueryFromCustomQuery(this.$defaultQuery);
605
560
  var execute = false;
606
561
  this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, this.getAggsQuery()), execute);
607
-
608
562
  if (this.$defaultQuery) {
609
563
  this.updateQuery({
610
564
  componentId: this.internalComponent,
@@ -617,7 +571,6 @@ var ReactiveList = {
617
571
  }, execute);
618
572
  } // query will be executed here
619
573
 
620
-
621
574
  if (this.showInfiniteScroll) {
622
575
  window.addEventListener('scroll', this.scrollHandler);
623
576
  }
@@ -676,16 +629,13 @@ var ReactiveList = {
676
629
  methods: {
677
630
  renderErrorComponent: function renderErrorComponent() {
678
631
  var renderError = this.$scopedSlots.renderError || this.$props.renderError;
679
-
680
632
  if (renderError && this.error && !this.isLoading) {
681
633
  return index.isFunction(renderError) ? renderError(this.error) : renderError;
682
634
  }
683
-
684
635
  return null;
685
636
  },
686
637
  renderResults: function renderResults() {
687
638
  var _this2 = this;
688
-
689
639
  var h = this.$createElement;
690
640
  var size = this.$props.size;
691
641
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
@@ -699,8 +649,8 @@ var ReactiveList = {
699
649
  return _this2.triggerClickAnalytics(_this2.currentPageState * size + index);
700
650
  }
701
651
  });
702
- })]); // If analytics is set to true then render with impression tracker
703
-
652
+ })]);
653
+ // If analytics is set to true then render with impression tracker
704
654
  return this.analytics ? h(ImpressionTracker$1, {
705
655
  "attrs": {
706
656
  "hits": this.data
@@ -710,38 +660,32 @@ var ReactiveList = {
710
660
  updateQueryOptions: function updateQueryOptions(props) {
711
661
  var options = getQueryOptions(props);
712
662
  options.from = this.$data.from;
713
-
714
663
  if (props.sortOptions && Array.isArray(props.sortOptions)) {
715
664
  var sortOptionIndex = props.defaultSortOption ? props.sortOptions.findIndex(function (s) {
716
665
  return s.label === props.defaultSortOption;
717
666
  }) : 0;
718
-
719
667
  if (props.sortOptions[sortOptionIndex]) {
720
668
  var _ref3;
721
-
722
669
  options.sort = [(_ref3 = {}, _ref3[props.sortOptions[sortOptionIndex].dataField] = {
723
670
  order: props.sortOptions[sortOptionIndex].sortBy
724
671
  }, _ref3)];
725
672
  }
726
673
  } else if (props.sortBy) {
727
674
  var _ref4;
728
-
729
675
  options.sort = [(_ref4 = {}, _ref4[props.dataField] = {
730
676
  order: props.sortBy
731
677
  }, _ref4)];
732
678
  }
733
-
734
679
  this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, this.getAggsQuery()), true);
735
680
  },
736
681
  getAggsQuery: function getAggsQuery() {
737
682
  var _this$$props2 = this.$props,
738
- size = _this$$props2.size,
739
- aggregationField = _this$$props2.aggregationField;
683
+ size = _this$$props2.size,
684
+ aggregationField = _this$$props2.aggregationField;
740
685
  var afterKey = this.$data.afterKey;
741
686
  var queryOptions = {
742
687
  size: size
743
688
  };
744
-
745
689
  if (aggregationField) {
746
690
  queryOptions.aggs = getCompositeAggsQuery({
747
691
  props: this.$props,
@@ -749,7 +693,6 @@ var ReactiveList = {
749
693
  showTopHits: true
750
694
  }).aggs;
751
695
  }
752
-
753
696
  return queryOptions;
754
697
  },
755
698
  scrollHandler: function scrollHandler() {
@@ -759,9 +702,9 @@ var ReactiveList = {
759
702
  },
760
703
  loadMore: function loadMore() {
761
704
  if (this.aggregationField && !this.afterKey) return;
762
-
763
705
  if (this.hits && !this.shouldRenderPagination && this.total > this.hits.length) {
764
- var value = this.$data.from + this.$props.size; // If current hits length is less than the current from then it means
706
+ var value = this.$data.from + this.$props.size;
707
+ // If current hits length is less than the current from then it means
765
708
  // that there are no results present.
766
709
  // It can happen because of many reasons some of them are:
767
710
  // 1. Using the `collapse` query to remove results
@@ -772,11 +715,9 @@ var ReactiveList = {
772
715
  if (this.hits.length < value) {
773
716
  return;
774
717
  }
775
-
776
718
  var options = _rollupPluginBabelHelpers._extends({}, getQueryOptions(this.$props), this.getAggsQuery());
777
-
778
- this.from = value; // Update default query to support pagination for aggregationField
779
-
719
+ this.from = value;
720
+ // Update default query to support pagination for aggregationField
780
721
  index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
781
722
  this.loadMoreAction(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, options, {
782
723
  from: value
@@ -802,37 +743,30 @@ var ReactiveList = {
802
743
  renderStats: function renderStats() {
803
744
  var h = this.$createElement;
804
745
  var renderResultStats = this.$scopedSlots.renderResultStats || this.$props.renderResultStats;
805
-
806
746
  if (renderResultStats && this.$data.total) {
807
747
  return renderResultStats(this.stats);
808
748
  }
809
-
810
749
  if (this.stats.numberOfResults) {
811
750
  return h("p", {
812
751
  "class": resultStats + " " + getClassName(this.$props.innerClass, 'resultStats')
813
752
  }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
814
753
  }
815
-
816
754
  return null;
817
755
  },
818
756
  renderNoResult: function renderNoResult() {
819
757
  var h = this.$createElement;
820
758
  var renderNoResults = this.$scopedSlots.renderNoResults || this.$props.renderNoResults;
821
-
822
759
  if (this.$scopedSlots.renderNoResults) {
823
760
  return index.isFunction(renderNoResults) ? renderNoResults() : renderNoResults;
824
761
  }
825
-
826
762
  return h("p", {
827
763
  "class": getClassName(this.$props.innerClass, 'noResults') || null
828
764
  }, [index.isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
829
765
  },
830
766
  handleSortChange: function handleSortChange(e) {
831
767
  var index = e.target.value;
832
-
833
768
  if (this.sortOptions && this.sortOptions[index]) {
834
769
  var _ref5;
835
-
836
770
  // This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
837
771
  var options = getQueryOptions(this.$props);
838
772
  options.from = 0;
@@ -841,8 +775,8 @@ var ReactiveList = {
841
775
  options.sort = [(_ref5 = {}, _ref5[sortField] = {
842
776
  order: sortBy
843
777
  }, _ref5)];
844
- this.sortOptionIndex = index; // To handle sort options for RS API
845
-
778
+ this.sortOptionIndex = index;
779
+ // To handle sort options for RS API
846
780
  this.updateComponentProps(this.componentId, {
847
781
  dataField: sortField,
848
782
  sortBy: sortBy
@@ -857,20 +791,16 @@ var ReactiveList = {
857
791
  },
858
792
  triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
859
793
  var docId = documentId;
860
-
861
794
  if (!docId) {
862
795
  var _this$getData = this.getData(),
863
- data = _this$getData.data;
864
-
796
+ data = _this$getData.data;
865
797
  var hitData = data.find(function (hit) {
866
798
  return hit._click_id === searchPosition;
867
799
  });
868
-
869
800
  if (hitData && hitData._id) {
870
801
  docId = hitData._id;
871
802
  }
872
803
  }
873
-
874
804
  this.recordResultClick(searchPosition, docId);
875
805
  },
876
806
  renderSortOptions: function renderSortOptions() {
@@ -898,8 +828,7 @@ var ReactiveList = {
898
828
  },
899
829
  withClickIds: function withClickIds(results) {
900
830
  var _this$getAllData = this.getAllData(),
901
- base = _this$getAllData.base;
902
-
831
+ base = _this$getAllData.base;
903
832
  return results.map(function (result, index) {
904
833
  return _rollupPluginBabelHelpers._extends({}, result, {
905
834
  _click_id: base + index
@@ -909,11 +838,11 @@ var ReactiveList = {
909
838
  // Shape of the object to be returned in onData & render
910
839
  getAllData: function getAllData() {
911
840
  var size = this.size,
912
- promotedResults = this.promotedResults,
913
- aggregationData = this.aggregationData,
914
- customData = this.customData,
915
- currentPage = this.currentPage,
916
- hits = this.hits;
841
+ promotedResults = this.promotedResults,
842
+ aggregationData = this.aggregationData,
843
+ customData = this.customData,
844
+ currentPage = this.currentPage,
845
+ hits = this.hits;
917
846
  var results = parseHits(hits) || [];
918
847
  var parsedPromotedResults = parseHits(promotedResults) || [];
919
848
  var base = currentPage * size;
@@ -929,10 +858,9 @@ var ReactiveList = {
929
858
  },
930
859
  getData: function getData() {
931
860
  var _this$getAllData2 = this.getAllData(),
932
- promotedResults = _this$getAllData2.promotedResults,
933
- aggregationData = _this$getAllData2.aggregationData,
934
- customData = _this$getAllData2.customData;
935
-
861
+ promotedResults = _this$getAllData2.promotedResults,
862
+ aggregationData = _this$getAllData2.aggregationData,
863
+ customData = _this$getAllData2.customData;
936
864
  return {
937
865
  data: this.data,
938
866
  aggregationData: this.withClickIds(aggregationData || []),
@@ -944,8 +872,7 @@ var ReactiveList = {
944
872
  },
945
873
  getComponent: function getComponent() {
946
874
  var error = this.error,
947
- isLoading = this.isLoading;
948
-
875
+ isLoading = this.isLoading;
949
876
  var data = _rollupPluginBabelHelpers._extends({
950
877
  error: error,
951
878
  loading: isLoading || false,
@@ -953,12 +880,10 @@ var ReactiveList = {
953
880
  triggerClickAnalytics: this.triggerClickAnalytics,
954
881
  setPage: this.setPage
955
882
  }, this.getData());
956
-
957
883
  return index.getComponent(data, this);
958
884
  }
959
885
  }
960
886
  };
961
-
962
887
  var mapStateToProps = function mapStateToProps(state, props) {
963
888
  return {
964
889
  defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
@@ -980,7 +905,6 @@ var mapStateToProps = function mapStateToProps(state, props) {
980
905
  isLoading: state.isLoading[props.componentId]
981
906
  };
982
907
  };
983
-
984
908
  var mapDispatchtoProps = {
985
909
  loadMoreAction: loadMore,
986
910
  setPageURL: setValue,
@@ -989,70 +913,58 @@ var mapDispatchtoProps = {
989
913
  updateComponentProps: updateComponentProps,
990
914
  setDefaultQuery: setDefaultQuery,
991
915
  recordResultClick: recordResultClick
992
- }; // Only used for SSR
993
-
916
+ };
917
+ // Only used for SSR
994
918
  ReactiveList.generateQueryOptions = function (props) {
995
919
  var options = getQueryOptions(props);
996
920
  var size = props.size,
997
- dataField = props.dataField,
998
- defaultSortOption = props.defaultSortOption,
999
- sortOptionsNew = props.sortOptions,
1000
- currentPage = props.currentPage,
1001
- sortBy = props.sortBy;
921
+ dataField = props.dataField,
922
+ defaultSortOption = props.defaultSortOption,
923
+ sortOptionsNew = props.sortOptions,
924
+ currentPage = props.currentPage,
925
+ sortBy = props.sortBy;
1002
926
  options.from = currentPage ? (currentPage - 1) * (size || 10) : 0;
1003
927
  options.size = size || 10;
1004
-
1005
928
  var getSortOption = function getSortOption() {
1006
929
  var _ref7;
1007
-
1008
930
  if (defaultSortOption) {
1009
931
  var sortOption = sortOptionsNew.find(function (option) {
1010
932
  return option.label === defaultSortOption;
1011
933
  });
1012
-
1013
934
  if (sortOption) {
1014
935
  var _ref6;
1015
-
1016
936
  return _ref6 = {}, _ref6[sortOption.dataField] = {
1017
937
  order: sortOption.sortBy
1018
938
  }, _ref6;
1019
939
  }
1020
940
  }
1021
-
1022
941
  return _ref7 = {}, _ref7[sortOptionsNew[0].dataField] = {
1023
942
  order: sortOptionsNew[0].sortBy
1024
943
  }, _ref7;
1025
944
  };
1026
-
1027
945
  if (sortOptionsNew) {
1028
946
  options.sort = [getSortOption()];
1029
947
  } else if (sortBy) {
1030
948
  var _ref8;
1031
-
1032
949
  options.sort = [(_ref8 = {}, _ref8[dataField] = {
1033
950
  order: sortBy
1034
951
  }, _ref8)];
1035
952
  }
1036
-
1037
953
  return options;
1038
954
  };
1039
-
1040
955
  ReactiveList.hasInternalComponent = function () {
1041
956
  return true;
1042
957
  };
1043
-
1044
958
  var RLConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
1045
959
  componentType: constants.componentTypes.reactiveList,
1046
960
  internalComponent: ReactiveList.hasInternalComponent()
1047
961
  }));
1048
-
1049
962
  ReactiveList.install = function (Vue) {
1050
963
  Vue.component(ReactiveList.name, RLConnected);
1051
964
  Vue.component(ResultListWrapper.name, ResultListWrapper);
1052
965
  Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
1053
- }; // Add componentType for SSR
1054
-
1055
-
966
+ };
967
+ // Add componentType for SSR
1056
968
  ReactiveList.componentType = constants.componentTypes.reactiveList;
1057
969
 
1058
970
  exports.RLConnected = RLConnected;