@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.
@@ -5517,7 +5517,7 @@
5517
5517
  }, size > 0 ? {
5518
5518
  numberOfPages: Math.ceil(total / size)
5519
5519
  } : null, {
5520
- time: time,
5520
+ time: time || 0,
5521
5521
  hidden: hidden,
5522
5522
  promoted: promotedResults && promotedResults.length
5523
5523
  });
@@ -8636,7 +8636,7 @@
8636
8636
  componentList.forEach(function (component) {
8637
8637
  var componentProps = props[component];
8638
8638
 
8639
- if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8639
+ if (selectedValues[componentId] && selectedValues[componentId].reference !== 'URL' && componentProps && [constants$1.componentTypes.reactiveList, constants$1.componentTypes.reactiveMap].includes(componentProps.componentType)) {
8640
8640
  dispatch((0, value.setValue)(component, null));
8641
8641
  }
8642
8642
 
@@ -8721,8 +8721,9 @@
8721
8721
  }
8722
8722
  }
8723
8723
  } else {
8724
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + '_' + component : component;
8724
8725
  finalQuery = [].concat(_toConsumableArray(finalQuery), [{
8725
- preference: component
8726
+ preference: preference
8726
8727
  }, currentQuery]);
8727
8728
  }
8728
8729
  }
@@ -8927,8 +8928,9 @@
8927
8928
  appendToAggs: appendToAggs
8928
8929
  }));
8929
8930
  } else {
8931
+ var preference = store.config && store.config.analyticsConfig && store.config.analyticsConfig.userId ? store.config.analyticsConfig.userId + '_' + component : component;
8930
8932
  var _finalQuery = [{
8931
- preference: component
8933
+ preference: preference
8932
8934
  }, currentQuery];
8933
8935
  dispatch(msearch(_finalQuery, [component], appendToHits, false, appendToAggs));
8934
8936
  }
@@ -13882,18 +13884,17 @@
13882
13884
  ResultCardsWrapper: ResultCardsWrapper
13883
13885
  },
13884
13886
  data: function data() {
13885
- var props = this.$props;
13886
13887
  var currentPageState = 0;
13888
+ var defaultPage = this.defaultPage || -1;
13887
13889
 
13888
- if (props.defaultPage >= 0) {
13889
- currentPageState = props.defaultPage;
13890
- } else if (props.currentPage) {
13891
- currentPageState = Math.max(props.currentPage - 1, 0);
13890
+ if (defaultPage >= 0) {
13891
+ currentPageState = defaultPage;
13892
+ } else if (this.currentPage) {
13893
+ currentPageState = Math.max(this.currentPage - 1, 0);
13892
13894
  }
13893
13895
 
13894
13896
  this.__state = {
13895
- from: currentPageState * props.size,
13896
- isLoading: true,
13897
+ from: currentPageState * this.size,
13897
13898
  currentPageState: currentPageState
13898
13899
  };
13899
13900
  return this.__state;
@@ -13922,8 +13923,10 @@
13922
13923
  console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
13923
13924
  }
13924
13925
 
13925
- if (this.defaultPage >= 0) {
13926
- this.currentPageState = this.defaultPage;
13926
+ var defaultPage = this.defaultPage || -1;
13927
+
13928
+ if (defaultPage >= 0) {
13929
+ this.currentPageState = defaultPage;
13927
13930
  this.from = this.currentPageState * this.$props.size;
13928
13931
  }
13929
13932
 
@@ -13990,12 +13993,9 @@
13990
13993
  return this.$listeners && this.$listeners.resultStats;
13991
13994
  },
13992
13995
  stats: function stats() {
13993
- var _this$getAllData = this.getAllData(),
13994
- filteredResults = _this$getAllData.filteredResults;
13995
-
13996
13996
  return _extends({}, getResultStats(this), {
13997
13997
  currentPage: this.currentPageState,
13998
- displayedResults: filteredResults.length
13998
+ displayedResults: this.data.length
13999
13999
  });
14000
14000
  },
14001
14001
  hasCustomRender: function hasCustomRender() {
@@ -14004,6 +14004,27 @@
14004
14004
  showInfiniteScroll: function showInfiniteScroll() {
14005
14005
  // Pagination has higher priority then infinite scroll
14006
14006
  return this.infiniteScroll && !this.shouldRenderPagination;
14007
+ },
14008
+ data: function data() {
14009
+ var results = parseHits(this.hits) || [];
14010
+ var parsedPromotedResults = parseHits(this.promotedResults) || [];
14011
+ var filteredResults = results;
14012
+
14013
+ if (parsedPromotedResults.length) {
14014
+ var ids = parsedPromotedResults.map(function (item) {
14015
+ return item._id;
14016
+ }).filter(Boolean);
14017
+
14018
+ if (ids) {
14019
+ filteredResults = filteredResults.filter(function (item) {
14020
+ return !ids.includes(item._id);
14021
+ });
14022
+ }
14023
+
14024
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
14025
+ }
14026
+
14027
+ return helper_2(filteredResults);
14007
14028
  }
14008
14029
  },
14009
14030
  watch: {
@@ -14085,7 +14106,7 @@
14085
14106
  }
14086
14107
  },
