@appbaseio/reactivesearch-vue 2.0.0-alpha.3 → 3.0.0-alpha.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 (108) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +17405 -25231
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +6 -15
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/Button-ad042719.js +59 -0
  6. package/dist/cjs/Card-f5ab024a.js +27 -0
  7. package/dist/cjs/{ComponentWrapper-ad3dad02.js → ComponentWrapper-75f88599.js} +42 -56
  8. package/dist/cjs/Container-29f049b2.js +12 -0
  9. package/dist/cjs/DropDown-6cf84c47.js +698 -0
  10. package/dist/cjs/DynamicRangeSlider.js +103 -155
  11. package/dist/cjs/Flex-d5675ea6.js +48 -0
  12. package/dist/cjs/FormControlList-fadd792f.js +42 -0
  13. package/dist/cjs/Input-4b434436.js +74 -0
  14. package/dist/cjs/ListItem-d57d648d.js +42 -0
  15. package/dist/cjs/MultiDropdownList.js +124 -240
  16. package/dist/cjs/MultiList.js +123 -261
  17. package/dist/cjs/MultiRange.js +87 -133
  18. package/dist/cjs/{Pagination-71e85fa9.js → Pagination-b5ddc906.js} +70 -83
  19. package/dist/cjs/PreferencesConsumer-eb265924.js +75 -0
  20. package/dist/cjs/RangeInput.js +163 -171
  21. package/dist/cjs/RangeSlider.js +81 -109
  22. package/dist/cjs/ReactiveBase.js +139 -157
  23. package/dist/cjs/ReactiveComponent-eb8db4c1.js +2189 -0
  24. package/dist/cjs/ReactiveComponent.js +46 -340
  25. package/dist/cjs/ReactiveGoogleMap.js +445 -655
  26. package/dist/cjs/ReactiveList.js +179 -304
  27. package/dist/cjs/ResultCard.js +36 -36
  28. package/dist/cjs/ResultList.js +48 -56
  29. package/dist/cjs/SelectedFilters.js +62 -69
  30. package/dist/cjs/SingleDropdownList.js +117 -177
  31. package/dist/cjs/SingleList.js +121 -205
  32. package/dist/cjs/SingleRange.js +78 -105
  33. package/dist/cjs/StateProvider.js +74 -47
  34. package/dist/cjs/Title-8802a218.js +12 -0
  35. package/dist/cjs/ToggleButton.js +72 -119
  36. package/dist/cjs/{_rollupPluginBabelHelpers-c705cbe6.js → _rollupPluginBabelHelpers-f8b843f8.js} +0 -15
  37. package/dist/cjs/{index-6a167fe0.js → index-d8d8f291.js} +38 -108
  38. package/dist/cjs/index.js +44 -41
  39. package/dist/cjs/initReactivesearch.js +69 -152
  40. package/dist/cjs/install.js +47 -43
  41. package/dist/cjs/ssr-6907ada3.js +66 -0
  42. package/dist/cjs/{utils-d6a52588.js → utils-83fd01e9.js} +7 -16
  43. package/dist/cjs/version.js +1 -1
  44. package/dist/cjs/{vueTypes-727b7c63.js → vueTypes-1bf00978.js} +8 -19
  45. package/dist/es/Button-474510e3.js +53 -0
  46. package/dist/es/{Card-450683f1.js → Card-38cbe652.js} +3 -3
  47. package/dist/es/{ComponentWrapper-424e86fd.js → ComponentWrapper-5166c76a.js} +42 -56
  48. package/dist/es/{Container-ba826e96.js → Container-d00219f7.js} +2 -2
  49. package/dist/es/DropDown-8764360c.js +688 -0
  50. package/dist/es/DynamicRangeSlider.js +103 -155
  51. package/dist/es/Flex-a08e22d7.js +46 -0
  52. package/dist/es/FormControlList-fe6eaee4.js +38 -0
  53. package/dist/es/Input-4a8ef1f3.js +69 -0
  54. package/dist/es/{ListItem-cad14c5e.js → ListItem-16756c02.js} +7 -8
  55. package/dist/es/MultiDropdownList.js +124 -240
  56. package/dist/es/MultiList.js +123 -261
  57. package/dist/es/MultiRange.js +87 -133
  58. package/dist/es/{Pagination-784bf143.js → Pagination-72bd1d9e.js} +70 -83
  59. package/dist/es/PreferencesConsumer-c276709c.js +73 -0
  60. package/dist/es/RangeInput.js +163 -170
  61. package/dist/es/RangeSlider.js +81 -109
  62. package/dist/es/ReactiveBase.js +138 -155
  63. package/dist/es/ReactiveComponent-f9fa5780.js +2183 -0
  64. package/dist/es/ReactiveComponent.js +42 -337
  65. package/dist/es/ReactiveGoogleMap.js +440 -649
  66. package/dist/es/ReactiveList.js +177 -301
  67. package/dist/es/ResultCard.js +36 -36
  68. package/dist/es/ResultList.js +48 -56
  69. package/dist/es/SelectedFilters.js +62 -69
  70. package/dist/es/SingleDropdownList.js +117 -177
  71. package/dist/es/SingleList.js +121 -205
  72. package/dist/es/SingleRange.js +78 -105
  73. package/dist/es/StateProvider.js +75 -48
  74. package/dist/es/{Title-3342664a.js → Title-863dfa42.js} +2 -2
  75. package/dist/es/ToggleButton.js +72 -119
  76. package/dist/es/{_rollupPluginBabelHelpers-76660dab.js → _rollupPluginBabelHelpers-ded08042.js} +0 -15
  77. package/dist/es/{index-7788a843.js → index-4520a598.js} +39 -107
  78. package/dist/es/index.js +30 -32
  79. package/dist/es/initReactivesearch.js +69 -152
  80. package/dist/es/install.js +49 -41
  81. package/dist/es/{ssr-b2c0b401.js → ssr-af398f0c.js} +36 -7
  82. package/dist/es/{utils-9e68acee.js → utils-9e5a16a1.js} +7 -16
  83. package/dist/es/version.js +1 -1
  84. package/dist/es/{vueTypes-b8146772.js → vueTypes-f1923c72.js} +8 -19
  85. package/package.json +10 -9
  86. package/dist/cjs/Button-446f819e.js +0 -68
  87. package/dist/cjs/CancelSvg-9f258f4f.js +0 -449
  88. package/dist/cjs/Card-642547a8.js +0 -30
  89. package/dist/cjs/Container-daf30918.js +0 -15
  90. package/dist/cjs/DataSearch-6cf29cf0.js +0 -2323
  91. package/dist/cjs/DataSearch.js +0 -30
  92. package/dist/cjs/DropDown-c479bbb0.js +0 -328
  93. package/dist/cjs/Flex-aa517a13.js +0 -52
  94. package/dist/cjs/FormControlList-c195a592.js +0 -47
  95. package/dist/cjs/Input-e6603a7e.js +0 -79
  96. package/dist/cjs/ListItem-8c9e0d68.js +0 -46
  97. package/dist/cjs/Title-1de7d0f4.js +0 -15
  98. package/dist/cjs/install-42ba1d44.js +0 -1409
  99. package/dist/cjs/ssr-3027b848.js +0 -39
  100. package/dist/es/Button-d8bc15ea.js +0 -59
  101. package/dist/es/CancelSvg-4cfae5fd.js +0 -440
  102. package/dist/es/DataSearch-4888aa43.js +0 -2308
  103. package/dist/es/DataSearch.js +0 -22
  104. package/dist/es/DropDown-05a644a5.js +0 -322
  105. package/dist/es/Flex-1f0795c3.js +0 -47
  106. package/dist/es/FormControlList-c22d64f6.js +0 -40
  107. package/dist/es/Input-7a2a9fac.js +0 -71
  108. package/dist/es/install-80bc2764.js +0 -1402
