@appbaseio/reactivesearch-vue 3.0.0-rc.5.alpha.1 → 3.0.0-rc.5.alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +1,28 @@
1
1
  import { helper, Actions, causes } from '@appbaseio/reactivecore';
2
- import { SEARCH_COMPONENTS_MODES, componentTypes, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
2
+ import { SEARCH_COMPONENTS_MODES, componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
3
3
  import _transformOn from '@vue/babel-helper-vue-transform-on';
4
4
  import { _ as _taggedTemplateLiteralLoose, a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
5
- import { createVNode, createTextVNode, defineComponent, isVNode, mergeProps, h } from 'vue';
5
+ import { createVNode, createTextVNode, defineComponent, isVNode, mergeProps } from 'vue';
6
6
  import VueTypes from 'vue-types';
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';
7
+ import { getQueryOptions, suggestionTypes } from '@appbaseio/reactivecore/lib/utils/helper';
8
8
  import { styled, createGlobalStyle } from '@appbaseio/vue-emotion';
9
9
  import { css } from '@emotion/css';
10
+ import 'polished';
10
11
  import { B as Button } from './Button-fd869491.js';
11
12
  import { t as types } from './vueTypes-f1923c72.js';
12
- import { RLConnected as ReactiveList } from './ReactiveList.js';
13
- import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
13
+ import '@appbaseio/reactivecore/lib/utils/transform';
14
+ import 'redux';
14
15
  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
16
  import { C as ComponentWrapper } from './ComponentWrapper-8a3c388d.js';
16
17
  import { P as PreferencesConsumer } from './PreferencesConsumer-b058d14e.js';
17
18
  import { T as Title } from './Title-863dfa42.js';
18
- import { L as ListItem } from './ListItem-e3c6acf4.js';
19
19
  import { F as Flex } from './Flex-25792bc3.js';
20
- import ReactiveBase from './ReactiveBase.js';
21
20
  import hotkeys from 'hotkeys-js';
22
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './DropDown-fc1fef02.js';
21
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './CancelSvg-e7ae49e9.js';
23
22
  import { n as noSuggestions, s as suggestionsContainer, I as Input, a as suggestions } from './Input-f7499ef8.js';
23
+ import 'compute-scroll-into-view';
24
24
  import { C as Container } from './Container-d00219f7.js';
25
25
  import Highlight from 'vue-highlight-words';
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';
45
26
 
46
27
  var _templateObject;
47
28
  var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: stretch;\n width: 100%;\n"])));
@@ -1862,831 +1843,5 @@ SBConnected.install = function (Vue) {
1862
1843
  // Add componentType for SSR
1863
1844
  SBConnected.componentType = componentTypes.searchBox;
1864
1845
 
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
- },
1898
- props: {
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,
2170
- customQuery: types.func,
2171
- defaultQuery: types.func,
2172
- enableAppbase: types.bool,
2173
- index: types.string,
2174
- showFilter: types.bool,
2175
- URLParams: types.bool,
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,
2191
- react: types.react,
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;
2206
- },
2207
- created: function created() {
2208
- var props = this.$props;
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);
2216
- }
2217
-
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`.');
2229
- }
2230
- },
2231
- watch: {
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();
2242
- },
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) {
2249
- if (!isEqual$1(newVal, oldVal)) {
2250
- this.setValue(newVal);
2251
- }
2252
- },
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
- }
2267
- }
2268
- },
2269
- aggregationData: function aggregationData(newVal, oldVal) {
2270
- if (newVal && !isEqual$1(newVal, oldVal)) {
2271
- this.$data.aggregationData = newVal;
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)])]);
2329
- },
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;
2340
- },
2341
- handleInputChange: function handleInputChange(e) {
2342
- var value = e.target.value;
2343
- this.searchTerm = value;
2344
- },
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);
2364
- }
2365
- return null;
2366
- },
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);
2386
- }
2387
- },
2388
- filterDataBasedOnSearchTerm: function filterDataBasedOnSearchTerm(listArray, parentPath) {
2389
- var _this = this;
2390
- if (!(listArray && Array.isArray(listArray) && listArray.length)) {
2391
- return null;
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;
2416
- },
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
- };
2453
- });
2454
- var listQuery = {
2455
- bool: (_bool = {}, _bool[booleanAggregator] = queryArray, _bool)
2456
- };
2457
- query = value.length ? listQuery : null;
2458
- }
2459
- if (query && this.$props.nestedField) {
2460
- return {
2461
- nested: {
2462
- path: this.$props.nestedField,
2463
- query: query
2464
- }
2465
- };
2466
- }
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);
2478
- }
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
- }
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
- }
2530
- }
2531
- },
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;
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
- });
2596
- }
2597
- };
2598
- var mapStateToProps$1 = function mapStateToProps(state, props) {
2599
- return {
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,
2604
- error: state.error[props.componentId],
2605
- isLoading: state.isLoading[props.componentId],
2606
- enableAppbase: state.config.enableAppbase
2607
- };
2608
- };
2609
- var mapDispatchtoProps = {
2610
- setQueryOptions: setQueryOptions,
2611
- updateQueryAction: updateQueryAction
2612
- };
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
-
2628
- var RcConnected = PreferencesConsumer({
2629
- name: 'RcConnected',
2630
- render: function render() {
2631
- var component = ReactiveComponent;
2632
- switch (this.$attrs.componentType) {
2633
- case componentTypes.reactiveList:
2634
- component = ReactiveList;
2635
- break;
2636
- case componentTypes.searchBox:
2637
- component = SBConnected;
2638
- break;
2639
- // list components
2640
- case componentTypes.singleList:
2641
- component = SingleList;
2642
- break;
2643
- case componentTypes.multiList:
2644
- component = MultiList;
2645
- break;
2646
- case componentTypes.singleDropdownList:
2647
- component = SingleDropdownList;
2648
- break;
2649
- case componentTypes.multiDropdownList:
2650
- component = MultiDropdownList;
2651
- break;
2652
- // basic components
2653
- case componentTypes.toggleButton:
2654
- component = ToggleButton;
2655
- break;
2656
- // range components
2657
- case componentTypes.dynamicRangeSlider:
2658
- component = DynamicRangeSlider;
2659
- break;
2660
- case componentTypes.singleRange:
2661
- component = SingleRange;
2662
- break;
2663
- case componentTypes.multiRange:
2664
- component = MultiRange;
2665
- break;
2666
- case componentTypes.rangeSlider:
2667
- component = RangeSlider;
2668
- break;
2669
- case componentTypes.rangeInput:
2670
- component = RangeInput;
2671
- break;
2672
- }
2673
- return h(component, null, this.$slots);
2674
- }
2675
- });
2676
- RcConnected.name = ReactiveComponent.name;
2677
- RcConnected.hasInternalComponent = ReactiveComponent.hasInternalComponent;
2678
- // Add componentType for SSR
2679
- RcConnected.componentType = componentTypes.reactiveComponent;
2680
- RcConnected.install = function (Vue) {
2681
- Vue.component(RcConnected.name, RcConnected);
2682
- };
2683
-
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 };
1846
+ export default SBConnected;
1847
+ export { SBConnected };