@appbaseio/reactivesearch-vue 3.3.0 → 3.3.1

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