@@ -1,15 +1,16 @@
1
1
  import configureStore, { Actions, helper } from '@appbaseio/reactivecore';
2
- import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
3
- import VueTypes from 'vue-types';
4
2
  import '@appbaseio/reactivecore/lib/utils/constants';
3
+ import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
4
+ import { h, createVNode, isVNode } from 'vue';
5
+ import VueTypes from 'vue-types';
5
6
  import { isEqual as isEqual$1, transformRequestUsingEndpoint } from '@appbaseio/reactivecore/lib/utils/helper';
6
- import styled from '@appbaseio/vue-emotion';
7
- import { t as types } from './vueTypes-b8146772.js';
7
+ import { styled, createCache } from '@appbaseio/vue-emotion';
8
+ import { t as types } from './vueTypes-f1923c72.js';
8
9
  import 'redux';
9
- import { c as connect, e as composeThemeObject, X as X_SEARCH_CLIENT } from './index-7788a843.js';
10
- import _mergeJSXProps from '@vue/babel-helper-vue-jsx-merge-props';
10
+ import { c as connect, e as composeThemeObject, X as X_SEARCH_CLIENT } from './index-4520a598.js';
11
11
  import { updateAnalyticsConfig } from '@appbaseio/reactivecore/lib/actions/analytics';
12
12
  import Appbase from 'appbase-js';
