@appbaseio/reactivesearch-vue 1.34.0-alpha.2 → 1.34.0

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 (104) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +10874 -8633
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +12 -11
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/Button-841fd06d.js +62 -0
  6. package/dist/cjs/{CancelSvg-062a42f0.js → CancelSvg-220a7cc3.js} +40 -32
  7. package/dist/cjs/Card-240f283d.js +30 -0
  8. package/dist/cjs/{ComponentWrapper-db45cc6d.js → ComponentWrapper-94c50228.js} +7 -7
  9. package/dist/cjs/Container-e699ea95.js +15 -0
  10. package/dist/cjs/DataSearch.js +1312 -20
  11. package/dist/cjs/{DropDown-3b899b20.js → DropDown-7a52c661.js} +79 -78
  12. package/dist/cjs/DynamicRangeSlider.js +46 -56
  13. package/dist/cjs/Flex-ddd7cb6b.js +50 -0
  14. package/dist/cjs/FormControlList-bbb5cd24.js +45 -0
  15. package/dist/cjs/Input-ead4cd84.js +77 -0
  16. package/dist/cjs/ListItem-5088bd6a.js +45 -0
  17. package/dist/cjs/MultiDropdownList.js +68 -74
  18. package/dist/cjs/MultiList.js +94 -89
  19. package/dist/cjs/MultiRange.js +44 -54
  20. package/dist/cjs/{Pagination-a468f960.js → Pagination-e56a5b79.js} +53 -56
  21. package/dist/cjs/{PreferencesConsumer-034c55e3.js → PreferencesConsumer-5e6e84a2.js} +5 -6
  22. package/dist/cjs/RangeInput.js +107 -115
  23. package/dist/cjs/RangeSlider.js +39 -50
  24. package/dist/cjs/ReactiveBase.js +55 -69
  25. package/dist/cjs/ReactiveComponent.js +316 -46
  26. package/dist/cjs/{ReactiveComponent-f0f486ca.js → ReactiveComponentPrivate-244c6055.js} +321 -618
  27. package/dist/cjs/ReactiveComponentPrivate.js +55 -0
  28. package/dist/cjs/ReactiveGoogleMap.js +439 -384
  29. package/dist/cjs/ReactiveList.js +128 -100
  30. package/dist/cjs/ResultCard.js +19 -26
  31. package/dist/cjs/ResultList.js +27 -31
  32. package/dist/cjs/SelectedFilters.js +34 -49
  33. package/dist/cjs/SingleDropdownList.js +66 -73
  34. package/dist/cjs/SingleList.js +96 -90
  35. package/dist/cjs/SingleRange.js +42 -48
  36. package/dist/cjs/StateProvider.js +2 -2
  37. package/dist/cjs/Tags-4ec43831.js +883 -0
  38. package/dist/cjs/Title-16042ea0.js +15 -0
  39. package/dist/cjs/ToggleButton.js +34 -39
  40. package/dist/cjs/{index-dc25b706.js → index-de136c17.js} +8 -6
  41. package/dist/cjs/index.js +27 -25
  42. package/dist/cjs/initReactivesearch.js +0 -3
  43. package/dist/cjs/install.js +23 -22
  44. package/dist/cjs/ssr-f2fc1bf6.js +36 -0
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/cjs/{vueTypes-621a8143.js → vueTypes-b7007f5f.js} +3 -2
  47. package/dist/es/Button-153cd885.js +53 -0
  48. package/dist/es/{CancelSvg-14ebc9a1.js → CancelSvg-e40552a5.js} +37 -30
  49. package/dist/es/{Card-1951569e.js → Card-19ad6d90.js} +6 -5
  50. package/dist/es/{ComponentWrapper-bf443c0b.js → ComponentWrapper-edaeaceb.js} +6 -6
  51. package/dist/es/Container-d00219f7.js +1 -1
  52. package/dist/es/DataSearch.js +1312 -18
  53. package/dist/es/{DropDown-35e232b7.js → DropDown-2c0dd714.js} +78 -78
  54. package/dist/es/DynamicRangeSlider.js +43 -53
  55. package/dist/es/Flex-7c177a10.js +45 -0
  56. package/dist/es/FormControlList-99797d0a.js +38 -0
  57. package/dist/es/Input-c09c0b56.js +69 -0
  58. package/dist/es/{ListItem-47a6345a.js → ListItem-07888a65.js} +7 -6
  59. package/dist/es/MultiDropdownList.js +66 -72
  60. package/dist/es/MultiList.js +93 -88
  61. package/dist/es/MultiRange.js +42 -52
  62. package/dist/es/{Pagination-145b4ff2.js → Pagination-edeb7dbe.js} +53 -56
  63. package/dist/es/{PreferencesConsumer-7ea7313a.js → PreferencesConsumer-86a676c8.js} +4 -5
  64. package/dist/es/RangeInput.js +103 -112
  65. package/dist/es/RangeSlider.js +36 -47
  66. package/dist/es/ReactiveBase.js +53 -68
  67. package/dist/es/ReactiveComponent.js +316 -45
  68. package/dist/es/{ReactiveComponent-e2fb9eb4.js → ReactiveComponentPrivate-6f16e1b7.js} +316 -614
  69. package/dist/es/ReactiveComponentPrivate.js +47 -0
  70. package/dist/es/ReactiveGoogleMap.js +434 -380
  71. package/dist/es/ReactiveList.js +125 -98
  72. package/dist/es/ResultCard.js +18 -25
  73. package/dist/es/ResultList.js +26 -30
  74. package/dist/es/SelectedFilters.js +32 -47
  75. package/dist/es/SingleDropdownList.js +64 -71
  76. package/dist/es/SingleList.js +94 -88
  77. package/dist/es/SingleRange.js +40 -46
  78. package/dist/es/StateProvider.js +2 -2
  79. package/dist/es/Tags-1c2d6c4d.js +869 -0
  80. package/dist/es/Title-863dfa42.js +1 -1
  81. package/dist/es/ToggleButton.js +32 -37
  82. package/dist/es/{index-285a43a6.js → index-5509c0bc.js} +8 -6
  83. package/dist/es/index.js +20 -19
  84. package/dist/es/initReactivesearch.js +0 -3
  85. package/dist/es/install.js +20 -19
  86. package/dist/es/ssr-03607d84.js +1 -1
  87. package/dist/es/version.js +1 -1
  88. package/dist/es/{vueTypes-e4af6fe2.js → vueTypes-66ebc93e.js} +3 -2
  89. package/package.json +10 -10
  90. package/dist/cjs/Button-626c5e8e.js +0 -58
  91. package/dist/cjs/Card-c381ded3.js +0 -26
  92. package/dist/cjs/Container-29f049b2.js +0 -12
  93. package/dist/cjs/DataSearch-7c71ec9f.js +0 -2043
  94. package/dist/cjs/Flex-d5675ea6.js +0 -48
  95. package/dist/cjs/FormControlList-cf1ff2ca.js +0 -42
  96. package/dist/cjs/Input-4d278ca0.js +0 -74
  97. package/dist/cjs/ListItem-c067bc07.js +0 -41
  98. package/dist/cjs/Title-8802a218.js +0 -12
  99. package/dist/cjs/ssr-eb901d09.js +0 -35
  100. package/dist/es/Button-ebafa3d6.js +0 -52
  101. package/dist/es/DataSearch-4f9a4e46.js +0 -2028
  102. package/dist/es/Flex-a08e22d7.js +0 -46
  103. package/dist/es/FormControlList-fa5cf78b.js +0 -38
  104. package/dist/es/Input-3b8408a6.js +0 -69
