@appbaseio/reactivesearch-vue 1.33.10 → 1.33.11

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.
@@ -1,46 +1,318 @@
1
- import '@appbaseio/reactivecore';
2
- import '@appbaseio/reactivecore/lib/utils/constants';
3
- import './_rollupPluginBabelHelpers-ded08042.js';
4
- import 'vue-types';
5
- import '@appbaseio/reactivecore/lib/utils/helper';
6
- import 'emotion';
7
- import '@appbaseio/vue-emotion';
8
- import 'polished';
9
- import './Button-153cd885.js';
10
- import './vueTypes-8986b709.js';
11
- import './Pagination-28e56c5c.js';
12
- import './ReactiveList.js';
1
+ import { Actions, helper } from '@appbaseio/reactivecore';
2
+ import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
+ import { a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
4
+ import VueTypes from 'vue-types';
5
+ import { t as types } from './vueTypes-8986b709.js';
13
6
  import '@appbaseio/reactivecore/lib/utils/transform';
14
7
  import 'redux';
15
- import './index-0444a498.js';
16
- import './ComponentWrapper-39966c87.js';
17
- import './PreferencesConsumer-bc097ebb.js';
18
- import '@vue/babel-helper-vue-jsx-merge-props';
19
- import './Title-863dfa42.js';
20
- import './ListItem-07888a65.js';
21
- import './Card-19ad6d90.js';
22
- import './Flex-7c177a10.js';
23
- import 'hotkeys-js';
24
- import './DataSearch-8a195d63.js';
25
- import './CancelSvg-e40552a5.js';
26
- import './Input-c09c0b56.js';
27
- import 'compute-scroll-into-view';
28
- import './Container-d00219f7.js';
29
- import 'vue-highlight-words';
30
- export { R as default } from './ReactiveComponent-9ae8b96c.js';
31
- import '@appbaseio/reactivecore/lib/utils/suggestions';
32
- import './FormControlList-99797d0a.js';
33
- import './utils-9e5a16a1.js';
34
- import './SingleList.js';
35
- import './MultiList.js';
36
- import './DropDown-28ddce07.js';
37
- import './SingleDropdownList.js';
38
- import './MultiDropdownList.js';
39
- import './ToggleButton.js';
40
- import 'vue-no-ssr';
41
- import './ssr-03607d84.js';
42
- import './DynamicRangeSlider.js';
43
- import './SingleRange.js';
44
- import './MultiRange.js';
45
- import './RangeSlider.js';
46
- import './RangeInput.js';
8
+ import { f as updateCustomQuery, u as updateDefaultQuery, i as isQueryIdentical, c as connect } from './index-0444a498.js';
9
+ import { C as ComponentWrapper } from './ComponentWrapper-39966c87.js';
10
+ import { P as PreferencesConsumer } from './PreferencesConsumer-bc097ebb.js';
11
+
12
+ var _excluded = ["options"];
13
+ var updateQuery = Actions.updateQuery,
14
+ setQueryOptions = Actions.setQueryOptions,
15
+ setCustomQuery = Actions.setCustomQuery,
16
+ setDefaultQuery = Actions.setDefaultQuery;
17
+ var parseHits = helper.parseHits,
18
+ isEqual = helper.isEqual,
19
+ getCompositeAggsQuery = helper.getCompositeAggsQuery,
20
+ getResultStats = helper.getResultStats,
21
+ extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
22
+ getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
23
+ var ReactiveComponent = {
24
+ name: 'ReactiveComponent',
25
+ props: {
26
+ componentId: types.stringRequired,
27
+ aggregationField: types.string,
28
+ aggregationSize: VueTypes.number,
29
+ size: VueTypes.number,
30
+ defaultQuery: types.func,
31
+ customQuery: types.func,
32
+ filterLabel: types.string,
33
+ react: types.react,
34
+ showFilter: VueTypes.bool.def(true),
35
+ URLParams: VueTypes.bool.def(false),
36
+ distinctField: types.string,
37
+ distinctFieldConfig: types.props,
38
+ index: VueTypes.string,
39
+ endpoint: types.endpointConfig
40
+ },
41
+ created: function created() {
42
+ var _this = this;
43
+ var props = this.$props;
44
+ this.internalComponent = null;
45
+ this.$defaultQuery = null;
46
+ // Set custom query in store
47
+ updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
48
+ var customQuery = props.customQuery,
49
+ componentId = props.componentId,
50
+ filterLabel = props.filterLabel,
51
+ showFilter = props.showFilter,
52
+ URLParams = props.URLParams,
53
+ distinctField = props.distinctField,
54
+ distinctFieldConfig = props.distinctFieldConfig,
55
+ index = props.index;
56
+ if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
57
+ console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
58
+ }
59
+ if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
60
+ console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
61
+ }
62
+ if (!this.enableAppbase && index) {
63
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
64
+ }
65
+ if (customQuery) {
66
+ var calcCustomQuery = customQuery(this.selectedValue, props);
67
+ var query = extractQueryFromCustomQuery(calcCustomQuery);
68
+ var customQueryOptions = calcCustomQuery ? getOptionsForCustomQuery(calcCustomQuery) : null;
69
+ if (customQueryOptions) {
70
+ this.setQueryOptions(componentId, _extends({}, customQueryOptions, this.getAggsQuery()), false);
71
+ } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
72
+ this.updateQuery({
73
+ componentId: componentId,
74
+ query: query,
75
+ value: this.selectedValue || null,
76
+ label: filterLabel,
77
+ showFilter: showFilter,
78
+ URLParams: URLParams
79
+ });
80
+ }
81
+ this.setQuery = function (_ref) {
82
+ var options = _ref.options,
83
+ obj = _objectWithoutPropertiesLoose(_ref, _excluded);
84
+ var queryToBeSet = obj.query;
85
+
86
+ // when enableAppbase is true, Backend throws error because of repeated query in request body
87
+ if (queryToBeSet && queryToBeSet.query) {
88
+ queryToBeSet = queryToBeSet.query;
89
+ }
90
+ var customQueryCalc = _extends({}, options, {
91
+ query: queryToBeSet
92
+ });
93
+ var rsAPIQuery = customQueryCalc;
94
+ // handle stored queries
95
+ if (queryToBeSet && queryToBeSet.id) {
96
+ rsAPIQuery = queryToBeSet;
97
+ }
98
+ // Update customQuery field for RS API
99
+ _this.setCustomQuery(props.componentId, rsAPIQuery);
100
+ if (options) {
101
+ _this.setQueryOptions(props.componentId, _extends({}, _this.getAggsQuery(), options), false);
102
+ }
103
+ _this.updateQuery(_extends({}, obj, {
104
+ query: customQueryCalc.query,
105
+ componentId: props.componentId,
106
+ label: props.filterLabel,
107
+ showFilter: props.showFilter,
108
+ URLParams: props.URLParams
109
+ }));
110
+ };
111
+ if (props.defaultQuery) {
112
+ this.internalComponent = props.componentId + "__internal";
113
+ }
114
+ if (this.internalComponent && this.$props.defaultQuery) {
115
+ updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
116
+ this.$defaultQuery = this.$props.defaultQuery(this.selectedValue, this.$props);
117
+ var _query = extractQueryFromCustomQuery(this.$defaultQuery);
118
+ var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
119
+ if (queryOptions) {
120
+ this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
121
+ } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
122
+ this.updateQuery({
123
+ componentId: this.internalComponent,
124
+ query: _query
125
+ });
126
+ }
127
+ },
128
+ watch: {
129
+ hits: function hits(newVal, oldVal) {
130
+ if (!isEqual(newVal, oldVal)) {
131
+ this.$emit('data', this.getData());
132
+ }
133
+ },
134
+ rawData: function rawData(newVal, oldVal) {
135
+ if (!isEqual(newVal, oldVal)) {
136
+ this.$emit('data', this.getData());
137
+ }
138
+ },
139
+ aggregations: function aggregations(newVal, oldVal) {
140
+ if (!isEqual(newVal, oldVal)) {
141
+ this.$emit('data', this.getData());
142
+ }
143
+ },
144
+ aggregationData: function aggregationData(newVal, oldVal) {
145
+ if (!isEqual(newVal, oldVal)) {
146
+ this.$emit('data', this.getData());
147
+ }
148
+ },
149
+ promotedResults: function promotedResults(newVal, oldVal) {
150
+ if (!isEqual(newVal, oldVal)) {
151
+ this.$emit('data', this.getData());
152
+ }
153
+ },
154
+ hidden: function hidden(newVal, oldVal) {
155
+ if (!isEqual(newVal, oldVal)) {
156
+ this.$emit('data', this.getData());
157
+ }
158
+ },
159
+ total: function total(newVal, oldVal) {
160
+ if (!isEqual(newVal, oldVal)) {
161
+ this.$emit('data', this.getData());
162
+ }
163
+ },
164
+ time: function time(newVal, oldVal) {
165
+ if (!isEqual(newVal, oldVal)) {
166
+ this.$emit('data', this.getData());
167
+ }
168
+ },
169
+ defaultQuery: function defaultQuery(newVal, oldVal) {
170
+ if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
171
+ this.$defaultQuery = newVal(this.selectedValue, this.$props);
172
+ var query = extractQueryFromCustomQuery(this.$defaultQuery);
173
+ var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
174
+ if (queryOptions) {
175
+ this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
176
+ } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
177
+ // Update default query for RS API
178
+ updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
179
+ this.updateQuery({
180
+ componentId: this.internalComponent,
181
+ query: query
182
+ });
183
+ }
184
+ },
185
+ customQuery: function customQuery(newVal, oldVal) {
186
+ if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
187
+ var componentId = this.$props.componentId;
188
+ this.$customQuery = newVal(this.selectedValue, this.$props);
189
+ var query = extractQueryFromCustomQuery(this.$customQuery);
190
+ var queryOptions = getOptionsForCustomQuery(this.$customQuery);
191
+ if (queryOptions) {
192
+ this.setQueryOptions(componentId, _extends({}, queryOptions, this.getAggsQuery()), false);
193
+ } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
194
+
195
+ // Update custom query for RS API
196
+ updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
197
+ this.updateQuery({
198
+ componentId: componentId,
199
+ query: query
200
+ });
201
+ }
202
+ }
203
+ },
204
+ render: function render() {
205
+ var h = arguments[0];
206
+ try {
207
+ var dom = this.$scopedSlots["default"];
208
+ var error = this.error,
209
+ isLoading = this.isLoading,
210
+ selectedValue = this.selectedValue;
211
+ var propsToBePassed = _extends({
212
+ error: error,
213
+ loading: isLoading
214
+ }, this.getData(), {
215
+ value: selectedValue,
216
+ setQuery: this.setQuery
217
+ });
218
+ return h("div", [dom(propsToBePassed)]);
219
+ } catch (e) {
220
+ return null;
221
+ }
222
+ },
223
+ methods: {
224
+ getAggsQuery: function getAggsQuery() {
225
+ if (this.aggregationField) {
226
+ return {
227
+ aggs: getCompositeAggsQuery({
228
+ props: this.$props,
229
+ showTopHits: true,
230
+ value: this.selectedValue
231
+ }).aggs
232
+ };
233
+ }
234
+ return {};
235
+ },
236
+ getData: function getData() {
237
+ var hits = this.hits,
238
+ aggregations = this.aggregations,
239
+ aggregationData = this.aggregationData,
240
+ promotedResults = this.promotedResults,
241
+ rawData = this.rawData;
242
+ var filteredResults = parseHits(hits);
243
+ if (promotedResults.length) {
244
+ var ids = promotedResults.map(function (item) {
245
+ return item._id;
246
+ }).filter(Boolean);
247
+ if (ids) {
248
+ filteredResults = filteredResults.filter(function (item) {
249
+ return !ids.includes(item._id);
250
+ });
251
+ }
252
+ filteredResults = [].concat(promotedResults, filteredResults);
253
+ }
254
+ return {
255
+ data: filteredResults,
256
+ aggregationData: aggregationData,
257
+ rawData: rawData,
258
+ aggregations: aggregations,
259
+ promotedData: promotedResults,
260
+ resultStats: this.stats
261
+ };
262
+ }
263
+ },
264
+ computed: {
265
+ stats: function stats() {
266
+ return getResultStats(this);
267
+ }
268
+ }
269
+ };
270
+ ReactiveComponent.hasInternalComponent = function (props) {
271
+ return !!props.defaultQuery;
272
+ };
273
+ var mapStateToProps = function mapStateToProps(state, props) {
274
+ return {
275
+ aggregations: state.aggregations[props.componentId] && state.aggregations[props.componentId] || null,
276
+ aggregationData: state.compositeAggregations[props.componentId] || [],
277
+ hits: state.hits[props.componentId] && state.hits[props.componentId].hits || [],
278
+ rawData: state.rawData[props.componentId],
279
+ error: state.error[props.componentId],
280
+ isLoading: state.isLoading[props.componentId],
281
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
282
+ promotedResults: state.promotedResults[props.componentId] || [],
283
+ time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
284
+ total: state.hits[props.componentId] && state.hits[props.componentId].total,
285
+ hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
286
+ componentProps: state.props[props.componentId],
287
+ enableAppbase: state.config.enableAppbase
288
+ };
289
+ };
290
+ var mapDispatchtoProps = {
291
+ setQueryOptions: setQueryOptions,
292
+ updateQuery: updateQuery,
293
+ setCustomQuery: setCustomQuery,
294
+ setDefaultQuery: setDefaultQuery
295
+ };
296
+ var ConnectedComponent = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(ReactiveComponent), {
297
+ componentType: componentTypes.reactiveComponent
298
+ });
299
+ var RcConnected = PreferencesConsumer({
300
+ name: 'RcConnected',
301
+ render: function render(h) {
302
+ return h(ConnectedComponent, {
303
+ attrs: this.$attrs,
304
+ on: this.$listeners,
305
+ scopedSlots: this.$scopedSlots,
306
+ slots: this.$slots
307
+ });
308
+ }
309
+ });
310
+ RcConnected.name = ReactiveComponent.name;
311
+ RcConnected.hasInternalComponent = ReactiveComponent.hasInternalComponent;
312
+ // Add componentType for SSR
313
+ RcConnected.componentType = componentTypes.reactiveComponent;
314
+ RcConnected.install = function (Vue) {
315
+ Vue.component(RcConnected.name, RcConnected);
316
+ };
317
+
318
+ export default RcConnected;