@appbaseio/reactivesearch-vue 3.3.0 → 3.3.2

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.
Files changed (87) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +47205 -44250
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +32 -32
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-f96a0570.js → Button-7aee17e3.js} +1 -1
  6. package/dist/cjs/{DropDown-ebe20e81.js → CancelSvg-6094cd37.js} +1 -292
  7. package/dist/cjs/{Card-63968d94.js → Card-abff695e.js} +2 -2
  8. package/dist/cjs/{ComponentWrapper-0334c14b.js → ComponentWrapper-3bedbe57.js} +2 -2
  9. package/dist/cjs/{Container-29f049b2.js → Container-1c05785a.js} +1 -1
  10. package/dist/cjs/DropDown-815d458e.js +299 -0
  11. package/dist/cjs/DynamicRangeSlider.js +6 -6
  12. package/dist/cjs/{Flex-ddde6d26.js → Flex-f7af0673.js} +1 -1
  13. package/dist/cjs/{FormControlList-fadd792f.js → FormControlList-2c10e01a.js} +1 -1
  14. package/dist/cjs/{Input-cee51a53.js → Input-55fbd8e1.js} +1 -1
  15. package/dist/cjs/{ListItem-7a682970.js → ListItem-f272f502.js} +2 -2
  16. package/dist/cjs/MultiDropdownList.js +11 -10
  17. package/dist/cjs/MultiList.js +9 -9
  18. package/dist/cjs/MultiRange.js +7 -7
  19. package/dist/cjs/{Pagination-c53a18ab.js → Pagination-accd2fbf.js} +1 -1
  20. package/dist/cjs/{PreferencesConsumer-7bee3c57.js → PreferencesConsumer-37cab7a0.js} +2 -2
  21. package/dist/cjs/RangeInput.js +9 -9
  22. package/dist/cjs/RangeSlider.js +7 -7
  23. package/dist/cjs/ReactiveBase.js +2 -2
  24. package/dist/cjs/ReactiveComponent.js +4 -4
  25. package/dist/cjs/ReactiveGoogleMap.js +8 -8
  26. package/dist/cjs/ReactiveList.js +10 -10
  27. package/dist/cjs/ResultCard.js +3 -3
  28. package/dist/cjs/ResultList.js +3 -3
  29. package/dist/cjs/{install-c61d8b86.js → SearchBox-4dff47b4.js} +39 -1681
  30. package/dist/cjs/SearchBox.js +38 -0
  31. package/dist/cjs/SelectedFilters.js +5 -5
  32. package/dist/cjs/SingleDropdownList.js +11 -10
  33. package/dist/cjs/SingleList.js +9 -9
  34. package/dist/cjs/SingleRange.js +7 -7
  35. package/dist/cjs/StateProvider.js +2 -2
  36. package/dist/cjs/{Title-8802a218.js → Title-d513ac26.js} +1 -1
  37. package/dist/cjs/ToggleButton.js +7 -7
  38. package/dist/cjs/{_rollupPluginBabelHelpers-f8b843f8.js → _rollupPluginBabelHelpers-1a877b17.js} +14 -14
  39. package/dist/cjs/{index-1f41363f.js → index-7ca9570e.js} +1 -1
  40. package/dist/cjs/index.js +21 -19
  41. package/dist/cjs/install-246c0dab.js +1683 -0
  42. package/dist/cjs/install.js +19 -17
  43. package/dist/cjs/{ssr-8dd13d43.js → ssr-15d936a0.js} +1 -1
  44. package/dist/cjs/{utils-c9bd5628.js → utils-a3db8765.js} +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/es/{Button-5c2cf399.js → Button-8178e39a.js} +1 -1
  47. package/dist/es/{DropDown-36fa9ac5.js → CancelSvg-5b82ad4f.js} +3 -293
  48. package/dist/es/{Card-54b9e7a0.js → Card-3a81ac7b.js} +2 -2
  49. package/dist/es/{ComponentWrapper-46d04344.js → ComponentWrapper-90d42a29.js} +2 -2
  50. package/dist/es/{Container-d00219f7.js → Container-e2261542.js} +1 -1
  51. package/dist/es/DropDown-f8049812.js +295 -0
  52. package/dist/es/DynamicRangeSlider.js +6 -6
  53. package/dist/es/{Flex-25792bc3.js → Flex-5d11362e.js} +1 -1
  54. package/dist/es/{FormControlList-fe6eaee4.js → FormControlList-968ff972.js} +1 -1
  55. package/dist/es/{Input-437ae439.js → Input-cda7f4ad.js} +1 -1
  56. package/dist/es/{ListItem-e3c6acf4.js → ListItem-beea18db.js} +2 -2
  57. package/dist/es/MultiDropdownList.js +11 -10
  58. package/dist/es/MultiList.js +9 -9
  59. package/dist/es/MultiRange.js +7 -7
  60. package/dist/es/{Pagination-591fdb79.js → Pagination-b2160aac.js} +1 -1
  61. package/dist/es/{PreferencesConsumer-0856ed43.js → PreferencesConsumer-a2bd59db.js} +2 -2
  62. package/dist/es/RangeInput.js +9 -9
  63. package/dist/es/RangeSlider.js +7 -7
  64. package/dist/es/ReactiveBase.js +2 -2
  65. package/dist/es/ReactiveComponent.js +4 -4
  66. package/dist/es/ReactiveGoogleMap.js +8 -8
  67. package/dist/es/ReactiveList.js +10 -10
  68. package/dist/es/ResultCard.js +3 -3
  69. package/dist/es/ResultList.js +3 -3
  70. package/dist/es/{install-4fe6038c.js → SearchBox-57e3a0ff.js} +14 -1668
  71. package/dist/es/SearchBox.js +29 -0
  72. package/dist/es/SelectedFilters.js +5 -5
  73. package/dist/es/SingleDropdownList.js +11 -10
  74. package/dist/es/SingleList.js +9 -9
  75. package/dist/es/SingleRange.js +7 -7
  76. package/dist/es/StateProvider.js +2 -2
  77. package/dist/es/{Title-863dfa42.js → Title-100fe896.js} +1 -1
  78. package/dist/es/ToggleButton.js +7 -7
  79. package/dist/es/{_rollupPluginBabelHelpers-ded08042.js → _rollupPluginBabelHelpers-5e8399d7.js} +14 -14
  80. package/dist/es/{index-104f1dfb.js → index-3af85a74.js} +1 -1
  81. package/dist/es/index.js +21 -19
  82. package/dist/es/install-74125db1.js +1676 -0
  83. package/dist/es/install.js +19 -17
  84. package/dist/es/{ssr-c630ccb9.js → ssr-40133887.js} +1 -1
  85. package/dist/es/{utils-d7dd4f4e.js → utils-badbb2a8.js} +1 -1
  86. package/dist/es/version.js +1 -1
  87. package/package.json +4 -4
@@ -5,52 +5,28 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
5
5
  var reactivecore = require('@appbaseio/reactivecore');
6
6
  var constants = require('@appbaseio/reactivecore/lib/utils/constants');
7
7
  var _transformOn = _interopDefault(require('@vue/babel-helper-vue-transform-on'));
8
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-f8b843f8.js');
8
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-1a877b17.js');
9
9
  var vue = require('vue');
10
10
  var VueTypes = _interopDefault(require('vue-types'));
11
11
  var helper = require('@appbaseio/reactivecore/lib/utils/helper');
12
12
  var vueEmotion = require('@appbaseio/vue-emotion');
13
13
  var css = require('@emotion/css');
14
14
  var polished = require('polished');
15
- var Button = require('./Button-f96a0570.js');
15
+ var Button = require('./Button-7aee17e3.js');
16
16
  var vueTypes = require('./vueTypes-289a891a.js');
17
- var ReactiveList = require('./ReactiveList.js');
18
- var transform = require('@appbaseio/reactivecore/lib/utils/transform');
19
- var index = require('./index-1f41363f.js');
20
- var ComponentWrapper = require('./ComponentWrapper-0334c14b.js');
21
- var PreferencesConsumer = require('./PreferencesConsumer-7bee3c57.js');
22
- var Title = require('./Title-8802a218.js');
23
- var ListItem = require('./ListItem-7a682970.js');
24
- var Flex = require('./Flex-ddde6d26.js');
17
+ var index = require('./index-7ca9570e.js');
18
+ var ComponentWrapper = require('./ComponentWrapper-3bedbe57.js');
19
+ var PreferencesConsumer = require('./PreferencesConsumer-37cab7a0.js');
20
+ var Title = require('./Title-d513ac26.js');
21
+ var Flex = require('./Flex-f7af0673.js');
25
22
  var analytics = require('@appbaseio/reactivecore/lib/actions/analytics');
26
- var ReactiveBase = require('./ReactiveBase.js');
27
23
  var hotkeys = _interopDefault(require('hotkeys-js'));
28
24
  var xss = _interopDefault(require('xss'));
29
25
  var remarkable = require('remarkable');
30
- var DropDown = require('./DropDown-ebe20e81.js');
31
- var Input = require('./Input-cee51a53.js');
32
- var Container = require('./Container-29f049b2.js');
26
+ var CancelSvg = require('./CancelSvg-6094cd37.js');
27
+ var Input = require('./Input-55fbd8e1.js');
28
+ var Container = require('./Container-1c05785a.js');
33
29
  var Highlight = _interopDefault(require('vue-highlight-words'));
34
- var query = require('@appbaseio/reactivecore/lib/actions/query');
35
- var suggestions = require('@appbaseio/reactivecore/lib/utils/suggestions');
36
- var FormControlList = require('./FormControlList-fadd792f.js');
37
- var utils = require('./utils-c9bd5628.js');
38
- var SingleList = require('./SingleList.js');
39
- var MultiList = require('./MultiList.js');
40
- var types = _interopDefault(require('@appbaseio/reactivecore/lib/utils/types'));
41
- var SingleDropdownList = require('./SingleDropdownList.js');
42
- var MultiDropdownList = require('./MultiDropdownList.js');
43
- var ToggleButton = require('./ToggleButton.js');
44
- var ReactiveComponent = require('./ReactiveComponent.js');
45
- var DynamicRangeSlider = require('./DynamicRangeSlider.js');
46
- var SingleRange = require('./SingleRange.js');
47
- var MultiRange = require('./MultiRange.js');
48
- var RangeSlider = require('./RangeSlider.js');
49
- var RangeInput = require('./RangeInput.js');
50
- var SelectedFilters = require('./SelectedFilters.js');
51
- var ResultCard = require('./ResultCard.js');
52
- var ResultList = require('./ResultList.js');
53
- var StateProvider = require('./StateProvider.js');
54
30
 
55
31
  var _templateObject;
