@appbaseio/reactivesearch-vue 3.0.0-alpha.7 → 3.0.0-rc.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.
Files changed (61) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +3046 -1186
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{ComponentWrapper-2dc930e1.js → ComponentWrapper-9146d811.js} +1 -1
  6. package/dist/cjs/{DropDown-f48bea16.js → DropDown-b16418e9.js} +1 -1
  7. package/dist/cjs/DynamicRangeSlider.js +2 -2
  8. package/dist/cjs/{Flex-d5675ea6.js → Flex-ddde6d26.js} +3 -1
  9. package/dist/cjs/{ListItem-23af8974.js → ListItem-7a682970.js} +6 -1
  10. package/dist/cjs/MultiDropdownList.js +5 -5
  11. package/dist/cjs/MultiList.js +4 -4
  12. package/dist/cjs/MultiRange.js +3 -3
  13. package/dist/cjs/{PreferencesConsumer-2c69ac61.js → PreferencesConsumer-85dee673.js} +1 -1
  14. package/dist/cjs/RangeInput.js +4 -4
  15. package/dist/cjs/RangeSlider.js +3 -3
  16. package/dist/cjs/ReactiveBase.js +1 -1
  17. package/dist/cjs/ReactiveComponent.js +297 -43
  18. package/dist/cjs/ReactiveGoogleMap.js +3 -3
  19. package/dist/cjs/ReactiveList.js +5 -5
  20. package/dist/cjs/ResultList.js +1 -1
  21. package/dist/cjs/SelectedFilters.js +1 -1
  22. package/dist/cjs/SingleDropdownList.js +5 -5
  23. package/dist/cjs/SingleList.js +4 -4
  24. package/dist/cjs/SingleRange.js +3 -3
  25. package/dist/cjs/StateProvider.js +1 -1
  26. package/dist/cjs/ToggleButton.js +3 -3
  27. package/dist/cjs/{index-1481798c.js → index-779ed366.js} +2 -4
  28. package/dist/cjs/index.js +17 -14
  29. package/dist/cjs/{ReactiveComponent-8180c806.js → install-7cdf6798.js} +756 -244
  30. package/dist/cjs/install.js +28 -32
  31. package/dist/cjs/{utils-36b1b880.js → utils-c9bd5628.js} +9 -0
  32. package/dist/cjs/version.js +1 -1
  33. package/dist/es/{ComponentWrapper-3a215eed.js → ComponentWrapper-8a3c388d.js} +1 -1
  34. package/dist/es/{DropDown-7174661a.js → DropDown-fc1fef02.js} +1 -1
  35. package/dist/es/DynamicRangeSlider.js +2 -2
  36. package/dist/es/{Flex-a08e22d7.js → Flex-25792bc3.js} +3 -1
  37. package/dist/es/{ListItem-1cb1b4de.js → ListItem-e3c6acf4.js} +6 -1
  38. package/dist/es/MultiDropdownList.js +5 -5
  39. package/dist/es/MultiList.js +4 -4
  40. package/dist/es/MultiRange.js +3 -3
  41. package/dist/es/{PreferencesConsumer-24e88f3b.js → PreferencesConsumer-b058d14e.js} +1 -1
  42. package/dist/es/RangeInput.js +4 -4
  43. package/dist/es/RangeSlider.js +3 -3
  44. package/dist/es/ReactiveBase.js +1 -1
  45. package/dist/es/ReactiveComponent.js +298 -42
  46. package/dist/es/ReactiveGoogleMap.js +3 -3
  47. package/dist/es/ReactiveList.js +5 -5
  48. package/dist/es/ResultList.js +1 -1
  49. package/dist/es/SelectedFilters.js +1 -1
  50. package/dist/es/SingleDropdownList.js +5 -5
  51. package/dist/es/SingleList.js +4 -4
  52. package/dist/es/SingleRange.js +3 -3
  53. package/dist/es/StateProvider.js +1 -1
  54. package/dist/es/ToggleButton.js +3 -3
  55. package/dist/es/{index-4520a598.js → index-882489e1.js} +2 -4
  56. package/dist/es/index.js +11 -10
  57. package/dist/es/{ReactiveComponent-f78ff2cd.js → install-0c7962bc.js} +765 -255
  58. package/dist/es/install.js +26 -34
  59. package/dist/es/{utils-9e5a16a1.js → utils-d7dd4f4e.js} +9 -1
  60. package/dist/es/version.js +1 -1
  61. package/package.json +2 -2
@@ -14,26 +14,38 @@ var css = require('@emotion/css');
14
14
  var Button = require('./Button-d4da7470.js');
15
15
  var vueTypes = require('./vueTypes-1bf00978.js');
16
16
  var ReactiveList = require('./ReactiveList.js');
17
- var index = require('./index-1481798c.js');
18
- var ComponentWrapper = require('./ComponentWrapper-2dc930e1.js');
19
- var PreferencesConsumer = require('./PreferencesConsumer-2c69ac61.js');
17
+ var transform = require('@appbaseio/reactivecore/lib/utils/transform');
18
+ var index = require('./index-779ed366.js');
19
+ var ComponentWrapper = require('./ComponentWrapper-9146d811.js');
20
+ var PreferencesConsumer = require('./PreferencesConsumer-85dee673.js');
20
21
  var Title = require('./Title-8802a218.js');
21
- var Flex = require('./Flex-d5675ea6.js');
22
+ var ListItem = require('./ListItem-7a682970.js');
23
+ var Flex = require('./Flex-ddde6d26.js');
24
+ var ReactiveBase = require('./ReactiveBase.js');
22
25
  var hotkeys = _interopDefault(require('hotkeys-js'));
23
- var DropDown = require('./DropDown-f48bea16.js');
26
+ var DropDown = require('./DropDown-b16418e9.js');
24
27
  var Input = require('./Input-497be42a.js');
25
28
  var Container = require('./Container-29f049b2.js');
26
29
  var Highlight = _interopDefault(require('vue-highlight-words'));
30
+ var suggestions = require('@appbaseio/reactivecore/lib/utils/suggestions');
31
+ var FormControlList = require('./FormControlList-fadd792f.js');
32
+ var utils = require('./utils-c9bd5628.js');
27
33
  var SingleList = require('./SingleList.js');
28
34
  var MultiList = require('./MultiList.js');
35
+ var types = _interopDefault(require('@appbaseio/reactivecore/lib/utils/types'));
29
36
  var SingleDropdownList = require('./SingleDropdownList.js');
30
37
  var MultiDropdownList = require('./MultiDropdownList.js');
31
38
  var ToggleButton = require('./ToggleButton.js');
39
+ var ReactiveComponent = require('./ReactiveComponent.js');
32
40
  var DynamicRangeSlider = require('./DynamicRangeSlider.js');
33
41
  var SingleRange = require('./SingleRange.js');
34
42
  var MultiRange = require('./MultiRange.js');
35
43
  var RangeSlider = require('./RangeSlider.js');
36
44
  var RangeInput = require('./RangeInput.js');
45
+ var SelectedFilters = require('./SelectedFilters.js');
46
+ var ResultCard = require('./ResultCard.js');
47
+ var ResultList = require('./ResultList.js');
48
+ var StateProvider = require('./StateProvider.js');
37
49
 
38
50
  var _templateObject;
39
51
  var InputGroup = vueEmotion.styled('div')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n display: flex;\n align-items: stretch;\n width: 100%;\n"])));
