@appbaseio/reactivesearch-vue 3.0.0-rc.6.5 → 3.0.0-rc.6.6

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.
@@ -4,7 +4,7 @@ import _transformOn from '@vue/babel-helper-vue-transform-on';
4
4
  import { _ as _taggedTemplateLiteralLoose, a as _extends, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
5
5
  import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
6
6
  import VueTypes from 'vue-types';
7
- import { getQueryOptions, getObjectFromLocalStorage, suggestionTypes, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, 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, featuredSuggestionsActionTypes, suggestionTypes, getObjectFromLocalStorage, getClassName as getClassName$2, setObjectInLocalStorage, recLookup, 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 } from '@appbaseio/vue-emotion';
9
9
  import { css, keyframes } from '@emotion/css';
10
10
  import { lighten } from 'polished';
@@ -21,9 +21,10 @@ import { F as Flex } from './Flex-25792bc3.js';
21
21
  import { recordAISessionUsefulness } from '@appbaseio/reactivecore/lib/actions/analytics';
22
22
  import ReactiveBase from './ReactiveBase.js';
23
23
  import hotkeys from 'hotkeys-js';
24
+ import xss from 'xss';
24
25
  import { Remarkable } from 'remarkable';
25
- import { I as IconWrapper, C as CancelSvg, a as IconGroup, D as Downshift, b as InputWrapper } from './DropDown-39fedff8.js';
26
- import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, a as suggestions } from './Input-11d211d2.js';
26
+ import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-bede2a41.js';
27
+ import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, a as suggestions, b as searchboxSuggestions } from './Input-4376ac1f.js';
27
28
  import { C as Container } from './Container-d00219f7.js';
28
29
  import Highlight from 'vue-highlight-words';
29
30
  import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
@@ -48,7 +49,9 @@ import ResultList from './ResultList.js';
48
49
  import StateProvider from './StateProvider.js';
49
50
 
50
51
  var _templateObject;
51
- var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: stretch;\n\twidth: 100%;\n"])));
52
+ var InputGroup = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: stretch;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\n\t", "\n};\n"])), function (props) {
53
+ return props.isOpen && 'box-shadow: rgb(0 0 0 / 20%) 0px 0px 15px;';
54
+ });
52
55
  InputGroup.defaultProps = {
53
56
  className: 'input-group'
54
57
  };
@@ -1066,6 +1069,9 @@ var AIFeedback = defineComponent({
1066
1069
  }
1067
1070
  });
1068
1071
 
