@appbaseio/reactivesearch-vue 1.16.0-alpha.36 → 1.16.0-alpha.37

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.
@@ -264,9 +264,10 @@ var isEqual$1 = helper.isEqual,
264
264
  getQueryOptions = helper.getQueryOptions,
265
265
  getClassName = helper.getClassName,
266
266
  parseHits = helper.parseHits,
267
- getOptionsFromQuery = helper.getOptionsFromQuery,
268
267
  getCompositeAggsQuery = helper.getCompositeAggsQuery,
269
- getResultStats = helper.getResultStats;
268
+ getResultStats = helper.getResultStats,
269
+ extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
270
+ getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
270
271
  var ReactiveList = {
271
272
  name: 'ReactiveList',
272
273
  components: {
@@ -329,6 +330,12 @@ var ReactiveList = {
329
330
  });
330
331
  }
331
332
 
333
+ if (this.urlSortOption) {
334
+ this.sortOptionIndex = this.$props.sortOptions.findIndex(function (s) {
335
+ return s.label === _this.urlSortOption;
336
+ }) || 0;
337
+ }
338
+
332
339
  this.updateComponentProps(this.componentId, {
333
340
  from: this.from
334
341
  }, componentTypes.reactiveList);
@@ -458,19 +465,11 @@ var ReactiveList = {
458
465
  var options = getQueryOptions(this.$props);
459
466
  options.from = 0;
460
467
  this.$defaultQuery = newVal(null, this.$props);
461
-
462
- var _ref = this.$defaultQuery || {},
463
- sort = _ref.sort,
464
- query = _ref.query;
465
-
466
- if (sort) {
467
- options.sort = this.$defaultQuery.sort;
468
- }
469
-
470
- var queryOptions = getOptionsFromQuery(this.$defaultQuery);
468
+ var query = extractQueryFromCustomQuery(this.$defaultQuery);
469
+ var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
471
470
 
472
471
  if (queryOptions) {
473
- options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery));
472
+ options = _extends({}, options, queryOptions);
474
473
  } // Update calculated default query in store
475
474
 
476
475
 
@@ -561,24 +560,24 @@ var ReactiveList = {
561
560
  options.from = this.$data.from;
562
561
 
563
562
  if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
564
- var _ref2;
563
+ var _ref;
565
564
 
566
565
  var sortField = this.sortOptions[this.sortOptionIndex].dataField;
567
566
  var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
568
- options.sort = [(_ref2 = {}, _ref2[sortField] = {
567
+ options.sort = [(_ref = {}, _ref[sortField] = {
569
568
  order: sortBy
570
- }, _ref2)]; // To handle sort options for RS API
569
+ }, _ref)]; // To handle sort options for RS API
571
570
 
572
571
  this.updateComponentProps(this.componentId, {
573
572
  dataField: sortField,
574
573
  sortBy: sortBy
575
574
  }, componentTypes.reactiveList);
576
575
  } else if (this.$props.sortBy) {
577
- var _ref3;
576
+ var _ref2;
578
577
 
579
- options.sort = [(_ref3 = {}, _ref3[this.$props.dataField] = {
578
+ options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
580
579
  order: this.$props.sortBy
581
- }, _ref3)];
580
+ }, _ref2)];
582
581
  } // Override sort query with defaultQuery's sort if defined
583
582
 
584
583
 
@@ -586,20 +585,13 @@ var ReactiveList = {
586
585
 
587
586
  if (this.$props.defaultQuery) {
588
587
  this.$defaultQuery = this.$props.defaultQuery();
589
- options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery));
590
-
591
- if (this.$defaultQuery.sort) {
592
- options.sort = this.$defaultQuery.sort;
593
- } // Update calculated default query in store
594
-
588
+ options = _extends({}, options, getOptionsForCustomQuery(this.$defaultQuery)); // Update calculated default query in store
595
589
 
596
590
  updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
597
591
  } // execute is set to false at the time of mount
598
592
 
599
593
 