14087
14108
  hits: function hits(newVal, oldVal) {
14088
- this.$emit('data', this.getAllData());
14109
+ this.$emit('data', this.getData());
14089
14110
 
14090
14111
  if (this.shouldRenderPagination) {
14091
14112
  // called when page is changed
@@ -14270,13 +14291,10 @@
14270
14291
 
14271
14292
  var h = this.$createElement;
14272
14293
  var size = this.$props.size;
14273
- var hits = this.$data.hits;
14274
- var results = parseHits(hits) || [];
14275
- var filteredResults = results;
14276
14294
  var renderItem = this.$scopedSlots.renderItem || this.$props.renderItem;
14277
14295
  var element = this.hasCustomRender ? this.getComponent() : h("div", {
14278
14296
  "class": this.$props.listClass + " " + getClassName$1(this.$props.innerClass, 'list')
14279
- }, [[].concat(filteredResults).map(function (item, index) {
14297
+ }, [this.data.map(function (item, index) {
14280
14298
  return renderItem({
14281
14299
  item: item,
14282
14300
  triggerClickAnalytics: function triggerClickAnalytics() {
@@ -14287,7 +14305,7 @@
14287
14305
 
14288
14306
  return this.analytics ? h(ImpressionTracker$1, {
14289
14307
  "attrs": {
14290
- "hits": filteredResults
14308
+ "hits": this.data
14291
14309
  }
14292
14310
  }, [element]) : element;
14293
14311
  },
@@ -14391,7 +14409,7 @@
14391
14409
  if (this.stats.numberOfResults) {
14392
14410
  return h("p", {
14393
14411
  "class": resultStats + " " + getClassName$1(this.$props.innerClass, 'resultStats')
14394
- }, [this.stats.numberOfResults, " results found in ", this.stats.time, "ms"]);
14412
+ }, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
14395
14413
  }
14396
14414
 
14397
14415
  return null;
@@ -14467,8 +14485,8 @@
14467
14485
  })]);
14468
14486
  },
14469
14487
  withClickIds: function withClickIds(results) {
14470
- var _this$getAllData2 = this.getAllData(),
14471
- base = _this$getAllData2.base;
14488
+ var _this$getAllData = this.getAllData(),
14489
+ base = _this$getAllData.base;
14472
14490
 
14473
14491
  return results.map(function (result, index) {
14474
14492
  return _extends({}, result, {
@@ -14486,26 +14504,9 @@
14486
14504
  hits = this.hits;
14487
14505
  var results = parseHits(hits) || [];
14488
14506
  var parsedPromotedResults = parseHits(promotedResults) || [];
14489
- var filteredResults = results;
14490
14507
  var base = currentPage * size;
14491
-
14492
- if (parsedPromotedResults.length) {
14493
- var ids = parsedPromotedResults.map(function (item) {
14494
- return item._id;
14495
- }).filter(Boolean);
14496
-
14497
- if (ids) {
14498
- filteredResults = filteredResults.filter(function (item) {
14499
- return !ids.includes(item._id);
14500
- });
14501
- }
14502
-
14503
- filteredResults = [].concat(parsedPromotedResults, filteredResults);
14504
- }
14505
-
14506
14508
  return {
14507
14509
  results: results,
14508
- filteredResults: filteredResults,
14509
14510
  customData: customData || {},
14510
14511
  promotedResults: parsedPromotedResults,
14511
14512
  aggregationData: aggregationData,
@@ -14515,16 +14516,15 @@
14515
14516
  };
14516
14517
  },
14517
14518
  getData: function getData() {
14518
- var _this$getAllData3 = this.getAllData(),
14519
- filteredResults = _this$getAllData3.filteredResults,
14520
- promotedResults = _this$getAllData3.promotedResults,
14521
- aggregationData = _this$getAllData3.aggregationData,
14522
- customData = _this$getAllData3.customData;
14519
+ var _this$getAllData2 = this.getAllData(),
14520
+ promotedResults = _this$getAllData2.promotedResults,
14521
+ aggregationData = _this$getAllData2.aggregationData,
14522
+ customData = _this$getAllData2.customData;
14523
14523
 
14524
14524
  return {
14525
- data: this.withClickIds(filteredResults),
14525
+ data: this.data,
14526
14526
  aggregationData: this.withClickIds(aggregationData || []),
14527
- promotedData: this.withClickIds(promotedResults),
14527
+ promotedData: this.withClickIds(promotedResults || []),
14528
14528
  rawData: this.rawData,
14529
14529
  resultStats: this.stats,
14530
14530
  customData: customData
@@ -14536,7 +14536,7 @@
14536
14536
 
14537
14537
  var data = _extends({
14538
14538
  error: error,
14539
- loading: isLoading,
14539
+ loading: isLoading || false,
14540
14540
  loadMore: this.loadMore,
14541
14541
  // TODO: Remove in v2
14542
14542
  triggerAnalytics: this.triggerClickAnalytics,
@@ -14551,13 +14551,13 @@
14551
14551
 
14552
14552
  var mapStateToProps$1 = function mapStateToProps(state, props) {
14553
14553
  return {
14554
- defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
14554
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
14555
14555
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
14556
14556
  rawData: state.rawData[props.componentId],
14557
- aggregationData: state.compositeAggregations[props.componentId] || [],
14558
- promotedResults: state.promotedResults[props.componentId] || [],
14557
+ aggregationData: state.compositeAggregations[props.componentId],
14558
+ promotedResults: state.promotedResults[props.componentId],
14559
14559
  customData: state.customData[props.componentId],
14560
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
14560
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
14561
14561
  total: state.hits[props.componentId] && state.hits[props.componentId].total,
14562
14562
  hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
14563
14563
  analytics: state.config && state.config.analytics,
@@ -14566,7 +14566,7 @@
14566
14566
  error: state.error[props.componentId],
14567
14567
  afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
14568
14568
  componentProps: state.props[props.componentId],
14569
- isLoading: state.isLoading[props.componentId] || false
14569
+ isLoading: state.isLoading[props.componentId]
14570
14570
  };
14571
14571
  };
14572
14572
 
@@ -23497,9 +23497,15 @@
23497
23497
  this.setQueryOptions(componentId, _extends({}, customQueryOptions, this.getAggsQuery()), false);
23498
23498
  } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
23499
23499
 
23500
+ var queryToSet = query || null;
23501
+
23502
+ if (calcCustomQuery && calcCustomQuery.id) {
23503
+ queryToSet = calcCustomQuery;
23504
+ }
23505
+
23500
23506
  this.updateQuery({
23501
23507
  componentId: componentId,
23502
- query: query,
23508
+ queryToSet: queryToSet,
23503
23509
  value: this.selectedValue || null,
23504
23510
  label: filterLabel,
23505
23511
  showFilter: showFilter,
@@ -23513,6 +23519,12 @@
23513
23519
 
23514
23520
  if (options) {
23515
23521
  _this.setQueryOptions(props.componentId, _extends({}, options, _this.getAggsQuery()), false);
23522
+ }
23523
+
23524
+ var queryToBeSet = obj.query; // when enableAppbase is true, Backend throws error because of repeated query in request body
23525
+
23526
+ if (obj && obj.query && obj.query.query) {
23527
+ queryToBeSet = obj.query.query;
23516
23528
  } // Update customQuery field for RS API
23517
23529
 
23518
23530
 
@@ -23520,7 +23532,11 @@
23520
23532
  var customQueryCalc = _extends({}, options);
23521
23533
 
23522
23534
  if (obj && obj.query) {
23523
- customQueryCalc.query = obj.query;
23535
+ if (obj.query.id) {
23536
+ customQueryCalc = queryToBeSet;
23537
+ } else {
23538
+ customQueryCalc.query = obj.query;
23539
+ }
23524
23540
  }
23525
23541
 
23526
23542
  _this.setCustomQuery(props.componentId, customQueryCalc);
@@ -23551,9 +23567,15 @@
23551
23567
  this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
23552
23568
  } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
23553
23569
 
23570
+ var queryToSet = query || null;
23571
+
23572
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23573
+ queryToSet = this.$defaultQuery;
23574
+ }
23575
+
23554
23576
  this.updateQuery({
23555
23577
  componentId: this.internalComponent,
23556
- query: query || null
23578
+ query: queryToSet
23557
23579
  });
23558
23580
  }
23559
23581
  },
@@ -23612,9 +23634,15 @@
23612
23634
 
23613
23635
 
23614
23636
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, undefined);
23637
+ var queryToSet = query || null;
23638
+
23639
+ if (!queryToSet && this.$defaultQuery && this.$defaultQuery.id) {
23640
+ queryToSet = this.$defaultQuery;
23641
+ }
23642
+
23615
23643
  this.updateQuery({
23616
23644
  componentId: this.internalComponent,
23617
- query: query || null
23645
+ query: queryToSet
23618
23646
  });
23619
23647
  }
23620
23648
  },
@@ -23633,9 +23661,15 @@
23633
23661
 
23634
23662
 
23635
23663
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, undefined);
23664
+ var queryToSet = query || null;
23665
+
23666
+ if (this.$customQuery && this.$customQuery.id) {
23667
+ queryToSet = this.$customQuery;
23668
+ }
23669
+
23636
23670
  this.updateQuery({
23637
23671
  componentId: componentId,
23638
- query: query || null
23672
+ query: queryToSet
23639
23673
  });
23640
23674
  }
23641
23675
  }
@@ -25520,7 +25554,7 @@
25520
25554
  watch: {
25521
25555
  searchState: function searchState(newVal, oldVal) {
25522
25556
  if (this.isStateChanged(newVal, oldVal)) {
25523
- this.$emit('change', newVal, oldVal);
25557
+ this.$emit('change', oldVal, newVal);
25524
25558
  }
25525
25559
  },
25526
25560
  selectedValues: function selectedValues(newVal, oldVal) {
@@ -25905,8 +25939,9 @@
25905
25939
  appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), transform_1(state, component.componentId, orderOfQueries));
25906
25940
  }
25907
25941
  } else {
25942
+ var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
25908
25943
  finalQuery = [].concat(finalQuery, [{
25909
- preference: component.componentId
25944
+ preference: preference
25910
25945
  }, currentQuery]);
25911
25946
  }
25912
25947
  }
@@ -26060,7 +26095,7 @@
26060
26095
  });
26061
26096
  }
26062
26097
 
26063
- var version = "1.23.0";
26098
+ var version = "1.23.4";
26064
26099
 
26065
26100
  var _templateObject$n, _templateObject2$a;
26066
26101