@appbaseio/reactivesearch-vue 3.0.0-rc.16 → 3.0.0-rc.18
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 +6316 -5869
- 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/index.js +2 -2
- package/dist/cjs/{install-aa32f65f.js → install-2103a9a2.js} +435 -120
- package/dist/cjs/install.js +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/components/search/AIAnswer.d.ts +5 -0
- package/dist/components/search/SearchBox.d.ts +1 -0
- package/dist/es/index.js +3 -3
- package/dist/es/{install-28637a98.js → install-18595cf0.js} +436 -121
- package/dist/es/install.js +2 -2
- package/dist/es/version.js +1 -1
- package/dist/types.ts +9 -7
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { helper, Actions, causes } from '@appbaseio/reactivecore';
|
|
2
|
-
import { SEARCH_COMPONENTS_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } from '@appbaseio/reactivecore/lib/utils/constants';
|
|
2
|
+
import { SEARCH_COMPONENTS_MODES, AI_TRIGGER_MODES, componentTypes, AI_LOCAL_CACHE_KEY, AI_ROLES, TREELIST_VALUES_PATH_SEPARATOR } 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, b as _objectWithoutPropertiesLoose } from './_rollupPluginBabelHelpers-ded08042.js';
|
|
5
5
|
import { createVNode, createTextVNode, defineComponent, ref, watch, isVNode, mergeProps, h } from 'vue';
|
|
@@ -21,8 +21,8 @@ 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 { Remarkable } from 'remarkable';
|
|
25
24
|
import xss from 'xss';
|
|
25
|
+
import { Remarkable } from 'remarkable';
|
|
26
26
|
import { I as IconWrapper, C as CancelSvg, a as IconGroup, B as ButtonIconWrapper, D as Downshift, b as InputWrapper } from './DropDown-845623df.js';
|
|
27
27
|
import { n as noSuggestions, T as TextArea, I as Input, s as suggestionsContainer, A as Actions$1, a as suggestions, b as searchboxSuggestions } from './Input-83dee8c5.js';
|
|
28
28
|
import { C as Container } from './Container-d00219f7.js';
|
|
@@ -804,7 +804,7 @@ var HorizontalSkeletonLoader = defineComponent({
|
|
|
804
804
|
});
|
|
805
805
|
|
|
806
806
|
var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
807
|
-
var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n"])), function (props) {
|
|
807
|
+
var Chatbox = styled('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tposition: relative;\n\tmargin: 0 auto;\n\tpadding: 10px;\n\tbackground-color: #fafafa;\n\twidth: 100%;\n\tbox-shadow: rgb(0 0 0 / 20%) 0px 0px 6px;\n\tborder-radius: 6px;\n\tmargin-bottom: 20px;\n\tbackground-color: ", ";\n\n\t.--trigger-message-wrapper {\n\t\tcursor: pointer;\n\t}\n"])), function (props) {
|
|
808
808
|
return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
|
|
809
809
|
});
|
|
810
810
|
var ChatContainer = styled('div')(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\theight: 100%;\n\tposition: relative;\n\t.--ai-answer-error-container {\n\t\ttext-align: center;\n\t\tposition: absolute;\n\t\tbottom: 0px;\n\t\t", ";\n\t\tz-index: 1;\n\t\tleft: 50%;\n\t\ttransform: translateX(-50%);\n\t\twidth: 100%;\n\n\t\t.--default-error-element {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tpadding: 10px;\n\t\t\tbackground-color: ", ";\n\t\t\tbox-shadow: 0 -5px 5px -2px\n\t\t\t\t", ";\n\n\t\t\tspan {\n\t\t\t\tmargin-bottom: 5px;\n\t\t\t}\n\n\t\t\tbutton {\n\t\t\t}\n\t\t}\n\t}\n\n\t", ";\n"])), function (props) {
|
|
@@ -829,11 +829,15 @@ var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTem
|
|
|
829
829
|
return finalColor;
|
|
830
830
|
}, typingDots);
|
|
831
831
|
var resetCSS = function resetCSS(props) {
|
|
832
|
-
return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
|
|
832
|
+
return "\n\thtml,\n\tbody,\n\tdiv,\n\tspan,\n\tapplet,\n\tobject,\n\tiframe,\n\th1,\n\th2,\n\th3,\n\th4,\n\th5,\n\th6,\n\tp,\n\tblockquote,\n\tpre,\n\ta,\n\tabbr,\n\tacronym,\n\taddress,\n\tbig,\n\tcite,\n\tcode,\n\tdel,\n\tdfn,\n\tem,\n\timg,\n\tins,\n\tkbd,\n\tq,\n\ts,\n\tsamp,\n\tsmall,\n\tstrike,\n\tstrong,\n\tsub,\n\tsup,\n\ttt,\n\tvar,\n\tb,\n\tu,\n\ti,\n\tcenter,\n\tdl,\n\tdt,\n\tdd,\n\tol,\n\tul,\n\tli,\n\tfieldset,\n\tform,\n\tlabel,\n\tlegend,\n\ttable,\n\tcaption,\n\ttbody,\n\ttfoot,\n\tthead,\n\ttr,\n\tth,\n\ttd,\n\tarticle,\n\taside,\n\tcanvas,\n\tdetails,\n\tembed,\n\tfigure,\n\tfigcaption,\n\tfooter,\n\theader,\n\thgroup,\n\tmenu,\n\tnav,\n\toutput,\n\truby,\n\tsection,\n\tsummary,\n\ttime,\n\tmark,\n\taudio,\n\tvideo {\n\t\tmargin: 0;\n\t\tpadding: 0;\n\t\tborder: 0;\n\t\tfont-size: 100%;\n\t\tfont: inherit;\n\t\tvertical-align: baseline;\n\t\toverflow-wrap: anywhere;\n\t}\n\tpre {\n\t\tmargin: 10px auto;\n\t\twhite-space: pre-wrap;\n\n\t}\n\ttable {\n\t\tmargin: 10px auto;\n\t\tborder-collapse: collapse;\n\t\tborder-spacing: 0;\n\t}\n\ttr {\n\t\tborder-bottom: 1px solid #ccc;\n\t}\n\tth,\n\ttd {\n\t\ttext-align: left;\n\t\tpadding: 4px;\n\t\tborder: 1px solid;\n\t\tborder-collapse: collapse;\n\t}\n\tpre,\n\tcode {\n\t\tpadding: 0.6em 0.4em;\n\t\tbackground: " + (
|
|
833
|
+
// eslint-disable-next-line no-nested-ternary
|
|
834
|
+
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryColor : props.theme.colors.borderColor : props.theme.colors.borderColor) + ";\n\n\t}\n\n\tpre{\n\t\tcolor: " + (
|
|
833
835
|
// eslint-disable-next-line no-nested-ternary
|
|
834
|
-
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.
|
|
836
|
+
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";}\n\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
|
|
835
837
|
// eslint-disable-next-line no-nested-ternary
|
|
836
|
-
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\
|
|
838
|
+
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\tborder-radius: 3px;\n\t\tfont-size: 85%;\n\t\tpadding: 0.2em 0.4em;\n\t\tmargin-top: 5px;\n\t\tdisplay: inline-block;\n\t\toverflow: auto;\n\t\twidth: fit-content;\n\t\tmax-width: 100%;\n\t}\n\ncode[class*='language-'],\n\tpre[class*='language-'] {\n\t\tcolor: " + (
|
|
839
|
+
// eslint-disable-next-line no-nested-ternary
|
|
840
|
+
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\ttext-shadow: none;\n\t}\n\n\tul,\n\tol {\n\t\tlist-style-position: inside;\n\t\tpadding-left: 10px;\n\n\t}\n\n\tli{\n\t\tdisplay: list-item;\n\t\tcursor: default;\n\t\tpadding: initial;\n\n\t\t&:hover{\n\t\t\tbackground-color: initial;\n\t\t}\n\t}\n\tp {\n\t\tmargin: inherit;\n\t}\n";
|
|
837
841
|
};
|
|
838
842
|
var messageBGColor = function messageBGColor(props) {
|
|
839
843
|
var finalBGColor;
|
|
@@ -1084,7 +1088,9 @@ var md = new Remarkable();
|
|
|
1084
1088
|
md.set({
|
|
1085
1089
|
html: true,
|
|
1086
1090
|
breaks: true,
|
|
1087
|
-
xhtmlOut: true
|
|
1091
|
+
xhtmlOut: true,
|
|
1092
|
+
linkify: true,
|
|
1093
|
+
linkTarget: '_blank'
|
|
1088
1094
|
});
|
|
1089
1095
|
var _dropdownULRef = 'dropdownULRef';
|
|
1090
1096
|
var _inputGroupRef = 'inputGroupRef';
|
|
@@ -1112,7 +1118,9 @@ var SearchBox = defineComponent({
|
|
|
1112
1118
|
showAIScreen: false,
|
|
1113
1119
|
showAIScreenFooter: false,
|
|
1114
1120
|
showFeedbackComponent: false,
|
|
1115
|
-
feedbackState: null
|
|
1121
|
+
feedbackState: null,
|
|
1122
|
+
faqAnswer: '',
|
|
1123
|
+
faqQuestion: ''
|
|
1116
1124
|
};
|
|
1117
1125
|
this.internalComponent = props.componentId + "__internal";
|
|
1118
1126
|
return this.__state;
|
|
@@ -1148,17 +1156,33 @@ var SearchBox = defineComponent({
|
|
|
1148
1156
|
}
|
|
1149
1157
|
},
|
|
1150
1158
|
computed: {
|
|
1159
|
+
currentTriggerMode: function currentTriggerMode() {
|
|
1160
|
+
return this.$props.AIUIConfig && this.$props.AIUIConfig.triggerOn || AI_TRIGGER_MODES.MANUAL;
|
|
1161
|
+
},
|
|
1151
1162
|
hasCustomRenderer: function hasCustomRenderer$1() {
|
|
1152
1163
|
return hasCustomRenderer(this);
|
|
1153
1164
|
},
|
|
1154
1165
|
stats: function stats() {
|
|
1155
1166
|
return getResultStats(this);
|
|
1156
1167
|
},
|
|
1168
|
+
mergedAIQuestion: function mergedAIQuestion() {
|
|
1169
|
+
return this.faqQuestion || this.AIResponse && this.AIResponse.response && this.AIResponse.response.question;
|
|
1170
|
+
},
|
|
1171
|
+
mergedAIAnswer: function mergedAIAnswer() {
|
|
1172
|
+
return this.faqAnswer || this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.text;
|
|
1173
|
+
},
|
|
1157
1174
|
parsedSuggestions: function parsedSuggestions() {
|
|
1158
1175
|
var suggestionsArray = [];
|
|
1159
1176
|
if (Array.isArray(this.suggestions) && this.suggestions.length) {
|
|
1160
1177
|
suggestionsArray = [].concat(withClickIds(this.suggestions));
|
|
1161
1178
|
}
|
|
1179
|
+
if (this.renderTriggerMessage() && this.currentValue && !this.isLoading) {
|
|
1180
|
+
suggestionsArray.unshift({
|
|
1181
|
+
label: this.renderTriggerMessage(),
|
|
1182
|
+
value: 'AI_TRIGGER_MESSAGE',
|
|
1183
|
+
_suggestion_type: '_internal_a_i_trigger'
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1162
1186
|
suggestionsArray = suggestionsArray.map(function (s) {
|
|
1163
1187
|
if (s.sectionId) {
|
|
1164
1188
|
return s;
|
|
@@ -1212,6 +1236,11 @@ var SearchBox = defineComponent({
|
|
|
1212
1236
|
enableQuerySuggestions: VueTypes.bool.def(false),
|
|
1213
1237
|
enablePopularSuggestions: VueTypes.bool.def(false),
|
|
1214
1238
|
enableRecentSuggestions: VueTypes.bool.def(false),
|
|
1239
|
+
enableFAQSuggestions: VueTypes.bool.def(false),
|
|
1240
|
+
FAQSuggestionsConfig: VueTypes.shape({
|
|
1241
|
+
sectionLabel: VueTypes.string,
|
|
1242
|
+
size: VueTypes.number
|
|
1243
|
+
}),
|
|
1215
1244
|
fieldWeights: types.fieldWeights,
|
|
1216
1245
|
filterLabel: types.string,
|
|
1217
1246
|
fuzziness: types.fuzziness,
|
|
@@ -1335,7 +1364,11 @@ var SearchBox = defineComponent({
|
|
|
1335
1364
|
if (this.$options.isTagsMode) {
|
|
1336
1365
|
cause = causes.SUGGESTION_SELECT;
|
|
1337
1366
|
}
|
|
1338
|
-
|
|
1367
|
+
if (this.$props.value === undefined) {
|
|
1368
|
+
this.setValue(newVal, newVal === '', this.$props, cause, false);
|
|
1369
|
+
} else {
|
|
1370
|
+
this.setValue(newVal || '', true, this.$props, cause);
|
|
1371
|
+
}
|
|
1339
1372
|
}
|
|
1340
1373
|
},
|
|
1341
1374
|
focusShortcuts: function focusShortcuts() {
|
|
@@ -1423,6 +1456,20 @@ var SearchBox = defineComponent({
|
|
|
1423
1456
|
}
|
|
1424
1457
|
},
|
|
1425
1458
|
methods: {
|
|
1459
|
+
renderTriggerMessage: function renderTriggerMessage() {
|
|
1460
|
+
if (this.$props.enableAI) {
|
|
1461
|
+
if (this.$props.AIUIConfig && this.$props.AIUIConfig.renderTriggerMessage) {
|
|
1462
|
+
return this.$props.AIUIConfig.renderTriggerMessage;
|
|
1463
|
+
}
|
|
1464
|
+
if (this.$slots.renderTriggerMessage) {
|
|
1465
|
+
return this.$slots.renderTriggerMessage();
|
|
1466
|
+
}
|
|
1467
|
+
if (this.currentTriggerMode === AI_TRIGGER_MODES.MANUAL && (this.$props.AIUIConfig ? !this.$props.AIUIConfig.askButton : true)) {
|
|
1468
|
+
return 'Click to trigger AIAnswer';
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return null;
|
|
1472
|
+
},
|
|
1426
1473
|
handleText: function handleText(value, cause) {
|
|
1427
1474
|
if (cause === causes.CLEAR_VALUE) {
|
|
1428
1475
|
this.triggerCustomQuery(value);
|
|
@@ -1447,8 +1494,8 @@ var SearchBox = defineComponent({
|
|
|
1447
1494
|
value: currentValue,
|
|
1448
1495
|
resultStats: this.stats,
|
|
1449
1496
|
AIData: {
|
|
1450
|
-
question: this.
|
|
1451
|
-
answer: this.
|
|
1497
|
+
question: this.mergedAIQuestion,
|
|
1498
|
+
answer: this.mergedAIAnswer,
|
|
1452
1499
|
documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
|
|
1453
1500
|
showAIScreen: this.showAIScreen,
|
|
1454
1501
|
sources: this.getAISourceObjects(),
|
|
@@ -1479,7 +1526,7 @@ var SearchBox = defineComponent({
|
|
|
1479
1526
|
this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
|
|
1480
1527
|
}
|
|
1481
1528
|
},
|
|
1482
|
-
setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
|
|
1529
|
+
setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue, shouldExecuteQuery) {
|
|
1483
1530
|
var _this2 = this;
|
|
1484
1531
|
if (isDefaultValue === void 0) {
|
|
1485
1532
|
isDefaultValue = false;
|
|
@@ -1493,6 +1540,9 @@ var SearchBox = defineComponent({
|
|
|
1493
1540
|
if (categoryValue === void 0) {
|
|
1494
1541
|
categoryValue = undefined;
|
|
1495
1542
|
}
|
|
1543
|
+
if (shouldExecuteQuery === void 0) {
|
|
1544
|
+
shouldExecuteQuery = true;
|
|
1545
|
+
}
|
|
1496
1546
|
var performUpdate = function performUpdate() {
|
|
1497
1547
|
if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
|
|
1498
1548
|
return;
|
|
@@ -1521,24 +1571,31 @@ var SearchBox = defineComponent({
|
|
|
1521
1571
|
if (_this2.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
|
|
1522
1572
|
queryHandlerValue = Array.isArray(_this2.selectedTags) && _this2.selectedTags.length ? _this2.selectedTags : undefined;
|
|
1523
1573
|
}
|
|
1574
|
+
if ((_this2.faqAnswer || _this2.faqQuestion) && value === '') {
|
|
1575
|
+
// Empty the previous state
|
|
1576
|
+
_this2.faqAnswer = '';
|
|
1577
|
+
_this2.faqQuestion = '';
|
|
1578
|
+
_this2.showAIScreen = false;
|
|
1579
|
+
}
|
|
1524
1580
|
if (isDefaultValue) {
|
|
1525
1581
|
if (_this2.$props.autosuggest) {
|
|
1526
1582
|
if (toggleIsOpen) {
|
|
1527
1583
|
_this2.isOpen = false;
|
|
1528
1584
|
}
|
|
1529
|
-
if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
|
|
1585
|
+
if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI && _this2.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && _this2.currentValue.endsWith('?') ? {
|
|
1530
1586
|
enableAI: true
|
|
1531
|
-
} : {});
|
|
1587
|
+
} : {}, shouldExecuteQuery);
|
|
1532
1588
|
} // in case of strict selection only SUGGESTION_SELECT should be able
|
|
1533
1589
|
// to set the query otherwise the value should reset
|
|
1534
1590
|
if (props.strictSelection) {
|
|
1535
1591
|
if (cause === causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
|
|
1536
|
-
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
|
|
1592
|
+
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
|
|
1537
1593
|
} else {
|
|
1538
1594
|
_this2.setValue('', true);
|
|
1539
1595
|
}
|
|
1540
1596
|
} else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
|
|
1541
|
-
_this2.
|
|
1597
|
+
_this2.showAIScreen = false;
|
|
1598
|
+
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
|
|
1542
1599
|
}
|
|
1543
1600
|
} else {
|
|
1544
1601
|
// debounce for handling text while typing
|
|
@@ -1549,10 +1606,13 @@ var SearchBox = defineComponent({
|
|
|
1549
1606
|
};
|
|
1550
1607
|
checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
|
|
1551
1608
|
},
|
|
1552
|
-
triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
|
|
1609
|
+
triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta, shouldExecuteQuery) {
|
|
1553
1610
|
if (meta === void 0) {
|
|
1554
1611
|
meta = {};
|
|
1555
1612
|
}
|
|
1613
|
+
if (shouldExecuteQuery === void 0) {
|
|
1614
|
+
shouldExecuteQuery = true;
|
|
1615
|
+
}
|
|
1556
1616
|
if (!this.$props.autosuggest) {
|
|
1557
1617
|
return;
|
|
1558
1618
|
}
|
|
@@ -1573,12 +1633,15 @@ var SearchBox = defineComponent({
|
|
|
1573
1633
|
value: value,
|
|
1574
1634
|
componentType: componentTypes.searchBox,
|
|
1575
1635
|
meta: meta
|
|
1576
|
-
});
|
|
1636
|
+
}, shouldExecuteQuery);
|
|
1577
1637
|
},
|
|
1578
|
-
triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
|
|
1638
|
+
triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue, shouldExecuteQuery) {
|
|
1579
1639
|
if (categoryValue === void 0) {
|
|
1580
1640
|
categoryValue = undefined;
|
|
1581
1641
|
}
|
|
1642
|
+
if (shouldExecuteQuery === void 0) {
|
|
1643
|
+
shouldExecuteQuery = true;
|
|
1644
|
+
}
|
|
1582
1645
|
var _this$$props = this.$props,
|
|
1583
1646
|
customQuery = _this$$props.customQuery,
|
|
1584
1647
|
filterLabel = _this$$props.filterLabel,
|
|
@@ -1607,7 +1670,7 @@ var SearchBox = defineComponent({
|
|
|
1607
1670
|
URLParams: URLParams,
|
|
1608
1671
|
componentType: componentTypes.searchBox,
|
|
1609
1672
|
category: categoryValue
|
|
1610
|
-
});
|
|
1673
|
+
}, shouldExecuteQuery);
|
|
1611
1674
|
},
|
|
1612
1675
|
handleFocus: function handleFocus(event) {
|
|
1613
1676
|
if (this.$props.autosuggest) {
|
|
@@ -1618,7 +1681,9 @@ var SearchBox = defineComponent({
|
|
|
1618
1681
|
handleVoiceResults: function handleVoiceResults(_ref) {
|
|
1619
1682
|
var results = _ref.results;
|
|
1620
1683
|
if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
|
|
1684
|
+
var _this$$refs2;
|
|
1621
1685
|
this.setValue(results[0][0].transcript.trim(), true);
|
|
1686
|
+
(_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[this.$props.innerRef]) == null || (_this$$refs2 = _this$$refs2.$el) == null ? void 0 : _this$$refs2.focus(); // eslint-disable-line
|
|
1622
1687
|
}
|
|
1623
1688
|
},
|
|
1624
1689
|
triggerQuery: function triggerQuery(_ref2) {
|
|
@@ -1658,6 +1723,8 @@ var SearchBox = defineComponent({
|
|
|
1658
1723
|
clearValue: function clearValue() {
|
|
1659
1724
|
this.setValue('', false, this.$props, !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined, false);
|
|
1660
1725
|
this.onValueSelectedHandler('', !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined);
|
|
1726
|
+
this.showAIScreen = false;
|
|
1727
|
+
this.isOpen = false;
|
|
1661
1728
|
},
|
|
1662
1729
|
handleKeyDown: function handleKeyDown(event, highlightedIndex) {
|
|
1663
1730
|
if (highlightedIndex === void 0) {
|
|
@@ -1670,9 +1737,10 @@ var SearchBox = defineComponent({
|
|
|
1670
1737
|
} else if (highlightedIndex === null) {
|
|
1671
1738
|
this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined,
|
|
1672
1739
|
// to handle tags
|
|
1673
|
-
!this.$props.enableAI);
|
|
1674
|
-
if (this.$props.enableAI && !this.showAIScreen) {
|
|
1740
|
+
!(this.$props.enableAI && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')));
|
|
1741
|
+
if (this.$props.enableAI && !this.showAIScreen && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')) {
|
|
1675
1742
|
this.showAIScreen = true;
|
|
1743
|
+
this.isOpen = true;
|
|
1676
1744
|
}
|
|
1677
1745
|
this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
|
|
1678
1746
|
}
|
|
@@ -1693,7 +1761,7 @@ var SearchBox = defineComponent({
|
|
|
1693
1761
|
}
|
|
1694
1762
|
var value = this.$props.value;
|
|
1695
1763
|
if (value === undefined) {
|
|
1696
|
-
this.setValue(inputValue,
|
|
1764
|
+
this.setValue(inputValue, inputValue === '', this.$props, undefined, false);
|
|
1697
1765
|
} else {
|
|
1698
1766
|
this.$emit('change', inputValue, function (_ref3) {
|
|
1699
1767
|
var isOpen = _ref3.isOpen;
|
|
@@ -1708,7 +1776,7 @@ var SearchBox = defineComponent({
|
|
|
1708
1776
|
},
|
|
1709
1777
|
handleFeaturedSuggestionClicked: function handleFeaturedSuggestionClicked(suggestion) {
|
|
1710
1778
|
try {
|
|
1711
|
-
var _this$$
|
|
1779
|
+
var _this$$refs3;
|
|
1712
1780
|
if (suggestion.action === featuredSuggestionsActionTypes.NAVIGATE) {
|
|
1713
1781
|
var _JSON$parse = JSON.parse(suggestion.subAction),
|
|
1714
1782
|
_JSON$parse$target = _JSON$parse.target,
|
|
@@ -1727,7 +1795,7 @@ var SearchBox = defineComponent({
|
|
|
1727
1795
|
func(suggestion, this.$data.currentValue, this.$props.customEvents);
|
|
1728
1796
|
}
|
|
1729
1797
|
if (suggestion.action === featuredSuggestionsActionTypes.SELECT) {
|
|
1730
|
-
this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS);
|
|
1798
|
+
this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS, false);
|
|
1731
1799
|
this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT);
|
|
1732
1800
|
}
|
|
1733
1801
|
// blur is important to close the dropdown
|
|
@@ -1735,21 +1803,41 @@ var SearchBox = defineComponent({
|
|
|
1735
1803
|
// else Downshift probably is focusing the dropdown
|
|
1736
1804
|
// and not letting it close
|
|
1737
1805
|
// eslint-disable-next-line no-unused-expressions
|
|
1738
|
-
(_this$$
|
|
1806
|
+
(_this$$refs3 = this.$refs) == null || (_this$$refs3 = _this$$refs3[this.$props.innerRef]) == null || (_this$$refs3 = _this$$refs3.el) == null ? void 0 : _this$$refs3.blur();
|
|
1739
1807
|
} catch (e) {
|
|
1740
1808
|
console.error("Error: There was an error parsing the subAction for the featured suggestion with label, \"" + suggestion.label + "\"", e);
|
|
1741
1809
|
}
|
|
1742
1810
|
},
|
|
1743
1811
|
onSuggestionSelected: function onSuggestionSelected(suggestion) {
|
|
1744
1812
|
var _this4 = this;
|
|
1745
|
-
|
|
1813
|
+
var value = this.$props.value;
|
|
1814
|
+
// The state of the suggestion is open by the time it reaches here. i.e. isOpen = true
|
|
1815
|
+
// handle when FAQ suggestion is clicked
|
|
1816
|
+
if (suggestion && suggestion._suggestion_type === suggestionTypes.FAQ) {
|
|
1817
|
+
this.currentValue = suggestion.value;
|
|
1818
|
+
// Handle AI
|
|
1819
|
+
// Independent of enableAI.
|
|
1820
|
+
this.faqAnswer = suggestion._answer;
|
|
1821
|
+
this.faqQuestion = suggestion.value;
|
|
1822
|
+
this.isOpen = true;
|
|
1746
1823
|
this.showAIScreen = true;
|
|
1824
|
+
if (value !== undefined) this.$emit('change', suggestion.value, function () {});
|
|
1825
|
+
this.onValueSelectedHandler(suggestion.value);
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
if (suggestion && suggestion._suggestion_type === '_internal_a_i_trigger') {
|
|
1829
|
+
this.showAIScreen = true;
|
|
1830
|
+
this.askButtonOnClick();
|
|
1831
|
+
return;
|
|
1747
1832
|
}
|
|
1748
|
-
var value = this.$props.value;
|
|
1749
1833
|
|
|
1750
1834
|
// handle featured suggestions click event
|
|
1751
1835
|
if (suggestion._suggestion_type === suggestionTypes.Featured) {
|
|
1752
1836
|
this.handleFeaturedSuggestionClicked(suggestion);
|
|
1837
|
+
// Handle AI
|
|
1838
|
+
if (!this.$props.enableAI) this.isOpen = false;else {
|
|
1839
|
+
this.showAIScreen = true;
|
|
1840
|
+
}
|
|
1753
1841
|
return;
|
|
1754
1842
|
}
|
|
1755
1843
|
// Record analytics for selected suggestions
|
|
@@ -1779,6 +1867,11 @@ var SearchBox = defineComponent({
|
|
|
1779
1867
|
});
|
|
1780
1868
|
}
|
|
1781
1869
|
this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
|
|
1870
|
+
|
|
1871
|
+
// Handle AI
|
|
1872
|
+
if (!this.$props.enableAI) this.isOpen = false;else if (this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && suggestion.value.endsWith('?')) {
|
|
1873
|
+
this.showAIScreen = true;
|
|
1874
|
+
}
|
|
1782
1875
|
},
|
|
1783
1876
|
onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
|
|
1784
1877
|
if (currentValue === void 0) {
|
|
@@ -2022,14 +2115,14 @@ var SearchBox = defineComponent({
|
|
|
2022
2115
|
})]);
|
|
2023
2116
|
},
|
|
2024
2117
|
focusSearchBox: function focusSearchBox(event) {
|
|
2025
|
-
var _this$$
|
|
2118
|
+
var _this$$refs4;
|
|
2026
2119
|
var elt = event.target || event.srcElement;
|
|
2027
2120
|
var tagName = elt.tagName;
|
|
2028
2121
|
if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
|
|
2029
2122
|
// already in an input
|
|
2030
2123
|
return;
|
|
2031
2124
|
}
|
|
2032
|
-
(_this$$
|
|
2125
|
+
(_this$$refs4 = this.$refs) == null || (_this$$refs4 = _this$$refs4[this.$props.innerRef]) == null || (_this$$refs4 = _this$$refs4.$el) == null ? void 0 : _this$$refs4.focus(); // eslint-disable-line
|
|
2033
2126
|
},
|
|
2034
2127
|
listenForFocusShortcuts: function listenForFocusShortcuts() {
|
|
2035
2128
|
var _this9 = this;
|
|
@@ -2248,8 +2341,8 @@ var SearchBox = defineComponent({
|
|
|
2248
2341
|
var customAIRenderer = this.$props.renderAIAnswer || this.$slots.renderAIAnswer;
|
|
2249
2342
|
if (customAIRenderer) {
|
|
2250
2343
|
return customAIRenderer({
|
|
2251
|
-
question: this.
|
|
2252
|
-
answer: this.
|
|
2344
|
+
question: this.mergedAIQuestion,
|
|
2345
|
+
answer: this.mergedAIAnswer,
|
|
2253
2346
|
documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
|
|
2254
2347
|
loading: this.isAIResponseLoading || this.isLoading,
|
|
2255
2348
|
sources: this.getAISourceObjects(),
|
|
@@ -2260,7 +2353,7 @@ var SearchBox = defineComponent({
|
|
|
2260
2353
|
return this.renderAIScreenLoader();
|
|
2261
2354
|
}
|
|
2262
2355
|
return createVNode("div", null, [createVNode(Answer, {
|
|
2263
|
-
"innerHTML": md.render(this.
|
|
2356
|
+
"innerHTML": md.render(this.mergedAIAnswer)
|
|
2264
2357
|
}, null), this.renderAIScreenFooter(), this.showFeedbackComponent && createVNode("div", {
|
|
2265
2358
|
"class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
|
|
2266
2359
|
}, [createVNode(AIFeedback, {
|
|
@@ -2446,23 +2539,43 @@ var SearchBox = defineComponent({
|
|
|
2446
2539
|
var suggestionsHaveIcon = item.some(function (s) {
|
|
2447
2540
|
return s.icon || s.iconURL;
|
|
2448
2541
|
});
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2542
|
+
if (renderItem) {
|
|
2543
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2544
|
+
item: sectionItem
|
|
2545
|
+
}), _transformOn(getItemEvents({
|
|
2546
|
+
item: sectionItem
|
|
2547
|
+
})), {
|
|
2548
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2549
|
+
"style": {
|
|
2550
|
+
justifyContent: 'flex-start',
|
|
2551
|
+
alignItems: 'center'
|
|
2552
|
+
},
|
|
2553
|
+
"class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
|
|
2554
|
+
}), [renderItem(sectionItem)]);
|
|
2555
|
+
}
|
|
2556
|
+
if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
|
|
2557
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2558
|
+
item: sectionItem
|
|
2559
|
+
}), _transformOn(getItemEvents({
|
|
2560
|
+
item: sectionItem
|
|
2561
|
+
})), {
|
|
2562
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2563
|
+
"style": {
|
|
2564
|
+
justifyContent: 'flex-start',
|
|
2565
|
+
alignItems: 'center'
|
|
2566
|
+
},
|
|
2567
|
+
"class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
|
|
2568
|
+
}), [createVNode(SuggestionItem, {
|
|
2569
|
+
"currentValue": _this16.currentValue,
|
|
2570
|
+
"suggestion": sectionItem
|
|
2571
|
+
}, null)]);
|
|
2572
|
+
}
|
|
2573
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2461
2574
|
item: sectionItem
|
|
2462
2575
|
}), _transformOn(getItemEvents({
|
|
2463
2576
|
item: sectionItem
|
|
2464
2577
|
})), {
|
|
2465
|
-
"key": index + sectionIndex,
|
|
2578
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2466
2579
|
"style": {
|
|
2467
2580
|
justifyContent: 'flex-start',
|
|
2468
2581
|
alignItems: 'center'
|
|
@@ -2677,6 +2790,7 @@ SBConnected.install = function (Vue) {
|
|
|
2677
2790
|
// Add componentType for SSR
|
|
2678
2791
|
SBConnected.componentType = componentTypes.searchBox;
|
|
2679
2792
|
|
|
2793
|
+
var _excluded$1 = ["_source"];
|
|
2680
2794
|
function _isSlot$1(s) {
|
|
2681
2795
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
2682
2796
|
}
|
|
@@ -2684,7 +2798,9 @@ var md$1 = new Remarkable();
|
|
|
2684
2798
|
md$1.set({
|
|
2685
2799
|
html: true,
|
|
2686
2800
|
breaks: true,
|
|
2687
|
-
xhtmlOut: true
|
|
2801
|
+
xhtmlOut: true,
|
|
2802
|
+
linkify: true,
|
|
2803
|
+
linkTarget: '_blank'
|
|
2688
2804
|
});
|
|
2689
2805
|
var _inputWrapperRef = 'inputWrapperRef';
|
|
2690
2806
|
var _inputRef = 'inputRef';
|
|
@@ -2697,7 +2813,10 @@ var AIAnswer = defineComponent({
|
|
|
2697
2813
|
messages: [],
|
|
2698
2814
|
inputMessage: '',
|
|
2699
2815
|
AISessionId: '',
|
|
2700
|
-
error: null
|
|
2816
|
+
error: null,
|
|
2817
|
+
sourceDocIds: null,
|
|
2818
|
+
initialHits: null,
|
|
2819
|
+
isTriggered: false
|
|
2701
2820
|
};
|
|
2702
2821
|
this.internalComponent = props.componentId + "__internal";
|
|
2703
2822
|
return this.__state;
|
|
@@ -2707,7 +2826,16 @@ var AIAnswer = defineComponent({
|
|
|
2707
2826
|
from: 'theme_reactivesearch'
|
|
2708
2827
|
}
|
|
2709
2828
|
},
|
|
2710
|
-
created: function created() {
|
|
2829
|
+
created: function created() {
|
|
2830
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
|
|
2831
|
+
this.isTriggered = true;
|
|
2832
|
+
} else if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
|
|
2833
|
+
this.isTriggered = true;
|
|
2834
|
+
if (this.AISessionId) {
|
|
2835
|
+
this.handleSendMessage(null, false, '', true);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
},
|
|
2711
2839
|
computed: {
|
|
2712
2840
|
hasCustomRenderer: function hasCustomRenderer$1() {
|
|
2713
2841
|
return hasCustomRenderer(this);
|
|
@@ -2720,6 +2848,9 @@ var AIAnswer = defineComponent({
|
|
|
2720
2848
|
},
|
|
2721
2849
|
errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
|
|
2722
2850
|
return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
|
|
2851
|
+
},
|
|
2852
|
+
hasTriggered: function hasTriggered() {
|
|
2853
|
+
return this.isTriggered;
|
|
2723
2854
|
}
|
|
2724
2855
|
},
|
|
2725
2856
|
props: {
|
|
@@ -2758,13 +2889,26 @@ var AIAnswer = defineComponent({
|
|
|
2758
2889
|
sessionIdFromStore: VueTypes.string,
|
|
2759
2890
|
showComponent: types.boolRequired,
|
|
2760
2891
|
componentError: types.componentObject,
|
|
2761
|
-
style: types.style
|
|
2892
|
+
style: types.style,
|
|
2893
|
+
showSourceDocuments: VueTypes.bool.def(false),
|
|
2894
|
+
renderSourceDocument: types.func,
|
|
2895
|
+
onSourceClick: types.func,
|
|
2896
|
+
isAITyping: types.boolRequired,
|
|
2897
|
+
triggerOn: VueTypes.string.def(AI_TRIGGER_MODES.ALWAYS),
|
|
2898
|
+
renderTriggerMessage: types.func
|
|
2762
2899
|
},
|
|
2763
2900
|
mounted: function mounted() {},
|
|
2764
2901
|
watch: {
|
|
2765
2902
|
AIResponse: function AIResponse(newVal) {
|
|
2766
2903
|
if (newVal) {
|
|
2767
|
-
this.
|
|
2904
|
+
if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
|
|
2905
|
+
this.sourceDocIds = newVal.response.answer.documentIds;
|
|
2906
|
+
var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
|
|
2907
|
+
if (localCache && localCache.meta && localCache.meta.hits) {
|
|
2908
|
+
this.initialHits = localCache.meta.hits;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2768
2912
|
var messagesHistory = newVal.messages,
|
|
2769
2913
|
response = newVal.response;
|
|
2770
2914
|
var finalMessages = [];
|
|
@@ -2775,7 +2919,7 @@ var AIAnswer = defineComponent({
|
|
|
2775
2919
|
}
|
|
2776
2920
|
|
|
2777
2921
|
// pushing message history so far
|
|
2778
|
-
if (messagesHistory &&
|
|
2922
|
+
if (messagesHistory && Array.isArray(messagesHistory)) {
|
|
2779
2923
|
finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
|
|
2780
2924
|
return msg.role !== AI_ROLES.SYSTEM;
|
|
2781
2925
|
}));
|
|
@@ -2800,6 +2944,9 @@ var AIAnswer = defineComponent({
|
|
|
2800
2944
|
loading: this.$props.isAIResponseLoading || this.$props.isLoading,
|
|
2801
2945
|
error: this.$props.AIResponseError
|
|
2802
2946
|
});
|
|
2947
|
+
if (newVal && newVal.hits && newVal.hits.hits) {
|
|
2948
|
+
this.initialHits = newVal.hits.hits;
|
|
2949
|
+
}
|
|
2803
2950
|
},
|
|
2804
2951
|
isAIResponseLoading: function isAIResponseLoading(newVal) {
|
|
2805
2952
|
this.$emit('on-data', {
|
|
@@ -2824,7 +2971,7 @@ var AIAnswer = defineComponent({
|
|
|
2824
2971
|
},
|
|
2825
2972
|
AIResponseError: function AIResponseError(newVal) {
|
|
2826
2973
|
this.error = newVal;
|
|
2827
|
-
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId ||
|
|
2974
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2828
2975
|
if (this.error && !this.AISessionId) {
|
|
2829
2976
|
var errorMessage = this.errorMessageForMissingSessionId;
|
|
2830
2977
|
this.error = {
|
|
@@ -2845,7 +2992,7 @@ var AIAnswer = defineComponent({
|
|
|
2845
2992
|
componentError: function componentError(newVal) {
|
|
2846
2993
|
var _this = this;
|
|
2847
2994
|
if (newVal && newVal._bodyBlob) {
|
|
2848
|
-
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId ||
|
|
2995
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2849
2996
|
if (!this.AISessionId) {
|
|
2850
2997
|
this.generateNewSessionId();
|
|
2851
2998
|
}
|
|
@@ -2868,23 +3015,154 @@ var AIAnswer = defineComponent({
|
|
|
2868
3015
|
console.error('Error reading component error text data:', error);
|
|
2869
3016
|
});
|
|
2870
3017
|
}
|
|
3018
|
+
},
|
|
3019
|
+
showComponent: function showComponent() {
|
|
3020
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
|
|
3021
|
+
this.isTriggered = true;
|
|
3022
|
+
}
|
|
3023
|
+
},
|
|
3024
|
+
dependentComponentValue: function dependentComponentValue(newVal) {
|
|
3025
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
|
|
3026
|
+
this.isTriggered = true;
|
|
3027
|
+
if (this.AISessionId) {
|
|
3028
|
+
this.handleSendMessage(null, false, '', true);
|
|
3029
|
+
}
|
|
3030
|
+
} else if (this.hasTriggered && this.$props.triggerOn !== AI_TRIGGER_MODES.ALWAYS) {
|
|
3031
|
+
this.isTriggered = false;
|
|
3032
|
+
}
|
|
3033
|
+
},
|
|
3034
|
+
AISessionId: function AISessionId(newVal) {
|
|
3035
|
+
if (newVal) {
|
|
3036
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
|
|
3037
|
+
this.handleSendMessage(null, false, '', true);
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
},
|
|
3041
|
+
triggerOn: function triggerOn(newVal) {
|
|
3042
|
+
if (newVal === AI_TRIGGER_MODES.ALWAYS) {
|
|
3043
|
+
this.isTriggered = true;
|
|
3044
|
+
}
|
|
2871
3045
|
}
|
|
2872
3046
|
},
|
|
2873
3047
|
methods: {
|
|
2874
|
-
|
|
3048
|
+
renderTriggerMessageFunc: function renderTriggerMessageFunc() {
|
|
3049
|
+
var triggerOn = this.$props.triggerOn;
|
|
3050
|
+
if (this.$props.renderTriggerMessage) {
|
|
3051
|
+
return this.$props.renderTriggerMessage;
|
|
3052
|
+
}
|
|
3053
|
+
if (this.$slots.renderTriggerMessage) {
|
|
3054
|
+
return this.$slots.renderTriggerMessage();
|
|
3055
|
+
}
|
|
3056
|
+
if (triggerOn === AI_TRIGGER_MODES.QUESTION) {
|
|
3057
|
+
if (!this.dependentComponentValue.endsWith('?')) {
|
|
3058
|
+
return createVNode("span", null, [createVNode("span", {
|
|
3059
|
+
"role": "img",
|
|
3060
|
+
"aria-label": "bulb"
|
|
3061
|
+
}, [createTextVNode("\uD83D\uDCA1")]), createTextVNode("End your question with a question mark (?)")]);
|
|
3062
|
+
}
|
|
3063
|
+
} else if (triggerOn === AI_TRIGGER_MODES.MANUAL) {
|
|
3064
|
+
return createVNode("span", null, [createTextVNode("Click here to ask AI"), ' ', createVNode("span", {
|
|
3065
|
+
"role": "img",
|
|
3066
|
+
"aria-label": "bulb"
|
|
3067
|
+
}, [createTextVNode("\uD83E\uDD16")])]);
|
|
3068
|
+
}
|
|
3069
|
+
return null;
|
|
3070
|
+
},
|
|
3071
|
+
handleTriggerClick: function handleTriggerClick() {
|
|
3072
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.MANUAL) {
|
|
3073
|
+
this.handleSendMessage(null, false, '', true);
|
|
3074
|
+
this.isTriggered = true;
|
|
3075
|
+
}
|
|
3076
|
+
},
|
|
3077
|
+
getAISourceObjects: function getAISourceObjects() {
|
|
2875
3078
|
var _this2 = this;
|
|
3079
|
+
var sourceObjects = [];
|
|
3080
|
+
if (!this.AIResponse) return sourceObjects;
|
|
3081
|
+
var docIds = this.sourceDocIds || [];
|
|
3082
|
+
if (this.initialHits) {
|
|
3083
|
+
docIds.forEach(function (id) {
|
|
3084
|
+
var foundSourceObj = _this2.initialHits.find(function (hit) {
|
|
3085
|
+
return hit._id === id;
|
|
3086
|
+
}) || {};
|
|
3087
|
+
if (foundSourceObj) {
|
|
3088
|
+
var _foundSourceObj$_sour = foundSourceObj._source,
|
|
3089
|
+
_source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
|
|
3090
|
+
rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
|
|
3091
|
+
sourceObjects.push(_extends({}, rest, _source));
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3094
|
+
} else {
|
|
3095
|
+
sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
|
|
3096
|
+
return {
|
|
3097
|
+
_id: id
|
|
3098
|
+
};
|
|
3099
|
+
}));
|
|
3100
|
+
}
|
|
3101
|
+
return sourceObjects;
|
|
3102
|
+
},
|
|
3103
|
+
renderAIScreenFooter: function renderAIScreenFooter() {
|
|
3104
|
+
var _slot2;
|
|
3105
|
+
var _this3 = this;
|
|
3106
|
+
var _ref = this.$props || {},
|
|
3107
|
+
_ref$showSourceDocume = _ref.showSourceDocuments,
|
|
3108
|
+
showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
|
|
3109
|
+
_ref$onSourceClick = _ref.onSourceClick,
|
|
3110
|
+
onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
|
|
3111
|
+
renderSourceDocument = _ref.renderSourceDocument;
|
|
3112
|
+
var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
|
|
3113
|
+
if (this.isLoadingState || this.isAITyping) {
|
|
3114
|
+
return null;
|
|
3115
|
+
}
|
|
3116
|
+
var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
|
|
3117
|
+
if (customRenderSourceDoc) {
|
|
3118
|
+
return customRenderSourceDoc(sourceObj);
|
|
3119
|
+
}
|
|
3120
|
+
return sourceObj._id;
|
|
3121
|
+
};
|
|
3122
|
+
return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? createVNode(Footer, {
|
|
3123
|
+
"themePreset": this.$props.themePreset,
|
|
3124
|
+
"style": {
|
|
3125
|
+
marginTop: '1.5rem',
|
|
3126
|
+
background: 'inherit'
|
|
3127
|
+
}
|
|
3128
|
+
}, {
|
|
3129
|
+
"default": function _default() {
|
|
3130
|
+
return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
|
|
3131
|
+
var _slot;
|
|
3132
|
+
return createVNode(Button, {
|
|
3133
|
+
"class": "--ai-source-tag " + (getClassName$2(_this3.$props.innerClass, 'ai-source-tag') || ''),
|
|
3134
|
+
"info": true,
|
|
3135
|
+
"onClick": function onClick() {
|
|
3136
|
+
return onSourceClick && onSourceClick(el);
|
|
3137
|
+
},
|
|
3138
|
+
"key": el._id
|
|
3139
|
+
}, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
|
|
3140
|
+
"default": function _default() {
|
|
3141
|
+
return [_slot];
|
|
3142
|
+
}
|
|
3143
|
+
});
|
|
3144
|
+
})) ? _slot2 : {
|
|
3145
|
+
"default": function _default() {
|
|
3146
|
+
return [_slot2];
|
|
3147
|
+
}
|
|
3148
|
+
})];
|
|
3149
|
+
}
|
|
3150
|
+
}) : null;
|
|
3151
|
+
},
|
|
3152
|
+
generateNewSessionId: function generateNewSessionId() {
|
|
3153
|
+
var _this4 = this;
|
|
2876
3154
|
var newSessionPromise = this.createAISession();
|
|
2877
3155
|
newSessionPromise.then(function (res) {
|
|
2878
|
-
|
|
3156
|
+
_this4.AISessionId = res.AIsessionId;
|
|
2879
3157
|
})["catch"](function (e) {
|
|
2880
3158
|
console.error(e);
|
|
2881
3159
|
});
|
|
2882
3160
|
},
|
|
2883
3161
|
scrollToBottom: function scrollToBottom() {
|
|
2884
|
-
var
|
|
3162
|
+
var _this5 = this;
|
|
2885
3163
|
this.$nextTick(function () {
|
|
2886
|
-
var
|
|
2887
|
-
var messageContainer = (
|
|
3164
|
+
var _this5$$refs;
|
|
3165
|
+
var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
|
|
2888
3166
|
if (messageContainer && messageContainer.$el) {
|
|
2889
3167
|
messageContainer.$el.scrollTo({
|
|
2890
3168
|
top: messageContainer.$el.scrollHeight,
|
|
@@ -2897,24 +3175,33 @@ var AIAnswer = defineComponent({
|
|
|
2897
3175
|
this.inputMessage = e.target.value;
|
|
2898
3176
|
this.handleTextAreaHeightChange();
|
|
2899
3177
|
},
|
|
2900
|
-
handleSendMessage: function handleSendMessage(e, isRetry, text) {
|
|
3178
|
+
handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
|
|
2901
3179
|
if (isRetry === void 0) {
|
|
2902
3180
|
isRetry = false;
|
|
2903
3181
|
}
|
|
2904
3182
|
if (text === void 0) {
|
|
2905
3183
|
text = this.inputMessage;
|
|
2906
3184
|
}
|
|
3185
|
+
if (fetchMeta === void 0) {
|
|
3186
|
+
fetchMeta = false;
|
|
3187
|
+
}
|
|
2907
3188
|
if (typeof e === 'object' && e !== null) e.preventDefault();
|
|
2908
|
-
if (text.trim()) {
|
|
3189
|
+
if (text.trim() || !text && !e) {
|
|
2909
3190
|
if (this.isLoadingState) {
|
|
2910
3191
|
return;
|
|
2911
3192
|
}
|
|
2912
3193
|
if (this.AISessionId) {
|
|
2913
|
-
if (!isRetry)
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
3194
|
+
if (!isRetry) {
|
|
3195
|
+
var finalMessages = [].concat(this.messages);
|
|
3196
|
+
if (text) {
|
|
3197
|
+
finalMessages.push({
|
|
3198
|
+
content: text,
|
|
3199
|
+
role: AI_ROLES.USER
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
this.messages = [].concat(finalMessages);
|
|
3203
|
+
}
|
|
3204
|
+
this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
|
|
2918
3205
|
} else {
|
|
2919
3206
|
console.error(this.errorMessageForMissingSessionId);
|
|
2920
3207
|
this.error = {
|
|
@@ -2963,7 +3250,6 @@ var AIAnswer = defineComponent({
|
|
|
2963
3250
|
return null;
|
|
2964
3251
|
},
|
|
2965
3252
|
handleKeyPress: function handleKeyPress(e) {
|
|
2966
|
-
window.console.log('e', e);
|
|
2967
3253
|
if (e.key === 'Enter') {
|
|
2968
3254
|
this.handleSendMessage(e);
|
|
2969
3255
|
this.inputMessage = '';
|
|
@@ -2995,15 +3281,15 @@ var AIAnswer = defineComponent({
|
|
|
2995
3281
|
if (typeof window === 'undefined') return false;
|
|
2996
3282
|
return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
|
|
2997
3283
|
},
|
|
2998
|
-
handleVoiceResults: function handleVoiceResults(
|
|
2999
|
-
var results =
|
|
3284
|
+
handleVoiceResults: function handleVoiceResults(_ref2) {
|
|
3285
|
+
var results = _ref2.results;
|
|
3000
3286
|
if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
|
|
3001
3287
|
this.handleSendMessage(null, false, results[0][0].transcript.trim());
|
|
3002
3288
|
}
|
|
3003
3289
|
},
|
|
3004
3290
|
renderIcons: function renderIcons() {
|
|
3005
|
-
var
|
|
3006
|
-
var
|
|
3291
|
+
var _this6 = this;
|
|
3292
|
+
var _slot3, _slot4;
|
|
3007
3293
|
var _this$$props = this.$props,
|
|
3008
3294
|
getMicInstance = _this$$props.getMicInstance,
|
|
3009
3295
|
showVoiceInput = _this$$props.showVoiceInput,
|
|
@@ -3016,14 +3302,14 @@ var AIAnswer = defineComponent({
|
|
|
3016
3302
|
"positionType": "absolute"
|
|
3017
3303
|
}, {
|
|
3018
3304
|
"default": function _default() {
|
|
3019
|
-
return [!
|
|
3305
|
+
return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && createVNode(Mic, {
|
|
3020
3306
|
"getInstance": getMicInstance,
|
|
3021
3307
|
"render": renderMic,
|
|
3022
|
-
"handleResult":
|
|
3308
|
+
"handleResult": _this6.handleVoiceResults,
|
|
3023
3309
|
"class": getClassName$2(innerClass, 'ai-search-mic') || null
|
|
3024
|
-
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(
|
|
3310
|
+
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
|
|
3025
3311
|
"default": function _default() {
|
|
3026
|
-
return [
|
|
3312
|
+
return [_slot3];
|
|
3027
3313
|
}
|
|
3028
3314
|
})];
|
|
3029
3315
|
}
|
|
@@ -3033,9 +3319,9 @@ var AIAnswer = defineComponent({
|
|
|
3033
3319
|
"positionType": "absolute"
|
|
3034
3320
|
}, {
|
|
3035
3321
|
"default": function _default() {
|
|
3036
|
-
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(
|
|
3322
|
+
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
|
|
3037
3323
|
"default": function _default() {
|
|
3038
|
-
return [
|
|
3324
|
+
return [_slot4];
|
|
3039
3325
|
}
|
|
3040
3326
|
})];
|
|
3041
3327
|
}
|
|
@@ -3045,7 +3331,7 @@ var AIAnswer = defineComponent({
|
|
|
3045
3331
|
this.handleSendMessage(e);
|
|
3046
3332
|
},
|
|
3047
3333
|
renderEnterButtonElement: function renderEnterButtonElement() {
|
|
3048
|
-
var
|
|
3334
|
+
var _this7 = this;
|
|
3049
3335
|
var _this$$props2 = this.$props,
|
|
3050
3336
|
enterButton = _this$$props2.enterButton,
|
|
3051
3337
|
innerClass = _this$$props2.innerClass;
|
|
@@ -3053,16 +3339,16 @@ var AIAnswer = defineComponent({
|
|
|
3053
3339
|
if (enterButton) {
|
|
3054
3340
|
var getEnterButtonMarkup = function getEnterButtonMarkup() {
|
|
3055
3341
|
if (renderEnterButton) {
|
|
3056
|
-
return renderEnterButton(
|
|
3342
|
+
return renderEnterButton(_this7.enterButtonOnClick);
|
|
3057
3343
|
}
|
|
3058
3344
|
return createVNode(SendButton, {
|
|
3059
3345
|
"primary": true,
|
|
3060
3346
|
"type": "submit",
|
|
3061
3347
|
"tabIndex": 0,
|
|
3062
|
-
"onClick":
|
|
3063
|
-
"onKeyPress":
|
|
3348
|
+
"onClick": _this7.handleSendMessage,
|
|
3349
|
+
"onKeyPress": _this7.handleKeyPress,
|
|
3064
3350
|
"class": "ask-btn " + getClassName$2(innerClass, 'ai-enter-button'),
|
|
3065
|
-
"disabled":
|
|
3351
|
+
"disabled": _this7.isLoadingState || !_this7.AISessionId
|
|
3066
3352
|
}, {
|
|
3067
3353
|
"default": function _default() {
|
|
3068
3354
|
return [createTextVNode("Send")];
|
|
@@ -3105,6 +3391,20 @@ var AIAnswer = defineComponent({
|
|
|
3105
3391
|
}
|
|
3106
3392
|
this.$forceUpdate();
|
|
3107
3393
|
}
|
|
3394
|
+
},
|
|
3395
|
+
getTitle: function getTitle() {
|
|
3396
|
+
var _this8 = this;
|
|
3397
|
+
var hasTitle = this.$props.title || this.$slots.title || null;
|
|
3398
|
+
if (hasTitle) {
|
|
3399
|
+
return createVNode(Title, {
|
|
3400
|
+
"class": getClassName$2(this.$props.innerClass, 'ai-title') || null
|
|
3401
|
+
}, {
|
|
3402
|
+
"default": function _default() {
|
|
3403
|
+
return [_this8.$props.title || _this8.$slots.title()];
|
|
3404
|
+
}
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
return null;
|
|
3108
3408
|
}
|
|
3109
3409
|
},
|
|
3110
3410
|
beforeUnmount: function beforeUnmount() {
|
|
@@ -3119,55 +3419,62 @@ var AIAnswer = defineComponent({
|
|
|
3119
3419
|
}
|
|
3120
3420
|
},
|
|
3121
3421
|
render: function render() {
|
|
3122
|
-
var
|
|
3123
|
-
var
|
|
3422
|
+
var _slot5;
|
|
3423
|
+
var _this9 = this;
|
|
3124
3424
|
var props = this.$props;
|
|
3125
3425
|
if (!this.shouldShowComponent) {
|
|
3126
3426
|
return null;
|
|
3127
3427
|
}
|
|
3428
|
+
if (!this.isTriggered) {
|
|
3429
|
+
return createVNode(Chatbox, {
|
|
3430
|
+
"style": props.style || {}
|
|
3431
|
+
}, {
|
|
3432
|
+
"default": function _default() {
|
|
3433
|
+
return [_this9.getTitle(), createVNode("div", {
|
|
3434
|
+
"class": "--trigger-message-wrapper",
|
|
3435
|
+
"onClick": _this9.handleTriggerClick,
|
|
3436
|
+
"aria-hidden": "true"
|
|
3437
|
+
}, [_this9.renderTriggerMessageFunc()])];
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3128
3441
|
return createVNode(Chatbox, {
|
|
3129
3442
|
"style": props.style || {}
|
|
3130
3443
|
}, {
|
|
3131
3444
|
"default": function _default() {
|
|
3132
|
-
return [
|
|
3133
|
-
"class": getClassName$2(_this6.$props.innerClass, 'title') || ''
|
|
3134
|
-
}, {
|
|
3135
|
-
"default": function _default() {
|
|
3136
|
-
return [_this6.$props.title];
|
|
3137
|
-
}
|
|
3138
|
-
}), createVNode(ChatContainer, {
|
|
3445
|
+
return [_this9.getTitle(), createVNode(ChatContainer, {
|
|
3139
3446
|
"class": "--ai-chat-container",
|
|
3140
3447
|
"theme": props.theme,
|
|
3141
3448
|
"showInput": props.showInput
|
|
3142
3449
|
}, {
|
|
3143
3450
|
"default": function _default() {
|
|
3144
|
-
return [
|
|
3145
|
-
"themePreset":
|
|
3451
|
+
return [_this9.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3452
|
+
"themePreset": _this9.themePreset,
|
|
3146
3453
|
"theme": props.theme,
|
|
3147
|
-
"ref":
|
|
3454
|
+
"ref": _this9.$props.innerRef,
|
|
3148
3455
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
3149
|
-
}, _isSlot$1(
|
|
3456
|
+
}, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
|
|
3150
3457
|
"default": function _default() {
|
|
3151
|
-
return [
|
|
3458
|
+
return [_slot5];
|
|
3152
3459
|
}
|
|
3153
|
-
}), !
|
|
3154
|
-
"themePreset":
|
|
3460
|
+
}), !_this9.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3461
|
+
"themePreset": _this9.themePreset,
|
|
3155
3462
|
"theme": props.theme,
|
|
3156
|
-
"ref":
|
|
3463
|
+
"ref": _this9.$props.innerRef,
|
|
3157
3464
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
3158
3465
|
}, {
|
|
3159
3466
|
"default": function _default() {
|
|
3160
|
-
return [
|
|
3467
|
+
return [_this9.messages.map(function (message, index) {
|
|
3161
3468
|
return createVNode(Message, {
|
|
3162
3469
|
"key": index,
|
|
3163
3470
|
"isSender": message.role === AI_ROLES.USER,
|
|
3164
3471
|
"innerHTML": md$1.render(message.content),
|
|
3165
|
-
"themePreset":
|
|
3472
|
+
"themePreset": _this9.themePreset,
|
|
3166
3473
|
"theme": props.theme,
|
|
3167
3474
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
|
|
3168
3475
|
}, null);
|
|
3169
|
-
}),
|
|
3170
|
-
"themePreset":
|
|
3476
|
+
}), _this9.isLoadingState && createVNode(Message, {
|
|
3477
|
+
"themePreset": _this9.themePreset,
|
|
3171
3478
|
"theme": props.theme,
|
|
3172
3479
|
"isSender": false,
|
|
3173
3480
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || null)
|
|
@@ -3176,31 +3483,31 @@ var AIAnswer = defineComponent({
|
|
|
3176
3483
|
return [createVNode(TypingIndicator, null, {
|
|
3177
3484
|
"default": function _default() {
|
|
3178
3485
|
return [createVNode(TypingDot, {
|
|
3179
|
-
"themePreset":
|
|
3486
|
+
"themePreset": _this9.themePreset
|
|
3180
3487
|
}, null), createVNode(TypingDot, {
|
|
3181
|
-
"themePreset":
|
|
3488
|
+
"themePreset": _this9.themePreset
|
|
3182
3489
|
}, null), createVNode(TypingDot, {
|
|
3183
|
-
"themePreset":
|
|
3490
|
+
"themePreset": _this9.themePreset
|
|
3184
3491
|
}, null)];
|
|
3185
3492
|
}
|
|
3186
3493
|
})];
|
|
3187
3494
|
}
|
|
3188
3495
|
})];
|
|
3189
3496
|
}
|
|
3190
|
-
}),
|
|
3497
|
+
}), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && createVNode("div", {
|
|
3191
3498
|
"class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
|
|
3192
3499
|
}, [createVNode(AIFeedback, {
|
|
3193
|
-
"hideUI":
|
|
3194
|
-
"key":
|
|
3500
|
+
"hideUI": _this9.isLoadingState || !_this9.sessionId,
|
|
3501
|
+
"key": _this9.sessionId,
|
|
3195
3502
|
"onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
|
|
3196
|
-
|
|
3503
|
+
_this9.trackUsefullness(_this9.sessionId, {
|
|
3197
3504
|
useful: useful,
|
|
3198
3505
|
reason: reason
|
|
3199
3506
|
});
|
|
3200
3507
|
}
|
|
3201
|
-
}, null)]), props.showInput && createVNode(MessageInputContainer, {
|
|
3508
|
+
}, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && createVNode(MessageInputContainer, {
|
|
3202
3509
|
"class": "--ai-input-container",
|
|
3203
|
-
"onSubmit":
|
|
3510
|
+
"onSubmit": _this9.handleSendMessage
|
|
3204
3511
|
}, {
|
|
3205
3512
|
"default": function _default() {
|
|
3206
3513
|
return [createVNode(InputGroup, {
|
|
@@ -3216,19 +3523,19 @@ var AIAnswer = defineComponent({
|
|
|
3216
3523
|
"ref": _inputRef,
|
|
3217
3524
|
"placeholder": props.placeholder,
|
|
3218
3525
|
"enterButton": props.enterButton,
|
|
3219
|
-
"value":
|
|
3220
|
-
"onInput":
|
|
3526
|
+
"value": _this9.inputMessage,
|
|
3527
|
+
"onInput": _this9.handleMessageInputChange,
|
|
3221
3528
|
"id": props.componentId + "-ai-input",
|
|
3222
3529
|
"showIcon": props.showIcon,
|
|
3223
3530
|
"iconPosition": props.iconPosition,
|
|
3224
|
-
"themePreset":
|
|
3225
|
-
"disabled":
|
|
3531
|
+
"themePreset": _this9.themePreset,
|
|
3532
|
+
"disabled": _this9.isLoadingState || !_this9.AISessionId,
|
|
3226
3533
|
"class": getClassName$2(props.innerClass, 'ai-input') || null
|
|
3227
|
-
}, null), ' ',
|
|
3534
|
+
}, null), ' ', _this9.renderIcons()];
|
|
3228
3535
|
}
|
|
3229
3536
|
})];
|
|
3230
3537
|
}
|
|
3231
|
-
}),
|
|
3538
|
+
}), _this9.renderEnterButtonElement()];
|
|
3232
3539
|
}
|
|
3233
3540
|
}), ' '];
|
|
3234
3541
|
}
|
|
@@ -3246,9 +3553,11 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
|
3246
3553
|
// eslint-disable-next-line prefer-destructuring
|
|
3247
3554
|
dependencyComponent = dependencyComponent[0];
|
|
3248
3555
|
}
|
|
3249
|
-
var showComponent = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value;
|
|
3556
|
+
var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
|
|
3557
|
+
var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
|
|
3250
3558
|
return {
|
|
3251
3559
|
showComponent: showComponent,
|
|
3560
|
+
dependentComponentValue: dependentComponentValue,
|
|
3252
3561
|
AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
|
|
3253
3562
|
isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
|
|
3254
3563
|
AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
|
|
@@ -3256,11 +3565,17 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
|
3256
3565
|
themePreset: state.config.themePreset,
|
|
3257
3566
|
isLoading: state.isLoading[props.componentId] || false,
|
|
3258
3567
|
sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
|
|
3259
|
-
componentError: state.error[props.componentId]
|
|
3568
|
+
componentError: state.error[props.componentId] || null,
|
|
3569
|
+
isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
|
|
3260
3570
|
};
|
|
3261
3571
|
};
|
|
3262
3572
|
var mapDispatchToProps$1 = {
|
|
3263
|
-
getAIResponse:
|
|
3573
|
+
getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
|
|
3574
|
+
if (shouldFetchMeta === void 0) {
|
|
3575
|
+
shouldFetchMeta = false;
|
|
3576
|
+
}
|
|
3577
|
+
return fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
|
|
3578
|
+
},
|
|
3264
3579
|
trackUsefullness: recordAISessionUsefulness,
|
|
3265
3580
|
createAISession: createAISession
|
|
3266
3581
|
};
|