@@ -8,13 +8,14 @@ var configureStore = require('@appbaseio/reactivecore');
8
8
  var configureStore__default = _interopDefault(configureStore);
9
9
  require('@appbaseio/reactivecore/lib/utils/constants');
10
10
  var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
11
- var vue = require('vue');
12
11
  var VueTypes = _interopDefault(require('vue-types'));
13
12
  var helper = require('@appbaseio/reactivecore/lib/utils/helper');
14
- var vueEmotion = require('@appbaseio/vue-emotion');
15
- var vueTypes = require('./vueTypes-621a8143.js');
13
+ var styled = require('@appbaseio/vue-emotion');
14
+ var styled__default = _interopDefault(styled);
15
+ var vueTypes = require('./vueTypes-b7007f5f.js');
16
16
  require('redux');
17
- var index = require('./index-dc25b706.js');
17
+ var index = require('./index-de136c17.js');
18
+ var _mergeJSXProps = _interopDefault(require('@vue/babel-helper-vue-jsx-merge-props'));
18
19
  var analytics = require('@appbaseio/reactivecore/lib/actions/analytics');
19
20
  var Appbase = _interopDefault(require('appbase-js'));
20
21
  var AppbaseAnalytics = _interopDefault(require('@appbaseio/analytics'));
@@ -44,48 +45,40 @@ var Provider = {
44
45
  $analytics: this.analyticsRef
45
46
  };
