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