@appbaseio/reactivesearch-vue 3.0.0-rc.6.4 → 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.
- package/dist/@appbaseio/reactivesearch-vue.umd.js +2080 -197
- package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
- package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
- package/dist/cjs/{DropDown-aef75c14.js → DropDown-dcdaf54f.js} +12 -4
- package/dist/cjs/{Input-56eba499.js → Input-df30e5fc.js} +23 -16
- package/dist/cjs/MultiDropdownList.js +2 -2
- package/dist/cjs/MultiList.js +1 -1
- package/dist/cjs/RangeInput.js +1 -1
- package/dist/cjs/SingleDropdownList.js +2 -2
- package/dist/cjs/SingleList.js +1 -1
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/{install-65eec53a.js → install-3821345b.js} +371 -125
- package/dist/cjs/install.js +4 -3
- package/dist/cjs/version.js +1 -1
- package/dist/es/{DropDown-39fedff8.js → DropDown-bede2a41.js} +12 -5
- package/dist/es/{Input-11d211d2.js → Input-4376ac1f.js} +23 -17
- package/dist/es/MultiDropdownList.js +2 -2
- package/dist/es/MultiList.js +1 -1
- package/dist/es/RangeInput.js +1 -1
- package/dist/es/SingleDropdownList.js +2 -2
- package/dist/es/SingleList.js +1 -1
- package/dist/es/index.js +5 -4
- package/dist/es/{install-cb6c5753.js → install-af4c53c4.js} +373 -127
- package/dist/es/install.js +4 -3
- package/dist/es/version.js +1 -1
- package/package.json +90 -89
|
@@ -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,
|
|
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,12 +21,13 @@ 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-
|
|
26
|
-
import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, a as suggestions } from './Input-
|
|
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
|
-
import { fetchAIResponse } from '@appbaseio/reactivecore/lib/actions/query';
|
|
30
|
+
import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
|
|
30
31
|
import { replaceDiacritics } from '@appbaseio/reactivecore/lib/utils/suggestions';
|
|
31
32
|
import { C as Checkbox, R as Radio } from './FormControlList-fe6eaee4.js';
|
|
32
33
|
import { s as sanitizeObject } from './utils-d7dd4f4e.js';
|
|
@@ -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.
|
|
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.
|
|
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(
|
|
2020
|
+
}, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
|
|
1884
2021
|
"default": function _default() {
|
|
1885
|
-
return [
|
|
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(
|
|
2033
|
+
}, _isSlot(_slot6 = _this7.renderIcon()) ? _slot6 : {
|
|
1897
2034
|
"default": function _default() {
|
|
1898
|
-
return [
|
|
2035
|
+
return [_slot6];
|
|
1899
2036
|
}
|
|
1900
2037
|
})];
|
|
1901
2038
|
}
|
|
1902
2039
|
})]);
|
|
1903
2040
|
},
|
|
1904
2041
|
focusSearchBox: function focusSearchBox(event) {
|
|
1905
|
-
var _this$$
|
|
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$$
|
|
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
|
-
|
|
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
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
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
|
|
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(
|
|
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
|
-
})) ?
|
|
2248
|
+
})) ? _slot7 : {
|
|
2097
2249
|
"default": function _default() {
|
|
2098
|
-
return [
|
|
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.
|
|
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.
|
|
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.
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
item
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
"
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
item
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
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
|
}), {
|
|
@@ -2542,6 +2750,7 @@ var AIAnswer = defineComponent({
|
|
|
2542
2750
|
isLoading: types.boolRequired,
|
|
2543
2751
|
sessionIdFromStore: VueTypes.string,
|
|
2544
2752
|
showComponent: types.boolRequired,
|
|
2753
|
+
componentError: types.componentObject,
|
|
2545
2754
|
style: types.style
|
|
2546
2755
|
},
|
|
2547
2756
|
mounted: function mounted() {},
|
|
@@ -2625,14 +2834,50 @@ var AIAnswer = defineComponent({
|
|
|
2625
2834
|
},
|
|
2626
2835
|
messages: function messages() {
|
|
2627
2836
|
this.scrollToBottom();
|
|
2837
|
+
},
|
|
2838
|
+
componentError: function componentError(newVal) {
|
|
2839
|
+
var _this = this;
|
|
2840
|
+
if (newVal && newVal._bodyBlob) {
|
|
2841
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
|
|
2842
|
+
if (!this.AISessionId) {
|
|
2843
|
+
this.generateNewSessionId();
|
|
2844
|
+
}
|
|
2845
|
+
newVal._bodyBlob.text().then(function (textData) {
|
|
2846
|
+
try {
|
|
2847
|
+
var parsedErrorRes = JSON.parse(textData);
|
|
2848
|
+
if (parsedErrorRes.error) {
|
|
2849
|
+
_this.error = parsedErrorRes.error;
|
|
2850
|
+
_this.$emit('on-data', {
|
|
2851
|
+
data: _this.messages,
|
|
2852
|
+
rawData: _this.$props.rawData,
|
|
2853
|
+
loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
|
|
2854
|
+
error: parsedErrorRes.error
|
|
2855
|
+
});
|
|
2856
|
+
}
|
|
2857
|
+
} catch (error) {
|
|
2858
|
+
console.error('Error parsing component error JSON:', error);
|
|
2859
|
+
}
|
|
2860
|
+
})["catch"](function (error) {
|
|
2861
|
+
console.error('Error reading component error text data:', error);
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2628
2864
|
}
|
|
2629
2865
|
},
|
|
2630
2866
|
methods: {
|
|
2867
|
+
generateNewSessionId: function generateNewSessionId() {
|
|
2868
|
+
var _this2 = this;
|
|
2869
|
+
var newSessionPromise = this.createAISession();
|
|
2870
|
+
newSessionPromise.then(function (res) {
|
|
2871
|
+
_this2.AISessionId = res.AIsessionId;
|
|
2872
|
+
})["catch"](function (e) {
|
|
2873
|
+
console.error(e);
|
|
2874
|
+
});
|
|
2875
|
+
},
|
|
2631
2876
|
scrollToBottom: function scrollToBottom() {
|
|
2632
|
-
var
|
|
2877
|
+
var _this3 = this;
|
|
2633
2878
|
this.$nextTick(function () {
|
|
2634
|
-
var
|
|
2635
|
-
var messageContainer = (
|
|
2879
|
+
var _this3$$refs;
|
|
2880
|
+
var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
|
|
2636
2881
|
if (messageContainer && messageContainer.$el) {
|
|
2637
2882
|
messageContainer.$el.scrollTo({
|
|
2638
2883
|
top: messageContainer.$el.scrollHeight,
|
|
@@ -2699,7 +2944,7 @@ var AIAnswer = defineComponent({
|
|
|
2699
2944
|
"class": "--ai-answer-error-container " + (getClassName$2(this.$props.innerClass, 'ai-error') || '')
|
|
2700
2945
|
}, [createVNode("div", {
|
|
2701
2946
|
"class": "--default-error-element"
|
|
2702
|
-
}, [createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? "Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && createVNode(Button, {
|
|
2947
|
+
}, [createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? ", Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && createVNode(Button, {
|
|
2703
2948
|
"primary": true,
|
|
2704
2949
|
"onClick": this.handleRetryRequest
|
|
2705
2950
|
}, {
|
|
@@ -2750,7 +2995,7 @@ var AIAnswer = defineComponent({
|
|
|
2750
2995
|
}
|
|
2751
2996
|
},
|
|
2752
2997
|
renderIcons: function renderIcons() {
|
|
2753
|
-
var
|
|
2998
|
+
var _this4 = this;
|
|
2754
2999
|
var _slot, _slot2;
|
|
2755
3000
|
var _this$$props = this.$props,
|
|
2756
3001
|
getMicInstance = _this$$props.getMicInstance,
|
|
@@ -2764,12 +3009,12 @@ var AIAnswer = defineComponent({
|
|
|
2764
3009
|
"positionType": "absolute"
|
|
2765
3010
|
}, {
|
|
2766
3011
|
"default": function _default() {
|
|
2767
|
-
return [!
|
|
3012
|
+
return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && createVNode(Mic, {
|
|
2768
3013
|
"getInstance": getMicInstance,
|
|
2769
3014
|
"render": renderMic,
|
|
2770
|
-
"handleResult":
|
|
3015
|
+
"handleResult": _this4.handleVoiceResults,
|
|
2771
3016
|
"class": getClassName$2(innerClass, 'ai-search-mic') || null
|
|
2772
|
-
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot =
|
|
3017
|
+
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
|
|
2773
3018
|
"default": function _default() {
|
|
2774
3019
|
return [_slot];
|
|
2775
3020
|
}
|
|
@@ -2781,7 +3026,7 @@ var AIAnswer = defineComponent({
|
|
|
2781
3026
|
"positionType": "absolute"
|
|
2782
3027
|
}, {
|
|
2783
3028
|
"default": function _default() {
|
|
2784
|
-
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot2 =
|
|
3029
|
+
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
|
|
2785
3030
|
"default": function _default() {
|
|
2786
3031
|
return [_slot2];
|
|
2787
3032
|
}
|
|
@@ -2793,7 +3038,7 @@ var AIAnswer = defineComponent({
|
|
|
2793
3038
|
this.handleSendMessage(e);
|
|
2794
3039
|
},
|
|
2795
3040
|
renderEnterButtonElement: function renderEnterButtonElement() {
|
|
2796
|
-
var
|
|
3041
|
+
var _this5 = this;
|
|
2797
3042
|
var _this$$props2 = this.$props,
|
|
2798
3043
|
enterButton = _this$$props2.enterButton,
|
|
2799
3044
|
innerClass = _this$$props2.innerClass;
|
|
@@ -2801,16 +3046,16 @@ var AIAnswer = defineComponent({
|
|
|
2801
3046
|
if (enterButton) {
|
|
2802
3047
|
var getEnterButtonMarkup = function getEnterButtonMarkup() {
|
|
2803
3048
|
if (renderEnterButton) {
|
|
2804
|
-
return renderEnterButton(
|
|
3049
|
+
return renderEnterButton(_this5.enterButtonOnClick);
|
|
2805
3050
|
}
|
|
2806
3051
|
return createVNode(SendButton, {
|
|
2807
3052
|
"primary": true,
|
|
2808
3053
|
"type": "submit",
|
|
2809
3054
|
"tabIndex": 0,
|
|
2810
|
-
"onClick":
|
|
2811
|
-
"onKeyPress":
|
|
3055
|
+
"onClick": _this5.handleSendMessage,
|
|
3056
|
+
"onKeyPress": _this5.handleKeyPress,
|
|
2812
3057
|
"class": "ask-btn " + getClassName$2(innerClass, 'ai-enter-button'),
|
|
2813
|
-
"disabled":
|
|
3058
|
+
"disabled": _this5.isLoadingState || !_this5.AISessionId
|
|
2814
3059
|
}, {
|
|
2815
3060
|
"default": function _default() {
|
|
2816
3061
|
return [createTextVNode("Send")];
|
|
@@ -2833,10 +3078,10 @@ var AIAnswer = defineComponent({
|
|
|
2833
3078
|
return getComponent(data, this);
|
|
2834
3079
|
},
|
|
2835
3080
|
handleTextAreaHeightChange: function handleTextAreaHeightChange() {
|
|
2836
|
-
var _this$$
|
|
2837
|
-
var textArea = (_this$$
|
|
2838
|
-
var inputWrapper = (_this$$
|
|
2839
|
-
var errorContainer = (_this$$
|
|
3081
|
+
var _this$$refs, _this$$refs$_inputRef, _this$$refs2, _this$$refs2$_inputWr, _this$$refs3;
|
|
3082
|
+
var textArea = (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$_inputRef = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs$_inputRef.$el;
|
|
3083
|
+
var inputWrapper = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputWr = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2$_inputWr.$el;
|
|
3084
|
+
var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
|
|
2840
3085
|
if (textArea) {
|
|
2841
3086
|
textArea.style.height = '42px';
|
|
2842
3087
|
var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
|
|
@@ -2868,21 +3113,20 @@ var AIAnswer = defineComponent({
|
|
|
2868
3113
|
},
|
|
2869
3114
|
render: function render() {
|
|
2870
3115
|
var _slot3;
|
|
2871
|
-
var
|
|
3116
|
+
var _this6 = this;
|
|
2872
3117
|
var props = this.$props;
|
|
2873
3118
|
if (!this.shouldShowComponent) {
|
|
2874
3119
|
return null;
|
|
2875
3120
|
}
|
|
2876
3121
|
return createVNode(Chatbox, {
|
|
2877
|
-
"style": props.style
|
|
2878
|
-
"class": "--ai-chat-box-wrapper"
|
|
3122
|
+
"style": props.style || {}
|
|
2879
3123
|
}, {
|
|
2880
3124
|
"default": function _default() {
|
|
2881
|
-
return [
|
|
2882
|
-
"class": getClassName$2(
|
|
3125
|
+
return [_this6.$props.title && createVNode(Title, {
|
|
3126
|
+
"class": getClassName$2(_this6.$props.innerClass, 'title') || ''
|
|
2883
3127
|
}, {
|
|
2884
3128
|
"default": function _default() {
|
|
2885
|
-
return [
|
|
3129
|
+
return [_this6.$props.title];
|
|
2886
3130
|
}
|
|
2887
3131
|
}), createVNode(ChatContainer, {
|
|
2888
3132
|
"class": "--ai-chat-container",
|
|
@@ -2890,33 +3134,33 @@ var AIAnswer = defineComponent({
|
|
|
2890
3134
|
"showInput": props.showInput
|
|
2891
3135
|
}, {
|
|
2892
3136
|
"default": function _default() {
|
|
2893
|
-
return [
|
|
2894
|
-
"themePreset":
|
|
3137
|
+
return [_this6.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3138
|
+
"themePreset": _this6.themePreset,
|
|
2895
3139
|
"theme": props.theme,
|
|
2896
|
-
"ref":
|
|
3140
|
+
"ref": _this6.$props.innerRef,
|
|
2897
3141
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
2898
|
-
}, _isSlot$1(_slot3 =
|
|
3142
|
+
}, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
|
|
2899
3143
|
"default": function _default() {
|
|
2900
3144
|
return [_slot3];
|
|
2901
3145
|
}
|
|
2902
|
-
}), !
|
|
2903
|
-
"themePreset":
|
|
3146
|
+
}), !_this6.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3147
|
+
"themePreset": _this6.themePreset,
|
|
2904
3148
|
"theme": props.theme,
|
|
2905
|
-
"ref":
|
|
3149
|
+
"ref": _this6.$props.innerRef,
|
|
2906
3150
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
2907
3151
|
}, {
|
|
2908
3152
|
"default": function _default() {
|
|
2909
|
-
return [
|
|
3153
|
+
return [_this6.messages.map(function (message, index) {
|
|
2910
3154
|
return createVNode(Message, {
|
|
2911
3155
|
"key": index,
|
|
2912
3156
|
"isSender": message.role === AI_ROLES.USER,
|
|
2913
3157
|
"innerHTML": md$1.render(message.content),
|
|
2914
|
-
"themePreset":
|
|
3158
|
+
"themePreset": _this6.themePreset,
|
|
2915
3159
|
"theme": props.theme,
|
|
2916
3160
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
|
|
2917
3161
|
}, null);
|
|
2918
|
-
}),
|
|
2919
|
-
"themePreset":
|
|
3162
|
+
}), _this6.isLoadingState && createVNode(Message, {
|
|
3163
|
+
"themePreset": _this6.themePreset,
|
|
2920
3164
|
"theme": props.theme,
|
|
2921
3165
|
"isSender": false,
|
|
2922
3166
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || null)
|
|
@@ -2925,31 +3169,31 @@ var AIAnswer = defineComponent({
|
|
|
2925
3169
|
return [createVNode(TypingIndicator, null, {
|
|
2926
3170
|
"default": function _default() {
|
|
2927
3171
|
return [createVNode(TypingDot, {
|
|
2928
|
-
"themePreset":
|
|
3172
|
+
"themePreset": _this6.themePreset
|
|
2929
3173
|
}, null), createVNode(TypingDot, {
|
|
2930
|
-
"themePreset":
|
|
3174
|
+
"themePreset": _this6.themePreset
|
|
2931
3175
|
}, null), createVNode(TypingDot, {
|
|
2932
|
-
"themePreset":
|
|
3176
|
+
"themePreset": _this6.themePreset
|
|
2933
3177
|
}, null)];
|
|
2934
3178
|
}
|
|
2935
3179
|
})];
|
|
2936
3180
|
}
|
|
2937
3181
|
})];
|
|
2938
3182
|
}
|
|
2939
|
-
}),
|
|
3183
|
+
}), _this6.renderErrorComponent(), ' ', props.showFeedback && createVNode("div", {
|
|
2940
3184
|
"class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
|
|
2941
3185
|
}, [createVNode(AIFeedback, {
|
|
2942
|
-
"hideUI":
|
|
2943
|
-
"key":
|
|
3186
|
+
"hideUI": _this6.isLoadingState || !_this6.sessionId,
|
|
3187
|
+
"key": _this6.sessionId,
|
|
2944
3188
|
"onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
|
|
2945
|
-
|
|
3189
|
+
_this6.trackUsefullness(_this6.sessionId, {
|
|
2946
3190
|
useful: useful,
|
|
2947
3191
|
reason: reason
|
|
2948
3192
|
});
|
|
2949
3193
|
}
|
|
2950
3194
|
}, null)]), props.showInput && createVNode(MessageInputContainer, {
|
|
2951
3195
|
"class": "--ai-input-container",
|
|
2952
|
-
"onSubmit":
|
|
3196
|
+
"onSubmit": _this6.handleSendMessage
|
|
2953
3197
|
}, {
|
|
2954
3198
|
"default": function _default() {
|
|
2955
3199
|
return [createVNode(InputGroup, {
|
|
@@ -2965,19 +3209,19 @@ var AIAnswer = defineComponent({
|
|
|
2965
3209
|
"ref": _inputRef,
|
|
2966
3210
|
"placeholder": props.placeholder,
|
|
2967
3211
|
"enterButton": props.enterButton,
|
|
2968
|
-
"value":
|
|
2969
|
-
"onInput":
|
|
3212
|
+
"value": _this6.inputMessage,
|
|
3213
|
+
"onInput": _this6.handleMessageInputChange,
|
|
2970
3214
|
"id": props.componentId + "-ai-input",
|
|
2971
3215
|
"showIcon": props.showIcon,
|
|
2972
3216
|
"iconPosition": props.iconPosition,
|
|
2973
|
-
"themePreset":
|
|
2974
|
-
"disabled":
|
|
3217
|
+
"themePreset": _this6.themePreset,
|
|
3218
|
+
"disabled": _this6.isLoadingState || !_this6.AISessionId,
|
|
2975
3219
|
"class": getClassName$2(props.innerClass, 'ai-input') || null
|
|
2976
|
-
}, null), ' ',
|
|
3220
|
+
}, null), ' ', _this6.renderIcons()];
|
|
2977
3221
|
}
|
|
2978
3222
|
})];
|
|
2979
3223
|
}
|
|
2980
|
-
}),
|
|
3224
|
+
}), _this6.renderEnterButtonElement()];
|
|
2981
3225
|
}
|
|
2982
3226
|
}), ' '];
|
|
2983
3227
|
}
|
|
@@ -3004,12 +3248,14 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
|
3004
3248
|
rawData: state.rawData[props.componentId],
|
|
3005
3249
|
themePreset: state.config.themePreset,
|
|
3006
3250
|
isLoading: state.isLoading[props.componentId] || false,
|
|
3007
|
-
sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || ''
|
|
3251
|
+
sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
|
|
3252
|
+
componentError: state.error[props.componentId]
|
|
3008
3253
|
};
|
|
3009
3254
|
};
|
|
3010
3255
|
var mapDispatchToProps$1 = {
|
|
3011
3256
|
getAIResponse: fetchAIResponse,
|
|
3012
|
-
trackUsefullness: recordAISessionUsefulness
|
|
3257
|
+
trackUsefullness: recordAISessionUsefulness,
|
|
3258
|
+
createAISession: createAISession
|
|
3013
3259
|
};
|
|
3014
3260
|
var AIConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps$1, mapDispatchToProps$1)(AIAnswer), {
|
|
3015
3261
|
componentType: componentTypes.AIAnswer,
|
|
@@ -3023,8 +3269,8 @@ AIConnected.install = function (Vue) {
|
|
|
3023
3269
|
// Add componentType for SSR
|
|
3024
3270
|
AIConnected.componentType = componentTypes.AIAnswer;
|
|
3025
3271
|
|
|
3026
|
-
var _templateObject$
|
|
3027
|
-
var HierarchicalMenuList = styled('ul')(_templateObject$
|
|
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"])));
|
|
3028
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) {
|
|
3029
3275
|
return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
|
|
3030
3276
|
});
|