@appbaseio/reactivesearch-vue 1.16.0-alpha.3 → 1.16.0-alpha.32

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 (101) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +6388 -5403
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/Button-d2f1aeda.js +68 -0
  6. package/dist/cjs/{DownShift-b09da079.js → CancelSvg-82021d23.js} +60 -16
  7. package/dist/cjs/Card-4b915733.js +30 -0
  8. package/dist/cjs/{ComponentWrapper-5a0a8849.js → ComponentWrapper-7302fe1a.js} +40 -21
  9. package/dist/cjs/{Container-f84e72fc.js → Container-8a08d663.js} +3 -11
  10. package/dist/cjs/DataSearch.js +341 -391
  11. package/dist/cjs/{DropDown-c66be1a8.js → DropDown-c46d8b0c.js} +80 -95
  12. package/dist/cjs/DynamicRangeSlider.js +81 -25
  13. package/dist/cjs/Flex-699639d2.js +52 -0
  14. package/dist/cjs/FormControlList-73497794.js +47 -0
  15. package/dist/cjs/Input-c6f181d5.js +79 -0
  16. package/dist/cjs/ListItem-933c27e4.js +46 -0
  17. package/dist/cjs/MultiDropdownList.js +71 -46
  18. package/dist/cjs/MultiList.js +49 -29
  19. package/dist/cjs/MultiRange.js +20 -14
  20. package/dist/cjs/{Pagination-91df3b77.js → Pagination-1b2320a7.js} +4 -3
  21. package/dist/cjs/RangeInput.js +29 -45
  22. package/dist/cjs/RangeSlider.js +31 -28
  23. package/dist/cjs/ReactiveBase.js +55 -34
  24. package/dist/cjs/ReactiveComponent.js +80 -36
  25. package/dist/cjs/ReactiveGoogleMap.js +326 -235
  26. package/dist/cjs/ReactiveList.js +149 -202
  27. package/dist/cjs/ResultCard.js +8 -6
  28. package/dist/cjs/ResultList.js +8 -6
  29. package/dist/cjs/SelectedFilters.js +25 -12
  30. package/dist/cjs/SingleDropdownList.js +70 -45
  31. package/dist/cjs/SingleList.js +44 -26
  32. package/dist/cjs/SingleRange.js +17 -11
  33. package/dist/cjs/StateProvider.js +11 -7
  34. package/dist/cjs/{Title-e9beb554.js → Title-39765ee6.js} +3 -11
  35. package/dist/cjs/ToggleButton.js +35 -16
  36. package/dist/cjs/{_rollupPluginBabelHelpers-280a574c.js → _rollupPluginBabelHelpers-4abdbfff.js} +11 -1
  37. package/dist/cjs/{index-e0583d76.js → index-d44a0a21.js} +87 -13
  38. package/dist/cjs/index.js +23 -19
  39. package/dist/cjs/initReactivesearch.js +80 -38
  40. package/dist/cjs/install.js +20 -18
  41. package/dist/cjs/ssr-c333c82c.js +39 -0
  42. package/dist/cjs/{utils-d1ea9f95.js → utils-23afb20b.js} +2 -2
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/cjs/{vueTypes-c21f265b.js → vueTypes-6de9d2a9.js} +9 -4
  45. package/dist/es/Button-799185e2.js +59 -0
  46. package/dist/es/{DownShift-d8f2500f.js → CancelSvg-4d9e0857.js} +56 -17
  47. package/dist/es/Card-04b3c33e.js +23 -0
  48. package/dist/es/{ComponentWrapper-d0b21b95.js → ComponentWrapper-bbb717bc.js} +40 -21
  49. package/dist/es/Container-4383c6f0.js +10 -0
  50. package/dist/es/DataSearch.js +339 -389
  51. package/dist/es/{DropDown-5dbd69c2.js → DropDown-4edaa621.js} +79 -94
  52. package/dist/es/DynamicRangeSlider.js +81 -25
  53. package/dist/es/Flex-aac91505.js +47 -0
  54. package/dist/es/FormControlList-fe389a2e.js +40 -0
  55. package/dist/es/Input-d8519224.js +71 -0
  56. package/dist/es/ListItem-bdb6d53d.js +39 -0
  57. package/dist/es/MultiDropdownList.js +71 -46
  58. package/dist/es/MultiList.js +49 -29
  59. package/dist/es/MultiRange.js +20 -14
  60. package/dist/es/{Pagination-800af44f.js → Pagination-b3e4054a.js} +4 -3
  61. package/dist/es/RangeInput.js +29 -45
  62. package/dist/es/RangeSlider.js +31 -28
  63. package/dist/es/ReactiveBase.js +55 -34
  64. package/dist/es/ReactiveComponent.js +80 -36
  65. package/dist/es/ReactiveGoogleMap.js +326 -235
  66. package/dist/es/ReactiveList.js +149 -202
  67. package/dist/es/ResultCard.js +8 -6
  68. package/dist/es/ResultList.js +8 -6
  69. package/dist/es/SelectedFilters.js +25 -12
  70. package/dist/es/SingleDropdownList.js +70 -45
  71. package/dist/es/SingleList.js +44 -26
  72. package/dist/es/SingleRange.js +17 -11
  73. package/dist/es/StateProvider.js +11 -7
  74. package/dist/es/Title-579f8d6c.js +10 -0
  75. package/dist/es/ToggleButton.js +35 -16
  76. package/dist/es/{_rollupPluginBabelHelpers-c9fbe19f.js → _rollupPluginBabelHelpers-ecf6c03c.js} +11 -1
  77. package/dist/es/{index-1fe91a0a.js → index-5daa8276.js} +84 -14
  78. package/dist/es/index.js +23 -19
  79. package/dist/es/initReactivesearch.js +80 -38
  80. package/dist/es/install.js +20 -18
  81. package/dist/es/ssr-e3196de1.js +33 -0
  82. package/dist/es/{utils-ce3d86fd.js → utils-3a32e13f.js} +2 -2
  83. package/dist/es/version.js +1 -1
  84. package/dist/es/{vueTypes-98d938a9.js → vueTypes-9326e0be.js} +9 -4
  85. package/package.json +86 -78
  86. package/dist/cjs/Button-78d8bc26.js +0 -146
  87. package/dist/cjs/Card-b4af314f.js +0 -58
  88. package/dist/cjs/Flex-737c55be.js +0 -160
  89. package/dist/cjs/FormControlList-08dfb28e.js +0 -105
  90. package/dist/cjs/Input-643d02a7.js +0 -178
  91. package/dist/cjs/ListItem-0c58c5d2.js +0 -84
  92. package/dist/cjs/ssr-b7a729f9.js +0 -47
  93. package/dist/es/Button-6c71c66e.js +0 -137
  94. package/dist/es/Card-ecf70ba1.js +0 -51
  95. package/dist/es/Container-f5efec9e.js +0 -18
  96. package/dist/es/Flex-40a74d8a.js +0 -155
  97. package/dist/es/FormControlList-b96aebef.js +0 -98
  98. package/dist/es/Input-dfd9dd40.js +0 -170
  99. package/dist/es/ListItem-da73bc7d.js +0 -77
  100. package/dist/es/Title-22c2f3bf.js +0 -18
  101. package/dist/es/ssr-2f57791d.js +0 -41