@@ -1854,334 +1866,834 @@ SBConnected.install = function (Vue) {
1854
1866
  // Add componentType for SSR
1855
1867
  SBConnected.componentType = constants.componentTypes.searchBox;
1856
1868
 
1857
- var _excluded = ["options"];
1858
- var updateQuery$1 = reactivecore.Actions.updateQuery,
1859
- setQueryOptions = reactivecore.Actions.setQueryOptions,
1860
- setCustomQuery$1 = reactivecore.Actions.setCustomQuery,
1861
- setDefaultQuery$1 = reactivecore.Actions.setDefaultQuery;
1862
- var parseHits = reactivecore.helper.parseHits,
1863
- isEqual$1 = reactivecore.helper.isEqual,
1864
- getCompositeAggsQuery$1 = reactivecore.helper.getCompositeAggsQuery,
1865
- getResultStats$1 = reactivecore.helper.getResultStats,
1866
- extractQueryFromCustomQuery = reactivecore.helper.extractQueryFromCustomQuery,
1867
- getOptionsForCustomQuery = reactivecore.helper.getOptionsForCustomQuery;
1868
- var ReactiveComponent = {
1869
- name: 'ReactiveComponent',
1869
+ var _templateObject$8, _templateObject2$1;
1870
+ var HierarchicalMenuList = vueEmotion.styled('ul')(_templateObject$8 || (_templateObject$8 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tmax-height: 0;\n\toverflow: hidden;\n\n\t&.--open {\n\t\tmax-height: 100%;\n\t}\n"])));
1871
+ var HierarchicalMenuListItem = vueEmotion.styled('li')(_templateObject2$1 || (_templateObject2$1 = _rollupPluginBabelHelpers._taggedTemplateLiteralLoose(["\n\tfont-weight: 400;\n\tline-height: 1.5;\n\tbox-sizing: border-box;\n\n\ta {\n\t\tcolor: #424242;\n\t\ttext-decoration: none;\n\t\tgap: 5px;\n\t\t.--leaf-icon,\n\t\t.--folder-icon {\n\t\t\tline-height: 15px;\n\t\t\tsvg {\n\t\t\t\theight: 15px;\n\t\t\t}\n\t\t}\n\n\t\tinput {\n\t\t\tmargin: 0;\n\t\t\tcursor: pointer;\n\t\t}\n\t}\n\n\t.--switcher-icon {\n\t\ttransition: all 0.2s ease-in;\n\t\tmargin-right: 2px;\n\t}\n\t.--list-child {\n\t\tpadding-left: 1rem;\n\t\tposition: relative;\n\t\t&:before {\n\t\t\theight: 100%;\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\tborder-left: 1px solid #787878;\n\t\t\twidth: 0;\n\t\t\tleft: 19px;\n\t\t\t", ";\n\t\t}\n\n\t\t&.--show-switcher-icon {\n\t\t\tpadding-left: 36px;\n\t\t}\n\t}\n\t.--list-item-label {\n\t\tline-height: 100%;\n\t}\n\t.--list-item-count {\n\t\tmargin-left: 10px;\n\t\tpadding: 0.1rem 0.4rem;\n\t\tfont-size: 0.8rem;\n\t\tcolor: #424242;\n\t\tbackground-color: #dee1e6;\n\t\tborder-radius: 8px;\n\t}\n\t&.-selected-item {\n\t\tfont-weight: 700 !important;\n\t}\n\t&.-expanded-item {\n\t\t& > a {\n\t\t\t& div > .--switcher-icon {\n\t\t\t\ttransform: rotate(90deg);\n\t\t\t}\n\t\t}\n\t}\n\t.--list-item-label-count-wrapper {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\t&:hover {\n\t\t\t.--list-item-count,\n\t\t\t.--list-item-label {\n\t\t\t\tfont-weight: 700;\n\t\t\t}\n\t\t}\n\t}\n"])), function (props) {
1872
+ return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
1873
+ });
1874
+
1875
+ var HierarchicalMenuListItemComponent = {
1876
+ name: 'HierarchicalMenuListItemComponent',
1877
+ data: function data() {
1878
+ return {
1879
+ isExpanded: false,
1880
+ newParentPath: ''
1881
+ };
1882
+ },
1883
+ created: function created() {
1884
+ var listItemLabel = this.listItem.key;
1885
+ var newParentPath = listItemLabel;
1886
+ if (this.parentPath) {
1887
+ newParentPath = "" + this.parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + listItemLabel;
1888
+ }
1889
+ this.newParentPath = newParentPath;
1890
+ this.isExpanded = !!helper.recLookup(this.selectedValues, newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
1891
+ },
1892
+ watch: {
1893
+ listItem: function listItem(newVal) {
1894
+ if (newVal.initiallyExpanded) {
1895
+ this.isExpanded = newVal.initiallyExpanded;
1896
+ }
1897
+ },
1898
+ selectedValues: function selectedValues(newVal) {
1899
+ this.isExpanded = !!helper.recLookup(newVal, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
1900
+ }
1901
+ },
1870
1902
  props: {
1871
- componentId: vueTypes.types.stringRequired,
1872
- aggregationField: vueTypes.types.string,
1873
- aggregationSize: VueTypes.number,
1874
- size: VueTypes.number,
1875
- defaultQuery: vueTypes.types.func,
1903
+ parentPath: types.string,
1904
+ selectedValues: types.rawData,
1905
+ mode: types.string,
1906
+ searchTerm: types.string,
1907
+ listItem: types.rawData,
1908
+ showLine: types.bool,
1909
+ renderItem: types.func,
1910
+ handleListItemClick: types.func,
1911
+ renderSwitcherIcon: types.func,
1912
+ showCheckbox: VueTypes.bool,
1913
+ innerClass: types.style,
1914
+ showRadio: VueTypes.bool,
1915
+ renderIcon: types.func,
1916
+ showCount: VueTypes.bool,
1917
+ showSwitcherIcon: types.bool,
1918
+ switcherIcon: types.children
1919
+ },
1920
+ render: function render() {
1921
+ var _this = this;
1922
+ var _this$$props = this.$props,
1923
+ selectedValues = _this$$props.selectedValues,
1924
+ mode = _this$$props.mode,
1925
+ searchTerm = _this$$props.searchTerm,
1926
+ listItem = _this$$props.listItem,
1927
+ parentPath = _this$$props.parentPath,
1928
+ showLine = _this$$props.showLine,
1929
+ renderItem = _this$$props.renderItem,
1930
+ handleListItemClick = _this$$props.handleListItemClick,
1931
+ showCheckbox = _this$$props.showCheckbox,
1932
+ innerClass = _this$$props.innerClass,
1933
+ showRadio = _this$$props.showRadio,
1934
+ renderIcon = _this$$props.renderIcon,
1935
+ showCount = _this$$props.showCount,
1936
+ showSwitcherIcon = _this$$props.showSwitcherIcon;
1937
+ if (!(listItem instanceof Object) || Object.keys(listItem).length === 0) {
1938
+ return null;
1939
+ }
1940
+ var listItemLabel = listItem.key;
1941
+ var listItemCount = listItem.count;
1942
+ var isLeafNode = !(Array.isArray(listItem.list) && listItem.list.length > 0);
1943
+ var renderSwitcherIcon = function renderSwitcherIcon(isExpandedProp) {
1944
+ if (showSwitcherIcon === false) {
1945
+ return null;
1946
+ }
1947
+ var switcherIcon = _this.$props.switcherIcon;
1948
+ if (switcherIcon) return switcherIcon(isExpandedProp);
1949
+ return (
1950
+ /* eslint-disable jsx-a11y/click-events-have-key-events
1951
+ , jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-tabindex */
1952
+ vue.createVNode("span", {
1953
+ "tabIndex": "0",
1954
+ "onClick": function onClick(e) {
1955
+ e.stopPropagation();
1956
+ _this.isExpanded = !_this.isExpanded;
1957
+ },
1958
+ "class": "--switcher-icon"
1959
+ }, [vue.createTextVNode("\u27A4")])
1960
+ );
1961
+ };
1962
+ var isSelected = false;
1963
+ if (mode === 'single') {
1964
+ if (helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR) === true) {
1965
+ isSelected = true;
1966
+ }
1967
+ } else {
1968
+ isSelected = !!helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
1969
+ }
1970
+ return vue.createVNode(HierarchicalMenuListItem, {
1971
+ "class": (isSelected ? '-selected-item' : '') + " " + (this.isExpanded ? '-expanded-item' : ''),
1972
+ "key": this.newParentPath,
1973
+ "showLine": showLine
1974
+ }, {
1975
+ "default": function _default() {
1976
+ return [vue.createVNode(ListItem.ListItem, {
1977
+ "isTreeListItem": true,
1978
+ "onClick": function onClick() {
1979
+ handleListItemClick(listItemLabel, parentPath);
1980
+ },
1981
+ "style": {
1982
+ textDecoration: 'none'
1983
+ }
1984
+ }, {
1985
+ "default": function _default() {
1986
+ return [renderItem ? renderItem(listItemLabel, listItemCount, isSelected) : vue.createVNode(Flex.Flex, {
1987
+ "alignItems": "center",
1988
+ "gap": "5px"
1989
+ }, {
1990
+ "default": function _default() {
1991
+ return [!isLeafNode && renderSwitcherIcon(isSelected), mode === 'multiple' && showCheckbox && vue.createVNode(Flex.Flex, {
1992
+ "alignItems": "center",
1993
+ "gap": "5px"
1994
+ }, {
1995
+ "default": function _default() {
1996
+ return [vue.createVNode(FormControlList.Checkbox, {
1997
+ "type": "checkbox",
1998
+ "class": helper.getClassName(innerClass, 'checkbox') || null,
1999
+ "checked": isSelected,
2000
+ "id": listItemLabel + "-checkbox-" + _this.newParentPath,
2001
+ "name": listItemLabel + "-checkbox-" + _this.newParentPath,
2002
+ "show": true,
2003
+ "readOnly": true
2004
+ }, null), vue.createVNode("label", {
2005
+ "style": {
2006
+ width: '26px',
2007
+ marginTop: 0,
2008
+ marginBottom: 0,
2009
+ marginRight: '-9px',
2010
+ left: '-3px'
2011
+ },
2012
+ "htmlFor": listItemLabel + "-checkbox-" + _this.newParentPath,
2013
+ "onClick": function onClick(e) {
2014
+ e.stopPropagation();
2015
+ }
2016
+ }, null)];
2017
+ }
2018
+ }), mode === 'single' && showRadio && vue.createVNode(Flex.Flex, {
2019
+ "alignItems": "center",
2020
+ "gap": "5px"
2021
+ }, {
2022
+ "default": function _default() {
2023
+ return [vue.createVNode(FormControlList.Radio, {
2024
+ "checked": isSelected,
2025
+ "class": helper.getClassName(innerClass, 'radio') || null,
2026
+ "id": listItemLabel + "-radio-" + _this.newParentPath,
2027
+ "name": listItemLabel + "-radio-" + _this.newParentPath,
2028
+ "show": true,
2029
+ "readOnly": true,
2030
+ "type": "radio"
2031
+ }, null), vue.createVNode("label", {
2032
+ "style": {
2033
+ width: '26px',
2034
+ marginTop: 0,
2035
+ marginBottom: 0,
2036
+ marginRight: '-9px',
2037
+ left: '-3px'
2038
+ },
2039
+ "htmlFor": listItemLabel + "-radio-" + _this.newParentPath,
2040
+ "onClick": function onClick(e) {
2041
+ e.stopPropagation();
2042
+ }
2043
+ }, null)];
2044
+ }
2045
+ }), ' ', renderIcon(isLeafNode), vue.createVNode("div", {
2046
+ "class": "--list-item-label-count-wrapper"
2047
+ }, [vue.createVNode("span", {
2048
+ "class": "--list-item-label " + (helper.getClassName(innerClass, 'label') || '')
2049
+ }, [listItemLabel]), showCount && vue.createVNode("span", {
2050
+ "class": "--list-item-count " + (helper.getClassName(innerClass, 'count') || '')
2051
+ }, [listItemCount])])];
2052
+ }
2053
+ })];
2054
+ }
2055
+ }), isLeafNode === false && vue.createVNode("div", {
2056
+ "class": "--list-child " + (showSwitcherIcon ? ' --show-switcher-icon' : '')
2057
+ }, [vue.createVNode(HierarchicalMenuComponent, {
2058
+ "key": _this.newParentPath + "-" + listItemLabel + "-" + listItemCount,
2059
+ "listArray": listItem.list,
2060
+ "parentPath": _this.newParentPath,
2061
+ "isExpanded": _this.isExpanded,
2062
+ "listItemProps": {
2063
+ mode: mode,
2064
+ selectedValues: selectedValues,
2065
+ searchTerm: searchTerm,
2066
+ showLine: showLine,
2067
+ renderItem: renderItem,
2068
+ handleListItemClick: handleListItemClick,
2069
+ renderSwitcherIcon: renderSwitcherIcon,
2070
+ showCheckbox: showCheckbox,
2071
+ innerClass: innerClass,
2072
+ showRadio: showRadio,
2073
+ renderIcon: renderIcon,
2074
+ showCount: showCount,
2075
+ showSwitcherIcon: showSwitcherIcon,
2076
+ switcherIcon: _this.$props.switcherIcon
2077
+ }
2078
+ }, null)])];
2079
+ }
2080
+ });
2081
+ }
2082
+ };
2083
+
2084
+ function _isSlot$1(s) {
2085
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2086
+ }
2087
+ var HierarchicalMenuComponent = {
2088
+ name: 'HierarchicalMenuComponent',
2089
+ props: {
2090
+ listArray: VueTypes.arrayOf(VueTypes.object),
2091
+ // array of objects
2092
+ parentPath: VueTypes.string.def(''),
2093
+ isExpanded: VueTypes.bool.def(false),
2094
+ listItemProps: types.rawData
2095
+ },
2096
+ render: function render() {
2097
+ var _slot;
2098
+ var _this$$props = this.$props,
2099
+ listArray = _this$$props.listArray,
2100
+ isExpanded = _this$$props.isExpanded,
2101
+ parentPath = _this$$props.parentPath,
2102
+ listItemProps = _this$$props.listItemProps;
2103
+ if (!Array.isArray(listArray) || listArray.length === 0) {
2104
+ return null;
2105
+ }
2106
+ return vue.createVNode(HierarchicalMenuList, {
2107
+ "class": "" + (isExpanded ? '--open' : ''),
2108
+ "isSelected": isExpanded
2109
+ }, _isSlot$1(_slot = listArray.map(function (listItem) {
2110
+ return vue.createVNode(HierarchicalMenuListItemComponent, vue.mergeProps({
2111
+ "key": parentPath + "__" + JSON.stringify(listItem),
2112
+ "parentPath": parentPath,
2113
+ "listItem": listItem
2114
+ }, listItemProps), null);
2115
+ })) ? _slot : {
2116
+ "default": function _default() {
2117
+ return [_slot];
2118
+ }
2119
+ });
2120
+ }
2121
+ };
2122
+
2123
+ function _isSlot$2(s) {
2124
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2125
+ }
2126
+ var updateQueryAction = reactivecore.Actions.updateQuery,
2127
+ setQueryOptions = reactivecore.Actions.setQueryOptions;
2128
+ var transformValueIntoLocalState = function transformValueIntoLocalState(valueArray) {
2129
+ var valueToSet = {};
2130
+ if (valueArray.length) {
2131
+ var newSelectedValues = {};
2132
+ valueArray.forEach(function (valueItem) {
2133
+ helper.setDeep(newSelectedValues, valueItem.split(' > '), !helper.recLookup(newSelectedValues, valueItem.split(' > '), constants.TREELIST_VALUES_PATH_SEPARATOR), true);
2134
+ });
2135
+ valueToSet = newSelectedValues;
2136
+ }
2137
+ return valueToSet;
2138
+ };
2139
+ var TreeList = {
2140
+ name: 'TreeList',
2141
+ props: {
2142
+ selectedValue: vueTypes.types.selectedValue,
2143
+ error: vueTypes.types.title,
2144
+ rawData: vueTypes.types.rawData,
2145
+ aggregationData: vueTypes.types.rawData,
2146
+ themePreset: vueTypes.types.themePreset,
2147
+ updateQueryAction: vueTypes.types.funcRequired,
2148
+ setQueryOptions: vueTypes.types.funcRequired,
2149
+ // component props
2150
+ componentId: vueTypes.types.string.isRequired,
2151
+ className: vueTypes.types.string,
2152
+ style: vueTypes.types.style,
2153
+ showRadio: VueTypes.bool.def(false),
2154
+ showCheckbox: vueTypes.types.bool.def(false),
2155
+ mode: VueTypes.oneOf(['single', 'multiple']).def('multiple'),
2156
+ showCount: VueTypes.bool.def(false),
2157
+ showSearch: VueTypes.bool.def(false),
2158
+ showIcon: VueTypes.bool.def(false),
2159
+ icon: vueTypes.types.children,
2160
+ showLeafIcon: VueTypes.bool.def(false),
2161
+ leafIcon: vueTypes.types.children,
2162
+ showLine: VueTypes.bool.def(false),
2163
+ switcherIcon: vueTypes.types.func,
2164
+ render: vueTypes.types.func,
2165
+ renderItem: vueTypes.types.func,
2166
+ innerClass: vueTypes.types.style,
2167
+ placeholder: vueTypes.types.string,
2168
+ title: vueTypes.types.title,
2169
+ isLoading: vueTypes.types.bool,
2170
+ dataField: vueTypes.types.stringArray.isRequired,
2171
+ onQueryChange: vueTypes.types.func,
2172
+ defaultValue: vueTypes.types.stringArray,
2173
+ value: vueTypes.types.stringArray,
1876
2174
  customQuery: vueTypes.types.func,
2175
+ defaultQuery: vueTypes.types.func,
2176
+ enableAppbase: vueTypes.types.bool,
2177
+ index: vueTypes.types.string,
2178
+ showFilter: vueTypes.types.bool,
2179
+ URLParams: vueTypes.types.bool,
1877
2180
  filterLabel: vueTypes.types.string,
2181
+ onChange: vueTypes.types.func,
2182
+ onValueChange: vueTypes.types.func,
2183
+ beforeValueChange: vueTypes.types.func,
2184
+ sortBy: vueTypes.types.sortByWithCount.def('count'),
2185
+ onError: vueTypes.types.func,
2186
+ showSwitcherIcon: vueTypes.types.bool.def(true),
2187
+ renderError: vueTypes.types.title,
2188
+ renderNoResults: vueTypes.types.func,
2189
+ loader: vueTypes.types.title,
2190
+ aggergationSize: vueTypes.types.number,
2191
+ endpoint: vueTypes.types.endpoint,
2192
+ queryFormat: vueTypes.types.queryFormatSearch.def('or'),
2193
+ size: vueTypes.types.number.def(100),
2194
+ nestedField: vueTypes.types.string,
1878
2195
  react: vueTypes.types.react,
1879
- showFilter: VueTypes.bool.def(true),
1880
- URLParams: VueTypes.bool.def(false),
1881
- distinctField: vueTypes.types.string,
1882
- distinctFieldConfig: vueTypes.types.props,
1883
- index: VueTypes.string,
1884
- endpoint: vueTypes.types.endpointConfig
2196
+ transformData: vueTypes.types.func,
2197
+ selectAllLabel: vueTypes.types.string,
2198
+ showMissing: VueTypes.bool.def(false),
2199
+ missingLabel: VueTypes.string.def('N/A')
2200
+ },
2201
+ data: function data() {
2202
+ var props = this.$props;
2203
+ this.__state = {
2204
+ selectedValues: {},
2205
+ searchTerm: '',
2206
+ aggregationData: []
2207
+ };
2208
+ this.internalComponent = props.componentId + "__internal";
2209
+ return this.__state;
1885
2210
  },
1886
2211
  created: function created() {
1887
- var _this = this;
1888
2212
  var props = this.$props;
1889
- this.internalComponent = null;
1890
- this.$defaultQuery = null;
1891
- // Set custom query in store
1892
- index.updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
1893
- var customQuery = props.customQuery,
1894
- componentId = props.componentId,
1895
- filterLabel = props.filterLabel,
1896
- showFilter = props.showFilter,
1897
- URLParams = props.URLParams;
1898
- if (customQuery) {
1899
- var calcCustomQuery = customQuery(this.selectedValue, props);
1900
- var query = extractQueryFromCustomQuery(calcCustomQuery);
1901
- var customQueryOptions = calcCustomQuery ? getOptionsForCustomQuery(calcCustomQuery) : null;
1902
- if (customQueryOptions) {
1903
- this.setQueryOptions(componentId, _rollupPluginBabelHelpers._extends({}, customQueryOptions, this.getAggsQuery()), false);
1904
- } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
1905
- this.updateQuery({
1906
- componentId: componentId,
1907
- query: query,
1908
- value: this.selectedValue || null,
1909
- label: filterLabel,
1910
- showFilter: showFilter,
1911
- URLParams: URLParams
1912
- });
2213
+ var componentId = props.componentId;
2214
+ var defaultValue = this.defaultValue || this.value;
2215
+ var currentValueArray = this.selectedValue || defaultValue || [];
2216
+ // update local state for selected values
2217
+ if (currentValueArray.length) {
2218
+ var newSelectedValues = transformValueIntoLocalState(currentValueArray);
2219
+ this.setValue(newSelectedValues, true);
1913
2220
  }
1914
- this.setQuery = function (_ref) {
1915
- var options = _ref.options,
1916
- obj = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(_ref, _excluded);
1917
- var queryToBeSet = obj.query;
1918
2221
 
1919
- // when enableAppbase is true, Backend throws error because of repeated query in request body
1920
- if (queryToBeSet && queryToBeSet.query) {
1921
- queryToBeSet = queryToBeSet.query;
1922
- }
1923
- var customQueryCalc = _rollupPluginBabelHelpers._extends({}, options, {
1924
- query: queryToBeSet
1925
- });
1926
- var rsAPIQuery = customQueryCalc;
1927
- // handle stored queries
1928
- if (queryToBeSet && queryToBeSet.id) {
1929
- rsAPIQuery = queryToBeSet;
1930
- }
1931
- // Update customQuery field for RS API
1932
- _this.setCustomQuery(props.componentId, rsAPIQuery);
1933
- if (options) {
1934
- _this.setQueryOptions(props.componentId, _rollupPluginBabelHelpers._extends({}, _this.getAggsQuery(), options), false);
1935
- }
1936
- _this.updateQuery(_rollupPluginBabelHelpers._extends({}, obj, {
1937
- query: customQueryCalc.query,
1938
- componentId: props.componentId,
1939
- label: props.filterLabel,
1940
- showFilter: props.showFilter,
1941
- URLParams: props.URLParams
1942
- }));
1943
- };
1944
- if (props.defaultQuery) {
1945
- this.internalComponent = props.componentId + "__internal";
1946
- }
1947
- if (this.internalComponent && this.$props.defaultQuery) {
1948
- index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
1949
- this.$defaultQuery = this.$props.defaultQuery(this.selectedValue, this.$props);
1950
- var _query = extractQueryFromCustomQuery(this.$defaultQuery);
1951
- var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
1952
- if (queryOptions) {
1953
- this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
1954
- } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
1955
- this.updateQuery({
1956
- componentId: this.internalComponent,
1957
- query: _query
1958
- });
2222
+ // Set custom and default queries in store
2223
+ helper.updateCustomQuery(componentId, props, currentValueArray);
2224
+ helper.updateDefaultQuery(componentId, props, currentValueArray);
2225
+ this.updateQueryOptions();
2226
+ },
2227
+ mounted: function mounted() {
2228
+ var _this$$props = this.$props,
2229
+ enableAppbase = _this$$props.enableAppbase,
2230
+ index = _this$$props.index;
2231
+ if (!enableAppbase && index) {
2232
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
1959
2233
  }
1960
2234
  },
1961
2235
  watch: {
1962
- hits: function hits(newVal, oldVal) {
1963
- if (!isEqual$1(newVal, oldVal)) {
1964
- this.$emit('data', this.getData());
1965
- }
2236
+ defaultQuery: function defaultQuery() {
2237
+ this.updateDefaultQuery();
2238
+ this.updateQuery([]);
1966
2239
  },
1967
- rawData: function rawData(newVal, oldVal) {
1968
- if (!isEqual$1(newVal, oldVal)) {
1969
- this.$emit('data', this.getData());
2240
+ customQuery: function customQuery() {
2241
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
2242
+ this.updateQuery(valueArray);
2243
+ },
2244
+ sortBy: function sortBy() {
2245
+ this.updateQueryOptions();
2246
+ },
2247
+ dataField: function dataField() {
2248
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
2249
+ this.updateQueryOptions();
2250
+ this.updateQuery(valueArray);
2251
+ },
2252
+ value: function value(newVal, oldVal) {
2253
+ if (!helper.isEqual(newVal, oldVal)) {
2254
+ this.setValue(newVal);
1970
2255
  }
1971
2256
  },
1972
- aggregations: function aggregations(newVal, oldVal) {
1973
- if (!isEqual$1(newVal, oldVal)) {
1974
- this.$emit('data', this.getData());
2257
+ selectedValue: function selectedValue(newVal) {
2258
+ if (!helper.isEqual(helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues), newVal)) {
2259
+ var _this$$props2 = this.$props,
2260
+ value = _this$$props2.value,
2261
+ onChange = _this$$props2.onChange;
2262
+ var valueToSet = [];
2263
+ if (Array.isArray(newVal) && newVal.length) {
2264
+ valueToSet = newVal;
2265
+ }
2266
+ if (value === undefined) {
2267
+ this.setValue(valueToSet);
2268
+ } else if (onChange && !helper.isEqual(value, valueToSet)) {
2269
+ onChange(valueToSet);
2270
+ }
1975
2271
  }
1976
2272
  },
1977
2273
  aggregationData: function aggregationData(newVal, oldVal) {
1978
- if (!isEqual$1(newVal, oldVal)) {
1979
- this.$emit('data', this.getData());
2274
+ if (newVal && !helper.isEqual(newVal, oldVal)) {
2275
+ this.$data.aggregationData = newVal;
1980
2276
  }
2277
+ }
2278
+ },
2279
+ computed: {
2280
+ hasCustomRenderer: function hasCustomRenderer() {
2281
+ return index.hasCustomRenderer(this);
2282
+ }
2283
+ },
2284
+ methods: {
2285
+ renderIcon: function renderIcon(isLeafNode) {
2286
+ var _this$$props3 = this.$props,
2287
+ showIcon = _this$$props3.showIcon,
2288
+ showLeafIcon = _this$$props3.showLeafIcon,
2289
+ icon = _this$$props3.icon;
2290
+ if (isLeafNode) {
2291
+ if (!showLeafIcon) return null;
2292
+ var _ref = this.$slots || this.$props,
2293
+ leafIcon = _ref.leafIcon;
2294
+ if (leafIcon) return leafIcon();
2295
+ return vue.createVNode("span", {
2296
+ "role": "img",
2297
+ "aria-label": "file",
2298
+ "class": "--leaf-icon"
2299
+ }, [vue.createVNode("svg", {
2300
+ "viewBox": "64 64 896 896",
2301
+ "focusable": "false",
2302
+ "data-icon": "file",
2303
+ "width": "1em",
2304
+ "height": "1em",
2305
+ "fill": "currentColor",
2306
+ "aria-hidden": "true"
2307
+ }, [vue.createVNode("path", {
2308
+ "d": "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"
2309
+ }, null)])]);
2310
+ }
2311
+ if (!showIcon) return null;
2312
+ if (icon) {
2313
+ return icon;
2314
+ }
2315
+ if (this.$slots.icon) {
2316
+ return this.$slots.icon();
2317
+ }
2318
+ return vue.createVNode("span", {
2319
+ "role": "img",
2320
+ "aria-label": "folder-open",
2321
+ "class": "--folder-icon"
2322
+ }, [vue.createVNode("svg", {
2323
+ "viewBox": "64 64 896 896",
2324
+ "focusable": "false",
2325
+ "data-icon": "folder-open",
2326
+ "width": "1em",
2327
+ "height": "1em",
2328
+ "fill": "currentColor",
2329
+ "aria-hidden": "true"
2330
+ }, [vue.createVNode("path", {
2331
+ "d": "M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"
2332
+ }, null)])]);
1981
2333
  },
1982
- promotedResults: function promotedResults(newVal, oldVal) {
1983
- if (!isEqual$1(newVal, oldVal)) {
1984
- this.$emit('data', this.getData());
1985
- }
2334
+ getTransformedData: function getTransformedData() {
2335
+ var _this$$props4 = this.$props,
2336
+ dataField = _this$$props4.dataField,
2337
+ showSearch = _this$$props4.showSearch;
2338
+ var transformedData = helper.transformRawTreeListData(this.$data.aggregationData, dataField);
2339
+ var filteredData = [];
2340
+ if (showSearch && this.searchTerm) {
2341
+ filteredData = this.filterDataBasedOnSearchTerm(transformedData, '');
2342
+ }
2343
+ return filteredData.length ? filteredData : transformedData;
1986
2344
  },
1987
- hidden: function hidden(newVal, oldVal) {
1988
- if (!isEqual$1(newVal, oldVal)) {
1989
- this.$emit('data', this.getData());
1990
- }
2345
+ handleInputChange: function handleInputChange(e) {
2346
+ var value = e.target.value;
2347
+ this.searchTerm = value;
1991
2348
  },
1992
- total: function total(newVal, oldVal) {
1993
- if (!isEqual$1(newVal, oldVal)) {
1994
- this.$emit('data', this.getData());
2349
+ renderSearch: function renderSearch() {
2350
+ var _this$$props5 = this.$props,
2351
+ showSearch = _this$$props5.showSearch,
2352
+ innerClass = _this$$props5.innerClass,
2353
+ placeholder = _this$$props5.placeholder,
2354
+ componentId = _this$$props5.componentId,
2355
+ themePreset = _this$$props5.themePreset;
2356
+ if (showSearch) {
2357
+ return vue.createVNode(Input.Input, {
2358
+ "class": helper.getClassName(innerClass, 'input') || null,
2359
+ "onInput": this.handleInputChange,
2360
+ "value": this.searchTerm,
2361
+ "placeholder": placeholder || 'Search',
2362
+ "style": {
2363
+ margin: '0 0 8px'
2364
+ },
2365
+ "aria-label": componentId + "-search",
2366
+ "themePreset": themePreset
2367
+ }, null);
1995
2368
  }
2369
+ return null;
1996
2370
  },
1997
- time: function time(newVal, oldVal) {
1998
- if (!isEqual$1(newVal, oldVal)) {
1999
- this.$emit('data', this.getData());
2371
+ handleListItemClick: function handleListItemClick(key, parentPath) {
2372
+ var path = key;
2373
+ if (parentPath) {
2374
+ path = "" + parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + key;
2375
+ }
2376
+ var newSelectedValues = _rollupPluginBabelHelpers._extends({}, this.selectedValues);
2377
+ if (this.$props.mode === 'single') {
2378
+ newSelectedValues = {};
2379
+ helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), true, true);
2380
+ } else {
2381
+ var newValue = !helper.recLookup(newSelectedValues, path, constants.TREELIST_VALUES_PATH_SEPARATOR);
2382
+ helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), newValue, true);
2383
+ }
2384
+ newSelectedValues = utils.sanitizeObject(_rollupPluginBabelHelpers._extends({}, newSelectedValues));
2385
+ if (this.$props.value === undefined) {
2386
+ this.setValue(newSelectedValues);
2387
+ } else if (this.$props.onChange) {
2388
+ var valueToSet = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(newSelectedValues);
2389
+ this.$props.onChange(valueToSet);
2000
2390
  }
2001
2391
  },
2002
- defaultQuery: function defaultQuery(newVal, oldVal) {
2003
- if (newVal && !index.isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
2004
- this.$defaultQuery = newVal(this.selectedValue, this.$props);
2005
- var query = extractQueryFromCustomQuery(this.$defaultQuery);
2006
- var queryOptions = getOptionsForCustomQuery(this.$defaultQuery);
2007
- if (queryOptions) {
2008
- this.setQueryOptions(this.internalComponent, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
2009
- } else this.setQueryOptions(this.internalComponent, this.getAggsQuery(), false);
2010
- // Update default query for RS API
2011
- index.updateDefaultQuery(this.componentId, this.setDefaultQuery, this.$props, this.selectedValue);
2012
- this.updateQuery({
2013
- componentId: this.internalComponent,
2014
- query: query
2015
- });
2392
+ filterDataBasedOnSearchTerm: function filterDataBasedOnSearchTerm(listArray, parentPath) {
2393
+ var _this = this;
2394
+ if (!(listArray && Array.isArray(listArray) && listArray.length)) {
2395
+ return null;
2016
2396
  }
2397
+ var result = [];
2398
+ listArray.forEach(function (ele) {
2399
+ var isLeafItem = !ele.list;
2400
+ var newParentPath = ele.key;
2401
+ if (parentPath) {
2402
+ newParentPath = parentPath + "." + ele.key;
2403
+ }
2404
+ var keyHasSearchTerm = suggestions.replaceDiacritics(ele.key).toLowerCase().includes(suggestions.replaceDiacritics(_this.$data.searchTerm).toLowerCase()) || helper.recLookup(_this.$data.selectedValues, newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
2405
+ if (isLeafItem && keyHasSearchTerm) {
2406
+ result.push(_rollupPluginBabelHelpers._extends({}, ele, {
2407
+ initiallyExpanded: keyHasSearchTerm
2408
+ }));
2409
+ } else if (!isLeafItem) {
2410
+ var filteredChildrenItems = _this.filterDataBasedOnSearchTerm(ele.list, newParentPath);
2411
+ if (keyHasSearchTerm || !!filteredChildrenItems.length) {
2412
+ result.push(_rollupPluginBabelHelpers._extends({}, ele, {
2413
+ initiallyExpanded: keyHasSearchTerm || !!filteredChildrenItems.length,
2414
+ list: filteredChildrenItems
2415
+ }));
2416
+ }
2417
+ }
2418
+ });
2419
+ return result;
2017
2420
  },
2018
- customQuery: function customQuery(newVal, oldVal) {
2019
- if (newVal && !index.isQueryIdentical(newVal, oldVal, this.selectedValue, this.$props)) {
2020
- var componentId = this.$props.componentId;
2021
- this.$customQuery = newVal(this.selectedValue, this.$props);
2022
- var query = extractQueryFromCustomQuery(this.$customQuery);
2023
- var queryOptions = getOptionsForCustomQuery(this.$customQuery);
2024
- if (queryOptions) {
2025
- this.setQueryOptions(componentId, _rollupPluginBabelHelpers._extends({}, queryOptions, this.getAggsQuery()), false);
2026
- } else this.setQueryOptions(componentId, this.getAggsQuery(), false);
2027
-
2028
- // Update custom query for RS API
2029
- index.updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.selectedValue);
2030
- this.updateQuery({
2031
- componentId: componentId,
2032
- query: query
2421
+ getComponent: function getComponent() {
2422
+ var _this$$props6 = this.$props,
2423
+ rawData = _this$$props6.rawData,
2424
+ error = _this$$props6.error,
2425
+ isLoading = _this$$props6.isLoading;
2426
+ var data = {
2427
+ data: this.getTransformedData(),
2428
+ rawData: rawData,
2429
+ error: error,
2430
+ handleClick: this.handleListItemClick,
2431
+ value: this.$data.selectedValues,
2432
+ loading: isLoading,
2433
+ PATH_SEPARATOR: constants.TREELIST_VALUES_PATH_SEPARATOR
2434
+ };
2435
+ return this.$slots.render(data) || helper.getComponent(data, this.$props);
2436
+ },
2437
+ getDefaultQuery: function getDefaultQuery(value) {
2438
+ var _this2 = this;
2439
+ var query = null;
2440
+ var type = 'term';
2441
+ var booleanAggregator = this.$props.queryFormat === 'or' ? 'should' : 'must';
2442
+ if (!Array.isArray(value) || value.length === 0) {
2443
+ return null;
2444
+ }
2445
+ if (value) {
2446
+ var _bool;
2447
+ // adds a sub-query with must as an array of objects for each term/value
2448
+ var queryArray = value.map(function (item) {
2449
+ return {
2450
+ bool: {
2451
+ must: item.split(' > ').map(function (subItem, i) {
2452
+ var _type, _ref2;
2453
+ return _ref2 = {}, _ref2[type] = (_type = {}, _type[_this2.$props.dataField[i]] = subItem, _type), _ref2;
2454
+ })
2455
+ }
2456
+ };
2033
2457
  });
2458
+ var listQuery = {
2459
+ bool: (_bool = {}, _bool[booleanAggregator] = queryArray, _bool)
2460
+ };
2461
+ query = value.length ? listQuery : null;
2034
2462
  }
2035
- }
2036
- },
2037
- render: function render() {
2038
- try {
2039
- var dom = this.$slots["default"];
2040
- var error = this.error,
2041
- isLoading = this.isLoading,
2042
- selectedValue = this.selectedValue;
2043
- var propsToBePassed = _rollupPluginBabelHelpers._extends({
2044
- error: error,
2045
- loading: isLoading
2046
- }, this.getData(), {
2047
- value: selectedValue,
2048
- setQuery: this.setQuery
2049
- });
2050
- return vue.createVNode("div", null, [dom(propsToBePassed)]);
2051
- } catch (e) {
2052
- return null;
2053
- }
2054
- },
2055
- methods: {
2056
- getAggsQuery: function getAggsQuery() {
2057
- if (this.aggregationField) {
2463
+ if (query && this.$props.nestedField) {
2058
2464
  return {
2059
- aggs: getCompositeAggsQuery$1({
2060
- props: this.$props,
2061
- showTopHits: true,
2062
- value: this.selectedValue
2063
- }).aggs
2465
+ nested: {
2466
+ path: this.$props.nestedField,
2467
+ query: query
2468
+ }
2064
2469
  };
2065
2470
  }
2066
- return {};
2067
- },
2068
- getData: function getData() {
2069
- var hits = this.hits,
2070
- aggregations = this.aggregations,
2071
- aggregationData = this.aggregationData,
2072
- promotedResults = this.promotedResults,
2073
- rawData = this.rawData;
2074
- var filteredResults = parseHits(hits);
2075
- if (promotedResults.length) {
2076
- var ids = promotedResults.map(function (item) {
2077
- return item._id;
2078
- }).filter(Boolean);
2079
- if (ids) {
2080
- filteredResults = filteredResults.filter(function (item) {
2081
- return !ids.includes(item._id);
2082
- });
2083
- }
2084
- filteredResults = [].concat(promotedResults, filteredResults);
2471
+ return query;
2472
+ },
2473
+ updateQuery: function updateQuery(value) {
2474
+ var customQuery = this.$props.customQuery;
2475
+ var query = this.getDefaultQuery(value);
2476
+ var customQueryOptions;
2477
+ if (customQuery) {
2478
+ var _ref3 = customQuery(value, this.$props) || {};
2479
+ query = _ref3.query;
2480
+ customQueryOptions = helper.getOptionsFromQuery(customQuery(value, this.$props));
2481
+ helper.updateCustomQuery(this.$props.componentId, this.$props, value);
2085
2482
  }
2086
- return {
2087
- data: filteredResults,
2088
- aggregationData: aggregationData,
2089
- rawData: rawData,
2090
- aggregations: aggregations,
2091
- promotedData: promotedResults,
2092
- resultStats: this.stats
2483
+ this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, this.generateQueryOptions(), customQueryOptions));
2484
+ this.updateQueryAction({
2485
+ componentId: this.$props.componentId,
2486
+ query: query,
2487
+ value: value,
2488
+ label: this.$props.filterLabel,
2489
+ showFilter: this.$props.showFilter,
2490
+ URLParams: this.$props.URLParams,
2491
+ componentType: constants.componentTypes.treeList
2492
+ });
2493
+ },
2494
+ setValue: function setValue(value, hasMountedParam) {
2495
+ var _this3 = this;
2496
+ if (hasMountedParam === void 0) {
2497
+ hasMountedParam = true;
2498
+ }
2499
+ var finalValues = Array.isArray(value) === false ? helper.transformTreeListLocalStateIntoQueryComptaibleFormat(value) : value;
2500
+ var performUpdate = function performUpdate() {
2501
+ var handleUpdates = function handleUpdates() {
2502
+ _this3.updateQuery(finalValues);
2503
+ if (_this3.$props.onValueChange) _this3.$props.onValueChange(finalValues);
2504
+ };
2505
+ if (hasMountedParam) {
2506
+ _this3.selectedValues = Array.isArray(value) ? transformValueIntoLocalState(value) : value;
2507
+ handleUpdates();
2508
+ } else {
2509
+ handleUpdates();
2510
+ }
2093
2511
  };
2512
+ helper.checkValueChange(this.$props.componentId, finalValues, this.$props.beforeValueChange, performUpdate);
2513
+ },
2514
+ generateQueryOptions: function generateQueryOptions() {
2515
+ var queryOptions = helper.getQueryOptions(this.$props);
2516
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
2517
+ return helper.getAggsQuery(valueArray, queryOptions, this.$props);
2518
+ },
2519
+ updateDefaultQuery: function updateDefaultQuery(queryOptions) {
2520
+ var value = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
2521
+ // Update default query for RS API
2522
+ helper.updateDefaultQuery(this.$props.componentId, this.$props, value);
2523
+ helper.updateInternalQuery(transform.getInternalComponentID(this.$props.componentId), queryOptions, value, this.$props, this.generateQueryOptions(), null);
2524
+ },
2525
+ updateQueryOptions: function updateQueryOptions() {
2526
+ // for a new query due to other changes don't append after to get fresh results
2527
+ var queryOptions = this.generateQueryOptions(this.$props, {}, helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues));
2528
+ if (this.$props.defaultQuery) {
2529
+ // eslint-disable-next-line no-use-before-define
2530
+ this.updateDefaultQuery(queryOptions);
2531
+ } else {
2532
+ this.setQueryOptions(transform.getInternalComponentID(this.$props.componentId), queryOptions);
2533
+ }
2094
2534
  }
2095
2535
  },
2096
- computed: {
2097
- stats: function stats() {
2098
- return getResultStats$1(this);
2536
+ render: function render() {
2537
+ var _this4 = this;
2538
+ var props = this.$props;
2539
+ var style = props.style,
2540
+ className = props.className,
2541
+ mode = props.mode,
2542
+ showLine = props.showLine,
2543
+ renderItem = props.renderItem,
2544
+ showCheckbox = props.showCheckbox,
2545
+ innerClass = props.innerClass,
2546
+ showRadio = props.showRadio,
2547
+ showCount = props.showCount,
2548
+ showSwitcherIcon = props.showSwitcherIcon,
2549
+ switcherIcon = props.switcherIcon,
2550
+ title = props.title,
2551
+ loader = props.loader,
2552
+ renderError = props.renderError;
2553
+ if (this.isLoading) {
2554
+ return (this.$slots.loader ? this.$slots.loader() : loader) || null;
2099
2555
  }
2556
+ if (this.error) {
2557
+ if (this.$slots.renderError) {
2558
+ return this.$slots.renderError(this.error);
2559
+ }
2560
+ return helper.isFunction(renderError) ? renderError(this.error) : renderError;
2561
+ }
2562
+ var transformedData = this.getTransformedData();
2563
+ if (!transformedData || transformedData.length === 0) {
2564
+ return this.$slots.renderNoResults ? this.$slots.renderNoResults() : null;
2565
+ }
2566
+ return vue.createVNode(Container.Container, {
2567
+ "style": style,
2568
+ "class": className
2569
+ }, {
2570
+ "default": function _default() {
2571
+ return [props.title && vue.createVNode(Title.Title, {
2572
+ "class": helper.getClassName(innerClass, 'title') || null
2573
+ }, _isSlot$2(title) ? title : {
2574
+ "default": function _default() {
2575
+ return [title];
2576
+ }
2577
+ }), _this4.renderSearch(), _this4.hasCustomRenderer ? _this4.getComponent() : vue.createVNode(HierarchicalMenuComponent, {
2578
+ "key": "initial-node",
2579
+ "listArray": transformedData,
2580
+ "parentPath": "",
2581
+ "isExpanded": true,
2582
+ "listItemProps": {
2583
+ mode: mode,
2584
+ selectedValues: _this4.selectedValues,
2585
+ searchTerm: _this4.searchTerm,
2586
+ showLine: showLine,
2587
+ renderItem: renderItem != null ? renderItem : _this4.$slots.renderItem,
2588
+ handleListItemClick: _this4.handleListItemClick,
2589
+ showCheckbox: showCheckbox,
2590
+ innerClass: innerClass,
2591
+ showRadio: showRadio,
2592
+ renderIcon: _this4.renderIcon,
2593
+ showCount: showCount,
2594
+ showSwitcherIcon: showSwitcherIcon,
2595
+ switcherIcon: switcherIcon != null ? switcherIcon : _this4.$slots.switcherIcon
2596
+ }
2597
+ }, null)];
2598
+ }
2599
+ });
2100
2600
  }
2101
2601
  };
2102
- ReactiveComponent.hasInternalComponent = function (props) {
2103
- return !!props.defaultQuery;
2104
- };
2105
2602
  var mapStateToProps$1 = function mapStateToProps(state, props) {
2106
2603
  return {
2107
- aggregations: state.aggregations[props.componentId] && state.aggregations[props.componentId] || null,
2108
- aggregationData: state.compositeAggregations[props.componentId] || [],
2109
- hits: state.hits[props.componentId] && state.hits[props.componentId].hits || [],
2110
- rawData: state.rawData[props.componentId],
2604
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
2605
+ rawData: state.rawData[props.componentId] || {},
2606
+ aggregationData: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId] || {},
2607
+ themePreset: state.config.themePreset,
2111
2608
  error: state.error[props.componentId],
2112
2609
  isLoading: state.isLoading[props.componentId],
2113
- selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
2114
- promotedResults: state.promotedResults[props.componentId] || [],
2115
- time: state.hits[props.componentId] && state.hits[props.componentId].time || 0,
2116
- total: state.hits[props.componentId] && state.hits[props.componentId].total,
2117
- hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden,
2118
- componentProps: state.props[props.componentId]
2610
+ enableAppbase: state.config.enableAppbase
2119
2611
  };
2120
2612
  };
2121
2613
  var mapDispatchtoProps = {
2122
2614
  setQueryOptions: setQueryOptions,
2123
- updateQuery: updateQuery$1,
2124
- setCustomQuery: setCustomQuery$1,
2125
- setDefaultQuery: setDefaultQuery$1
2615
+ updateQueryAction: updateQueryAction
2126
2616
  };
2127
- var ConnectedComponent = ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchtoProps)(ReactiveComponent), {
2128
- componentType: constants.componentTypes.reactiveComponent
2129
- });
2617
+ TreeList.hasInternalComponent = function () {
2618
+ return true;
2619
+ };
2620
+ var TreeListConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchtoProps)(TreeList), {
2621
+ componentType: constants.componentTypes.treeList,
2622
+ internalComponent: TreeList.hasInternalComponent()
2623
+ }));
2624
+ TreeListConnected.name = TreeList.name;
2625
+ TreeListConnected.install = function (Vue) {
2626
+ Vue.component(TreeListConnected.name, TreeListConnected);
2627
+ };
2628
+
2629
+ // Add componentType for SSR
2630
+ TreeListConnected.componentType = constants.componentTypes.treeList;
2631
+
2130
2632
  var RcConnected = PreferencesConsumer.PreferencesConsumer({
2131
2633
  name: 'RcConnected',
2132
2634
  render: function render() {
2133
- var component = ConnectedComponent;
2635
+ var component = ReactiveComponent.default;
2134
2636
  switch (this.$attrs.componentType) {
2135
2637
  case constants.componentTypes.reactiveList:
2136
- component = ReactiveList.RLConnected;
2638
+ component = ReactiveList.default;
2137
2639
  break;
2138
2640
  case constants.componentTypes.searchBox:
2139
2641
  component = SBConnected;
2140
2642
  break;
2141
2643
  // list components
2142
2644
  case constants.componentTypes.singleList:
2143
- component = SingleList.ListConnected;
2645
+ component = SingleList.default;
2144
2646
  break;
2145
2647
  case constants.componentTypes.multiList:
2146
- component = MultiList.ListConnected;
2648
+ component = MultiList.default;
2147
2649
  break;
2148
2650
  case constants.componentTypes.singleDropdownList:
2149
- component = SingleDropdownList.ListConnected;
2651
+ component = SingleDropdownList.default;
2150
2652
  break;
2151
2653
  case constants.componentTypes.multiDropdownList:
2152
- component = MultiDropdownList.ListConnected;
2654
+ component = MultiDropdownList.default;
2153
2655
  break;
2154
2656
  // basic components
2155
2657
  case constants.componentTypes.toggleButton:
2156
- component = ToggleButton.TBConnected;
2658
+ component = ToggleButton.default;
2157
2659
  break;
2158
2660
  // range components
2159
2661
  case constants.componentTypes.dynamicRangeSlider:
2160
- component = DynamicRangeSlider.RangeConnected;
2662
+ component = DynamicRangeSlider.default;
2161
2663
  break;
2162
2664
  case constants.componentTypes.singleRange:
2163
- component = SingleRange.RangeConnected;
2665
+ component = SingleRange.default;
2164
2666
  break;
2165
2667
  case constants.componentTypes.multiRange:
2166
- component = MultiRange.RangeConnected;
2668
+ component = MultiRange.default;
2167
2669
  break;
2168
2670
  case constants.componentTypes.rangeSlider:
2169
- component = RangeSlider.RangeConnected;
2671
+ component = RangeSlider.default;
2170
2672
  break;
2171
2673
  case constants.componentTypes.rangeInput:
2172
- component = RangeInput.RangeConnected;
2674
+ component = RangeInput.default;
2173
2675
  break;
2174
2676
  }
2175
2677
  return vue.h(component, null, this.$slots);
2176
2678
  }
2177
2679
  });
2178
- RcConnected.name = ReactiveComponent.name;
2179
- RcConnected.hasInternalComponent = ReactiveComponent.hasInternalComponent;
2680
+ RcConnected.name = ReactiveComponent.default.name;
2681
+ RcConnected.hasInternalComponent = ReactiveComponent.default.hasInternalComponent;
2180
2682
  // Add componentType for SSR
2181
2683
  RcConnected.componentType = constants.componentTypes.reactiveComponent;
2182
2684
  RcConnected.install = function (Vue) {
2183
2685
  Vue.component(RcConnected.name, RcConnected);
2184
2686
  };
2185
2687
 
2186
- exports.ReactiveComponent = RcConnected;
2688
+ var components = [ReactiveList.default, ResultCard.default, ResultList.default, ReactiveBase.default, SBConnected, SingleList.default, MultiList.default, SingleRange.default, MultiRange.default, RangeSlider.default, DynamicRangeSlider.default, ReactiveComponent.default, RcConnected, SelectedFilters.default, ToggleButton.default, SingleDropdownList.default, MultiDropdownList.default, StateProvider.default, RangeInput.default, TreeListConnected];
2689
+ function install (Vue) {
2690
+ components.map(function (component) {
2691
+ Vue.use(component);
2692
+ return null;
2693
+ });
2694
+ }
2695
+
2696
+ exports.ReactiveComponentPrivate = RcConnected;
2187
2697
  exports.SearchBox = SBConnected;
2698
+ exports.TreeList = TreeListConnected;
2699
+ exports.install = install;