600
- var _ref4 = this.$defaultQuery || {},
601
- query = _ref4.query;
602
-
594
+ var query = extractQueryFromCustomQuery(this.$defaultQuery);
603
595
  var execute = false;
604
596
  this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), execute);
605
597
 
@@ -714,18 +706,18 @@ var ReactiveList = {
714
706
  }) : 0;
715
707
 
716
708
  if (props.sortOptions[sortOptionIndex]) {
717
- var _ref5;
709
+ var _ref3;
718
710
 
719
- options.sort = [(_ref5 = {}, _ref5[props.sortOptions[sortOptionIndex].dataField] = {
711
+ options.sort = [(_ref3 = {}, _ref3[props.sortOptions[sortOptionIndex].dataField] = {
720
712
  order: props.sortOptions[sortOptionIndex].sortBy
721
- }, _ref5)];
713
+ }, _ref3)];
722
714
  }
723
715
  } else if (props.sortBy) {
724
- var _ref6;
716
+ var _ref4;
725
717
 
726
- options.sort = [(_ref6 = {}, _ref6[props.dataField] = {
718
+ options.sort = [(_ref4 = {}, _ref4[props.dataField] = {
727
719
  order: props.sortBy
728
- }, _ref6)];
720
+ }, _ref4)];
729
721
  }
730
722
 
731
723
  this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), true);