56
32
  var InputGroup = vueEmotion.styled('div')(_templateObject || (_templateObject = _rollupPluginBabelHelpers._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) {
@@ -699,7 +675,7 @@ var Mic = {
699
675
  if (this.hasCustomRenderer) {
700
676
  return this.getComponent();
701
677
  }
702
- return vue.createVNode(DropDown.IconWrapper, null, {
678
+ return vue.createVNode(CancelSvg.IconWrapper, null, {
703
679
  "default": function _default() {
704
680
  return [_this2.Icon];
705
681
  }
@@ -2063,7 +2039,7 @@ var SearchBox = vue.defineComponent({
2063
2039
  },
2064
2040
  renderCancelIcon: function renderCancelIcon() {
2065
2041
  if (this.$props.showClear) {
2066
- return this.$props.clearIcon || vue.createVNode(DropDown.CancelSvg, null, null);
2042
+ return this.$props.clearIcon || vue.createVNode(CancelSvg.CancelSvg, null, null);
2067
2043
  }
2068
2044
  return null;
2069
2045
  },
@@ -2179,11 +2155,11 @@ var SearchBox = vue.defineComponent({
2179
2155
  var _this$$props3 = this.$props,
2180
2156
  iconPosition = _this$$props3.iconPosition,
2181
2157
  showIcon = _this$$props3.showIcon;
2182
- return vue.createVNode("div", null, [vue.createVNode(DropDown.IconGroup, {
2158
+ return vue.createVNode("div", null, [vue.createVNode(CancelSvg.IconGroup, {
2183
2159
  "groupPosition": "left"
2184
2160
  }, {
2185
2161
  "default": function _default() {
2186
- return [iconPosition === 'left' && showIcon && vue.createVNode(DropDown.IconWrapper, {
2162
+ return [iconPosition === 'left' && showIcon && vue.createVNode(CancelSvg.IconWrapper, {
2187
2163
  "onClick": _this9.handleSearchIconClick
2188
2164
  }, _isSlot(_slot3 = _this9.renderIcon()) ? _slot3 : {
2189
2165
  "default": function _default() {
@@ -2206,11 +2182,11 @@ var SearchBox = vue.defineComponent({
2206
2182
  showFocusShortcutsIcon = _this$$props4.showFocusShortcutsIcon;
2207
2183
  var renderMic = this.$slots.renderMic || this.$props.renderMic;
2208
2184
  var currentValue = this.$data.currentValue;
2209
- return vue.createVNode("div", null, [vue.createVNode(DropDown.IconGroup, {
2185
+ return vue.createVNode("div", null, [vue.createVNode(CancelSvg.IconGroup, {
2210
2186
  "groupPosition": "right"
2211
2187
  }, {
2212
2188
  "default": function _default() {
2213
- return [currentValue && showClear && vue.createVNode(DropDown.IconWrapper, {
2189
+ return [currentValue && showClear && vue.createVNode(CancelSvg.IconWrapper, {
2214
2190
  "onClick": _this10.clearValue,
2215
2191
  "showIcon": showIcon,
2216
2192
  "isClearIcon": true
@@ -2218,7 +2194,7 @@ var SearchBox = vue.defineComponent({
2218
2194
  "default": function _default() {
2219
2195
  return [_slot4];
2220
2196
  }
2221
- }), showFocusShortcutsIcon && vue.createVNode(DropDown.ButtonIconWrapper, {
2197
+ }), showFocusShortcutsIcon && vue.createVNode(CancelSvg.ButtonIconWrapper, {
2222
2198
  "onClick": function onClick(e) {
2223
2199
  return _this10.focusSearchBox(e);
2224
2200
  }
@@ -2231,7 +2207,7 @@ var SearchBox = vue.defineComponent({
2231
2207
  "render": renderMic,
2232
2208
  "handleResult": _this10.handleVoiceResults,
2233
2209
  "className": getClassName$1(innerClass, 'mic') || null
2234
- }, null), iconPosition === 'right' && showIcon && vue.createVNode(DropDown.IconWrapper, {
2210
+ }, null), iconPosition === 'right' && showIcon && vue.createVNode(CancelSvg.IconWrapper, {
2235
2211
  "onClick": _this10.handleSearchIconClick
2236
2212
  }, _isSlot(_slot6 = _this10.renderIcon()) ? _slot6 : {
2237
2213
  "default": function _default() {
@@ -2329,7 +2305,7 @@ var SearchBox = vue.defineComponent({
2329
2305
  "onClick": function onClick() {
2330
2306
  return _this13.clearTag(item);
2331
2307
  }
2332
- }, [vue.createVNode(DropDown.CancelSvg, null, null)])];
2308
+ }, [vue.createVNode(CancelSvg.CancelSvg, null, null)])];
2333
2309
  }
2334
2310
  });
2335
2311
  },
@@ -2374,7 +2350,7 @@ var SearchBox = vue.defineComponent({
2374
2350
  "aria-label": "delete-tag",
2375
2351
  "class": "close-icon",
2376
2352
  "onClick": _this14.clearAllTags
2377
- }, [vue.createVNode(DropDown.CancelSvg, null, null)])];
2353
+ }, [vue.createVNode(CancelSvg.CancelSvg, null, null)])];
2378
2354
  }
2379
2355
  })];
2380
2356
  }
@@ -2574,7 +2550,7 @@ var SearchBox = vue.defineComponent({
2574
2550
  "default": function _default() {
2575
2551
  return [_this19.$props.title];
2576
2552
  }
2577
- }), _this19.$props.autosuggest ? vue.createVNode(DropDown.Downshift, {
2553
+ }), _this19.$props.autosuggest ? vue.createVNode(CancelSvg.Downshift, {
2578
2554
  "id": _this19.$props.componentId + "-downshift",
2579
2555
  "handleChange": _this19.onSuggestionSelected,
2580
2556
  "handleMouseup": _this19.handleStateChange,
@@ -2739,7 +2715,7 @@ var SearchBox = vue.defineComponent({
2739
2715
  "default": function _default() {
2740
2716
  return [_this19.renderInputAddonBefore(), _this19.renderLeftIcons()];
2741
2717
  }
2742
- }), vue.createVNode(DropDown.InputWrapper, null, {
2718
+ }), vue.createVNode(CancelSvg.InputWrapper, null, {
2743
2719
  "default": function _default() {
2744
2720
  return [vue.createVNode(Input.TextArea, vue.mergeProps(_transformOn(getInputEvents({
2745
2721
  onInput: _this19.onInputChange,
@@ -2795,7 +2771,7 @@ var SearchBox = vue.defineComponent({
2795
2771
  "default": function _default() {
2796
2772
  return [_this19.renderInputAddonBefore(), _this19.renderLeftIcons()];
2797
2773
  }
2798
- }), vue.createVNode(DropDown.InputWrapper, null, {
2774
+ }), vue.createVNode(CancelSvg.InputWrapper, null, {
2799
2775
  "default": function _default() {
2800
2776
  return [vue.createVNode(Input.TextArea, vue.mergeProps(_transformOn({
2801
2777
  blur: function blur(e) {
@@ -2917,1638 +2893,20 @@ SBConnected.install = function (Vue) {
2917
2893
  // Add componentType for SSR
2918
2894
  SBConnected.componentType = constants.componentTypes.searchBox;
2919
2895
 
2920
- var _excluded$1 = ["_source"];
2921
- function _isSlot$1(s) {
2922
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2923
- }
2924
- var md$1 = new remarkable.Remarkable();
2925
- md$1.set({
2926
- html: true,
2927
- breaks: true,
2928
- xhtmlOut: true,
2929
- linkify: true,
2930
- linkTarget: '_blank'
2931
- });
2932
- var _inputWrapperRef = 'inputWrapperRef';
2933
- var _inputRef = 'inputRef';
2934
- var _errorContainerRef = 'errorContainerRef';
2935
- var AIAnswer = vue.defineComponent({
2936
- name: 'AIAnswer',
2937
- data: function data() {
2938
- var props = this.$props;
2939
- this.__state = {
2940
- messages: [],
2941
- inputMessage: '',
2942
- AISessionId: '',
2943
- error: null,
2944
- sourceDocIds: null,
2945
- initialHits: null,
2946
- isTriggered: false
2947
- };
2948
- this.internalComponent = props.componentId + "__internal";
2949
- return this.__state;
2950
- },
2951
- inject: {
2952
- theme: {
2953
- from: 'theme_reactivesearch'
2954
- }
2955
- },
2956
- created: function created() {
2957
- if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
2958
- this.isTriggered = true;
2959
- } else if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
2960
- this.isTriggered = true;
2961
- if (this.AISessionId) {
2962
- this.handleSendMessage(null, false, '', true);
2963
- }
2964
- }
2965
- },
2966
- computed: {
2967
- hasCustomRenderer: function hasCustomRenderer() {
2968
- return index.hasCustomRenderer(this);
2969
- },
2970
- isLoadingState: function isLoadingState() {
2971
- return this.isAIResponseLoading || this.isLoading;
2972
- },
2973
- shouldShowComponent: function shouldShowComponent() {
2974
- return this.showComponent;
2975
- },
2976
- errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
2977
- return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
2978
- },
2979
- hasTriggered: function hasTriggered() {
2980
- return this.isTriggered;
2981
- }
2982
- },
2983
- props: {
2984
- componentId: vueTypes.types.string.isRequired,
2985
- showVoiceInput: VueTypes.bool.def(false),
2986
- showFeedback: VueTypes.bool.def(true),
2987
- showIcon: VueTypes.bool.def(true),
2988
- onData: vueTypes.types.func,
2989
- innerRef: VueTypes.string.def('AISearchInputField'),
2990
- react: vueTypes.types.react,
2991
- enableAI: VueTypes.bool.def(true),
2992
- AIConfig: vueTypes.types.AIConfig,
2993
- iconPosition: vueTypes.types.iconPosition.def('left'),
2994
- themePreset: vueTypes.types.themePreset,
2995
- theme: vueTypes.types.style,
2996
- icon: vueTypes.types.children,
2997
- iconURL: VueTypes.string.def(''),
2998
- renderMic: vueTypes.types.func,
2999
- getMicInstance: vueTypes.types.func,
3000
- innerClass: vueTypes.types.style,
3001
- placeholder: VueTypes.string.def('Ask a question'),
3002
- title: vueTypes.types.title,
3003
- AIResponse: vueTypes.types.componentObject,
3004
- isAIResponseLoading: VueTypes.bool.def(false),
3005
- AIResponseError: vueTypes.types.componentObject,
3006
- getAIResponse: vueTypes.types.func.isRequired,
3007
- enterButton: vueTypes.types.bool,
3008
- renderEnterButton: vueTypes.types.title,
3009
- showInput: VueTypes.bool.def(true),
3010
- clearSessionOnDestroy: VueTypes.bool.def(true),
3011
- rawData: vueTypes.types.rawData,
3012
- render: vueTypes.types.func,
3013
- onError: vueTypes.types.func,
3014
- renderError: vueTypes.types.title,
3015
- isLoading: vueTypes.types.boolRequired,
3016
- sessionIdFromStore: VueTypes.string,
3017
- showComponent: vueTypes.types.boolRequired,
3018
- componentError: vueTypes.types.componentObject,
3019
- style: vueTypes.types.style,
3020
- showSourceDocuments: VueTypes.bool.def(false),
3021
- renderSourceDocument: vueTypes.types.func,
3022
- onSourceClick: vueTypes.types.func,
3023
- isAITyping: vueTypes.types.boolRequired,
3024
- triggerOn: VueTypes.string.def(constants.AI_TRIGGER_MODES.ALWAYS),
3025
- renderTriggerMessage: vueTypes.types.func
3026
- },
3027
- mounted: function mounted() {},
3028
- watch: {
3029
- AIResponse: function AIResponse(newVal) {
3030
- if (newVal) {
3031
- if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
3032
- this.sourceDocIds = newVal.response.answer.documentIds;
3033
- var localCache = helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) && helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY)[this.$props.componentId];
3034
- if (localCache && localCache.meta && localCache.meta.hits) {
3035
- this.initialHits = localCache.meta.hits;
3036
- }
3037
- }
3038
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
3039
- var messagesHistory = newVal.messages,
3040
- response = newVal.response;
3041
- var finalMessages = [];
3042
- if (response && response.error) {
3043
- this.error = {
3044
- message: response.error
3045
- };
3046
- }
3047
- // pushing message history so far
3048
- if (messagesHistory && Array.isArray(messagesHistory)) {
3049
- finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
3050
- return msg.role !== constants.AI_ROLES.SYSTEM;
3051
- }));
3052
- if (finalMessages[0].role === constants.AI_ROLES.USER) {
3053
- finalMessages.shift();
3054
- }
3055
- } else if (response && response.answer && response.answer.text) {
3056
- finalMessages.push({
3057
- role: constants.AI_ROLES.ASSISTANT,
3058
- content: response.answer.text
3059
- });
3060
- if (!this.AISessionId) this.error = {
3061
- message: this.errorMessageForMissingSessionId
3062
- };
3063
- }
3064
- this.messages = finalMessages;
3065
- } else if (!newVal && !this.error) {
3066
- this.messages = [];
3067
- }
3068
- },
3069
- rawData: function rawData(newVal) {
3070
- this.$emit('on-data', {
3071
- data: this.messages,
3072
- rawData: newVal,
3073
- loading: this.$props.isAIResponseLoading || this.$props.isLoading,
3074
- error: this.$props.AIResponseError
3075
- });
3076
- if (newVal && newVal.hits && newVal.hits.hits) {
3077
- this.initialHits = newVal.hits.hits;
3078
- }
3079
- },
3080
- isAIResponseLoading: function isAIResponseLoading(newVal) {
3081
- this.$emit('on-data', {
3082
- data: this.messages,
3083
- rawData: this.$props.rawData,
3084
- loading: newVal || this.isLoading,
3085
- error: this.$props.AIResponseError
3086
- });
3087
- },
3088
- isLoading: function isLoading(newVal) {
3089
- this.$emit('on-data', {
3090
- data: this.messages,
3091
- rawData: this.$props.rawData,
3092
- loading: newVal || this.isAIResponseLoading,
3093
- error: this.$props.AIResponseError
3094
- });
3095
- },
3096
- sessionIdFromStore: function sessionIdFromStore(newVal) {
3097
- if (newVal) {
3098
- this.sessionId = newVal;
3099
- }
3100
- },
3101
- AIResponseError: function AIResponseError(newVal) {
3102
- this.error = newVal;
3103
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
3104
- if (this.error && !this.AISessionId) {
3105
- var errorMessage = this.errorMessageForMissingSessionId;
3106
- this.error = {
3107
- message: errorMessage
3108
- };
3109
- console.error(errorMessage);
3110
- }
3111
- this.$emit('on-data', {
3112
- data: this.messages,
3113
- rawData: this.$props.rawData,
3114
- loading: this.isAIResponseLoading || this.isLoading,
3115
- error: newVal
3116
- });
3117
- },
3118
- messages: function messages() {
3119
- this.scrollToBottom();
3120
- },
3121
- componentError: function componentError(newVal) {
3122
- var _this = this;
3123
- if (newVal && newVal._bodyBlob) {
3124
- this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || (((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).response || {}).sessionId;
3125
- if (!this.AISessionId) {
3126
- this.generateNewSessionId();
3127
- }
3128
- newVal._bodyBlob.text().then(function (textData) {
3129
- try {
3130
- var parsedErrorRes = JSON.parse(textData);
3131
- if (parsedErrorRes.error) {
3132
- _this.error = parsedErrorRes.error;
3133
- _this.$emit('on-data', {
3134
- data: _this.messages,
3135
- rawData: _this.$props.rawData,
3136
- loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
3137
- error: parsedErrorRes.error
3138
- });
3139
- }
3140
- } catch (error) {
3141
- console.error('Error parsing component error JSON:', error);
3142
- }
3143
- })["catch"](function (error) {
3144
- console.error('Error reading component error text data:', error);
3145
- });
3146
- }
3147
- },
3148
- showComponent: function showComponent() {
3149
- if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
3150
- this.isTriggered = true;
3151
- }
3152
- },
3153
- dependentComponentValue: function dependentComponentValue(newVal) {
3154
- if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
3155
- this.isTriggered = true;
3156
- if (this.AISessionId) {
3157
- this.handleSendMessage(null, false, '', true);
3158
- }
3159
- } else if (this.hasTriggered && this.$props.triggerOn !== constants.AI_TRIGGER_MODES.ALWAYS) {
3160
- this.isTriggered = false;
3161
- }
3162
- },
3163
- AISessionId: function AISessionId(newVal) {
3164
- if (newVal) {
3165
- if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
3166
- this.handleSendMessage(null, false, '', true);
3167
- }
3168
- }
3169
- },
3170
- triggerOn: function triggerOn(newVal) {
3171
- if (newVal === constants.AI_TRIGGER_MODES.ALWAYS) {
3172
- this.isTriggered = true;
3173
- }
3174
- }
3175
- },
3176
- methods: {
3177
- renderTriggerMessageFunc: function renderTriggerMessageFunc() {
3178
- var triggerOn = this.$props.triggerOn;
3179
- if (this.$props.renderTriggerMessage) {
3180
- return this.$props.renderTriggerMessage;
3181
- }
3182
- if (this.$slots.renderTriggerMessage) {
3183
- return this.$slots.renderTriggerMessage();
3184
- }
3185
- if (triggerOn === constants.AI_TRIGGER_MODES.QUESTION) {
3186
- if (!this.dependentComponentValue.endsWith('?')) {
3187
- return vue.createVNode("span", null, [vue.createVNode("span", {
3188
- "role": "img",
3189
- "aria-label": "bulb"
3190
- }, [vue.createTextVNode("\uD83D\uDCA1")]), vue.createTextVNode("End your question with a question mark (?)")]);
3191
- }
3192
- } else if (triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
3193
- return vue.createVNode("span", null, [vue.createTextVNode("Click here to ask AI"), ' ', vue.createVNode("span", {
3194
- "role": "img",
3195
- "aria-label": "bulb"
3196
- }, [vue.createTextVNode("\uD83E\uDD16")])]);
3197
- }
3198
- return null;
3199
- },
3200
- handleTriggerClick: function handleTriggerClick() {
3201
- if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
3202
- this.handleSendMessage(null, false, '', true);
3203
- this.isTriggered = true;
3204
- }
3205
- },
3206
- getAISourceObjects: function getAISourceObjects() {
3207
- var _this2 = this;
3208
- var sourceObjects = [];
3209
- if (!this.AIResponse) return sourceObjects;
3210
- var docIds = this.sourceDocIds || [];
3211
- if (this.initialHits) {
3212
- docIds.forEach(function (id) {
3213
- var foundSourceObj = _this2.initialHits.find(function (hit) {
3214
- return hit._id === id;
3215
- }) || {};
3216
- if (foundSourceObj) {
3217
- var _foundSourceObj$_sour = foundSourceObj._source,
3218
- _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
3219
- rest = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(foundSourceObj, _excluded$1);
3220
- sourceObjects.push(_rollupPluginBabelHelpers._extends({}, rest, _source));
3221
- }
3222
- });
3223
- } else {
3224
- sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
3225
- return {
3226
- _id: id
3227
- };
3228
- }));
3229
- }
3230
- return sourceObjects;
3231
- },
3232
- renderAIScreenFooter: function renderAIScreenFooter() {
3233
- var _slot2;
3234
- var _this3 = this;
3235
- var _ref = this.$props || {},
3236
- _ref$showSourceDocume = _ref.showSourceDocuments,
3237
- showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
3238
- _ref$onSourceClick = _ref.onSourceClick,
3239
- onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
3240
- renderSourceDocument = _ref.renderSourceDocument;
3241
- var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
3242
- if (this.isLoadingState || this.isAITyping) {
3243
- return null;
3244
- }
3245
- var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
3246
- if (customRenderSourceDoc) {
3247
- return customRenderSourceDoc(sourceObj);
3248
- }
3249
- return sourceObj._id;
3250
- };
3251
- return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? vue.createVNode(Footer, {
3252
- "themePreset": this.$props.themePreset,
3253
- "style": {
3254
- marginTop: '1.5rem',
3255
- background: 'inherit'
3256
- }
3257
- }, {
3258
- "default": function _default() {
3259
- return [vue.createTextVNode("Summary generated using the following sources:"), ' ', vue.createVNode(SourceTags, null, _isSlot$1(_slot2 = _this3.getAISourceObjects().map(function (el) {
3260
- var _slot;
3261
- return vue.createVNode(Button.Button, {
3262
- "class": "--ai-source-tag " + (helper.getClassName(_this3.$props.innerClass, 'ai-source-tag') || ''),
3263
- "info": true,
3264
- "onClick": function onClick() {
3265
- return onSourceClick && onSourceClick(el);
3266
- },
3267
- "key": el._id
3268
- }, _isSlot$1(_slot = renderSourceDocumentLabel(el)) ? _slot : {
3269
- "default": function _default() {
3270
- return [_slot];
3271
- }
3272
- });
3273
- })) ? _slot2 : {
3274
- "default": function _default() {
3275
- return [_slot2];
3276
- }
3277
- })];
3278
- }
3279
- }) : null;
3280
- },
3281
- generateNewSessionId: function generateNewSessionId() {
3282
- var _this4 = this;
3283
- var newSessionPromise = this.createAISession();
3284
- newSessionPromise.then(function (res) {
3285
- _this4.AISessionId = res.AIsessionId;
3286
- })["catch"](function (e) {
3287
- console.error(e);
3288
- });
3289
- },
3290
- scrollToBottom: function scrollToBottom() {
3291
- var _this5 = this;
3292
- this.$nextTick(function () {
3293
- var _this5$$refs;
3294
- var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
3295
- if (messageContainer && messageContainer.$el) {
3296
- messageContainer.$el.scrollTo({
3297
- top: messageContainer.$el.scrollHeight,
3298
- behavior: 'smooth'
3299
- });
3300
- }
3301
- });
3302
- },
3303
- handleMessageInputChange: function handleMessageInputChange(e) {
3304
- this.inputMessage = e.target.value;
3305
- this.handleTextAreaHeightChange();
3306
- },
3307
- handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
3308
- if (isRetry === void 0) {
3309
- isRetry = false;
3310
- }
3311
- if (text === void 0) {
3312
- text = this.inputMessage;
3313
- }
3314
- if (fetchMeta === void 0) {
3315
- fetchMeta = false;
3316
- }
3317
- if (typeof e === 'object' && e !== null) e.preventDefault();
3318
- if (text.trim() || !text && !e) {
3319
- if (this.isLoadingState) {
3320
- return;
3321
- }
3322
- if (this.AISessionId) {
3323
- if (!isRetry) {
3324
- var finalMessages = [].concat(this.messages);
3325
- if (text) {
3326
- finalMessages.push({
3327
- content: text,
3328
- role: constants.AI_ROLES.USER
3329
- });
3330
- }
3331
- this.messages = [].concat(finalMessages);
3332
- }
3333
- this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
3334
- } else {
3335
- console.error(this.errorMessageForMissingSessionId);
3336
- this.error = {
3337
- message: "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Trying reloading the App."
3338
- };
3339
- }
3340
- this.inputMessage = '';
3341
- }
3342
- },
3343
- handleRetryRequest: function handleRetryRequest() {
3344
- if (this.messages && !this.isLoadingState) {
3345
- var _this$messages;
3346
- var lastUserRequestMessage = (_this$messages = this.messages[this.messages.length - 1]) == null ? void 0 : _this$messages.content;
3347
- if (this.AISessionId) {
3348
- this.getAIResponse(this.AISessionId, this.componentId, lastUserRequestMessage);
3349
- this.inputMessage = '';
3350
- } else {
3351
- console.error("AISessionId for " + this.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.");
3352
- }
3353
- }
3354
- },
3355
- renderErrorComponent: function renderErrorComponent() {
3356
- var renderError = this.$slots.renderError || this.$props.renderError;
3357
- if (this.error && !this.isLoadingState) {
3358
- var _this$error, _this$error2;
3359
- if (renderError) {
3360
- return vue.createVNode("div", {
3361
- "ref": _errorContainerRef,
3362
- "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
3363
- }, [index.isFunction(renderError) ? renderError(this.error, this.handleRetryRequest) : renderError]);
3364
- }
3365
- return vue.createVNode("div", {
3366
- "ref": _errorContainerRef,
3367
- "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
3368
- }, [vue.createVNode("div", {
3369
- "class": "--default-error-element"
3370
- }, [vue.createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? ", Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && vue.createVNode(Button.Button, {
3371
- "primary": true,
3372
- "onClick": this.handleRetryRequest
3373
- }, {
3374
- "default": function _default() {
3375
- return [vue.createTextVNode("Try again")];
3376
- }
3377
- })])]);
3378
- }
3379
- return null;
3380
- },
3381
- handleKeyPress: function handleKeyPress(e) {
3382
- if (e.key === 'Enter') {
3383
- this.handleSendMessage(e);
3384
- this.inputMessage = '';
3385
- }
3386
- },
3387
- renderIcon: function renderIcon() {
3388
- if (this.$props.showIcon) {
3389
- if (this.$props.icon) {
3390
- return this.$props.icon;
3391
- }
3392
- if (this.$slots.icon) {
3393
- return this.$slots.icon();
3394
- }
3395
- if (this.$props.iconURL) {
3396
- return vue.createVNode("img", {
3397
- "style": {
3398
- maxHeight: '25px'
3399
- },
3400
- "src": this.$props.iconURL,
3401
- "alt": "search-icon"
3402
- }, null);
3403
- }
3404
- return vue.createVNode(SearchSvg, null, null);
3405
- }
3406
- return null;
3407
- },
3408
- shouldMicRender: function shouldMicRender(showVoiceSearch) {
3409
- // checks for SSR
3410
- if (typeof window === 'undefined') return false;
3411
- return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
3412
- },
3413
- handleVoiceResults: function handleVoiceResults(_ref2) {
3414
- var results = _ref2.results;
3415
- if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
3416
- this.handleSendMessage(null, false, results[0][0].transcript.trim());
3417
- }
3418
- },
3419
- renderIcons: function renderIcons() {
3420
- var _this6 = this;
3421
- var _slot3, _slot4;
3422
- var _this$$props = this.$props,
3423
- getMicInstance = _this$$props.getMicInstance,
3424
- showVoiceInput = _this$$props.showVoiceInput,
3425
- iconPosition = _this$$props.iconPosition,
3426
- innerClass = _this$$props.innerClass;
3427
- var renderMic = this.$slots.renderMic || this.$props.renderMic;
3428
- return vue.createVNode("div", null, [vue.createVNode(DropDown.IconGroup, {
3429
- "enableAI": true,
3430
- "groupPosition": "right",
3431
- "positionType": "absolute"
3432
- }, {
3433
- "default": function _default() {
3434
- return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
3435
- "getInstance": getMicInstance,
3436
- "render": renderMic,
3437
- "handleResult": _this6.handleVoiceResults,
3438
- "class": helper.getClassName(innerClass, 'ai-search-mic') || null
3439
- }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot3 = _this6.renderIcon()) ? _slot3 : {
3440
- "default": function _default() {
3441
- return [_slot3];
3442
- }
3443
- })];
3444
- }
3445
- }), vue.createVNode(DropDown.IconGroup, {
3446
- "enableAI": true,
3447
- "groupPosition": "left",
3448
- "positionType": "absolute"
3449
- }, {
3450
- "default": function _default() {
3451
- return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot4 = _this6.renderIcon()) ? _slot4 : {
3452
- "default": function _default() {
3453
- return [_slot4];
3454
- }
3455
- })];
3456
- }
3457
- })]);
3458
- },
3459
- enterButtonOnClick: function enterButtonOnClick(e) {
3460
- this.handleSendMessage(e);
3461
- },
3462
- renderEnterButtonElement: function renderEnterButtonElement() {
3463
- var _this7 = this;
3464
- var _this$$props2 = this.$props,
3465
- enterButton = _this$$props2.enterButton,
3466
- innerClass = _this$$props2.innerClass;
3467
- var renderEnterButton = this.$slots.renderEnterButton;
3468
- if (enterButton) {
3469
- var getEnterButtonMarkup = function getEnterButtonMarkup() {
3470
- if (renderEnterButton) {
3471
- return renderEnterButton(_this7.enterButtonOnClick);
3472
- }
3473
- return vue.createVNode(SendButton, {
3474
- "primary": true,
3475
- "type": "submit",
3476
- "tabIndex": 0,
3477
- "onClick": _this7.handleSendMessage,
3478
- "onKeyPress": _this7.handleKeyPress,
3479
- "class": "ask-btn " + helper.getClassName(innerClass, 'ai-enter-button'),
3480
- "disabled": _this7.isLoadingState || !_this7.AISessionId
3481
- }, {
3482
- "default": function _default() {
3483
- return [vue.createTextVNode("Send")];
3484
- }
3485
- });
3486
- };
3487
- return vue.createVNode("div", {
3488
- "class": "ai-enter-button-wrapper"
3489
- }, [getEnterButtonMarkup()]);
3490
- }
3491
- return null;
3492
- },
3493
- getComponent: function getComponent() {
3494
- var data = {
3495
- error: this.AIResponseError,
3496
- loading: this.isAIResponseLoading,
3497
- data: this.messages,
3498
- rawData: this.rawData
3499
- };
3500
- return index.getComponent(data, this);
3501
- },
3502
- handleTextAreaHeightChange: function handleTextAreaHeightChange() {
3503
- var _this$$refs, _this$$refs2, _this$$refs3;
3504
- var textArea = (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs.$el;
3505
- var inputWrapper = (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2.$el;
3506
- var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
3507
- if (textArea) {
3508
- textArea.style.height = '42px';
3509
- var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
3510
- var maxHeight = lineHeight * 11; // max height for 10 lines
3511
- var height = Math.min(textArea.scrollHeight, maxHeight);
3512
- textArea.style.height = height + "px";
3513
- textArea.style.overflowY = height === maxHeight ? 'auto' : 'hidden';
3514
- // wrapper around input/ textarea
3515
- inputWrapper.style.height = height + "px";
3516
- // adjust error-container
3517
-
3518
- if (errorContainer) {
3519
- errorContainer.style.bottom = height + "px";
3520
- }
3521
- this.$forceUpdate();
3522
- }
3523
- },
3524
- getTitle: function getTitle() {
3525
- var _this8 = this;
3526
- var hasTitle = this.$props.title || this.$slots.title || null;
3527
- if (hasTitle) {
3528
- return vue.createVNode(Title.Title, {
3529
- "class": helper.getClassName(this.$props.innerClass, 'ai-title') || null
3530
- }, {
3531
- "default": function _default() {
3532
- return [_this8.$props.title || _this8.$slots.title()];
3533
- }
3534
- });
3535
- }
3536
- return null;
3537
- }
3538
- },
3539
- beforeUnmount: function beforeUnmount() {
3540
- if (this.$props.clearSessionOnDestroy) {
3541
- // cleanup logic
3542
- // final Object to store in local storage cache
3543
- var finalCacheObj = helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {};
3544
- // delete current component's cache
3545
- delete finalCacheObj[this.$props.componentId];
3546
- // update local cache
3547
- helper.setObjectInLocalStorage(constants.AI_LOCAL_CACHE_KEY, finalCacheObj);
3548
- }
3549
- },
3550
- render: function render() {
3551
- var _slot5;
3552
- var _this9 = this;
3553
- var props = this.$props;
3554
- if (!this.shouldShowComponent) {
3555
- return null;
3556
- }
3557
- if (!this.isTriggered) {
3558
- return vue.createVNode(Chatbox, {
3559
- "style": props.style || {}
3560
- }, {
3561
- "default": function _default() {
3562
- return [_this9.getTitle(), vue.createVNode("div", {
3563
- "class": "--trigger-message-wrapper",
3564
- "onClick": _this9.handleTriggerClick,
3565
- "aria-hidden": "true"
3566
- }, [_this9.renderTriggerMessageFunc()])];
3567
- }
3568
- });
3569
- }
3570
- return vue.createVNode(Chatbox, {
3571
- "style": props.style || {}
3572
- }, {
3573
- "default": function _default() {
3574
- return [_this9.getTitle(), vue.createVNode(ChatContainer, {
3575
- "class": "--ai-chat-container",
3576
- "theme": props.theme,
3577
- "showInput": props.showInput
3578
- }, {
3579
- "default": function _default() {
3580
- return [_this9.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3581
- "themePreset": _this9.themePreset,
3582
- "theme": props.theme,
3583
- "ref": _this9.$props.innerRef,
3584
- "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
3585
- }, _isSlot$1(_slot5 = _this9.getComponent()) ? _slot5 : {
3586
- "default": function _default() {
3587
- return [_slot5];
3588
- }
3589
- }), !_this9.hasCustomRenderer && vue.createVNode(MessagesContainer, {
3590
- "themePreset": _this9.themePreset,
3591
- "theme": props.theme,
3592
- "ref": _this9.$props.innerRef,
3593
- "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
3594
- }, {
3595
- "default": function _default() {
3596
- return [_this9.messages.map(function (message, index) {
3597
- return vue.createVNode(Message, {
3598
- "key": index,
3599
- "isSender": message.role === constants.AI_ROLES.USER,
3600
- "innerHTML": md$1.render(message.content),
3601
- "themePreset": _this9.themePreset,
3602
- "theme": props.theme,
3603
- "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || '')
3604
- }, null);
3605
- }), _this9.isLoadingState && vue.createVNode(Message, {
3606
- "themePreset": _this9.themePreset,
3607
- "theme": props.theme,
3608
- "isSender": false,
3609
- "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || null)
3610
- }, {
3611
- "default": function _default() {
3612
- return [vue.createVNode(TypingIndicator, null, {
3613
- "default": function _default() {
3614
- return [vue.createVNode(TypingDot, {
3615
- "themePreset": _this9.themePreset
3616
- }, null), vue.createVNode(TypingDot, {
3617
- "themePreset": _this9.themePreset
3618
- }, null), vue.createVNode(TypingDot, {
3619
- "themePreset": _this9.themePreset
3620
- }, null)];
3621
- }
3622
- })];
3623
- }
3624
- })];
3625
- }
3626
- }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode("div", {
3627
- "class": "--ai-answer-feedback-container " + (helper.getClassName(props.innerClass, 'ai-feedback') || '')
3628
- }, [vue.createVNode(AIFeedback, {
3629
- "hideUI": _this9.isLoadingState || !_this9.sessionId,
3630
- "key": _this9.sessionId,
3631
- "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
3632
- _this9.trackUsefullness(_this9.sessionId, {
3633
- useful: useful,
3634
- reason: reason
3635
- });
3636
- }
3637
- }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode(MessageInputContainer, {
3638
- "class": "--ai-input-container",
3639
- "onSubmit": _this9.handleSendMessage
3640
- }, {
3641
- "default": function _default() {
3642
- return [vue.createVNode(InputGroup, {
3643
- "enableAI": true,
3644
- "isOpen": false
3645
- }, {
3646
- "default": function _default() {
3647
- return [vue.createVNode(DropDown.InputWrapper, {
3648
- "ref": _inputWrapperRef
3649
- }, {
3650
- "default": function _default() {
3651
- return [vue.createVNode(MessageInput, {
3652
- "ref": _inputRef,
3653
- "placeholder": props.placeholder,
3654
- "enterButton": props.enterButton,
3655
- "value": _this9.inputMessage,
3656
- "onInput": _this9.handleMessageInputChange,
3657
- "id": props.componentId + "-ai-input",
3658
- "showIcon": props.showIcon,
3659
- "iconPosition": props.iconPosition,
3660
- "themePreset": _this9.themePreset,
3661
- "disabled": _this9.isLoadingState || !_this9.AISessionId,
3662
- "class": helper.getClassName(props.innerClass, 'ai-input') || null
3663
- }, null), ' ', _this9.renderIcons()];
3664
- }
3665
- })];
3666
- }
3667
- }), _this9.renderEnterButtonElement()];
3668
- }
3669
- }), ' '];
3670
- }
3671
- })];
3672
- }
3673
- });
3674
- }
3675
- });
3676
- AIAnswer.hasInternalComponent = function () {
3677
- return true;
3678
- };
3679
- var mapStateToProps$1 = function mapStateToProps(state, props) {
3680
- var dependencyComponent = Object.values(props.react)[0];
3681
- if (Array.isArray(dependencyComponent)) {
3682
- // eslint-disable-next-line prefer-destructuring
3683
- dependencyComponent = dependencyComponent[0];
3684
- }
3685
- var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
3686
- var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
3687
- return {
3688
- showComponent: showComponent,
3689
- dependentComponentValue: dependentComponentValue,
3690
- AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
3691
- isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
3692
- AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
3693
- rawData: state.rawData[props.componentId],
3694
- themePreset: state.config.themePreset,
3695
- isLoading: state.isLoading[props.componentId] || false,
3696
- sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3697
- componentError: state.error[props.componentId] || null,
3698
- isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
3699
- };
3700
- };
3701
- var mapDispatchToProps$1 = {
3702
- getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
3703
- if (shouldFetchMeta === void 0) {
3704
- shouldFetchMeta = false;
3705
- }
3706
- return query.fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
3707
- },
3708
- trackUsefullness: analytics.recordAISessionUsefulness,
3709
- createAISession: query.createAISession
3710
- };
3711
- var AIConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchToProps$1)(AIAnswer), {
3712
- componentType: constants.componentTypes.AIAnswer,
3713
- internalComponent: true
3714
- }));
3715
- AIConnected.name = AIAnswer.name;
3716
- AIConnected.hasInternalComponent = AIAnswer.hasInternalComponent;
3717
- AIConnected.install = function (Vue) {
3718
- Vue.component(AIConnected.name, AIConnected);
3719
- };
3720
- // Add componentType for SSR
3721
- AIConnected.componentType = constants.componentTypes.AIAnswer;
3722
-
3723
- var _templateObject$9, _templateObject2$4;
3724
- var HierarchicalMenuList = vueEmotion.styled('ul')(_templateObject$9 || (_templateObject$9 = _rollupPluginBabelHelpers._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"])));
3725
- var HierarchicalMenuListItem = vueEmotion.styled('li')(_templateObject2$4 || (_templateObject2$4 = _rollupPluginBabelHelpers._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) {
3726
- return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
3727
- });
3728
-
3729
- var HierarchicalMenuListItemComponent = {
3730
- name: 'HierarchicalMenuListItemComponent',
3731
- data: function data() {
3732
- return {
3733
- isExpanded: false,
3734
- newParentPath: ''
3735
- };
3736
- },
3737
- created: function created() {
3738
- var listItemLabel = this.listItem.key;
3739
- var newParentPath = listItemLabel;
3740
- if (this.parentPath) {
3741
- newParentPath = "" + this.parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + listItemLabel;
3742
- }
3743
- this.newParentPath = newParentPath;
3744
- this.isExpanded = !!helper.recLookup(this.selectedValues, newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
3745
- },
3746
- watch: {
3747
- listItem: function listItem(newVal) {
3748
- if (newVal.initiallyExpanded) {
3749
- this.isExpanded = newVal.initiallyExpanded;
3750
- }
3751
- },
3752
- selectedValues: function selectedValues(newVal) {
3753
- this.isExpanded = !!helper.recLookup(newVal, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
3754
- }
3755
- },
3756
- props: {
3757
- parentPath: types.string,
3758
- selectedValues: types.rawData,
3759
- mode: types.string,
3760
- searchTerm: types.string,
3761
- listItem: types.rawData,
3762
- showLine: types.bool,
3763
- renderItem: types.func,
3764
- handleListItemClick: types.func,
3765
- renderSwitcherIcon: types.func,
3766
- showCheckbox: VueTypes.bool,
3767
- innerClass: types.style,
3768
- showRadio: VueTypes.bool,
3769
- renderIcon: types.func,
3770
- showCount: VueTypes.bool,
3771
- showSwitcherIcon: types.bool,
3772
- switcherIcon: types.children
3773
- },
3774
- render: function render() {
3775
- var _this = this;
3776
- var _this$$props = this.$props,
3777
- selectedValues = _this$$props.selectedValues,
3778
- mode = _this$$props.mode,
3779
- searchTerm = _this$$props.searchTerm,
3780
- listItem = _this$$props.listItem,
3781
- parentPath = _this$$props.parentPath,
3782
- showLine = _this$$props.showLine,
3783
- renderItem = _this$$props.renderItem,
3784
- handleListItemClick = _this$$props.handleListItemClick,
3785
- showCheckbox = _this$$props.showCheckbox,
3786
- innerClass = _this$$props.innerClass,
3787
- showRadio = _this$$props.showRadio,
3788
- renderIcon = _this$$props.renderIcon,
3789
- showCount = _this$$props.showCount,
3790
- showSwitcherIcon = _this$$props.showSwitcherIcon;
3791
- if (!(listItem instanceof Object) || Object.keys(listItem).length === 0) {
3792
- return null;
3793
- }
3794
- var listItemLabel = listItem.key;
3795
- var listItemCount = listItem.count;
3796
- var isLeafNode = !(Array.isArray(listItem.list) && listItem.list.length > 0);
3797
- var renderSwitcherIcon = function renderSwitcherIcon(isExpandedProp) {
3798
- if (showSwitcherIcon === false) {
3799
- return null;
3800
- }
3801
- var switcherIcon = _this.$props.switcherIcon;
3802
- if (switcherIcon) return switcherIcon(isExpandedProp);
3803
- return (
3804
- /* eslint-disable jsx-a11y/click-events-have-key-events
3805
- , jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-tabindex */
3806
- vue.createVNode("span", {
3807
- "tabIndex": "0",
3808
- "onClick": function onClick(e) {
3809
- e.stopPropagation();
3810
- _this.isExpanded = !_this.isExpanded;
3811
- },
3812
- "class": "--switcher-icon"
3813
- }, [vue.createTextVNode("\u27A4")])
3814
- );
3815
- };
3816
- var isSelected = false;
3817
- if (mode === 'single') {
3818
- if (helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR) === true) {
3819
- isSelected = true;
3820
- }
3821
- } else {
3822
- isSelected = !!helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
3823
- }
3824
- return vue.createVNode(HierarchicalMenuListItem, {
3825
- "class": (isSelected ? '-selected-item' : '') + " " + (this.isExpanded ? '-expanded-item' : ''),
3826
- "key": this.newParentPath,
3827
- "showLine": showLine
3828
- }, {
3829
- "default": function _default() {
3830
- return [vue.createVNode(ListItem.ListItem, {
3831
- "isTreeListItem": true,
3832
- "onClick": function onClick() {
3833
- handleListItemClick(listItemLabel, parentPath);
3834
- },
3835
- "style": {
3836
- textDecoration: 'none'
3837
- }
3838
- }, {
3839
- "default": function _default() {
3840
- return [renderItem ? renderItem(listItemLabel, listItemCount, isSelected) : vue.createVNode(Flex.Flex, {
3841
- "alignItems": "center",
3842
- "gap": "5px"
3843
- }, {
3844
- "default": function _default() {
3845
- return [!isLeafNode && renderSwitcherIcon(isSelected), mode === 'multiple' && showCheckbox && vue.createVNode(Flex.Flex, {
3846
- "alignItems": "center",
3847
- "gap": "5px"
3848
- }, {
3849
- "default": function _default() {
3850
- return [vue.createVNode(FormControlList.Checkbox, {
3851
- "type": "checkbox",
3852
- "class": helper.getClassName(innerClass, 'checkbox') || null,
3853
- "checked": isSelected,
3854
- "id": listItemLabel + "-checkbox-" + _this.newParentPath,
3855
- "name": listItemLabel + "-checkbox-" + _this.newParentPath,
3856
- "show": true,
3857
- "readOnly": true
3858
- }, null), vue.createVNode("label", {
3859
- "style": {
3860
- width: '26px',
3861
- marginTop: 0,
3862
- marginBottom: 0,
3863
- marginRight: '-9px',
3864
- left: '-3px'
3865
- },
3866
- "htmlFor": listItemLabel + "-checkbox-" + _this.newParentPath,
3867
- "onClick": function onClick(e) {
3868
- e.stopPropagation();
3869
- }
3870
- }, null)];
3871
- }
3872
- }), mode === 'single' && showRadio && vue.createVNode(Flex.Flex, {
3873
- "alignItems": "center",
3874
- "gap": "5px"
3875
- }, {
3876
- "default": function _default() {
3877
- return [vue.createVNode(FormControlList.Radio, {
3878
- "checked": isSelected,
3879
- "class": helper.getClassName(innerClass, 'radio') || null,
3880
- "id": listItemLabel + "-radio-" + _this.newParentPath,
3881
- "name": listItemLabel + "-radio-" + _this.newParentPath,
3882
- "show": true,
3883
- "readOnly": true,
3884
- "type": "radio"
3885
- }, null), vue.createVNode("label", {
3886
- "style": {
3887
- width: '26px',
3888
- marginTop: 0,
3889
- marginBottom: 0,
3890
- marginRight: '-9px',
3891
- left: '-3px'
3892
- },
3893
- "htmlFor": listItemLabel + "-radio-" + _this.newParentPath,
3894
- "onClick": function onClick(e) {
3895
- e.stopPropagation();
3896
- }
3897
- }, null)];
3898
- }
3899
- }), ' ', renderIcon(isLeafNode), vue.createVNode("div", {
3900
- "class": "--list-item-label-count-wrapper"
3901
- }, [vue.createVNode("span", {
3902
- "class": "--list-item-label " + (helper.getClassName(innerClass, 'label') || '')
3903
- }, [listItemLabel]), showCount && vue.createVNode("span", {
3904
- "class": "--list-item-count " + (helper.getClassName(innerClass, 'count') || '')
3905
- }, [listItemCount])])];
3906
- }
3907
- })];
3908
- }
3909
- }), isLeafNode === false && vue.createVNode("div", {
3910
- "class": "--list-child " + (showSwitcherIcon ? ' --show-switcher-icon' : '')
3911
- }, [vue.createVNode(HierarchicalMenuComponent, {
3912
- "key": _this.newParentPath + "-" + listItemLabel + "-" + listItemCount,
3913
- "listArray": listItem.list,
3914
- "parentPath": _this.newParentPath,
3915
- "isExpanded": _this.isExpanded,
3916
- "listItemProps": {
3917
- mode: mode,
3918
- selectedValues: selectedValues,
3919
- searchTerm: searchTerm,
3920
- showLine: showLine,
3921
- renderItem: renderItem,
3922
- handleListItemClick: handleListItemClick,
3923
- renderSwitcherIcon: renderSwitcherIcon,
3924
- showCheckbox: showCheckbox,
3925
- innerClass: innerClass,
3926
- showRadio: showRadio,
3927
- renderIcon: renderIcon,
3928
- showCount: showCount,
3929
- showSwitcherIcon: showSwitcherIcon,
3930
- switcherIcon: _this.$props.switcherIcon
3931
- }
3932
- }, null)])];
3933
- }
3934
- });
3935
- }
3936
- };
3937
-
3938
- function _isSlot$2(s) {
3939
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
3940
- }
3941
- var HierarchicalMenuComponent = {
3942
- name: 'HierarchicalMenuComponent',
3943
- props: {
3944
- listArray: VueTypes.arrayOf(VueTypes.object),
3945
- // array of objects
3946
- parentPath: VueTypes.string.def(''),
3947
- isExpanded: VueTypes.bool.def(false),
3948
- listItemProps: types.rawData
3949
- },
3950
- render: function render() {
3951
- var _slot;
3952
- var _this$$props = this.$props,
3953
- listArray = _this$$props.listArray,
3954
- isExpanded = _this$$props.isExpanded,
3955
- parentPath = _this$$props.parentPath,
3956
- listItemProps = _this$$props.listItemProps;
3957
- if (!Array.isArray(listArray) || listArray.length === 0) {
3958
- return null;
3959
- }
3960
- return vue.createVNode(HierarchicalMenuList, {
3961
- "class": "" + (isExpanded ? '--open' : ''),
3962
- "isSelected": isExpanded
3963
- }, _isSlot$2(_slot = listArray.map(function (listItem) {
3964
- return vue.createVNode(HierarchicalMenuListItemComponent, vue.mergeProps({
3965
- "key": parentPath + "__" + JSON.stringify(listItem),
3966
- "parentPath": parentPath,
3967
- "listItem": listItem
3968
- }, listItemProps), null);
3969
- })) ? _slot : {
3970
- "default": function _default() {
3971
- return [_slot];
3972
- }
3973
- });
3974
- }
3975
- };
3976
-
3977
- function _isSlot$3(s) {
3978
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
3979
- }
3980
- var updateQueryAction = reactivecore.Actions.updateQuery,
3981
- setQueryOptions = reactivecore.Actions.setQueryOptions;
3982
- var transformValueIntoLocalState = function transformValueIntoLocalState(valueArray) {
3983
- var valueToSet = {};
3984
- if (valueArray.length) {
3985
- var newSelectedValues = {};
3986
- valueArray.forEach(function (valueItem) {
3987
- helper.setDeep(newSelectedValues, valueItem.split(' > '), !helper.recLookup(newSelectedValues, valueItem.split(' > '), constants.TREELIST_VALUES_PATH_SEPARATOR), true);
3988
- });
3989
- valueToSet = newSelectedValues;
3990
- }
3991
- return valueToSet;
3992
- };
3993
- var TreeList = {
3994
- name: 'TreeList',
3995
- props: {
3996
- selectedValue: vueTypes.types.selectedValue,
3997
- error: vueTypes.types.title,
3998
- rawData: vueTypes.types.rawData,
3999
- aggregationData: vueTypes.types.rawData,
4000
- themePreset: vueTypes.types.themePreset,
4001
- updateQueryAction: vueTypes.types.funcRequired,
4002
- setQueryOptions: vueTypes.types.funcRequired,
4003
- // component props
4004
- componentId: vueTypes.types.string.isRequired,
4005
- className: vueTypes.types.string,
4006
- style: vueTypes.types.style,
4007
- showRadio: VueTypes.bool.def(false),
4008
- showCheckbox: vueTypes.types.bool.def(false),
4009
- mode: VueTypes.oneOf(['single', 'multiple']).def('multiple'),
4010
- showCount: VueTypes.bool.def(false),
4011
- showSearch: VueTypes.bool.def(false),
4012
- showIcon: VueTypes.bool.def(false),
4013
- icon: vueTypes.types.children,
4014
- showLeafIcon: VueTypes.bool.def(false),
4015
- leafIcon: vueTypes.types.children,
4016
- showLine: VueTypes.bool.def(false),
4017
- switcherIcon: vueTypes.types.func,
4018
- render: vueTypes.types.func,
4019
- renderItem: vueTypes.types.func,
4020
- innerClass: vueTypes.types.style,
4021
- placeholder: vueTypes.types.string,
4022
- title: vueTypes.types.title,
4023
- isLoading: vueTypes.types.bool,
4024
- dataField: vueTypes.types.stringArray.isRequired,
4025
- onQueryChange: vueTypes.types.func,
4026
- defaultValue: vueTypes.types.stringArray,
4027
- value: vueTypes.types.stringArray,
4028
- customQuery: vueTypes.types.func,
4029
- defaultQuery: vueTypes.types.func,
4030
- enableAppbase: vueTypes.types.bool,
4031
- index: vueTypes.types.string,
4032
- showFilter: vueTypes.types.bool,
4033
- URLParams: vueTypes.types.bool,
4034
- filterLabel: vueTypes.types.string,
4035
- onChange: vueTypes.types.func,
4036
- onValueChange: vueTypes.types.func,
4037
- beforeValueChange: vueTypes.types.func,
4038
- sortBy: vueTypes.types.sortByWithCount.def('count'),
4039
- onError: vueTypes.types.func,
4040
- showSwitcherIcon: vueTypes.types.bool.def(true),
4041
- renderError: vueTypes.types.title,
4042
- renderNoResults: vueTypes.types.func,
4043
- loader: vueTypes.types.title,
4044
- aggergationSize: vueTypes.types.number,
4045
- endpoint: vueTypes.types.endpoint,
4046
- queryFormat: vueTypes.types.queryFormatSearch.def('or'),
4047
- size: vueTypes.types.number.def(100),
4048
- nestedField: vueTypes.types.string,
4049
- react: vueTypes.types.react,
4050
- transformData: vueTypes.types.func,
4051
- selectAllLabel: vueTypes.types.string,
4052
- showMissing: VueTypes.bool.def(false),
4053
- missingLabel: VueTypes.string.def('N/A')
4054
- },
4055
- data: function data() {
4056
- var props = this.$props;
4057
- this.__state = {
4058
- selectedValues: {},
4059
- searchTerm: '',
4060
- aggregationData: []
4061
- };
4062
- this.internalComponent = props.componentId + "__internal";
4063
- return this.__state;
4064
- },
4065
- created: function created() {
4066
- var props = this.$props;
4067
- var componentId = props.componentId;
4068
- var defaultValue = this.defaultValue || this.value;
4069
- var currentValueArray = this.selectedValue || defaultValue || [];
4070
- // update local state for selected values
4071
- if (currentValueArray.length) {
4072
- var newSelectedValues = transformValueIntoLocalState(currentValueArray);
4073
- this.setValue(newSelectedValues, true);
4074
- }
4075
-
4076
- // Set custom and default queries in store
4077
- helper.updateCustomQuery(componentId, props, currentValueArray);
4078
- helper.updateDefaultQuery(componentId, props, currentValueArray);
4079
- this.updateQueryOptions();
4080
- },
4081
- mounted: function mounted() {
4082
- var _this$$props = this.$props,
4083
- enableAppbase = _this$$props.enableAppbase,
4084
- index = _this$$props.index;
4085
- if (!enableAppbase && index) {
4086
- console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
4087
- }
4088
- },
4089
- watch: {
4090
- defaultQuery: function defaultQuery() {
4091
- this.updateDefaultQuery();
4092
- this.updateQuery([]);
4093
- },
4094
- customQuery: function customQuery() {
4095
- var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
4096
- this.updateQuery(valueArray);
4097
- },
4098
- sortBy: function sortBy() {
4099
- this.updateQueryOptions();
4100
- },
4101
- dataField: function dataField() {
4102
- var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
4103
- this.updateQueryOptions();
4104
- this.updateQuery(valueArray);
4105
- },
4106
- value: function value(newVal, oldVal) {
4107
- if (!helper.isEqual(newVal, oldVal)) {
4108
- this.setValue(newVal);
4109
- }
4110
- },
4111
- selectedValue: function selectedValue(newVal) {
4112
- if (!helper.isEqual(helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues), newVal)) {
4113
- var _this$$props2 = this.$props,
4114
- value = _this$$props2.value,
4115
- onChange = _this$$props2.onChange;
4116
- var valueToSet = [];
4117
- if (Array.isArray(newVal) && newVal.length) {
4118
- valueToSet = newVal;
4119
- }
4120
- if (value === undefined) {
4121
- this.setValue(valueToSet);
4122
- } else if (onChange && !helper.isEqual(value, valueToSet)) {
4123
- onChange(valueToSet);
4124
- }
4125
- }
4126
- },
4127
- aggregationData: function aggregationData(newVal, oldVal) {
4128
- if (newVal && !helper.isEqual(newVal, oldVal)) {
4129
- this.$data.aggregationData = newVal;
4130
- }
4131
- }
4132
- },
4133
- computed: {
4134
- hasCustomRenderer: function hasCustomRenderer() {
4135
- return index.hasCustomRenderer(this);
4136
- }
4137
- },
4138
- methods: {
4139
- renderIcon: function renderIcon(isLeafNode) {
4140
- var _this$$props3 = this.$props,
4141
- showIcon = _this$$props3.showIcon,
4142
- showLeafIcon = _this$$props3.showLeafIcon,
4143
- icon = _this$$props3.icon;
4144
- if (isLeafNode) {
4145
- if (!showLeafIcon) return null;
4146
- var _ref = this.$slots || this.$props,
4147
- leafIcon = _ref.leafIcon;
4148
- if (leafIcon) return leafIcon();
4149
- return vue.createVNode("span", {
4150
- "role": "img",
4151
- "aria-label": "file",
4152
- "class": "--leaf-icon"
4153
- }, [vue.createVNode("svg", {
4154
- "viewBox": "64 64 896 896",
4155
- "focusable": "false",
4156
- "data-icon": "file",
4157
- "width": "1em",
4158
- "height": "1em",
4159
- "fill": "currentColor",
4160
- "aria-hidden": "true"
4161
- }, [vue.createVNode("path", {
4162
- "d": "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"
4163
- }, null)])]);
4164
- }
4165
- if (!showIcon) return null;
4166
- if (icon) {
4167
- return icon;
4168
- }
4169
- if (this.$slots.icon) {
4170
- return this.$slots.icon();
4171
- }
4172
- return vue.createVNode("span", {
4173
- "role": "img",
4174
- "aria-label": "folder-open",
4175
- "class": "--folder-icon"
4176
- }, [vue.createVNode("svg", {
4177
- "viewBox": "64 64 896 896",
4178
- "focusable": "false",
4179
- "data-icon": "folder-open",
4180
- "width": "1em",
4181
- "height": "1em",
4182
- "fill": "currentColor",
4183
- "aria-hidden": "true"
4184
- }, [vue.createVNode("path", {
4185
- "d": "M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"
4186
- }, null)])]);
4187
- },
4188
- getTransformedData: function getTransformedData() {
4189
- var _this$$props4 = this.$props,
4190
- dataField = _this$$props4.dataField,
4191
- showSearch = _this$$props4.showSearch;
4192
- var transformedData = helper.transformRawTreeListData(this.$data.aggregationData, dataField);
4193
- var filteredData = [];
4194
- if (showSearch && this.searchTerm) {
4195
- filteredData = this.filterDataBasedOnSearchTerm(transformedData, '');
4196
- }
4197
- return filteredData.length ? filteredData : transformedData;
4198
- },
4199
- handleInputChange: function handleInputChange(e) {
4200
- var value = e.target.value;
4201
- this.searchTerm = value;
4202
- },
4203
- renderSearch: function renderSearch() {
4204
- var _this$$props5 = this.$props,
4205
- showSearch = _this$$props5.showSearch,
4206
- innerClass = _this$$props5.innerClass,
4207
- placeholder = _this$$props5.placeholder,
4208
- componentId = _this$$props5.componentId,
4209
- themePreset = _this$$props5.themePreset;
4210
- if (showSearch) {
4211
- return vue.createVNode(Input.Input, {
4212
- "class": helper.getClassName(innerClass, 'input') || null,
4213
- "onInput": this.handleInputChange,
4214
- "value": this.searchTerm,
4215
- "placeholder": placeholder || 'Search',
4216
- "style": {
4217
- margin: '0 0 8px'
4218
- },
4219
- "aria-label": componentId + "-search",
4220
- "themePreset": themePreset
4221
- }, null);
4222
- }
4223
- return null;
4224
- },
4225
- handleListItemClick: function handleListItemClick(key, parentPath) {
4226
- var path = key;
4227
- if (parentPath) {
4228
- path = "" + parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + key;
4229
- }
4230
- var newSelectedValues = _rollupPluginBabelHelpers._extends({}, this.selectedValues);
4231
- if (this.$props.mode === 'single') {
4232
- newSelectedValues = {};
4233
- helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), true, true);
4234
- } else {
4235
- var newValue = !helper.recLookup(newSelectedValues, path, constants.TREELIST_VALUES_PATH_SEPARATOR);
4236
- helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), newValue, true);
4237
- }
4238
- newSelectedValues = utils.sanitizeObject(_rollupPluginBabelHelpers._extends({}, newSelectedValues));
4239
- if (this.$props.value === undefined) {
4240
- this.setValue(newSelectedValues);
4241
- } else if (this.$props.onChange) {
4242
- var valueToSet = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(newSelectedValues);
4243
- this.$props.onChange(valueToSet);
4244
- }
4245
- },
4246
- filterDataBasedOnSearchTerm: function filterDataBasedOnSearchTerm(listArray, parentPath) {
4247
- var _this = this;
4248
- if (!(listArray && Array.isArray(listArray) && listArray.length)) {
4249
- return null;
4250
- }
4251
- var result = [];
4252
- listArray.forEach(function (ele) {
4253
- var isLeafItem = !ele.list;
4254
- var newParentPath = ele.key;
4255
- if (parentPath) {
4256
- newParentPath = parentPath + "." + ele.key;
4257
- }
4258
- var keyHasSearchTerm = suggestions.replaceDiacritics(ele.key).toLowerCase().includes(suggestions.replaceDiacritics(_this.$data.searchTerm).toLowerCase()) || helper.recLookup(_this.$data.selectedValues, newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
4259
- if (isLeafItem && keyHasSearchTerm) {
4260
- result.push(_rollupPluginBabelHelpers._extends({}, ele, {
4261
- initiallyExpanded: keyHasSearchTerm
4262
- }));
4263
- } else if (!isLeafItem) {
4264
- var filteredChildrenItems = _this.filterDataBasedOnSearchTerm(ele.list, newParentPath);
4265
- if (keyHasSearchTerm || !!filteredChildrenItems.length) {
4266
- result.push(_rollupPluginBabelHelpers._extends({}, ele, {
4267
- initiallyExpanded: keyHasSearchTerm || !!filteredChildrenItems.length,
4268
- list: filteredChildrenItems
4269
- }));
4270
- }
4271
- }
4272
- });
4273
- return result;
4274
- },
4275
- getComponent: function getComponent() {
4276
- var _this$$props6 = this.$props,
4277
- rawData = _this$$props6.rawData,
4278
- error = _this$$props6.error,
4279
- isLoading = _this$$props6.isLoading;
4280
- var data = {
4281
- data: this.getTransformedData(),
4282
- rawData: rawData,
4283
- error: error,
4284
- handleClick: this.handleListItemClick,
4285
- value: this.$data.selectedValues,
4286
- loading: isLoading,
4287
- PATH_SEPARATOR: constants.TREELIST_VALUES_PATH_SEPARATOR
4288
- };
4289
- return this.$slots.render(data) || helper.getComponent(data, this.$props);
4290
- },
4291
- getDefaultQuery: function getDefaultQuery(value) {
4292
- var _this2 = this;
4293
- var query = null;
4294
- var type = 'term';
4295
- var booleanAggregator = this.$props.queryFormat === 'or' ? 'should' : 'must';
4296
- if (!Array.isArray(value) || value.length === 0) {
4297
- return null;
4298
- }
4299
- if (value) {
4300
- var _bool;
4301
- // adds a sub-query with must as an array of objects for each term/value
4302
- var queryArray = value.map(function (item) {
4303
- return {
4304
- bool: {
4305
- must: item.split(' > ').map(function (subItem, i) {
4306
- var _type, _ref2;
4307
- return _ref2 = {}, _ref2[type] = (_type = {}, _type[_this2.$props.dataField[i]] = subItem, _type), _ref2;
4308
- })
4309
- }
4310
- };
4311
- });
4312
- var listQuery = {
4313
- bool: (_bool = {}, _bool[booleanAggregator] = queryArray, _bool)
4314
- };
4315
- query = value.length ? listQuery : null;
4316
- }
4317
- if (query && this.$props.nestedField) {
4318
- return {
4319
- nested: {
4320
- path: this.$props.nestedField,
4321
- query: query
4322
- }
4323
- };
4324
- }
4325
- return query;
4326
- },
4327
- updateQuery: function updateQuery(value) {
4328
- var customQuery = this.$props.customQuery;
4329
- var query = this.getDefaultQuery(value);
4330
- var customQueryOptions;
4331
- if (customQuery) {
4332
- var _ref3 = customQuery(value, this.$props) || {};
4333
- query = _ref3.query;
4334
- customQueryOptions = helper.getOptionsFromQuery(customQuery(value, this.$props));
4335
- helper.updateCustomQuery(this.$props.componentId, this.$props, value);
4336
- }
4337
- this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, this.generateQueryOptions(), customQueryOptions));
4338
- this.updateQueryAction({
4339
- componentId: this.$props.componentId,
4340
- query: query,
4341
- value: value,
4342
- label: this.$props.filterLabel,
4343
- showFilter: this.$props.showFilter,
4344
- URLParams: this.$props.URLParams,
4345
- componentType: constants.componentTypes.treeList
4346
- });
4347
- },
4348
- setValue: function setValue(value, hasMountedParam) {
4349
- var _this3 = this;
4350
- if (hasMountedParam === void 0) {
4351
- hasMountedParam = true;
4352
- }
4353
- var finalValues = Array.isArray(value) === false ? helper.transformTreeListLocalStateIntoQueryComptaibleFormat(value) : value;
4354
- var performUpdate = function performUpdate() {
4355
- var handleUpdates = function handleUpdates() {
4356
- _this3.updateQuery(finalValues);
4357
- if (_this3.$props.onValueChange) _this3.$props.onValueChange(finalValues);
4358
- };
4359
- if (hasMountedParam) {
4360
- _this3.selectedValues = Array.isArray(value) ? transformValueIntoLocalState(value) : value;
4361
- handleUpdates();
4362
- } else {
4363
- handleUpdates();
4364
- }
4365
- };
4366
- helper.checkValueChange(this.$props.componentId, finalValues, this.$props.beforeValueChange, performUpdate);
4367
- },
4368
- generateQueryOptions: function generateQueryOptions() {
4369
- var queryOptions = helper.getQueryOptions(this.$props);
4370
- var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
4371
- return helper.getAggsQuery(valueArray, queryOptions, this.$props);
4372
- },
4373
- updateDefaultQuery: function updateDefaultQuery(queryOptions) {
4374
- var value = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
4375
- // Update default query for RS API
4376
- helper.updateDefaultQuery(this.$props.componentId, this.$props, value);
4377
- helper.updateInternalQuery(transform.getInternalComponentID(this.$props.componentId), queryOptions, value, this.$props, this.generateQueryOptions(), null);
4378
- },
4379
- updateQueryOptions: function updateQueryOptions() {
4380
- // for a new query due to other changes don't append after to get fresh results
4381
- var queryOptions = this.generateQueryOptions(this.$props, {}, helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues));
4382
- if (this.$props.defaultQuery) {
4383
- // eslint-disable-next-line no-use-before-define
4384
- this.updateDefaultQuery(queryOptions);
4385
- } else {
4386
- this.setQueryOptions(transform.getInternalComponentID(this.$props.componentId), queryOptions);
4387
- }
4388
- }
4389
- },
4390
- render: function render() {
4391
- var _this4 = this;
4392
- var props = this.$props;
4393
- var style = props.style,
4394
- className = props.className,
4395
- mode = props.mode,
4396
- showLine = props.showLine,
4397
- renderItem = props.renderItem,
4398
- showCheckbox = props.showCheckbox,
4399
- innerClass = props.innerClass,
4400
- showRadio = props.showRadio,
4401
- showCount = props.showCount,
4402
- showSwitcherIcon = props.showSwitcherIcon,
4403
- switcherIcon = props.switcherIcon,
4404
- title = props.title,
4405
- loader = props.loader,
4406
- renderError = props.renderError;
4407
- if (this.isLoading) {
4408
- return (this.$slots.loader ? this.$slots.loader() : loader) || null;
4409
- }
4410
- if (this.error) {
4411
- if (this.$slots.renderError) {
4412
- return this.$slots.renderError(this.error);
4413
- }
4414
- return helper.isFunction(renderError) ? renderError(this.error) : renderError;
4415
- }
4416
- var transformedData = this.getTransformedData();
4417
- if (!transformedData || transformedData.length === 0) {
4418
- return this.$slots.renderNoResults ? this.$slots.renderNoResults() : null;
4419
- }
4420
- return vue.createVNode(Container.Container, {
4421
- "style": style,
4422
- "class": className
4423
- }, {
4424
- "default": function _default() {
4425
- return [props.title && vue.createVNode(Title.Title, {
4426
- "class": helper.getClassName(innerClass, 'title') || null
4427
- }, _isSlot$3(title) ? title : {
4428
- "default": function _default() {
4429
- return [title];
4430
- }
4431
- }), _this4.renderSearch(), _this4.hasCustomRenderer ? _this4.getComponent() : vue.createVNode(HierarchicalMenuComponent, {
4432
- "key": "initial-node",
4433
- "listArray": transformedData,
4434
- "parentPath": "",
4435
- "isExpanded": true,
4436
- "listItemProps": {
4437
- mode: mode,
4438
- selectedValues: _this4.selectedValues,
4439
- searchTerm: _this4.searchTerm,
4440
- showLine: showLine,
4441
- renderItem: renderItem != null ? renderItem : _this4.$slots.renderItem,
4442
- handleListItemClick: _this4.handleListItemClick,
4443
- showCheckbox: showCheckbox,
4444
- innerClass: innerClass,
4445
- showRadio: showRadio,
4446
- renderIcon: _this4.renderIcon,
4447
- showCount: showCount,
4448
- showSwitcherIcon: showSwitcherIcon,
4449
- switcherIcon: switcherIcon != null ? switcherIcon : _this4.$slots.switcherIcon
4450
- }
4451
- }, null)];
4452
- }
4453
- });
4454
- }
4455
- };
4456
- var mapStateToProps$2 = function mapStateToProps(state, props) {
4457
- return {
4458
- selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
4459
- rawData: state.rawData[props.componentId] || {},
4460
- aggregationData: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId] || {},
4461
- themePreset: state.config.themePreset,
4462
- error: state.error[props.componentId],
4463
- isLoading: state.isLoading[props.componentId],
4464
- enableAppbase: state.config.enableAppbase
4465
- };
4466
- };
4467
- var mapDispatchtoProps = {
4468
- setQueryOptions: setQueryOptions,
4469
- updateQueryAction: updateQueryAction
4470
- };
4471
- TreeList.hasInternalComponent = function () {
4472
- return true;
4473
- };
4474
- var TreeListConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$2, mapDispatchtoProps)(TreeList), {
4475
- componentType: constants.componentTypes.treeList,
4476
- internalComponent: TreeList.hasInternalComponent()
4477
- }));
4478
- TreeListConnected.name = TreeList.name;
4479
- TreeListConnected.install = function (Vue) {
4480
- Vue.component(TreeListConnected.name, TreeListConnected);
4481
- };
4482
-
4483
- // Add componentType for SSR
4484
- TreeListConnected.componentType = constants.componentTypes.treeList;
4485
-
4486
- var RcConnected = PreferencesConsumer.PreferencesConsumer({
4487
- name: 'RcConnected',
4488
- render: function render() {
4489
- var component = ReactiveComponent.default;
4490
- switch (this.$attrs.componentType) {
4491
- case constants.componentTypes.reactiveList:
4492
- component = ReactiveList.default;
4493
- break;
4494
- case constants.componentTypes.searchBox:
4495
- component = SBConnected;
4496
- break;
4497
- // list components
4498
- case constants.componentTypes.singleList:
4499
- component = SingleList.default;
4500
- break;
4501
- case constants.componentTypes.multiList:
4502
- component = MultiList.default;
4503
- break;
4504
- case constants.componentTypes.singleDropdownList:
4505
- component = SingleDropdownList.default;
4506
- break;
4507
- case constants.componentTypes.multiDropdownList:
4508
- component = MultiDropdownList.default;
4509
- break;
4510
- // basic components
4511
- case constants.componentTypes.toggleButton:
4512
- component = ToggleButton.default;
4513
- break;
4514
- // range components
4515
- case constants.componentTypes.dynamicRangeSlider:
4516
- component = DynamicRangeSlider.default;
4517
- break;
4518
- case constants.componentTypes.singleRange:
4519
- component = SingleRange.default;
4520
- break;
4521
- case constants.componentTypes.multiRange:
4522
- component = MultiRange.default;
4523
- break;
4524
- case constants.componentTypes.rangeSlider:
4525
- component = RangeSlider.default;
4526
- break;
4527
- case constants.componentTypes.rangeInput:
4528
- component = RangeInput.default;
4529
- break;
4530
- }
4531
- return vue.h(component, null, this.$slots);
4532
- }
4533
- });
4534
- RcConnected.name = ReactiveComponent.default.name;
4535
- RcConnected.hasInternalComponent = ReactiveComponent.default.hasInternalComponent;
4536
- // Add componentType for SSR
4537
- RcConnected.componentType = constants.componentTypes.reactiveComponent;
4538
- RcConnected.install = function (Vue) {
4539
- Vue.component(RcConnected.name, RcConnected);
4540
- };
4541
-
4542
- var components = [ReactiveList.default, ResultCard.default, ResultList.default, ReactiveBase.default, SBConnected, SingleList.default, MultiList.default, SingleRange.default, MultiRange.default, RangeSlider.default, DynamicRangeSlider.default, ReactiveComponent.default, RcConnected, SelectedFilters.default, ToggleButton.default, SingleDropdownList.default, MultiDropdownList.default, StateProvider.default, RangeInput.default, TreeListConnected, AIConnected];
4543
- function install (Vue) {
4544
- components.map(function (component) {
4545
- Vue.use(component);
4546
- return null;
4547
- });
4548
- }
4549
-
4550
- exports.AIAnswer = AIConnected;
4551
- exports.ReactiveComponentPrivate = RcConnected;
2896
+ exports.AIFeedback = AIFeedback;
2897
+ exports.ChatContainer = ChatContainer;
2898
+ exports.Chatbox = Chatbox;
2899
+ exports.Footer = Footer;
2900
+ exports.InputGroup = InputGroup;
2901
+ exports.Message = Message;
2902
+ exports.MessageInput = MessageInput;
2903
+ exports.MessageInputContainer = MessageInputContainer;
2904
+ exports.MessagesContainer = MessagesContainer;
2905
+ exports.Mic = Mic;
2906
+ exports.SBConnected = SBConnected;
4552
2907
  exports.SearchBox = SBConnected;
4553
- exports.TreeList = TreeListConnected;
4554
- exports.install = install;
2908
+ exports.SearchSvg = SearchSvg;
2909
+ exports.SendButton = SendButton;
2910
+ exports.SourceTags = SourceTags;
2911
+ exports.TypingDot = TypingDot;
2912
+ exports.TypingIndicator = TypingIndicator;