46
47
  },
47
- render: function render() {
48
- if (this.$slots["default"]().length > 1) {
49
- return vue.h('div', this.$slots["default"]());
48
+ render: function render(h) {
49
+ if (this.$slots["default"].length > 1) {
50
+ return h('div', this.$slots["default"]);
50
51
  }
51
- return this.$slots["default"]()[0];
52
+ return this.$slots["default"][0];
52
53
  }
53
54
  };
54
55
 
55
56
  var _templateObject;
56
- function _isSlot(s) {
57
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
58
- }
59
- var Base = function Base(_ref) {
60
- var _ref$data$attrs$as = _ref.data.attrs.as,
61
- T = _ref$data$attrs$as === void 0 ? 'div' : _ref$data$attrs$as,
62
- props = _ref.data,
63
- children = _ref.children;
64
- var propsVar = props;
65
- delete propsVar.attrs.as;
66
- return vue.createVNode(T, props, _isSlot(children) ? children : {
67
- "default": function _default() {
68
- return [children];
69
- }
70
- });
57
+ var Base = {
58
+ functional: true,
59
+ render: function render(h, _ref) {
60
+ var _ref$data$attrs$as = _ref.data.attrs.as,
61
+ T = _ref$data$attrs$as === void 0 ? 'div' : _ref$data$attrs$as,
62
+ props = _ref.data,
63
+ children = _ref.children;
64
+ delete props.attrs.as;
65
+ return h(T, _mergeJSXProps([{}, props]), [children]);
66
+ }
71
67
  };
72
- var Base$1 = vueEmotion.styled(Base)(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tfont-family: ", ";\n\tfont-size: ", ";\n\tcolor: ", ";\n\twidth: 100%;\n\n\tinput,\n\tbutton,\n\ttextarea,\n\tselect {\n\t\tfont-family: ", ";\n\t}\n\n\t*,\n\t*:before,\n\t*:after {\n\t\tbox-sizing: border-box;\n\t}\n"])), function (_ref2) {
68
+ var Base$1 = styled__default(Base)(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tfont-family: ", ";\n\tfont-size: ", ";\n\tcolor: ", ";\n\twidth: 100%;\n\n\tinput,\n\tbutton,\n\ttextarea,\n\tselect {\n\t\tfont-family: ", ";\n\t}\n\n\t*,\n\t*:before,\n\t*:after {\n\t\tbox-sizing: border-box;\n\t}\n"])), function (_ref2) {
73
69
  var theme = _ref2.theme;
74
- return theme && theme.typography ? theme.typography.fontFamily : 'unset';
70
+ return theme.typography.fontFamily;
75
71
  }, function (_ref3) {
76
72
  var theme = _ref3.theme;
77
- return theme && theme.typography ? theme.typography.fontSize : 'unset';
73
+ return theme.typography.fontSize;
78
74
  }, function (_ref4) {
79
75
  var theme = _ref4.theme;
80
- return theme && theme.typography ? theme.typography.textColor : 'unset';
76
+ return theme.colors.textColor;
81
77
  }, function (_ref5) {
82
78
  var theme = _ref5.theme;
83
- return theme && theme.typography ? theme.typography.fontFamily : 'unset';
79
+ return theme.typography.fontFamily;
84
80
  });
85
81
 
86
- function _isSlot$1(s) {
87
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
88
- }
89
82
  var setHeaders = configureStore.Actions.setHeaders,
90
83
  setValue = configureStore.Actions.setValue;
91
84
  var isEqual = configureStore.helper.isEqual;
@@ -274,15 +267,14 @@ var URLParamsProvider = {
274
267
  }
275
268
  },
276
269
  render: function render() {
277
- var children = this.$slots["default"]();
278
- return vue.createVNode(Base$1, {
279
- "as": this.$props.as,
270
+ var h = arguments[0];
271
+ var children = this.$slots["default"];
272
+ return h(Base$1, {
273
+ "attrs": {
274
+ "as": this.$props.as
275
+ },
280
276
  "class": this.$props.className
281
- }, _isSlot$1(children) ? children : {
282
- "default": function _default() {
283
- return [children];
284
- }
285
- });
277
+ }, [children]);
286
278
  }
287
279
  };
