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