@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
@@ -1,24 +1,24 @@
1
1
  import { Actions, helper } from '@appbaseio/reactivecore';
2
2
  import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
3
+ import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
4
4
  import VueTypes from 'vue-types';
5
5
  import { withClickIds } from '@appbaseio/reactivecore/lib/utils/helper';
6
6
  import { css } from 'emotion';
7
7
  import styled from '@appbaseio/vue-emotion';
8
8
  import 'polished';
9
- import './Button-35aa984e.js';
10
- import { t as types } from './vueTypes-b8146772.js';
11
- import { P as Pagination } from './Pagination-af9de08f.js';
9
+ import './Button-153cd885.js';
10
+ import { t as types } from './vueTypes-8986b709.js';
11
+ import { P as Pagination } from './Pagination-28e56c5c.js';
12
12
  import '@appbaseio/reactivecore/lib/utils/transform';
13
13
  import 'redux';
14
- import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-99c5f9c9.js';
15
- import { C as ComponentWrapper } from './ComponentWrapper-d5e814a4.js';
16
- import { P as PreferencesConsumer } from './PreferencesConsumer-c30605fe.js';
14
+ import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-0444a498.js';
15
+ import { C as ComponentWrapper } from './ComponentWrapper-240450cc.js';
16
+ import { P as PreferencesConsumer } from './PreferencesConsumer-bc097ebb.js';
17
17
  import _mergeJSXProps from '@vue/babel-helper-vue-jsx-merge-props';
18
- import './Title-3342664a.js';
19
- import { c as container } from './ListItem-cad14c5e.js';
20
- import { c as container$1 } from './Card-450683f1.js';
21
- import { F as Flex } from './Flex-1f0795c3.js';
18
+ import './Title-863dfa42.js';
19
+ import { c as container } from './ListItem-07888a65.js';
20
+ import { c as container$1 } from './Card-19ad6d90.js';
21
+ import { F as Flex } from './Flex-7c177a10.js';
22
22
 
23
23
  var _templateObject;
24
24
  var PoweredByImage = styled('img')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\twidth: 110px;\n"])));
