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