13
+ import AppbaseAnalytics from '@appbaseio/analytics';
13
14
  import 'url-search-params-polyfill';
14
15
 
15
16
  var Provider = {
@@ -22,53 +23,64 @@ var Provider = {
22
23
  if (!store.dispatch && !store.subscribe && !store.getState) {
23
24
  throw new Error('[reactivesearch-vue] - store provided is not a valid redux store');
24
25
  }
25
-
26
26
  return true;
27
27
  }
28
+ },
29
+ analyticsRef: {
30
+ type: Object,
31
+ required: false
28
32
  }
29
33
  },
30
34
  provide: function provide() {
31
35
  return {
32
- $$store: this.store
36
+ $$store: this.store,
37
+ $analytics: this.analyticsRef
33
38
  };
34
39
  },
35
- render: function render(h) {
36
- if (this.$slots["default"].length > 1) {
37
- return h('div', this.$slots["default"]);
40
+ render: function render() {
41
+ if (this.$slots["default"]().length > 1) {
42
+ return h('div', this.$slots["default"]());
38
43
  }
39
-
40
- return this.$slots["default"][0];
44
+ return this.$slots["default"]()[0];
41
45
  }
42
46
  };
43
47
 
44
48
  var _templateObject;
45
- var Base = {
46
- functional: true,
47
- render: function render(h, _ref) {
48
- var _ref$data$attrs$as = _ref.data.attrs.as,
49
- T = _ref$data$attrs$as === void 0 ? 'div' : _ref$data$attrs$as,
50
- props = _ref.data,
51
- children = _ref.children;
52
- delete props.attrs.as;
53
- return h(T, _mergeJSXProps([{}, props]), [children]);
54
- }
49
+ function _isSlot(s) {
50
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
51
+ }
52
+ var Base = function Base(_ref) {
53
+ var _ref$data$attrs$as = _ref.data.attrs.as,
54
+ T = _ref$data$attrs$as === void 0 ? 'div' : _ref$data$attrs$as,
55
+ props = _ref.data,
56
+ children = _ref.children;
57
+ var propsVar = props;
58
+ delete propsVar.attrs.as;
59
+ return createVNode(T, props, _isSlot(children) ? children : {
60
+ "default": function _default() {
61
+ return [children];
62
+ }
63
+ });
55
64
  };
56
65
  var Base$1 = styled(Base)(_templateObject || (_templateObject = _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) {
57
66
  var theme = _ref2.theme;
58
- return theme.typography.fontFamily;
67
+ return theme && theme.typography ? theme.typography.fontFamily : 'unset';
59
68
  }, function (_ref3) {
60
69
  var theme = _ref3.theme;
61
- return theme.typography.fontSize;
70
+ return theme && theme.typography ? theme.typography.fontSize : 'unset';
62
71
  }, function (_ref4) {
63
72
  var theme = _ref4.theme;
64
- return theme.colors.textColor;
73
+ return theme && theme.colors ? theme.colors.textColor : 'unset';
65
74
  }, function (_ref5) {
66
75
  var theme = _ref5.theme;
67
- return theme.typography.fontFamily;
76
+ return theme && theme.typography ? theme.typography.fontFamily : 'unset';
68
77
  });
69
78
 
79
+ function _isSlot$1(s) {
80
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
81
+ }
70
82
  var setHeaders = Actions.setHeaders,
71
- setValue = Actions.setValue;
83
+ setValue = Actions.setValue;
72
84
  var isEqual = helper.isEqual;
73
85
  var URLParamsProvider = {
74
86
  name: 'URLParamsProvider',
@@ -81,32 +93,27 @@ var URLParamsProvider = {
81
93
  },
82
94
  mounted: function mounted() {
83
95
  var _this = this;
84
-
85
96
  this.init();
86
-
87
97
  window.onpopstate = function () {
88
98
  _this.init();
89
-
90
- var activeComponents = Array.from(_this.params.keys()); // remove inactive components from selectedValues
91
-
99
+ var activeComponents = Array.from(_this.params.keys());
100
+ // remove inactive components from selectedValues
92
101
  Object.keys(_this.currentSelectedState).filter(function (item) {
93
102
  return !activeComponents.includes(item);
94
103
  }).forEach(function (component) {
95
104
  _this.setValue(component, null, undefined, undefined, undefined, undefined, undefined, undefined, 'URL');
96
- }); // update active components in selectedValues
97
-
105
+ });
106
+ // update active components in selectedValues
98
107
  Array.from(_this.params.entries()).forEach(function (item) {
99
108
  try {
100
109
  var component = item[0],
101
- value = item[1];
102
-
110
+ value = item[1];
103
111
  var _ref = _this.selectedValues[component] || {
104
- label: component
105
- },
106
- label = _ref.label,
107
- showFilter = _ref.showFilter,
108
- URLParams = _ref.URLParams;
109
-
112
+ label: component
113
+ },
114
+ label = _ref.label,
115
+ showFilter = _ref.showFilter,
116
+ URLParams = _ref.URLParams;
110
117
  _this.setValue(component, JSON.parse(value), label, showFilter, URLParams, undefined, undefined, undefined, 'URL');
111
118
  } catch (e) {
112
119
  // Do not set value if JSON parsing fails.
@@ -124,7 +131,6 @@ var URLParamsProvider = {
124
131
  },
125
132
  selectedValues: function selectedValues(newVal, oldVal) {
126
133
  var _this2 = this;
127
-
128
134
  if (!isEqual(newVal, oldVal)) {
129
135
  this.searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
130
136
  this.params = new URLSearchParams(this.searchString);
@@ -134,8 +140,8 @@ var URLParamsProvider = {
134
140
  currentComponents.filter(function (component) {
135
141
  return newVal[component].URLParams;
136
142
  }).forEach(function (component) {
137
- var selectedValues = newVal[component]; // prevents empty history pollution on initial load
138
-
143
+ var selectedValues = newVal[component];
144
+ // prevents empty history pollution on initial load
139
145
  if (_this2.hasValidValue(newVal[component]) || _this2.hasValidValue(oldVal[component])) {
140
146
  if (selectedValues.URLParams) {
141
147
  if (selectedValues.category) {
@@ -143,48 +149,41 @@ var URLParamsProvider = {
143
149
  category: selectedValues.category,
144
150
  value: selectedValues.value
145
151
  }));
146
-
147
152
  if (shouldUpdateHistory) {
148
153
  shouldPushHistory = true;
149
154
  }
150
155
  } else {
151
156
  var _shouldUpdateHistory = _this2.setURL(component, _this2.getValue(selectedValues.value));
152
-
153
157
  if (_shouldUpdateHistory) {
154
158
  shouldPushHistory = true;
155
159
  }
156
160
  }
157
161
  } else {
158
162
  _this2.params["delete"](component);
159
-
160
163
  shouldPushHistory = true;
161
164
  }
162
165
  } else if (!_this2.hasValidValue(newVal[component]) && urlComponents.includes(component)) {
163
166
  // doesn't have a valid value, but the url has a (stale) valid value set
164
167
  _this2.params["delete"](component);
165
-
166
168
  shouldPushHistory = true;
167
169
  }
168
- }); // remove unmounted components
170
+ });
169
171
 
172
+ // remove unmounted components
170
173
  Object.keys(newVal).filter(function (component) {
171
174
  return !currentComponents.includes(component);
172
175
  }).forEach(function (component) {
173
176
  _this2.params["delete"](component);
174
-
175
177
  shouldPushHistory = true;
176
178
  });
177
-
178
179
  if (!currentComponents.length) {
179
180
  Array.from(this.params.keys()).forEach(function (item) {
180
181
  if (_this2.searchComponents && _this2.searchComponents.includes(item)) {
181
182
  _this2.params["delete"](item);
182
-
183
183
  shouldPushHistory = true;
184
184
  }
185
185
  });
186
186
  }
187
-
188
187
  if (shouldPushHistory) {
189
188
  this.pushToHistory();
190
189
  }
@@ -208,10 +207,8 @@ var URLParamsProvider = {
208
207
  // search on homepage -> route changes -> search results page with same search query
209
208
  if (window) {
210
209
  var searchString = this.$props.getSearchParams ? this.$props.getSearchParams() : window.location.search;
211
-
212
210
  if (searchString !== this.searchString) {
213
211
  var event;
214
-
215
212
  if (typeof Event === 'function') {
216
213
  event = new Event('popstate');
217
214
  } else {
@@ -219,7 +216,6 @@ var URLParamsProvider = {
219
216
  event = document.createEvent('Event');
220
217
  event.initEvent('popstate', true, true);
221
218
  }
222
-
223
219
  window.dispatchEvent(event);
224
220
  }
225
221
  }
@@ -231,20 +227,17 @@ var URLParamsProvider = {
231
227
  },
232
228
  getValue: function getValue(value) {
233
229
  var _this3 = this;
234
-
235
230
  if (Array.isArray(value) && value.length) {
236
231
  return value.map(function (item) {
237
232
  return _this3.getValue(item);
238
233
  });
239
234
  }
240
-
241
235
  if (value && typeof value === 'object') {
242
236
  // TODO: support for NestedList
243
237
  if (value.location) return value;
244
238
  if (value.category) return value;
245
239
  return value.label || value.key || null;
246
240
  }
247
-
248
241
  return value;
249
242
  },
250
243
  setURL: function setURL(component, value) {
@@ -252,21 +245,17 @@ var URLParamsProvider = {
252
245
  this.params["delete"](component);
253
246
  return true;
254
247
  }
255
-
256
248
  var data = JSON.stringify(value);
257
-
258
249
  if (data !== this.params.get(component)) {
259
250
  this.params.set(component, data);
260
251
  return true;
261
252
  }
262
-
263
253
  return false;
264
254
  },
265
255
  pushToHistory: function pushToHistory() {
266
256
  var paramsSting = this.params.toString() ? "?" + this.params.toString() : '';
267
257
  var base = window.location.href.split('?')[0];
268
258
  var newURL = "" + base + paramsSting;
269
-
270
259
  if (this.$props.setSearchParams) {
271
260
  this.$props.setSearchParams(newURL);
272
261
  } else if (window.history.pushState) {
@@ -274,38 +263,34 @@ var URLParamsProvider = {
274
263
  path: newURL
275
264
  }, '', newURL);
276
265
  }
277
-
278
266
  this.init();
279
267
  }
280
268
  },
281
269
  render: function render() {
282
- var h = arguments[0];
283
- var children = this.$slots["default"];
284
- return h(Base$1, {
285
- "attrs": {
286
- "as": this.$props.as
287
- },
270
+ var children = this.$slots["default"]();
271
+ return createVNode(Base$1, {
272
+ "as": this.$props.as,
288
273
  "class": this.$props.className
289
- }, [children]);
274
+ }, _isSlot$1(children) ? children : {
275
+ "default": function _default() {
276
+ return [children];
277
+ }
278
+ });
290
279
  }
291
280
  };
292
-
293
281
  var mapStateToProps = function mapStateToProps(state) {
294
282
  return {
295
283
  selectedValues: state.selectedValues,
296
284
  searchComponents: state.components
297
285
  };
298
286
  };
299
-
300
287
  var mapDispatchtoProps = {
301
288
  setHeaders: setHeaders,
302
289
  setValue: setValue
303
290
  };
304
-
305
291
  URLParamsProvider.install = function (Vue) {
306
292
  Vue.component(URLParamsProvider.name, URLParamsProvider);
307
293
  };
308
-
309
294
  var URLParamsProvider$1 = connect(mapStateToProps, mapDispatchtoProps)(URLParamsProvider);
310
295
 
311
296
  var typography = {
@@ -339,10 +324,12 @@ function getTheme(preset) {
339
324
  if (preset === 'light') {
340
325
  return light;
341
326
  }
342
-
343
327
  return dark;
344
328
  }
345
329
 
330
+ function _isSlot$2(s) {
331
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
332
+ }
346
333
  var ReactiveBase = {
347
334
  name: 'ReactiveBase',
348
335
  data: function data() {
@@ -354,25 +341,10 @@ var ReactiveBase = {
354
341
  created: function created() {
355
342
  this.setStore(this.$props);
356
343
  },
357
- mounted: function mounted() {
358
- var analyticsConfig = this.analyticsConfig,
359
- enableAppbase = this.enableAppbase,
360
- endpoint = this.endpoint; // TODO: Remove in 2.0
361
-
362
- if (analyticsConfig !== undefined) {
363
- console.warn('Warning(ReactiveSearch): The `analyticsConfig` prop has been marked as deprecated, please use the `appbaseConfig` prop instead.');
364
- }
365
-
366
- if (!enableAppbase && endpoint) {
367
- console.warn('Warning(ReactiveSearch): The `endpoint` prop works only when `enableAppbase` prop is set to true.');
368
- }
369
- },
370
344
  props: {
371
345
  app: types.string,
372
346
  analytics: VueTypes.bool,
373
- analyticsConfig: types.analyticsConfig,
374
- appbaseConfig: types.appbaseConfig,
375
- enableAppbase: VueTypes.bool.def(false),
347
+ reactivesearchAPIConfig: types.reactivesearchAPIConfig,
376
348
  credentials: types.string,
377
349
  headers: types.headers,
378
350
  queryParams: types.string,
@@ -390,12 +362,17 @@ var ReactiveBase = {
390
362
  getSearchParams: types.func,
391
363
  setSearchParams: types.func,
392
364
  mongodb: types.mongodb,
393
- endpoint: types.endpointConfig
365
+ endpoint: types.endpointConfig,
366
+ preferences: VueTypes.object
394
367
  },
395
368
  provide: function provide() {
396
369
  return {
397
370
  theme_reactivesearch: composeThemeObject(getTheme(this.$props.themePreset), this.$props.theme),
398
- store: this.store
371
+ store: this.store,
372
+ $searchPreferences: this.preferences,
373
+ $emotionCache: this.$parent && this.$parent.$emotionCache || createCache({
374
+ key: 'css'
375
+ })
399
376
  };
400
377
  },
401
378
  watch: {
@@ -417,14 +394,7 @@ var ReactiveBase = {
417
394
  headers: function headers() {
418
395
  this.updateState(this.$props);
419
396
  },
420
- analyticsConfig: function analyticsConfig(newVal, oldVal) {
421
- if (!isEqual$1(newVal, oldVal)) {
422
- if (this.store) {
423
- this.store.dispatch(updateAnalyticsConfig(newVal));
424
- }
425
- }
426
- },
427
- appbaseConfig: function appbaseConfig(newVal, oldVal) {
397
+ reactivesearchAPIConfig: function reactivesearchAPIConfig(newVal, oldVal) {
428
398
  if (!isEqual$1(newVal, oldVal)) {
429
399
  if (this.store) {
430
400
  this.store.dispatch(updateAnalyticsConfig(newVal));
@@ -438,20 +408,17 @@ var ReactiveBase = {
438
408
  computed: {
439
409
  getHeaders: function getHeaders() {
440
410
  var _this$$props = this.$props,
441
- enableAppbase = _this$$props.enableAppbase,
442
- headers = _this$$props.headers,
443
- appbaseConfig = _this$$props.appbaseConfig,
444
- mongodb = _this$$props.mongodb,
445
- endpoint = _this$$props.endpoint;
446
-
447
- var _ref = appbaseConfig || {},
448
- enableTelemetry = _ref.enableTelemetry;
449
-
450
- return _extends({}, enableAppbase && !mongodb && _extends({
411
+ headers = _this$$props.headers,
412
+ reactivesearchAPIConfig = _this$$props.reactivesearchAPIConfig,
413
+ mongodb = _this$$props.mongodb,
414
+ endpoint = _this$$props.endpoint;
415
+ var _ref = reactivesearchAPIConfig || {},
416
+ enableTelemetry = _ref.enableTelemetry;
417
+ return _extends({}, !mongodb && _extends({
451
418
  'X-Search-Client': X_SEARCH_CLIENT
452
419
  }, enableTelemetry === false && {
453
420
  'X-Enable-Telemetry': false
454
- }), headers, enableAppbase && endpoint && endpoint.headers && _extends({}, endpoint.headers));
421
+ }), headers, endpoint && endpoint.headers && _extends({}, endpoint.headers));
455
422
  }
456
423
  },
457
424
  methods: {
@@ -461,12 +428,8 @@ var ReactiveBase = {
461
428
  },
462
429
  setStore: function setStore(props) {
463
430
  var credentials = props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
464
-
465
- var appbaseConfig = _extends({}, props.analyticsConfig, props.appbaseConfig);
466
-
467
431
  var url = props.url && props.url.trim() !== '' ? props.url : '';
468
-
469
- if (props.enableAppbase && props.endpoint) {
432
+ if (props.endpoint) {
470
433
  if (props.endpoint.url) {
471
434
  // eslint-disable-next-line prefer-destructuring
472
435
  url = props.endpoint.url;
@@ -474,7 +437,6 @@ var ReactiveBase = {
474
437
  throw Error('Error(ReactiveSearch): The `endpoint` prop object requires `url` property.');
475
438
  }
476
439
  }
477
-
478
440
  var config = {
479
441
  url: url,
480
442
  app: props.app,
@@ -482,58 +444,74 @@ var ReactiveBase = {
482
444
  type: props.type ? props.type : '*',
483
445
  transformRequest: props.transformRequest,
484
446
  transformResponse: props.transformResponse,
485
- enableAppbase: props.enableAppbase,
486
- analytics: props.appbaseConfig ? props.appbaseConfig.recordAnalytics : props.analytics,
487
- analyticsConfig: appbaseConfig,
447
+ enableAppbase: true,
448
+ analytics: props.reactivesearchAPIConfig ? props.reactivesearchAPIConfig.recordAnalytics : props.analytics,
449
+ analyticsConfig: props.reactivesearchAPIConfig,
488
450
  mongodb: props.mongodb,
489
451
  endpoint: props.endpoint
490
452
  };
491
453
  var queryParams = '';
492
-
493
454
  if (typeof window !== 'undefined') {
494
455
  queryParams = window.location.search;
495
456
  } else {
496
457
  queryParams = props.queryParams || '';
497
458
  }
498
-
499
459
  var params = new URLSearchParams(queryParams);
500
460
  var selectedValues = {};
501
461
  var urlValues = {};
502
462
  Array.from(params.keys()).forEach(function (key) {
503
463
  try {
504
464
  var _extends2, _extends3;
505
-
506
465
  var parsedParams = JSON.parse(params.get(key));
507
466
  var selectedValue = {};
508
-
509
467
  if (parsedParams.value) {
510
468
  selectedValue.value = parsedParams.value;
511
469
  } else {
512
470
  selectedValue.value = parsedParams;
513
471
  }
514
-
515
472
  if (parsedParams.category) selectedValue.category = parsedParams.category;
516
473
  selectedValue.reference = 'URL';
517
474
  selectedValues = _extends({}, selectedValues, (_extends2 = {}, _extends2[key] = selectedValue, _extends2));
518
475
  urlValues = _extends({}, urlValues, (_extends3 = {}, _extends3[key] = selectedValue.value, _extends3));
519
- } catch (e) {// Do not add to selectedValues if JSON parsing fails.
476
+ } catch (e) {
477
+ // Do not add to selectedValues if JSON parsing fails.
520
478
  }
521
479
  });
522
480
  var themePreset = props.themePreset,
523
- enableAppbase = props.enableAppbase,
524
- endpoint = props.endpoint;
481
+ endpoint = props.endpoint;
525
482
  var appbaseRef = Appbase(config);
526
-
527
483
  appbaseRef.transformRequest = function (request) {
528
- var modifiedRequest = enableAppbase ? transformRequestUsingEndpoint(request, endpoint) : request;
484
+ var modifiedRequest = transformRequestUsingEndpoint(request, endpoint);
529
485
  if (props.transformRequest) return props.transformRequest(modifiedRequest);
530
486
  return modifiedRequest;
531
487
  };
532
-
533
488
  if (this.$props.transformResponse) {
534
489
  appbaseRef.transformResponse = this.$props.transformResponse;
535
490
  }
536
-
491
+ var analyticsInitConfig = {
492
+ url: url && url.replace(/\/\/.*@/, '//'),
493
+ credentials: appbaseRef.credentials,
494
+ // When endpoint prop is used index is not defined, so we use _default
495
+ index: appbaseRef.app || '_default',
496
+ globalCustomEvents: this.$props.reactivesearchAPIConfig && this.$props.reactivesearchAPIConfig.customEvents
497
+ };
498
+ try {
499
+ if (this.$props.endpoint && this.$props.endpoint.url) {
500
+ // Remove parts between '//' and first '/' in the url
501
+ analyticsInitConfig.url = this.$props.endpoint.url.replace(/\/\/(.*?)\/.*/, '//$1');
502
+ var headerCredentials = this.$props.endpoint.headers && this.$props.endpoint.headers.Authorization;
503
+ analyticsInitConfig.credentials = headerCredentials && headerCredentials.replace('Basic ', '');
504
+ // Decode the credentials
505
+ analyticsInitConfig.credentials = analyticsInitConfig.credentials && atob(analyticsInitConfig.credentials);
506
+ }
507
+ } catch (e) {
508
+ console.error('Endpoint not set correctly for analytics');
509
+ console.error(e);
510
+ }
511
+ var analyticsRef = null;
512
+ if (config.analytics) {
513
+ analyticsRef = AppbaseAnalytics.init(analyticsInitConfig);
514
+ }
537
515
  var initialState = _extends({
538
516
  config: _extends({}, config, {
539
517
  initialQueriesSyncTime: props.initialQueriesSyncTime,
@@ -542,37 +520,42 @@ var ReactiveBase = {
542
520
  themePreset: themePreset
543
521
  }),
544
522
  appbaseRef: appbaseRef,
523
+ analyticsRef: analyticsRef,
545
524
  selectedValues: selectedValues,
546
525
  urlValues: urlValues,
547
526
  headers: this.getHeaders
548
527
  }, this.$props.initialState);
549
-
550
528
  this.store = configureStore(initialState);
529
+ this.analyticsRef = analyticsRef;
551
530
  }
552
531
  },
553
532
  render: function render() {
554
- var h = arguments[0];
555
- var children = this.$slots["default"];
533
+ var _this = this;
534
+ var children = this.$slots["default"]();
556
535
  var _this$$props2 = this.$props,
557
- style = _this$$props2.style,
558
- className = _this$$props2.className;
559
- return h(Provider, {
560
- "attrs": {
561
- "store": this.store
536
+ style = _this$$props2.style,
537
+ className = _this$$props2.className;
538
+ return createVNode(Provider, {
539
+ "store": this.store,
540
+ "analyticsRef": this.analyticsRef
541
+ }, {
542
+ "default": function _default() {
543
+ return [createVNode(URLParamsProvider$1, {
544
+ "as": _this.$props.as,
545
+ "headers": _this.getHeaders,
546
+ "style": style,
547
+ "className": className,
548
+ "getSearchParams": _this.getSearchParams,
549
+ "setSearchParams": _this.setSearchParams
550
+ }, _isSlot$2(children) ? children : {
551
+ "default": function _default() {
552
+ return [children];
553
+ }
554
+ })];
562
555
  }
563
- }, [h(URLParamsProvider$1, {
564
- "attrs": {
565
- "as": this.$props.as,
566
- "headers": this.getHeaders,
567
- "className": className,
568
- "getSearchParams": this.getSearchParams,
569
- "setSearchParams": this.setSearchParams
570
- },
571
- "style": style
572
- }, [children])]);
556
+ });
573
557
  }
574
558
  };
575
-
576
559
  ReactiveBase.install = function (Vue) {
577
560
  Vue.component(ReactiveBase.name, ReactiveBase);
578
561
  };