@appbaseio/reactivesearch-vue 1.32.4 → 1.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +2558 -2390
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +14 -9
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/{ComponentWrapper-ad3dad02.js → ComponentWrapper-981ab977.js} +7 -6
- package/dist/cjs/{DataSearch-b51a5d0f.js → DataSearch-c42d8681.js} +11 -8
- package/dist/cjs/DataSearch.js +6 -4
- package/dist/cjs/DropDown-c479bbb0.js +1 -1
- package/dist/cjs/DynamicRangeSlider.js +5 -3
- package/dist/cjs/MultiDropdownList.js +10 -6
- package/dist/cjs/MultiList.js +11 -6
- package/dist/cjs/MultiRange.js +7 -5
- package/dist/cjs/PreferencesConsumer-4707bd94.js +87 -0
- package/dist/cjs/RangeInput.js +7 -5
- package/dist/cjs/RangeSlider.js +6 -5
- package/dist/cjs/ReactiveBase.js +6 -4
- package/dist/cjs/{install-add725fe.js → ReactiveComponent-63ef70c2.js} +407 -22
- package/dist/cjs/ReactiveComponent.js +48 -340
- package/dist/cjs/ReactiveGoogleMap.js +6 -5
- package/dist/cjs/ReactiveList.js +6 -5
- package/dist/cjs/SelectedFilters.js +2 -2
- package/dist/cjs/SingleDropdownList.js +10 -6
- package/dist/cjs/SingleList.js +12 -6
- package/dist/cjs/SingleRange.js +7 -5
- package/dist/cjs/StateProvider.js +2 -2
- package/dist/cjs/ToggleButton.js +8 -6
- package/dist/cjs/{index-6a167fe0.js → index-08f8dfa3.js} +1 -1
- package/dist/cjs/index.js +28 -21
- package/dist/cjs/initReactivesearch.js +1 -1
- package/dist/cjs/install.js +30 -24
- package/dist/cjs/version.js +1 -1
- package/dist/es/{ComponentWrapper-424e86fd.js → ComponentWrapper-d5e814a4.js} +7 -6
- package/dist/es/{DataSearch-c40e26c7.js → DataSearch-d56bf07a.js} +11 -9
- package/dist/es/DataSearch.js +5 -4
- package/dist/es/DropDown-05a644a5.js +1 -1
- package/dist/es/DynamicRangeSlider.js +5 -3
- package/dist/es/MultiDropdownList.js +10 -6
- package/dist/es/MultiList.js +11 -6
- package/dist/es/MultiRange.js +7 -5
- package/dist/es/PreferencesConsumer-4169deb1.js +85 -0
- package/dist/es/RangeInput.js +7 -5
- package/dist/es/RangeSlider.js +6 -5
- package/dist/es/ReactiveBase.js +6 -4
- package/dist/es/{install-5b8c657a.js → ReactiveComponent-9e4721e1.js} +418 -33
- package/dist/es/ReactiveComponent.js +44 -337
- package/dist/es/ReactiveGoogleMap.js +6 -5
- package/dist/es/ReactiveList.js +6 -5
- package/dist/es/SelectedFilters.js +2 -2
- package/dist/es/SingleDropdownList.js +10 -6
- package/dist/es/SingleList.js +12 -6
- package/dist/es/SingleRange.js +7 -5
- package/dist/es/StateProvider.js +2 -2
- package/dist/es/ToggleButton.js +8 -6
- package/dist/es/{index-7788a843.js → index-99c5f9c9.js} +1 -1
- package/dist/es/index.js +14 -13
- package/dist/es/initReactivesearch.js +1 -1
- package/dist/es/install.js +32 -22
- package/dist/es/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
2
|
+
import { b as getCamelCase } from './index-99c5f9c9.js';
|
|
3
|
+
|
|
4
|
+
var deepValue = function deepValue(o, p) {
|
|
5
|
+
return p.split('.').reduce(function (a, v) {
|
|
6
|
+
return a ? a[v] : null;
|
|
7
|
+
}, o);
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* PreferencesConsumer reads the preferences from SearchPreferencesContext
|
|
11
|
+
* and set the props from preferences to the component
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var PreferencesConsumer = function PreferencesConsumer(component) {
|
|
17
|
+
return {
|
|
18
|
+
name: 'PreferencesConsumer',
|
|
19
|
+
inject: {
|
|
20
|
+
$searchPreferences: {
|
|
21
|
+
"default": null
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
render: function render(h) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
|
|
27
|
+
var userProps = Object.keys(this.$attrs).reduce(function (result, key) {
|
|
28
|
+
var _extends2;
|
|
29
|
+
|
|
30
|
+
return _extends({}, result, (_extends2 = {}, _extends2[getCamelCase(key)] = _this.$attrs[key], _extends2));
|
|
31
|
+
}, {});
|
|
32
|
+
var context = this.$searchPreferences;
|
|
33
|
+
|
|
34
|
+
if (!userProps || !userProps.componentId) {
|
|
35
|
+
throw Error('ReactiveSearch: componentId is required');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var componentId = userProps.componentId;
|
|
39
|
+
var preferencesPath = userProps.preferencesPath;
|
|
40
|
+
var preferences;
|
|
41
|
+
|
|
42
|
+
if (context) {
|
|
43
|
+
if (preferencesPath) {
|
|
44
|
+
// read preferences from path
|
|
45
|
+
preferences = deepValue(context, preferencesPath);
|
|
46
|
+
} else {
|
|
47
|
+
preferences = deepValue(context, ['componentSettings', componentId].join('.')); // read preferences from componentSettings
|
|
48
|
+
}
|
|
49
|
+
} // Retrieve component specific preferences
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
var componentProps = userProps;
|
|
53
|
+
|
|
54
|
+
if (preferences) {
|
|
55
|
+
if (preferences.rsConfig) {
|
|
56
|
+
componentProps = _extends({}, preferences.rsConfig, componentProps);
|
|
57
|
+
} else {
|
|
58
|
+
componentProps = _extends({}, preferences, componentProps);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (preferences.enabled !== undefined && !preferences.enabled) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
} // Parse component props
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
Object.keys(componentProps).forEach(function (p) {
|
|
68
|
+
if (typeof componentProps[p] === 'string') {
|
|
69
|
+
if (['defaultQuery', 'customQuery', 'setOption'].includes(p)) {
|
|
70
|
+
// eslint-disable-next-line
|
|
71
|
+
componentProps[p] = eval(componentProps[p]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return h(component, {
|
|
76
|
+
attrs: componentProps,
|
|
77
|
+
on: this.$listeners,
|
|
78
|
+
scopedSlots: this.$scopedSlots,
|
|
79
|
+
slots: this.$slots
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { PreferencesConsumer as P };
|
package/dist/es/RangeInput.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { helper } from '@appbaseio/reactivecore';
|
|
2
|
+
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
2
3
|
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
4
|
import VueTypes from 'vue-types';
|
|
4
|
-
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
5
5
|
import { css } from 'emotion';
|
|
6
6
|
import styled from '@appbaseio/vue-emotion';
|
|
7
7
|
import 'polished';
|
|
8
8
|
import { t as types } from './vueTypes-b8146772.js';
|
|
9
9
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
10
10
|
import 'redux';
|
|
11
|
-
import { c as connect } from './index-
|
|
12
|
-
import { C as ComponentWrapper } from './ComponentWrapper-
|
|
11
|
+
import { c as connect } from './index-99c5f9c9.js';
|
|
12
|
+
import { C as ComponentWrapper } from './ComponentWrapper-d5e814a4.js';
|
|
13
|
+
import { P as PreferencesConsumer } from './PreferencesConsumer-4169deb1.js';
|
|
13
14
|
import './Title-3342664a.js';
|
|
14
15
|
import { F as Flex } from './Flex-1f0795c3.js';
|
|
15
16
|
import { I as Input } from './Input-7a2a9fac.js';
|
|
@@ -325,9 +326,9 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
325
326
|
};
|
|
326
327
|
};
|
|
327
328
|
|
|
328
|
-
var RangeConnected = ComponentWrapper(connect(mapStateToProps, {})(RangeInput), {
|
|
329
|
+
var RangeConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, {})(RangeInput), {
|
|
329
330
|
componentType: componentTypes.rangeInput
|
|
330
|
-
});
|
|
331
|
+
}));
|
|
331
332
|
|
|
332
333
|
RangeInput.install = function (Vue) {
|
|
333
334
|
Vue.component(RangeInput.name, RangeConnected);
|
|
@@ -337,3 +338,4 @@ RangeInput.install = function (Vue) {
|
|
|
337
338
|
RangeInput.componentType = componentTypes.rangeInput;
|
|
338
339
|
|
|
339
340
|
export default RangeInput;
|
|
341
|
+
export { RangeConnected };
|
package/dist/es/RangeSlider.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Actions, helper } from '@appbaseio/reactivecore';
|
|
2
|
+
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
2
3
|
import { a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
4
|
import VueTypes from 'vue-types';
|
|
4
|
-
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
5
5
|
import '@appbaseio/vue-emotion';
|
|
6
6
|
import { t as types } from './vueTypes-b8146772.js';
|
|
7
7
|
import '@appbaseio/reactivecore/lib/utils/transform';
|
|
8
8
|
import 'redux';
|
|
9
|
-
import { f as updateCustomQuery, i as isQueryIdentical, c as connect } from './index-
|
|
10
|
-
import { C as ComponentWrapper } from './ComponentWrapper-
|
|
9
|
+
import { f as updateCustomQuery, i as isQueryIdentical, c as connect } from './index-99c5f9c9.js';
|
|
10
|
+
import { C as ComponentWrapper } from './ComponentWrapper-d5e814a4.js';
|
|
11
|
+
import { P as PreferencesConsumer } from './PreferencesConsumer-4169deb1.js';
|
|
11
12
|
import { T as Title } from './Title-3342664a.js';
|
|
12
13
|
import { C as Container } from './Container-ba826e96.js';
|
|
13
14
|
import NoSSR from 'vue-no-ssr';
|
|
@@ -278,9 +279,9 @@ var mapDispatchtoProps = {
|
|
|
278
279
|
setQueryOptions: setQueryOptions,
|
|
279
280
|
setCustomQuery: setCustomQuery
|
|
280
281
|
};
|
|
281
|
-
var RangeConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(RangeSlider), {
|
|
282
|
+
var RangeConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(RangeSlider), {
|
|
282
283
|
componentType: componentTypes.rangeSlider
|
|
283
|
-
});
|
|
284
|
+
}));
|
|
284
285
|
|
|
285
286
|
RangeSlider.install = function (Vue) {
|
|
286
287
|
Vue.component(RangeSlider.name, RangeConnected);
|
package/dist/es/ReactiveBase.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import configureStore, { Actions, helper } from '@appbaseio/reactivecore';
|
|
2
|
+
import '@appbaseio/reactivecore/lib/utils/constants';
|
|
2
3
|
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
4
|
import VueTypes from 'vue-types';
|
|
4
|
-
import '@appbaseio/reactivecore/lib/utils/constants';
|
|
5
5
|
import { isEqual as isEqual$1, transformRequestUsingEndpoint } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
6
6
|
import styled from '@appbaseio/vue-emotion';
|
|
7
7
|
import { t as types } from './vueTypes-b8146772.js';
|
|
8
8
|
import 'redux';
|
|
9
|
-
import { c as connect, e as composeThemeObject, X as X_SEARCH_CLIENT } from './index-
|
|
9
|
+
import { c as connect, e as composeThemeObject, X as X_SEARCH_CLIENT } from './index-99c5f9c9.js';
|
|
10
10
|
import _mergeJSXProps from '@vue/babel-helper-vue-jsx-merge-props';
|
|
11
11
|
import { updateAnalyticsConfig } from '@appbaseio/reactivecore/lib/actions/analytics';
|
|
12
12
|
import Appbase from 'appbase-js';
|
|
@@ -384,12 +384,14 @@ var ReactiveBase = {
|
|
|
384
384
|
getSearchParams: types.func,
|
|
385
385
|
setSearchParams: types.func,
|
|
386
386
|
mongodb: types.mongodb,
|
|
387
|
-
endpoint: types.endpointConfig
|
|
387
|
+
endpoint: types.endpointConfig,
|
|
388
|
+
preferences: VueTypes.object
|
|
388
389
|
},
|
|
389
390
|
provide: function provide() {
|
|
390
391
|
return {
|
|
391
392
|
theme_reactivesearch: composeThemeObject(getTheme(this.$props.themePreset), this.$props.theme),
|
|
392
|
-
store: this.store
|
|
393
|
+
store: this.store,
|
|
394
|
+
$searchPreferences: this.preferences
|
|
393
395
|
};
|
|
394
396
|
},
|
|
395
397
|
watch: {
|
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
import { Actions, helper, causes } from '@appbaseio/reactivecore';
|
|
2
|
-
import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
3
|
-
import VueTypes from 'vue-types';
|
|
4
2
|
import { SEARCH_COMPONENTS_MODES, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
3
|
+
import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-76660dab.js';
|
|
4
|
+
import VueTypes from 'vue-types';
|
|
5
5
|
import { getQueryOptions, suggestionTypes } from '@appbaseio/reactivecore/lib/utils/helper';
|
|
6
6
|
import styled from '@appbaseio/vue-emotion';
|
|
7
7
|
import { B as Button } from './Button-35aa984e.js';
|
|
8
8
|
import { t as types } from './vueTypes-b8146772.js';
|
|
9
|
-
import
|
|
10
|
-
import { n as decodeHtml, h as hasCustomRenderer, i as isQueryIdentical, g as getComponent, u as updateDefaultQuery, f as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-
|
|
11
|
-
import { C as ComponentWrapper } from './ComponentWrapper-
|
|
9
|
+
import { RLConnected } from './ReactiveList.js';
|
|
10
|
+
import { n as decodeHtml, h as hasCustomRenderer, i as isQueryIdentical, g as getComponent, u as updateDefaultQuery, f as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-99c5f9c9.js';
|
|
11
|
+
import { C as ComponentWrapper } from './ComponentWrapper-d5e814a4.js';
|
|
12
|
+
import { P as PreferencesConsumer } from './PreferencesConsumer-4169deb1.js';
|
|
12
13
|
import { T as Title } from './Title-3342664a.js';
|
|
13
|
-
import ReactiveBase from './ReactiveBase.js';
|
|
14
14
|
import hotkeys from 'hotkeys-js';
|
|
15
|
-
import { S as SearchSvg,
|
|
15
|
+
import { S as SearchSvg, b as SuggestionWrapper, I as InputAddon, M as Mic, T as TagItem, c as TagsContainer, d as InputGroup, C as CustomSvg, e as SuggestionItem, D as DSConnected } from './DataSearch-d56bf07a.js';
|
|
16
16
|
import { C as CancelSvg, a as IconGroup, I as IconWrapper, D as Downshift, b as InputWrapper } from './CancelSvg-4cfae5fd.js';
|
|
17
17
|
import { s as suggestionsContainer, I as Input, a as suggestions } from './Input-7a2a9fac.js';
|
|
18
18
|
import { C as Container } from './Container-ba826e96.js';
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import ResultList from './ResultList.js';
|
|
30
|
-
import RangeSlider from './RangeSlider.js';
|
|
31
|
-
import DynamicRangeSlider from './DynamicRangeSlider.js';
|
|
32
|
-
import StateProvider from './StateProvider.js';
|
|
33
|
-
import RangeInput from './RangeInput.js';
|
|
19
|
+
import { ListConnected as ListConnected$4 } from './SingleList.js';
|
|
20
|
+
import { ListConnected as ListConnected$3 } from './MultiList.js';
|
|
21
|
+
import { ListConnected as ListConnected$2 } from './SingleDropdownList.js';
|
|
22
|
+
import { ListConnected as ListConnected$1 } from './MultiDropdownList.js';
|
|
23
|
+
import { ListConnected } from './ToggleButton.js';
|
|
24
|
+
import { RangeConnected as RangeConnected$4 } from './DynamicRangeSlider.js';
|
|
25
|
+
import { RangeConnected as RangeConnected$3 } from './SingleRange.js';
|
|
26
|
+
import { RangeConnected as RangeConnected$2 } from './MultiRange.js';
|
|
27
|
+
import { RangeConnected as RangeConnected$1 } from './RangeSlider.js';
|
|
28
|
+
import { RangeConnected } from './RangeInput.js';
|
|
34
29
|
|
|
35
30
|
var _templateObject;
|
|
36
31
|
var AutofillSvgIcon = styled('button')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tmargin-left: auto;\n\tposition: relative;\n\tright: -3px;\n\tborder: none;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0;\n\tz-index: 111000;\n\n\tsvg {\n\t\tcursor: pointer;\n\t\tfill: #707070;\n\t\theight: 20px;\n\t}\n\n\t&:hover {\n\t\tsvg {\n\t\t\tfill: #1c1a1a;\n\t\t}\n\t}\n"])));
|
|
@@ -1379,24 +1374,414 @@ var mapDispatchToProps = {
|
|
|
1379
1374
|
setDefaultQuery: setDefaultQuery,
|
|
1380
1375
|
recordSuggestionClick: recordSuggestionClick
|
|
1381
1376
|
};
|
|
1382
|
-
var
|
|
1377
|
+
var SBConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(SearchBox), {
|
|
1383
1378
|
componentType: componentTypes.searchBox,
|
|
1384
1379
|
internalComponent: true
|
|
1385
|
-
});
|
|
1380
|
+
}));
|
|
1386
1381
|
|
|
1387
1382
|
SearchBox.install = function (Vue) {
|
|
1388
|
-
Vue.component(SearchBox.name,
|
|
1383
|
+
Vue.component(SearchBox.name, SBConnected);
|
|
1389
1384
|
}; // Add componentType for SSR
|
|
1390
1385
|
|
|
1391
1386
|
|
|
1392
1387
|
SearchBox.componentType = componentTypes.searchBox;
|
|
1393
1388
|
|
|
1394
|
-
var
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1389
|
+
var _excluded = ["options"];
|
|
1390
|
+
var updateQuery$1 = Actions.updateQuery,
|
|
1391
|
+
setQueryOptions = Actions.setQueryOptions,
|
|
1392
|
+
setCustomQuery$1 = Actions.setCustomQuery,
|
|
1393
|
+
setDefaultQuery$1 = Actions.setDefaultQuery;
|
|
1394
|
+
var parseHits = helper.parseHits,
|
|
1395
|
+
isEqual$1 = helper.isEqual,
|
|
1396
|
+
getCompositeAggsQuery$1 = helper.getCompositeAggsQuery,
|
|
1397
|
+
getResultStats$1 = helper.getResultStats,
|
|
1398
|
+
extractQueryFromCustomQuery = helper.extractQueryFromCustomQuery,
|
|
1399
|
+
getOptionsForCustomQuery = helper.getOptionsForCustomQuery;
|
|
1400
|
+
var ReactiveComponent = {
|
|
1401
|
+
name: 'ReactiveComponent',
|
|
1402
|
+
props: {
|
|
1403
|
+
componentId: types.stringRequired,
|
|
1404
|
+
aggregationField: types.string,
|
|
1405
|
+
aggregationSize: VueTypes.number,
|
|
1406
|
+
size: VueTypes.number,
|
|
1407
|
+
defaultQuery: types.func,
|
|
1408
|
+
customQuery: types.func,
|
|
1409
|
+
filterLabel: types.string,
|
|
1410
|
+
react: types.react,
|
|
1411
|
+
showFilter: VueTypes.bool.def(true),
|
|
1412
|
+
URLParams: VueTypes.bool.def(false),
|
|
1413
|
+
distinctField: types.string,
|
|
1414
|
+
distinctFieldConfig: types.props,
|
|
1415
|
+
index: VueTypes.string,
|
|
1416
|
+
endpoint: types.endpointConfig
|
|
1417
|
+
},
|
|
1418
|
+
created: function created() {
|
|
1419
|
+
var _this = this;
|
|
1420
|
+
|
|
1421
|
+
var props = this.$props;
|
|
1422
|
+
this.internalComponent = null;
|
|
1423
|
+
this.$defaultQuery = null; // Set custom query in store
|
|
1424
|
+
|
|
1425
|
+
updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
|
|
1426
|
+
var customQuery = props.customQuery,
|
|
1427
|
+
componentId = props.componentId,
|
|
1428
|
+
filterLabel = props.filterLabel,
|
|
1429
|
+
showFilter = props.showFilter,
|
|
1430
|
+
URLParams = props.URLParams,
|
|
1431
|
+
distinctField = props.distinctField,
|
|
1432
|
+
distinctFieldConfig = props.distinctFieldConfig,
|
|
1433
|
+
index = props.index;
|
|
1434
|
+
|
|
1435
|
+
if (this.enableAppbase && this.aggregationField && this.aggregationField !== '') {
|
|
1436
|
+
console.warn('Warning(ReactiveSearch): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
if (!this.enableAppbase && (distinctField || distinctFieldConfig)) {
|
|
1440
|
+
console.warn('Warning(ReactiveSearch): In order to use the `distinctField` and `distinctFieldConfig` props, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
if (!this.enableAppbase && index) {
|
|
1444
|
+
console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
if (customQuery) {
|
|
1448
|
+
var calcCustomQuery = customQuery(this.selectedValue, props);
|
|
1449
|
+
var query = extractQueryFromCustomQuery(calcCustomQuery);
|
|
1450
|
+
var customQueryOptions = calcCustomQuery ? getOptionsForCustomQuery(calcCustomQuery) : null;
|
|
1451
|
+
|
|
1452
|
+
if (customQueryOptions) {
|
|
1453
|
+
this.setQueryOptions(componentId, _extends({}, customQueryOptions, this.getAggsQuery()), false);
|
|
1454
|
+
} else this.setQueryOptions(componentId, this.getAggsQuery(), false);
|
|
1455
|
+
|
|
1456
|
+
this.updateQuery({
|
|
1457
|
+
componentId: componentId,
|
|
1458
|
+
query: query,
|
|
1459
|
+
value: this.selectedValue || null,
|
|
1460
|
+
label: filterLabel,
|
|
1461
|
+
showFilter: showFilter,
|
|
1462
|
+
URLParams: URLParams
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
this.setQuery = function (_ref) {
|
|
1467
|
+
var options = _ref.options,
|
|
1468
|
+
obj = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1469
|
+
|
|
1470
|
+
var queryToBeSet = obj.query; // when enableAppbase is true, Backend throws error because of repeated query in request body
|
|
1471
|
+
|
|
1472
|
+
if (queryToBeSet && queryToBeSet.query) {
|
|
1473
|
+
queryToBeSet = queryToBeSet.query;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
var customQueryCalc = _extends({}, options, {
|
|
1477
|
+
query: queryToBeSet
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
var rsAPIQuery = customQueryCalc; // handle stored queries
|
|
1481
|
+
|
|
1482
|
+
if (queryToBeSet && queryToBeSet.id) {
|
|
1483
|
+
rsAPIQuery = queryToBeSet;
|
|
1484
|
+
} // Update customQuery field for RS API
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
_this.setCustomQuery(props.componentId, rsAPIQuery);
|
|
1488
|
+
|
|
1489
|
+
if (options) {
|
|
1490
|
+
_this.setQueryOptions(props.componentId, _extends({}, _this.getAggsQuery(), options), false);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
_this.updateQuery(_extends({}, obj, {
|
|
1494
|
+
query: customQueryCalc.query,
|
|
1495
|
+
componentId: props.componentId,
|
|
1496
|
+
label: props.filterLabel,
|
|
1497
|
+
showFilter: props.showFilter,
|
|
1498
|
+
URLParams: props.URLParams
|
|
1499
|
+
}));
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
if (props.defaultQuery) {
|
|
1503
|
+
this.internalComponent = props.componentId + "__internal";
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
if (this.internalComponent && this.$props.defaultQuery) {
|
|
1507
|
+
updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
|
|
1508
|
+
this.$defaultQuery = this.$props.defaultQuery(this.selectedValue, this.$props);
|
|
1509
|
+
|
|
1510
|
+
var _query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
1511
|
+
|
|
1512
|
+
var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
|
|
1513
|
+
|
|
1514
|
+
if (queryOptions) {
|
|
1515
|
+
this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
|
|
1516
|
+
} else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
|
|
1517
|
+
|
|
1518
|
+
this.updateQuery({
|
|
1519
|
+
componentId: this.internalComponent,
|
|
1520
|
+
query: _query
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
watch: {
|
|
1525
|
+
hits: function hits(newVal, oldVal) {
|
|
1526
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1527
|
+
this.$emit('data', this.getData());
|
|
1528
|
+
}
|
|
1529
|
+
},
|
|
1530
|
+
rawData: function rawData(newVal, oldVal) {
|
|
1531
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1532
|
+
this.$emit('data', this.getData());
|
|
1533
|
+
}
|
|
1534
|
+
},
|
|
1535
|
+
aggregations: function aggregations(newVal, oldVal) {
|
|
1536
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1537
|
+
this.$emit('data', this.getData());
|
|
1538
|
+
}
|
|
1539
|
+
},
|
|
1540
|
+
aggregationData: function aggregationData(newVal, oldVal) {
|
|
1541
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1542
|
+
this.$emit('data', this.getData());
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
promotedResults: function promotedResults(newVal, oldVal) {
|
|
1546
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1547
|
+
this.$emit('data', this.getData());
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1550
|
+
hidden: function hidden(newVal, oldVal) {
|
|
1551
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1552
|
+
this.$emit('data', this.getData());
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
total: function total(newVal, oldVal) {
|
|
1556
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1557
|
+
this.$emit('data', this.getData());
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
time: function time(newVal, oldVal) {
|
|
1561
|
+
if (!isEqual$1(newVal, oldVal)) {
|
|
1562
|
+
this.$emit('data', this.getData());
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
defaultQuery: function defaultQuery(newVal, oldVal) {
|
|
1566
|
+
if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
|
|
1567
|
+
this.$defaultQuery = newVal(this.selectedValue, this.$props);
|
|
1568
|
+
var query = extractQueryFromCustomQuery(this.$defaultQuery);
|
|
1569
|
+
var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
|
|
1570
|
+
|
|
1571
|
+
if (queryOptions) {
|
|
1572
|
+
this.setQueryOptions(this.internalComponent, _extends({}, queryOptions, this.getAggsQuery()), false);
|
|
1573
|
+
} else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false); // Update default query for RS API
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
|
|
1577
|
+
this.updateQuery({
|
|
1578
|
+
componentId: this.internalComponent,
|
|
1579
|
+
query: query
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
customQuery: function customQuery(newVal, oldVal) {
|
|
1584
|
+
if (newVal && !isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
|
|
1585
|
+
var componentId = this.$props.componentId;
|
|
1586
|
+
this.$customQuery = newVal(this.selectedValue, this.$props);
|
|
1587
|
+
var query = extractQueryFromCustomQuery(this.$customQuery);
|
|
1588
|
+
var queryOptions = getOptionsForCustomQuery(this.$customQuery);
|
|
1589
|
+
|
|
1590
|
+
if (queryOptions) {
|
|
1591
|
+
this.setQueryOptions(componentId, _extends({}, queryOptions, this.getAggsQuery()), false);
|
|
1592
|
+
} else this.setQueryOptions(componentId, this.getAggsQuery(), false); // Update custom query for RS API
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
|
|
1596
|
+
this.updateQuery({
|
|
1597
|
+
componentId: componentId,
|
|
1598
|
+
query: query
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
},
|
|
1603
|
+
render: function render() {
|
|
1604
|
+
var h = arguments[0];
|
|
1605
|
+
|
|
1606
|
+
try {
|
|
1607
|
+
var dom = this.$scopedSlots["default"];
|
|
1608
|
+
var error = this.error,
|
|
1609
|
+
isLoading = this.isLoading,
|
|
1610
|
+
selectedValue = this.selectedValue;
|
|
1611
|
+
|
|
1612
|
+
var propsToBePassed = _extends({
|
|
1613
|
+
error: error,
|
|
1614
|
+
loading: isLoading
|
|
1615
|
+
}, this.getData(), {
|
|
1616
|
+
value: selectedValue,
|
|
1617
|
+
setQuery: this.setQuery
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
return h("div", [dom(propsToBePassed)]);
|
|
1621
|
+
} catch (e) {
|
|
1622
|
+
return null;
|
|
1623
|
+
}
|
|
1624
|
+
},
|
|
1625
|
+
methods: {
|
|
1626
|
+
getAggsQuery: function getAggsQuery() {
|
|
1627
|
+
if (this.aggregationField) {
|
|
1628
|
+
return {
|
|
1629
|
+
aggs: getCompositeAggsQuery$1({
|
|
1630
|
+
props: this.$props,
|
|
1631
|
+
showTopHits: true,
|
|
1632
|
+
value: this.selectedValue
|
|
1633
|
+
}).aggs
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
return {};
|
|
1638
|
+
},
|
|
1639
|
+
getData: function getData() {
|
|
1640
|
+
var hits = this.hits,
|
|
1641
|
+
aggregations = this.aggregations,
|
|
1642
|
+
aggregationData = this.aggregationData,
|
|
1643
|
+
promotedResults = this.promotedResults,
|
|
1644
|
+
rawData = this.rawData;
|
|
1645
|
+
var filteredResults = parseHits(hits);
|
|
1646
|
+
|
|
1647
|
+
if (promotedResults.length) {
|
|
1648
|
+
var ids = promotedResults.map(function (item) {
|
|
1649
|
+
return item._id;
|
|
1650
|
+
}).filter(Boolean);
|
|
1651
|
+
|
|
1652
|
+
if (ids) {
|
|
1653
|
+
filteredResults = filteredResults.filter(function (item) {
|
|
1654
|
+
return !ids.includes(item._id);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
filteredResults = [].concat(promotedResults, filteredResults);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
return {
|
|
1662
|
+
data: filteredResults,
|
|
1663
|
+
aggregationData: aggregationData,
|
|
1664
|
+
rawData: rawData,
|
|
1665
|
+
aggregations: aggregations,
|
|
1666
|
+
promotedData: promotedResults,
|
|
1667
|
+
resultStats: this.stats
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
},
|
|
1671
|
+
computed: {
|
|
1672
|
+
stats: function stats() {
|
|
1673
|
+
return getResultStats$1(this);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
|
|
1678
|
+
ReactiveComponent.hasInternalComponent = function (props) {
|
|
1679
|
+
return !!props.defaultQuery;
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
1683
|
+
return {
|
|
1684
|
+
aggregations: state.aggregations[props.componentId] && state.aggregations[props.componentId] || null,
|
|
1685
|
+
aggregationData: state.compositeAggregations[props.componentId] || [],
|
|
1686
|
+
hits: state.hits[props.componentId] && state.hits[props.componentId].hits || [],
|
|
1687
|
+
rawData: state.rawData[props.componentId],
|
|
1688
|
+
error: state.error[props.componentId],
|
|
1689
|
+
isLoading: state.isLoading[props.componentId],
|
|
1690
|
+
selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
|
|
1691
|
+
promotedResults: state.promotedResults[props.componentId] || [],
|
|
1692
|
+
time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
|
|
1693
|
+
total: state.hits[props.componentId] && state.hits[props.componentId].total,
|
|
1694
|
+
hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
|
|
1695
|
+
componentProps: state.props[props.componentId],
|
|
1696
|
+
enableAppbase: state.config.enableAppbase
|
|
1697
|
+
};
|
|
1698
|
+
};
|
|
1699
|
+
|
|
1700
|
+
var mapDispatchtoProps = {
|
|
1701
|
+
setQueryOptions: setQueryOptions,
|
|
1702
|
+
updateQuery: updateQuery$1,
|
|
1703
|
+
setCustomQuery: setCustomQuery$1,
|
|
1704
|
+
setDefaultQuery: setDefaultQuery$1
|
|
1705
|
+
};
|
|
1706
|
+
var ConnectedComponent = ComponentWrapper(connect(mapStateToProps$1, mapDispatchtoProps)(ReactiveComponent), {
|
|
1707
|
+
componentType: componentTypes.reactiveComponent
|
|
1708
|
+
});
|
|
1709
|
+
var RcConnected = PreferencesConsumer({
|
|
1710
|
+
name: 'RcConnected',
|
|
1711
|
+
render: function render(h) {
|
|
1712
|
+
var component = ConnectedComponent;
|
|
1713
|
+
|
|
1714
|
+
switch (this.$attrs.componentType) {
|
|
1715
|
+
case componentTypes.reactiveList:
|
|
1716
|
+
component = RLConnected;
|
|
1717
|
+
break;
|
|
1718
|
+
|
|
1719
|
+
case componentTypes.dataSearch:
|
|
1720
|
+
component = DSConnected;
|
|
1721
|
+
break;
|
|
1722
|
+
|
|
1723
|
+
case componentTypes.searchBox:
|
|
1724
|
+
component = SBConnected;
|
|
1725
|
+
break;
|
|
1726
|
+
// list components
|
|
1727
|
+
|
|
1728
|
+
case componentTypes.singleList:
|
|
1729
|
+
component = ListConnected$4;
|
|
1730
|
+
break;
|
|
1731
|
+
|
|
1732
|
+
case componentTypes.multiList:
|
|
1733
|
+
component = ListConnected$3;
|
|
1734
|
+
break;
|
|
1735
|
+
|
|
1736
|
+
case componentTypes.singleDropdownList:
|
|
1737
|
+
component = ListConnected$2;
|
|
1738
|
+
break;
|
|
1739
|
+
|
|
1740
|
+
case componentTypes.multiDropdownList:
|
|
1741
|
+
component = ListConnected$1;
|
|
1742
|
+
break;
|
|
1743
|
+
// basic components
|
|
1744
|
+
|
|
1745
|
+
case componentTypes.toggleButton:
|
|
1746
|
+
component = ListConnected;
|
|
1747
|
+
break;
|
|
1748
|
+
// range components
|
|
1749
|
+
|
|
1750
|
+
case componentTypes.dynamicRangeSlider:
|
|
1751
|
+
component = RangeConnected$4;
|
|
1752
|
+
break;
|
|
1753
|
+
|
|
1754
|
+
case componentTypes.singleRange:
|
|
1755
|
+
component = RangeConnected$3;
|
|
1756
|
+
break;
|
|
1757
|
+
|
|
1758
|
+
case componentTypes.multiRange:
|
|
1759
|
+
component = RangeConnected$2;
|
|
1760
|
+
break;
|
|
1761
|
+
|
|
1762
|
+
case componentTypes.rangeSlider:
|
|
1763
|
+
component = RangeConnected$1;
|
|
1764
|
+
break;
|
|
1765
|
+
|
|
1766
|
+
case componentTypes.rangeInput:
|
|
1767
|
+
component = RangeConnected;
|
|
1768
|
+
break;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
return h(component, {
|
|
1772
|
+
attrs: this.$attrs,
|
|
1773
|
+
on: this.$listeners,
|
|
1774
|
+
scopedSlots: this.$scopedSlots,
|
|
1775
|
+
slots: this.$slots
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
|
|
1780
|
+
ReactiveComponent.install = function (Vue) {
|
|
1781
|
+
Vue.component(ReactiveComponent.name, RcConnected);
|
|
1782
|
+
}; // Add componentType for SSR
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
ReactiveComponent.componentType = componentTypes.reactiveComponent;
|
|
1401
1786
|
|
|
1402
|
-
export {
|
|
1787
|
+
export { ReactiveComponent as R, SearchBox as S };
|