@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
package/dist/es/ReactiveList.js
CHANGED
|
@@ -1,59 +1,48 @@
|
|
|
1
1
|
import { Actions, helper } from '@appbaseio/reactivecore';
|
|
2
|
-
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
|
-
import VueTypes from 'vue-types';
|
|
4
2
|
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
3
|
+
import _transformOn from '@vue/babel-helper-vue-transform-on';
|
|
4
|
+
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
|
|
5
|
+
import { createVNode, mergeProps, createTextVNode, isVNode } from 'vue';
|
|
6
|
+
import VueTypes from 'vue-types';
|
|
5
7
|
import { withClickIds } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
8
|
+
import { styled } from '@appbaseio/vue-emotion';
|
|
6
9
|
import { css } from 'emotion';
|
|
7
|
-
import styled from '@appbaseio/vue-emotion';
|
|
8
10
|
import 'polished';
|
|
9
|
-
import './Button-
|
|
10
|
-
import { t as types } from './vueTypes-
|
|
11
|
-
import { P as Pagination } from './Pagination-
|
|
11
|
+
import './Button-474510e3.js';
|
|
12
|
+
import { t as types } from './vueTypes-f1923c72.js';
|
|
13
|
+
import { P as Pagination } from './Pagination-72bd1d9e.js';
|
|
12
14
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
13
15
|
import 'redux';
|
|
14
|
-
import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-
|
|
15
|
-
import { C as ComponentWrapper } from './ComponentWrapper-
|
|
16
|
-
import
|
|
17
|
-
import './Title-
|
|
18
|
-
import { c as container } from './ListItem-
|
|
19
|
-
import { c as container$1 } from './Card-
|
|
20
|
-
import { F as Flex } from './Flex-
|
|
16
|
+
import { c as connect, h as hasCustomRenderer, i as isQueryIdentical, u as updateDefaultQuery, a as isFunction, g as getComponent } from './index-4520a598.js';
|
|
17
|
+
import { C as ComponentWrapper } from './ComponentWrapper-5166c76a.js';
|
|
18
|
+
import { P as PreferencesConsumer } from './PreferencesConsumer-c276709c.js';
|
|
19
|
+
import './Title-863dfa42.js';
|
|
20
|
+
import { c as container } from './ListItem-16756c02.js';
|
|
21
|
+
import { c as container$1 } from './Card-38cbe652.js';
|
|
22
|
+
import { F as Flex } from './Flex-a08e22d7.js';
|
|
21
23
|
|
|
22
24
|
var _templateObject;
|
|
23
25
|
var PoweredByImage = styled('img')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\twidth: 110px;\n"])));
|
|
24
26
|
|
|
25
|
-
var PoweredBy = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}, [h(PoweredByImage, {
|
|
35
|
-
"attrs": {
|
|
36
|
-
"src": "https://cdn.jsdelivr.net/gh/appbaseio/cdn@d2ec210045e59104ee5485841fa17b23fc83f097/appbase/logos/rbc-logo.svg"
|
|
37
|
-
}
|
|
38
|
-
})]);
|
|
39
|
-
}
|
|
27
|
+
var PoweredBy = function PoweredBy() {
|
|
28
|
+
return createVNode("a", {
|
|
29
|
+
"href": "https://appbase.io/",
|
|
30
|
+
"target": "_blank",
|
|
31
|
+
"rel": "noopener noreferrer"
|
|
32
|
+
}, [createVNode(PoweredByImage, {
|
|
33
|
+
"src": "https://cdn.jsdelivr.net/gh/appbaseio/cdn@d2ec210045e59104ee5485841fa17b23fc83f097/appbase/logos/rbc-logo.svg"
|
|
34
|
+
}, null)]);
|
|
40
35
|
};
|
|
41
36
|
|
|
42
37
|
var ResultListWrapper = {
|
|
43
38
|
name: 'ResultListWrapper',
|
|
44
39
|
functional: true,
|
|
45
|
-
render: function render(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return h("div", _mergeJSXProps([{
|
|
50
|
-
"attrs": {
|
|
51
|
-
"className": container
|
|
52
|
-
}
|
|
53
|
-
}, props]), [children]);
|
|
40
|
+
render: function render(context) {
|
|
41
|
+
return createVNode("div", mergeProps({
|
|
42
|
+
"className": container
|
|
43
|
+
}, context.$props), [context.$slots["default"]()]);
|
|
54
44
|
}
|
|
55
45
|
};
|
|
56
|
-
|
|
57
46
|
ResultListWrapper.install = function (Vue) {
|
|
58
47
|
Vue.component(ResultListWrapper.name, ResultListWrapper);
|
|
59
48
|
};
|
|
@@ -61,18 +50,12 @@ ResultListWrapper.install = function (Vue) {
|
|
|
61
50
|
var ResultCardsWrapper = {
|
|
62
51
|
name: 'ResultCardsWrapper',
|
|
63
52
|
functional: true,
|
|
64
|
-
render: function render(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return h("div", _mergeJSXProps([{
|
|
69
|
-
"attrs": {
|
|
70
|
-
"className": container$1
|
|
71
|
-
}
|
|
72
|
-
}, props]), [children]);
|
|
53
|
+
render: function render(context) {
|
|
54
|
+
return createVNode("div", mergeProps({
|
|
55
|
+
"className": container$1
|
|
56
|
+
}, context.$props), [context.$slots["default"]()]);
|
|
73
57
|
}
|
|
74
58
|
};
|
|
75
|
-
|
|
76
59
|
ResultCardsWrapper.install = function (Vue) {
|
|
77
60
|
Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
|
|
78
61
|
};
|
|
@@ -83,15 +66,13 @@ var sortOptions = css(_templateObject2 || (_templateObject2 = _taggedTemplateLit
|
|
|
83
66
|
|
|
84
67
|
var recordImpressions = Actions.recordImpressions;
|
|
85
68
|
var isEqual = helper.isEqual;
|
|
86
|
-
|
|
87
69
|
var debounce = function debounce(method, delay) {
|
|
88
|
-
clearTimeout(method._tId);
|
|
89
|
-
|
|
70
|
+
clearTimeout(method._tId);
|
|
71
|
+
// eslint-disable-next-line
|
|
90
72
|
method._tId = setTimeout(function () {
|
|
91
73
|
method();
|
|
92
74
|
}, delay);
|
|
93
75
|
};
|
|
94
|
-
|
|
95
76
|
var ImpressionTracker = {
|
|
96
77
|
name: 'ImpressionTracker',
|
|
97
78
|
inject: ['$$store'],
|
|
@@ -104,16 +85,15 @@ var ImpressionTracker = {
|
|
|
104
85
|
// An object to track the recorded impressions
|
|
105
86
|
// It can have the values in following shape
|
|
106
87
|
// { "hit_id": { "index": "test" }}
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
this.trackedIds = {};
|
|
89
|
+
// An object to know the the un-tracked impression i.e not recorded by BE
|
|
109
90
|
// It can have the values in following shape
|
|
110
91
|
// { "query_id": [{ "id": "hit_id", "index": "test"}]}
|
|
111
|
-
|
|
112
92
|
this.waitingToBeTracked = {};
|
|
113
93
|
},
|
|
114
94
|
mounted: function mounted() {
|
|
115
|
-
this.setCurrentHits(this.hits);
|
|
116
|
-
|
|
95
|
+
this.setCurrentHits(this.hits);
|
|
96
|
+
// Add scroll events to track the impressions
|
|
117
97
|
if (window) {
|
|
118
98
|
window.addEventListener('scroll', this.tracker);
|
|
119
99
|
}
|
|
@@ -132,7 +112,6 @@ var ImpressionTracker = {
|
|
|
132
112
|
var currentHitIds = newVal.map(function (hit) {
|
|
133
113
|
return hit._id;
|
|
134
114
|
});
|
|
135
|
-
|
|
136
115
|
if (!isEqual(currentHitIds, prevHitIds)) {
|
|
137
116
|
this.setCurrentHits(newVal);
|
|
138
117
|
}
|
|
@@ -145,28 +124,24 @@ var ImpressionTracker = {
|
|
|
145
124
|
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
146
125
|
},
|
|
147
126
|
setCurrentHits: function setCurrentHits(hits) {
|
|
148
|
-
this.currentHits = hits;
|
|
149
|
-
|
|
127
|
+
this.currentHits = hits;
|
|
128
|
+
// Reset the tracked Ids for new hits
|
|
150
129
|
this.trackedIds = {};
|
|
151
|
-
|
|
152
130
|
if (hits && hits.length) {
|
|
153
|
-
this.tracker();
|
|
131
|
+
this.tracker();
|
|
132
|
+
// Run the tracker function on an interval of 1s to track the impressions for
|
|
154
133
|
// non-scroll views for e.g on tab change
|
|
155
|
-
|
|
156
134
|
this.setTrackerInterval();
|
|
157
135
|
}
|
|
158
136
|
},
|
|
159
137
|
recordImpression: function recordImpression() {
|
|
160
138
|
var _this = this;
|
|
161
|
-
|
|
162
139
|
if (Object.keys(this.waitingToBeTracked).length) {
|
|
163
140
|
var unTrackedHits = _extends({}, this.waitingToBeTracked);
|
|
164
|
-
|
|
165
141
|
Object.keys(unTrackedHits).forEach(function (queryId) {
|
|
166
142
|
if (unTrackedHits[queryId] && unTrackedHits[queryId].length) {
|
|
167
|
-
_this.trackImpressions(queryId, unTrackedHits[queryId]);
|
|
168
|
-
|
|
169
|
-
|
|
143
|
+
_this.trackImpressions(queryId, unTrackedHits[queryId]);
|
|
144
|
+
// Removed tracked impressions from waiting list
|
|
170
145
|
delete _this.waitingToBeTracked[queryId];
|
|
171
146
|
}
|
|
172
147
|
});
|
|
@@ -174,13 +149,12 @@ var ImpressionTracker = {
|
|
|
174
149
|
},
|
|
175
150
|
addToWaitingList: function addToWaitingList(hitObject) {
|
|
176
151
|
var queryId = this.getQueryId();
|
|
177
|
-
|
|
178
152
|
if (hitObject && queryId) {
|
|
179
153
|
var impression = {
|
|
180
154
|
id: hitObject._id,
|
|
181
155
|
index: hitObject._index
|
|
182
|
-
};
|
|
183
|
-
|
|
156
|
+
};
|
|
157
|
+
// Check if query id already present in waiting list
|
|
184
158
|
if (this.waitingToBeTracked[queryId]) {
|
|
185
159
|
this.waitingToBeTracked[queryId].push(impression);
|
|
186
160
|
} else {
|
|
@@ -190,32 +164,27 @@ var ImpressionTracker = {
|
|
|
190
164
|
},
|
|
191
165
|
tracker: function tracker() {
|
|
192
166
|
var _this2 = this;
|
|
193
|
-
|
|
194
167
|
if (!this.getHitIds().length) {
|
|
195
168
|
this.clearTrackerInterval();
|
|
196
169
|
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
170
|
+
}
|
|
171
|
+
// only run at client-side
|
|
200
172
|
if (window && document) {
|
|
201
173
|
this.getHitIds().forEach(function (id) {
|
|
202
174
|
var element = document.getElementById(id);
|
|
203
|
-
|
|
204
175
|
if (element) {
|
|
205
176
|
if (_this2.inViewPort(element)) {
|
|
206
177
|
// Add the hit id in the list of tracked ids
|
|
207
178
|
var hitObject = _this2.currentHits.find(function (hit) {
|
|
208
179
|
return hit._id === id;
|
|
209
180
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
181
|
+
_this2.trackedIds[id] = true;
|
|
182
|
+
// Add hit to waiting list to be recorded
|
|
213
183
|
_this2.addToWaitingList(hitObject);
|
|
214
184
|
}
|
|
215
185
|
}
|
|
216
186
|
});
|
|
217
187
|
}
|
|
218
|
-
|
|
219
188
|
debounce(this.recordImpression, 300);
|
|
220
189
|
},
|
|
221
190
|
setTrackerInterval: function setTrackerInterval() {
|
|
@@ -223,8 +192,8 @@ var ImpressionTracker = {
|
|
|
223
192
|
},
|
|
224
193
|
clearTrackerInterval: function clearTrackerInterval() {
|
|
225
194
|
if (this.intervalID) {
|
|
226
|
-
clearInterval(this.intervalID);
|
|
227
|
-
|
|
195
|
+
clearInterval(this.intervalID);
|
|
196
|
+
// Reset interval ID
|
|
228
197
|
this.intervalID = null;
|
|
229
198
|
}
|
|
230
199
|
},
|
|
@@ -234,7 +203,6 @@ var ImpressionTracker = {
|
|
|
234
203
|
},
|
|
235
204
|
getHitIds: function getHitIds() {
|
|
236
205
|
var _this3 = this;
|
|
237
|
-
|
|
238
206
|
return this.currentHits.map(function (hit) {
|
|
239
207
|
return hit._id;
|
|
240
208
|
}).filter(function (id) {
|
|
@@ -253,21 +221,24 @@ var ImpressionTracker$1 = connect(function () {
|
|
|
253
221
|
return null;
|
|
254
222
|
}, mapDispatchToProps)(ImpressionTracker);
|
|
255
223
|
|
|
224
|
+
function _isSlot(s) {
|
|
225
|
+
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
226
|
+
}
|
|
256
227
|
var setQueryOptions = Actions.setQueryOptions,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
228
|
+
updateQuery = Actions.updateQuery,
|
|
229
|
+
loadMore = Actions.loadMore,
|
|
230
|
+
setValue = Actions.setValue,
|
|
231
|
+
updateComponentProps = Actions.updateComponentProps,
|
|
232
|
+
setDefaultQuery = Actions.setDefaultQuery,
|
|
233
|
+
recordResultClick = Actions.recordResultClick;
|
|
263
234
|
var isEqual$1 = helper.isEqual,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
235
|
+
getQueryOptions = helper.getQueryOptions,
|
|
236
|
+
getClassName = helper.getClassName,
|
|
237
|
+
parseHits = helper.parseHits,
|
|
238
|
+
getCompositeAggsQuery = helper.getCompositeAggsQuery,
|
|
239
|
+
getResultStats = helper.getResultStats,
|
|
240
|
+
extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
|
|
241
|
+
getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
|
|
271
242
|
var ReactiveList = {
|
|
272
243
|
name: 'ReactiveList',
|
|
273
244
|
components: {
|
|
@@ -277,13 +248,11 @@ var ReactiveList = {
|
|
|
277
248
|
data: function data() {
|
|
278
249
|
var currentPageState = 0;
|
|
279
250
|
var defaultPage = this.defaultPage || -1;
|
|
280
|
-
|
|
281
251
|
if (defaultPage >= 0) {
|
|
282
252
|
currentPageState = defaultPage;
|
|
283
253
|
} else if (this.currentPage) {
|
|
284
254
|
currentPageState = Math.max(this.currentPage - 1, 0);
|
|
285
255
|
}
|
|
286
|
-
|
|
287
256
|
this.__state = {
|
|
288
257
|
from: currentPageState * this.size,
|
|
289
258
|
currentPageState: currentPageState
|
|
@@ -292,50 +261,27 @@ var ReactiveList = {
|
|
|
292
261
|
},
|
|
293
262
|
created: function created() {
|
|
294
263
|
var _this = this;
|
|
295
|
-
|
|
296
|
-
var _this$$props = this.$props,
|
|
297
|
-
distinctField = _this$$props.distinctField,
|
|
298
|
-
distinctFieldConfig = _this$$props.distinctFieldConfig,
|
|
299
|
-
index = _this$$props.index; // no support for pagination and aggregationField together
|
|
300
|
-
|
|
264
|
+
// no support for pagination and aggregationField together
|
|
301
265
|
if (this.pagination && this.aggregationField) {
|
|
302
266
|
console.warn('Pagination is not supported when aggregationField is present. The list will be rendered with infinite scroll');
|
|
303
267
|
}
|
|
304
|
-
|
|
305
|
-
if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
|
|
306
|
-
console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
|
|
310
|
-
console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (!this.enableAppbase && index) {
|
|
314
|
-
console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
|
|
315
|
-
}
|
|
316
|
-
|
|
317
268
|
var defaultPage = this.defaultPage || -1;
|
|
318
|
-
|
|
319
269
|
if (defaultPage >= 0) {
|
|
320
270
|
this.currentPageState = defaultPage;
|
|
321
271
|
this.from = this.currentPageState * this.$props.size;
|
|
322
272
|
}
|
|
323
|
-
|
|
324
273
|
this.internalComponent = this.$props.componentId + "__internal";
|
|
325
274
|
this.sortOptionIndex = 0;
|
|
326
|
-
|
|
327
275
|
if (this.defaultSortOption && this.sortOptions && Array.isArray(this.sortOptions)) {
|
|
328
276
|
this.sortOptionIndex = this.sortOptions.findIndex(function (s) {
|
|
329
277
|
return s.label === _this.defaultSortOption;
|
|
330
278
|
});
|
|
331
279
|
}
|
|
332
|
-
|
|
333
280
|
if (this.urlSortOption) {
|
|
334
281
|
this.sortOptionIndex = this.$props.sortOptions.findIndex(function (s) {
|
|
335
282
|
return s.label === _this.urlSortOption;
|
|
336
283
|
}) || 0;
|
|
337
284
|
}
|
|
338
|
-
|
|
339
285
|
this.updateComponentProps(this.componentId, {
|
|
340
286
|
from: this.from
|
|
341
287
|
}, componentTypes.reactiveList);
|
|
@@ -390,10 +336,10 @@ var ReactiveList = {
|
|
|
390
336
|
return Math.ceil(this.total / this.$props.size) || 0;
|
|
391
337
|
},
|
|
392
338
|
hasPageChangeListener: function hasPageChangeListener() {
|
|
393
|
-
return this.$
|
|
339
|
+
return this.$attrs && this.$attrs.pageChange;
|
|
394
340
|
},
|
|
395
341
|
hasResultStatsListener: function hasResultStatsListener() {
|
|
396
|
-
return this.$
|
|
342
|
+
return this.$attrs && this.$attrs.resultStats;
|
|
397
343
|
},
|
|
398
344
|
stats: function stats() {
|
|
399
345
|
return _extends({}, getResultStats(this), {
|
|
@@ -412,21 +358,17 @@ var ReactiveList = {
|
|
|
412
358
|
var results = parseHits(this.hits) || [];
|
|
413
359
|
var parsedPromotedResults = parseHits(this.promotedResults) || [];
|
|
414
360
|
var filteredResults = results;
|
|
415
|
-
|
|
416
361
|
if (parsedPromotedResults.length) {
|
|
417
362
|
var ids = parsedPromotedResults.map(function (item) {
|
|
418
363
|
return item._id;
|
|
419
364
|
}).filter(Boolean);
|
|
420
|
-
|
|
421
365
|
if (ids) {
|
|
422
366
|
filteredResults = filteredResults.filter(function (item) {
|
|
423
367
|
return !ids.includes(item._id);
|
|
424
368
|
});
|
|
425
369
|
}
|
|
426
|
-
|
|
427
370
|
filteredResults = [].concat(parsedPromotedResults, filteredResults);
|
|
428
371
|
}
|
|
429
|
-
|
|
430
372
|
return withClickIds(filteredResults);
|
|
431
373
|
}
|
|
432
374
|
},
|
|
@@ -468,19 +410,16 @@ var ReactiveList = {
|
|
|
468
410
|
this.$defaultQuery = newVal(null, this.$props);
|
|
469
411
|
var query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
470
412
|
var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
|
|
471
|
-
|
|
472
413
|
if (queryOptions) {
|
|
473
414
|
options = _extends({}, options, queryOptions);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
415
|
+
}
|
|
416
|
+
// Update calculated default query in store
|
|
477
417
|
updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
|
|
478
418
|
this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), !query);
|
|
479
419
|
this.updateQuery({
|
|
480
420
|
componentId: this.internalComponent,
|
|
481
421
|
query: query
|
|
482
422
|
}, true); // reset page because of query change
|
|
483
|
-
|
|
484
423
|
this.currentPageState = 0;
|
|
485
424
|
this.from = 0;
|
|
486
425
|
}
|
|
@@ -502,7 +441,6 @@ var ReactiveList = {
|
|
|
502
441
|
},
|
|
503
442
|
hits: function hits(newVal, oldVal) {
|
|
504
443
|
this.$emit('data', this.getData());
|
|
505
|
-
|
|
506
444
|
if (this.shouldRenderPagination) {
|
|
507
445
|
// called when page is changed
|
|
508
446
|
if (this.isLoading && (oldVal || newVal)) {
|
|
@@ -520,7 +458,6 @@ var ReactiveList = {
|
|
|
520
458
|
if (this.scrollOnChange) {
|
|
521
459
|
window.scrollTo(0, 0);
|
|
522
460
|
}
|
|
523
|
-
|
|
524
461
|
this.from = 0;
|
|
525
462
|
}
|
|
526
463
|
}
|
|
@@ -544,7 +481,6 @@ var ReactiveList = {
|
|
|
544
481
|
window.removeEventListener('scroll', this.scrollHandler);
|
|
545
482
|
}
|
|
546
483
|
} // handle window url history change (on native back and forth interactions)
|
|
547
|
-
|
|
548
484
|
},
|
|
549
485
|
defaultPage: function defaultPage(newVal, oldVal) {
|
|
550
486
|
if (this.currentPageState !== newVal && oldVal !== newVal) {
|
|
@@ -556,46 +492,39 @@ var ReactiveList = {
|
|
|
556
492
|
if (this.defaultPage < 0 && this.currentPage > 0) {
|
|
557
493
|
this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, this.URLParams);
|
|
558
494
|
}
|
|
559
|
-
|
|
560
495
|
var options = getQueryOptions(this.$props);
|
|
561
496
|
options.from = this.$data.from;
|
|
562
|
-
|
|
563
497
|
if (this.sortOptions && this.sortOptions[this.sortOptionIndex]) {
|
|
564
498
|
var _ref;
|
|
565
|
-
|
|
566
499
|
var sortField = this.sortOptions[this.sortOptionIndex].dataField;
|
|
567
500
|
var sortBy = this.sortOptions[this.sortOptionIndex].sortBy;
|
|
568
501
|
options.sort = [(_ref = {}, _ref[sortField] = {
|
|
569
502
|
order: sortBy
|
|
570
|
-
}, _ref)];
|
|
571
|
-
|
|
503
|
+
}, _ref)];
|
|
504
|
+
// To handle sort options for RS API
|
|
572
505
|
this.updateComponentProps(this.componentId, {
|
|
573
506
|
dataField: sortField,
|
|
574
507
|
sortBy: sortBy
|
|
575
508
|
}, componentTypes.reactiveList);
|
|
576
509
|
} else if (this.$props.sortBy) {
|
|
577
510
|
var _ref2;
|
|
578
|
-
|
|
579
511
|
options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
|
|
580
512
|
order: this.$props.sortBy
|
|
581
513
|
}, _ref2)];
|
|
582
514
|
} // Override sort query with defaultQuery's sort if defined
|
|
583
515
|
|
|
584
|
-
|
|
585
516
|
this.$defaultQuery = null;
|
|
586
|
-
|
|
587
517
|
if (this.$props.defaultQuery) {
|
|
588
518
|
this.$defaultQuery = this.$props.defaultQuery();
|
|
589
|
-
options = _extends({}, options, getOptionsForCustomQuery(this.$defaultQuery));
|
|
519
|
+
options = _extends({}, options, getOptionsForCustomQuery(this.$defaultQuery));
|
|
590
520
|
|
|
521
|
+
// Update calculated default query in store
|
|
591
522
|
updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
|
|
523
|
+
}
|
|
524
|
+
// execute is set to false at the time of mount
|
|
595
525
|
var query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
596
526
|
var execute = false;
|
|
597
527
|
this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), execute);
|
|
598
|
-
|
|
599
528
|
if (this.$defaultQuery) {
|
|
600
529
|
this.updateQuery({
|
|
601
530
|
componentId: this.internalComponent,
|
|
@@ -608,131 +537,122 @@ var ReactiveList = {
|
|
|
608
537
|
}, execute);
|
|
609
538
|
} // query will be executed here
|
|
610
539
|
|
|
611
|
-
|
|
612
540
|
if (this.showInfiniteScroll) {
|
|
613
541
|
window.addEventListener('scroll', this.scrollHandler);
|
|
614
542
|
}
|
|
615
543
|
},
|
|
616
|
-
|
|
544
|
+
beforeUnmount: function beforeUnmount() {
|
|
617
545
|
if (this.showInfiniteScroll) {
|
|
618
546
|
window.removeEventListener('scroll', this.scrollHandler);
|
|
619
547
|
}
|
|
620
548
|
},
|
|
621
549
|
render: function render() {
|
|
622
|
-
var
|
|
550
|
+
var _this2 = this;
|
|
623
551
|
var hits = this.$data.hits;
|
|
624
552
|
var results = parseHits(hits) || [];
|
|
625
|
-
return
|
|
553
|
+
return createVNode("div", {
|
|
626
554
|
"style": this.$props.style,
|
|
627
555
|
"class": this.$props.className
|
|
628
|
-
}, [this.isLoading && this.shouldRenderPagination && this.showInfiniteScroll && (this.$
|
|
629
|
-
"
|
|
630
|
-
"labelPosition": this.sortOptions ? 'right' : 'left'
|
|
631
|
-
},
|
|
556
|
+
}, [this.isLoading && this.shouldRenderPagination && this.showInfiniteScroll && (this.$slots.loader || this.$props.loader), this.renderErrorComponent(), createVNode(Flex, {
|
|
557
|
+
"labelPosition": this.sortOptions ? 'right' : 'left',
|
|
632
558
|
"class": getClassName(this.$props.innerClass, 'resultsInfo')
|
|
633
|
-
},
|
|
634
|
-
"
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
559
|
+
}, {
|
|
560
|
+
"default": function _default() {
|
|
561
|
+
return [_this2.sortOptions ? _this2.renderSortOptions() : null, _this2.$props.showResultStats && results.length ? _this2.renderStats() : null];
|
|
562
|
+
}
|
|
563
|
+
}), !this.isLoading && hits && hits.length === 0 ? this.renderNoResult() : null, this.shouldRenderPagination && (this.$props.paginationAt === 'top' || this.$props.paginationAt === 'both') ? createVNode(Pagination, {
|
|
564
|
+
"pages": this.$props.pages,
|
|
565
|
+
"totalPages": this.totalPages,
|
|
566
|
+
"currentPage": this.currentPageState,
|
|
567
|
+
"setPage": this.setPage,
|
|
568
|
+
"innerClass": this.$props.innerClass,
|
|
569
|
+
"prevLabel": this.$props.prevLabel,
|
|
570
|
+
"nextLabel": this.$props.nextLabel
|
|
571
|
+
}, null) : null, this.renderResults(), this.isLoading && !this.shouldRenderPagination ? this.$slots.loader || this.$props.loader || createVNode("div", {
|
|
644
572
|
"style": {
|
|
645
573
|
textAlign: 'center',
|
|
646
574
|
margin: '20px 0',
|
|
647
575
|
color: '#666'
|
|
648
576
|
}
|
|
649
|
-
}, ["Loading..."]) : null, this.shouldRenderPagination && (this.$props.paginationAt === 'bottom' || this.$props.paginationAt === 'both') ?
|
|
650
|
-
"
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}) : null, this.url.endsWith('appbase.io') && results.length ? h(Flex, {
|
|
661
|
-
"attrs": {
|
|
662
|
-
"direction": "row-reverse"
|
|
663
|
-
},
|
|
577
|
+
}, [createTextVNode("Loading...")]) : null, this.shouldRenderPagination && (this.$props.paginationAt === 'bottom' || this.$props.paginationAt === 'both') ? createVNode(Pagination, {
|
|
578
|
+
"pages": this.$props.pages,
|
|
579
|
+
"totalPages": Math.ceil(this.$data.total / this.$props.size),
|
|
580
|
+
"currentPage": this.currentPageState,
|
|
581
|
+
"setPage": this.setPage,
|
|
582
|
+
"showEndPage": this.$props.showEndPage,
|
|
583
|
+
"innerClass": this.$props.innerClass,
|
|
584
|
+
"prevLabel": this.$props.prevLabel,
|
|
585
|
+
"nextLabel": this.$props.nextLabel
|
|
586
|
+
}, null) : null, this.url.endsWith('appbase.io') && results.length ? createVNode(Flex, {
|
|
587
|
+
"direction": "row-reverse",
|
|
664
588
|
"class": getClassName(this.$props.innerClass, 'poweredBy')
|
|
665
|
-
},
|
|
589
|
+
}, {
|
|
590
|
+
"default": function _default() {
|
|
591
|
+
return [createVNode(PoweredBy, null, null)];
|
|
592
|
+
}
|
|
593
|
+
}) : null]);
|
|
666
594
|
},
|
|
667
595
|
methods: {
|
|
668
596
|
renderErrorComponent: function renderErrorComponent() {
|
|
669
|
-
var renderError = this.$
|
|
670
|
-
|
|
597
|
+
var renderError = this.$slots.renderError || this.$props.renderError;
|
|
671
598
|
if (renderError && this.error && !this.isLoading) {
|
|
672
599
|
return isFunction(renderError) ? renderError(this.error) : renderError;
|
|
673
600
|
}
|
|
674
|
-
|
|
675
601
|
return null;
|
|
676
602
|
},
|
|
677
603
|
renderResults: function renderResults() {
|
|
678
|
-
var
|
|
679
|
-
|
|
680
|
-
var h = this.$createElement;
|
|
604
|
+
var _this3 = this;
|
|
681
605
|
var size = this.$props.size;
|
|
682
|
-
var renderItem = this.$
|
|
683
|
-
var element = this.hasCustomRender ? this.getComponent() :
|
|
606
|
+
var renderItem = this.$slots.renderItem || this.$props.renderItem;
|
|
607
|
+
var element = this.hasCustomRender ? this.getComponent() : createVNode("div", {
|
|
684
608
|
"class": this.$props.listClass + " " + getClassName(this.$props.innerClass, 'list')
|
|
685
609
|
}, [this.data.map(function (item, index) {
|
|
686
610
|
return renderItem({
|
|
687
611
|
item: item,
|
|
688
|
-
count:
|
|
612
|
+
count: _this3.currentPageState * size + index + 1,
|
|
689
613
|
triggerClickAnalytics: function triggerClickAnalytics() {
|
|
690
|
-
return
|
|
614
|
+
return _this3.triggerClickAnalytics(_this3.currentPageState * size + index);
|
|
691
615
|
}
|
|
692
616
|
});
|
|
693
|
-
})]);
|
|
694
|
-
|
|
695
|
-
return this.analytics ?
|
|
696
|
-
"
|
|
697
|
-
|
|
617
|
+
})]);
|
|
618
|
+
// If analytics is set to true then render with impression tracker
|
|
619
|
+
return this.analytics ? createVNode(ImpressionTracker$1, {
|
|
620
|
+
"hits": this.data
|
|
621
|
+
}, _isSlot(element) ? element : {
|
|
622
|
+
"default": function _default() {
|
|
623
|
+
return [element];
|
|
698
624
|
}
|
|
699
|
-
}
|
|
625
|
+
}) : element;
|
|
700
626
|
},
|
|
701
627
|
updateQueryOptions: function updateQueryOptions(props) {
|
|
702
628
|
var options = getQueryOptions(props);
|
|
703
629
|
options.from = this.$data.from;
|
|
704
|
-
|
|
705
630
|
if (props.sortOptions && Array.isArray(props.sortOptions)) {
|
|
706
631
|
var sortOptionIndex = props.defaultSortOption ? props.sortOptions.findIndex(function (s) {
|
|
707
632
|
return s.label === props.defaultSortOption;
|
|
708
633
|
}) : 0;
|
|
709
|
-
|
|
710
634
|
if (props.sortOptions[sortOptionIndex]) {
|
|
711
635
|
var _ref3;
|
|
712
|
-
|
|
713
636
|
options.sort = [(_ref3 = {}, _ref3[props.sortOptions[sortOptionIndex].dataField] = {
|
|
714
637
|
order: props.sortOptions[sortOptionIndex].sortBy
|
|
715
638
|
}, _ref3)];
|
|
716
639
|
}
|
|
717
640
|
} else if (props.sortBy) {
|
|
718
641
|
var _ref4;
|
|
719
|
-
|
|
720
642
|
options.sort = [(_ref4 = {}, _ref4[props.dataField] = {
|
|
721
643
|
order: props.sortBy
|
|
722
644
|
}, _ref4)];
|
|
723
645
|
}
|
|
724
|
-
|
|
725
646
|
this.setQueryOptions(this.$props.componentId, _extends({}, options, this.getAggsQuery()), true);
|
|
726
647
|
},
|
|
727
648
|
getAggsQuery: function getAggsQuery() {
|
|
728
|
-
var _this$$
|
|
729
|
-
|
|
730
|
-
|
|
649
|
+
var _this$$props = this.$props,
|
|
650
|
+
size = _this$$props.size,
|
|
651
|
+
aggregationField = _this$$props.aggregationField;
|
|
731
652
|
var afterKey = this.$data.afterKey;
|
|
732
653
|
var queryOptions = {
|
|
733
654
|
size: size
|
|
734
655
|
};
|
|
735
|
-
|
|
736
656
|
if (aggregationField) {
|
|
737
657
|
queryOptions.aggs = getCompositeAggsQuery({
|
|
738
658
|
props: this.$props,
|
|
@@ -740,7 +660,6 @@ var ReactiveList = {
|
|
|
740
660
|
showTopHits: true
|
|
741
661
|
}).aggs;
|
|
742
662
|
}
|
|
743
|
-
|
|
744
663
|
return queryOptions;
|
|
745
664
|
},
|
|
746
665
|
scrollHandler: function scrollHandler() {
|
|
@@ -750,9 +669,9 @@ var ReactiveList = {
|
|
|
750
669
|
},
|
|
751
670
|
loadMore: function loadMore() {
|
|
752
671
|
if (this.aggregationField && !this.afterKey) return;
|
|
753
|
-
|
|
754
672
|
if (this.hits && !this.shouldRenderPagination && this.total > this.hits.length) {
|
|
755
|
-
var value = this.$data.from + this.$props.size;
|
|
673
|
+
var value = this.$data.from + this.$props.size;
|
|
674
|
+
// If current hits length is less than the current from then it means
|
|
756
675
|
// that there are no results present.
|
|
757
676
|
// It can happen because of many reasons some of them are:
|
|
758
677
|
// 1. Using the `collapse` query to remove results
|
|
@@ -763,11 +682,9 @@ var ReactiveList = {
|
|
|
763
682
|
if (this.hits.length < value) {
|
|
764
683
|
return;
|
|
765
684
|
}
|
|
766
|
-
|
|
767
685
|
var options = _extends({}, getQueryOptions(this.$props), this.getAggsQuery());
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
686
|
+
this.from = value;
|
|
687
|
+
// Update default query to support pagination for aggregationField
|
|
771
688
|
updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props);
|
|
772
689
|
this.loadMoreAction(this.$props.componentId, _extends({}, options, {
|
|
773
690
|
from: value
|
|
@@ -791,39 +708,30 @@ var ReactiveList = {
|
|
|
791
708
|
}
|
|
792
709
|
},
|
|
793
710
|
renderStats: function renderStats() {
|
|
794
|
-
var
|
|
795
|
-
var renderResultStats = this.$scopedSlots.renderResultStats || this.$props.renderResultStats;
|
|
796
|
-
|
|
711
|
+
var renderResultStats = this.$slots.renderResultStats || this.$props.renderResultStats;
|
|
797
712
|
if (renderResultStats && this.$data.total) {
|
|
798
713
|
return renderResultStats(this.stats);
|
|
799
714
|
}
|
|
800
|
-
|
|
801
715
|
if (this.stats.numberOfResults) {
|
|
802
|
-
return
|
|
716
|
+
return createVNode("p", {
|
|
803
717
|
"class": resultStats + " " + getClassName(this.$props.innerClass, 'resultStats')
|
|
804
|
-
}, [this.stats.numberOfResults, " results found in ", this.stats.time || 0, "ms"]);
|
|
718
|
+
}, [this.stats.numberOfResults, createTextVNode(" results found in "), this.stats.time || 0, createTextVNode("ms")]);
|
|
805
719
|
}
|
|
806
|
-
|
|
807
720
|
return null;
|
|
808
721
|
},
|
|
809
722
|
renderNoResult: function renderNoResult() {
|
|
810
|
-
var
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
if (this.$scopedSlots.renderNoResults) {
|
|
723
|
+
var renderNoResults = this.$slots.renderNoResults || this.$props.renderNoResults;
|
|
724
|
+
if (this.$slots.renderNoResults) {
|
|
814
725
|
return isFunction(renderNoResults) ? renderNoResults() : renderNoResults;
|
|
815
726
|
}
|
|
816
|
-
|
|
817
|
-
return h("p", {
|
|
727
|
+
return createVNode("p", {
|
|
818
728
|
"class": getClassName(this.$props.innerClass, 'noResults') || null
|
|
819
729
|
}, [isFunction(renderNoResults) ? renderNoResults() : renderNoResults]);
|
|
820
730
|
},
|
|
821
731
|
handleSortChange: function handleSortChange(e) {
|
|
822
732
|
var index = e.target.value;
|
|
823
|
-
|
|
824
733
|
if (this.sortOptions && this.sortOptions[index]) {
|
|
825
734
|
var _ref5;
|
|
826
|
-
|
|
827
735
|
// This fixes issue #371 (where sorting a multi-result page with infinite loader breaks)
|
|
828
736
|
var options = getQueryOptions(this.$props);
|
|
829
737
|
options.from = 0;
|
|
@@ -832,8 +740,8 @@ var ReactiveList = {
|
|
|
832
740
|
options.sort = [(_ref5 = {}, _ref5[sortField] = {
|
|
833
741
|
order: sortBy
|
|
834
742
|
}, _ref5)];
|
|
835
|
-
this.sortOptionIndex = index;
|
|
836
|
-
|
|
743
|
+
this.sortOptionIndex = index;
|
|
744
|
+
// To handle sort options for RS API
|
|
837
745
|
this.updateComponentProps(this.componentId, {
|
|
838
746
|
dataField: sortField,
|
|
839
747
|
sortBy: sortBy
|
|
@@ -848,49 +756,36 @@ var ReactiveList = {
|
|
|
848
756
|
},
|
|
849
757
|
triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
|
|
850
758
|
var docId = documentId;
|
|
851
|
-
|
|
852
759
|
if (!docId) {
|
|
853
760
|
var _this$getData = this.getData(),
|
|
854
|
-
|
|
855
|
-
|
|
761
|
+
data = _this$getData.data;
|
|
856
762
|
var hitData = data.find(function (hit) {
|
|
857
763
|
return hit._click_id === searchPosition;
|
|
858
764
|
});
|
|
859
|
-
|
|
860
765
|
if (hitData && hitData._id) {
|
|
861
766
|
docId = hitData._id;
|
|
862
767
|
}
|
|
863
768
|
}
|
|
864
|
-
|
|
865
769
|
this.recordResultClick(searchPosition, docId);
|
|
866
770
|
},
|
|
867
771
|
renderSortOptions: function renderSortOptions() {
|
|
868
|
-
|
|
869
|
-
|
|
772
|
+
return createVNode("select", mergeProps(_transformOn({
|
|
773
|
+
change: this.handleSortChange
|
|
774
|
+
}), {
|
|
870
775
|
"class": sortOptions + " " + getClassName(this.$props.innerClass, 'sortOptions'),
|
|
871
|
-
"
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
"
|
|
876
|
-
"change": this.handleSortChange
|
|
877
|
-
},
|
|
878
|
-
"domProps": {
|
|
879
|
-
"value": this.sortOptionIndex
|
|
880
|
-
}
|
|
881
|
-
}, [this.sortOptions.map(function (sort, index) {
|
|
882
|
-
return h("option", {
|
|
776
|
+
"name": "sort-options",
|
|
777
|
+
"aria-label": "Sort options",
|
|
778
|
+
"value": this.sortOptionIndex
|
|
779
|
+
}), [this.sortOptions.map(function (sort, index) {
|
|
780
|
+
return createVNode("option", {
|
|
883
781
|
"key": sort.label,
|
|
884
|
-
"
|
|
885
|
-
"value": index
|
|
886
|
-
}
|
|
782
|
+
"value": index
|
|
887
783
|
}, [sort.label]);
|
|
888
784
|
})]);
|
|
889
785
|
},
|
|
890
786
|
withClickIds: function withClickIds(results) {
|
|
891
787
|
var _this$getAllData = this.getAllData(),
|
|
892
|
-
|
|
893
|
-
|
|
788
|
+
base = _this$getAllData.base;
|
|
894
789
|
return results.map(function (result, index) {
|
|
895
790
|
return _extends({}, result, {
|
|
896
791
|
_click_id: base + index
|
|
@@ -900,11 +795,11 @@ var ReactiveList = {
|
|
|
900
795
|
// Shape of the object to be returned in onData & render
|
|
901
796
|
getAllData: function getAllData() {
|
|
902
797
|
var size = this.size,
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
798
|
+
promotedResults = this.promotedResults,
|
|
799
|
+
aggregationData = this.aggregationData,
|
|
800
|
+
customData = this.customData,
|
|
801
|
+
currentPage = this.currentPage,
|
|
802
|
+
hits = this.hits;
|
|
908
803
|
var results = parseHits(hits) || [];
|
|
909
804
|
var parsedPromotedResults = parseHits(promotedResults) || [];
|
|
910
805
|
var base = currentPage * size;
|
|
@@ -920,10 +815,9 @@ var ReactiveList = {
|
|
|
920
815
|
},
|
|
921
816
|
getData: function getData() {
|
|
922
817
|
var _this$getAllData2 = this.getAllData(),
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
818
|
+
promotedResults = _this$getAllData2.promotedResults,
|
|
819
|
+
aggregationData = _this$getAllData2.aggregationData,
|
|
820
|
+
customData = _this$getAllData2.customData;
|
|
927
821
|
return {
|
|
928
822
|
data: this.data,
|
|
929
823
|
aggregationData: this.withClickIds(aggregationData || []),
|
|
@@ -935,23 +829,18 @@ var ReactiveList = {
|
|
|
935
829
|
},
|
|
936
830
|
getComponent: function getComponent$1() {
|
|
937
831
|
var error = this.error,
|
|
938
|
-
|
|
939
|
-
|
|
832
|
+
isLoading = this.isLoading;
|
|
940
833
|
var data = _extends({
|
|
941
834
|
error: error,
|
|
942
835
|
loading: isLoading || false,
|
|
943
836
|
loadMore: this.loadMore,
|
|
944
|
-
// TODO: Remove in v2
|
|
945
|
-
triggerAnalytics: this.triggerClickAnalytics,
|
|
946
837
|
triggerClickAnalytics: this.triggerClickAnalytics,
|
|
947
838
|
setPage: this.setPage
|
|
948
839
|
}, this.getData());
|
|
949
|
-
|
|
950
840
|
return getComponent(data, this);
|
|
951
841
|
}
|
|
952
842
|
}
|
|
953
843
|
};
|
|
954
|
-
|
|
955
844
|
var mapStateToProps = function mapStateToProps(state, props) {
|
|
956
845
|
return {
|
|
957
846
|
defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1,
|
|
@@ -965,7 +854,6 @@ var mapStateToProps = function mapStateToProps(state, props) {
|
|
|
965
854
|
total: state.hits[props.componentId] && state.hits[props.componentId].total,
|
|
966
855
|
hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
|
|
967
856
|
analytics: state.config && state.config.analytics,
|
|
968
|
-
enableAppbase: state.config.enableAppbase,
|
|
969
857
|
url: state.config.url,
|
|
970
858
|
error: state.error[props.componentId],
|
|
971
859
|
afterKey: state.aggregations[props.componentId] && state.aggregations[props.componentId][props.aggregationField] && state.aggregations[props.componentId][props.aggregationField].after_key,
|
|
@@ -973,7 +861,6 @@ var mapStateToProps = function mapStateToProps(state, props) {
|
|
|
973
861
|
isLoading: state.isLoading[props.componentId]
|
|
974
862
|
};
|
|
975
863
|
};
|
|
976
|
-
|
|
977
864
|
var mapDispatchtoProps = {
|
|
978
865
|
loadMoreAction: loadMore,
|
|
979
866
|
setPageURL: setValue,
|
|
@@ -982,71 +869,60 @@ var mapDispatchtoProps = {
|
|
|
982
869
|
updateComponentProps: updateComponentProps,
|
|
983
870
|
setDefaultQuery: setDefaultQuery,
|
|
984
871
|
recordResultClick: recordResultClick
|
|
985
|
-
};
|
|
986
|
-
|
|
872
|
+
};
|
|
873
|
+
// Only used for SSR
|
|
987
874
|
ReactiveList.generateQueryOptions = function (props) {
|
|
988
875
|
var options = getQueryOptions(props);
|
|
989
876
|
var size = props.size,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
877
|
+
dataField = props.dataField,
|
|
878
|
+
defaultSortOption = props.defaultSortOption,
|
|
879
|
+
sortOptionsNew = props.sortOptions,
|
|
880
|
+
currentPage = props.currentPage,
|
|
881
|
+
sortBy = props.sortBy;
|
|
995
882
|
options.from = currentPage ? (currentPage - 1) * (size || 10) : 0;
|
|
996
883
|
options.size = size || 10;
|
|
997
|
-
|
|
998
884
|
var getSortOption = function getSortOption() {
|
|
999
885
|
var _ref7;
|
|
1000
|
-
|
|
1001
886
|
if (defaultSortOption) {
|
|
1002
887
|
var sortOption = sortOptionsNew.find(function (option) {
|
|
1003
888
|
return option.label === defaultSortOption;
|
|
1004
889
|
});
|
|
1005
|
-
|
|
1006
890
|
if (sortOption) {
|
|
1007
891
|
var _ref6;
|
|
1008
|
-
|
|
1009
892
|
return _ref6 = {}, _ref6[sortOption.dataField] = {
|
|
1010
893
|
order: sortOption.sortBy
|
|
1011
894
|
}, _ref6;
|
|
1012
895
|
}
|
|
1013
896
|
}
|
|
1014
|
-
|
|
1015
897
|
return _ref7 = {}, _ref7[sortOptionsNew[0].dataField] = {
|
|
1016
898
|
order: sortOptionsNew[0].sortBy
|
|
1017
899
|
}, _ref7;
|
|
1018
900
|
};
|
|
1019
|
-
|
|
1020
901
|
if (sortOptionsNew) {
|
|
1021
902
|
options.sort = [getSortOption()];
|
|
1022
903
|
} else if (sortBy) {
|
|
1023
904
|
var _ref8;
|
|
1024
|
-
|
|
1025
905
|
options.sort = [(_ref8 = {}, _ref8[dataField] = {
|
|
1026
906
|
order: sortBy
|
|
1027
907
|
}, _ref8)];
|
|
1028
908
|
}
|
|
1029
|
-
|
|
1030
909
|
return options;
|
|
1031
910
|
};
|
|
1032
|
-
|
|
1033
911
|
ReactiveList.hasInternalComponent = function () {
|
|
1034
912
|
return true;
|
|
1035
913
|
};
|
|
1036
|
-
|
|
1037
|
-
var RLConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
|
|
914
|
+
var RLConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(ReactiveList), {
|
|
1038
915
|
componentType: componentTypes.reactiveList,
|
|
1039
916
|
internalComponent: ReactiveList.hasInternalComponent()
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
Vue.component(
|
|
917
|
+
}));
|
|
918
|
+
RLConnected.name = ReactiveList.name;
|
|
919
|
+
RLConnected.install = function (Vue) {
|
|
920
|
+
Vue.component(RLConnected.name, RLConnected);
|
|
1044
921
|
Vue.component(ResultListWrapper.name, ResultListWrapper);
|
|
1045
922
|
Vue.component(ResultCardsWrapper.name, ResultCardsWrapper);
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
ReactiveList.componentType = componentTypes.reactiveList;
|
|
923
|
+
};
|
|
924
|
+
// Add componentType for SSR
|
|
925
|
+
RLConnected.componentType = componentTypes.reactiveList;
|
|
1050
926
|
|
|
1051
|
-
export default
|
|
927
|
+
export default RLConnected;
|
|
1052
928
|
export { RLConnected };
|