@@ -828,16 +820,16 @@ var ReactiveList = {
828
820
  var index = e.target.value;
829
821
 
830
822
  if (this.sortOptions && this.sortOptions[index]) {
831
- var _ref7;
823
+ var _ref5;
832
824
 
833
825
  // This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
834
826
  var options = getQueryOptions(this.$props);
835
827
  options.from = 0;
836
828
  var sortField = this.sortOptions[index].dataField;
837
829
  var sortBy = this.sortOptions[index].sortBy;
838
- options.sort = [(_ref7 = {}, _ref7[sortField] = {
830
+ options.sort = [(_ref5 = {}, _ref5[sortField] = {
839
831
  order: sortBy
840
- }, _ref7)];
832
+ }, _ref5)];
841
833
  this.sortOptionIndex = index; // To handle sort options for RS API
842
834
 
843
835
  this.updateComponentProps(this.componentId, {
@@ -845,8 +837,11 @@ var ReactiveList = {
845
837
  sortBy: sortBy
846
838
  }, componentTypes.reactiveList);
847
839
  this.setQueryOptions(this.$props.componentId, options, true);
840
+ this.setPage(0);
848
841
  this.currentPageState = 0;
849
842
  this.from = 0;
843
+ var sortOption = this.$props.sortOptions[this.sortOptionIndex] ? this.$props.sortOptions[this.sortOptionIndex].label : null;
844
+ this.setPageURL(this.$props.componentId + "sortOption", sortOption, this.$props.componentId + "sortOption", false, this.$props.URLParams);
850
845
  }
851
846
  },
852
847
  triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
@@ -958,6 +953,7 @@ var ReactiveList = {
958
953
  var mapStateToProps = function mapStateToProps(state, props) {
959
954
  return {
960
955
  defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
956
+ urlSortOption: state.selectedValues[props.componentId + "sortOption"] && state.selectedValues[props.componentId + "sortOption"].value,
961
957
  hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
962
958
  rawData: state.rawData[props.componentId],
963
959
  aggregationData: state.compositeAggregations[props.componentId],
@@ -998,7 +994,7 @@ ReactiveList.generateQueryOptions = function (props) {
998
994
  options.size = size || 10;
999
995
 
1000
996
  var getSortOption = function getSortOption() {
1001
- var _ref9;
997
+ var _ref7;
1002
998
 
1003
999
  if (defaultSortOption) {
1004
1000
  var sortOption = sortOptionsNew.find(function (option) {
@@ -1006,35 +1002,39 @@ ReactiveList.generateQueryOptions = function (props) {
1006
1002
  });
1007
1003
 
1008
1004
  if (sortOption) {
1009
- var _ref8;
1005
+ var _ref6;
1010
1006
 
1011
- return _ref8 = {}, _ref8[sortOption.dataField] = {
1007
+ return _ref6 = {}, _ref6[sortOption.dataField] = {
1012
1008
  order: sortOption.sortBy
1013
- }, _ref8;
1009
+ }, _ref6;
1014
1010
  }
1015
1011
  }
1016
1012
 
1017
- return _ref9 = {}, _ref9[sortOptionsNew[0].dataField] = {
1013
+ return _ref7 = {}, _ref7[sortOptionsNew[0].dataField] = {
1018
1014
  order: sortOptionsNew[0].sortBy
1019
- }, _ref9;
1015
+ }, _ref7;
1020
1016
  };
1021
1017
 
1022
1018
  if (sortOptionsNew) {
1023
1019
  options.sort = [getSortOption()];
1024
1020
  } else if (sortBy) {
1025
- var _ref10;
1021
+ var _ref8;
1026
1022
 
1027
- options.sort = [(_ref10 = {}, _ref10[dataField] = {
1023
+ options.sort = [(_ref8 = {}, _ref8[dataField] = {
1028
1024
  order: sortBy
1029
- }, _ref10)];
1025
+ }, _ref8)];
1030
1026
  }
1031
1027
 
1032
1028
  return options;
1033
1029
  };
1034
1030
 
1031
+ ReactiveList.hasInternalComponent = function () {
1032
+ return true;
1033
+ };
1034
+
1035
1035
  var RLConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
1036
1036
  componentType: componentTypes.reactiveList,
1037
- internalComponent: true
1037
+ internalComponent: ReactiveList.hasInternalComponent()
1038
1038
  });
1039
1039
 
1040
1040
  ReactiveList.install = function (Vue) {
@@ -29,9 +29,10 @@ var getQueryOptions = helper.getQueryOptions,
29
29
  checkValueChange = helper.checkValueChange,
30
30
  checkPropChange = helper.checkPropChange,
31
31
  getClassName = helper.getClassName,
32
- getOptionsFromQuery = helper.getOptionsFromQuery,
33
32
  isEqual = helper.isEqual,
34
- getCompositeAggsQuery = helper.getCompositeAggsQuery;
33
+ getCompositeAggsQuery = helper.getCompositeAggsQuery,
34
+ extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
35
+ getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
35
36
  var SingleDropdownList = {
36
37
  name: 'SingleDropdownList',
37
38
  data: function data() {
@@ -285,12 +286,13 @@ var SingleDropdownList = {
285
286
 
286
287
  if (this.defaultQuery) {
287
288
  var defaultQueryToBeSet = this.defaultQuery(value, props) || {};
289
+ var defaultQueryObj = extractQueryFromCustomQuery(defaultQueryToBeSet);
288
290
 
289
- if (defaultQueryToBeSet.query) {
290
- query = defaultQueryToBeSet.query;
291
+ if (defaultQueryObj) {
292
+ query = defaultQueryObj;
291
293
  }
292
294
 
293
- defaultQueryOptions = getOptionsFromQuery(defaultQueryToBeSet); // Update calculated default query in store
295
+ defaultQueryOptions = getOptionsForCustomQuery(defaultQueryToBeSet); // Update calculated default query in store
294
296
 
295
297
  updateDefaultQuery(props.componentId, this.setDefaultQuery, props, value);
296
298
  }
@@ -309,10 +311,9 @@ var SingleDropdownList = {
309
311
  var customQueryOptions;
310
312
 
311
313
  if (customQuery) {
312
- var _ref = customQuery(value, props) || {};
313
-
314
- query = _ref.query;
315
- customQueryOptions = getOptionsFromQuery(customQuery(value, props));
314
+ var customQueryCalc = customQuery(value, props);
315
+ query = extractQueryFromCustomQuery(customQueryCalc);
316
+ customQueryOptions = getOptionsForCustomQuery(customQueryCalc);
316
317
  updateCustomQuery(props.componentId, this.setCustomQuery, props, value);
317
318
  }
318
319
 
@@ -350,7 +351,7 @@ var SingleDropdownList = {
350
351
 
351
352
  if (props.defaultQuery) {
352
353
  var value = this.$data.currentValue;
353
- var defaultQueryOptions = getOptionsFromQuery(props.defaultQuery(value, props));
354
+ var defaultQueryOptions = getOptionsForCustomQuery(props.defaultQuery(value, props));
354
355
  this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, defaultQueryOptions));
355
356
  } else {
356
357
  this.setQueryOptions(this.internalComponent, queryOptions);
@@ -442,6 +443,10 @@ SingleDropdownList.generateQueryOptions = function (props, after) {
442
443
  }) : getAggsQuery(queryOptions, props);
443
444
  };
444
445
 
446
+ SingleDropdownList.hasInternalComponent = function () {
447
+ return true;
448
+ };
449
+
445
450
  var mapStateToProps = function mapStateToProps(state, props) {
446
451
  return {
447
452
  options: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId],
@@ -463,7 +468,7 @@ var mapDispatchtoProps = {
463
468
  };
464
469
  var ListConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(SingleDropdownList), {
465
470
  componentType: componentTypes.singleDropdownList,
466
- internalComponent: true
471
+ internalComponent: SingleDropdownList.hasInternalComponent()
467
472
  });
468
473
 
469
474
  SingleDropdownList.install = function (Vue) {
@@ -24,8 +24,9 @@ var updateQuery = Actions.updateQuery,
24
24
  var getQueryOptions = helper.getQueryOptions,
25
25
  checkValueChange = helper.checkValueChange,
26
26
  getClassName = helper.getClassName,
27
- getOptionsFromQuery = helper.getOptionsFromQuery,
28
- isEqual = helper.isEqual;
27
+ isEqual = helper.isEqual,
28
+ extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
29
+ getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
29
30
  var SingleList = {
30
31
  name: 'SingleList',
31
32
  props: {
@@ -267,12 +268,13 @@ var SingleList = {
267
268
 
268
269
  if (this.defaultQuery) {
269
270
  var defaultQueryToBeSet = this.defaultQuery(value, props) || {};
271
+ var defaultQueryObj = extractQueryFromCustomQuery(defaultQueryToBeSet);
270
272
 
271
- if (defaultQueryToBeSet.query) {
272
- query = defaultQueryToBeSet.query;
273
+ if (defaultQueryObj) {
274
+ query = defaultQueryObj;
273
275
  }
274
276
 
275
- defaultQueryOptions = getOptionsFromQuery(defaultQueryToBeSet); // Update calculated default query in store
277
+ defaultQueryOptions = getOptionsForCustomQuery(defaultQueryToBeSet); // Update calculated default query in store
276
278
 
277
279
  updateDefaultQuery(props.componentId, this.setDefaultQuery, props, value);
278
280
  }
@@ -291,10 +293,9 @@ var SingleList = {
291
293
  var customQueryOptions;
292
294
 
293
295
  if (customQuery) {
294
- var _ref = customQuery(value, props) || {};
295
-
296
- query = _ref.query;
297
- customQueryOptions = getOptionsFromQuery(customQuery(value, props));
296
+ var customQueryCalc = customQuery(value, props);
297
+ query = extractQueryFromCustomQuery(customQueryCalc);
298
+ customQueryOptions = getOptionsForCustomQuery(customQueryCalc);
298
299
  updateCustomQuery(props.componentId, this.setCustomQuery, props, value);
299
300
  }
300
301
 
@@ -318,7 +319,7 @@ var SingleList = {
318
319
 
319
320
  if (props.defaultQuery) {
320
321
  var value = this.$data.currentValue;
321
- var defaultQueryOptions = getOptionsFromQuery(props.defaultQuery(value, props));
322
+ var defaultQueryOptions = getOptionsForCustomQuery(props.defaultQuery(value, props));
322
323
  this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, defaultQueryOptions));
323
324
  } else {
324
325
  this.setQueryOptions(this.internalComponent, queryOptions);
@@ -463,6 +464,10 @@ SingleList.defaultQuery = function (value, props) {
463
464
  return query;
464
465
  };
465
466
 
467
+ SingleList.hasInternalComponent = function () {
468
+ return true;
469
+ };
470
+
466
471
  var mapStateToProps = function mapStateToProps(state, props) {
467
472
  return {
468
473
  options: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId],
@@ -484,7 +489,7 @@ var mapDispatchtoProps = {
484
489
  };
485
490
  var ListConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(SingleList), {
486
491
  componentType: componentTypes.singleList,
487
- internalComponent: true
492
+ internalComponent: SingleList.hasInternalComponent()
488
493
  });
489
494
 
490
495
  SingleList.install = function (Vue) {
@@ -1,6 +1,6 @@
1
1
  import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ecf6c03c.js';
2
2
  import { validProps, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
- import { pushToAndClause, buildQuery } from '@appbaseio/reactivecore/lib/utils/helper';
3
+ import { pushToAndClause, buildQuery, extractQueryFromCustomQuery, getOptionsForCustomQuery } from '@appbaseio/reactivecore/lib/utils/helper';
4
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';
@@ -12,10 +12,9 @@ import dependencyTreeReducer from '@appbaseio/reactivecore/lib/reducers/dependen
12
12
  import fetchGraphQL from '@appbaseio/reactivecore/lib/utils/graphQL';
13
13
  import { isPropertyDefined } from '@appbaseio/reactivecore/lib/actions/utils';
14
14
 
15
- var _excluded = ["aggs", "size"];
15
+ var _excluded = ["aggs", "size"],
16
+ _excluded2 = ["query"];
16
17
  var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
17
- var componentsWithHighlightQuery = [componentTypes.dataSearch, componentTypes.categorySearch];
18
- var componentsWithOptions = [componentTypes.reactiveList, componentTypes.reactiveMap, componentTypes.singleList, componentTypes.multiList, componentTypes.tagCloud].concat(componentsWithHighlightQuery);
19
18
  var componentsWithoutFilters = [componentTypes.numberBox, componentTypes.ratingsFilter];
20
19
  var resultComponents = [componentTypes.reactiveList, componentTypes.reactiveMap];
21
20
 
@@ -49,23 +48,35 @@ function parseValue(value, component) {
49
48
  }
50
49
 
51
50
  return value;
52
- }
51
+ } // Returns query DSL with query property and other options
52
+
53
+
54
+ function getDefaultQuery(component, value) {
55
+ // get custom or default query of sensor components
56
+ var currentValue = parseValue(value, component); // get default query of result components
57
+
58
+ if (component.defaultQuery) {
59
+ var defaultQuery = component.defaultQuery(currentValue, component);
60
+ return _extends({
61
+ query: extractQueryFromCustomQuery(defaultQuery)
62
+ }, getOptionsForCustomQuery(defaultQuery));
63
+ }
53
64
 
54
- function getQuery(component, value, componentType) {
55
- // get default query of result components
56
- if (resultComponents.includes(componentType)) {
57
- return component.defaultQuery ? component.defaultQuery() : {};
58
- } // get custom or default query of sensor components
65
+ return component.source.defaultQuery ? {
66
+ query: component.source.defaultQuery(currentValue, component)
67
+ } : {};
68
+ } // Only results the query part
59
69
 
60
70
 
71
+ function getCustomQuery(component, value) {
72
+ // get custom or default query of sensor components
61
73
  var currentValue = parseValue(value, component);
62
74
 
63
75
  if (component.customQuery) {
64
- var customQuery = component.customQuery(currentValue, component);
65
- return customQuery && customQuery.query;
76
+ return extractQueryFromCustomQuery(component.customQuery(currentValue, component));
66
77
  }
67
78
 
68
- return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) : {};
79
+ return component.source.defaultQuery ? component.source.defaultQuery(currentValue, component) : null;
69
80
  }
70
81
 
71
82
  function initReactivesearch(componentCollection, searchState, settings) {
@@ -120,6 +131,11 @@ function initReactivesearch(componentCollection, searchState, settings) {
120
131
  }
121
132
  });
122
133
  var isInternalComponentPresent = false;
134
+
135
+ if (component.source.hasInternalComponent) {
136
+ isInternalComponentPresent = component.source.hasInternalComponent(component);
137
+ }
138
+
123
139
  var isResultComponent = resultComponents.includes(componentType);
124
140
  var internalComponent = component.componentId + "__internal";
125
141
  var label = component.filterLabel || component.componentId;
@@ -151,74 +167,66 @@ function initReactivesearch(componentCollection, searchState, settings) {
151
167
 
152
168
  if (component.defaultQuery && typeof component.defaultQuery === 'function') {
153
169
  defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
154
- } // [2] set query options - main component query (valid for result components)
155
-
170
+ }
156
171
 
157
- if (componentsWithOptions.includes(componentType)) {
158
- var options = component.source.generateQueryOptions ? component.source.generateQueryOptions(component) : null;
159
- var highlightQuery = {};
172
+ var componentQueryOptions = {}; // [2] set query options - main component query (valid for result components)
160
173
 
161
- if (componentsWithHighlightQuery.includes(componentType) && component.highlight) {
162
- highlightQuery = component.source.highlightQuery(component);
163
- }
174
+ if (component && component.source.generateQueryOptions) {
175
+ componentQueryOptions = _extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
176
+ }
164
177
 
165
- if (options && Object.keys(options).length || highlightQuery && Object.keys(highlightQuery).length) {
166
- // eslint-disable-next-line
167
- var _ref = options || {},
168
- aggs = _ref.aggs,
169
- size = _ref.size,
170
- otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
171
-
172
- if (aggs && Object.keys(aggs).length) {
173
- isInternalComponentPresent = true; // query should be applied on the internal component
174
- // to enable feeding the data to parent component
175
-
176
- queryOptions = queryOptionsReducer(queryOptions, {
177
- type: 'SET_QUERY_OPTIONS',
178
- component: internalComponent,
179
- options: {
180
- aggs: aggs,
181
- size: typeof size === 'undefined' ? 100 : size
182
- }
183
- });
184
- } // sort, highlight, size, from - query should be applied on the main component
178
+ var highlightQuery = {};
185
179
 
180
+ if (component.source.highlightQuery) {
181
+ highlightQuery = component.source.highlightQuery(component);
182
+ }
186
183
 
187
- if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
188
- if (!otherQueryOptions) otherQueryOptions = {};
189
- if (!highlightQuery) highlightQuery = {};
184
+ if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
185
+ // eslint-disable-next-line
186
+ var _ref = componentQueryOptions || {},
187
+ aggs = _ref.aggs,
188
+ size = _ref.size,
189
+ otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
190
+
191
+ if (aggs && Object.keys(aggs).length) {
192
+ isInternalComponentPresent = true;
193
+ componentQueryOptions = _extends({}, componentQueryOptions, {
194
+ aggs: aggs,
195
+ size: typeof size === 'undefined' ? 100 : size
196
+ });
197
+ } // sort, highlight, size, from - query should be applied on the main component
190
198
 
191
- var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
192
- size: size
193
- });
194
199
 
195
- if (isInternalComponentPresent) {
196
- mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery);
197
- }
200
+ if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
201
+ if (!otherQueryOptions) otherQueryOptions = {};
202
+ if (!highlightQuery) highlightQuery = {};
198
203
 
199
- if (isResultComponent) {
200
- var currentPage = component.currentPage ? component.currentPage - 1 : 0;
204
+ var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
205
+ size: size
206
+ });
201
207
 
202
- if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
203
- currentPage = selectedValues[component.componentId].value - 1 || 0;
204
- }
208
+ if (isInternalComponentPresent) {
209
+ mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery);
210
+ }
205
211
 
206
- var resultSize = component.size || 10;
207
- var from = currentPage * resultSize; // Update props for RS API
212
+ if (isResultComponent) {
213
+ var currentPage = component.currentPage ? component.currentPage - 1 : 0;
208
214
 
209
- compProps.from = from;
210
- mainQueryOptions = _extends({}, mainQueryOptions, highlightQuery, {
211
- size: resultSize,
212
- from: from
213
- });
215
+ if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
216
+ currentPage = selectedValues[component.componentId].value - 1 || 0;
214
217
  }
215
218
 
216
- queryOptions = queryOptionsReducer(queryOptions, {
217
- type: 'SET_QUERY_OPTIONS',
218
- component: component.componentId,
219
- options: _extends({}, mainQueryOptions)
219
+ var resultSize = component.size || 10;
220
+ var from = currentPage * resultSize; // Update props for RS API
221
+
222
+ compProps.from = from;
223
+ mainQueryOptions = _extends({}, mainQueryOptions, highlightQuery, {
224
+ size: resultSize,
225
+ from: from
220
226
  });
221
227
  }
228
+
229
+ componentQueryOptions = _extends({}, componentQueryOptions, mainQueryOptions);
222
230
  }
223
231
  } // [3] set dependency tree
224
232
 
@@ -238,23 +246,32 @@ function initReactivesearch(componentCollection, searchState, settings) {
238
246
  } // [4] set query list
239
247
 
240
248
 
241
- if (isResultComponent) {
242
- var _getQuery = getQuery(component, value, componentType),
243
- query = _getQuery.query;
249
+ var _ref2 = getDefaultQuery(component, value) || {},
250
+ defaultQuery = _ref2.query,
251
+ defaultQueryOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
244
252
 
245
- queryList = queryReducer(queryList, {
246
- type: 'SET_QUERY',
247
- component: internalComponent,
248
- query: query
249
- });
250
- } else {
251
- queryList = queryReducer(queryList, {
252
- type: 'SET_QUERY',
253
- component: component.componentId,
254
- query: getQuery(component, value, componentType)
255
- });
256
- } // Set component type in component props
253
+ queryList = queryReducer(queryList, {
254
+ type: 'SET_QUERY',
255
+ component: internalComponent,
256
+ query: defaultQuery
257
+ });
258
+ queryOptions = queryOptionsReducer(queryOptions, {
259
+ type: 'SET_QUERY_OPTIONS',
260
+ component: internalComponent,
261
+ options: _extends({}, componentQueryOptions, defaultQueryOptions)
262
+ });
263
+ var customQuery = getCustomQuery(component, value); // set custom query for main component
257
264
 
265
+ queryList = queryReducer(queryList, {
266
+ type: 'SET_QUERY',
267
+ component: component.componentId,
268
+ query: customQuery
269
+ });
270
+ queryOptions = queryOptionsReducer(queryOptions, {
271
+ type: 'SET_QUERY_OPTIONS',
272
+ component: component.componentId,
273
+ options: _extends({}, componentQueryOptions)
274
+ }); // Set component type in component props
258
275
 
259
276
  compProps.componentType = componentType;
260
277
  componentProps[component.componentId] = compProps;
@@ -1,3 +1,3 @@
1
- var version = "1.16.0-alpha.36";
1
+ var version = "1.16.0-alpha.37";
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.16.0-alpha.36",
3
+ "version": "1.16.0-alpha.37",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "jsnext:main": "dist/es/index.js",
@@ -34,10 +34,10 @@
34
34
  ],
35
35
  "sideEffects": false,
36
36
  "dependencies": {
37
- "@appbaseio/reactivecore": "9.13.4",
37
+ "@appbaseio/reactivecore": "9.14.1",
38
38
  "@appbaseio/vue-emotion": "0.4.4",
39
39
  "@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
40
- "appbase-js": "^4.5.1",
40
+ "appbase-js": "^5.0.0",
41
41
  "compute-scroll-into-view": "^1.0.11",
42
42
  "emotion": "9.2.12",
43
43
  "gmap-vue": "^1.5.0",