1072
+ var _templateObject$8;
1073
+ var AutosuggestFooterContainer = styled('div')(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tcolor: #8792a2;\n\tbackground: #f7fafc;\n\tpadding: 10px;\n\theight: 40px;\n"])));
1074
+
1069
1075
  var _excluded = ["_source"];
1070
1076
  function _isSlot(s) {
1071
1077
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
@@ -1102,7 +1108,8 @@ var SearchBox = defineComponent({
1102
1108
  showAIScreen: false,
1103
1109
  showAIScreenFooter: false,
1104
1110
  showFeedbackComponent: false,
1105
- feedbackState: null
1111
+ feedbackState: null,
1112
+ prefilledAIAnswer: ''
1106
1113
  };
1107
1114
  this.internalComponent = props.componentId + "__internal";
1108
1115
  return this.__state;
@@ -1143,6 +1150,37 @@ var SearchBox = defineComponent({
1143
1150
  },
1144
1151
  stats: function stats() {
1145
1152
  return getResultStats(this);
1153
+ },
1154
+ mergedAIAnswer: function mergedAIAnswer() {
1155
+ return this.prefilledAIAnswer || this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text;
1156
+ },
1157
+ parsedSuggestions: function parsedSuggestions() {
1158
+ var suggestionsArray = [];
1159
+ if (Array.isArray(this.suggestions) && this.suggestions.length) {
1160
+ suggestionsArray = [].concat(withClickIds(this.suggestions));
1161
+ }
1162
+ suggestionsArray = suggestionsArray.map(function (s) {
1163
+ if (s.sectionId) {
1164
+ return s;
1165
+ }
1166
+ return _extends({}, s, {
1167
+ sectionId: s._suggestion_type
1168
+ });
1169
+ });
1170
+ var sectionsAccumulated = [];
1171
+ var sectionisedSuggestions = suggestionsArray.reduce(function (acc, d, currentIndex) {
1172
+ if (sectionsAccumulated.includes(d.sectionId)) return acc;
1173
+ if (d.sectionId) {
1174
+ acc[currentIndex] = suggestionsArray.filter(function (g) {
1175
+ return g.sectionId === d.sectionId;
1176
+ });
1177
+ sectionsAccumulated.push(d.sectionId);
1178
+ } else {
1179
+ acc[currentIndex] = d;
1180
+ }
1181
+ return acc;
1182
+ }, {});
1183
+ return Object.values(sectionisedSuggestions);
1146
1184
  }
1147
1185
  },
1148
1186
  props: {
@@ -1174,6 +1212,11 @@ var SearchBox = defineComponent({
1174
1212
  enableQuerySuggestions: VueTypes.bool.def(false),
1175
1213
  enablePopularSuggestions: VueTypes.bool.def(false),
1176
1214
  enableRecentSuggestions: VueTypes.bool.def(false),
1215
+ enableFAQSuggestions: VueTypes.bool.def(false),
1216
+ FAQSuggestionsConfig: VueTypes.shape({
1217
+ sectionLabel: VueTypes.string,
1218
+ size: VueTypes.number
1219
+ }),
1177
1220
  fieldWeights: types.fieldWeights,
1178
1221
  filterLabel: types.string,
1179
1222
  fuzziness: types.fuzziness,
@@ -1209,12 +1252,20 @@ var SearchBox = defineComponent({
1209
1252
  distinctFieldConfig: types.props,
1210
1253
  //
1211
1254
  focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
1255
+ showFocusShortcutsIcon: VueTypes.bool.def(true),
1212
1256
  addonBefore: VueTypes.any,
1213
1257
  addonAfter: VueTypes.any,
1258
+ showSuggestionsFooter: VueTypes.bool.def(true),
1214
1259
  expandSuggestionsContainer: VueTypes.bool.def(true),
1260
+ renderSuggestionsFooter: VueTypes.func,
1215
1261
  index: VueTypes.string,
1216
1262
  popularSuggestionsConfig: VueTypes.object,
1217
1263
  recentSuggestionsConfig: VueTypes.object,
1264
+ featuredSuggestionsConfig: VueTypes.shape({
1265
+ maxSuggestionsPerSection: VueTypes.number,
1266
+ sectionsOrder: VueTypes.arrayOf(VueTypes.string)
1267
+ }),
1268
+ customEvents: VueTypes.object,
1218
1269
  applyStopwords: VueTypes.bool,
1219
1270
  customStopwords: types.stringArray,
1220
1271
  onData: types.func,
@@ -1402,7 +1453,7 @@ var SearchBox = defineComponent({
1402
1453
  resultStats: this.stats,
1403
1454
  AIData: {
1404
1455
  question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
1405
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
1456
+ answer: this.mergedAIAnswerc,
1406
1457
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
1407
1458
  showAIScreen: this.showAIScreen,
1408
1459
  sources: this.getAISourceObjects(),
@@ -1433,7 +1484,7 @@ var SearchBox = defineComponent({
1433
1484
  this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
1434
1485
  }
1435
1486
  },
1436
- setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
1487
+ setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue, shouldExecuteQuery) {
1437
1488
  var _this2 = this;
1438
1489
  if (isDefaultValue === void 0) {
1439
1490
  isDefaultValue = false;
@@ -1447,6 +1498,9 @@ var SearchBox = defineComponent({
1447
1498
  if (categoryValue === void 0) {
1448
1499
  categoryValue = undefined;
1449
1500
  }
1501
+ if (shouldExecuteQuery === void 0) {
1502
+ shouldExecuteQuery = true;
1503
+ }
1450
1504
  var performUpdate = function performUpdate() {
1451
1505
  if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
1452
1506
  return;
@@ -1482,17 +1536,18 @@ var SearchBox = defineComponent({
1482
1536
  }
1483
1537
  if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
1484
1538
  enableAI: true
1485
- } : {});
1539
+ } : {}, shouldExecuteQuery);
1486
1540
  } // in case of strict selection only SUGGESTION_SELECT should be able
1487
1541
  // to set the query otherwise the value should reset
1488
1542
  if (props.strictSelection) {
1489
1543
  if (cause === causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
1490
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1544
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1491
1545
  } else {
1492
1546
  _this2.setValue('', true);
1493
1547
  }
1494
1548
  } else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
1495
- _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
1549
+ _this2.showAIScreen = false;
1550
+ _this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
1496
1551
  }
1497
1552
  } else {
1498
1553
  // debounce for handling text while typing
@@ -1503,10 +1558,13 @@ var SearchBox = defineComponent({
1503
1558
  };
1504
1559
  checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
1505
1560
  },
1506
- triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
1561
+ triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta, shouldExecuteQuery) {
1507
1562
  if (meta === void 0) {
1508
1563
  meta = {};
1509
1564
  }
1565
+ if (shouldExecuteQuery === void 0) {
1566
+ shouldExecuteQuery = true;
1567
+ }
1510
1568
  if (!this.$props.autosuggest) {
1511
1569
  return;
1512
1570
  }
@@ -1527,12 +1585,15 @@ var SearchBox = defineComponent({
1527
1585
  value: value,
1528
1586
  componentType: componentTypes.searchBox,
1529
1587
  meta: meta
1530
- });
1588
+ }, shouldExecuteQuery);
1531
1589
  },
1532
- triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
1590
+ triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue, shouldExecuteQuery) {
1533
1591
  if (categoryValue === void 0) {
1534
1592
  categoryValue = undefined;
1535
1593
  }
1594
+ if (shouldExecuteQuery === void 0) {
1595
+ shouldExecuteQuery = true;
1596
+ }
1536
1597
  var _this$$props = this.$props,
1537
1598
  customQuery = _this$$props.customQuery,
1538
1599
  filterLabel = _this$$props.filterLabel,
@@ -1561,7 +1622,7 @@ var SearchBox = defineComponent({
1561
1622
  URLParams: URLParams,
1562
1623
  componentType: componentTypes.searchBox,
1563
1624
  category: categoryValue
1564
- });
1625
+ }, shouldExecuteQuery);
1565
1626
  },
1566
1627
  handleFocus: function handleFocus(event) {
1567
1628
  if (this.$props.autosuggest) {
@@ -1660,12 +1721,60 @@ var SearchBox = defineComponent({
1660
1721
  }, e);
1661
1722
  }
1662
1723
  },
1724
+ handleFeaturedSuggestionClicked: function handleFeaturedSuggestionClicked(suggestion) {
1725
+ try {
1726
+ var _this$$refs2, _this$$refs2$this$$pr;
1727
+ if (suggestion.action === featuredSuggestionsActionTypes.NAVIGATE) {
1728
+ var _JSON$parse = JSON.parse(suggestion.subAction),
1729
+ _JSON$parse$target = _JSON$parse.target,
1730
+ target = _JSON$parse$target === void 0 ? '_self' : _JSON$parse$target,
1731
+ _JSON$parse$link = _JSON$parse.link,
1732
+ link = _JSON$parse$link === void 0 ? '/' : _JSON$parse$link;
1733
+ if (typeof window !== 'undefined') {
1734
+ window.open(link, target);
1735
+ }
1736
+ }
1737
+ if (suggestion.action === featuredSuggestionsActionTypes.FUNCTION) {
1738
+ var matchedValues = suggestion.subAction.match(/function\s*\(.*\)(.|\n)*/);
1739
+ var functionStr = matchedValues && matchedValues[0];
1740
+ // eslint-disable-next-line no-new-func
1741
+ var func = new Function("return " + functionStr)();
1742
+ func(suggestion, this.$data.currentValue, this.$props.customEvents);
1743
+ }
1744
+ if (suggestion.action === featuredSuggestionsActionTypes.SELECT) {
1745
+ this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS);
1746
+ this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT);
1747
+ }
1748
+ // blur is important to close the dropdown
1749
+ // on selecting one of featured suggestions
1750
+ // else Downshift probably is focusing the dropdown
1751
+ // and not letting it close
1752
+ // eslint-disable-next-line no-unused-expressions
1753
+ (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$this$$pr = _this$$refs2[this.$props.innerRef]) == null ? void 0 : _this$$refs2$this$$pr.blur();
1754
+ } catch (e) {
1755
+ console.error("Error: There was an error parsing the subAction for the featured suggestion with label, \"" + suggestion.label + "\"", e);
1756
+ }
1757
+ },
1663
1758
  onSuggestionSelected: function onSuggestionSelected(suggestion) {
1664
1759
  var _this4 = this;
1760
+ // handle when FAQ suggestion is clicked
1761
+ if (suggestion && suggestion._suggestion_type === suggestionTypes.FAQ) {
1762
+ this.prefilledAIAnswer = suggestion._answer;
1763
+ this.setValue(suggestion.value, true, this.$props, causes.SUGGESTION_SELECT, true, false, suggestion._category, false);
1764
+ this.isOpen = true;
1765
+ this.showAIScreen = true;
1766
+ return;
1767
+ }
1665
1768
  if (!this.$props.enableAI) this.isOpen = false;else {
1666
1769
  this.showAIScreen = true;
1667
1770
  }
1668
1771
  var value = this.$props.value;
1772
+
1773
+ // handle featured suggestions click event
1774
+ if (suggestion._suggestion_type === suggestionTypes.Featured) {
1775
+ this.handleFeaturedSuggestionClicked(suggestion);
1776
+ return;
1777
+ }
1669
1778
  // Record analytics for selected suggestions
1670
1779
  this.triggerClickAnalytics(suggestion._click_id);
1671
1780
  if (value === undefined) {
@@ -1821,6 +1930,13 @@ var SearchBox = defineComponent({
1821
1930
  customQuery: true
1822
1931
  });
1823
1932
  },
1933
+ suggestionsFooter: function suggestionsFooter() {
1934
+ return typeof renderSuggestionsFooter === 'function' ? this.$props.renderSuggestionsFooter() : createVNode(AutosuggestFooterContainer, null, {
1935
+ "default": function _default() {
1936
+ return [createVNode("div", null, [createTextVNode("\u2191\u2193 Navigate")]), createVNode("div", null, [createTextVNode("\u21A9 Go")])];
1937
+ }
1938
+ });
1939
+ },
1824
1940
  renderEnterButtonElement: function renderEnterButtonElement() {
1825
1941
  var _this6 = this;
1826
1942
  var _this$$props2 = this.$props,
@@ -1848,16 +1964,29 @@ var SearchBox = defineComponent({
1848
1964
  }
1849
1965
  return null;
1850
1966
  },
1967
+ renderShortcut: function renderShortcut() {
1968
+ if (this.$props.focusShortcuts && this.$props.focusShortcuts.length) {
1969
+ var shortcut = this.$props.focusShortcuts[0];
1970
+ shortcut = shortcut.toLowerCase();
1971
+ shortcut = shortcut.replace('shift', '⬆️');
1972
+ shortcut = shortcut.replace('command', 'cmd');
1973
+ shortcut = shortcut.replace('control', 'ctrl');
1974
+ shortcut = shortcut.replace('option', 'alt');
1975
+ return shortcut.toUpperCase();
1976
+ }
1977
+ return '/';
1978
+ },
1851
1979
  renderIcons: function renderIcons() {
1852
1980
  var _this7 = this;
1853
- var _slot3, _slot4, _slot5;
1981
+ var _slot3, _slot4, _slot5, _slot6;
1854
1982
  var _this$$props3 = this.$props,
1855
1983
  iconPosition = _this$$props3.iconPosition,
1856
1984
  showClear = _this$$props3.showClear,
1857
1985
  innerClass = _this$$props3.innerClass,
1858
1986
  getMicInstance = _this$$props3.getMicInstance,
1859
1987
  showVoiceSearch = _this$$props3.showVoiceSearch,
1860
- showIcon = _this$$props3.showIcon;
1988
+ showIcon = _this$$props3.showIcon,
1989
+ showFocusShortcutsIcon = _this$$props3.showFocusShortcutsIcon;
1861
1990
  var renderMic = this.$slots.renderMic || this.$props.renderMic;
1862
1991
  var currentValue = this.$data.currentValue;
1863
1992
  return createVNode("div", null, [createVNode(IconGroup, {
@@ -1873,6 +2002,14 @@ var SearchBox = defineComponent({
1873
2002
  "default": function _default() {
1874
2003
  return [_slot3];
1875
2004
  }
2005
+ }), showFocusShortcutsIcon && createVNode(ButtonIconWrapper, {
2006
+ "onClick": function onClick(e) {
2007
+ return _this7.focusSearchBox(e);
2008
+ }
2009
+ }, _isSlot(_slot4 = _this7.renderShortcut()) ? _slot4 : {
2010
+ "default": function _default() {
2011
+ return [_slot4];
2012
+ }
1876
2013
  }), showVoiceSearch && createVNode(Mic, {
1877
2014
  "getInstance": getMicInstance,
1878
2015
  "render": renderMic,
@@ -1880,9 +2017,9 @@ var SearchBox = defineComponent({
1880
2017
  "className": getClassName$1(innerClass, 'mic') || null
1881
2018
  }, null), iconPosition === 'right' && showIcon && createVNode(IconWrapper, {
1882
2019
  "onClick": _this7.handleSearchIconClick
1883
- }, _isSlot(_slot4 = _this7.renderIcon()) ? _slot4 : {
2020
+ }, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
1884
2021
  "default": function _default() {
1885
- return [_slot4];
2022
+ return [_slot5];
1886
2023
  }
1887
2024
  })];
1888
2025
  }
@@ -1893,23 +2030,23 @@ var SearchBox = defineComponent({
1893
2030
  "default": function _default() {
1894
2031
  return [iconPosition === 'left' && showIcon && createVNode(IconWrapper, {
1895
2032
  "onClick": _this7.handleSearchIconClick
1896
- }, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
2033
+ }, _isSlot(_slot6 = _this7.renderIcon()) ? _slot6 : {
1897
2034
  "default": function _default() {
1898
- return [_slot5];
2035
+ return [_slot6];
1899
2036
  }
1900
2037
  })];
1901
2038
  }
1902
2039
  })]);
1903
2040
  },
1904
2041
  focusSearchBox: function focusSearchBox(event) {
1905
- var _this$$refs2, _this$$refs2$this$$pr;
2042
+ var _this$$refs3, _this$$refs3$this$$pr;
1906
2043
  var elt = event.target || event.srcElement;
1907
2044
  var tagName = elt.tagName;
1908
2045
  if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
1909
2046
  // already in an input
1910
2047
  return;
1911
2048
  }
1912
- (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$this$$pr = _this$$refs2[this.$props.innerRef]) == null ? void 0 : _this$$refs2$this$$pr.focus(); // eslint-disable-line
2049
+ (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$this$$pr = _this$$refs3[this.$props.innerRef]) == null ? void 0 : _this$$refs3$this$$pr.focus(); // eslint-disable-line
1913
2050
  },
1914
2051
  listenForFocusShortcuts: function listenForFocusShortcuts() {
1915
2052
  var _this8 = this;
@@ -1949,16 +2086,31 @@ var SearchBox = defineComponent({
1949
2086
  this.currentValue = decodeHtml(value);
1950
2087
  this.triggerDefaultQuery(value);
1951
2088
  },
1952
- renderAutoFill: function renderAutoFill(suggestion) {
2089
+ renderActionIcon: function renderActionIcon(suggestion) {
1953
2090
  var _this9 = this;
1954
2091
  var handleAutoFillClick = function handleAutoFillClick(e) {
1955
2092
  e.stopPropagation();
1956
2093
  _this9.onAutofillClick(suggestion);
1957
2094
  };
1958
- /* 👇 avoid showing autofill for category suggestions👇 */
1959
- return suggestion._category ? null : createVNode(AutoFillSvg, {
1960
- "onClick": handleAutoFillClick
1961
- }, null);
2095
+ if (suggestion._suggestion_type === suggestionTypes.Featured) {
2096
+ if (suggestion.action === featuredSuggestionsActionTypes.FUNCTION) {
2097
+ return createVNode(AutoFillSvg, {
2098
+ "style": {
2099
+ transform: 'rotate(135deg)',
2100
+ pointerEvents: 'none'
2101
+ }
2102
+ }, null);
2103
+ }
2104
+ return null;
2105
+ }
2106
+ if (!suggestion._category) {
2107
+ /* 👇 avoid showing autofill for category suggestions👇 */
2108
+
2109
+ return createVNode(AutoFillSvg, {
2110
+ "onClick": handleAutoFillClick
2111
+ }, null);
2112
+ }
2113
+ return null;
1962
2114
  },
1963
2115
  renderTag: function renderTag(item) {
1964
2116
  var _this10 = this;
@@ -2065,7 +2217,7 @@ var SearchBox = defineComponent({
2065
2217
  return createVNode(HorizontalSkeletonLoader, null, null);
2066
2218
  },
2067
2219
  renderAIScreenFooter: function renderAIScreenFooter() {
2068
- var _slot6;
2220
+ var _slot7;
2069
2221
  var _this12 = this;
2070
2222
  var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
2071
2223
  AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
@@ -2080,7 +2232,7 @@ var SearchBox = defineComponent({
2080
2232
  "themePreset": this.$props.themePreset
2081
2233
  }, {
2082
2234
  "default": function _default() {
2083
- return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot6 = _this12.getAISourceObjects().map(function (el) {
2235
+ return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot7 = _this12.getAISourceObjects().map(function (el) {
2084
2236
  return createVNode(Button, {
2085
2237
  "class": "--ai-source-tag " + (getClassName$1(_this12.$props.innerClass, 'ai-source-tag') || ''),
2086
2238
  "title": el[sourceDocumentLabel],
@@ -2093,9 +2245,9 @@ var SearchBox = defineComponent({
2093
2245
  return [el[sourceDocumentLabel]];
2094
2246
  }
2095
2247
  });
2096
- })) ? _slot6 : {
2248
+ })) ? _slot7 : {
2097
2249
  "default": function _default() {
2098
- return [_slot6];
2250
+ return [_slot7];
2099
2251
  }
2100
2252
  })];
2101
2253
  }
@@ -2107,7 +2259,7 @@ var SearchBox = defineComponent({
2107
2259
  if (customAIRenderer) {
2108
2260
  return customAIRenderer({
2109
2261
  question: this.AIResponse && this.AIResponse.response && this.AIResponse.response.question,
2110
- answer: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text,
2262
+ answer: this.mergedAIAnswer,
2111
2263
  documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
2112
2264
  loading: this.isAIResponseLoading || this.isLoading,
2113
2265
  sources: this.getAISourceObjects(),
@@ -2118,7 +2270,7 @@ var SearchBox = defineComponent({
2118
2270
  return this.renderAIScreenLoader();
2119
2271
  }
2120
2272
  return createVNode("div", null, [createVNode(Answer, {
2121
- "innerHTML": md.render(this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text)
2273
+ "innerHTML": md.render(this.mergedAIAnswer)
2122
2274
  }, null), this.renderAIScreenFooter(), this.showFeedbackComponent && createVNode("div", {
2123
2275
  "class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
2124
2276
  }, [createVNode(AIFeedback, {
@@ -2227,23 +2379,58 @@ var SearchBox = defineComponent({
2227
2379
  highlightedIndex = _ref8.highlightedIndex,
2228
2380
  setHighlightedIndex = _ref8.setHighlightedIndex;
2229
2381
  var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
2230
- var getIcon = function getIcon(iconType) {
2382
+ var getIcon = function getIcon(iconType, item, leaveSpaceForIcon) {
2231
2383
  switch (iconType) {
2232
2384
  case suggestionTypes.Recent:
2233
2385
  return recentSearchesIcon;
2234
2386
  case suggestionTypes.Popular:
2235
2387
  return popularSearchesIcon;
2388
+ case suggestionTypes.Featured:
2389
+ if (item.icon) {
2390
+ return function () {
2391
+ return createVNode("div", {
2392
+ "style": {
2393
+ display: 'flex'
2394
+ },
2395
+ "innerHTML": xss(item.icon)
2396
+ }, null);
2397
+ };
2398
+ }
2399
+ if (item.iconURL) {
2400
+ return function () {
2401
+ return (// When you change below also change the empty icon below
2402
+ createVNode("img", {
2403
+ "style": {
2404
+ maxHeight: '25px'
2405
+ },
2406
+ "src": xss(item.iconURL),
2407
+ "alt": item.value
2408
+ }, null)
2409
+ );
2410
+ };
2411
+ }
2412
+ // Render an empty icon when no icon is provided from the dashboard
2413
+ return function () {
2414
+ return createVNode("span", {
2415
+ "style": {
2416
+ display: 'inline-block',
2417
+ height: '25px',
2418
+ width: leaveSpaceForIcon ? '25px' : 0
2419
+ }
2420
+ }, null);
2421
+ };
2236
2422
  default:
2237
2423
  return null;
2238
2424
  }
2239
2425
  };
2426
+ var indexOffset = 0;
2240
2427
  return createVNode("div", null, [_this15.hasCustomRenderer && _this15.getComponent({
2241
2428
  isOpen: isOpen,
2242
2429
  getItemProps: getItemProps,
2243
2430
  getItemEvents: getItemEvents,
2244
2431
  highlightedIndex: highlightedIndex
2245
2432
  }), _this15.renderErrorComponent(), !_this15.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
2246
- "class": suggestions(_this15.themePreset, _this15.theme) + " " + getClassName$1(_this15.$props.innerClass, 'list'),
2433
+ "class": suggestions(_this15.themePreset, _this15.theme) + " " + getClassName$1(_this15.$props.innerClass, 'list') + " " + searchboxSuggestions(_this15.themePreset, _this15.theme) + "\n\t\t\t\t\t\t\t\t\t\t\t\t\t",
2247
2434
  "ref": _dropdownULRef
2248
2435
  }, [_this15.showAIScreen && createVNode(SearchBoxAISection, {
2249
2436
  "themePreset": _this15.$props.themePreset
@@ -2251,43 +2438,63 @@ var SearchBox = defineComponent({
2251
2438
  "default": function _default() {
2252
2439
  return [_this15.renderAIScreen(), ' ', _this15.renderErrorComponent(true)];
2253
2440
  }
2254
- }), !_this15.showAIScreen && _this15.normalizedSuggestions.map(function (item, index) {
2255
- return renderItem ? createVNode("li", mergeProps(getItemProps({
2256
- item: item
2257
- }), getItemEvents({
2258
- item: item
2259
- }), {
2260
- "key": index + 1 + "-" + item.value,
2261
- "style": {
2262
- backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
2263
- justifyContent: 'flex-start',
2264
- alignItems: 'center'
2265
- }
2266
- }), [renderItem(item)]) : createVNode("li", mergeProps(getItemProps({
2267
- item: item
2268
- }), _transformOn(getItemEvents({
2269
- item: item
2270
- })), {
2271
- "key": index + 1 + "-" + item.value,
2272
- "style": {
2273
- backgroundColor: _this15.getBackgroundColor(highlightedIndex, index),
2274
- justifyContent: 'flex-start',
2275
- alignItems: 'center'
2276
- }
2277
- }), [createVNode("div", {
2278
- "style": {
2279
- padding: '0 10px 0 0',
2280
- display: 'flex'
2281
- }
2282
- }, [createVNode(CustomSvg, {
2283
- "className": getClassName$1(_this15.$props.innerClass, item._suggestion_type + "-search-icon") || null,
2284
- "icon": getIcon(item._suggestion_type),
2285
- "type": item._suggestion_type + "-search-icon"
2286
- }, null)]), createVNode(SuggestionItem, {
2287
- "currentValue": _this15.currentValue,
2288
- "suggestion": item
2289
- }, null), _this15.renderAutoFill(item)]);
2290
- })]) : _this15.renderNoSuggestions(_this15.normalizedSuggestions)]);
2441
+ }), !_this15.showAIScreen && _this15.parsedSuggestions.map(function (item, itemIndex) {
2442
+ var index = indexOffset + itemIndex;
2443
+ if (Array.isArray(item)) {
2444
+ var sectionHtml = xss(item[0].sectionLabel);
2445
+ indexOffset += item.length - 1;
2446
+ return createVNode("div", {
2447
+ "class": "section-container"
2448
+ }, [sectionHtml ? createVNode("div", {
2449
+ "class": "section-header " + getClassName$1(_this15.$props.innerClass, 'section-label'),
2450
+ "key": "" + item[0].sectionId,
2451
+ "innerHTML": sectionHtml
2452
+ }, null) : null, createVNode("ul", {
2453
+ "class": "section-list"
2454
+ }, [item.map(function (sectionItem, sectionIndex) {
2455
+ var suggestionsHaveIcon = item.some(function (s) {
2456
+ return s.icon || s.iconURL;
2457
+ });
2458
+ return renderItem ? createVNode("li", mergeProps(getItemProps({
2459
+ item: sectionItem
2460
+ }), _transformOn(getItemEvents({
2461
+ item: sectionItem
2462
+ })), {
2463
+ "key": index + sectionIndex,
2464
+ "style": {
2465
+ justifyContent: 'flex-start',
2466
+ alignItems: 'center'
2467
+ },
2468
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this15.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this15.$props.innerClass, 'suggestion-item'))
2469
+ }), [renderItem(sectionItem)]) : createVNode("li", mergeProps(getItemProps({
2470
+ item: sectionItem
2471
+ }), _transformOn(getItemEvents({
2472
+ item: sectionItem
2473
+ })), {
2474
+ "key": index + sectionIndex,
2475
+ "style": {
2476
+ justifyContent: 'flex-start',
2477
+ alignItems: 'center'
2478
+ },
2479
+ "class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this15.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this15.$props.innerClass, 'suggestion-item'))
2480
+ }), [createVNode("div", {
2481
+ "style": {
2482
+ padding: '0 10px 0 0',
2483
+ display: 'flex'
2484
+ }
2485
+ }, [createVNode(CustomSvg, {
2486
+ "key": sectionItem._suggestion_type + "-" + sectionIndex,
2487
+ "className": getClassName$1(_this15.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
2488
+ "icon": getIcon(sectionItem._suggestion_type, sectionItem, suggestionsHaveIcon),
2489
+ "type": sectionItem._suggestion_type + "-search-icon"
2490
+ }, null)]), createVNode(SuggestionItem, {
2491
+ "currentValue": _this15.currentValue,
2492
+ "suggestion": sectionItem
2493
+ }, null), _this15.renderActionIcon(sectionItem)]);
2494
+ })])]);
2495
+ }
2496
+ return createVNode("div", null, [createTextVNode("No suggestions")]);
2497
+ }), _this15.$props.showSuggestionsFooter ? _this15.suggestionsFooter() : null]) : _this15.renderNoSuggestions(_this15.normalizedSuggestions)]);
2291
2498
  };
2292
2499
  return createVNode("div", {
2293
2500
  "class": suggestionsContainer
@@ -2327,7 +2534,8 @@ var SearchBox = defineComponent({
2327
2534
  "placeholder": _this15.$props.placeholder,
2328
2535
  "autoFocus": _this15.$props.autoFocus,
2329
2536
  "showFocusShortcutsIcon": _this15.$props.showFocusShortcutsIcon,
2330
- "showVoiceSearch": _this15.$props.showVoiceSearch
2537
+ "showVoiceSearch": _this15.$props.showVoiceSearch,
2538
+ "searchBox": true
2331
2539
  }, getInputProps({
2332
2540
  value: _this15.$data.currentValue === null ? '' : _this15.$data.currentValue
2333
2541
  }), {
@@ -3061,8 +3269,8 @@ AIConnected.install = function (Vue) {
3061
3269
  // Add componentType for SSR
3062
3270
  AIConnected.componentType = componentTypes.AIAnswer;
3063
3271
 
3064
- var _templateObject$8, _templateObject2$4;
3065
- 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"])));
3272
+ var _templateObject$9, _templateObject2$4;
3273
+ var HierarchicalMenuList = styled('ul')(_templateObject$9 || (_templateObject$9 = _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"])));
3066
3274
  var HierarchicalMenuListItem = styled('li')(_templateObject2$4 || (_templateObject2$4 = _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) {
3067
3275
  return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
3068
3276
  });
@@ -28,10 +28,11 @@ import '@appbaseio/analytics';
28
28
  import 'url-search-params-polyfill';
29
29
  import './ReactiveBase.js';
30
30
  import 'hotkeys-js';
31
+ import 'xss';
31
32
  import 'remarkable';
32
- export { i as default } from './install-b785dd55.js';
33
- import './DropDown-39fedff8.js';
34
- import './Input-11d211d2.js';
33
+ export { i as default } from './install-af4c53c4.js';
34
+ import './DropDown-bede2a41.js';
35
+ import './Input-4376ac1f.js';
35
36
  import 'compute-scroll-into-view';
36
37
  import './Container-d00219f7.js';
37
38
  import 'vue-highlight-words';