@appbaseio/reactivesearch-vue 2.0.0-alpha.4 → 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.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +17538 -25422
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +6 -15
- 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-75f88599.js} +42 -56
- package/dist/cjs/Container-29f049b2.js +12 -0
- package/dist/cjs/DropDown-6cf84c47.js +698 -0
- package/dist/cjs/DynamicRangeSlider.js +103 -155
- package/dist/cjs/Flex-d5675ea6.js +48 -0
- package/dist/cjs/FormControlList-fadd792f.js +42 -0
- package/dist/cjs/Input-4b434436.js +74 -0
- package/dist/cjs/ListItem-d57d648d.js +42 -0
- package/dist/cjs/MultiDropdownList.js +124 -240
- package/dist/cjs/MultiList.js +123 -261
- package/dist/cjs/MultiRange.js +87 -133
- package/dist/cjs/{Pagination-71e85fa9.js → Pagination-b5ddc906.js} +70 -83
- package/dist/cjs/PreferencesConsumer-eb265924.js +75 -0
- package/dist/cjs/RangeInput.js +163 -171
- package/dist/cjs/RangeSlider.js +81 -109
- package/dist/cjs/ReactiveBase.js +139 -157
- package/dist/cjs/ReactiveComponent-eb8db4c1.js +2189 -0
- package/dist/cjs/ReactiveComponent.js +46 -340
- package/dist/cjs/ReactiveGoogleMap.js +445 -655
- package/dist/cjs/ReactiveList.js +179 -304
- 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 +121 -205
- 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-6907ada3.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-5166c76a.js} +42 -56
- package/dist/es/{Container-ba826e96.js → Container-d00219f7.js} +2 -2
- package/dist/es/DropDown-8764360c.js +688 -0
- package/dist/es/DynamicRangeSlider.js +103 -155
- package/dist/es/Flex-a08e22d7.js +46 -0
- package/dist/es/FormControlList-fe6eaee4.js +38 -0
- package/dist/es/Input-4a8ef1f3.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 +123 -261
- package/dist/es/MultiRange.js +87 -133
- package/dist/es/{Pagination-784bf143.js → Pagination-72bd1d9e.js} +70 -83
- package/dist/es/PreferencesConsumer-c276709c.js +73 -0
- package/dist/es/RangeInput.js +163 -170
- package/dist/es/RangeSlider.js +81 -109
- package/dist/es/ReactiveBase.js +138 -155
- package/dist/es/ReactiveComponent-f9fa5780.js +2183 -0
- package/dist/es/ReactiveComponent.js +42 -337
- package/dist/es/ReactiveGoogleMap.js +440 -649
- package/dist/es/ReactiveList.js +177 -301
- 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 +121 -205
- 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-af398f0c.js} +36 -7
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
2
1
|
import { validProps, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
2
|
+
import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
|
|
3
3
|
import { transformRequestUsingEndpoint, pushToAndClause, buildQuery, extractQueryFromCustomQuery, getOptionsForCustomQuery } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
4
4
|
import { isSearchComponent, getRSQuery, extractPropsFromState, getDependentQueries } from '@appbaseio/reactivecore/lib/utils/transform';
|
|
5
5
|
import Appbase from 'appbase-js';
|
|
@@ -13,15 +13,13 @@ import fetchGraphQL from '@appbaseio/reactivecore/lib/utils/graphQL';
|
|
|
13
13
|
import { isPropertyDefined } from '@appbaseio/reactivecore/lib/actions/utils';
|
|
14
14
|
|
|
15
15
|
var _excluded = ["aggs", "size"],
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
_excluded2 = ["query"],
|
|
17
|
+
_excluded3 = ["query"];
|
|
19
18
|
var _componentTypeToDefau;
|
|
20
19
|
var X_SEARCH_CLIENT = 'ReactiveSearch Vue';
|
|
21
20
|
var componentsWithoutFilters = [componentTypes.numberBox, componentTypes.ratingsFilter];
|
|
22
21
|
var resultComponents = [componentTypes.reactiveList, componentTypes.reactiveMap];
|
|
23
22
|
var componentTypeToDefaultValue = (_componentTypeToDefau = {}, _componentTypeToDefau[componentTypes.singleList] = '', _componentTypeToDefau[componentTypes.multiList] = [], _componentTypeToDefau[componentTypes.singleDataList] = '', _componentTypeToDefau[componentTypes.singleDropdownList] = '', _componentTypeToDefau[componentTypes.multiDataList] = [], _componentTypeToDefau[componentTypes.multiDropdownList] = [], _componentTypeToDefau[componentTypes.tagCloud] = '', _componentTypeToDefau[componentTypes.toggleButton] = '', _componentTypeToDefau[componentTypes.singleDropdownRange] = '', _componentTypeToDefau[componentTypes.multiDropdownRange] = [], _componentTypeToDefau[componentTypes.singleRange] = '', _componentTypeToDefau[componentTypes.multiRange] = [], _componentTypeToDefau);
|
|
24
|
-
|
|
25
23
|
function getValue(state, id, defaultValue, componentType) {
|
|
26
24
|
if (state && state[id]) {
|
|
27
25
|
try {
|
|
@@ -39,86 +37,71 @@ function getValue(state, id, defaultValue, componentType) {
|
|
|
39
37
|
};
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
return {
|
|
44
41
|
value: defaultValue || componentTypeToDefaultValue[componentType] || null,
|
|
45
42
|
reference: 'DEFAULT'
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
|
|
49
45
|
function parseValue(value, component) {
|
|
50
46
|
if (component.source && component.source.parseValue) {
|
|
51
47
|
return component.source.parseValue(value, component);
|
|
52
48
|
}
|
|
53
|
-
|
|
54
49
|
return value;
|
|
55
|
-
}
|
|
56
|
-
|
|
50
|
+
}
|
|
57
51
|
|
|
52
|
+
// Returns query DSL with query property and other options
|
|
58
53
|
function getDefaultQuery(component, value) {
|
|
59
54
|
// get custom or default query of sensor components
|
|
60
|
-
var currentValue = parseValue(value, component);
|
|
61
|
-
|
|
55
|
+
var currentValue = parseValue(value, component);
|
|
56
|
+
// get default query of result components
|
|
62
57
|
if (component.defaultQuery) {
|
|
63
58
|
var defaultQuery = component.defaultQuery(currentValue, component);
|
|
64
59
|
return _extends({
|
|
65
60
|
query: extractQueryFromCustomQuery(defaultQuery)
|
|
66
61
|
}, getOptionsForCustomQuery(defaultQuery));
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
return component.source.defaultQuery ? {
|
|
70
64
|
query: component.source.defaultQuery(currentValue, component)
|
|
71
65
|
} : {};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
}
|
|
67
|
+
// Only results the query part
|
|
75
68
|
function getCustomQuery(component, value) {
|
|
76
69
|
// get custom or default query of sensor components
|
|
77
70
|
var currentValue = parseValue(value, component);
|
|
78
|
-
|
|
79
71
|
if (component.customQuery) {
|
|
80
72
|
var customQuery = component.customQuery(currentValue, component);
|
|
81
73
|
return _extends({
|
|
82
74
|
query: extractQueryFromCustomQuery(customQuery)
|
|
83
75
|
}, getOptionsForCustomQuery(customQuery));
|
|
84
76
|
}
|
|
85
|
-
|
|
86
77
|
return component.source.defaultQuery ? {
|
|
87
78
|
query: component.source.defaultQuery(currentValue, component)
|
|
88
79
|
} : null;
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
function initReactivesearch(componentCollection, searchState, settings) {
|
|
92
82
|
return new Promise(function (resolve, reject) {
|
|
93
83
|
var credentials = settings.url && settings.url.trim() !== '' && !settings.credentials ? null : settings.credentials;
|
|
94
|
-
var enableTelemetry = settings.
|
|
95
|
-
|
|
96
|
-
var headers = _extends({}, settings.enableAppbase && _extends({
|
|
84
|
+
var enableTelemetry = settings.reactivesearchAPIConfig && settings.reactivesearchAPIConfig.enableTelemetry !== undefined ? settings.reactivesearchAPIConfig.enableTelemetry : true;
|
|
85
|
+
var headers = _extends({}, _extends({
|
|
97
86
|
'X-Search-Client': X_SEARCH_CLIENT
|
|
98
87
|
}, enableTelemetry === false && {
|
|
99
88
|
'X-Enable-Telemetry': false
|
|
100
|
-
}), settings.headers, settings.
|
|
101
|
-
|
|
89
|
+
}), settings.headers, settings.endpoint && settings.endpoint.headers ? settings.endpoint.headers : {});
|
|
102
90
|
var url = settings.url && settings.url.trim() !== '' ? settings.url : 'https://scalr.api.appbase.io';
|
|
103
91
|
var transformRequest = settings.transformRequest || null;
|
|
104
|
-
|
|
105
|
-
if (settings.enableAppbase && settings.endpoint) {
|
|
92
|
+
if (settings.endpoint) {
|
|
106
93
|
if (settings.endpoint.url) {
|
|
107
94
|
// eslint-disable-next-line prefer-destructuring
|
|
108
95
|
url = settings.endpoint.url;
|
|
109
96
|
}
|
|
110
|
-
|
|
111
97
|
transformRequest = function transformRequest(request) {
|
|
112
98
|
var modifiedRequest = transformRequestUsingEndpoint(request, settings.endpoint);
|
|
113
|
-
|
|
114
99
|
if (settings.transformRequest) {
|
|
115
100
|
return settings.transformRequest(modifiedRequest);
|
|
116
101
|
}
|
|
117
|
-
|
|
118
102
|
return modifiedRequest;
|
|
119
103
|
};
|
|
120
104
|
}
|
|
121
|
-
|
|
122
105
|
var config = {
|
|
123
106
|
url: url,
|
|
124
107
|
app: settings.app,
|
|
@@ -128,20 +111,17 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
128
111
|
transformResponse: settings.transformResponse || null,
|
|
129
112
|
graphQLUrl: settings.graphQLUrl || '',
|
|
130
113
|
headers: headers,
|
|
131
|
-
analyticsConfig: settings.
|
|
132
|
-
enableAppbase:
|
|
114
|
+
analyticsConfig: settings.reactivesearchAPIConfig || null,
|
|
115
|
+
enableAppbase: true,
|
|
133
116
|
endpoint: settings.endpoint
|
|
134
117
|
};
|
|
135
118
|
var appbaseRef = Appbase(config);
|
|
136
|
-
|
|
137
119
|
if (config.transformRequest) {
|
|
138
120
|
appbaseRef.transformRequest = config.transformRequest;
|
|
139
121
|
}
|
|
140
|
-
|
|
141
122
|
if (config.transformResponse) {
|
|
142
123
|
appbaseRef.transformResponse = config.transformResponse;
|
|
143
124
|
}
|
|
144
|
-
|
|
145
125
|
var components = [];
|
|
146
126
|
var selectedValues = {};
|
|
147
127
|
var internalValues = {};
|
|
@@ -151,7 +131,6 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
151
131
|
var dependencyTree = {};
|
|
152
132
|
var finalQuery = [];
|
|
153
133
|
var appbaseQuery = {}; // Use object to prevent duplicate query added by react prop
|
|
154
|
-
|
|
155
134
|
var orderOfQueries = [];
|
|
156
135
|
var hits = {};
|
|
157
136
|
var aggregations = {};
|
|
@@ -162,8 +141,8 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
162
141
|
var componentProps = {};
|
|
163
142
|
componentCollection.forEach(function (component) {
|
|
164
143
|
var componentType = component.source.componentType;
|
|
165
|
-
components = [].concat(components, [component.componentId]);
|
|
166
|
-
|
|
144
|
+
components = [].concat(components, [component.componentId]);
|
|
145
|
+
// Set component props
|
|
167
146
|
var compProps = {};
|
|
168
147
|
Object.keys(component).forEach(function (key) {
|
|
169
148
|
if (validProps.includes(key)) {
|
|
@@ -171,26 +150,20 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
171
150
|
}
|
|
172
151
|
});
|
|
173
152
|
var isInternalComponentPresent = false;
|
|
174
|
-
|
|
175
153
|
if (component.source.hasInternalComponent) {
|
|
176
154
|
isInternalComponentPresent = component.source.hasInternalComponent(component);
|
|
177
155
|
}
|
|
178
|
-
|
|
179
156
|
var isResultComponent = resultComponents.includes(componentType);
|
|
180
157
|
var internalComponent = component.componentId + "__internal";
|
|
181
158
|
var label = component.filterLabel || component.componentId;
|
|
182
|
-
|
|
183
159
|
var _getValue = getValue(searchState, component.componentId, component.value || component.defaultValue, componentType),
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
160
|
+
value = _getValue.value,
|
|
161
|
+
reference = _getValue.reference;
|
|
162
|
+
// [1] set selected values
|
|
188
163
|
var showFilter = component.showFilter !== undefined ? component.showFilter : true;
|
|
189
|
-
|
|
190
164
|
if (componentsWithoutFilters.includes(componentType)) {
|
|
191
165
|
showFilter = false;
|
|
192
166
|
}
|
|
193
|
-
|
|
194
167
|
selectedValues = valueReducer(selectedValues, {
|
|
195
168
|
type: 'SET_VALUE',
|
|
196
169
|
component: component.componentId,
|
|
@@ -199,99 +172,82 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
199
172
|
reference: reference,
|
|
200
173
|
showFilter: showFilter,
|
|
201
174
|
URLParams: component.URLParams || false
|
|
202
|
-
});
|
|
203
|
-
|
|
175
|
+
});
|
|
176
|
+
// Set custom and default queries
|
|
204
177
|
if (component.customQuery && typeof component.customQuery === 'function') {
|
|
205
178
|
customQueries[component.componentId] = component.customQuery(value, compProps);
|
|
206
179
|
}
|
|
207
|
-
|
|
208
180
|
if (component.defaultQuery && typeof component.defaultQuery === 'function') {
|
|
209
181
|
defaultQueries[component.componentId] = component.defaultQuery(value, compProps);
|
|
210
182
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
183
|
+
var componentQueryOptions = {};
|
|
184
|
+
// [2] set query options - main component query (valid for result components)
|
|
214
185
|
if (component && component.source.generateQueryOptions) {
|
|
215
186
|
componentQueryOptions = _extends({}, componentQueryOptions, component.source.generateQueryOptions(component));
|
|
216
187
|
}
|
|
217
|
-
|
|
218
188
|
var highlightQuery = {};
|
|
219
|
-
|
|
220
189
|
if (component.source.highlightQuery) {
|
|
221
190
|
highlightQuery = component.source.highlightQuery(component);
|
|
222
191
|
}
|
|
223
|
-
|
|
224
192
|
if (componentQueryOptions && Object.keys(componentQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
225
193
|
// eslint-disable-next-line
|
|
226
194
|
var _ref = componentQueryOptions || {},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
195
|
+
aggs = _ref.aggs,
|
|
196
|
+
size = _ref.size,
|
|
197
|
+
otherQueryOptions = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
231
198
|
if (aggs && Object.keys(aggs).length) {
|
|
232
199
|
isInternalComponentPresent = true;
|
|
233
200
|
componentQueryOptions = _extends({}, componentQueryOptions, {
|
|
234
201
|
aggs: aggs,
|
|
235
202
|
size: typeof size === 'undefined' ? 100 : size
|
|
236
203
|
});
|
|
237
|
-
}
|
|
238
|
-
|
|
204
|
+
}
|
|
239
205
|
|
|
206
|
+
// sort, highlight, size, from - query should be applied on the main component
|
|
240
207
|
if (otherQueryOptions && Object.keys(otherQueryOptions).length || highlightQuery && Object.keys(highlightQuery).length) {
|
|
241
208
|
if (!otherQueryOptions) otherQueryOptions = {};
|
|
242
209
|
if (!highlightQuery) highlightQuery = {};
|
|
243
|
-
|
|
244
210
|
var mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery, {
|
|
245
211
|
size: size
|
|
246
212
|
});
|
|
247
|
-
|
|
248
213
|
if (isInternalComponentPresent) {
|
|
249
214
|
mainQueryOptions = _extends({}, otherQueryOptions, highlightQuery);
|
|
250
215
|
}
|
|
251
|
-
|
|
252
216
|
if (isResultComponent) {
|
|
253
217
|
var currentPage = component.currentPage ? component.currentPage - 1 : 0;
|
|
254
|
-
|
|
255
218
|
if (selectedValues[component.componentId] && selectedValues[component.componentId].value) {
|
|
256
219
|
currentPage = selectedValues[component.componentId].value - 1 || 0;
|
|
257
220
|
}
|
|
258
|
-
|
|
259
221
|
var resultSize = component.size || 10;
|
|
260
|
-
var from = currentPage * resultSize;
|
|
261
|
-
|
|
222
|
+
var from = currentPage * resultSize;
|
|
223
|
+
// Update props for RS API
|
|
262
224
|
compProps.from = from;
|
|
263
225
|
mainQueryOptions = _extends({}, mainQueryOptions, highlightQuery, {
|
|
264
226
|
size: resultSize,
|
|
265
227
|
from: from
|
|
266
228
|
});
|
|
267
229
|
}
|
|
268
|
-
|
|
269
230
|
componentQueryOptions = _extends({}, componentQueryOptions, mainQueryOptions);
|
|
270
231
|
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
232
|
+
}
|
|
233
|
+
// [3] set dependency tree
|
|
274
234
|
if (component.react || isInternalComponentPresent || isResultComponent) {
|
|
275
235
|
var react = component.react;
|
|
276
|
-
|
|
277
236
|
if (isInternalComponentPresent || isResultComponent) {
|
|
278
237
|
react = pushToAndClause(react, internalComponent);
|
|
279
238
|
}
|
|
280
|
-
|
|
281
239
|
dependencyTree = dependencyTreeReducer(dependencyTree, {
|
|
282
240
|
type: 'WATCH_COMPONENT',
|
|
283
241
|
component: component.componentId,
|
|
284
242
|
react: react
|
|
285
243
|
});
|
|
286
|
-
}
|
|
244
|
+
}
|
|
245
|
+
// [4] set query list
|
|
287
246
|
// Do not set default query for suggestions
|
|
288
|
-
|
|
289
|
-
|
|
290
247
|
if (isInternalComponentPresent && !isSearchComponent(component.componentType)) {
|
|
291
248
|
var _ref2 = getDefaultQuery(component, value) || {},
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
249
|
+
defaultQuery = _ref2.query,
|
|
250
|
+
defaultQueryOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
295
251
|
queryList = queryReducer(queryList, {
|
|
296
252
|
type: 'SET_QUERY',
|
|
297
253
|
component: internalComponent,
|
|
@@ -303,13 +259,11 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
303
259
|
options: _extends({}, componentQueryOptions, defaultQueryOptions)
|
|
304
260
|
});
|
|
305
261
|
}
|
|
306
|
-
|
|
307
262
|
var _ref3 = getCustomQuery(component, value) || {},
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
263
|
+
query = _ref3.query,
|
|
264
|
+
options = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
265
|
+
var customQuery = query;
|
|
266
|
+
// set custom query for main component
|
|
313
267
|
queryList = queryReducer(queryList, {
|
|
314
268
|
type: 'SET_QUERY',
|
|
315
269
|
component: component.componentId,
|
|
@@ -319,8 +273,8 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
319
273
|
type: 'SET_QUERY_OPTIONS',
|
|
320
274
|
component: component.componentId,
|
|
321
275
|
options: _extends({}, options)
|
|
322
|
-
});
|
|
323
|
-
|
|
276
|
+
});
|
|
277
|
+
// Set component type in component props
|
|
324
278
|
compProps.componentType = componentType;
|
|
325
279
|
componentProps[component.componentId] = compProps;
|
|
326
280
|
});
|
|
@@ -334,76 +288,56 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
334
288
|
props: componentProps,
|
|
335
289
|
customQueries: customQueries,
|
|
336
290
|
defaultQueries: defaultQueries
|
|
337
|
-
};
|
|
338
|
-
|
|
291
|
+
};
|
|
292
|
+
// [5] Generate finalQuery for search
|
|
339
293
|
componentCollection.forEach(function (component) {
|
|
340
294
|
// eslint-disable-next-line
|
|
341
295
|
var _buildQuery = buildQuery(component.componentId, dependencyTree, queryList, queryOptions),
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
296
|
+
queryObj = _buildQuery.queryObj,
|
|
297
|
+
options = _buildQuery.options;
|
|
345
298
|
var componentQueryOptions = options;
|
|
346
|
-
var validOptions = ['aggs', 'from', 'sort'];
|
|
347
|
-
|
|
299
|
+
var validOptions = ['aggs', 'from', 'sort'];
|
|
300
|
+
// check if query or componentQueryOptions are valid - non-empty
|
|
348
301
|
if (queryObj && !!Object.keys(queryObj).length || componentQueryOptions && Object.keys(componentQueryOptions).some(function (item) {
|
|
349
302
|
return validOptions.includes(item);
|
|
350
303
|
})) {
|
|
351
304
|
var _extends2;
|
|
352
|
-
|
|
353
305
|
if (!queryObj || queryObj && !Object.keys(queryObj).length) {
|
|
354
306
|
queryObj = {
|
|
355
307
|
match_all: {}
|
|
356
308
|
};
|
|
357
309
|
}
|
|
358
|
-
|
|
359
310
|
orderOfQueries = [].concat(orderOfQueries, [component.componentId]);
|
|
360
|
-
|
|
361
311
|
var currentQuery = _extends({
|
|
362
312
|
query: _extends({}, queryObj)
|
|
363
313
|
}, componentQueryOptions, queryOptions[component.componentId]);
|
|
364
|
-
|
|
365
314
|
queryLog = _extends({}, queryLog, (_extends2 = {}, _extends2[component.componentId] = currentQuery, _extends2));
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
var _extends3;
|
|
374
|
-
|
|
375
|
-
// Apply dependent queries
|
|
376
|
-
appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), getDependentQueries(state, component.componentId, orderOfQueries));
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
var preference = config && config.analyticsConfig && config.analyticsConfig.userId ? config.analyticsConfig.userId + "_" + component : component;
|
|
380
|
-
finalQuery = [].concat(finalQuery, [{
|
|
381
|
-
preference: preference
|
|
382
|
-
}, currentQuery]);
|
|
315
|
+
var query = getRSQuery(component.componentId, extractPropsFromState(state, component.componentId, queryOptions && Object.keys(queryOptions[component.componentId]).length ? {
|
|
316
|
+
from: queryOptions[component.componentId].from
|
|
317
|
+
} : null));
|
|
318
|
+
if (query) {
|
|
319
|
+
var _extends3;
|
|
320
|
+
// Apply dependent queries
|
|
321
|
+
appbaseQuery = _extends({}, appbaseQuery, (_extends3 = {}, _extends3[component.componentId] = query, _extends3), getDependentQueries(state, component.componentId, orderOfQueries));
|
|
383
322
|
}
|
|
384
323
|
}
|
|
385
324
|
});
|
|
386
325
|
state.queryLog = queryLog;
|
|
387
|
-
|
|
388
326
|
var handleTransformResponse = function handleTransformResponse(res, component) {
|
|
389
327
|
if (config.transformResponse && typeof config.transformResponse === 'function') {
|
|
390
328
|
return config.transformResponse(res, component);
|
|
391
329
|
}
|
|
392
|
-
|
|
393
330
|
return new Promise(function (resolveTransformResponse) {
|
|
394
331
|
return resolveTransformResponse(res);
|
|
395
332
|
});
|
|
396
333
|
};
|
|
397
|
-
|
|
398
334
|
var handleResponse = function handleResponse(res) {
|
|
399
335
|
var allPromises = orderOfQueries.map(function (component, index) {
|
|
400
336
|
return new Promise(function (responseResolve, responseReject) {
|
|
401
337
|
handleTransformResponse(res.responses[index], component).then(function (response) {
|
|
402
338
|
var _extends5;
|
|
403
|
-
|
|
404
339
|
if (response.aggregations) {
|
|
405
340
|
var _extends4;
|
|
406
|
-
|
|
407
341
|
aggregations = _extends({}, aggregations, (_extends4 = {}, _extends4[component] = response.aggregations, _extends4));
|
|
408
342
|
compositeAggregations = compositeAggsReducer(compositeAggregations, {
|
|
409
343
|
type: UPDATE_COMPOSITE_AGGS,
|
|
@@ -411,7 +345,6 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
411
345
|
append: false
|
|
412
346
|
});
|
|
413
347
|
}
|
|
414
|
-
|
|
415
348
|
hits = _extends({}, hits, (_extends5 = {}, _extends5[component] = {
|
|
416
349
|
hits: response.hits.hits,
|
|
417
350
|
total: typeof response.hits.total === 'object' ? response.hits.total.value : response.hits.total,
|
|
@@ -431,7 +364,6 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
431
364
|
resolve(state);
|
|
432
365
|
});
|
|
433
366
|
};
|
|
434
|
-
|
|
435
367
|
var handleRSResponse = function handleRSResponse(res) {
|
|
436
368
|
var promotedResults = {};
|
|
437
369
|
var rawData = {};
|
|
@@ -443,7 +375,6 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
443
375
|
handleTransformResponse(res[component], component).then(function (response) {
|
|
444
376
|
if (response) {
|
|
445
377
|
var _extends7;
|
|
446
|
-
|
|
447
378
|
if (response.promoted) {
|
|
448
379
|
promotedResults[component] = response.promoted.map(function (promoted) {
|
|
449
380
|
return _extends({}, promoted.doc, {
|
|
@@ -451,24 +382,20 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
451
382
|
});
|
|
452
383
|
});
|
|
453
384
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
385
|
+
rawData[component] = response;
|
|
386
|
+
// Update custom data
|
|
457
387
|
if (response.customData) {
|
|
458
388
|
customData[component] = response.customData;
|
|
459
|
-
}
|
|
460
|
-
|
|
389
|
+
}
|
|
461
390
|
|
|
391
|
+
// Update settings
|
|
462
392
|
if (response.settings) {
|
|
463
393
|
settingsResponse[component] = response.settings;
|
|
464
394
|
}
|
|
465
|
-
|
|
466
395
|
if (response.aggregations) {
|
|
467
396
|
var _extends6;
|
|
468
|
-
|
|
469
397
|
aggregations = _extends({}, aggregations, (_extends6 = {}, _extends6[component] = response.aggregations, _extends6));
|
|
470
398
|
}
|
|
471
|
-
|
|
472
399
|
timestamp[component] = res._timestamp;
|
|
473
400
|
var hitsObj = response.hits ? response.hits : response[component].hits;
|
|
474
401
|
hits = _extends({}, hits, (_extends7 = {}, _extends7[component] = {
|
|
@@ -497,17 +424,14 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
497
424
|
resolve(state);
|
|
498
425
|
});
|
|
499
426
|
};
|
|
500
|
-
|
|
501
427
|
if (config.graphQLUrl) {
|
|
502
428
|
var handleTransformRequest = function handleTransformRequest(res) {
|
|
503
429
|
if (config.transformRequest && typeof config.transformRequest === 'function') {
|
|
504
430
|
var transformRequestPromise = config.transformRequest(res);
|
|
505
431
|
return transformRequestPromise instanceof Promise ? transformRequestPromise : Promise.resolve(transformRequestPromise);
|
|
506
432
|
}
|
|
507
|
-
|
|
508
433
|
return Promise.resolve(res);
|
|
509
434
|
};
|
|
510
|
-
|
|
511
435
|
handleTransformRequest(finalQuery).then(function (requestQuery) {
|
|
512
436
|
fetchGraphQL(config.graphQLUrl, config.url, config.credentials, config.app, requestQuery).then(function (res) {
|
|
513
437
|
handleResponse(res);
|
|
@@ -517,34 +441,23 @@ function initReactivesearch(componentCollection, searchState, settings) {
|
|
|
517
441
|
})["catch"](function (err) {
|
|
518
442
|
return reject(err);
|
|
519
443
|
});
|
|
520
|
-
} else if (
|
|
444
|
+
} else if (Object.keys(appbaseQuery).length) {
|
|
521
445
|
finalQuery = Object.keys(appbaseQuery).map(function (c) {
|
|
522
446
|
return appbaseQuery[c];
|
|
523
|
-
});
|
|
524
|
-
|
|
447
|
+
});
|
|
448
|
+
// Call RS API
|
|
525
449
|
var rsAPISettings = {};
|
|
526
|
-
|
|
527
450
|
if (config.analyticsConfig) {
|
|
528
451
|
rsAPISettings.recordAnalytics = isPropertyDefined(config.analyticsConfig.recordAnalytics) ? config.analyticsConfig.recordAnalytics : undefined;
|
|
529
452
|
rsAPISettings.userId = isPropertyDefined(config.analyticsConfig.userId) ? config.analyticsConfig.userId : undefined;
|
|
530
453
|
rsAPISettings.enableQueryRules = isPropertyDefined(config.analyticsConfig.enableQueryRules) ? config.analyticsConfig.enableQueryRules : undefined;
|
|
531
454
|
rsAPISettings.customEvents = isPropertyDefined(config.analyticsConfig.customEvents) ? config.analyticsConfig.customEvents : undefined;
|
|
532
455
|
}
|
|
533
|
-
|
|
534
456
|
appbaseRef.reactiveSearchv3(finalQuery, rsAPISettings).then(function (res) {
|
|
535
457
|
handleRSResponse(res);
|
|
536
458
|
})["catch"](function (err) {
|
|
537
459
|
return reject(err);
|
|
538
460
|
});
|
|
539
|
-
} else {
|
|
540
|
-
appbaseRef.msearch({
|
|
541
|
-
type: config.type === '*' ? '' : config.type,
|
|
542
|
-
body: finalQuery
|
|
543
|
-
}).then(function (res) {
|
|
544
|
-
handleResponse(res);
|
|
545
|
-
})["catch"](function (err) {
|
|
546
|
-
return reject(err);
|
|
547
|
-
});
|
|
548
461
|
}
|
|
549
462
|
});
|
|
550
463
|
}
|
package/dist/es/install.js
CHANGED
|
@@ -1,55 +1,63 @@
|
|
|
1
1
|
import '@appbaseio/reactivecore';
|
|
2
|
-
import './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
|
-
import 'vue-types';
|
|
4
2
|
import '@appbaseio/reactivecore/lib/utils/constants';
|
|
3
|
+
import '@vue/babel-helper-vue-transform-on';
|
|
4
|
+
import './_rollupPluginBabelHelpers-ded08042.js';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import 'vue-types';
|
|
5
7
|
import '@appbaseio/reactivecore/lib/utils/helper';
|
|
6
|
-
import 'emotion';
|
|
7
8
|
import '@appbaseio/vue-emotion';
|
|
9
|
+
import 'emotion';
|
|
8
10
|
import 'polished';
|
|
9
|
-
import './Button-
|
|
10
|
-
import './vueTypes-
|
|
11
|
-
import './Pagination-
|
|
12
|
-
import './ReactiveList.js';
|
|
11
|
+
import './Button-474510e3.js';
|
|
12
|
+
import './vueTypes-f1923c72.js';
|
|
13
|
+
import './Pagination-72bd1d9e.js';
|
|
14
|
+
import ReactiveList from './ReactiveList.js';
|
|
13
15
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
14
16
|
import 'redux';
|
|
15
|
-
import './index-
|
|
16
|
-
import './ComponentWrapper-
|
|
17
|
-
import '
|
|
18
|
-
import './Title-
|
|
19
|
-
import './ListItem-
|
|
20
|
-
import './Card-
|
|
21
|
-
import './Flex-
|
|
17
|
+
import './index-4520a598.js';
|
|
18
|
+
import './ComponentWrapper-5166c76a.js';
|
|
19
|
+
import './PreferencesConsumer-c276709c.js';
|
|
20
|
+
import './Title-863dfa42.js';
|
|
21
|
+
import './ListItem-16756c02.js';
|
|
22
|
+
import './Card-38cbe652.js';
|
|
23
|
+
import './Flex-a08e22d7.js';
|
|
22
24
|
import '@appbaseio/reactivecore/lib/actions/analytics';
|
|
23
25
|
import 'appbase-js';
|
|
26
|
+
import '@appbaseio/analytics';
|
|
24
27
|
import 'url-search-params-polyfill';
|
|
25
|
-
import './ReactiveBase.js';
|
|
28
|
+
import ReactiveBase from './ReactiveBase.js';
|
|
26
29
|
import 'hotkeys-js';
|
|
27
|
-
import './
|
|
28
|
-
import './
|
|
29
|
-
import './Input-
|
|
30
|
+
import { S as SearchBox, R as ReactiveComponent } from './ReactiveComponent-f9fa5780.js';
|
|
31
|
+
import './DropDown-8764360c.js';
|
|
32
|
+
import './Input-4a8ef1f3.js';
|
|
30
33
|
import 'compute-scroll-into-view';
|
|
31
|
-
import './Container-
|
|
34
|
+
import './Container-d00219f7.js';
|
|
32
35
|
import 'vue-highlight-words';
|
|
33
|
-
export { i as default } from './install-ac8a1edb.js';
|
|
34
36
|
import '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
35
|
-
import './FormControlList-
|
|
36
|
-
import './utils-
|
|
37
|
-
import './SingleList.js';
|
|
38
|
-
import './MultiList.js';
|
|
39
|
-
import './
|
|
40
|
-
import './
|
|
41
|
-
import './
|
|
42
|
-
import './
|
|
43
|
-
import './
|
|
44
|
-
import './
|
|
45
|
-
import './
|
|
46
|
-
import './
|
|
47
|
-
import './
|
|
48
|
-
import './
|
|
49
|
-
import '
|
|
50
|
-
import './
|
|
51
|
-
import './
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
import './FormControlList-fe6eaee4.js';
|
|
38
|
+
import './utils-9e5a16a1.js';
|
|
39
|
+
import SingleList from './SingleList.js';
|
|
40
|
+
import MultiList from './MultiList.js';
|
|
41
|
+
import SingleDropdownList from './SingleDropdownList.js';
|
|
42
|
+
import MultiDropdownList from './MultiDropdownList.js';
|
|
43
|
+
import ToggleButton from './ToggleButton.js';
|
|
44
|
+
import './ssr-af398f0c.js';
|
|
45
|
+
import DynamicRangeSlider from './DynamicRangeSlider.js';
|
|
46
|
+
import SingleRange from './SingleRange.js';
|
|
47
|
+
import MultiRange from './MultiRange.js';
|
|
48
|
+
import RangeSlider from './RangeSlider.js';
|
|
49
|
+
import RangeInput from './RangeInput.js';
|
|
50
|
+
import SelectedFilters from './SelectedFilters.js';
|
|
51
|
+
import ResultCard from './ResultCard.js';
|
|
52
|
+
import ResultList from './ResultList.js';
|
|
53
|
+
import StateProvider from './StateProvider.js';
|
|
54
|
+
|
|
55
|
+
var components = [ReactiveList, ResultCard, ResultList, ReactiveBase, SearchBox, SingleList, MultiList, SingleRange, MultiRange, RangeSlider, DynamicRangeSlider, ReactiveComponent, SelectedFilters, ToggleButton, SingleDropdownList, MultiDropdownList, StateProvider, RangeInput];
|
|
56
|
+
function install (Vue) {
|
|
57
|
+
components.map(function (component) {
|
|
58
|
+
Vue.use(component);
|
|
59
|
+
return null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default install;
|