@appbaseio/reactivesearch-vue 3.0.0-rc.9 → 3.0.0
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 +4866 -701
- 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/{ComponentWrapper-0b9ffb1a.js → ComponentWrapper-0334c14b.js} +1 -1
- package/dist/cjs/{DropDown-aef75c14.js → DropDown-26666911.js} +14 -6
- package/dist/cjs/DynamicRangeSlider.js +7 -4
- package/dist/cjs/{Input-56eba499.js → Input-3ecdb905.js} +27 -74
- package/dist/cjs/MultiDropdownList.js +7 -6
- package/dist/cjs/MultiList.js +6 -5
- package/dist/cjs/MultiRange.js +5 -4
- package/dist/cjs/{Pagination-bcf8af5f.js → Pagination-c53a18ab.js} +1 -1
- package/dist/cjs/{PreferencesConsumer-85dee673.js → PreferencesConsumer-7bee3c57.js} +1 -1
- package/dist/cjs/RangeInput.js +8 -5
- package/dist/cjs/RangeSlider.js +8 -5
- package/dist/cjs/ReactiveBase.js +20 -18
- package/dist/cjs/ReactiveComponent.js +5 -4
- package/dist/cjs/ReactiveGoogleMap.js +8 -5
- package/dist/cjs/ReactiveList.js +6 -5
- package/dist/cjs/ResultCard.js +1 -1
- package/dist/cjs/ResultList.js +1 -1
- package/dist/cjs/SelectedFilters.js +2 -2
- package/dist/cjs/SingleDropdownList.js +7 -6
- package/dist/cjs/SingleList.js +6 -5
- package/dist/cjs/SingleRange.js +5 -4
- package/dist/cjs/StateProvider.js +1 -1
- package/dist/cjs/ToggleButton.js +5 -4
- package/dist/cjs/{index-779ed366.js → index-1f41363f.js} +7 -3
- package/dist/cjs/index.js +11 -8
- package/dist/cjs/{install-e8141489.js → install-08b8d6e7.js} +814 -283
- package/dist/cjs/install.js +11 -8
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/{vueTypes-a5f1745e.js → vueTypes-289a891a.js} +2 -1
- package/dist/components/ReactiveBase/ReactiveBase.d.ts +33 -0
- package/dist/components/basic/ReactiveComponent.d.ts +30 -0
- package/dist/components/basic/ReactiveComponentPrivate.d.ts +10 -0
- package/dist/components/basic/SelectedFilters.d.ts +24 -0
- package/dist/components/basic/StateProvider.d.ts +12 -0
- package/dist/components/list/MultiDropdownList.d.ts +49 -0
- package/dist/components/list/MultiList.d.ts +47 -0
- package/dist/components/list/SingleDropdownList.d.ts +47 -0
- package/dist/components/list/SingleList.d.ts +47 -0
- package/dist/components/list/ToggleButton.d.ts +33 -0
- package/dist/components/list/TreeList.d.ts +48 -0
- package/dist/components/range/DynamicRangeSlider.d.ts +38 -0
- package/dist/components/range/MultiRange.d.ts +30 -0
- package/dist/components/range/RangeInput.d.ts +30 -0
- package/dist/components/range/RangeSlider.d.ts +40 -0
- package/dist/components/range/SingleRange.d.ts +28 -0
- package/dist/components/result/ReactiveList.d.ts +55 -0
- package/dist/components/result/ResultCard.d.ts +10 -0
- package/dist/components/result/ResultList.d.ts +11 -0
- package/dist/components/search/AIAnswer.d.ts +44 -0
- package/dist/components/search/SearchBox.d.ts +107 -0
- package/dist/es/{ComponentWrapper-a2635cfc.js → ComponentWrapper-46d04344.js} +1 -1
- package/dist/es/{DropDown-39fedff8.js → DropDown-48045fde.js} +14 -7
- package/dist/es/DynamicRangeSlider.js +8 -5
- package/dist/es/{Input-11d211d2.js → Input-83dee8c5.js} +26 -75
- package/dist/es/MultiDropdownList.js +7 -6
- package/dist/es/MultiList.js +6 -5
- package/dist/es/MultiRange.js +5 -4
- package/dist/es/{Pagination-50fc3ef5.js → Pagination-591fdb79.js} +1 -1
- package/dist/es/{PreferencesConsumer-b058d14e.js → PreferencesConsumer-0856ed43.js} +1 -1
- package/dist/es/RangeInput.js +8 -5
- package/dist/es/RangeSlider.js +9 -6
- package/dist/es/ReactiveBase.js +20 -18
- package/dist/es/ReactiveComponent.js +5 -4
- package/dist/es/ReactiveGoogleMap.js +8 -5
- package/dist/es/ReactiveList.js +6 -5
- package/dist/es/ResultCard.js +1 -1
- package/dist/es/ResultList.js +1 -1
- package/dist/es/SelectedFilters.js +2 -2
- package/dist/es/SingleDropdownList.js +7 -6
- package/dist/es/SingleList.js +6 -5
- package/dist/es/SingleRange.js +5 -4
- package/dist/es/StateProvider.js +1 -1
- package/dist/es/ToggleButton.js +5 -4
- package/dist/es/{index-882489e1.js → index-104f1dfb.js} +7 -3
- package/dist/es/index.js +12 -9
- package/dist/es/{install-b785dd55.js → install-e883f435.js} +816 -285
- package/dist/es/install.js +11 -8
- package/dist/es/version.js +1 -1
- package/dist/es/{vueTypes-09cab4d3.js → vueTypes-f503e267.js} +2 -1
- package/dist/index.d.ts +40 -0
- package/dist/types.ts +226 -0
- package/package.json +7 -4
|
@@ -1,29 +1,30 @@
|
|
|
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';
|
|
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';
|
|
11
11
|
import { B as Button } from './Button-5c2cf399.js';
|
|
12
|
-
import { t as types } from './vueTypes-
|
|
12
|
+
import { t as types } from './vueTypes-f503e267.js';
|
|
13
13
|
import { RLConnected as ReactiveList } from './ReactiveList.js';
|
|
14
14
|
import { getInternalComponentID } from '@appbaseio/reactivecore/lib/utils/transform';
|
|
15
|
-
import { g as getComponent, h as hasCustomRenderer, f as decodeHtml, i as isQueryIdentical, u as updateDefaultQuery, j as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-
|
|
16
|
-
import { C as ComponentWrapper } from './ComponentWrapper-
|
|
17
|
-
import { P as PreferencesConsumer } from './PreferencesConsumer-
|
|
15
|
+
import { g as getComponent, h as hasCustomRenderer, f as decodeHtml, i as isQueryIdentical, u as updateDefaultQuery, j as updateCustomQuery, a as isFunction, k as isEmpty, p as parseFocusShortcuts, l as extractModifierKeysFromFocusShortcuts, c as connect } from './index-104f1dfb.js';
|
|
16
|
+
import { C as ComponentWrapper } from './ComponentWrapper-46d04344.js';
|
|
17
|
+
import { P as PreferencesConsumer } from './PreferencesConsumer-0856ed43.js';
|
|
18
18
|
import { T as Title } from './Title-863dfa42.js';
|
|
19
19
|
import { L as ListItem } from './ListItem-e3c6acf4.js';
|
|
20
20
|
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-48045fde.js';
|
|
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';
|
|
27
28
|
import { C as Container } from './Container-d00219f7.js';
|
|
28
29
|
import Highlight from 'vue-highlight-words';
|
|
29
30
|
import { fetchAIResponse, createAISession } from '@appbaseio/reactivecore/lib/actions/query';
|
|
@@ -48,7 +49,13 @@ 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\t", "\n\t};\n"])), function (_ref) {
|
|
53
|
+
var theme = _ref.theme,
|
|
54
|
+
searchBox = _ref.searchBox;
|
|
55
|
+
return searchBox && "background-color: " + (theme.colors.backgroundColor || '#fafafa') + ";\n\t\tcolor: " + (theme.colors.textColor || '#fff') + ";\n\n\t\t&:focus-within {\n\t\t\tbackground-color: " + (theme.colors.backgroundColor || '#fff') + ";\n\t\t}";
|
|
56
|
+
}, function (props) {
|
|
57
|
+
return props.isOpen && "box-shadow: rgb(0 0 0 / 20%) 0px 0px 15px;\n\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;";
|
|
58
|
+
});
|
|
52
59
|
InputGroup.defaultProps = {
|
|
53
60
|
className: 'input-group'
|
|
54
61
|
};
|
|
@@ -778,8 +785,11 @@ var _templateObject$4, _templateObject2;
|
|
|
778
785
|
var TagsContainer = styled('div')(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tmargin-top: 10px;\n\twidth: 100%;\n"])));
|
|
779
786
|
var TagItem = styled('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tcursor: default;\n\tbox-sizing: border-box;\n\tmargin: 0 4px 4px 0;\n\tcolor: #000000d9;\n\tfont-size: 14px;\n\tfont-variant: tabular-nums;\n\tline-height: 1.5715;\n\tlist-style: none;\n\tfont-feature-settings: 'tnum';\n\tdisplay: inline-block;\n\theight: auto;\n\tpadding: 0 2px 0 7px;\n\tfont-size: 12px;\n\tline-height: 22px;\n\twhite-space: nowrap;\n\tbackground: #fafafa;\n\tborder: 1px solid #d9d9d9;\n\tborder-radius: 2px;\n\topacity: 1;\n\ttransition: all 0.3s;\n\n\tspan.close-icon {\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\theight: 15px;\n\t\t\tposition: relative;\n\t\t\ttop: 4px;\n\t\t\tfill: #262626;\n\t\t}\n\t}\n"])));
|
|
780
787
|
|
|
781
|
-
var _templateObject$5
|
|
782
|
-
var
|
|
788
|
+
var _templateObject$5;
|
|
789
|
+
var AutosuggestFooterContainer = styled('div')(_templateObject$5 || (_templateObject$5 = _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"])));
|
|
790
|
+
|
|
791
|
+
var _templateObject$6, _templateObject2$1, _templateObject3;
|
|
792
|
+
var skeletonAnimation = keyframes(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteralLoose(["\n 0% {\n background-position: 100% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n"])));
|
|
783
793
|
var SkeletonLoader = styled('div')(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 10px;\n"])));
|
|
784
794
|
var SkeletonLine = styled('div')(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\theight: 20px;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\trgba(220, 220, 220, 0.5) 25%,\n\t\trgba(240, 240, 240, 0.9) 50%,\n\t\trgba(220, 220, 220, 0.5) 75%\n\t);\n\tbackground-size: 200% 100%;\n\tanimation: ", " 1.5s infinite;\n"])), skeletonAnimation);
|
|
785
795
|
var HorizontalSkeletonLoader = defineComponent({
|
|
@@ -793,8 +803,8 @@ var HorizontalSkeletonLoader = defineComponent({
|
|
|
793
803
|
}
|
|
794
804
|
});
|
|
795
805
|
|
|
796
|
-
var _templateObject$
|
|
797
|
-
var Chatbox = styled('div')(_templateObject$
|
|
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\n\t.--trigger-message-wrapper {\n\t\tcursor: pointer;\n\t}\n"])), function (props) {
|
|
798
808
|
return props.theme && props.theme.colors ? props.theme.colors.backgroundColor : '#fff';
|
|
799
809
|
});
|
|
800
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) {
|
|
@@ -819,11 +829,15 @@ var TypingDot = styled('div')(_templateObject6 || (_templateObject6 = _taggedTem
|
|
|
819
829
|
return finalColor;
|
|
820
830
|
}, typingDots);
|
|
821
831
|
var resetCSS = function resetCSS(props) {
|
|
822
|
-
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: " + (
|
|
835
|
+
// 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\n\tcode {\n\t\tline-height: normal;\n\n\t\tcolor: " + (
|
|
823
837
|
// eslint-disable-next-line no-nested-ternary
|
|
824
|
-
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.
|
|
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: " + (
|
|
825
839
|
// eslint-disable-next-line no-nested-ternary
|
|
826
|
-
props.isSender ? props.themePreset !== 'dark' ? props.theme.colors.primaryTextColor : props.theme.colors.textColor : props.theme.colors.primaryTextColor) + ";\n\t\
|
|
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";
|
|
827
841
|
};
|
|
828
842
|
var messageBGColor = function messageBGColor(props) {
|
|
829
843
|
var finalBGColor;
|
|
@@ -852,7 +866,7 @@ var Message = styled('div')(_templateObject7 || (_templateObject7 = _taggedTempl
|
|
|
852
866
|
return resetCSS(props);
|
|
853
867
|
});
|
|
854
868
|
var MessageInputContainer = styled('form')(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\tpadding-top: 12px;\n\talign-items: stretch;\n\tmargin-top: 10px;\n\t.ai-enter-button-wrapper {\n\t\talign-self: baseline;\n\t\theight: 41px;\n\t}\n"])));
|
|
855
|
-
var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t::placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t:-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t::-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\t", "\n"])), function (props) {
|
|
869
|
+
var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n\twidth: 100%;\n\tborder-radius: 5px;\n\tborder: 1px solid #ccc;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\n\t::placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t:-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\n\t::-ms-input-placeholder {\n\t\tcolor: ", ";\n\t}\n\t", "\n\tpadding-left: 35px;\n"])), function (props) {
|
|
856
870
|
return props.themePreset === 'dark' ? props.theme.colors.borderColor : '#fff';
|
|
857
871
|
}, function (props) {
|
|
858
872
|
return props.themePreset === 'dark' ? props.theme.colors.titleColor : props.theme.colors.textColor;
|
|
@@ -869,8 +883,8 @@ var MessageInput = styled(TextArea)(_templateObject9 || (_templateObject9 = _tag
|
|
|
869
883
|
var SendButton = styled(Button)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n\tborder: none;\n\tcolor: #ffffff;\n\tcursor: pointer;\n\tfont-size: 16px;\n\tmargin-left: 8px;\n\toutline: none;\n\tpadding: 10px;\n\ttext-align: center;\n\n\t&:disabled {\n\t\tcursor: not-allowed;\n\t}\n"])));
|
|
870
884
|
var AIFeedbackContainer = styled('div')(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n\t.--feedback-svgs-wrapper {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tjustify-content: flex-end;\n\t\tgap: 5px;\n\n\t\tsvg {\n\t\t\tcursor: pointer;\n\t\t\ttransition: all ease-in 0.1s;\n\t\t\t&.selected {\n\t\t\t\ttransform: scale(1.1);\n\t\t\t\tcursor: default;\n\t\t\t}\n\n\t\t\t&:hover {\n\t\t\t\ttransform: scale(1.1);\n\t\t\t}\n\t\t}\n\t}\n\n\t.--feedback-input-wrapper {\n\t\tdisplay: flex;\n\t\tgap: 7px;\n\t}\n"])));
|
|
871
885
|
|
|
872
|
-
var _templateObject$
|
|
873
|
-
var fadeInFromBottom = keyframes(_templateObject$
|
|
886
|
+
var _templateObject$8, _templateObject2$3, _templateObject3$2, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1;
|
|
887
|
+
var fadeInFromBottom = keyframes(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteralLoose(["\n 0% {\n opacity: 0;\n transform: translateY(20px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
|
|
874
888
|
var fadeInFromTop = keyframes(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n 0% {\n opacity: 0;\n transform: translateY(-20px);\n }\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])));
|
|
875
889
|
var SearchBoxAISection = styled('div')(_templateObject3$2 || (_templateObject3$2 = _taggedTemplateLiteralLoose(["\n\tpadding: 10px;\n\tborder-radius: 4px;\n\tmin-height: 200px;\n\tpadding-top: 20px;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\tbackground-color: ", ";\n\tcolor: ", ";\n\t.--ai-answer-error-container {\n\t\tposition: absolute;\n\t\ttop: 50%;\n\t\tleft: 50%;\n\t\ttransform: translate(-50%, -50%);\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\tgap: 10px;\n\t\t}\n\t}\n"])), function (_ref) {
|
|
876
890
|
var themePreset = _ref.themePreset,
|
|
@@ -1074,7 +1088,9 @@ var md = new Remarkable();
|
|
|
1074
1088
|
md.set({
|
|
1075
1089
|
html: true,
|
|
1076
1090
|
breaks: true,
|
|
1077
|
-
xhtmlOut: true
|
|
1091
|
+
xhtmlOut: true,
|
|
1092
|
+
linkify: true,
|
|
1093
|
+
linkTarget: '_blank'
|
|
1078
1094
|
});
|
|
1079
1095
|
var _dropdownULRef = 'dropdownULRef';
|
|
1080
1096
|
var _inputGroupRef = 'inputGroupRef';
|
|
@@ -1102,7 +1118,9 @@ var SearchBox = defineComponent({
|
|
|
1102
1118
|
showAIScreen: false,
|
|
1103
1119
|
showAIScreenFooter: false,
|
|
1104
1120
|
showFeedbackComponent: false,
|
|
1105
|
-
feedbackState: null
|
|
1121
|
+
feedbackState: null,
|
|
1122
|
+
faqAnswer: '',
|
|
1123
|
+
faqQuestion: ''
|
|
1106
1124
|
};
|
|
1107
1125
|
this.internalComponent = props.componentId + "__internal";
|
|
1108
1126
|
return this.__state;
|
|
@@ -1138,11 +1156,55 @@ var SearchBox = defineComponent({
|
|
|
1138
1156
|
}
|
|
1139
1157
|
},
|
|
1140
1158
|
computed: {
|
|
1159
|
+
currentTriggerMode: function currentTriggerMode() {
|
|
1160
|
+
return this.$props.AIUIConfig && this.$props.AIUIConfig.triggerOn || AI_TRIGGER_MODES.MANUAL;
|
|
1161
|
+
},
|
|
1141
1162
|
hasCustomRenderer: function hasCustomRenderer$1() {
|
|
1142
1163
|
return hasCustomRenderer(this);
|
|
1143
1164
|
},
|
|
1144
1165
|
stats: function stats() {
|
|
1145
1166
|
return getResultStats(this);
|
|
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
|
+
},
|
|
1174
|
+
parsedSuggestions: function parsedSuggestions() {
|
|
1175
|
+
var suggestionsArray = [];
|
|
1176
|
+
if (Array.isArray(this.suggestions) && this.suggestions.length) {
|
|
1177
|
+
suggestionsArray = [].concat(withClickIds(this.suggestions));
|
|
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
|
+
}
|
|
1186
|
+
suggestionsArray = suggestionsArray.map(function (s) {
|
|
1187
|
+
if (s.sectionId) {
|
|
1188
|
+
return s;
|
|
1189
|
+
}
|
|
1190
|
+
return _extends({}, s, {
|
|
1191
|
+
sectionId: s._suggestion_type
|
|
1192
|
+
});
|
|
1193
|
+
});
|
|
1194
|
+
var sectionsAccumulated = [];
|
|
1195
|
+
var sectionisedSuggestions = suggestionsArray.reduce(function (acc, d, currentIndex) {
|
|
1196
|
+
if (sectionsAccumulated.includes(d.sectionId)) return acc;
|
|
1197
|
+
if (d.sectionId) {
|
|
1198
|
+
acc[currentIndex] = suggestionsArray.filter(function (g) {
|
|
1199
|
+
return g.sectionId === d.sectionId;
|
|
1200
|
+
});
|
|
1201
|
+
sectionsAccumulated.push(d.sectionId);
|
|
1202
|
+
} else {
|
|
1203
|
+
acc[currentIndex] = d;
|
|
1204
|
+
}
|
|
1205
|
+
return acc;
|
|
1206
|
+
}, {});
|
|
1207
|
+
return Object.values(sectionisedSuggestions);
|
|
1146
1208
|
}
|
|
1147
1209
|
},
|
|
1148
1210
|
props: {
|
|
@@ -1152,6 +1214,7 @@ var SearchBox = defineComponent({
|
|
|
1152
1214
|
className: VueTypes.string.def(''),
|
|
1153
1215
|
clearIcon: types.children,
|
|
1154
1216
|
componentId: types.stringRequired,
|
|
1217
|
+
compoundClause: types.compoundClause,
|
|
1155
1218
|
customHighlight: types.func,
|
|
1156
1219
|
customQuery: types.func,
|
|
1157
1220
|
defaultQuery: types.func,
|
|
@@ -1174,6 +1237,11 @@ var SearchBox = defineComponent({
|
|
|
1174
1237
|
enableQuerySuggestions: VueTypes.bool.def(false),
|
|
1175
1238
|
enablePopularSuggestions: VueTypes.bool.def(false),
|
|
1176
1239
|
enableRecentSuggestions: VueTypes.bool.def(false),
|
|
1240
|
+
enableFAQSuggestions: VueTypes.bool.def(false),
|
|
1241
|
+
FAQSuggestionsConfig: VueTypes.shape({
|
|
1242
|
+
sectionLabel: VueTypes.string,
|
|
1243
|
+
size: VueTypes.number
|
|
1244
|
+
}),
|
|
1177
1245
|
fieldWeights: types.fieldWeights,
|
|
1178
1246
|
filterLabel: types.string,
|
|
1179
1247
|
fuzziness: types.fuzziness,
|
|
@@ -1209,12 +1277,20 @@ var SearchBox = defineComponent({
|
|
|
1209
1277
|
distinctFieldConfig: types.props,
|
|
1210
1278
|
//
|
|
1211
1279
|
focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])).def(['/']),
|
|
1280
|
+
showFocusShortcutsIcon: VueTypes.bool.def(true),
|
|
1212
1281
|
addonBefore: VueTypes.any,
|
|
1213
1282
|
addonAfter: VueTypes.any,
|
|
1283
|
+
showSuggestionsFooter: VueTypes.bool.def(true),
|
|
1214
1284
|
expandSuggestionsContainer: VueTypes.bool.def(true),
|
|
1285
|
+
renderSuggestionsFooter: VueTypes.func,
|
|
1215
1286
|
index: VueTypes.string,
|
|
1216
1287
|
popularSuggestionsConfig: VueTypes.object,
|
|
1217
1288
|
recentSuggestionsConfig: VueTypes.object,
|
|
1289
|
+
featuredSuggestionsConfig: VueTypes.shape({
|
|
1290
|
+
maxSuggestionsPerSection: VueTypes.number,
|
|
1291
|
+
sectionsOrder: VueTypes.arrayOf(VueTypes.string)
|
|
1292
|
+
}),
|
|
1293
|
+
customEvents: VueTypes.object,
|
|
1218
1294
|
applyStopwords: VueTypes.bool,
|
|
1219
1295
|
customStopwords: types.stringArray,
|
|
1220
1296
|
onData: types.func,
|
|
@@ -1289,7 +1365,11 @@ var SearchBox = defineComponent({
|
|
|
1289
1365
|
if (this.$options.isTagsMode) {
|
|
1290
1366
|
cause = causes.SUGGESTION_SELECT;
|
|
1291
1367
|
}
|
|
1292
|
-
|
|
1368
|
+
if (this.$props.value === undefined) {
|
|
1369
|
+
this.setValue(newVal, newVal === '', this.$props, cause, false);
|
|
1370
|
+
} else {
|
|
1371
|
+
this.setValue(newVal || '', true, this.$props, cause);
|
|
1372
|
+
}
|
|
1293
1373
|
}
|
|
1294
1374
|
},
|
|
1295
1375
|
focusShortcuts: function focusShortcuts() {
|
|
@@ -1377,6 +1457,20 @@ var SearchBox = defineComponent({
|
|
|
1377
1457
|
}
|
|
1378
1458
|
},
|
|
1379
1459
|
methods: {
|
|
1460
|
+
renderTriggerMessage: function renderTriggerMessage() {
|
|
1461
|
+
if (this.$props.enableAI) {
|
|
1462
|
+
if (this.$props.AIUIConfig && this.$props.AIUIConfig.renderTriggerMessage) {
|
|
1463
|
+
return this.$props.AIUIConfig.renderTriggerMessage;
|
|
1464
|
+
}
|
|
1465
|
+
if (this.$slots.renderTriggerMessage) {
|
|
1466
|
+
return this.$slots.renderTriggerMessage();
|
|
1467
|
+
}
|
|
1468
|
+
if (this.currentTriggerMode === AI_TRIGGER_MODES.MANUAL && (this.$props.AIUIConfig ? !this.$props.AIUIConfig.askButton : true)) {
|
|
1469
|
+
return 'Click to trigger AIAnswer';
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
return null;
|
|
1473
|
+
},
|
|
1380
1474
|
handleText: function handleText(value, cause) {
|
|
1381
1475
|
if (cause === causes.CLEAR_VALUE) {
|
|
1382
1476
|
this.triggerCustomQuery(value);
|
|
@@ -1401,8 +1495,8 @@ var SearchBox = defineComponent({
|
|
|
1401
1495
|
value: currentValue,
|
|
1402
1496
|
resultStats: this.stats,
|
|
1403
1497
|
AIData: {
|
|
1404
|
-
question: this.
|
|
1405
|
-
answer: this.
|
|
1498
|
+
question: this.mergedAIQuestion,
|
|
1499
|
+
answer: this.mergedAIAnswer,
|
|
1406
1500
|
documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
|
|
1407
1501
|
showAIScreen: this.showAIScreen,
|
|
1408
1502
|
sources: this.getAISourceObjects(),
|
|
@@ -1433,7 +1527,7 @@ var SearchBox = defineComponent({
|
|
|
1433
1527
|
this.onValueSelectedHandler(currentValue, causes.SEARCH_ICON_CLICK);
|
|
1434
1528
|
}
|
|
1435
1529
|
},
|
|
1436
|
-
setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue) {
|
|
1530
|
+
setValue: function setValue(value, isDefaultValue, props, cause, toggleIsOpen, categoryValue, shouldExecuteQuery) {
|
|
1437
1531
|
var _this2 = this;
|
|
1438
1532
|
if (isDefaultValue === void 0) {
|
|
1439
1533
|
isDefaultValue = false;
|
|
@@ -1447,6 +1541,9 @@ var SearchBox = defineComponent({
|
|
|
1447
1541
|
if (categoryValue === void 0) {
|
|
1448
1542
|
categoryValue = undefined;
|
|
1449
1543
|
}
|
|
1544
|
+
if (shouldExecuteQuery === void 0) {
|
|
1545
|
+
shouldExecuteQuery = true;
|
|
1546
|
+
}
|
|
1450
1547
|
var performUpdate = function performUpdate() {
|
|
1451
1548
|
if (_this2.$options.isTagsMode && isEqual(value, _this2.selectedTags)) {
|
|
1452
1549
|
return;
|
|
@@ -1475,24 +1572,31 @@ var SearchBox = defineComponent({
|
|
|
1475
1572
|
if (_this2.$options.isTagsMode && cause === causes.SUGGESTION_SELECT) {
|
|
1476
1573
|
queryHandlerValue = Array.isArray(_this2.selectedTags) && _this2.selectedTags.length ? _this2.selectedTags : undefined;
|
|
1477
1574
|
}
|
|
1575
|
+
if ((_this2.faqAnswer || _this2.faqQuestion) && value === '') {
|
|
1576
|
+
// Empty the previous state
|
|
1577
|
+
_this2.faqAnswer = '';
|
|
1578
|
+
_this2.faqQuestion = '';
|
|
1579
|
+
_this2.showAIScreen = false;
|
|
1580
|
+
}
|
|
1478
1581
|
if (isDefaultValue) {
|
|
1479
1582
|
if (_this2.$props.autosuggest) {
|
|
1480
1583
|
if (toggleIsOpen) {
|
|
1481
1584
|
_this2.isOpen = false;
|
|
1482
1585
|
}
|
|
1483
|
-
if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI ? {
|
|
1586
|
+
if (typeof _this2.currentValue === 'string') _this2.triggerDefaultQuery(_this2.currentValue, props.enableAI && _this2.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && _this2.currentValue.endsWith('?') ? {
|
|
1484
1587
|
enableAI: true
|
|
1485
|
-
} : {});
|
|
1588
|
+
} : {}, shouldExecuteQuery);
|
|
1486
1589
|
} // in case of strict selection only SUGGESTION_SELECT should be able
|
|
1487
1590
|
// to set the query otherwise the value should reset
|
|
1488
1591
|
if (props.strictSelection) {
|
|
1489
1592
|
if (cause === causes.SUGGESTION_SELECT || (_this2.$options.isTagsMode ? _this2.selectedTags.length === 0 : value === '')) {
|
|
1490
|
-
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue);
|
|
1593
|
+
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
|
|
1491
1594
|
} else {
|
|
1492
1595
|
_this2.setValue('', true);
|
|
1493
1596
|
}
|
|
1494
1597
|
} else if (props.value === undefined || cause === causes.SUGGESTION_SELECT || cause === causes.CLEAR_VALUE) {
|
|
1495
|
-
_this2.
|
|
1598
|
+
_this2.showAIScreen = false;
|
|
1599
|
+
_this2.triggerCustomQuery(queryHandlerValue, _this2.$options.isTagsMode ? undefined : categoryValue, shouldExecuteQuery);
|
|
1496
1600
|
}
|
|
1497
1601
|
} else {
|
|
1498
1602
|
// debounce for handling text while typing
|
|
@@ -1503,10 +1607,13 @@ var SearchBox = defineComponent({
|
|
|
1503
1607
|
};
|
|
1504
1608
|
checkValueChange(props.componentId, value, props.beforeValueChange, performUpdate);
|
|
1505
1609
|
},
|
|
1506
|
-
triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta) {
|
|
1610
|
+
triggerDefaultQuery: function triggerDefaultQuery(paramValue, meta, shouldExecuteQuery) {
|
|
1507
1611
|
if (meta === void 0) {
|
|
1508
1612
|
meta = {};
|
|
1509
1613
|
}
|
|
1614
|
+
if (shouldExecuteQuery === void 0) {
|
|
1615
|
+
shouldExecuteQuery = true;
|
|
1616
|
+
}
|
|
1510
1617
|
if (!this.$props.autosuggest) {
|
|
1511
1618
|
return;
|
|
1512
1619
|
}
|
|
@@ -1527,12 +1634,15 @@ var SearchBox = defineComponent({
|
|
|
1527
1634
|
value: value,
|
|
1528
1635
|
componentType: componentTypes.searchBox,
|
|
1529
1636
|
meta: meta
|
|
1530
|
-
});
|
|
1637
|
+
}, shouldExecuteQuery);
|
|
1531
1638
|
},
|
|
1532
|
-
triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue) {
|
|
1639
|
+
triggerCustomQuery: function triggerCustomQuery(paramValue, categoryValue, shouldExecuteQuery) {
|
|
1533
1640
|
if (categoryValue === void 0) {
|
|
1534
1641
|
categoryValue = undefined;
|
|
1535
1642
|
}
|
|
1643
|
+
if (shouldExecuteQuery === void 0) {
|
|
1644
|
+
shouldExecuteQuery = true;
|
|
1645
|
+
}
|
|
1536
1646
|
var _this$$props = this.$props,
|
|
1537
1647
|
customQuery = _this$$props.customQuery,
|
|
1538
1648
|
filterLabel = _this$$props.filterLabel,
|
|
@@ -1561,7 +1671,7 @@ var SearchBox = defineComponent({
|
|
|
1561
1671
|
URLParams: URLParams,
|
|
1562
1672
|
componentType: componentTypes.searchBox,
|
|
1563
1673
|
category: categoryValue
|
|
1564
|
-
});
|
|
1674
|
+
}, shouldExecuteQuery);
|
|
1565
1675
|
},
|
|
1566
1676
|
handleFocus: function handleFocus(event) {
|
|
1567
1677
|
if (this.$props.autosuggest) {
|
|
@@ -1572,7 +1682,9 @@ var SearchBox = defineComponent({
|
|
|
1572
1682
|
handleVoiceResults: function handleVoiceResults(_ref) {
|
|
1573
1683
|
var results = _ref.results;
|
|
1574
1684
|
if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
|
|
1685
|
+
var _this$$refs2;
|
|
1575
1686
|
this.setValue(results[0][0].transcript.trim(), true);
|
|
1687
|
+
(_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
|
|
1576
1688
|
}
|
|
1577
1689
|
},
|
|
1578
1690
|
triggerQuery: function triggerQuery(_ref2) {
|
|
@@ -1612,6 +1724,8 @@ var SearchBox = defineComponent({
|
|
|
1612
1724
|
clearValue: function clearValue() {
|
|
1613
1725
|
this.setValue('', false, this.$props, !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined, false);
|
|
1614
1726
|
this.onValueSelectedHandler('', !this.$options.isTagsMode ? causes.CLEAR_VALUE : undefined);
|
|
1727
|
+
this.showAIScreen = false;
|
|
1728
|
+
this.isOpen = false;
|
|
1615
1729
|
},
|
|
1616
1730
|
handleKeyDown: function handleKeyDown(event, highlightedIndex) {
|
|
1617
1731
|
if (highlightedIndex === void 0) {
|
|
@@ -1624,9 +1738,10 @@ var SearchBox = defineComponent({
|
|
|
1624
1738
|
} else if (highlightedIndex === null) {
|
|
1625
1739
|
this.setValue(event.target.value, true, this.$props, this.$options.isTagsMode ? causes.SUGGESTION_SELECT : undefined,
|
|
1626
1740
|
// to handle tags
|
|
1627
|
-
!this.$props.enableAI);
|
|
1628
|
-
if (this.$props.enableAI && !this.showAIScreen) {
|
|
1741
|
+
!(this.$props.enableAI && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')));
|
|
1742
|
+
if (this.$props.enableAI && !this.showAIScreen && this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && event.target.value.endsWith('?')) {
|
|
1629
1743
|
this.showAIScreen = true;
|
|
1744
|
+
this.isOpen = true;
|
|
1630
1745
|
}
|
|
1631
1746
|
this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
|
|
1632
1747
|
}
|
|
@@ -1647,7 +1762,7 @@ var SearchBox = defineComponent({
|
|
|
1647
1762
|
}
|
|
1648
1763
|
var value = this.$props.value;
|
|
1649
1764
|
if (value === undefined) {
|
|
1650
|
-
this.setValue(inputValue,
|
|
1765
|
+
this.setValue(inputValue, inputValue === '', this.$props, undefined, false);
|
|
1651
1766
|
} else {
|
|
1652
1767
|
this.$emit('change', inputValue, function (_ref3) {
|
|
1653
1768
|
var isOpen = _ref3.isOpen;
|
|
@@ -1660,12 +1775,72 @@ var SearchBox = defineComponent({
|
|
|
1660
1775
|
}, e);
|
|
1661
1776
|
}
|
|
1662
1777
|
},
|
|
1778
|
+
handleFeaturedSuggestionClicked: function handleFeaturedSuggestionClicked(suggestion) {
|
|
1779
|
+
try {
|
|
1780
|
+
var _this$$refs3;
|
|
1781
|
+
if (suggestion.action === featuredSuggestionsActionTypes.NAVIGATE) {
|
|
1782
|
+
var _JSON$parse = JSON.parse(suggestion.subAction),
|
|
1783
|
+
_JSON$parse$target = _JSON$parse.target,
|
|
1784
|
+
target = _JSON$parse$target === void 0 ? '_self' : _JSON$parse$target,
|
|
1785
|
+
_JSON$parse$link = _JSON$parse.link,
|
|
1786
|
+
link = _JSON$parse$link === void 0 ? '/' : _JSON$parse$link;
|
|
1787
|
+
if (typeof window !== 'undefined') {
|
|
1788
|
+
window.open(link, target);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
if (suggestion.action === featuredSuggestionsActionTypes.FUNCTION) {
|
|
1792
|
+
var matchedValues = suggestion.subAction.match(/function\s*\(.*\)(.|\n)*/);
|
|
1793
|
+
var functionStr = matchedValues && matchedValues[0];
|
|
1794
|
+
// eslint-disable-next-line no-new-func
|
|
1795
|
+
var func = new Function("return " + functionStr)();
|
|
1796
|
+
func(suggestion, this.$data.currentValue, this.$props.customEvents);
|
|
1797
|
+
}
|
|
1798
|
+
if (suggestion.action === featuredSuggestionsActionTypes.SELECT) {
|
|
1799
|
+
this.setValue(suggestion.value, true, this.$props, this.$options.isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS, false);
|
|
1800
|
+
this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT);
|
|
1801
|
+
}
|
|
1802
|
+
// blur is important to close the dropdown
|
|
1803
|
+
// on selecting one of featured suggestions
|
|
1804
|
+
// else Downshift probably is focusing the dropdown
|
|
1805
|
+
// and not letting it close
|
|
1806
|
+
// eslint-disable-next-line no-unused-expressions
|
|
1807
|
+
(_this$$refs3 = this.$refs) == null || (_this$$refs3 = _this$$refs3[this.$props.innerRef]) == null || (_this$$refs3 = _this$$refs3.el) == null ? void 0 : _this$$refs3.blur();
|
|
1808
|
+
} catch (e) {
|
|
1809
|
+
console.error("Error: There was an error parsing the subAction for the featured suggestion with label, \"" + suggestion.label + "\"", e);
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1663
1812
|
onSuggestionSelected: function onSuggestionSelected(suggestion) {
|
|
1664
1813
|
var _this4 = this;
|
|
1665
|
-
|
|
1814
|
+
var value = this.$props.value;
|
|
1815
|
+
// The state of the suggestion is open by the time it reaches here. i.e. isOpen = true
|
|
1816
|
+
// handle when FAQ suggestion is clicked
|
|
1817
|
+
if (suggestion && suggestion._suggestion_type === suggestionTypes.FAQ) {
|
|
1818
|
+
this.currentValue = suggestion.value;
|
|
1819
|
+
// Handle AI
|
|
1820
|
+
// Independent of enableAI.
|
|
1821
|
+
this.faqAnswer = suggestion._answer;
|
|
1822
|
+
this.faqQuestion = suggestion.value;
|
|
1823
|
+
this.isOpen = true;
|
|
1666
1824
|
this.showAIScreen = true;
|
|
1825
|
+
if (value !== undefined) this.$emit('change', suggestion.value, function () {});
|
|
1826
|
+
this.onValueSelectedHandler(suggestion.value);
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
if (suggestion && suggestion._suggestion_type === '_internal_a_i_trigger') {
|
|
1830
|
+
this.showAIScreen = true;
|
|
1831
|
+
this.askButtonOnClick();
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// handle featured suggestions click event
|
|
1836
|
+
if (suggestion._suggestion_type === suggestionTypes.Featured) {
|
|
1837
|
+
this.handleFeaturedSuggestionClicked(suggestion);
|
|
1838
|
+
// Handle AI
|
|
1839
|
+
if (!this.$props.enableAI) this.isOpen = false;else {
|
|
1840
|
+
this.showAIScreen = true;
|
|
1841
|
+
}
|
|
1842
|
+
return;
|
|
1667
1843
|
}
|
|
1668
|
-
var value = this.$props.value;
|
|
1669
1844
|
// Record analytics for selected suggestions
|
|
1670
1845
|
this.triggerClickAnalytics(suggestion._click_id);
|
|
1671
1846
|
if (value === undefined) {
|
|
@@ -1693,6 +1868,11 @@ var SearchBox = defineComponent({
|
|
|
1693
1868
|
});
|
|
1694
1869
|
}
|
|
1695
1870
|
this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
|
|
1871
|
+
|
|
1872
|
+
// Handle AI
|
|
1873
|
+
if (!this.$props.enableAI) this.isOpen = false;else if (this.currentTriggerMode === AI_TRIGGER_MODES.QUESTION && suggestion.value.endsWith('?')) {
|
|
1874
|
+
this.showAIScreen = true;
|
|
1875
|
+
}
|
|
1696
1876
|
},
|
|
1697
1877
|
onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
|
|
1698
1878
|
if (currentValue === void 0) {
|
|
@@ -1821,6 +2001,13 @@ var SearchBox = defineComponent({
|
|
|
1821
2001
|
customQuery: true
|
|
1822
2002
|
});
|
|
1823
2003
|
},
|
|
2004
|
+
suggestionsFooter: function suggestionsFooter() {
|
|
2005
|
+
return typeof renderSuggestionsFooter === 'function' ? this.$props.renderSuggestionsFooter() : createVNode(AutosuggestFooterContainer, null, {
|
|
2006
|
+
"default": function _default() {
|
|
2007
|
+
return [createVNode("div", null, [createTextVNode("\u2191\u2193 Navigate")]), createVNode("div", null, [createTextVNode("\u21A9 Go")])];
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
},
|
|
1824
2011
|
renderEnterButtonElement: function renderEnterButtonElement() {
|
|
1825
2012
|
var _this6 = this;
|
|
1826
2013
|
var _this$$props2 = this.$props,
|
|
@@ -1848,71 +2035,98 @@ var SearchBox = defineComponent({
|
|
|
1848
2035
|
}
|
|
1849
2036
|
return null;
|
|
1850
2037
|
},
|
|
1851
|
-
|
|
2038
|
+
renderShortcut: function renderShortcut() {
|
|
2039
|
+
if (this.$props.focusShortcuts && this.$props.focusShortcuts.length) {
|
|
2040
|
+
var shortcut = this.$props.focusShortcuts[0];
|
|
2041
|
+
shortcut = shortcut.toLowerCase();
|
|
2042
|
+
shortcut = shortcut.replace('shift', '⬆️');
|
|
2043
|
+
shortcut = shortcut.replace('command', 'cmd');
|
|
2044
|
+
shortcut = shortcut.replace('control', 'ctrl');
|
|
2045
|
+
shortcut = shortcut.replace('option', 'alt');
|
|
2046
|
+
return shortcut.toUpperCase();
|
|
2047
|
+
}
|
|
2048
|
+
return '/';
|
|
2049
|
+
},
|
|
2050
|
+
renderLeftIcons: function renderLeftIcons() {
|
|
1852
2051
|
var _this7 = this;
|
|
1853
|
-
var _slot3
|
|
2052
|
+
var _slot3;
|
|
1854
2053
|
var _this$$props3 = this.$props,
|
|
1855
2054
|
iconPosition = _this$$props3.iconPosition,
|
|
1856
|
-
showClear = _this$$props3.showClear,
|
|
1857
|
-
innerClass = _this$$props3.innerClass,
|
|
1858
|
-
getMicInstance = _this$$props3.getMicInstance,
|
|
1859
|
-
showVoiceSearch = _this$$props3.showVoiceSearch,
|
|
1860
2055
|
showIcon = _this$$props3.showIcon;
|
|
2056
|
+
return createVNode("div", null, [createVNode(IconGroup, {
|
|
2057
|
+
"groupPosition": "left"
|
|
2058
|
+
}, {
|
|
2059
|
+
"default": function _default() {
|
|
2060
|
+
return [iconPosition === 'left' && showIcon && createVNode(IconWrapper, {
|
|
2061
|
+
"onClick": _this7.handleSearchIconClick
|
|
2062
|
+
}, _isSlot(_slot3 = _this7.renderIcon()) ? _slot3 : {
|
|
2063
|
+
"default": function _default() {
|
|
2064
|
+
return [_slot3];
|
|
2065
|
+
}
|
|
2066
|
+
})];
|
|
2067
|
+
}
|
|
2068
|
+
})]);
|
|
2069
|
+
},
|
|
2070
|
+
renderRightIcons: function renderRightIcons() {
|
|
2071
|
+
var _this8 = this;
|
|
2072
|
+
var _slot4, _slot5, _slot6;
|
|
2073
|
+
var _this$$props4 = this.$props,
|
|
2074
|
+
iconPosition = _this$$props4.iconPosition,
|
|
2075
|
+
showClear = _this$$props4.showClear,
|
|
2076
|
+
innerClass = _this$$props4.innerClass,
|
|
2077
|
+
getMicInstance = _this$$props4.getMicInstance,
|
|
2078
|
+
showVoiceSearch = _this$$props4.showVoiceSearch,
|
|
2079
|
+
showIcon = _this$$props4.showIcon,
|
|
2080
|
+
showFocusShortcutsIcon = _this$$props4.showFocusShortcutsIcon;
|
|
1861
2081
|
var renderMic = this.$slots.renderMic || this.$props.renderMic;
|
|
1862
2082
|
var currentValue = this.$data.currentValue;
|
|
1863
2083
|
return createVNode("div", null, [createVNode(IconGroup, {
|
|
1864
|
-
"groupPosition": "right"
|
|
1865
|
-
"positionType": "absolute"
|
|
2084
|
+
"groupPosition": "right"
|
|
1866
2085
|
}, {
|
|
1867
2086
|
"default": function _default() {
|
|
1868
2087
|
return [currentValue && showClear && createVNode(IconWrapper, {
|
|
1869
|
-
"onClick":
|
|
2088
|
+
"onClick": _this8.clearValue,
|
|
1870
2089
|
"showIcon": showIcon,
|
|
1871
2090
|
"isClearIcon": true
|
|
1872
|
-
}, _isSlot(
|
|
2091
|
+
}, _isSlot(_slot4 = _this8.renderCancelIcon()) ? _slot4 : {
|
|
1873
2092
|
"default": function _default() {
|
|
1874
|
-
return [
|
|
2093
|
+
return [_slot4];
|
|
2094
|
+
}
|
|
2095
|
+
}), showFocusShortcutsIcon && createVNode(ButtonIconWrapper, {
|
|
2096
|
+
"onClick": function onClick(e) {
|
|
2097
|
+
return _this8.focusSearchBox(e);
|
|
2098
|
+
}
|
|
2099
|
+
}, _isSlot(_slot5 = _this8.renderShortcut()) ? _slot5 : {
|
|
2100
|
+
"default": function _default() {
|
|
2101
|
+
return [_slot5];
|
|
1875
2102
|
}
|
|
1876
2103
|
}), showVoiceSearch && createVNode(Mic, {
|
|
1877
2104
|
"getInstance": getMicInstance,
|
|
1878
2105
|
"render": renderMic,
|
|
1879
|
-
"handleResult":
|
|
2106
|
+
"handleResult": _this8.handleVoiceResults,
|
|
1880
2107
|
"className": getClassName$1(innerClass, 'mic') || null
|
|
1881
2108
|
}, null), iconPosition === 'right' && showIcon && createVNode(IconWrapper, {
|
|
1882
|
-
"onClick":
|
|
1883
|
-
}, _isSlot(
|
|
1884
|
-
"default": function _default() {
|
|
1885
|
-
return [_slot4];
|
|
1886
|
-
}
|
|
1887
|
-
})];
|
|
1888
|
-
}
|
|
1889
|
-
}), createVNode(IconGroup, {
|
|
1890
|
-
"groupPosition": "left",
|
|
1891
|
-
"positionType": "absolute"
|
|
1892
|
-
}, {
|
|
1893
|
-
"default": function _default() {
|
|
1894
|
-
return [iconPosition === 'left' && showIcon && createVNode(IconWrapper, {
|
|
1895
|
-
"onClick": _this7.handleSearchIconClick
|
|
1896
|
-
}, _isSlot(_slot5 = _this7.renderIcon()) ? _slot5 : {
|
|
2109
|
+
"onClick": _this8.handleSearchIconClick
|
|
2110
|
+
}, _isSlot(_slot6 = _this8.renderIcon()) ? _slot6 : {
|
|
1897
2111
|
"default": function _default() {
|
|
1898
|
-
return [
|
|
2112
|
+
return [_slot6];
|
|
1899
2113
|
}
|
|
1900
2114
|
})];
|
|
1901
2115
|
}
|
|
1902
2116
|
})]);
|
|
1903
2117
|
},
|
|
1904
2118
|
focusSearchBox: function focusSearchBox(event) {
|
|
1905
|
-
var _this$$
|
|
2119
|
+
var _this$$refs4;
|
|
1906
2120
|
var elt = event.target || event.srcElement;
|
|
1907
2121
|
var tagName = elt.tagName;
|
|
1908
2122
|
if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
|
|
1909
2123
|
// already in an input
|
|
1910
2124
|
return;
|
|
1911
2125
|
}
|
|
1912
|
-
(_this$$
|
|
2126
|
+
(_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
|
|
1913
2127
|
},
|
|
1914
2128
|
listenForFocusShortcuts: function listenForFocusShortcuts() {
|
|
1915
|
-
var
|
|
2129
|
+
var _this9 = this;
|
|
1916
2130
|
var _this$$props$focusSho = this.$props.focusShortcuts,
|
|
1917
2131
|
focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
|
|
1918
2132
|
if (isEmpty(focusShortcuts)) {
|
|
@@ -1927,7 +2141,7 @@ var SearchBox = defineComponent({
|
|
|
1927
2141
|
function (event, handler) {
|
|
1928
2142
|
// Prevent the default refresh event under WINDOWS system
|
|
1929
2143
|
event.preventDefault();
|
|
1930
|
-
|
|
2144
|
+
_this9.focusSearchBox(event);
|
|
1931
2145
|
});
|
|
1932
2146
|
|
|
1933
2147
|
// if one of modifier keys are used, they are handled below
|
|
@@ -1937,7 +2151,7 @@ var SearchBox = defineComponent({
|
|
|
1937
2151
|
for (var index = 0; index < modifierKeys.length; index += 1) {
|
|
1938
2152
|
var element = modifierKeys[index];
|
|
1939
2153
|
if (hotkeys[element]) {
|
|
1940
|
-
|
|
2154
|
+
_this9.focusSearchBox(event);
|
|
1941
2155
|
break;
|
|
1942
2156
|
}
|
|
1943
2157
|
}
|
|
@@ -1949,19 +2163,34 @@ var SearchBox = defineComponent({
|
|
|
1949
2163
|
this.currentValue = decodeHtml(value);
|
|
1950
2164
|
this.triggerDefaultQuery(value);
|
|
1951
2165
|
},
|
|
1952
|
-
|
|
1953
|
-
var
|
|
2166
|
+
renderActionIcon: function renderActionIcon(suggestion) {
|
|
2167
|
+
var _this10 = this;
|
|
1954
2168
|
var handleAutoFillClick = function handleAutoFillClick(e) {
|
|
1955
2169
|
e.stopPropagation();
|
|
1956
|
-
|
|
2170
|
+
_this10.onAutofillClick(suggestion);
|
|
1957
2171
|
};
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
2172
|
+
if (suggestion._suggestion_type === suggestionTypes.Featured) {
|
|
2173
|
+
if (suggestion.action === featuredSuggestionsActionTypes.FUNCTION) {
|
|
2174
|
+
return createVNode(AutoFillSvg, {
|
|
2175
|
+
"style": {
|
|
2176
|
+
transform: 'rotate(135deg)',
|
|
2177
|
+
pointerEvents: 'none'
|
|
2178
|
+
}
|
|
2179
|
+
}, null);
|
|
2180
|
+
}
|
|
2181
|
+
return null;
|
|
2182
|
+
}
|
|
2183
|
+
if (!suggestion._category) {
|
|
2184
|
+
/* 👇 avoid showing autofill for category suggestions👇 */
|
|
2185
|
+
|
|
2186
|
+
return createVNode(AutoFillSvg, {
|
|
2187
|
+
"onClick": handleAutoFillClick
|
|
2188
|
+
}, null);
|
|
2189
|
+
}
|
|
2190
|
+
return null;
|
|
1962
2191
|
},
|
|
1963
2192
|
renderTag: function renderTag(item) {
|
|
1964
|
-
var
|
|
2193
|
+
var _this11 = this;
|
|
1965
2194
|
var innerClass = this.$props.innerClass;
|
|
1966
2195
|
return createVNode(TagItem, {
|
|
1967
2196
|
"class": getClassName$1(innerClass, 'selected-tag') || ''
|
|
@@ -1972,7 +2201,7 @@ var SearchBox = defineComponent({
|
|
|
1972
2201
|
"aria-label": "delete-tag",
|
|
1973
2202
|
"class": "close-icon",
|
|
1974
2203
|
"onClick": function onClick() {
|
|
1975
|
-
return
|
|
2204
|
+
return _this11.clearTag(item);
|
|
1976
2205
|
}
|
|
1977
2206
|
}, [createVNode(CancelSvg, null, null)])];
|
|
1978
2207
|
}
|
|
@@ -1995,7 +2224,7 @@ var SearchBox = defineComponent({
|
|
|
1995
2224
|
}
|
|
1996
2225
|
},
|
|
1997
2226
|
renderTags: function renderTags() {
|
|
1998
|
-
var
|
|
2227
|
+
var _this12 = this;
|
|
1999
2228
|
if (!Array.isArray(this.selectedTags)) {
|
|
2000
2229
|
return null;
|
|
2001
2230
|
}
|
|
@@ -2009,16 +2238,16 @@ var SearchBox = defineComponent({
|
|
|
2009
2238
|
}) : createVNode(TagsContainer, null, {
|
|
2010
2239
|
"default": function _default() {
|
|
2011
2240
|
return [tagsList.map(function (item) {
|
|
2012
|
-
return
|
|
2241
|
+
return _this12.renderTag(item);
|
|
2013
2242
|
}), shouldRenderClearAllTag && createVNode(TagItem, {
|
|
2014
|
-
"class": getClassName$1(
|
|
2243
|
+
"class": getClassName$1(_this12.$props.innerClass, 'selected-tag') || ''
|
|
2015
2244
|
}, {
|
|
2016
2245
|
"default": function _default() {
|
|
2017
2246
|
return [createVNode("span", null, [createTextVNode("Clear All")]), createVNode("span", {
|
|
2018
2247
|
"role": "img",
|
|
2019
2248
|
"aria-label": "delete-tag",
|
|
2020
2249
|
"class": "close-icon",
|
|
2021
|
-
"onClick":
|
|
2250
|
+
"onClick": _this12.clearAllTags
|
|
2022
2251
|
}, [createVNode(CancelSvg, null, null)])];
|
|
2023
2252
|
}
|
|
2024
2253
|
})];
|
|
@@ -2065,49 +2294,56 @@ var SearchBox = defineComponent({
|
|
|
2065
2294
|
return createVNode(HorizontalSkeletonLoader, null, null);
|
|
2066
2295
|
},
|
|
2067
2296
|
renderAIScreenFooter: function renderAIScreenFooter() {
|
|
2068
|
-
var
|
|
2069
|
-
var
|
|
2297
|
+
var _slot8;
|
|
2298
|
+
var _this13 = this;
|
|
2070
2299
|
var _this$$props$AIUIConf2 = this.$props.AIUIConfig,
|
|
2071
2300
|
AIUIConfig = _this$$props$AIUIConf2 === void 0 ? {} : _this$$props$AIUIConf2;
|
|
2072
2301
|
var _ref6 = AIUIConfig || {},
|
|
2073
2302
|
_ref6$showSourceDocum = _ref6.showSourceDocuments,
|
|
2074
2303
|
showSourceDocuments = _ref6$showSourceDocum === void 0 ? true : _ref6$showSourceDocum,
|
|
2075
|
-
_ref6$sourceDocumentL = _ref6.sourceDocumentLabel,
|
|
2076
|
-
sourceDocumentLabel = _ref6$sourceDocumentL === void 0 ? '_id' : _ref6$sourceDocumentL,
|
|
2077
2304
|
_ref6$onSourceClick = _ref6.onSourceClick,
|
|
2078
2305
|
onSourceClick = _ref6$onSourceClick === void 0 ? function () {} : _ref6$onSourceClick;
|
|
2306
|
+
var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
|
|
2307
|
+
if (_this13.$props.AIUIConfig && _this13.$props.AIUIConfig.renderSourceDocument) {
|
|
2308
|
+
return _this13.$props.AIUIConfig.renderSourceDocument(sourceObj);
|
|
2309
|
+
}
|
|
2310
|
+
if (_this13.$slots.renderSourceDocument) {
|
|
2311
|
+
return _this13.$slots.renderSourceDocument(sourceObj);
|
|
2312
|
+
}
|
|
2313
|
+
return sourceObj._id;
|
|
2314
|
+
};
|
|
2079
2315
|
return showSourceDocuments && this.showAIScreenFooter && this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds ? createVNode(Footer, {
|
|
2080
2316
|
"themePreset": this.$props.themePreset
|
|
2081
2317
|
}, {
|
|
2082
2318
|
"default": function _default() {
|
|
2083
|
-
return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(
|
|
2319
|
+
return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot(_slot8 = _this13.getAISourceObjects().map(function (el) {
|
|
2320
|
+
var _slot7;
|
|
2084
2321
|
return createVNode(Button, {
|
|
2085
|
-
"class": "--ai-source-tag " + (getClassName$1(
|
|
2086
|
-
"title": el[sourceDocumentLabel],
|
|
2322
|
+
"class": "--ai-source-tag " + (getClassName$1(_this13.$props.innerClass, 'ai-source-tag') || ''),
|
|
2087
2323
|
"info": true,
|
|
2088
2324
|
"onClick": function onClick() {
|
|
2089
2325
|
return onSourceClick && onSourceClick(el);
|
|
2090
2326
|
}
|
|
2091
|
-
}, {
|
|
2327
|
+
}, _isSlot(_slot7 = renderSourceDocumentLabel(el)) ? _slot7 : {
|
|
2092
2328
|
"default": function _default() {
|
|
2093
|
-
return [
|
|
2329
|
+
return [_slot7];
|
|
2094
2330
|
}
|
|
2095
2331
|
});
|
|
2096
|
-
})) ?
|
|
2332
|
+
})) ? _slot8 : {
|
|
2097
2333
|
"default": function _default() {
|
|
2098
|
-
return [
|
|
2334
|
+
return [_slot8];
|
|
2099
2335
|
}
|
|
2100
2336
|
})];
|
|
2101
2337
|
}
|
|
2102
2338
|
}) : null;
|
|
2103
2339
|
},
|
|
2104
2340
|
renderAIScreen: function renderAIScreen() {
|
|
2105
|
-
var
|
|
2341
|
+
var _this14 = this;
|
|
2106
2342
|
var customAIRenderer = this.$props.renderAIAnswer || this.$slots.renderAIAnswer;
|
|
2107
2343
|
if (customAIRenderer) {
|
|
2108
2344
|
return customAIRenderer({
|
|
2109
|
-
question: this.
|
|
2110
|
-
answer: this.
|
|
2345
|
+
question: this.mergedAIQuestion,
|
|
2346
|
+
answer: this.mergedAIAnswer,
|
|
2111
2347
|
documentIds: this.AIResponse && this.AIResponse.response && this.AIResponse.response.answer && this.AIResponse.response.answer.documentIds || [],
|
|
2112
2348
|
loading: this.isAIResponseLoading || this.isLoading,
|
|
2113
2349
|
sources: this.getAISourceObjects(),
|
|
@@ -2118,7 +2354,7 @@ var SearchBox = defineComponent({
|
|
|
2118
2354
|
return this.renderAIScreenLoader();
|
|
2119
2355
|
}
|
|
2120
2356
|
return createVNode("div", null, [createVNode(Answer, {
|
|
2121
|
-
"innerHTML": md.render(this.
|
|
2357
|
+
"innerHTML": md.render(this.mergedAIAnswer)
|
|
2122
2358
|
}, null), this.renderAIScreenFooter(), this.showFeedbackComponent && createVNode("div", {
|
|
2123
2359
|
"class": "" + (getClassName$1(this.$props.innerClass, 'ai-feedback') || '')
|
|
2124
2360
|
}, [createVNode(AIFeedback, {
|
|
@@ -2126,11 +2362,11 @@ var SearchBox = defineComponent({
|
|
|
2126
2362
|
"hideUI": this.isAIResponseLoading || this.isLoading || !this.sessionIdFromStore,
|
|
2127
2363
|
"key": this.sessionIdFromStore,
|
|
2128
2364
|
"onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
|
|
2129
|
-
|
|
2365
|
+
_this14.feedbackState = {
|
|
2130
2366
|
isRecorded: true,
|
|
2131
2367
|
feedbackType: useful ? 'positive' : 'negative'
|
|
2132
2368
|
};
|
|
2133
|
-
|
|
2369
|
+
_this14.recordAISessionUsefulness(_this14.sessionIdFromStore, {
|
|
2134
2370
|
useful: useful,
|
|
2135
2371
|
reason: reason
|
|
2136
2372
|
});
|
|
@@ -2165,22 +2401,22 @@ var SearchBox = defineComponent({
|
|
|
2165
2401
|
});
|
|
2166
2402
|
},
|
|
2167
2403
|
renderAskButtonElement: function renderAskButtonElement() {
|
|
2168
|
-
var
|
|
2169
|
-
var _this$$
|
|
2170
|
-
AIUIConfig = _this$$
|
|
2171
|
-
innerClass = _this$$
|
|
2404
|
+
var _this15 = this;
|
|
2405
|
+
var _this$$props5 = this.$props,
|
|
2406
|
+
AIUIConfig = _this$$props5.AIUIConfig,
|
|
2407
|
+
innerClass = _this$$props5.innerClass;
|
|
2172
2408
|
var _ref7 = AIUIConfig || {},
|
|
2173
2409
|
askButton = _ref7.askButton;
|
|
2174
2410
|
var renderAskButton = this.$slots.renderAskButton;
|
|
2175
2411
|
if (askButton) {
|
|
2176
2412
|
var getEnterButtonMarkup = function getEnterButtonMarkup() {
|
|
2177
2413
|
if (renderAskButton) {
|
|
2178
|
-
return renderAskButton(
|
|
2414
|
+
return renderAskButton(_this15.askButtonOnClick);
|
|
2179
2415
|
}
|
|
2180
2416
|
return createVNode(Button, {
|
|
2181
2417
|
"class": "enter-btn " + getClassName$1(innerClass, 'ask-button'),
|
|
2182
2418
|
"info": true,
|
|
2183
|
-
"onClick":
|
|
2419
|
+
"onClick": _this15.askButtonOnClick
|
|
2184
2420
|
}, {
|
|
2185
2421
|
"default": function _default() {
|
|
2186
2422
|
return [createTextVNode("Ask")];
|
|
@@ -2195,7 +2431,7 @@ var SearchBox = defineComponent({
|
|
|
2195
2431
|
}
|
|
2196
2432
|
},
|
|
2197
2433
|
render: function render() {
|
|
2198
|
-
var
|
|
2434
|
+
var _this16 = this;
|
|
2199
2435
|
var expandSuggestionsContainer = this.$props.expandSuggestionsContainer;
|
|
2200
2436
|
var _this$$slots = this.$slots,
|
|
2201
2437
|
recentSearchesIcon = _this$$slots.recentSearchesIcon,
|
|
@@ -2206,17 +2442,17 @@ var SearchBox = defineComponent({
|
|
|
2206
2442
|
"class": this.$props.className
|
|
2207
2443
|
}, {
|
|
2208
2444
|
"default": function _default() {
|
|
2209
|
-
return [
|
|
2210
|
-
"class": getClassName$1(
|
|
2445
|
+
return [_this16.$props.title && createVNode(Title, {
|
|
2446
|
+
"class": getClassName$1(_this16.$props.innerClass, 'title') || ''
|
|
2211
2447
|
}, {
|
|
2212
2448
|
"default": function _default() {
|
|
2213
|
-
return [
|
|
2449
|
+
return [_this16.$props.title];
|
|
2214
2450
|
}
|
|
2215
|
-
}),
|
|
2216
|
-
"id":
|
|
2217
|
-
"handleChange":
|
|
2218
|
-
"handleMouseup":
|
|
2219
|
-
"isOpen":
|
|
2451
|
+
}), _this16.$props.autosuggest ? createVNode(Downshift, {
|
|
2452
|
+
"id": _this16.$props.componentId + "-downshift",
|
|
2453
|
+
"handleChange": _this16.onSuggestionSelected,
|
|
2454
|
+
"handleMouseup": _this16.handleStateChange,
|
|
2455
|
+
"isOpen": _this16.$data.isOpen
|
|
2220
2456
|
}, {
|
|
2221
2457
|
"default": function _default(_ref8) {
|
|
2222
2458
|
var getInputEvents = _ref8.getInputEvents,
|
|
@@ -2227,156 +2463,249 @@ var SearchBox = defineComponent({
|
|
|
2227
2463
|
highlightedIndex = _ref8.highlightedIndex,
|
|
2228
2464
|
setHighlightedIndex = _ref8.setHighlightedIndex;
|
|
2229
2465
|
var renderSuggestionsDropdown = function renderSuggestionsDropdown() {
|
|
2230
|
-
var getIcon = function getIcon(iconType) {
|
|
2466
|
+
var getIcon = function getIcon(iconType, item, leaveSpaceForIcon) {
|
|
2231
2467
|
switch (iconType) {
|
|
2232
2468
|
case suggestionTypes.Recent:
|
|
2233
2469
|
return recentSearchesIcon;
|
|
2234
2470
|
case suggestionTypes.Popular:
|
|
2235
2471
|
return popularSearchesIcon;
|
|
2472
|
+
case suggestionTypes.Featured:
|
|
2473
|
+
if (item.icon) {
|
|
2474
|
+
return function () {
|
|
2475
|
+
return createVNode("div", {
|
|
2476
|
+
"style": {
|
|
2477
|
+
display: 'flex'
|
|
2478
|
+
},
|
|
2479
|
+
"innerHTML": xss(item.icon)
|
|
2480
|
+
}, null);
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
if (item.iconURL) {
|
|
2484
|
+
return function () {
|
|
2485
|
+
return (// When you change below also change the empty icon below
|
|
2486
|
+
createVNode("img", {
|
|
2487
|
+
"style": {
|
|
2488
|
+
maxWidth: '30px'
|
|
2489
|
+
},
|
|
2490
|
+
"src": xss(item.iconURL),
|
|
2491
|
+
"alt": item.value
|
|
2492
|
+
}, null)
|
|
2493
|
+
);
|
|
2494
|
+
};
|
|
2495
|
+
}
|
|
2496
|
+
// Render an empty icon when no icon is provided from the dashboard
|
|
2497
|
+
return function () {
|
|
2498
|
+
return createVNode("span", {
|
|
2499
|
+
"style": {
|
|
2500
|
+
display: 'inline-block',
|
|
2501
|
+
height: '30px',
|
|
2502
|
+
width: leaveSpaceForIcon ? '30px' : 0
|
|
2503
|
+
}
|
|
2504
|
+
}, null);
|
|
2505
|
+
};
|
|
2236
2506
|
default:
|
|
2237
2507
|
return null;
|
|
2238
2508
|
}
|
|
2239
2509
|
};
|
|
2240
|
-
|
|
2510
|
+
var indexOffset = 0;
|
|
2511
|
+
return createVNode("div", null, [_this16.hasCustomRenderer && _this16.getComponent({
|
|
2241
2512
|
isOpen: isOpen,
|
|
2242
2513
|
getItemProps: getItemProps,
|
|
2243
2514
|
getItemEvents: getItemEvents,
|
|
2244
2515
|
highlightedIndex: highlightedIndex
|
|
2245
|
-
}),
|
|
2246
|
-
"class": suggestions(
|
|
2516
|
+
}), _this16.renderErrorComponent(), !_this16.hasCustomRenderer && isOpen && hasSuggestions ? createVNode("ul", {
|
|
2517
|
+
"class": suggestions(_this16.themePreset, _this16.theme) + " " + getClassName$1(_this16.$props.innerClass, 'list') + " " + searchboxSuggestions(_this16.themePreset, _this16.theme) + "\n\t\t\t\t\t\t\t\t\t\t\t\t\t",
|
|
2247
2518
|
"ref": _dropdownULRef
|
|
2248
|
-
}, [
|
|
2249
|
-
"themePreset":
|
|
2519
|
+
}, [_this16.showAIScreen && createVNode(SearchBoxAISection, {
|
|
2520
|
+
"themePreset": _this16.$props.themePreset
|
|
2250
2521
|
}, {
|
|
2251
2522
|
"default": function _default() {
|
|
2252
|
-
return [
|
|
2523
|
+
return [_this16.renderAIScreen(), ' ', _this16.renderErrorComponent(true)];
|
|
2253
2524
|
}
|
|
2254
|
-
}), !
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
item
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2525
|
+
}), !_this16.showAIScreen && _this16.parsedSuggestions.map(function (item, itemIndex) {
|
|
2526
|
+
var index = indexOffset + itemIndex;
|
|
2527
|
+
if (Array.isArray(item)) {
|
|
2528
|
+
var sectionHtml = xss(item[0].sectionLabel);
|
|
2529
|
+
indexOffset += item.length - 1;
|
|
2530
|
+
return createVNode("div", {
|
|
2531
|
+
"key": "section-" + itemIndex,
|
|
2532
|
+
"class": "section-container"
|
|
2533
|
+
}, [sectionHtml ? createVNode("div", {
|
|
2534
|
+
"class": "section-header " + getClassName$1(_this16.$props.innerClass, 'section-label'),
|
|
2535
|
+
"key": "" + item[0].sectionId,
|
|
2536
|
+
"innerHTML": sectionHtml
|
|
2537
|
+
}, null) : null, createVNode("ul", {
|
|
2538
|
+
"class": "section-list"
|
|
2539
|
+
}, [item.map(function (sectionItem, sectionIndex) {
|
|
2540
|
+
var suggestionsHaveIcon = item.some(function (s) {
|
|
2541
|
+
return s.icon || s.iconURL;
|
|
2542
|
+
});
|
|
2543
|
+
if (renderItem) {
|
|
2544
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2545
|
+
item: sectionItem
|
|
2546
|
+
}), _transformOn(getItemEvents({
|
|
2547
|
+
item: sectionItem
|
|
2548
|
+
})), {
|
|
2549
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2550
|
+
"style": {
|
|
2551
|
+
justifyContent: 'flex-start',
|
|
2552
|
+
alignItems: 'center'
|
|
2553
|
+
},
|
|
2554
|
+
"class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
|
|
2555
|
+
}), [renderItem(sectionItem)]);
|
|
2556
|
+
}
|
|
2557
|
+
if (sectionItem._suggestion_type === '_internal_a_i_trigger') {
|
|
2558
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2559
|
+
item: sectionItem
|
|
2560
|
+
}), _transformOn(getItemEvents({
|
|
2561
|
+
item: sectionItem
|
|
2562
|
+
})), {
|
|
2563
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2564
|
+
"style": {
|
|
2565
|
+
justifyContent: 'flex-start',
|
|
2566
|
+
alignItems: 'center'
|
|
2567
|
+
},
|
|
2568
|
+
"class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
|
|
2569
|
+
}), [createVNode(SuggestionItem, {
|
|
2570
|
+
"currentValue": _this16.currentValue,
|
|
2571
|
+
"suggestion": sectionItem
|
|
2572
|
+
}, null)]);
|
|
2573
|
+
}
|
|
2574
|
+
return createVNode("li", mergeProps(getItemProps({
|
|
2575
|
+
item: sectionItem
|
|
2576
|
+
}), _transformOn(getItemEvents({
|
|
2577
|
+
item: sectionItem
|
|
2578
|
+
})), {
|
|
2579
|
+
"key": sectionItem._id + "_" + index + "_" + sectionIndex,
|
|
2580
|
+
"style": {
|
|
2581
|
+
justifyContent: 'flex-start',
|
|
2582
|
+
alignItems: 'center'
|
|
2583
|
+
},
|
|
2584
|
+
"class": "" + (highlightedIndex === index + sectionIndex ? "active-li-item " + getClassName$1(_this16.$props.innerClass, 'active-suggestion-item') : "li-item " + getClassName$1(_this16.$props.innerClass, 'suggestion-item'))
|
|
2585
|
+
}), [createVNode("div", {
|
|
2586
|
+
"style": {
|
|
2587
|
+
padding: '0 10px 0 0',
|
|
2588
|
+
display: 'flex'
|
|
2589
|
+
}
|
|
2590
|
+
}, [createVNode(CustomSvg, {
|
|
2591
|
+
"key": sectionItem._suggestion_type + "-" + sectionIndex,
|
|
2592
|
+
"className": getClassName$1(_this16.$props.innerClass, sectionItem._suggestion_type + "-search-icon") || null,
|
|
2593
|
+
"icon": getIcon(sectionItem._suggestion_type, sectionItem, suggestionsHaveIcon),
|
|
2594
|
+
"type": sectionItem._suggestion_type + "-search-icon"
|
|
2595
|
+
}, null)]), createVNode(SuggestionItem, {
|
|
2596
|
+
"currentValue": _this16.currentValue,
|
|
2597
|
+
"suggestion": sectionItem
|
|
2598
|
+
}, null), _this16.renderActionIcon(sectionItem)]);
|
|
2599
|
+
})])]);
|
|
2600
|
+
}
|
|
2601
|
+
return createVNode("div", null, [createTextVNode("No suggestions")]);
|
|
2602
|
+
}), !_this16.showAIScreen && _this16.parsedSuggestions.length && _this16.$props.showSuggestionsFooter ? _this16.suggestionsFooter() : null]) : _this16.renderNoSuggestions(_this16.normalizedSuggestions)]);
|
|
2291
2603
|
};
|
|
2292
2604
|
return createVNode("div", {
|
|
2293
2605
|
"class": suggestionsContainer
|
|
2294
2606
|
}, [createVNode(InputGroup, {
|
|
2295
|
-
"
|
|
2607
|
+
"searchBox": true,
|
|
2608
|
+
"ref": _inputGroupRef,
|
|
2609
|
+
"isOpen": _this16.$data.isOpen
|
|
2296
2610
|
}, {
|
|
2297
2611
|
"default": function _default() {
|
|
2298
|
-
return [
|
|
2612
|
+
return [createVNode(Actions$1, null, {
|
|
2613
|
+
"default": function _default() {
|
|
2614
|
+
return [_this16.renderInputAddonBefore(), _this16.renderLeftIcons()];
|
|
2615
|
+
}
|
|
2616
|
+
}), createVNode(InputWrapper, null, {
|
|
2299
2617
|
"default": function _default() {
|
|
2300
2618
|
return [createVNode(TextArea, mergeProps(_transformOn(getInputEvents({
|
|
2301
|
-
onInput:
|
|
2619
|
+
onInput: _this16.onInputChange,
|
|
2302
2620
|
onBlur: function onBlur(e) {
|
|
2303
|
-
|
|
2621
|
+
_this16.$emit('blur', e, _this16.triggerQuery);
|
|
2304
2622
|
},
|
|
2305
|
-
onFocus:
|
|
2623
|
+
onFocus: _this16.handleFocus,
|
|
2306
2624
|
onKeyPress: function onKeyPress(e) {
|
|
2307
|
-
|
|
2308
|
-
|
|
2625
|
+
_this16.$emit('keyPress', e, _this16.triggerQuery);
|
|
2626
|
+
_this16.$emit('key-press', e, _this16.triggerQuery);
|
|
2309
2627
|
},
|
|
2310
2628
|
onKeyDown: function onKeyDown(e) {
|
|
2311
|
-
return
|
|
2629
|
+
return _this16.handleKeyDown(e, highlightedIndex);
|
|
2312
2630
|
},
|
|
2313
2631
|
onKeyUp: function onKeyUp(e) {
|
|
2314
|
-
|
|
2315
|
-
|
|
2632
|
+
_this16.$emit('keyUp', e, _this16.triggerQuery);
|
|
2633
|
+
_this16.$emit('key-up', e, _this16.triggerQuery);
|
|
2316
2634
|
},
|
|
2317
2635
|
onClick: function onClick() {
|
|
2318
2636
|
setHighlightedIndex(null);
|
|
2319
2637
|
}
|
|
2320
2638
|
})), {
|
|
2321
|
-
"
|
|
2322
|
-
"
|
|
2323
|
-
"
|
|
2324
|
-
"
|
|
2325
|
-
"
|
|
2326
|
-
"
|
|
2327
|
-
"
|
|
2328
|
-
"autoFocus": _this15.$props.autoFocus,
|
|
2329
|
-
"showFocusShortcutsIcon": _this15.$props.showFocusShortcutsIcon,
|
|
2330
|
-
"showVoiceSearch": _this15.$props.showVoiceSearch
|
|
2639
|
+
"searchBox": true,
|
|
2640
|
+
"isOpen": _this16.$data.isOpen,
|
|
2641
|
+
"id": _this16.$props.componentId + "-input",
|
|
2642
|
+
"ref": _this16.$props.innerRef,
|
|
2643
|
+
"class": getClassName$1(_this16.$props.innerClass, 'input'),
|
|
2644
|
+
"placeholder": _this16.$props.placeholder,
|
|
2645
|
+
"autoFocus": _this16.$props.autoFocus
|
|
2331
2646
|
}, getInputProps({
|
|
2332
|
-
value:
|
|
2647
|
+
value: _this16.$data.currentValue === null ? '' : _this16.$data.currentValue
|
|
2333
2648
|
}), {
|
|
2334
|
-
"themePreset":
|
|
2649
|
+
"themePreset": _this16.themePreset,
|
|
2335
2650
|
"autocomplete": "off"
|
|
2336
|
-
}), null),
|
|
2651
|
+
}), null), !expandSuggestionsContainer && renderSuggestionsDropdown()];
|
|
2337
2652
|
}
|
|
2338
|
-
}),
|
|
2653
|
+
}), createVNode(Actions$1, null, {
|
|
2654
|
+
"default": function _default() {
|
|
2655
|
+
return [_this16.renderRightIcons(), _this16.renderInputAddonAfter(), _this16.renderAskButtonElement(), _this16.renderEnterButtonElement()];
|
|
2656
|
+
}
|
|
2657
|
+
})];
|
|
2339
2658
|
}
|
|
2340
|
-
}), expandSuggestionsContainer && renderSuggestionsDropdown(),
|
|
2659
|
+
}), expandSuggestionsContainer && renderSuggestionsDropdown(), _this16.renderTags()]);
|
|
2341
2660
|
}
|
|
2342
2661
|
}) : createVNode("div", {
|
|
2343
2662
|
"class": suggestionsContainer
|
|
2344
2663
|
}, [createVNode(InputGroup, {
|
|
2664
|
+
"searchBox": true,
|
|
2345
2665
|
"ref": _inputGroupRef
|
|
2346
2666
|
}, {
|
|
2347
2667
|
"default": function _default() {
|
|
2348
|
-
return [
|
|
2668
|
+
return [createVNode(Actions$1, null, {
|
|
2669
|
+
"default": function _default() {
|
|
2670
|
+
return [_this16.renderInputAddonBefore(), _this16.renderLeftIcons()];
|
|
2671
|
+
}
|
|
2672
|
+
}), createVNode(InputWrapper, null, {
|
|
2349
2673
|
"default": function _default() {
|
|
2350
2674
|
return [createVNode(TextArea, mergeProps(_transformOn({
|
|
2351
2675
|
blur: function blur(e) {
|
|
2352
|
-
|
|
2676
|
+
_this16.$emit('blur', e, _this16.triggerQuery);
|
|
2353
2677
|
},
|
|
2354
2678
|
keypress: function keypress(e) {
|
|
2355
|
-
|
|
2356
|
-
|
|
2679
|
+
_this16.$emit('keyPress', e, _this16.triggerQuery);
|
|
2680
|
+
_this16.$emit('key-press', e, _this16.triggerQuery);
|
|
2357
2681
|
},
|
|
2358
|
-
input:
|
|
2682
|
+
input: _this16.onInputChange,
|
|
2359
2683
|
focus: function focus(e) {
|
|
2360
|
-
|
|
2684
|
+
_this16.$emit('focus', e, _this16.triggerQuery);
|
|
2361
2685
|
},
|
|
2362
|
-
keydown:
|
|
2686
|
+
keydown: _this16.handleKeyDown,
|
|
2363
2687
|
keyup: function keyup(e) {
|
|
2364
|
-
|
|
2365
|
-
|
|
2688
|
+
_this16.$emit('keyUp', e, _this16.triggerQuery);
|
|
2689
|
+
_this16.$emit('key-up', e, _this16.triggerQuery);
|
|
2366
2690
|
}
|
|
2367
2691
|
}), {
|
|
2368
|
-
"
|
|
2369
|
-
"
|
|
2370
|
-
"
|
|
2371
|
-
"
|
|
2372
|
-
"
|
|
2373
|
-
"
|
|
2374
|
-
"
|
|
2375
|
-
"
|
|
2376
|
-
"
|
|
2377
|
-
|
|
2692
|
+
"searchBox": true,
|
|
2693
|
+
"class": getClassName$1(_this16.$props.innerClass, 'input') || '',
|
|
2694
|
+
"placeholder": _this16.$props.placeholder,
|
|
2695
|
+
"autofocus": _this16.$props.autoFocus,
|
|
2696
|
+
"value": _this16.$data.currentValue ? _this16.$data.currentValue : '',
|
|
2697
|
+
"iconPosition": _this16.$props.iconPosition,
|
|
2698
|
+
"showIcon": _this16.$props.showIcon,
|
|
2699
|
+
"showClear": _this16.$props.showClear,
|
|
2700
|
+
"ref": _this16.$props.innerRef,
|
|
2701
|
+
"themePreset": _this16.themePreset
|
|
2702
|
+
}), null)];
|
|
2703
|
+
}
|
|
2704
|
+
}), createVNode(Actions$1, null, {
|
|
2705
|
+
"default": function _default() {
|
|
2706
|
+
return [_this16.renderRightIcons(), _this16.renderInputAddonAfter(), _this16.renderEnterButtonElement()];
|
|
2378
2707
|
}
|
|
2379
|
-
})
|
|
2708
|
+
})];
|
|
2380
2709
|
}
|
|
2381
2710
|
})])];
|
|
2382
2711
|
}
|
|
@@ -2462,6 +2791,7 @@ SBConnected.install = function (Vue) {
|
|
|
2462
2791
|
// Add componentType for SSR
|
|
2463
2792
|
SBConnected.componentType = componentTypes.searchBox;
|
|
2464
2793
|
|
|
2794
|
+
var _excluded$1 = ["_source"];
|
|
2465
2795
|
function _isSlot$1(s) {
|
|
2466
2796
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
2467
2797
|
}
|
|
@@ -2469,7 +2799,9 @@ var md$1 = new Remarkable();
|
|
|
2469
2799
|
md$1.set({
|
|
2470
2800
|
html: true,
|
|
2471
2801
|
breaks: true,
|
|
2472
|
-
xhtmlOut: true
|
|
2802
|
+
xhtmlOut: true,
|
|
2803
|
+
linkify: true,
|
|
2804
|
+
linkTarget: '_blank'
|
|
2473
2805
|
});
|
|
2474
2806
|
var _inputWrapperRef = 'inputWrapperRef';
|
|
2475
2807
|
var _inputRef = 'inputRef';
|
|
@@ -2482,7 +2814,10 @@ var AIAnswer = defineComponent({
|
|
|
2482
2814
|
messages: [],
|
|
2483
2815
|
inputMessage: '',
|
|
2484
2816
|
AISessionId: '',
|
|
2485
|
-
error: null
|
|
2817
|
+
error: null,
|
|
2818
|
+
sourceDocIds: null,
|
|
2819
|
+
initialHits: null,
|
|
2820
|
+
isTriggered: false
|
|
2486
2821
|
};
|
|
2487
2822
|
this.internalComponent = props.componentId + "__internal";
|
|
2488
2823
|
return this.__state;
|
|
@@ -2492,7 +2827,16 @@ var AIAnswer = defineComponent({
|
|
|
2492
2827
|
from: 'theme_reactivesearch'
|
|
2493
2828
|
}
|
|
2494
2829
|
},
|
|
2495
|
-
created: function created() {
|
|
2830
|
+
created: function created() {
|
|
2831
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
|
|
2832
|
+
this.isTriggered = true;
|
|
2833
|
+
} else if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
|
|
2834
|
+
this.isTriggered = true;
|
|
2835
|
+
if (this.AISessionId) {
|
|
2836
|
+
this.handleSendMessage(null, false, '', true);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
},
|
|
2496
2840
|
computed: {
|
|
2497
2841
|
hasCustomRenderer: function hasCustomRenderer$1() {
|
|
2498
2842
|
return hasCustomRenderer(this);
|
|
@@ -2505,6 +2849,9 @@ var AIAnswer = defineComponent({
|
|
|
2505
2849
|
},
|
|
2506
2850
|
errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
|
|
2507
2851
|
return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
|
|
2852
|
+
},
|
|
2853
|
+
hasTriggered: function hasTriggered() {
|
|
2854
|
+
return this.isTriggered;
|
|
2508
2855
|
}
|
|
2509
2856
|
},
|
|
2510
2857
|
props: {
|
|
@@ -2543,13 +2890,26 @@ var AIAnswer = defineComponent({
|
|
|
2543
2890
|
sessionIdFromStore: VueTypes.string,
|
|
2544
2891
|
showComponent: types.boolRequired,
|
|
2545
2892
|
componentError: types.componentObject,
|
|
2546
|
-
style: types.style
|
|
2893
|
+
style: types.style,
|
|
2894
|
+
showSourceDocuments: VueTypes.bool.def(false),
|
|
2895
|
+
renderSourceDocument: types.func,
|
|
2896
|
+
onSourceClick: types.func,
|
|
2897
|
+
isAITyping: types.boolRequired,
|
|
2898
|
+
triggerOn: VueTypes.string.def(AI_TRIGGER_MODES.ALWAYS),
|
|
2899
|
+
renderTriggerMessage: types.func
|
|
2547
2900
|
},
|
|
2548
2901
|
mounted: function mounted() {},
|
|
2549
2902
|
watch: {
|
|
2550
2903
|
AIResponse: function AIResponse(newVal) {
|
|
2551
2904
|
if (newVal) {
|
|
2552
|
-
this.
|
|
2905
|
+
if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
|
|
2906
|
+
this.sourceDocIds = newVal.response.answer.documentIds;
|
|
2907
|
+
var localCache = getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) && getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY)[this.$props.componentId];
|
|
2908
|
+
if (localCache && localCache.meta && localCache.meta.hits) {
|
|
2909
|
+
this.initialHits = localCache.meta.hits;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2553
2913
|
var messagesHistory = newVal.messages,
|
|
2554
2914
|
response = newVal.response;
|
|
2555
2915
|
var finalMessages = [];
|
|
@@ -2560,7 +2920,7 @@ var AIAnswer = defineComponent({
|
|
|
2560
2920
|
}
|
|
2561
2921
|
|
|
2562
2922
|
// pushing message history so far
|
|
2563
|
-
if (messagesHistory &&
|
|
2923
|
+
if (messagesHistory && Array.isArray(messagesHistory)) {
|
|
2564
2924
|
finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
|
|
2565
2925
|
return msg.role !== AI_ROLES.SYSTEM;
|
|
2566
2926
|
}));
|
|
@@ -2585,6 +2945,9 @@ var AIAnswer = defineComponent({
|
|
|
2585
2945
|
loading: this.$props.isAIResponseLoading || this.$props.isLoading,
|
|
2586
2946
|
error: this.$props.AIResponseError
|
|
2587
2947
|
});
|
|
2948
|
+
if (newVal && newVal.hits && newVal.hits.hits) {
|
|
2949
|
+
this.initialHits = newVal.hits.hits;
|
|
2950
|
+
}
|
|
2588
2951
|
},
|
|
2589
2952
|
isAIResponseLoading: function isAIResponseLoading(newVal) {
|
|
2590
2953
|
this.$emit('on-data', {
|
|
@@ -2609,7 +2972,7 @@ var AIAnswer = defineComponent({
|
|
|
2609
2972
|
},
|
|
2610
2973
|
AIResponseError: function AIResponseError(newVal) {
|
|
2611
2974
|
this.error = newVal;
|
|
2612
|
-
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId ||
|
|
2975
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2613
2976
|
if (this.error && !this.AISessionId) {
|
|
2614
2977
|
var errorMessage = this.errorMessageForMissingSessionId;
|
|
2615
2978
|
this.error = {
|
|
@@ -2630,7 +2993,7 @@ var AIAnswer = defineComponent({
|
|
|
2630
2993
|
componentError: function componentError(newVal) {
|
|
2631
2994
|
var _this = this;
|
|
2632
2995
|
if (newVal && newVal._bodyBlob) {
|
|
2633
|
-
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId ||
|
|
2996
|
+
this.AISessionId = ((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((getObjectFromLocalStorage(AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
|
|
2634
2997
|
if (!this.AISessionId) {
|
|
2635
2998
|
this.generateNewSessionId();
|
|
2636
2999
|
}
|
|
@@ -2653,23 +3016,154 @@ var AIAnswer = defineComponent({
|
|
|
2653
3016
|
console.error('Error reading component error text data:', error);
|
|
2654
3017
|
});
|
|
2655
3018
|
}
|
|
3019
|
+
},
|
|
3020
|
+
showComponent: function showComponent() {
|
|
3021
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
|
|
3022
|
+
this.isTriggered = true;
|
|
3023
|
+
}
|
|
3024
|
+
},
|
|
3025
|
+
dependentComponentValue: function dependentComponentValue(newVal) {
|
|
3026
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
|
|
3027
|
+
this.isTriggered = true;
|
|
3028
|
+
if (this.AISessionId) {
|
|
3029
|
+
this.handleSendMessage(null, false, '', true);
|
|
3030
|
+
}
|
|
3031
|
+
} else if (this.hasTriggered && this.$props.triggerOn !== AI_TRIGGER_MODES.ALWAYS) {
|
|
3032
|
+
this.isTriggered = false;
|
|
3033
|
+
}
|
|
3034
|
+
},
|
|
3035
|
+
AISessionId: function AISessionId(newVal) {
|
|
3036
|
+
if (newVal) {
|
|
3037
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === AI_TRIGGER_MODES.ALWAYS) {
|
|
3038
|
+
this.handleSendMessage(null, false, '', true);
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
},
|
|
3042
|
+
triggerOn: function triggerOn(newVal) {
|
|
3043
|
+
if (newVal === AI_TRIGGER_MODES.ALWAYS) {
|
|
3044
|
+
this.isTriggered = true;
|
|
3045
|
+
}
|
|
2656
3046
|
}
|
|
2657
3047
|
},
|
|
2658
3048
|
methods: {
|
|
2659
|
-
|
|
3049
|
+
renderTriggerMessageFunc: function renderTriggerMessageFunc() {
|
|
3050
|
+
var triggerOn = this.$props.triggerOn;
|
|
3051
|
+
if (this.$props.renderTriggerMessage) {
|
|
3052
|
+
return this.$props.renderTriggerMessage;
|
|
3053
|
+
}
|
|
3054
|
+
if (this.$slots.renderTriggerMessage) {
|
|
3055
|
+
return this.$slots.renderTriggerMessage();
|
|
3056
|
+
}
|
|
3057
|
+
if (triggerOn === AI_TRIGGER_MODES.QUESTION) {
|
|
3058
|
+
if (!this.dependentComponentValue.endsWith('?')) {
|
|
3059
|
+
return createVNode("span", null, [createVNode("span", {
|
|
3060
|
+
"role": "img",
|
|
3061
|
+
"aria-label": "bulb"
|
|
3062
|
+
}, [createTextVNode("\uD83D\uDCA1")]), createTextVNode("End your question with a question mark (?)")]);
|
|
3063
|
+
}
|
|
3064
|
+
} else if (triggerOn === AI_TRIGGER_MODES.MANUAL) {
|
|
3065
|
+
return createVNode("span", null, [createTextVNode("Click here to ask AI"), ' ', createVNode("span", {
|
|
3066
|
+
"role": "img",
|
|
3067
|
+
"aria-label": "bulb"
|
|
3068
|
+
}, [createTextVNode("\uD83E\uDD16")])]);
|
|
3069
|
+
}
|
|
3070
|
+
return null;
|
|
3071
|
+
},
|
|
3072
|
+
handleTriggerClick: function handleTriggerClick() {
|
|
3073
|
+
if (this.$props.triggerOn === AI_TRIGGER_MODES.MANUAL) {
|
|
3074
|
+
this.handleSendMessage(null, false, '', true);
|
|
3075
|
+
this.isTriggered = true;
|
|
3076
|
+
}
|
|
3077
|
+
},
|
|
3078
|
+
getAISourceObjects: function getAISourceObjects() {
|
|
2660
3079
|
var _this2 = this;
|
|
3080
|
+
var sourceObjects = [];
|
|
3081
|
+
if (!this.AIResponse) return sourceObjects;
|
|
3082
|
+
var docIds = this.sourceDocIds || [];
|
|
3083
|
+
if (this.initialHits) {
|
|
3084
|
+
docIds.forEach(function (id) {
|
|
3085
|
+
var foundSourceObj = _this2.initialHits.find(function (hit) {
|
|
3086
|
+
return hit._id === id;
|
|
3087
|
+
}) || {};
|
|
3088
|
+
if (foundSourceObj) {
|
|
3089
|
+
var _foundSourceObj$_sour = foundSourceObj._source,
|
|
3090
|
+
_source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
|
|
3091
|
+
rest = _objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
|
|
3092
|
+
sourceObjects.push(_extends({}, rest, _source));
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
} else {
|
|
3096
|
+
sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
|
|
3097
|
+
return {
|
|
3098
|
+
_id: id
|
|
3099
|
+
};
|
|
3100
|
+
}));
|
|
3101
|
+
}
|
|
3102
|
+
return sourceObjects;
|
|
3103
|
+
},
|
|
3104
|
+
renderAIScreenFooter: function renderAIScreenFooter() {
|
|
3105
|
+
var _slot2;
|
|
3106
|
+
var _this3 = this;
|
|
3107
|
+
var _ref = this.$props || {},
|
|
3108
|
+
_ref$showSourceDocume = _ref.showSourceDocuments,
|
|
3109
|
+
showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
|
|
3110
|
+
_ref$onSourceClick = _ref.onSourceClick,
|
|
3111
|
+
onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
|
|
3112
|
+
renderSourceDocument = _ref.renderSourceDocument;
|
|
3113
|
+
var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
|
|
3114
|
+
if (this.isLoadingState || this.isAITyping) {
|
|
3115
|
+
return null;
|
|
3116
|
+
}
|
|
3117
|
+
var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
|
|
3118
|
+
if (customRenderSourceDoc) {
|
|
3119
|
+
return customRenderSourceDoc(sourceObj);
|
|
3120
|
+
}
|
|
3121
|
+
return sourceObj._id;
|
|
3122
|
+
};
|
|
3123
|
+
return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? createVNode(Footer, {
|
|
3124
|
+
"themePreset": this.$props.themePreset,
|
|
3125
|
+
"style": {
|
|
3126
|
+
marginTop: '1.5rem',
|
|
3127
|
+
background: 'inherit'
|
|
3128
|
+
}
|
|
3129
|
+
}, {
|
|
3130
|
+
"default": function _default() {
|
|
3131
|
+
return [createTextVNode("Summary generated using the following sources:"), ' ', createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
|
|
3132
|
+
var _slot;
|
|
3133
|
+
return createVNode(Button, {
|
|
3134
|
+
"class": "--ai-source-tag " + (getClassName$2(_this3.$props.innerClass, 'ai-source-tag') || ''),
|
|
3135
|
+
"info": true,
|
|
3136
|
+
"onClick": function onClick() {
|
|
3137
|
+
return onSourceClick && onSourceClick(el);
|
|
3138
|
+
},
|
|
3139
|
+
"key": el._id
|
|
3140
|
+
}, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
|
|
3141
|
+
"default": function _default() {
|
|
3142
|
+
return [_slot];
|
|
3143
|
+
}
|
|
3144
|
+
});
|
|
3145
|
+
})) ? _slot2 : {
|
|
3146
|
+
"default": function _default() {
|
|
3147
|
+
return [_slot2];
|
|
3148
|
+
}
|
|
3149
|
+
})];
|
|
3150
|
+
}
|
|
3151
|
+
}) : null;
|
|
3152
|
+
},
|
|
3153
|
+
generateNewSessionId: function generateNewSessionId() {
|
|
3154
|
+
var _this4 = this;
|
|
2661
3155
|
var newSessionPromise = this.createAISession();
|
|
2662
3156
|
newSessionPromise.then(function (res) {
|
|
2663
|
-
|
|
3157
|
+
_this4.AISessionId = res.AIsessionId;
|
|
2664
3158
|
})["catch"](function (e) {
|
|
2665
3159
|
console.error(e);
|
|
2666
3160
|
});
|
|
2667
3161
|
},
|
|
2668
3162
|
scrollToBottom: function scrollToBottom() {
|
|
2669
|
-
var
|
|
3163
|
+
var _this5 = this;
|
|
2670
3164
|
this.$nextTick(function () {
|
|
2671
|
-
var
|
|
2672
|
-
var messageContainer = (
|
|
3165
|
+
var _this5$$refs;
|
|
3166
|
+
var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
|
|
2673
3167
|
if (messageContainer && messageContainer.$el) {
|
|
2674
3168
|
messageContainer.$el.scrollTo({
|
|
2675
3169
|
top: messageContainer.$el.scrollHeight,
|
|
@@ -2682,24 +3176,33 @@ var AIAnswer = defineComponent({
|
|
|
2682
3176
|
this.inputMessage = e.target.value;
|
|
2683
3177
|
this.handleTextAreaHeightChange();
|
|
2684
3178
|
},
|
|
2685
|
-
handleSendMessage: function handleSendMessage(e, isRetry, text) {
|
|
3179
|
+
handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
|
|
2686
3180
|
if (isRetry === void 0) {
|
|
2687
3181
|
isRetry = false;
|
|
2688
3182
|
}
|
|
2689
3183
|
if (text === void 0) {
|
|
2690
3184
|
text = this.inputMessage;
|
|
2691
3185
|
}
|
|
3186
|
+
if (fetchMeta === void 0) {
|
|
3187
|
+
fetchMeta = false;
|
|
3188
|
+
}
|
|
2692
3189
|
if (typeof e === 'object' && e !== null) e.preventDefault();
|
|
2693
|
-
if (text.trim()) {
|
|
3190
|
+
if (text.trim() || !text && !e) {
|
|
2694
3191
|
if (this.isLoadingState) {
|
|
2695
3192
|
return;
|
|
2696
3193
|
}
|
|
2697
3194
|
if (this.AISessionId) {
|
|
2698
|
-
if (!isRetry)
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
3195
|
+
if (!isRetry) {
|
|
3196
|
+
var finalMessages = [].concat(this.messages);
|
|
3197
|
+
if (text) {
|
|
3198
|
+
finalMessages.push({
|
|
3199
|
+
content: text,
|
|
3200
|
+
role: AI_ROLES.USER
|
|
3201
|
+
});
|
|
3202
|
+
}
|
|
3203
|
+
this.messages = [].concat(finalMessages);
|
|
3204
|
+
}
|
|
3205
|
+
this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
|
|
2703
3206
|
} else {
|
|
2704
3207
|
console.error(this.errorMessageForMissingSessionId);
|
|
2705
3208
|
this.error = {
|
|
@@ -2748,7 +3251,6 @@ var AIAnswer = defineComponent({
|
|
|
2748
3251
|
return null;
|
|
2749
3252
|
},
|
|
2750
3253
|
handleKeyPress: function handleKeyPress(e) {
|
|
2751
|
-
window.console.log('e', e);
|
|
2752
3254
|
if (e.key === 'Enter') {
|
|
2753
3255
|
this.handleSendMessage(e);
|
|
2754
3256
|
this.inputMessage = '';
|
|
@@ -2780,15 +3282,15 @@ var AIAnswer = defineComponent({
|
|
|
2780
3282
|
if (typeof window === 'undefined') return false;
|
|
2781
3283
|
return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
|
|
2782
3284
|
},
|
|
2783
|
-
handleVoiceResults: function handleVoiceResults(
|
|
2784
|
-
var results =
|
|
3285
|
+
handleVoiceResults: function handleVoiceResults(_ref2) {
|
|
3286
|
+
var results = _ref2.results;
|
|
2785
3287
|
if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
|
|
2786
3288
|
this.handleSendMessage(null, false, results[0][0].transcript.trim());
|
|
2787
3289
|
}
|
|
2788
3290
|
},
|
|
2789
3291
|
renderIcons: function renderIcons() {
|
|
2790
|
-
var
|
|
2791
|
-
var
|
|
3292
|
+
var _this6 = this;
|
|
3293
|
+
var _slot3, _slot4;
|
|
2792
3294
|
var _this$$props = this.$props,
|
|
2793
3295
|
getMicInstance = _this$$props.getMicInstance,
|
|
2794
3296
|
showVoiceInput = _this$$props.showVoiceInput,
|
|
@@ -2801,14 +3303,14 @@ var AIAnswer = defineComponent({
|
|
|
2801
3303
|
"positionType": "absolute"
|
|
2802
3304
|
}, {
|
|
2803
3305
|
"default": function _default() {
|
|
2804
|
-
return [!
|
|
3306
|
+
return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && createVNode(Mic, {
|
|
2805
3307
|
"getInstance": getMicInstance,
|
|
2806
3308
|
"render": renderMic,
|
|
2807
|
-
"handleResult":
|
|
3309
|
+
"handleResult": _this6.handleVoiceResults,
|
|
2808
3310
|
"class": getClassName$2(innerClass, 'ai-search-mic') || null
|
|
2809
|
-
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(
|
|
3311
|
+
}, null), iconPosition === 'right' && createVNode(IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
|
|
2810
3312
|
"default": function _default() {
|
|
2811
|
-
return [
|
|
3313
|
+
return [_slot3];
|
|
2812
3314
|
}
|
|
2813
3315
|
})];
|
|
2814
3316
|
}
|
|
@@ -2818,9 +3320,9 @@ var AIAnswer = defineComponent({
|
|
|
2818
3320
|
"positionType": "absolute"
|
|
2819
3321
|
}, {
|
|
2820
3322
|
"default": function _default() {
|
|
2821
|
-
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(
|
|
3323
|
+
return [iconPosition === 'left' && createVNode(IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
|
|
2822
3324
|
"default": function _default() {
|
|
2823
|
-
return [
|
|
3325
|
+
return [_slot4];
|
|
2824
3326
|
}
|
|
2825
3327
|
})];
|
|
2826
3328
|
}
|
|
@@ -2830,7 +3332,7 @@ var AIAnswer = defineComponent({
|
|
|
2830
3332
|
this.handleSendMessage(e);
|
|
2831
3333
|
},
|
|
2832
3334
|
renderEnterButtonElement: function renderEnterButtonElement() {
|
|
2833
|
-
var
|
|
3335
|
+
var _this7 = this;
|
|
2834
3336
|
var _this$$props2 = this.$props,
|
|
2835
3337
|
enterButton = _this$$props2.enterButton,
|
|
2836
3338
|
innerClass = _this$$props2.innerClass;
|
|
@@ -2838,16 +3340,16 @@ var AIAnswer = defineComponent({
|
|
|
2838
3340
|
if (enterButton) {
|
|
2839
3341
|
var getEnterButtonMarkup = function getEnterButtonMarkup() {
|
|
2840
3342
|
if (renderEnterButton) {
|
|
2841
|
-
return renderEnterButton(
|
|
3343
|
+
return renderEnterButton(_this7.enterButtonOnClick);
|
|
2842
3344
|
}
|
|
2843
3345
|
return createVNode(SendButton, {
|
|
2844
3346
|
"primary": true,
|
|
2845
3347
|
"type": "submit",
|
|
2846
3348
|
"tabIndex": 0,
|
|
2847
|
-
"onClick":
|
|
2848
|
-
"onKeyPress":
|
|
3349
|
+
"onClick": _this7.handleSendMessage,
|
|
3350
|
+
"onKeyPress": _this7.handleKeyPress,
|
|
2849
3351
|
"class": "ask-btn " + getClassName$2(innerClass, 'ai-enter-button'),
|
|
2850
|
-
"disabled":
|
|
3352
|
+
"disabled": _this7.isLoadingState || !_this7.AISessionId
|
|
2851
3353
|
}, {
|
|
2852
3354
|
"default": function _default() {
|
|
2853
3355
|
return [createTextVNode("Send")];
|
|
@@ -2870,9 +3372,9 @@ var AIAnswer = defineComponent({
|
|
|
2870
3372
|
return getComponent(data, this);
|
|
2871
3373
|
},
|
|
2872
3374
|
handleTextAreaHeightChange: function handleTextAreaHeightChange() {
|
|
2873
|
-
var _this$$refs, _this$$
|
|
2874
|
-
var textArea = (_this$$refs = this.$refs) == null
|
|
2875
|
-
var inputWrapper = (_this$$refs2 = this.$refs) == null
|
|
3375
|
+
var _this$$refs, _this$$refs2, _this$$refs3;
|
|
3376
|
+
var textArea = (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs.$el;
|
|
3377
|
+
var inputWrapper = (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2.$el;
|
|
2876
3378
|
var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
|
|
2877
3379
|
if (textArea) {
|
|
2878
3380
|
textArea.style.height = '42px';
|
|
@@ -2890,6 +3392,20 @@ var AIAnswer = defineComponent({
|
|
|
2890
3392
|
}
|
|
2891
3393
|
this.$forceUpdate();
|
|
2892
3394
|
}
|
|
3395
|
+
},
|
|
3396
|
+
getTitle: function getTitle() {
|
|
3397
|
+
var _this8 = this;
|
|
3398
|
+
var hasTitle = this.$props.title || this.$slots.title || null;
|
|
3399
|
+
if (hasTitle) {
|
|
3400
|
+
return createVNode(Title, {
|
|
3401
|
+
"class": getClassName$2(this.$props.innerClass, 'ai-title') || null
|
|
3402
|
+
}, {
|
|
3403
|
+
"default": function _default() {
|
|
3404
|
+
return [_this8.$props.title || _this8.$slots.title()];
|
|
3405
|
+
}
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
return null;
|
|
2893
3409
|
}
|
|
2894
3410
|
},
|
|
2895
3411
|
beforeUnmount: function beforeUnmount() {
|
|
@@ -2904,55 +3420,62 @@ var AIAnswer = defineComponent({
|
|
|
2904
3420
|
}
|
|
2905
3421
|
},
|
|
2906
3422
|
render: function render() {
|
|
2907
|
-
var
|
|
2908
|
-
var
|
|
3423
|
+
var _slot5;
|
|
3424
|
+
var _this9 = this;
|
|
2909
3425
|
var props = this.$props;
|
|
2910
3426
|
if (!this.shouldShowComponent) {
|
|
2911
3427
|
return null;
|
|
2912
3428
|
}
|
|
3429
|
+
if (!this.isTriggered) {
|
|
3430
|
+
return createVNode(Chatbox, {
|
|
3431
|
+
"style": props.style || {}
|
|
3432
|
+
}, {
|
|
3433
|
+
"default": function _default() {
|
|
3434
|
+
return [_this9.getTitle(), createVNode("div", {
|
|
3435
|
+
"class": "--trigger-message-wrapper",
|
|
3436
|
+
"onClick": _this9.handleTriggerClick,
|
|
3437
|
+
"aria-hidden": "true"
|
|
3438
|
+
}, [_this9.renderTriggerMessageFunc()])];
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
2913
3442
|
return createVNode(Chatbox, {
|
|
2914
3443
|
"style": props.style || {}
|
|
2915
3444
|
}, {
|
|
2916
3445
|
"default": function _default() {
|
|
2917
|
-
return [
|
|
2918
|
-
"class": getClassName$2(_this6.$props.innerClass, 'title') || ''
|
|
2919
|
-
}, {
|
|
2920
|
-
"default": function _default() {
|
|
2921
|
-
return [_this6.$props.title];
|
|
2922
|
-
}
|
|
2923
|
-
}), createVNode(ChatContainer, {
|
|
3446
|
+
return [_this9.getTitle(), createVNode(ChatContainer, {
|
|
2924
3447
|
"class": "--ai-chat-container",
|
|
2925
3448
|
"theme": props.theme,
|
|
2926
3449
|
"showInput": props.showInput
|
|
2927
3450
|
}, {
|
|
2928
3451
|
"default": function _default() {
|
|
2929
|
-
return [
|
|
2930
|
-
"themePreset":
|
|
3452
|
+
return [_this9.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3453
|
+
"themePreset": _this9.themePreset,
|
|
2931
3454
|
"theme": props.theme,
|
|
2932
|
-
"ref":
|
|
3455
|
+
"ref": _this9.$props.innerRef,
|
|
2933
3456
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
2934
|
-
}, _isSlot$1(
|
|
3457
|
+
}, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
|
|
2935
3458
|
"default": function _default() {
|
|
2936
|
-
return [
|
|
3459
|
+
return [_slot5];
|
|
2937
3460
|
}
|
|
2938
|
-
}), !
|
|
2939
|
-
"themePreset":
|
|
3461
|
+
}), !_this9.hasCustomRenderer && createVNode(MessagesContainer, {
|
|
3462
|
+
"themePreset": _this9.themePreset,
|
|
2940
3463
|
"theme": props.theme,
|
|
2941
|
-
"ref":
|
|
3464
|
+
"ref": _this9.$props.innerRef,
|
|
2942
3465
|
"class": "--ai-message-container " + (getClassName$2(props.innerClass, 'ai-message-container') || '')
|
|
2943
3466
|
}, {
|
|
2944
3467
|
"default": function _default() {
|
|
2945
|
-
return [
|
|
3468
|
+
return [_this9.messages.map(function (message, index) {
|
|
2946
3469
|
return createVNode(Message, {
|
|
2947
3470
|
"key": index,
|
|
2948
3471
|
"isSender": message.role === AI_ROLES.USER,
|
|
2949
3472
|
"innerHTML": md$1.render(message.content),
|
|
2950
|
-
"themePreset":
|
|
3473
|
+
"themePreset": _this9.themePreset,
|
|
2951
3474
|
"theme": props.theme,
|
|
2952
3475
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || '')
|
|
2953
3476
|
}, null);
|
|
2954
|
-
}),
|
|
2955
|
-
"themePreset":
|
|
3477
|
+
}), _this9.isLoadingState && createVNode(Message, {
|
|
3478
|
+
"themePreset": _this9.themePreset,
|
|
2956
3479
|
"theme": props.theme,
|
|
2957
3480
|
"isSender": false,
|
|
2958
3481
|
"class": "--ai-answer-message " + (getClassName$2(props.innerClass, 'ai-message') || null)
|
|
@@ -2961,31 +3484,31 @@ var AIAnswer = defineComponent({
|
|
|
2961
3484
|
return [createVNode(TypingIndicator, null, {
|
|
2962
3485
|
"default": function _default() {
|
|
2963
3486
|
return [createVNode(TypingDot, {
|
|
2964
|
-
"themePreset":
|
|
3487
|
+
"themePreset": _this9.themePreset
|
|
2965
3488
|
}, null), createVNode(TypingDot, {
|
|
2966
|
-
"themePreset":
|
|
3489
|
+
"themePreset": _this9.themePreset
|
|
2967
3490
|
}, null), createVNode(TypingDot, {
|
|
2968
|
-
"themePreset":
|
|
3491
|
+
"themePreset": _this9.themePreset
|
|
2969
3492
|
}, null)];
|
|
2970
3493
|
}
|
|
2971
3494
|
})];
|
|
2972
3495
|
}
|
|
2973
3496
|
})];
|
|
2974
3497
|
}
|
|
2975
|
-
}),
|
|
3498
|
+
}), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && createVNode("div", {
|
|
2976
3499
|
"class": "--ai-answer-feedback-container " + (getClassName$2(props.innerClass, 'ai-feedback') || '')
|
|
2977
3500
|
}, [createVNode(AIFeedback, {
|
|
2978
|
-
"hideUI":
|
|
2979
|
-
"key":
|
|
3501
|
+
"hideUI": _this9.isLoadingState || !_this9.sessionId,
|
|
3502
|
+
"key": _this9.sessionId,
|
|
2980
3503
|
"onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
|
|
2981
|
-
|
|
3504
|
+
_this9.trackUsefullness(_this9.sessionId, {
|
|
2982
3505
|
useful: useful,
|
|
2983
3506
|
reason: reason
|
|
2984
3507
|
});
|
|
2985
3508
|
}
|
|
2986
|
-
}, null)]), props.showInput && createVNode(MessageInputContainer, {
|
|
3509
|
+
}, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && createVNode(MessageInputContainer, {
|
|
2987
3510
|
"class": "--ai-input-container",
|
|
2988
|
-
"onSubmit":
|
|
3511
|
+
"onSubmit": _this9.handleSendMessage
|
|
2989
3512
|
}, {
|
|
2990
3513
|
"default": function _default() {
|
|
2991
3514
|
return [createVNode(InputGroup, {
|
|
@@ -3001,19 +3524,19 @@ var AIAnswer = defineComponent({
|
|
|
3001
3524
|
"ref": _inputRef,
|
|
3002
3525
|
"placeholder": props.placeholder,
|
|
3003
3526
|
"enterButton": props.enterButton,
|
|
3004
|
-
"value":
|
|
3005
|
-
"onInput":
|
|
3527
|
+
"value": _this9.inputMessage,
|
|
3528
|
+
"onInput": _this9.handleMessageInputChange,
|
|
3006
3529
|
"id": props.componentId + "-ai-input",
|
|
3007
3530
|
"showIcon": props.showIcon,
|
|
3008
3531
|
"iconPosition": props.iconPosition,
|
|
3009
|
-
"themePreset":
|
|
3010
|
-
"disabled":
|
|
3532
|
+
"themePreset": _this9.themePreset,
|
|
3533
|
+
"disabled": _this9.isLoadingState || !_this9.AISessionId,
|
|
3011
3534
|
"class": getClassName$2(props.innerClass, 'ai-input') || null
|
|
3012
|
-
}, null), ' ',
|
|
3535
|
+
}, null), ' ', _this9.renderIcons()];
|
|
3013
3536
|
}
|
|
3014
3537
|
})];
|
|
3015
3538
|
}
|
|
3016
|
-
}),
|
|
3539
|
+
}), _this9.renderEnterButtonElement()];
|
|
3017
3540
|
}
|
|
3018
3541
|
}), ' '];
|
|
3019
3542
|
}
|
|
@@ -3031,9 +3554,11 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
|
3031
3554
|
// eslint-disable-next-line prefer-destructuring
|
|
3032
3555
|
dependencyComponent = dependencyComponent[0];
|
|
3033
3556
|
}
|
|
3034
|
-
var showComponent = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value;
|
|
3557
|
+
var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
|
|
3558
|
+
var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
|
|
3035
3559
|
return {
|
|
3036
3560
|
showComponent: showComponent,
|
|
3561
|
+
dependentComponentValue: dependentComponentValue,
|
|
3037
3562
|
AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
|
|
3038
3563
|
isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
|
|
3039
3564
|
AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
|
|
@@ -3041,11 +3566,17 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
|
|
|
3041
3566
|
themePreset: state.config.themePreset,
|
|
3042
3567
|
isLoading: state.isLoading[props.componentId] || false,
|
|
3043
3568
|
sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
|
|
3044
|
-
componentError: state.error[props.componentId]
|
|
3569
|
+
componentError: state.error[props.componentId] || null,
|
|
3570
|
+
isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
|
|
3045
3571
|
};
|
|
3046
3572
|
};
|
|
3047
3573
|
var mapDispatchToProps$1 = {
|
|
3048
|
-
getAIResponse:
|
|
3574
|
+
getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
|
|
3575
|
+
if (shouldFetchMeta === void 0) {
|
|
3576
|
+
shouldFetchMeta = false;
|
|
3577
|
+
}
|
|
3578
|
+
return fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
|
|
3579
|
+
},
|
|
3049
3580
|
trackUsefullness: recordAISessionUsefulness,
|
|
3050
3581
|
createAISession: createAISession
|
|
3051
3582
|
};
|
|
@@ -3061,8 +3592,8 @@ AIConnected.install = function (Vue) {
|
|
|
3061
3592
|
// Add componentType for SSR
|
|
3062
3593
|
AIConnected.componentType = componentTypes.AIAnswer;
|
|
3063
3594
|
|
|
3064
|
-
var _templateObject$
|
|
3065
|
-
var HierarchicalMenuList = styled('ul')(_templateObject$
|
|
3595
|
+
var _templateObject$9, _templateObject2$4;
|
|
3596
|
+
var HierarchicalMenuList = styled('ul')(_templateObject$9 || (_templateObject$9 = _taggedTemplateLiteralLoose(["\n\tlist-style: none;\n\tpadding: 0;\n\tmargin: 0;\n\tmax-height: 0;\n\toverflow: hidden;\n\n\t&.--open {\n\t\tmax-height: 100%;\n\t}\n"])));
|
|
3066
3597
|
var HierarchicalMenuListItem = styled('li')(_templateObject2$4 || (_templateObject2$4 = _taggedTemplateLiteralLoose(["\n\tfont-weight: 400;\n\tline-height: 1.5;\n\tbox-sizing: border-box;\n\n\ta {\n\t\tcolor: #424242;\n\t\ttext-decoration: none;\n\t\tgap: 5px;\n\t\t.--leaf-icon,\n\t\t.--folder-icon {\n\t\t\tline-height: 15px;\n\t\t\tsvg {\n\t\t\t\theight: 15px;\n\t\t\t}\n\t\t}\n\n\t\tinput {\n\t\t\tmargin: 0;\n\t\t\tcursor: pointer;\n\t\t}\n\t}\n\n\t.--switcher-icon {\n\t\ttransition: all 0.2s ease-in;\n\t\tmargin-right: 2px;\n\t}\n\t.--list-child {\n\t\tpadding-left: 1rem;\n\t\tposition: relative;\n\t\t&:before {\n\t\t\theight: 100%;\n\t\t\tcontent: '';\n\t\t\tposition: absolute;\n\t\t\tborder-left: 1px solid #787878;\n\t\t\twidth: 0;\n\t\t\tleft: 19px;\n\t\t\t", ";\n\t\t}\n\n\t\t&.--show-switcher-icon {\n\t\t\tpadding-left: 36px;\n\t\t}\n\t}\n\t.--list-item-label {\n\t\tline-height: 100%;\n\t}\n\t.--list-item-count {\n\t\tmargin-left: 10px;\n\t\tpadding: 0.1rem 0.4rem;\n\t\tfont-size: 0.8rem;\n\t\tcolor: #424242;\n\t\tbackground-color: #dee1e6;\n\t\tborder-radius: 8px;\n\t}\n\t&.-selected-item {\n\t\tfont-weight: 700 !important;\n\t}\n\t&.-expanded-item {\n\t\t& > a {\n\t\t\t& div > .--switcher-icon {\n\t\t\t\ttransform: rotate(90deg);\n\t\t\t}\n\t\t}\n\t}\n\t.--list-item-label-count-wrapper {\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\t&:hover {\n\t\t\t.--list-item-count,\n\t\t\t.--list-item-label {\n\t\t\t\tfont-weight: 700;\n\t\t\t}\n\t\t}\n\t}\n"])), function (props) {
|
|
3067
3598
|
return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
|
|
3068
3599
|
});
|