@@ -1,33 +1,26 @@
1
1
  import { Actions, helper } from '@appbaseio/reactivecore';
2
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-c9fbe19f.js';
2
+ import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ecf6c03c.js';
3
3
  import VueTypes from 'vue-types';
4
4
  import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
+ import { withClickIds } from '@appbaseio/reactivecore/lib/utils/helper';
5
6
  import { css } from 'emotion';
6
7
  import styled from '@appbaseio/vue-emotion';
7
8
  import 'polished';
8
- import './Button-6c71c66e.js';
9
- import { t as types } from './vueTypes-98d938a9.js';
10
- import { P as Pagination } from './Pagination-800af44f.js';
9
+ import './Button-799185e2.js';
10
+ import { t as types } from './vueTypes-9326e0be.js';
11
+ import { P as Pagination } from './Pagination-b3e4054a.js';
11
12
  import '@appbaseio/reactivecore/lib/utils/transform';
12
13
  import 'redux';
13
- import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-1fe91a0a.js';
14
- import { C as ComponentWrapper } from './ComponentWrapper-d0b21b95.js';
14
+ import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-5daa8276.js';
15
+ import { C as ComponentWrapper } from './ComponentWrapper-bbb717bc.js';
15
16
  import _mergeJSXProps from '@vue/babel-helper-vue-jsx-merge-props';
16
- import './Title-22c2f3bf.js';
17
- import { c as container } from './ListItem-da73bc7d.js';
18
- import { c as container$1 } from './Card-ecf70ba1.js';
19
- import { F as Flex } from './Flex-40a74d8a.js';
17
+ import './Title-579f8d6c.js';
18
+ import { c as container } from './ListItem-bdb6d53d.js';
19
+ import { c as container$1 } from './Card-04b3c33e.js';
20
+ import { F as Flex } from './Flex-aac91505.js';
20
21
 
21
- function _templateObject() {
22
- var data = _taggedTemplateLiteralLoose(["\n\twidth: 110px;\n"]);
23
-
24
- _templateObject = function _templateObject() {
25
- return data;
26
- };
27
-
28
- return data;
29
- }
30
- var PoweredByImage = styled('img')(_templateObject());
22
+ var _templateObject;
23
+ var PoweredByImage = styled('img')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\twidth: 110px;\n"])));
31
24
 
