@appbaseio/reactivesearch-vue 1.23.0 → 1.23.4

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.
@@ -2,6 +2,7 @@ import { helper, Actions } from '@appbaseio/reactivecore';
2
2
  import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-0f24d612.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';
@@ -438,18 +439,17 @@ var ReactiveList = {
438
439
  ResultCardsWrapper: ResultCardsWrapper
439
440
  },
440
441
  data: function data() {
441
- var props = this.$props;
442
442
  var currentPageState = 0;
443
+ var defaultPage = this.defaultPage || -1;
443
444
 
444
- if (props.defaultPage >= 0) {
445
- currentPageState = props.defaultPage;
446
- } else if (props.currentPage) {
447
- currentPageState = Math.max(props.currentPage - 1, 0);
445
+ if (defaultPage >= 0) {
446
+ currentPageState = defaultPage;
447
+ } else if (this.currentPage) {
448
+ currentPageState = Math.max(this.currentPage - 1, 0);
448
449
  }
449
450
 
450
451
  this.__state = {
451
- from: currentPageState * props.size,
452
- isLoading: true,
452
+ from: currentPageState * this.size,
453
453
  currentPageState: currentPageState
454
454
  };
455
455
  return this.__state;
@@ -478,8 +478,10 @@ var ReactiveList = {
478
478
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
479
479
  }
480
480
 
481
- if (this.defaultPage >= 0) {
482
- this.currentPageState = this.defaultPage;
481
+ var defaultPage = this.defaultPage || -1;
482
+
483
+ if (defaultPage >= 0) {
484
+ this.currentPageState = defaultPage;
483
485
  this.from = this.currentPageState * this.$props.size;
484
486
  }
485
487
 
@@ -546,12 +548,9 @@ var ReactiveList = {
546
548
  return this.$listeners && this.$listeners.resultStats;
547
549
  },
548
550
  stats: function stats() {
549
- var _this$getAllData = this.getAllData(),
550
- filteredResults = _this$getAllData.filteredResults;
551
-
552
551
  return _extends({}, getResultStats(this), {
553
552
  currentPage: this.currentPageState,
554
- displayedResults: filteredResults.length
553
+ displayedResults: this.data.length
555
554
  });
556
555
  },
557
556
  hasCustomRender: function hasCustomRender() {
@@ -560,6 +559,27 @@ var ReactiveList = {
560
559
  showInfiniteScroll: function showInfiniteScroll() {
561
560
  // Pagination has higher priority then infinite scroll
562
561
  return this.infiniteScroll && !this.shouldRenderPagination;
562
+ },
563
+ data: function data() {
564
+ var results = parseHits(this.hits) || [];
565
+ var parsedPromotedResults = parseHits(this.promotedResults) || [];
566
+ var filteredResults = results;
567
+
568
+ if (parsedPromotedResults.length) {
569
+ var ids = parsedPromotedResults.map(function (item) {
570
+ return item._id;
571
+ }).filter(Boolean);
572
+
573
+ if (ids) {
574
+ filteredResults = filteredResults.filter(function (item) {
575
+ return !ids.includes(item._id);
576
+ });
577
+ }
578
+
579
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
580
+ }
581
+
582
+ return withClickIds(filteredResults);
563
583
  }
564
584
  },
565
585
  watch: {
@@ -641,7 +661,7 @@ var ReactiveList = {
641
661
  }
642
662
  },
643
663
  hits: function hits(newVal, oldVal) {
644
- this.$emit('data', this.getAllData());
664
+ this.$emit('data', this.getData());
645
665
 
646
666
  if (this.shouldRenderPagination) {
647
667
  // called when page is changed
@@ -826,13 +846,10 @@ var ReactiveList = {
826
846
 
827
847
  var h = this.$createElement;
828
848
  var size = this.$props.size;
829
- var hits = this.$data.hits;
830
- var results = parseHits(hits) || [];
831
- var filteredResults = results;
832
849
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
833
850
  var element = this.hasCustomRender ? this.getComponent() : h("div", {
834
851
  "class": this.$props.listClass + " " + getClassName$1(this.$props.innerClass, 'list')
835
- }, [[].concat(filteredResults).map(function (item, index) {
852
+ }, [this.data.map(function (item, index) {
836
853
  return renderItem({
837
854
  item: item,
838
855
  triggerClickAnalytics: function triggerClickAnalytics() {
@@ -843,7 +860,7 @@ var ReactiveList = {
843
860
 
844
861
  return this.analytics ? h(ImpressionTracker$1, {
845
862
  "attrs": {
846
- "hits": filteredResults
863
+ "hits": this.data
847
864
  }
848
865
  }, [element]) : element;
849
866
  },
@@ -947,7 +964,7 @@ var ReactiveList = {
947
964
  if (this.stats.numberOfResults) {
948
965
  return h("p", {
949
966
  "class": resultStats + " " + getClassName$1(this.$props.innerClass, 'resultStats')
950
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
967
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
951
968
  }
952
969
 
953
970
  return null;
@@ -1023,8 +1040,8 @@ var ReactiveList = {
1023
1040
  })]);
1024
1041
  },
1025
1042
  withClickIds: function withClickIds(results) {
1026
- var _this$getAllData2 = this.getAllData(),
1027
- base = _this$getAllData2.base;
1043
+ var _this$getAllData = this.getAllData(),
1044
+ base = _this$getAllData.base;
1028
1045
 
1029
1046
  return results.map(function (result, index) {
1030
1047
  return _extends({}, result, {
@@ -1042,26 +1059,9 @@ var ReactiveList = {
1042
1059
  hits = this.hits;
1043
1060
  var results = parseHits(hits) || [];
1044
1061
  var parsedPromotedResults = parseHits(promotedResults) || [];
1045
- var filteredResults = results;
1046
1062
  var base = currentPage * size;
1047
-
1048
- if (parsedPromotedResults.length) {
1049
- var ids = parsedPromotedResults.map(function (item) {
1050
- return item._id;
1051
- }).filter(Boolean);
1052
-
1053
- if (ids) {
1054
- filteredResults = filteredResults.filter(function (item) {
1055
- return !ids.includes(item._id);
1056
- });
1057
- }
1058
-
1059
- filteredResults = [].concat(parsedPromotedResults, filteredResults);
1060
- }
1061
-
1062
1063
  return {
1063
1064
  results: results,
1064
- filteredResults: filteredResults,
1065
1065
  customData: customData || {},
1066
1066
  promotedResults: parsedPromotedResults,
1067
1067
  aggregationData: aggregationData,
@@ -1071,16 +1071,15 @@ var ReactiveList = {
1071
1071
  };
1072
1072
  },
1073
1073
  getData: function getData() {
1074
- var _this$getAllData3 = this.getAllData(),
1075
- filteredResults = _this$getAllData3.filteredResults,
1076
- promotedResults = _this$getAllData3.promotedResults,
1077
- aggregationData = _this$getAllData3.aggregationData,
1078
- customData = _this$getAllData3.customData;
1074
+ var _this$getAllData2 = this.getAllData(),
1075
+ promotedResults = _this$getAllData2.promotedResults,
1076
+ aggregationData = _this$getAllData2.aggregationData,
1077
+ customData = _this$getAllData2.customData;
1079
1078
 
1080
1079
  return {
1081
- data: this.withClickIds(filteredResults),
1080
+ data: this.data,
1082
1081
  aggregationData: this.withClickIds(aggregationData || []),
1083
- promotedData: this.withClickIds(promotedResults),
1082
+ promotedData: this.withClickIds(promotedResults || []),
1084
1083
  rawData: this.rawData,
1085
1084
  resultStats: this.stats,
1086
1085
  customData: customData
@@ -1092,7 +1091,7 @@ var ReactiveList = {
1092
1091
 
1093
1092
  var data = _extends({
1094
1093
  error: error,
1095
- loading: isLoading,
1094
+ loading: isLoading || false,
1096
1095
  loadMore: this.loadMore,
1097
1096
  // TODO: Remove in v2
1098
1097
  triggerAnalytics: this.triggerClickAnalytics,
@@ -1107,13 +1106,13 @@ var ReactiveList = {
1107
1106
 
1108
1107
  var mapStateToProps = function mapStateToProps(state, props) {
1109
1108
  return {
1110
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
1109
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
1111
1110
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
1112
1111
  rawData: state.rawData[props.componentId],
1113
- aggregationData: state.compositeAggregations[props.componentId] || [],
1114
- promotedResults: state.promotedResults[props.componentId] || [],
1112
+ aggregationData: state.compositeAggregations[props.componentId],
1113
+ promotedResults: state.promotedResults[props.componentId],
1115
1114
  customData: state.customData[props.componentId],
1116
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
1115
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
1117
1116
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
1118
1117
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
1119
1118
  analytics: state.config && state.config.analytics,
@@ -1122,7 +1121,7 @@ var mapStateToProps = function mapStateToProps(state, props) {
1122
1121
  error: state.error[props.componentId],
1123
1122
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
1124
1123
  componentProps: state.props[props.componentId],
1125
- isLoading: state.isLoading[props.componentId] || false
1124
+ isLoading: state.isLoading[props.componentId]
1126
1125
  };
1127
1126
  };
1128
1127
 
@@ -89,7 +89,7 @@ var StateProvider = {
89
89
  watch: {
90
90
  searchState: function searchState(newVal, oldVal) {
91
91
  if (this.isStateChanged(newVal, oldVal)) {
92
- this.$emit('change', newVal, oldVal);
92
+ this.$emit('change', oldVal, newVal);
93
93
  }
94
94
  },
95
95
  selectedValues: function selectedValues(newVal, oldVal) {
package/dist/es/index.js CHANGED
@@ -2,6 +2,7 @@ import '@appbaseio/reactivecore';
2
2
  import './_rollupPluginBabelHelpers-0f24d612.js';
3
3
  import 'vue-types';
4
4
  import '@appbaseio/reactivecore/lib/utils/constants';
5
+ import '@appbaseio/reactivecore/lib/utils/helper';
5
6
  import 'emotion';
6
7
  import '@appbaseio/vue-emotion';
7
8
  import 'polished';
@@ -17,7 +18,6 @@ import './Title-3522ff56.js';
17
18
  import './ListItem-8e8fb535.js';
18
19
  import './Card-6446f1b7.js';
19
20
  import './Flex-8770345d.js';
20
- import '@appbaseio/reactivecore/lib/utils/helper';
21
21
  import '@appbaseio/reactivecore/lib/actions/analytics';
22
22
  import 'appbase-js';
23
23
  import 'url-search-params-polyfill';
@@ -1,7 +1,7 @@
1
1
  import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-0f24d612.js';
2
2
  import { validProps, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
- import { getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
4
3
  import { pushToAndClause, buildQuery } from '@appbaseio/reactivecore/lib/utils/helper';
4
+ import { getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
5
5
  import Appbase from 'appbase-js';
6
6
  import valueReducer from '@appbaseio/reactivecore/lib/reducers/valueReducer';
7
7
  import queryReducer from '@appbaseio/reactivecore/lib/reducers/queryReducer';
@@ -307,8 +307,9 @@ function initReactivesearch(componentCollection, searchState, settings) {
307
307
  appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), getDependentQueries(state, component.componentId, orderOfQueries));
308
308
  }
309
309
  } else {
310
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
310
311
  finalQuery = [].concat(finalQuery, [{
311
- preference: component.componentId
312
+ preference: preference
312
313
  }, currentQuery]);
313
314
  }
314
315
  }
@@ -2,6 +2,7 @@ import '@appbaseio/reactivecore';
2
2
  import './_rollupPluginBabelHelpers-0f24d612.js';
3
3
  import 'vue-types';
4
4
  import '@appbaseio/reactivecore/lib/utils/constants';
5
+ import '@appbaseio/reactivecore/lib/utils/helper';
5
6
  import 'emotion';
6
7
  import '@appbaseio/vue-emotion';
7
8
  import 'polished';
@@ -17,7 +18,6 @@ import './Title-3522ff56.js';
17
18
  import './ListItem-8e8fb535.js';
18
19
  import './Card-6446f1b7.js';
19
20
  import './Flex-8770345d.js';
20
- import '@appbaseio/reactivecore/lib/utils/helper';
21
21
  import '@appbaseio/reactivecore/lib/actions/analytics';
22
22
  import 'appbase-js';
23
23
  import 'url-search-params-polyfill';
@@ -1,3 +1,3 @@
1
- var version = "1.23.0";
1
+ var version = "1.23.4";
2
2
 
3
3
  export default version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appbaseio/reactivesearch-vue",
3
- "version": "1.23.0",
3
+ "version": "1.23.4",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "jsnext:main": "dist/es/index.js",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
- "@appbaseio/reactivecore": "9.12.6",
37
+ "@appbaseio/reactivecore": "9.12.8",
38
38
  "@appbaseio/vue-emotion": "0.4.4",
39
39
  "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
40
40
  "appbase-js": "^4.4.1",