288
280
  var mapStateToProps = function mapStateToProps(state) {
@@ -334,9 +326,6 @@ function getTheme(preset) {
334
326
  return dark;
335
327
  }
336
328
 
337
- function _isSlot$2(s) {
338
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
339
- }
340
329
  var ReactiveBase = {
341
330
  name: 'ReactiveBase',
342
331
  data: function data() {
@@ -362,7 +351,6 @@ var ReactiveBase = {
362
351
  enableAppbase: VueTypes.bool.def(false),
363
352
  credentials: vueTypes.types.string,
364
353
  headers: vueTypes.types.headers,
365
- queryParams: vueTypes.types.string,
366
354
  theme: VueTypes.object.def({}),
367
355
  themePreset: VueTypes.string.def('light'),
368
356
  type: vueTypes.types.string,
@@ -378,16 +366,14 @@ var ReactiveBase = {
378
366
  setSearchParams: vueTypes.types.func,
379
367
  mongodb: vueTypes.types.mongodb,
380
368
  endpoint: vueTypes.types.endpointConfig,
381
- preferences: VueTypes.object
369
+ preferences: VueTypes.object,
370
+ httpRequestTimeout: VueTypes.number.def(30)
382
371
  },
383
372
  provide: function provide() {
384
373
  return {
385
374
  theme_reactivesearch: index.composeThemeObject(getTheme(this.$props.themePreset), this.$props.theme),
386
375
  store: this.store,
387
- $searchPreferences: this.preferences,
388
- $emotionCache: this.$parent && this.$parent.$emotionCache || vueEmotion.createCache({
389
- key: 'css'
390
- })
376
+ $searchPreferences: this.preferences
391
377
  };
392
378
  },
393
379
  watch: {
@@ -418,6 +404,9 @@ var ReactiveBase = {
418
404
  },
419
405
  mongodb: function mongodb() {
420
406
  this.updateState(this.$props);
407
+ },
408
+ httpRequestTimeout: function httpRequestTimeout() {
409
+ this.updateState(this.$props);
421
410
  }
422
411
  },
423
412
  computed: {
@@ -464,7 +453,8 @@ var ReactiveBase = {
464
453
  analytics: props.appbaseConfig ? props.appbaseConfig.recordAnalytics : props.analytics,
465
454
  analyticsConfig: props.appbaseConfig,
466
455
  mongodb: props.mongodb,
467
- endpoint: props.endpoint
456
+ endpoint: props.endpoint,
457
+ httpRequestTimeout: (props.httpRequestTimeout || 0) * 1000 || 30000
468
458
  };
469
459
  var queryParams = '';
470
460
  if (typeof window !== 'undefined') {
@@ -547,30 +537,26 @@ var ReactiveBase = {
547
537
  }
548
538
  },
549
539
  render: function render() {
550
- var _this = this;
551
- var children = this.$slots["default"]();
540
+ var h = arguments[0];
541
+ var children = this.$slots["default"];
552
542
  var _this$$props2 = this.$props,
553
543
  style = _this$$props2.style,
554
544
  className = _this$$props2.className;
555
- return vue.createVNode(Provider, {
556
- "store": this.store,
557
- "analyticsRef": this.analyticsRef
558
- }, {
559
- "default": function _default() {
560
- return [vue.createVNode(URLParamsProvider$1, {
561
- "as": _this.$props.as,
562
- "headers": _this.getHeaders,
563
- "style": style,
564
- "className": className,
565
- "getSearchParams": _this.getSearchParams,
566
- "setSearchParams": _this.setSearchParams
567
- }, _isSlot$2(children) ? children : {
568
- "default": function _default() {
569
- return [children];
570
- }
571
- })];
545
+ return h(Provider, {
546
+ "attrs": {
547
+ "store": this.store,
548
+ "analyticsRef": this.analyticsRef
572
549
  }
573
- });
550
+ }, [h(URLParamsProvider$1, {
551
+ "attrs": {
552
+ "as": this.$props.as,
553
+ "headers": this.getHeaders,
554
+ "className": className,
555
+ "getSearchParams": this.getSearchParams,
556
+ "setSearchParams": this.setSearchParams
557
+ },
558
+ "style": style
559
+ }, [children])]);
574
560
  }
575
561
  };
576
562
  ReactiveBase.install = function (Vue) {
@@ -2,54 +2,324 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('@appbaseio/reactivecore');
6
- require('@appbaseio/reactivecore/lib/utils/constants');
7
- require('./_rollupPluginBabelHelpers-f8b843f8.js');
8
- require('vue');
9
- require('vue-types');
10
- require('@appbaseio/reactivecore/lib/utils/helper');
11
- require('@appbaseio/vue-emotion');
12
- require('emotion');
13
- require('polished');
14
- require('./Button-626c5e8e.js');
15
- require('./vueTypes-621a8143.js');
16
- require('./Pagination-a468f960.js');
17
- require('./ReactiveList.js');
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var configureStore = require('@appbaseio/reactivecore');
8
+ var configureStore__default = _interopDefault(configureStore);
9
+ var constants = require('@appbaseio/reactivecore/lib/utils/constants');
10
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
11
+ var VueTypes = _interopDefault(require('vue-types'));
12
+ var vueTypes = require('./vueTypes-b7007f5f.js');
18
13
  require('@appbaseio/reactivecore/lib/utils/transform');
19
14
  require('redux');
20
- require('./index-dc25b706.js');
21
- require('./ComponentWrapper-db45cc6d.js');
22
- require('./PreferencesConsumer-034c55e3.js');
23
- require('./Title-8802a218.js');
24
- require('./ListItem-c067bc07.js');
25
- require('./Card-c381ded3.js');
26
- require('./Flex-d5675ea6.js');
27
- require('hotkeys-js');
28
- require('./DataSearch-7c71ec9f.js');
29
- require('./CancelSvg-062a42f0.js');
30
- require('./Input-4d278ca0.js');
31
- require('compute-scroll-into-view');
32
- require('./Container-29f049b2.js');
33
- require('vue-highlight-words');
34
- require('@vue/babel-helper-vue-transform-on');
35
- var ReactiveComponent = require('./ReactiveComponent-f0f486ca.js');
36
- require('@appbaseio/reactivecore/lib/utils/suggestions');
37
- require('./FormControlList-cf1ff2ca.js');
38
- require('./utils-83fd01e9.js');
39
- require('./SingleList.js');
40
- require('./MultiList.js');
41
- require('./DropDown-3b899b20.js');
42
- require('./SingleDropdownList.js');
43
- require('./MultiDropdownList.js');
44
- require('./ToggleButton.js');
45
- require('vue-no-ssr');
46
- require('./ssr-eb901d09.js');
47
- require('./DynamicRangeSlider.js');
48
- require('./SingleRange.js');
49
- require('./MultiRange.js');
50
- require('./RangeSlider.js');
51
- require('./RangeInput.js');
15
+ var index = require('./index-de136c17.js');
16
+ var ComponentWrapper = require('./ComponentWrapper-94c50228.js');
17
+ var PreferencesConsumer = require('./PreferencesConsumer-5e6e84a2.js');
18
+
19
+ var _excluded = ["options"];
20
+ var updateQuery = configureStore.Actions.updateQuery,
21
+ setQueryOptions = configureStore.Actions.setQueryOptions,
22
+ setCustomQuery = configureStore.Actions.setCustomQuery,
23
+ setDefaultQuery = configureStore.Actions.setDefaultQuery;
24
+ var parseHits = configureStore.helper.parseHits,
25
+ isEqual = configureStore.helper.isEqual,
26
+ getCompositeAggsQuery = configureStore.helper.getCompositeAggsQuery,
27
+ getResultStats = configureStore.helper.getResultStats,
28
+ extractQueryFromCustomQuery = configureStore.helper.extractQueryFromCustomQuery,
29
+ getOptionsForCustomQuery = configureStore.helper.getOptionsForCustomQuery;
30
+ var ReactiveComponent = {
31
+ name: 'ReactiveComponent',
32
+ props: {
33
+ componentId: vueTypes.types.stringRequired,
34
+ aggregationField: vueTypes.types.string,
35
+ aggregationSize: VueTypes.number,
36
+ size: VueTypes.number,
37
+ defaultQuery: vueTypes.types.func,
38
+ customQuery: vueTypes.types.func,
39
+ filterLabel: vueTypes.types.string,
40
+ react: vueTypes.types.react,
41
+ showFilter: VueTypes.bool.def(true),
42
+ URLParams: VueTypes.bool.def(false),
43
+ distinctField: vueTypes.types.string,
44
+ distinctFieldConfig: vueTypes.types.props,
45
+ index: VueTypes.string,
46
+ endpoint: vueTypes.types.endpointConfig
47
+ },
48
+ created: function created() {
49
+ var _this = this;
50
+ var props = this.$props;
51
+ this.internalComponent = null;
52
+ this.$defaultQuery = null;
53
+ // Set custom query in store
54
+ index.updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
55
+ var customQuery = props.customQuery,
56
+ componentId = props.componentId,
57
+ filterLabel = props.filterLabel,
58
+ showFilter = props.showFilter,
59
+ URLParams = props.URLParams,
60
+ distinctField = props.distinctField,
61
+ distinctFieldConfig = props.distinctFieldConfig,
62
+ index$1 = props.index;
63
+ if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
64
+ console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
65
+ }
66
+ if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
67
+ console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
68
+ }
69
+ if (!this.enableAppbase && index$1) {
70
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
71
+ }
72
+ if (customQuery) {
73
+ var calcCustomQuery = customQuery(this.selectedValue, props);
74
+ var query = extractQueryFromCustomQuery(calcCustomQuery);
75
+ var customQueryOptions = calcCustomQuery ? getOptionsForCustomQuery(calcCustomQuery) : null;
76
+ if (customQueryOptions) {
77
+ this.setQueryOptions(componentId, _rollupPluginBabelHelpers._extends({}, customQueryOptions, this.getAggsQuery()), false);
78
+ } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
79
+ this.updateQuery({
80
+ componentId: componentId,
81
+ query: query,
82
+ value: this.selectedValue || null,
83
+ label: filterLabel,
84
+ showFilter: showFilter,
85
+ URLParams: URLParams
86
+ });
87
+ }
88
+ this.setQuery = function (_ref) {
89
+ var options = _ref.options,
90
+ obj = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref, _excluded);
91
+ var queryToBeSet = obj.query;
52
92
 
93
+ // when enableAppbase is true, Backend throws error because of repeated query in request body
94
+ if (queryToBeSet && queryToBeSet.query) {
95
+ queryToBeSet = queryToBeSet.query;
96
+ }
97
+ var customQueryCalc = _rollupPluginBabelHelpers._extends({}, options, {
98
+ query: queryToBeSet
99
+ });
100
+ var rsAPIQuery = customQueryCalc;
101
+ // handle stored queries
102
+ if (queryToBeSet && queryToBeSet.id) {
103
+ rsAPIQuery = queryToBeSet;
104
+ }
105
+ // Update customQuery field for RS API
106
+ _this.setCustomQuery(props.componentId, rsAPIQuery);
107
+ if (options) {
108
+ _this.setQueryOptions(props.componentId, _rollupPluginBabelHelpers._extends({}, _this.getAggsQuery(), options), false);
109
+ }
110
+ _this.updateQuery(_rollupPluginBabelHelpers._extends({}, obj, {
111
+ query: customQueryCalc.query,
112
+ componentId: props.componentId,
113
+ label: props.filterLabel,
114
+ showFilter: props.showFilter,
115
+ URLParams: props.URLParams
116
+ }));
117
+ };
118
+ if (props.defaultQuery) {
119
+ this.internalComponent = props.componentId + "__internal";
120
+ }
121
+ if (this.internalComponent && this.$props.defaultQuery) {
122
+ index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
123
+ this.$defaultQuery = this.$props.defaultQuery(this.selectedValue, this.$props);
124
+ var _query = extractQueryFromCustomQuery(this.$defaultQuery);
125
+ var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
126
+ if (queryOptions) {
127
+ this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
128
+ } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
129
+ this.updateQuery({
130
+ componentId: this.internalComponent,
131
+ query: _query
132
+ });
133
+ }
134
+ },
135
+ watch: {
136
+ hits: function hits(newVal, oldVal) {
137
+ if (!isEqual(newVal, oldVal)) {
138
+ this.$emit('data', this.getData());
139
+ }
140
+ },
141
+ rawData: function rawData(newVal, oldVal) {
142
+ if (!isEqual(newVal, oldVal)) {
143
+ this.$emit('data', this.getData());
144
+ }
145
+ },
146
+ aggregations: function aggregations(newVal, oldVal) {
147
+ if (!isEqual(newVal, oldVal)) {
148
+ this.$emit('data', this.getData());
149
+ }
150
+ },
151
+ aggregationData: function aggregationData(newVal, oldVal) {
152
+ if (!isEqual(newVal, oldVal)) {
153
+ this.$emit('data', this.getData());
154
+ }
155
+ },
156
+ promotedResults: function promotedResults(newVal, oldVal) {
157
+ if (!isEqual(newVal, oldVal)) {
158
+ this.$emit('data', this.getData());
159
+ }
160
+ },
161
+ hidden: function hidden(newVal, oldVal) {
162
+ if (!isEqual(newVal, oldVal)) {
163
+ this.$emit('data', this.getData());
164
+ }
165
+ },
166
+ total: function total(newVal, oldVal) {
167
+ if (!isEqual(newVal, oldVal)) {
168
+ this.$emit('data', this.getData());
169
+ }
170
+ },
171
+ time: function time(newVal, oldVal) {
172
+ if (!isEqual(newVal, oldVal)) {
173
+ this.$emit('data', this.getData());
174
+ }
175
+ },
176
+ defaultQuery: function defaultQuery(newVal, oldVal) {
177
+ if (newVal && !index.isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
178
+ this.$defaultQuery = newVal(this.selectedValue, this.$props);
179
+ var query = extractQueryFromCustomQuery(this.$defaultQuery);
180
+ var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
181
+ if (queryOptions) {
182
+ this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
183
+ } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
184
+ // Update default query for RS API
185
+ index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
186
+ this.updateQuery({
187
+ componentId: this.internalComponent,
188
+ query: query
189
+ });
190
+ }
191
+ },
192
+ customQuery: function customQuery(newVal, oldVal) {
193
+ if (newVal && !index.isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
194
+ var componentId = this.$props.componentId;
195
+ this.$customQuery = newVal(this.selectedValue, this.$props);
196
+ var query = extractQueryFromCustomQuery(this.$customQuery);
197
+ var queryOptions = getOptionsForCustomQuery(this.$customQuery);
198
+ if (queryOptions) {
199
+ this.setQueryOptions(componentId, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
200
+ } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
53
201
 
202
+ // Update custom query for RS API
203
+ index.updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
204
+ this.updateQuery({
205
+ componentId: componentId,
206
+ query: query
207
+ });
208
+ }
209
+ }
210
+ },
211
+ render: function render() {
212
+ var h = arguments[0];
213
+ try {
214
+ var dom = this.$scopedSlots["default"];
215
+ var error = this.error,
216
+ isLoading = this.isLoading,
217
+ selectedValue = this.selectedValue;
218
+ var propsToBePassed = _rollupPluginBabelHelpers._extends({
219
+ error: error,
220
+ loading: isLoading
221
+ }, this.getData(), {
222
+ value: selectedValue,
223
+ setQuery: this.setQuery
224
+ });
225
+ return h("div", [dom(propsToBePassed)]);
226
+ } catch (e) {
227
+ return null;
228
+ }
229
+ },
230
+ methods: {
231
+ getAggsQuery: function getAggsQuery() {
232
+ if (this.aggregationField) {
233
+ return {
234
+ aggs: getCompositeAggsQuery({
235
+ props: this.$props,
236
+ showTopHits: true,
237
+ value: this.selectedValue
238
+ }).aggs
239
+ };
240
+ }
241
+ return {};
242
+ },
243
+ getData: function getData() {
244
+ var hits = this.hits,
245
+ aggregations = this.aggregations,
246
+ aggregationData = this.aggregationData,
247
+ promotedResults = this.promotedResults,
248
+ rawData = this.rawData;
249
+ var filteredResults = parseHits(hits);
250
+ if (promotedResults.length) {
251
+ var ids = promotedResults.map(function (item) {
252
+ return item._id;
253
+ }).filter(Boolean);
254
+ if (ids) {
255
+ filteredResults = filteredResults.filter(function (item) {
256
+ return !ids.includes(item._id);
257
+ });
258
+ }
259
+ filteredResults = [].concat(promotedResults, filteredResults);
260
+ }
261
+ return {
262
+ data: filteredResults,
263
+ aggregationData: aggregationData,
264
+ rawData: rawData,
265
+ aggregations: aggregations,
266
+ promotedData: promotedResults,
267
+ resultStats: this.stats
268
+ };
269
+ }
270
+ },
271
+ computed: {
272
+ stats: function stats() {
273
+ return getResultStats(this);
274
+ }
275
+ }
276
+ };
277
+ ReactiveComponent.hasInternalComponent = function (props) {
278
+ return !!props.defaultQuery;
279
+ };
280
+ var mapStateToProps = function mapStateToProps(state, props) {
281
+ return {
282
+ aggregations: state.aggregations[props.componentId] && state.aggregations[props.componentId] || null,
283
+ aggregationData: state.compositeAggregations[props.componentId] || [],
284
+ hits: state.hits[props.componentId] && state.hits[props.componentId].hits || [],
285
+ rawData: state.rawData[props.componentId],
286
+ error: state.error[props.componentId],
287
+ isLoading: state.isLoading[props.componentId],
288
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
289
+ promotedResults: state.promotedResults[props.componentId] || [],
290
+ time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
291
+ total: state.hits[props.componentId] && state.hits[props.componentId].total,
292
+ hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
293
+ componentProps: state.props[props.componentId],
294
+ enableAppbase: state.config.enableAppbase
295
+ };
296
+ };
297
+ var mapDispatchtoProps = {
298
+ setQueryOptions: setQueryOptions,
299
+ updateQuery: updateQuery,
300
+ setCustomQuery: setCustomQuery,
301
+ setDefaultQuery: setDefaultQuery
302
+ };
303
+ var ConnectedComponent = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchtoProps)(ReactiveComponent), {
304
+ componentType: constants.componentTypes.reactiveComponent
305
+ });
306
+ var RcConnected = PreferencesConsumer.PreferencesConsumer({
307
+ name: 'RcConnected',
308
+ render: function render(h) {
309
+ return h(ConnectedComponent, {
310
+ attrs: this.$attrs,
311
+ on: this.$listeners,
312
+ scopedSlots: this.$scopedSlots,
313
+ slots: this.$slots
314
+ });
315
+ }
316
+ });
317
+ RcConnected.name = ReactiveComponent.name;
318
+ RcConnected.hasInternalComponent = ReactiveComponent.hasInternalComponent;
319
+ // Add componentType for SSR
320
+ RcConnected.componentType = constants.componentTypes.reactiveComponent;
321
+ RcConnected.install = function (Vue) {
322
+ Vue.component(RcConnected.name, RcConnected);
323
+ };
54
324
 
55
- exports.default = ReactiveComponent.ReactiveComponent;
325
+ exports.default = RcConnected;