32
25
  var PoweredBy = {
33
26
  functional: true,
@@ -84,27 +77,9 @@ ResultCardsWrapper.install = function (Vue) {
84
77
  Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
85
78
  };
86
79
 
87
- function _templateObject2() {
88
- var data = _taggedTemplateLiteralLoose(["\n\tcolor: #424242;\n\theight: 32px;\n\tfont-size: 0.82rem;\n\tpadding: 0 25px 0 10px;\n\tbackground: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+)\n\t\tno-repeat 95% 50%;\n\tbackground-color: #fff;\n\t-moz-appearance: none;\n\t-webkit-appearance: none;\n\tappearance: none;\n\t-webkit-border-radius: 0;\n\tborder-radius: 0;\n\tborder: 0;\n\toutline: 1px solid #ddd;\n\toutline-offset: -1px;\n"]);
89
-
90
- _templateObject2 = function _templateObject2() {
91
- return data;
92
- };
93
-
94
- return data;
95
- }
96
-
97
- function _templateObject$1() {
98
- var data = _taggedTemplateLiteralLoose(["\n\tflex-grow: 1;\n\tfont-size: 0.82rem;\n"]);
99
-
100
- _templateObject$1 = function _templateObject() {
101
- return data;
102
- };
103
-
104
- return data;
105
- }
106
- var resultStats = css(_templateObject$1());
107
- var sortOptions = css(_templateObject2());
80
+ var _templateObject$1, _templateObject2;
81
+ var resultStats = css(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n\tflex-grow: 1;\n\tfont-size: 0.82rem;\n"])));
82
+ var sortOptions = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tcolor: #424242;\n\theight: 32px;\n\tfont-size: 0.82rem;\n\tpadding: 0 25px 0 10px;\n\tbackground: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+)\n\t\tno-repeat 95% 50%;\n\tbackground-color: #fff;\n\t-moz-appearance: none;\n\t-webkit-appearance: none;\n\tappearance: none;\n\t-webkit-border-radius: 0;\n\tborder-radius: 0;\n\tborder: 0;\n\toutline: 1px solid #ddd;\n\toutline-offset: -1px;\n"])));
108
83
 
109
84
  var recordImpressions = Actions.recordImpressions;
110
85
  var isEqual = helper.isEqual;
@@ -278,8 +253,7 @@ var ImpressionTracker$1 = connect(function () {
278
253
  return null;
279
254
  }, mapDispatchToProps)(ImpressionTracker);
280
255
 
281
- var setStreaming = Actions.setStreaming,
282
- setQueryOptions = Actions.setQueryOptions,
256
+ var setQueryOptions = Actions.setQueryOptions,
283
257
  updateQuery = Actions.updateQuery,
284
258
  loadMore = Actions.loadMore,
285
259
  setValue = Actions.setValue,
@@ -300,16 +274,17 @@ var ReactiveList = {
300
274
  ResultCardsWrapper: ResultCardsWrapper
301
275
  },
302
276
  data: function data() {
303
- var props = this.$props;
304
277
  var currentPageState = 0;
278
+ var defaultPage = this.defaultPage || -1;
305
279
 
306
- if (props.currentPage) {
307
- currentPageState = Math.max(props.currentPage - 1, 0);
280
+ if (defaultPage >= 0) {
281
+ currentPageState = defaultPage;
282
+ } else if (this.currentPage) {
283
+ currentPageState = Math.max(this.currentPage - 1, 0);
308
284
  }
309
285
 
310
286
  this.__state = {
311
- from: currentPageState * props.size,
312
- isLoading: true,
287
+ from: currentPageState * this.size,
313
288
  currentPageState: currentPageState
314
289
  };
315
290
  return this.__state;
@@ -319,29 +294,41 @@ var ReactiveList = {
319
294
 
320
295
  var _this$$props = this.$props,
321
296
  distinctField = _this$$props.distinctField,
322
- distinctFieldConfig = _this$$props.distinctFieldConfig; // no support for pagination and aggregationField together
297
+ distinctFieldConfig = _this$$props.distinctFieldConfig,
298
+ index = _this$$props.index; // no support for pagination and aggregationField together
323
299
 
324
300
  if (this.pagination && this.aggregationField) {
325
301
  console.warn('Pagination is not supported when aggregationField is present. The list will be rendered with infinite scroll');
326
302
  }
327
303
 
328
- if (this.config.enableAppbase && this.aggregationField && this.aggregationField !== '') {
304
+ if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
329
305
  console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
330
306
  }
331
307
 
332
- if (!this.config.enableAppbase && (distinctField || distinctFieldConfig)) {
308
+ if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
333
309
  console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
334
310
  }
335
311
 
336
- if (this.defaultPage >= 0) {
337
- this.currentPageState = this.defaultPage;
312
+ if (!this.enableAppbase && index) {
313
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
314
+ }
315
+
316
+ var defaultPage = this.defaultPage || -1;
317
+
318
+ if (defaultPage >= 0) {
319
+ this.currentPageState = defaultPage;
338
320
  this.from = this.currentPageState * this.$props.size;
339
321
  }
340
322
 
341
323
  this.internalComponent = this.$props.componentId + "__internal";
342
- this.sortOptionIndex = this.defaultSortOption ? this.sortOptions.findIndex(function (s) {
343
- return s.label === _this.defaultSortOption;
344
- }) : 0;
324
+ this.sortOptionIndex = 0;
325
+
326
+ if (this.defaultSortOption && this.sortOptions && Array.isArray(this.sortOptions)) {
327
+ this.sortOptionIndex = this.sortOptions.findIndex(function (s) {
328
+ return s.label === _this.defaultSortOption;
329
+ });
330
+ }
331
+
345
332
  this.updateComponentProps(this.componentId, {
346
333
  from: this.from
347
334
  }, componentTypes.reactiveList);
@@ -351,7 +338,7 @@ var ReactiveList = {
351
338
  },
352
339
  props: {
353
340
  currentPage: VueTypes.number.def(0),
354
- includeFields: types.includeFields.def(['*']),
341
+ includeFields: types.includeFields,
355
342
  // component props
356
343
  className: types.string,
357
344
  componentId: types.stringRequired,
@@ -360,7 +347,7 @@ var ReactiveList = {
360
347
  aggregationSize: VueTypes.number,
361
348
  defaultQuery: types.func,
362
349
  defaultSortOption: types.string,
363
- excludeFields: types.excludeFields.def([]),
350
+ excludeFields: types.excludeFields,
364
351
  innerClass: types.style,
365
352
  listClass: VueTypes.string.def(''),
366
353
  loader: types.title,
@@ -372,7 +359,7 @@ var ReactiveList = {
372
359
  pages: VueTypes.number.def(5),
373
360
  pagination: VueTypes.bool.def(false),
374
361
  infiniteScroll: VueTypes.bool.def(true),
375
- paginationAt: types.paginationAt.def('bottom'),
362
+ paginationAt: VueTypes.oneOf(['top', 'bottom', 'both']).def('bottom'),
376
363
  react: types.react,
377
364
  scrollOnChange: VueTypes.bool.def(true),
378
365
  showResultStats: VueTypes.bool.def(true),
@@ -380,12 +367,12 @@ var ReactiveList = {
380
367
  size: VueTypes.number.def(10),
381
368
  sortBy: types.sortBy,
382
369
  sortOptions: types.sortOptions,
383
- stream: types.bool,
384
370
  URLParams: VueTypes.bool.def(false),
385
371
  prevLabel: types.string,
386
372
  nextLabel: types.string,
387
373
  distinctField: types.string,
388
- distinctFieldConfig: types.props
374
+ distinctFieldConfig: types.props,
375
+ index: VueTypes.string
389
376
  },
390
377
  computed: {
391
378
  shouldRenderPagination: function shouldRenderPagination() {
@@ -401,12 +388,9 @@ var ReactiveList = {
401
388
  return this.$listeners && this.$listeners.resultStats;
402
389
  },
403
390
  stats: function stats() {
404
- var _this$getAllData = this.getAllData(),
405
- filteredResults = _this$getAllData.filteredResults;
406
-
407
- return _extends(_extends({}, getResultStats(this)), {}, {
391
+ return _extends({}, getResultStats(this), {
408
392
  currentPage: this.currentPageState,
409
- displayedResults: filteredResults.length
393
+ displayedResults: this.data.length
410
394
  });
411
395
  },
412
396
  hasCustomRender: function hasCustomRender() {
@@ -415,6 +399,27 @@ var ReactiveList = {
415
399
  showInfiniteScroll: function showInfiniteScroll() {
416
400
  // Pagination has higher priority then infinite scroll
417
401
  return this.infiniteScroll && !this.shouldRenderPagination;
402
+ },
403
+ data: function data() {
404
+ var results = parseHits(this.hits) || [];
405
+ var parsedPromotedResults = parseHits(this.promotedResults) || [];
406
+ var filteredResults = results;
407
+
408
+ if (parsedPromotedResults.length) {
409
+ var ids = parsedPromotedResults.map(function (item) {
410
+ return item._id;
411
+ }).filter(Boolean);
412
+
413
+ if (ids) {
414
+ filteredResults = filteredResults.filter(function (item) {
415
+ return !ids.includes(item._id);
416
+ });
417
+ }
418
+
419
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
420
+ }
421
+
422
+ return withClickIds(filteredResults);
418
423
  }
419
424
  },
420
425
  watch: {
@@ -465,12 +470,12 @@ var ReactiveList = {
465
470
  var queryOptions = getOptionsFromQuery(this.$defaultQuery);
466
471
 
467
472
  if (queryOptions) {
468
- options = _extends(_extends({}, options), getOptionsFromQuery(this.$defaultQuery));
473
+ options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery));
469
474
  } // Update calculated default query in store
470
475
 
471
476
 
472
477
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
473
- this.setQueryOptions(this.$props.componentId, _extends(_extends({}, options), this.getAggsQuery()), !query);
478
+ this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), !query);
474
479
  this.updateQuery({
475
480
  componentId: this.internalComponent,
476
481
  query: query
@@ -480,14 +485,6 @@ var ReactiveList = {
480
485
  this.from = 0;
481
486
  }
482
487
  },
483
- stream: function stream(newVal, oldVal) {
484
- if (oldVal !== newVal) {
485
- this.setStreaming(this.$props.componentId, newVal);
486
- }
487
- },
488
- streamHits: function streamHits() {
489
- this.$emit('data', this.getData());
490
- },
491
488
  promotedResults: function promotedResults(newVal, oldVal) {
492
489
  if (!isEqual$1(newVal, oldVal)) {
493
490
  this.$emit('data', this.getData());
@@ -504,7 +501,7 @@ var ReactiveList = {
504
501
  }
505
502
  },
506
503
  hits: function hits(newVal, oldVal) {
507
- this.$emit('data', this.getAllData());
504
+ this.$emit('data', this.getData());
508
505
 
509
506
  if (this.shouldRenderPagination) {
510
507
  // called when page is changed
@@ -549,31 +546,25 @@ var ReactiveList = {
549
546
  } // handle window url history change (on native back and forth interactions)
550
547
 
551
548
  },
552
- defaultPage: function defaultPage(newVal) {
553
- if (this.currentPageState !== newVal && this.defaultPage !== newVal) {
549
+ defaultPage: function defaultPage(newVal, oldVal) {
550
+ if (this.currentPageState !== newVal && oldVal !== newVal) {
554
551
  this.setPage(newVal >= 0 ? newVal : 0);
555
552
  }
556
553
  }
557
554
  },
558
555
  mounted: function mounted() {
559
- if (this.$props.stream) {
560
- this.setStreaming(this.$props.componentId, true);
561
- }
562
-
563
556
  if (this.defaultPage < 0 && this.currentPage > 0) {
564
- if (this.$props.URLParams) {
565
- this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, true);
566
- }
557
+ this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, this.URLParams);
567
558
  }
568
559
 
569
560
  var options = getQueryOptions(this.$props);
570
561
  options.from = this.$data.from;
571
562
 
572
- if (this.$props.sortOptions) {
563
+ if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
573
564
  var _ref2;
574
565
 
575
- var sortField = this.$props.sortOptions[this.sortOptionIndex].dataField;
576
- var sortBy = this.$props.sortOptions[this.sortOptionIndex].sortBy;
566
+ var sortField = this.sortOptions[this.sortOptionIndex].dataField;
567
+ var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
577
568
  options.sort = [(_ref2 = {}, _ref2[sortField] = {
578
569
  order: sortBy
579
570
  }, _ref2)]; // To handle sort options for RS API
@@ -595,7 +586,7 @@ var ReactiveList = {
595
586
 
596
587
  if (this.$props.defaultQuery) {
597
588
  this.$defaultQuery = this.$props.defaultQuery();
598
- options = _extends(_extends({}, options), getOptionsFromQuery(this.$defaultQuery));
589
+ options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery));
599
590
 
600
591
  if (this.$defaultQuery.sort) {
601
592
  options.sort = this.$defaultQuery.sort;
@@ -610,7 +601,7 @@ var ReactiveList = {
610
601
  query = _ref4.query;
611
602
 
612
603
  var execute = false;
613
- this.setQueryOptions(this.$props.componentId, _extends(_extends({}, options), this.getAggsQuery()), execute);
604
+ this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), execute);
614
605
 
615
606
  if (this.$defaultQuery) {
616
607
  this.updateQuery({
@@ -638,16 +629,15 @@ var ReactiveList = {
638
629
  var h = arguments[0];
639
630
  var hits = this.$data.hits;
640
631
  var results = parseHits(hits) || [];
641
- var streamResults = parseHits(this.$data.streamHits) || [];
642
632
  return h("div", {
643
633
  "style": this.$props.style,
644
634
  "class": this.$props.className
645
635
  }, [this.isLoading && this.shouldRenderPagination && this.showInfiniteScroll && (this.$scopedSlots.loader || this.$props.loader), this.renderErrorComponent(), h(Flex, {
646
636
  "attrs": {
647
- "labelPosition": this.$props.sortOptions ? 'right' : 'left'
637
+ "labelPosition": this.sortOptions ? 'right' : 'left'
648
638
  },
649
639
  "class": getClassName(this.$props.innerClass, 'resultsInfo')
650
- }, [this.$props.sortOptions ? this.renderSortOptions() : null, this.$props.showResultStats ? this.renderStats() : null]), !this.isLoading && results.length === 0 && streamResults.length === 0 ? this.renderNoResult() : null, this.shouldRenderPagination && (this.$props.paginationAt === 'top' || this.$props.paginationAt === 'both') ? h(Pagination, {
640
+ }, [this.sortOptions ? this.renderSortOptions() : null, this.$props.showResultStats && results.length ? this.renderStats() : null]), !this.isLoading && results.length === 0 ? this.renderNoResult() : null, this.shouldRenderPagination && (this.$props.paginationAt === 'top' || this.$props.paginationAt === 'both') ? h(Pagination, {
651
641
  "attrs": {
652
642
  "pages": this.$props.pages,
653
643
  "totalPages": this.totalPages,
@@ -657,7 +647,7 @@ var ReactiveList = {
657
647
  "prevLabel": this.$props.prevLabel,
658
648
  "nextLabel": this.$props.nextLabel
659
649
  }
660
- }) : null, this.renderResults(), this.isLoading && !this.shouldRenderPagination ? this.$props.loader || h("div", {
650
+ }) : null, this.renderResults(), this.isLoading && !this.shouldRenderPagination ? this.$scopedSlots.loader || this.$props.loader || h("div", {
661
651
  "style": {
662
652
  textAlign: 'center',
663
653
  margin: '20px 0',
@@ -674,7 +664,7 @@ var ReactiveList = {
674
664
  "prevLabel": this.$props.prevLabel,
675
665
  "nextLabel": this.$props.nextLabel
676
666
  }
677
- }) : null, this.config.url.endsWith('appbase.io') && results.length ? h(Flex, {
667
+ }) : null, this.url.endsWith('appbase.io') && results.length ? h(Flex, {
678
668
  "attrs": {
679
669
  "direction": "row-reverse"
680
670
  },
@@ -696,24 +686,10 @@ var ReactiveList = {
696
686
 
697
687
  var h = this.$createElement;
698
688
  var size = this.$props.size;
699
- var hits = this.$data.hits;
700
- var results = parseHits(hits) || [];
701
- var streamResults = parseHits(this.$data.streamHits) || [];
702
- var filteredResults = results;
703
689
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
704
-
705
- if (streamResults.length) {
706
- var ids = streamResults.map(function (item) {
707
- return item._id;
708
- });
709
- filteredResults = filteredResults.filter(function (item) {
710
- return !ids.includes(item._id);
711
- });
712
- }
713
-
714
690
  var element = this.hasCustomRender ? this.getComponent() : h("div", {
715
691
  "class": this.$props.listClass + " " + getClassName(this.$props.innerClass, 'list')
716
- }, [[].concat(streamResults, filteredResults).map(function (item, index) {
692
+ }, [this.data.map(function (item, index) {
717
693
  return renderItem({
718
694
  item: item,
719
695
  triggerClickAnalytics: function triggerClickAnalytics() {
@@ -724,7 +700,7 @@ var ReactiveList = {
724
700
 
725
701
  return this.analytics ? h(ImpressionTracker$1, {
726
702
  "attrs": {
727
- "hits": filteredResults
703
+ "hits": this.data
728
704
  }
729
705
  }, [element]) : element;
730
706
  },
@@ -732,15 +708,18 @@ var ReactiveList = {
732
708
  var options = getQueryOptions(props);
733
709
  options.from = this.$data.from;
734
710
 
735
- if (props.sortOptions) {
736
- var _ref5;
737
-
711
+ if (props.sortOptions && Array.isArray(props.sortOptions)) {
738
712
  var sortOptionIndex = props.defaultSortOption ? props.sortOptions.findIndex(function (s) {
739
713
  return s.label === props.defaultSortOption;
740
714
  }) : 0;
741
- options.sort = [(_ref5 = {}, _ref5[props.sortOptions[sortOptionIndex].dataField] = {
742
- order: props.sortOptions[sortOptionIndex].sortBy
743
- }, _ref5)];
715
+
716
+ if (props.sortOptions[sortOptionIndex]) {
717
+ var _ref5;
718
+
719
+ options.sort = [(_ref5 = {}, _ref5[props.sortOptions[sortOptionIndex].dataField] = {
720
+ order: props.sortOptions[sortOptionIndex].sortBy
721
+ }, _ref5)];
722
+ }
744
723
  } else if (props.sortBy) {
745
724
  var _ref6;
746
725
 
@@ -749,7 +728,7 @@ var ReactiveList = {
749
728
  }, _ref6)];
750
729
  }
751
730
 
752
- this.setQueryOptions(this.$props.componentId, _extends(_extends({}, options), this.getAggsQuery()), true);
731
+ this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), true);
753
732
  },
754
733
  getAggsQuery: function getAggsQuery() {
755
734
  var _this$$props2 = this.$props,
@@ -791,12 +770,12 @@ var ReactiveList = {
791
770
  return;
792
771
  }
793
772
 
794
- var options = _extends(_extends({}, getQueryOptions(this.$props)), this.getAggsQuery());
773
+ var options = _extends({}, getQueryOptions(this.$props), this.getAggsQuery());
795
774
 
796
775
  this.from = value; // Update default query to support pagination for aggregationField
797
776
 
798
777
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
799
- this.loadMoreAction(this.$props.componentId, _extends(_extends({}, options), {}, {
778
+ this.loadMoreAction(this.$props.componentId, _extends({}, options, {
800
779
  from: value
801
780
  }), true, !!this.aggregationField);
802
781
  }
@@ -811,13 +790,10 @@ var ReactiveList = {
811
790
  options.from = this.$data.from;
812
791
  this.from = value;
813
792
  this.currentPageState = page;
814
- this.loadMoreAction(this.$props.componentId, _extends(_extends({}, options), {}, {
793
+ this.loadMoreAction(this.$props.componentId, _extends({}, options, {
815
794
  from: value
816
795
  }), false);
817
-
818
- if (this.$props.URLParams) {
819
- this.setPageURL(this.$props.componentId, page + 1, this.$props.componentId, false, true);
820
- }
796
+ this.setPageURL(this.$props.componentId, page + 1, this.$props.componentId, false, this.URLParams);
821
797
  }
822
798
  },
823
799
  renderStats: function renderStats() {
@@ -831,7 +807,7 @@ var ReactiveList = {
831
807
  if (this.stats.numberOfResults) {
832
808
  return h("p", {
833
809
  "class": resultStats + " " + getClassName(this.$props.innerClass, 'resultStats')
834
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
810
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
835
811
  }
836
812
 
837
813
  return null;
@@ -839,31 +815,39 @@ var ReactiveList = {
839
815
  renderNoResult: function renderNoResult() {
840
816
  var h = this.$createElement;
841
817
  var renderNoResults = this.$scopedSlots.renderNoResults || this.$props.renderNoResults;
818
+
819
+ if (this.$scopedSlots.renderNoResults) {
820
+ return isFunction(renderNoResults) ? renderNoResults() : renderNoResults;
821
+ }
822
+
842
823
  return h("p", {
843
824
  "class": getClassName(this.$props.innerClass, 'noResults') || null
844
825
  }, [isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
845
826
  },
846
827
  handleSortChange: function handleSortChange(e) {
847
- var _ref7;
848
-
849
- var index = e.target.value; // This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
828
+ var index = e.target.value;
850
829
 
851
- var options = getQueryOptions(this.$props);
852
- options.from = 0;
853
- var sortField = this.$props.sortOptions[index].dataField;
854
- var sortBy = this.$props.sortOptions[index].sortBy;
855
- options.sort = [(_ref7 = {}, _ref7[sortField] = {
856
- order: sortBy
857
- }, _ref7)];
858
- this.sortOptionIndex = index; // To handle sort options for RS API
830
+ if (this.sortOptions && this.sortOptions[index]) {
831
+ var _ref7;
859
832
 
860
- this.updateComponentProps(this.componentId, {
861
- dataField: sortField,
862
- sortBy: sortBy
863
- }, componentTypes.reactiveList);
864
- this.setQueryOptions(this.$props.componentId, options, true);
865
- this.currentPageState = 0;
866
- this.from = 0;
833
+ // This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
834
+ var options = getQueryOptions(this.$props);
835
+ options.from = 0;
836
+ var sortField = this.sortOptions[index].dataField;
837
+ var sortBy = this.sortOptions[index].sortBy;
838
+ options.sort = [(_ref7 = {}, _ref7[sortField] = {
839
+ order: sortBy
840
+ }, _ref7)];
841
+ this.sortOptionIndex = index; // To handle sort options for RS API
842
+
843
+ this.updateComponentProps(this.componentId, {
844
+ dataField: sortField,
845
+ sortBy: sortBy
846
+ }, componentTypes.reactiveList);
847
+ this.setQueryOptions(this.$props.componentId, options, true);
848
+ this.currentPageState = 0;
849
+ this.from = 0;
850
+ }
867
851
  },
868
852
  triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
869
853
  var docId = documentId;
@@ -897,7 +881,7 @@ var ReactiveList = {
897
881
  "domProps": {
898
882
  "value": this.sortOptionIndex
899
883
  }
900
- }, [this.$props.sortOptions.map(function (sort, index) {
884
+ }, [this.sortOptions.map(function (sort, index) {
901
885
  return h("option", {
902
886
  "key": sort.label,
903
887
  "domProps": {
@@ -907,11 +891,11 @@ var ReactiveList = {
907
891
  })]);
908
892
  },
909
893
  withClickIds: function withClickIds(results) {
910
- var _this$getAllData2 = this.getAllData(),
911
- base = _this$getAllData2.base;
894
+ var _this$getAllData = this.getAllData(),
895
+ base = _this$getAllData.base;
912
896
 
913
897
  return results.map(function (result, index) {
914
- return _extends(_extends({}, result), {}, {
898
+ return _extends({}, result, {
915
899
  _click_id: base + index
916
900
  });
917
901
  });
@@ -923,41 +907,12 @@ var ReactiveList = {
923
907
  aggregationData = this.aggregationData,
924
908
  customData = this.customData,
925
909
  currentPage = this.currentPage,
926
- hits = this.hits,
927
- streamHits = this.streamHits;
910
+ hits = this.hits;
928
911
  var results = parseHits(hits) || [];
929
- var streamResults = parseHits(streamHits) || [];
930
912
  var parsedPromotedResults = parseHits(promotedResults) || [];
931
- var filteredResults = results;
932
913
  var base = currentPage * size;
933
-
934
- if (streamResults.length) {
935
- var ids = streamResults.map(function (item) {
936
- return item._id;
937
- });
938
- filteredResults = filteredResults.filter(function (item) {
939
- return !ids.includes(item._id);
940
- });
941
- }
942
-
943
- if (parsedPromotedResults.length) {
944
- var _ids = parsedPromotedResults.map(function (item) {
945
- return item._id;
946
- }).filter(Boolean);
947
-
948
- if (_ids) {
949
- filteredResults = filteredResults.filter(function (item) {
950
- return !_ids.includes(item._id);
951
- });
952
- }
953
-
954
- filteredResults = [].concat(streamResults, parsedPromotedResults, filteredResults);
955
- }
956
-
957
914
  return {
958
915
  results: results,
959
- streamResults: streamResults,
960
- filteredResults: filteredResults,
961
916
  customData: customData || {},
962
917
  promotedResults: parsedPromotedResults,
963
918
  aggregationData: aggregationData,
@@ -967,18 +922,15 @@ var ReactiveList = {
967
922
  };
968
923
  },
969
924
  getData: function getData() {
970
- var _this$getAllData3 = this.getAllData(),
971
- streamResults = _this$getAllData3.streamResults,
972
- filteredResults = _this$getAllData3.filteredResults,
973
- promotedResults = _this$getAllData3.promotedResults,
974
- aggregationData = _this$getAllData3.aggregationData,
975
- customData = _this$getAllData3.customData;
925
+ var _this$getAllData2 = this.getAllData(),
926
+ promotedResults = _this$getAllData2.promotedResults,
927
+ aggregationData = _this$getAllData2.aggregationData,
928
+ customData = _this$getAllData2.customData;
976
929
 
977
930
  return {
978
- data: this.withClickIds(filteredResults),
931
+ data: this.data,
979
932
  aggregationData: this.withClickIds(aggregationData || []),
980
- streamData: this.withClickIds(streamResults),
981
- promotedData: this.withClickIds(promotedResults),
933
+ promotedData: this.withClickIds(promotedResults || []),
982
934
  rawData: this.rawData,
983
935
  resultStats: this.stats,
984
936
  customData: customData
@@ -990,7 +942,7 @@ var ReactiveList = {
990
942
 
991
943
  var data = _extends({
992
944
  error: error,
993
- loading: isLoading,
945
+ loading: isLoading || false,
994
946
  loadMore: this.loadMore,
995
947
  // TODO: Remove in v2
996
948
  triggerAnalytics: this.triggerClickAnalytics,
@@ -1005,22 +957,22 @@ var ReactiveList = {
1005
957
 
1006
958
  var mapStateToProps = function mapStateToProps(state, props) {
1007
959
  return {
1008
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
960
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
1009
961
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
1010
962
  rawData: state.rawData[props.componentId],
1011
- aggregationData: state.compositeAggregations[props.componentId] || [],
1012
- promotedResults: state.promotedResults[props.componentId] || [],
963
+ aggregationData: state.compositeAggregations[props.componentId],
964
+ promotedResults: state.promotedResults[props.componentId],
1013
965
  customData: state.customData[props.componentId],
1014
- streamHits: state.streamHits[props.componentId],
1015
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
966
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
1016
967
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
1017
968
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
1018
969
  analytics: state.config && state.config.analytics,
1019
- config: state.config,
970
+ enableAppbase: state.config.enableAppbase,
971
+ url: state.config.url,
1020
972
  error: state.error[props.componentId],
1021
973
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
1022
974
  componentProps: state.props[props.componentId],
1023
- isLoading: state.isLoading[props.componentId] || false
975
+ isLoading: state.isLoading[props.componentId]
1024
976
  };
1025
977
  };
1026
978
 
@@ -1028,7 +980,6 @@ var mapDispatchtoProps = {
1028
980
  loadMoreAction: loadMore,
1029
981
  setPageURL: setValue,
1030
982
  setQueryOptions: setQueryOptions,
1031
- setStreaming: setStreaming,
1032
983
  updateQuery: updateQuery,
1033
984
  updateComponentProps: updateComponentProps,
1034
985
  setDefaultQuery: setDefaultQuery,
@@ -1036,11 +987,7 @@ var mapDispatchtoProps = {
1036
987
  }; // Only used for SSR
1037
988
 
1038
989
  ReactiveList.generateQueryOptions = function (props) {
1039
- // simulate default (includeFields and excludeFields) props to generate consistent query
1040
- var options = getQueryOptions(_extends({
1041
- includeFields: ['*'],
1042
- excludeFields: []
1043
- }, props));
990
+ var options = getQueryOptions(props);
1044
991
  var size = props.size,
1045
992
  dataField = props.dataField,
1046
993
  defaultSortOption = props.defaultSortOption,