@@ -45,7 +45,7 @@ var ResultListWrapper = {
45
45
  functional: true,
46
46
  render: function render(_, _ref) {
47
47
  var props = _ref.props,
48
- children = _ref.children;
48
+ children = _ref.children;
49
49
  var h = arguments[0];
50
50
  return h("div", _mergeJSXProps([{
51
51
  "attrs": {
@@ -54,7 +54,6 @@ var ResultListWrapper = {
54
54
  }, props]), [children]);
55
55
  }
56
56
  };
57
-
58
57
  ResultListWrapper.install = function (Vue) {
59
58
  Vue.component(ResultListWrapper.name, ResultListWrapper);
60
59
  };
@@ -64,7 +63,7 @@ var ResultCardsWrapper = {
64
63
  functional: true,
65
64
  render: function render(_, _ref) {
66
65
  var props = _ref.props,
67
- children = _ref.children;
66
+ children = _ref.children;
68
67
  var h = arguments[0];
69
68
  return h("div", _mergeJSXProps([{
70
69
  "attrs": {
@@ -73,7 +72,6 @@ var ResultCardsWrapper = {
73
72
  }, props]), [children]);
74
73
  }
75
74
  };
76
-
77
75
  ResultCardsWrapper.install = function (Vue) {
78
76
  Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
79
77
  };
@@ -84,15 +82,13 @@ var sortOptions = css(_templateObject2 || (_templateObject2 = _taggedTemplateLit
84
82
 
85
83
  var recordImpressions = Actions.recordImpressions;
86
84
  var isEqual = helper.isEqual;
87
-
88
85
  var debounce = function debounce(method, delay) {
89
- clearTimeout(method._tId); // eslint-disable-next-line
90
-
86
+ clearTimeout(method._tId);
87
+ // eslint-disable-next-line
91
88
  method._tId = setTimeout(function () {
92
89
  method();
93
90
  }, delay);
94
91
  };
95
-
96
92
  var ImpressionTracker = {
97
93
  name: 'ImpressionTracker',
98
94
  inject: ['$$store'],
@@ -105,16 +101,15 @@ var ImpressionTracker = {
105
101
  // An object to track the recorded impressions
106
102
  // It can have the values in following shape
107
103
  // { "hit_id": { "index": "test" }}
108
-
109
- this.trackedIds = {}; // An object to know the the un-tracked impression i.e not recorded by BE
104
+ this.trackedIds = {};
105
+ // An object to know the the un-tracked impression i.e not recorded by BE
110
106
  // It can have the values in following shape
111
107
  // { "query_id": [{ "id": "hit_id", "index": "test"}]}
112
-
113
108
  this.waitingToBeTracked = {};
114
109
  },
115
110
  mounted: function mounted() {
116
- this.setCurrentHits(this.hits); // Add scroll events to track the impressions
117
-
111
+ this.setCurrentHits(this.hits);
112
+ // Add scroll events to track the impressions
118
113
  if (window) {
119
114
  window.addEventListener('scroll', this.tracker);
120
115
  }
@@ -133,7 +128,6 @@ var ImpressionTracker = {
133
128
  var currentHitIds = newVal.map(function (hit) {
134
129
  return hit._id;
135
130
  });
136
-
137
131
  if (!isEqual(currentHitIds, prevHitIds)) {
138
132
  this.setCurrentHits(newVal);
139
133
  }
@@ -146,28 +140,24 @@ var ImpressionTracker = {
146
140
  return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
147
141
  },
148
142
  setCurrentHits: function setCurrentHits(hits) {
149
- this.currentHits = hits; // Reset the tracked Ids for new hits
150
-
143
+ this.currentHits = hits;
144
+ // Reset the tracked Ids for new hits
151
145
  this.trackedIds = {};
152
-
153
146
  if (hits && hits.length) {
154
- this.tracker(); // Run the tracker function on an interval of 1s to track the impressions for
147
+ this.tracker();
148
+ // Run the tracker function on an interval of 1s to track the impressions for
155
149
  // non-scroll views for e.g on tab change
156
-
157
150
  this.setTrackerInterval();
158
151
  }
159
152
  },
160
153
  recordImpression: function recordImpression() {
161
154
  var _this = this;
162
-
163
155
  if (Object.keys(this.waitingToBeTracked).length) {
164
156
  var unTrackedHits = _extends({}, this.waitingToBeTracked);
165
-
166
157
  Object.keys(unTrackedHits).forEach(function (queryId) {
167
158
  if (unTrackedHits[queryId] && unTrackedHits[queryId].length) {
168
- _this.trackImpressions(queryId, unTrackedHits[queryId]); // Removed tracked impressions from waiting list
169
-
170
-
159
+ _this.trackImpressions(queryId, unTrackedHits[queryId]);
160
+ // Removed tracked impressions from waiting list
171
161
  delete _this.waitingToBeTracked[queryId];
172
162
  }
173
163
  });
@@ -175,13 +165,12 @@ var ImpressionTracker = {
175
165
  },
176
166
  addToWaitingList: function addToWaitingList(hitObject) {
177
167
  var queryId = this.getQueryId();
178
-
179
168
  if (hitObject && queryId) {
180
169
  var impression = {
181
170
  id: hitObject._id,
182
171
  index: hitObject._index
183
- }; // Check if query id already present in waiting list
184
-
172
+ };
173
+ // Check if query id already present in waiting list
185
174
  if (this.waitingToBeTracked[queryId]) {
186
175
  this.waitingToBeTracked[queryId].push(impression);
187
176
  } else {
@@ -191,32 +180,27 @@ var ImpressionTracker = {
191
180
  },
192
181
  tracker: function tracker() {
193
182
  var _this2 = this;
194
-
195
183
  if (!this.getHitIds().length) {
196
184
  this.clearTrackerInterval();
197
185
  return;
198
- } // only run at client-side
199
-
200
-
186
+ }
187
+ // only run at client-side
201
188
  if (window && document) {
202
189
  this.getHitIds().forEach(function (id) {
203
190
  var element = document.getElementById(id);
204
-
205
191
  if (element) {
206
192
  if (_this2.inViewPort(element)) {
207
193
  // Add the hit id in the list of tracked ids
208
194
  var hitObject = _this2.currentHits.find(function (hit) {
209
195
  return hit._id === id;
210
196
  });
211
-
212
- _this2.trackedIds[id] = true; // Add hit to waiting list to be recorded
213
-
197
+ _this2.trackedIds[id] = true;
198
+ // Add hit to waiting list to be recorded
214
199
  _this2.addToWaitingList(hitObject);
215
200
  }
216
201
  }
217
202
  });
218
203
  }
219
-
220
204
  debounce(this.recordImpression, 300);
221
205
  },
222
206
  setTrackerInterval: function setTrackerInterval() {
@@ -224,8 +208,8 @@ var ImpressionTracker = {
224
208
  },
225
209
  clearTrackerInterval: function clearTrackerInterval() {
226
210
  if (this.intervalID) {
227
- clearInterval(this.intervalID); // Reset interval ID
228
-
211
+ clearInterval(this.intervalID);
212
+ // Reset interval ID
229
213
  this.intervalID = null;
230
214
  }
231
215
  },
@@ -235,7 +219,6 @@ var ImpressionTracker = {
235
219
  },
236
220
  getHitIds: function getHitIds() {
237
221
  var _this3 = this;
238
-
239
222
  return this.currentHits.map(function (hit) {
240
223
  return hit._id;
241
224
  }).filter(function (id) {
@@ -255,20 +238,20 @@ var ImpressionTracker$1 = connect(function () {
255
238
  }, mapDispatchToProps)(ImpressionTracker);
256
239
 
257
240
  var setQueryOptions = Actions.setQueryOptions,
258
- updateQuery = Actions.updateQuery,
259
- loadMore = Actions.loadMore,
260
- setValue = Actions.setValue,
261
- updateComponentProps = Actions.updateComponentProps,
262
- setDefaultQuery = Actions.setDefaultQuery,
263
- recordResultClick = Actions.recordResultClick;
241
+ updateQuery = Actions.updateQuery,
242
+ loadMore = Actions.loadMore,
243
+ setValue = Actions.setValue,
244
+ updateComponentProps = Actions.updateComponentProps,
245
+ setDefaultQuery = Actions.setDefaultQuery,
246
+ recordResultClick = Actions.recordResultClick;
264
247
  var isEqual$1 = helper.isEqual,
265
- getQueryOptions = helper.getQueryOptions,
266
- getClassName = helper.getClassName,
267
- parseHits = helper.parseHits,
268
- getCompositeAggsQuery = helper.getCompositeAggsQuery,
269
- getResultStats = helper.getResultStats,
270
- extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
271
- getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
248
+ getQueryOptions = helper.getQueryOptions,
249
+ getClassName = helper.getClassName,
250
+ parseHits = helper.parseHits,
251
+ getCompositeAggsQuery = helper.getCompositeAggsQuery,
252
+ getResultStats = helper.getResultStats,
253
+ extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
254
+ getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
272
255
  var ReactiveList = {
273
256
  name: 'ReactiveList',
274
257
  components: {
@@ -278,13 +261,11 @@ var ReactiveList = {
278
261
  data: function data() {
279
262
  var currentPageState = 0;
280
263
  var defaultPage = this.defaultPage || -1;
281
-
282
264
  if (defaultPage >= 0) {
283
265
  currentPageState = defaultPage;
284
266
  } else if (this.currentPage) {
285
267
  currentPageState = Math.max(this.currentPage - 1, 0);
286
268
  }
287
-
288
269
  this.__state = {
289
270
  from: currentPageState * this.size,
290
271
  currentPageState: currentPageState
@@ -293,50 +274,40 @@ var ReactiveList = {
293
274
  },
294
275
  created: function created() {
295
276
  var _this = this;
296
-
297
277
  var _this$$props = this.$props,
298
- distinctField = _this$$props.distinctField,
299
- distinctFieldConfig = _this$$props.distinctFieldConfig,
300
- index = _this$$props.index; // no support for pagination and aggregationField together
301
-
278
+ distinctField = _this$$props.distinctField,
279
+ distinctFieldConfig = _this$$props.distinctFieldConfig,
280
+ index = _this$$props.index;
281
+ // no support for pagination and aggregationField together
302
282
  if (this.pagination && this.aggregationField) {
303
283
  console.warn('Pagination is not supported when aggregationField is present. The list will be rendered with infinite scroll');
304
284
  }
305
-
306
285
  if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
307
286
  console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
308
287
  }
309
-
310
288
  if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
311
289
  console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
312
290
  }
313
-
314
291
  if (!this.enableAppbase && index) {
315
292
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
316
293
  }
317
-
318
294
  var defaultPage = this.defaultPage || -1;
319
-
320
295
  if (defaultPage >= 0) {
321
296
  this.currentPageState = defaultPage;
322
297
  this.from = this.currentPageState * this.$props.size;
323
298
  }
324
-
325
299
  this.internalComponent = this.$props.componentId + "__internal";
326
300
  this.sortOptionIndex = 0;
327
-
328
301
  if (this.defaultSortOption && this.sortOptions && Array.isArray(this.sortOptions)) {
329
302
  this.sortOptionIndex = this.sortOptions.findIndex(function (s) {
330
303
  return s.label === _this.defaultSortOption;
331
304
  });
332
305
  }
333
-
334
306
  if (this.urlSortOption) {
335
307
  this.sortOptionIndex = this.$props.sortOptions.findIndex(function (s) {
336
308
  return s.label === _this.urlSortOption;
337
309
  }) || 0;
338
310
  }
339
-
340
311
  this.updateComponentProps(this.componentId, {
341
312
  from: this.from
342
313
  }, componentTypes.reactiveList);
@@ -413,21 +384,17 @@ var ReactiveList = {
413
384
  var results = parseHits(this.hits) || [];
414
385
  var parsedPromotedResults = parseHits(this.promotedResults) || [];
415
386
  var filteredResults = results;
416
-
417
387
  if (parsedPromotedResults.length) {
418
388
  var ids = parsedPromotedResults.map(function (item) {
419
389
  return item._id;
420
390
  }).filter(Boolean);
421
-
422
391
  if (ids) {
423
392
  filteredResults = filteredResults.filter(function (item) {
424
393
  return !ids.includes(item._id);
425
394
  });
426
395
  }
427
-
428
396
  filteredResults = [].concat(parsedPromotedResults, filteredResults);
429
397
  }
430
-
431
398
  return withClickIds(filteredResults);
432
399
  }
433
400
  },
@@ -469,19 +436,16 @@ var ReactiveList = {
469
436
  this.$defaultQuery = newVal(null, this.$props);
470
437
  var query = extractQueryFromCustomQuery(this.$defaultQuery);
471
438
  var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
472
-
473
439
  if (queryOptions) {
474
440
  options = _extends({}, options, queryOptions);
475
- } // Update calculated default query in store
476
-
477
-
441
+ }
442
+ // Update calculated default query in store
478
443
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
479
444
  this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), !query);
480
445
  this.updateQuery({
481
446
  componentId: this.internalComponent,
482
447
  query: query
483
448
  }, true); // reset page because of query change
484
-
485
449
  this.currentPageState = 0;
486
450
  this.from = 0;
487
451
  }
@@ -503,7 +467,6 @@ var ReactiveList = {
503
467
  },
504
468
  hits: function hits(newVal, oldVal) {
505
469
  this.$emit('data', this.getData());
506
-
507
470
  if (this.shouldRenderPagination) {
508
471
  // called when page is changed
509
472
  if (this.isLoading && (oldVal || newVal)) {
@@ -521,7 +484,6 @@ var ReactiveList = {
521
484
  if (this.scrollOnChange) {
522
485
  window.scrollTo(0, 0);
523
486
  }
524
-
525
487
  this.from = 0;
526
488
  }
527
489
  }
@@ -545,7 +507,6 @@ var ReactiveList = {
545
507
  window.removeEventListener('scroll', this.scrollHandler);
546
508
  }
547
509
  } // handle window url history change (on native back and forth interactions)
548
-
549
510
  },
550
511
  defaultPage: function defaultPage(newVal, oldVal) {
551
512
  if (this.currentPageState !== newVal && oldVal !== newVal) {
@@ -557,46 +518,39 @@ var ReactiveList = {
557
518
  if (this.defaultPage < 0 && this.currentPage > 0) {
558
519
  this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, this.URLParams);
559
520
  }
560
-
561
521
  var options = getQueryOptions(this.$props);
562
522
  options.from = this.$data.from;
563
-
564
523
  if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
565
524
  var _ref;
566
-
567
525
  var sortField = this.sortOptions[this.sortOptionIndex].dataField;
568
526
  var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
569
527
  options.sort = [(_ref = {}, _ref[sortField] = {
570
528
  order: sortBy
571
- }, _ref)]; // To handle sort options for RS API
572
-
529
+ }, _ref)];
530
+ // To handle sort options for RS API
573
531
  this.updateComponentProps(this.componentId, {
574
532
  dataField: sortField,
575
533
  sortBy: sortBy
576
534
  }, componentTypes.reactiveList);
577
535
  } else if (this.$props.sortBy) {
578
536
  var _ref2;
579
-
580
537
  options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
581
538
  order: this.$props.sortBy
582
539
  }, _ref2)];
583
540
  } // Override sort query with defaultQuery's sort if defined
584
541
 
585
-
586
542
  this.$defaultQuery = null;
587
-
588
543
  if (this.$props.defaultQuery) {
589
544
  this.$defaultQuery = this.$props.defaultQuery();
590
- options = _extends({}, options, getOptionsForCustomQuery(this.$defaultQuery)); // Update calculated default query in store
545
+ options = _extends({}, options, getOptionsForCustomQuery(this.$defaultQuery));
591
546
 
547
+ // Update calculated default query in store
592
548
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
593
- } // execute is set to false at the time of mount
594
-
595
-
549
+ }
550
+ // execute is set to false at the time of mount
596
551
  var query = extractQueryFromCustomQuery(this.$defaultQuery);
597
552
  var execute = false;
598
553
  this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), execute);
599
-
600
554
  if (this.$defaultQuery) {
601
555
  this.updateQuery({
602
556
  componentId: this.internalComponent,
@@ -609,7 +563,6 @@ var ReactiveList = {
609
563
  }, execute);
610
564
  } // query will be executed here
611
565
 
612
-
613
566
  if (this.showInfiniteScroll) {
614
567
  window.addEventListener('scroll', this.scrollHandler);
615
568
  }
@@ -668,16 +621,13 @@ var ReactiveList = {
668
621
  methods: {
669
622
  renderErrorComponent: function renderErrorComponent() {
670
623
  var renderError = this.$scopedSlots.renderError || this.$props.renderError;
671
-
672
624
  if (renderError && this.error && !this.isLoading) {
673
625
  return isFunction(renderError) ? renderError(this.error) : renderError;
674
626
  }
675
-
676
627
  return null;
677
628
  },
678
629
  renderResults: function renderResults() {
679
630
  var _this2 = this;
680
-
681
631
  var h = this.$createElement;
682
632
  var size = this.$props.size;
683
633
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
@@ -691,8 +641,8 @@ var ReactiveList = {
691
641
  return _this2.triggerClickAnalytics(_this2.currentPageState * size + index);
692
642
  }
693
643
  });
694
- })]); // If analytics is set to true then render with impression tracker
695
-
644
+ })]);
645
+ // If analytics is set to true then render with impression tracker
696
646
  return this.analytics ? h(ImpressionTracker$1, {
697
647
  "attrs": {
698
648
  "hits": this.data
@@ -702,38 +652,32 @@ var ReactiveList = {
702
652
  updateQueryOptions: function updateQueryOptions(props) {
703
653
  var options = getQueryOptions(props);
704
654
  options.from = this.$data.from;
705
-
706
655
  if (props.sortOptions && Array.isArray(props.sortOptions)) {
707
656
  var sortOptionIndex = props.defaultSortOption ? props.sortOptions.findIndex(function (s) {
708
657
  return s.label === props.defaultSortOption;
709
658
  }) : 0;
710
-
711
659
  if (props.sortOptions[sortOptionIndex]) {
712
660
  var _ref3;
713
-
714
661
  options.sort = [(_ref3 = {}, _ref3[props.sortOptions[sortOptionIndex].dataField] = {
715
662
  order: props.sortOptions[sortOptionIndex].sortBy
716
663
  }, _ref3)];
717
664
  }
718
665
  } else if (props.sortBy) {
719
666
  var _ref4;
720
-
721
667
  options.sort = [(_ref4 = {}, _ref4[props.dataField] = {
722
668
  order: props.sortBy
723
669
  }, _ref4)];
724
670
  }
725
-
726
671
  this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), true);
727
672
  },
728
673
  getAggsQuery: function getAggsQuery() {
729
674
  var _this$$props2 = this.$props,
730
- size = _this$$props2.size,
731
- aggregationField = _this$$props2.aggregationField;
675
+ size = _this$$props2.size,
676
+ aggregationField = _this$$props2.aggregationField;
732
677
  var afterKey = this.$data.afterKey;
733
678
  var queryOptions = {
734
679
  size: size
735
680
  };
736
-
737
681
  if (aggregationField) {
738
682
  queryOptions.aggs = getCompositeAggsQuery({
739
683
  props: this.$props,
@@ -741,7 +685,6 @@ var ReactiveList = {
741
685
  showTopHits: true
742
686
  }).aggs;
743
687
  }
744
-
745
688
  return queryOptions;
746
689
  },
747
690
  scrollHandler: function scrollHandler() {
@@ -751,9 +694,9 @@ var ReactiveList = {
751
694
  },
752
695
  loadMore: function loadMore() {
753
696
  if (this.aggregationField && !this.afterKey) return;
754
-
755
697
  if (this.hits && !this.shouldRenderPagination && this.total > this.hits.length) {
756
- var value = this.$data.from + this.$props.size; // If current hits length is less than the current from then it means
698
+ var value = this.$data.from + this.$props.size;
699
+ // If current hits length is less than the current from then it means
757
700
  // that there are no results present.
758
701
  // It can happen because of many reasons some of them are:
759
702
  // 1. Using the `collapse` query to remove results
@@ -764,11 +707,9 @@ var ReactiveList = {
764
707
  if (this.hits.length < value) {
765
708
  return;
766
709
  }
767
-
768
710
  var options = _extends({}, getQueryOptions(this.$props), this.getAggsQuery());
769
-
770
- this.from = value; // Update default query to support pagination for aggregationField
771
-
711
+ this.from = value;
712
+ // Update default query to support pagination for aggregationField
772
713
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
773
714
  this.loadMoreAction(this.$props.componentId, _extends({}, options, {
774
715
  from: value
@@ -794,37 +735,30 @@ var ReactiveList = {
794
735
  renderStats: function renderStats() {
795
736
  var h = this.$createElement;
796
737
  var renderResultStats = this.$scopedSlots.renderResultStats || this.$props.renderResultStats;
797
-
798
738
  if (renderResultStats && this.$data.total) {
799
739
  return renderResultStats(this.stats);
800
740
  }
801
-
802
741
  if (this.stats.numberOfResults) {
803
742
  return h("p", {
804
743
  "class": resultStats + " " + getClassName(this.$props.innerClass, 'resultStats')
805
744
  }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
806
745
  }
807
-
808
746
  return null;
809
747
  },
810
748
  renderNoResult: function renderNoResult() {
811
749
  var h = this.$createElement;
812
750
  var renderNoResults = this.$scopedSlots.renderNoResults || this.$props.renderNoResults;
813
-
814
751
  if (this.$scopedSlots.renderNoResults) {
815
752
  return isFunction(renderNoResults) ? renderNoResults() : renderNoResults;
816
753
  }
817
-
818
754
  return h("p", {
819
755
  "class": getClassName(this.$props.innerClass, 'noResults') || null
820
756
  }, [isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
821
757
  },
822
758
  handleSortChange: function handleSortChange(e) {
823
759
  var index = e.target.value;
824
-
825
760
  if (this.sortOptions && this.sortOptions[index]) {
826
761
  var _ref5;
827
-
828
762
  // This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
829
763
  var options = getQueryOptions(this.$props);
830
764
  options.from = 0;
@@ -833,8 +767,8 @@ var ReactiveList = {
833
767
  options.sort = [(_ref5 = {}, _ref5[sortField] = {
834
768
  order: sortBy
835
769
  }, _ref5)];
836
- this.sortOptionIndex = index; // To handle sort options for RS API
837
-
770
+ this.sortOptionIndex = index;
771
+ // To handle sort options for RS API
838
772
  this.updateComponentProps(this.componentId, {
839
773
  dataField: sortField,
840
774
  sortBy: sortBy
@@ -849,20 +783,16 @@ var ReactiveList = {
849
783
  },
850
784
  triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
851
785
  var docId = documentId;
852
-
853
786
  if (!docId) {
854
787
  var _this$getData = this.getData(),
855
- data = _this$getData.data;
856
-
788
+ data = _this$getData.data;
857
789
  var hitData = data.find(function (hit) {
858
790
  return hit._click_id === searchPosition;
859
791
  });
860
-
861
792
  if (hitData && hitData._id) {
862
793
  docId = hitData._id;
863
794
  }
864
795
  }
865
-
866
796
  this.recordResultClick(searchPosition, docId);
867
797
  },
868
798
  renderSortOptions: function renderSortOptions() {
@@ -890,8 +820,7 @@ var ReactiveList = {
890
820
  },
891
821
  withClickIds: function withClickIds(results) {
892
822
  var _this$getAllData = this.getAllData(),
893
- base = _this$getAllData.base;
894
-
823
+ base = _this$getAllData.base;
895
824
  return results.map(function (result, index) {
896
825
  return _extends({}, result, {
897
826
  _click_id: base + index
@@ -901,11 +830,11 @@ var ReactiveList = {
901
830
  // Shape of the object to be returned in onData & render
902
831
  getAllData: function getAllData() {
903
832
  var size = this.size,
904
- promotedResults = this.promotedResults,
905
- aggregationData = this.aggregationData,
906
- customData = this.customData,
907
- currentPage = this.currentPage,
908
- hits = this.hits;
833
+ promotedResults = this.promotedResults,
834
+ aggregationData = this.aggregationData,
835
+ customData = this.customData,
836
+ currentPage = this.currentPage,
837
+ hits = this.hits;
909
838
  var results = parseHits(hits) || [];
910
839
  var parsedPromotedResults = parseHits(promotedResults) || [];
911
840
  var base = currentPage * size;
@@ -921,10 +850,9 @@ var ReactiveList = {
921
850
  },
922
851
  getData: function getData() {
923
852
  var _this$getAllData2 = this.getAllData(),
924
- promotedResults = _this$getAllData2.promotedResults,
925
- aggregationData = _this$getAllData2.aggregationData,
926
- customData = _this$getAllData2.customData;
927
-
853
+ promotedResults = _this$getAllData2.promotedResults,
854
+ aggregationData = _this$getAllData2.aggregationData,
855
+ customData = _this$getAllData2.customData;
928
856
  return {
929
857
  data: this.data,
930
858
  aggregationData: this.withClickIds(aggregationData || []),
@@ -936,8 +864,7 @@ var ReactiveList = {
936
864
  },
937
865
  getComponent: function getComponent$1() {
938
866
  var error = this.error,
939
- isLoading = this.isLoading;
940
-
867
+ isLoading = this.isLoading;
941
868
  var data = _extends({
942
869
  error: error,
943
870
  loading: isLoading || false,
@@ -945,12 +872,10 @@ var ReactiveList = {
945
872
  triggerClickAnalytics: this.triggerClickAnalytics,
946
873
  setPage: this.setPage
947
874
  }, this.getData());
948
-
949
875
  return getComponent(data, this);
950
876
  }
951
877
  }
952
878
  };
953
-
954
879
  var mapStateToProps = function mapStateToProps(state, props) {
955
880
  return {
956
881
  defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
@@ -972,7 +897,6 @@ var mapStateToProps = function mapStateToProps(state, props) {
972
897
  isLoading: state.isLoading[props.componentId]
973
898
  };
974
899
  };
975
-
976
900
  var mapDispatchtoProps = {
977
901
  loadMoreAction: loadMore,
978
902
  setPageURL: setValue,
@@ -981,70 +905,58 @@ var mapDispatchtoProps = {
981
905
  updateComponentProps: updateComponentProps,
982
906
  setDefaultQuery: setDefaultQuery,
983
907
  recordResultClick: recordResultClick
984
- }; // Only used for SSR
985
-
908
+ };
909
+ // Only used for SSR
986
910
  ReactiveList.generateQueryOptions = function (props) {
987
911
  var options = getQueryOptions(props);
988
912
  var size = props.size,
989
- dataField = props.dataField,
990
- defaultSortOption = props.defaultSortOption,
991
- sortOptionsNew = props.sortOptions,
992
- currentPage = props.currentPage,
993
- sortBy = props.sortBy;
913
+ dataField = props.dataField,
914
+ defaultSortOption = props.defaultSortOption,
915
+ sortOptionsNew = props.sortOptions,
916
+ currentPage = props.currentPage,
917
+ sortBy = props.sortBy;
994
918
  options.from = currentPage ? (currentPage - 1) * (size || 10) : 0;
995
919
  options.size = size || 10;
996
-
997
920
  var getSortOption = function getSortOption() {
998
921
  var _ref7;
999
-
1000
922
  if (defaultSortOption) {
1001
923
  var sortOption = sortOptionsNew.find(function (option) {
1002
924
  return option.label === defaultSortOption;
1003
925
  });
1004
-
1005
926
  if (sortOption) {
1006
927
  var _ref6;
1007
-
1008
928
  return _ref6 = {}, _ref6[sortOption.dataField] = {
1009
929
  order: sortOption.sortBy
1010
930
  }, _ref6;
1011
931
  }
1012
932
  }
1013
-
1014
933
  return _ref7 = {}, _ref7[sortOptionsNew[0].dataField] = {
1015
934
  order: sortOptionsNew[0].sortBy
1016
935
  }, _ref7;
1017
936
  };
1018
-
1019
937
  if (sortOptionsNew) {
1020
938
  options.sort = [getSortOption()];
1021
939
  } else if (sortBy) {
1022
940
  var _ref8;
1023
-
1024
941
  options.sort = [(_ref8 = {}, _ref8[dataField] = {
1025
942
  order: sortBy
1026
943
  }, _ref8)];
1027
944
  }
1028
-
1029
945
  return options;
1030
946
  };
1031
-
1032
947
  ReactiveList.hasInternalComponent = function () {
1033
948
  return true;
1034
949
  };
1035
-
1036
950
  var RLConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
1037
951
  componentType: componentTypes.reactiveList,
1038
952
  internalComponent: ReactiveList.hasInternalComponent()
1039
953
  }));
1040
-
1041
954
  ReactiveList.install = function (Vue) {
1042
955
  Vue.component(ReactiveList.name, RLConnected);
1043
956
  Vue.component(ResultListWrapper.name, ResultListWrapper);
1044
957
  Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
1045
- }; // Add componentType for SSR
1046
-
1047
-
958
+ };
959
+ // Add componentType for SSR
1048
960
  ReactiveList.componentType = componentTypes.reactiveList;
1049
961
 
1050
962
  export default ReactiveList;