@appbaseio/reactivesearch-vue 3.2.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 +811 -994
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  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 +11 -9
  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 +15 -10
  27. package/dist/cjs/ResultCard.js +3 -3
  28. package/dist/cjs/ResultList.js +3 -3
  29. package/dist/cjs/{install-a3c5b872.js → SearchBox-4dff47b4.js} +42 -1684
  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 +11 -9
  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 +15 -10
  68. package/dist/es/ResultCard.js +3 -3
  69. package/dist/es/ResultList.js +3 -3
  70. package/dist/es/{install-3c9a9694.js → SearchBox-57e3a0ff.js} +17 -1671
  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 +91 -91
@@ -0,0 +1,1683 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var reactivecore = require('@appbaseio/reactivecore');
6
+ var constants = require('@appbaseio/reactivecore/lib/utils/constants');
7
+ var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-1a877b17.js');
8
+ var vue = require('vue');
9
+ var VueTypes = _interopDefault(require('vue-types'));
10
+ var helper = require('@appbaseio/reactivecore/lib/utils/helper');
11
+ var vueEmotion = require('@appbaseio/vue-emotion');
12
+ var Button = require('./Button-7aee17e3.js');
13
+ var vueTypes = require('./vueTypes-289a891a.js');
14
+ var ReactiveList = require('./ReactiveList.js');
15
+ var transform = require('@appbaseio/reactivecore/lib/utils/transform');
16
+ var index = require('./index-7ca9570e.js');
17
+ var ComponentWrapper = require('./ComponentWrapper-3bedbe57.js');
18
+ var PreferencesConsumer = require('./PreferencesConsumer-37cab7a0.js');
19
+ var Title = require('./Title-d513ac26.js');
20
+ var ListItem = require('./ListItem-f272f502.js');
21
+ var Flex = require('./Flex-f7af0673.js');
22
+ var analytics = require('@appbaseio/reactivecore/lib/actions/analytics');
23
+ var ReactiveBase = require('./ReactiveBase.js');
24
+ var remarkable = require('remarkable');
25
+ var SearchBox = require('./SearchBox-4dff47b4.js');
26
+ var CancelSvg = require('./CancelSvg-6094cd37.js');
27
+ var Input = require('./Input-55fbd8e1.js');
28
+ var Container = require('./Container-1c05785a.js');
29
+ var query = require('@appbaseio/reactivecore/lib/actions/query');
30
+ var suggestions = require('@appbaseio/reactivecore/lib/utils/suggestions');
31
+ var FormControlList = require('./FormControlList-2c10e01a.js');
32
+ var utils = require('./utils-a3db8765.js');
33
+ var SingleList = require('./SingleList.js');
34
+ var MultiList = require('./MultiList.js');
35
+ var types = _interopDefault(require('@appbaseio/reactivecore/lib/utils/types'));
36
+ var SingleDropdownList = require('./SingleDropdownList.js');
37
+ var MultiDropdownList = require('./MultiDropdownList.js');
38
+ var ToggleButton = require('./ToggleButton.js');
39
+ var ReactiveComponent = require('./ReactiveComponent.js');
40
+ var DynamicRangeSlider = require('./DynamicRangeSlider.js');
41
+ var SingleRange = require('./SingleRange.js');
42
+ var MultiRange = require('./MultiRange.js');
43
+ var RangeSlider = require('./RangeSlider.js');
44
+ var RangeInput = require('./RangeInput.js');
45
+ var SelectedFilters = require('./SelectedFilters.js');
46
+ var ResultCard = require('./ResultCard.js');
47
+ var ResultList = require('./ResultList.js');
48
+ var StateProvider = require('./StateProvider.js');
49
+
50
+ var _excluded = ["_source"];
51
+ function _isSlot(s) {
52
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
53
+ }
54
+ var md = new remarkable.Remarkable();
55
+ md.set({
56
+ html: true,
57
+ breaks: true,
58
+ xhtmlOut: true,
59
+ linkify: true,
60
+ linkTarget: '_blank'
61
+ });
62
+ var _inputWrapperRef = 'inputWrapperRef';
63
+ var _inputRef = 'inputRef';
64
+ var _errorContainerRef = 'errorContainerRef';
65
+ var AIAnswer = vue.defineComponent({
66
+ name: 'AIAnswer',
67
+ data: function data() {
68
+ var props = this.$props;
69
+ this.__state = {
70
+ messages: [],
71
+ inputMessage: '',
72
+ AISessionId: '',
73
+ error: null,
74
+ sourceDocIds: null,
75
+ initialHits: null,
76
+ isTriggered: false
77
+ };
78
+ this.internalComponent = props.componentId + "__internal";
79
+ return this.__state;
80
+ },
81
+ inject: {
82
+ theme: {
83
+ from: 'theme_reactivesearch'
84
+ }
85
+ },
86
+ created: function created() {
87
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
88
+ this.isTriggered = true;
89
+ } else if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?')) {
90
+ this.isTriggered = true;
91
+ if (this.AISessionId) {
92
+ this.handleSendMessage(null, false, '', true);
93
+ }
94
+ }
95
+ },
96
+ computed: {
97
+ hasCustomRenderer: function hasCustomRenderer() {
98
+ return index.hasCustomRenderer(this);
99
+ },
100
+ isLoadingState: function isLoadingState() {
101
+ return this.isAIResponseLoading || this.isLoading;
102
+ },
103
+ shouldShowComponent: function shouldShowComponent() {
104
+ return this.showComponent;
105
+ },
106
+ errorMessageForMissingSessionId: function errorMessageForMissingSessionId() {
107
+ return "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.";
108
+ },
109
+ hasTriggered: function hasTriggered() {
110
+ return this.isTriggered;
111
+ }
112
+ },
113
+ props: {
114
+ componentId: vueTypes.types.string.isRequired,
115
+ showVoiceInput: VueTypes.bool.def(false),
116
+ showFeedback: VueTypes.bool.def(true),
117
+ showIcon: VueTypes.bool.def(true),
118
+ onData: vueTypes.types.func,
119
+ innerRef: VueTypes.string.def('AISearchInputField'),
120
+ react: vueTypes.types.react,
121
+ enableAI: VueTypes.bool.def(true),
122
+ AIConfig: vueTypes.types.AIConfig,
123
+ iconPosition: vueTypes.types.iconPosition.def('left'),
124
+ themePreset: vueTypes.types.themePreset,
125
+ theme: vueTypes.types.style,
126
+ icon: vueTypes.types.children,
127
+ iconURL: VueTypes.string.def(''),
128
+ renderMic: vueTypes.types.func,
129
+ getMicInstance: vueTypes.types.func,
130
+ innerClass: vueTypes.types.style,
131
+ placeholder: VueTypes.string.def('Ask a question'),
132
+ title: vueTypes.types.title,
133
+ AIResponse: vueTypes.types.componentObject,
134
+ isAIResponseLoading: VueTypes.bool.def(false),
135
+ AIResponseError: vueTypes.types.componentObject,
136
+ getAIResponse: vueTypes.types.func.isRequired,
137
+ enterButton: vueTypes.types.bool,
138
+ renderEnterButton: vueTypes.types.title,
139
+ showInput: VueTypes.bool.def(true),
140
+ clearSessionOnDestroy: VueTypes.bool.def(true),
141
+ rawData: vueTypes.types.rawData,
142
+ render: vueTypes.types.func,
143
+ onError: vueTypes.types.func,
144
+ renderError: vueTypes.types.title,
145
+ isLoading: vueTypes.types.boolRequired,
146
+ sessionIdFromStore: VueTypes.string,
147
+ showComponent: vueTypes.types.boolRequired,
148
+ componentError: vueTypes.types.componentObject,
149
+ style: vueTypes.types.style,
150
+ showSourceDocuments: VueTypes.bool.def(false),
151
+ renderSourceDocument: vueTypes.types.func,
152
+ onSourceClick: vueTypes.types.func,
153
+ isAITyping: vueTypes.types.boolRequired,
154
+ triggerOn: VueTypes.string.def(constants.AI_TRIGGER_MODES.ALWAYS),
155
+ renderTriggerMessage: vueTypes.types.func
156
+ },
157
+ mounted: function mounted() {},
158
+ watch: {
159
+ AIResponse: function AIResponse(newVal) {
160
+ if (newVal) {
161
+ if (this.$props.showSourceDocuments && newVal.response && newVal.response.answer && Array.isArray(newVal.response.answer.documentIds)) {
162
+ this.sourceDocIds = newVal.response.answer.documentIds;
163
+ var localCache = helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) && helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY)[this.$props.componentId];
164
+ if (localCache && localCache.meta && localCache.meta.hits) {
165
+ this.initialHits = localCache.meta.hits;
166
+ }
167
+ }
168
+ 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;
169
+ var messagesHistory = newVal.messages,
170
+ response = newVal.response;
171
+ var finalMessages = [];
172
+ if (response && response.error) {
173
+ this.error = {
174
+ message: response.error
175
+ };
176
+ }
177
+ // pushing message history so far
178
+ if (messagesHistory && Array.isArray(messagesHistory)) {
179
+ finalMessages.push.apply(finalMessages, messagesHistory.filter(function (msg) {
180
+ return msg.role !== constants.AI_ROLES.SYSTEM;
181
+ }));
182
+ if (finalMessages[0].role === constants.AI_ROLES.USER) {
183
+ finalMessages.shift();
184
+ }
185
+ } else if (response && response.answer && response.answer.text) {
186
+ finalMessages.push({
187
+ role: constants.AI_ROLES.ASSISTANT,
188
+ content: response.answer.text
189
+ });
190
+ if (!this.AISessionId) this.error = {
191
+ message: this.errorMessageForMissingSessionId
192
+ };
193
+ }
194
+ this.messages = finalMessages;
195
+ } else if (!newVal && !this.error) {
196
+ this.messages = [];
197
+ }
198
+ },
199
+ rawData: function rawData(newVal) {
200
+ this.$emit('on-data', {
201
+ data: this.messages,
202
+ rawData: newVal,
203
+ loading: this.$props.isAIResponseLoading || this.$props.isLoading,
204
+ error: this.$props.AIResponseError
205
+ });
206
+ if (newVal && newVal.hits && newVal.hits.hits) {
207
+ this.initialHits = newVal.hits.hits;
208
+ }
209
+ },
210
+ isAIResponseLoading: function isAIResponseLoading(newVal) {
211
+ this.$emit('on-data', {
212
+ data: this.messages,
213
+ rawData: this.$props.rawData,
214
+ loading: newVal || this.isLoading,
215
+ error: this.$props.AIResponseError
216
+ });
217
+ },
218
+ isLoading: function isLoading(newVal) {
219
+ this.$emit('on-data', {
220
+ data: this.messages,
221
+ rawData: this.$props.rawData,
222
+ loading: newVal || this.isAIResponseLoading,
223
+ error: this.$props.AIResponseError
224
+ });
225
+ },
226
+ sessionIdFromStore: function sessionIdFromStore(newVal) {
227
+ if (newVal) {
228
+ this.sessionId = newVal;
229
+ }
230
+ },
231
+ AIResponseError: function AIResponseError(newVal) {
232
+ this.error = newVal;
233
+ 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;
234
+ if (this.error && !this.AISessionId) {
235
+ var errorMessage = this.errorMessageForMissingSessionId;
236
+ this.error = {
237
+ message: errorMessage
238
+ };
239
+ console.error(errorMessage);
240
+ }
241
+ this.$emit('on-data', {
242
+ data: this.messages,
243
+ rawData: this.$props.rawData,
244
+ loading: this.isAIResponseLoading || this.isLoading,
245
+ error: newVal
246
+ });
247
+ },
248
+ messages: function messages() {
249
+ this.scrollToBottom();
250
+ },
251
+ componentError: function componentError(newVal) {
252
+ var _this = this;
253
+ if (newVal && newVal._bodyBlob) {
254
+ 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;
255
+ if (!this.AISessionId) {
256
+ this.generateNewSessionId();
257
+ }
258
+ newVal._bodyBlob.text().then(function (textData) {
259
+ try {
260
+ var parsedErrorRes = JSON.parse(textData);
261
+ if (parsedErrorRes.error) {
262
+ _this.error = parsedErrorRes.error;
263
+ _this.$emit('on-data', {
264
+ data: _this.messages,
265
+ rawData: _this.$props.rawData,
266
+ loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
267
+ error: parsedErrorRes.error
268
+ });
269
+ }
270
+ } catch (error) {
271
+ console.error('Error parsing component error JSON:', error);
272
+ }
273
+ })["catch"](function (error) {
274
+ console.error('Error reading component error text data:', error);
275
+ });
276
+ }
277
+ },
278
+ showComponent: function showComponent() {
279
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.$props.dependentComponentValue.endsWith('?')) {
280
+ this.isTriggered = true;
281
+ }
282
+ },
283
+ dependentComponentValue: function dependentComponentValue(newVal) {
284
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && newVal && newVal.endsWith('?')) {
285
+ this.isTriggered = true;
286
+ if (this.AISessionId) {
287
+ this.handleSendMessage(null, false, '', true);
288
+ }
289
+ } else if (this.hasTriggered && this.$props.triggerOn !== constants.AI_TRIGGER_MODES.ALWAYS) {
290
+ this.isTriggered = false;
291
+ }
292
+ },
293
+ AISessionId: function AISessionId(newVal) {
294
+ if (newVal) {
295
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.QUESTION && this.dependentComponentValue && this.dependentComponentValue.endsWith('?') || this.$props.triggerOn === constants.AI_TRIGGER_MODES.ALWAYS) {
296
+ this.handleSendMessage(null, false, '', true);
297
+ }
298
+ }
299
+ },
300
+ triggerOn: function triggerOn(newVal) {
301
+ if (newVal === constants.AI_TRIGGER_MODES.ALWAYS) {
302
+ this.isTriggered = true;
303
+ }
304
+ }
305
+ },
306
+ methods: {
307
+ renderTriggerMessageFunc: function renderTriggerMessageFunc() {
308
+ var triggerOn = this.$props.triggerOn;
309
+ if (this.$props.renderTriggerMessage) {
310
+ return this.$props.renderTriggerMessage;
311
+ }
312
+ if (this.$slots.renderTriggerMessage) {
313
+ return this.$slots.renderTriggerMessage();
314
+ }
315
+ if (triggerOn === constants.AI_TRIGGER_MODES.QUESTION) {
316
+ if (!this.dependentComponentValue.endsWith('?')) {
317
+ return vue.createVNode("span", null, [vue.createVNode("span", {
318
+ "role": "img",
319
+ "aria-label": "bulb"
320
+ }, [vue.createTextVNode("\uD83D\uDCA1")]), vue.createTextVNode("End your question with a question mark (?)")]);
321
+ }
322
+ } else if (triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
323
+ return vue.createVNode("span", null, [vue.createTextVNode("Click here to ask AI"), ' ', vue.createVNode("span", {
324
+ "role": "img",
325
+ "aria-label": "bulb"
326
+ }, [vue.createTextVNode("\uD83E\uDD16")])]);
327
+ }
328
+ return null;
329
+ },
330
+ handleTriggerClick: function handleTriggerClick() {
331
+ if (this.$props.triggerOn === constants.AI_TRIGGER_MODES.MANUAL) {
332
+ this.handleSendMessage(null, false, '', true);
333
+ this.isTriggered = true;
334
+ }
335
+ },
336
+ getAISourceObjects: function getAISourceObjects() {
337
+ var _this2 = this;
338
+ var sourceObjects = [];
339
+ if (!this.AIResponse) return sourceObjects;
340
+ var docIds = this.sourceDocIds || [];
341
+ if (this.initialHits) {
342
+ docIds.forEach(function (id) {
343
+ var foundSourceObj = _this2.initialHits.find(function (hit) {
344
+ return hit._id === id;
345
+ }) || {};
346
+ if (foundSourceObj) {
347
+ var _foundSourceObj$_sour = foundSourceObj._source,
348
+ _source = _foundSourceObj$_sour === void 0 ? {} : _foundSourceObj$_sour,
349
+ rest = _rollupPluginBabelHelpers._objectWithoutPropertiesLoose(foundSourceObj, _excluded);
350
+ sourceObjects.push(_rollupPluginBabelHelpers._extends({}, rest, _source));
351
+ }
352
+ });
353
+ } else {
354
+ sourceObjects.push.apply(sourceObjects, docIds.map(function (id) {
355
+ return {
356
+ _id: id
357
+ };
358
+ }));
359
+ }
360
+ return sourceObjects;
361
+ },
362
+ renderAIScreenFooter: function renderAIScreenFooter() {
363
+ var _slot2;
364
+ var _this3 = this;
365
+ var _ref = this.$props || {},
366
+ _ref$showSourceDocume = _ref.showSourceDocuments,
367
+ showSourceDocuments = _ref$showSourceDocume === void 0 ? true : _ref$showSourceDocume,
368
+ _ref$onSourceClick = _ref.onSourceClick,
369
+ onSourceClick = _ref$onSourceClick === void 0 ? function () {} : _ref$onSourceClick,
370
+ renderSourceDocument = _ref.renderSourceDocument;
371
+ var customRenderSourceDoc = renderSourceDocument || this.$slots.renderSourceDocument;
372
+ if (this.isLoadingState || this.isAITyping) {
373
+ return null;
374
+ }
375
+ var renderSourceDocumentLabel = function renderSourceDocumentLabel(sourceObj) {
376
+ if (customRenderSourceDoc) {
377
+ return customRenderSourceDoc(sourceObj);
378
+ }
379
+ return sourceObj._id;
380
+ };
381
+ return showSourceDocuments && Array.isArray(this.sourceDocIds) && this.sourceDocIds.length ? vue.createVNode(SearchBox.Footer, {
382
+ "themePreset": this.$props.themePreset,
383
+ "style": {
384
+ marginTop: '1.5rem',
385
+ background: 'inherit'
386
+ }
387
+ }, {
388
+ "default": function _default() {
389
+ return [vue.createTextVNode("Summary generated using the following sources:"), ' ', vue.createVNode(SearchBox.SourceTags, null, _isSlot(_slot2 = _this3.getAISourceObjects().map(function (el) {
390
+ var _slot;
391
+ return vue.createVNode(Button.Button, {
392
+ "class": "--ai-source-tag " + (helper.getClassName(_this3.$props.innerClass, 'ai-source-tag') || ''),
393
+ "info": true,
394
+ "onClick": function onClick() {
395
+ return onSourceClick && onSourceClick(el);
396
+ },
397
+ "key": el._id
398
+ }, _isSlot(_slot = renderSourceDocumentLabel(el)) ? _slot : {
399
+ "default": function _default() {
400
+ return [_slot];
401
+ }
402
+ });
403
+ })) ? _slot2 : {
404
+ "default": function _default() {
405
+ return [_slot2];
406
+ }
407
+ })];
408
+ }
409
+ }) : null;
410
+ },
411
+ generateNewSessionId: function generateNewSessionId() {
412
+ var _this4 = this;
413
+ var newSessionPromise = this.createAISession();
414
+ newSessionPromise.then(function (res) {
415
+ _this4.AISessionId = res.AIsessionId;
416
+ })["catch"](function (e) {
417
+ console.error(e);
418
+ });
419
+ },
420
+ scrollToBottom: function scrollToBottom() {
421
+ var _this5 = this;
422
+ this.$nextTick(function () {
423
+ var _this5$$refs;
424
+ var messageContainer = (_this5$$refs = _this5.$refs) == null ? void 0 : _this5$$refs[_this5.$props.innerRef];
425
+ if (messageContainer && messageContainer.$el) {
426
+ messageContainer.$el.scrollTo({
427
+ top: messageContainer.$el.scrollHeight,
428
+ behavior: 'smooth'
429
+ });
430
+ }
431
+ });
432
+ },
433
+ handleMessageInputChange: function handleMessageInputChange(e) {
434
+ this.inputMessage = e.target.value;
435
+ this.handleTextAreaHeightChange();
436
+ },
437
+ handleSendMessage: function handleSendMessage(e, isRetry, text, fetchMeta) {
438
+ if (isRetry === void 0) {
439
+ isRetry = false;
440
+ }
441
+ if (text === void 0) {
442
+ text = this.inputMessage;
443
+ }
444
+ if (fetchMeta === void 0) {
445
+ fetchMeta = false;
446
+ }
447
+ if (typeof e === 'object' && e !== null) e.preventDefault();
448
+ if (text.trim() || !text && !e) {
449
+ if (this.isLoadingState) {
450
+ return;
451
+ }
452
+ if (this.AISessionId) {
453
+ if (!isRetry) {
454
+ var finalMessages = [].concat(this.messages);
455
+ if (text) {
456
+ finalMessages.push({
457
+ content: text,
458
+ role: constants.AI_ROLES.USER
459
+ });
460
+ }
461
+ this.messages = [].concat(finalMessages);
462
+ }
463
+ this.getAIResponse(this.AISessionId, this.componentId, text, fetchMeta);
464
+ } else {
465
+ console.error(this.errorMessageForMissingSessionId);
466
+ this.error = {
467
+ message: "AISessionId for " + this.$props.componentId + " is missing! AIAnswer component requires an AISessionId to function. Trying reloading the App."
468
+ };
469
+ }
470
+ this.inputMessage = '';
471
+ }
472
+ },
473
+ handleRetryRequest: function handleRetryRequest() {
474
+ if (this.messages && !this.isLoadingState) {
475
+ var _this$messages;
476
+ var lastUserRequestMessage = (_this$messages = this.messages[this.messages.length - 1]) == null ? void 0 : _this$messages.content;
477
+ if (this.AISessionId) {
478
+ this.getAIResponse(this.AISessionId, this.componentId, lastUserRequestMessage);
479
+ this.inputMessage = '';
480
+ } else {
481
+ console.error("AISessionId for " + this.componentId + " is missing! AIAnswer component requires an AISessionId to function. Try reloading the App.");
482
+ }
483
+ }
484
+ },
485
+ renderErrorComponent: function renderErrorComponent() {
486
+ var renderError = this.$slots.renderError || this.$props.renderError;
487
+ if (this.error && !this.isLoadingState) {
488
+ var _this$error, _this$error2;
489
+ if (renderError) {
490
+ return vue.createVNode("div", {
491
+ "ref": _errorContainerRef,
492
+ "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
493
+ }, [index.isFunction(renderError) ? renderError(this.error, this.handleRetryRequest) : renderError]);
494
+ }
495
+ return vue.createVNode("div", {
496
+ "ref": _errorContainerRef,
497
+ "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
498
+ }, [vue.createVNode("div", {
499
+ "class": "--default-error-element"
500
+ }, [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, {
501
+ "primary": true,
502
+ "onClick": this.handleRetryRequest
503
+ }, {
504
+ "default": function _default() {
505
+ return [vue.createTextVNode("Try again")];
506
+ }
507
+ })])]);
508
+ }
509
+ return null;
510
+ },
511
+ handleKeyPress: function handleKeyPress(e) {
512
+ if (e.key === 'Enter') {
513
+ this.handleSendMessage(e);
514
+ this.inputMessage = '';
515
+ }
516
+ },
517
+ renderIcon: function renderIcon() {
518
+ if (this.$props.showIcon) {
519
+ if (this.$props.icon) {
520
+ return this.$props.icon;
521
+ }
522
+ if (this.$slots.icon) {
523
+ return this.$slots.icon();
524
+ }
525
+ if (this.$props.iconURL) {
526
+ return vue.createVNode("img", {
527
+ "style": {
528
+ maxHeight: '25px'
529
+ },
530
+ "src": this.$props.iconURL,
531
+ "alt": "search-icon"
532
+ }, null);
533
+ }
534
+ return vue.createVNode(SearchBox.SearchSvg, null, null);
535
+ }
536
+ return null;
537
+ },
538
+ shouldMicRender: function shouldMicRender(showVoiceSearch) {
539
+ // checks for SSR
540
+ if (typeof window === 'undefined') return false;
541
+ return showVoiceSearch && (window.webkitSpeechRecognition || window.SpeechRecognition);
542
+ },
543
+ handleVoiceResults: function handleVoiceResults(_ref2) {
544
+ var results = _ref2.results;
545
+ if (results && results[0] && results[0].isFinal && results[0][0] && results[0][0].transcript && results[0][0].transcript.trim()) {
546
+ this.handleSendMessage(null, false, results[0][0].transcript.trim());
547
+ }
548
+ },
549
+ renderIcons: function renderIcons() {
550
+ var _this6 = this;
551
+ var _slot3, _slot4;
552
+ var _this$$props = this.$props,
553
+ getMicInstance = _this$$props.getMicInstance,
554
+ showVoiceInput = _this$$props.showVoiceInput,
555
+ iconPosition = _this$$props.iconPosition,
556
+ innerClass = _this$$props.innerClass;
557
+ var renderMic = this.$slots.renderMic || this.$props.renderMic;
558
+ return vue.createVNode("div", null, [vue.createVNode(CancelSvg.IconGroup, {
559
+ "enableAI": true,
560
+ "groupPosition": "right",
561
+ "positionType": "absolute"
562
+ }, {
563
+ "default": function _default() {
564
+ return [!_this6.isLoadingState && _this6.AISessionId && _this6.shouldMicRender(showVoiceInput) && vue.createVNode(SearchBox.Mic, {
565
+ "getInstance": getMicInstance,
566
+ "render": renderMic,
567
+ "handleResult": _this6.handleVoiceResults,
568
+ "class": helper.getClassName(innerClass, 'ai-search-mic') || null
569
+ }, null), iconPosition === 'right' && vue.createVNode(CancelSvg.IconWrapper, null, _isSlot(_slot3 = _this6.renderIcon()) ? _slot3 : {
570
+ "default": function _default() {
571
+ return [_slot3];
572
+ }
573
+ })];
574
+ }
575
+ }), vue.createVNode(CancelSvg.IconGroup, {
576
+ "enableAI": true,
577
+ "groupPosition": "left",
578
+ "positionType": "absolute"
579
+ }, {
580
+ "default": function _default() {
581
+ return [iconPosition === 'left' && vue.createVNode(CancelSvg.IconWrapper, null, _isSlot(_slot4 = _this6.renderIcon()) ? _slot4 : {
582
+ "default": function _default() {
583
+ return [_slot4];
584
+ }
585
+ })];
586
+ }
587
+ })]);
588
+ },
589
+ enterButtonOnClick: function enterButtonOnClick(e) {
590
+ this.handleSendMessage(e);
591
+ },
592
+ renderEnterButtonElement: function renderEnterButtonElement() {
593
+ var _this7 = this;
594
+ var _this$$props2 = this.$props,
595
+ enterButton = _this$$props2.enterButton,
596
+ innerClass = _this$$props2.innerClass;
597
+ var renderEnterButton = this.$slots.renderEnterButton;
598
+ if (enterButton) {
599
+ var getEnterButtonMarkup = function getEnterButtonMarkup() {
600
+ if (renderEnterButton) {
601
+ return renderEnterButton(_this7.enterButtonOnClick);
602
+ }
603
+ return vue.createVNode(SearchBox.SendButton, {
604
+ "primary": true,
605
+ "type": "submit",
606
+ "tabIndex": 0,
607
+ "onClick": _this7.handleSendMessage,
608
+ "onKeyPress": _this7.handleKeyPress,
609
+ "class": "ask-btn " + helper.getClassName(innerClass, 'ai-enter-button'),
610
+ "disabled": _this7.isLoadingState || !_this7.AISessionId
611
+ }, {
612
+ "default": function _default() {
613
+ return [vue.createTextVNode("Send")];
614
+ }
615
+ });
616
+ };
617
+ return vue.createVNode("div", {
618
+ "class": "ai-enter-button-wrapper"
619
+ }, [getEnterButtonMarkup()]);
620
+ }
621
+ return null;
622
+ },
623
+ getComponent: function getComponent() {
624
+ var data = {
625
+ error: this.AIResponseError,
626
+ loading: this.isAIResponseLoading,
627
+ data: this.messages,
628
+ rawData: this.rawData
629
+ };
630
+ return index.getComponent(data, this);
631
+ },
632
+ handleTextAreaHeightChange: function handleTextAreaHeightChange() {
633
+ var _this$$refs, _this$$refs2, _this$$refs3;
634
+ var textArea = (_this$$refs = this.$refs) == null || (_this$$refs = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs.$el;
635
+ var inputWrapper = (_this$$refs2 = this.$refs) == null || (_this$$refs2 = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2.$el;
636
+ var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
637
+ if (textArea) {
638
+ textArea.style.height = '42px';
639
+ var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
640
+ var maxHeight = lineHeight * 11; // max height for 10 lines
641
+ var height = Math.min(textArea.scrollHeight, maxHeight);
642
+ textArea.style.height = height + "px";
643
+ textArea.style.overflowY = height === maxHeight ? 'auto' : 'hidden';
644
+ // wrapper around input/ textarea
645
+ inputWrapper.style.height = height + "px";
646
+ // adjust error-container
647
+
648
+ if (errorContainer) {
649
+ errorContainer.style.bottom = height + "px";
650
+ }
651
+ this.$forceUpdate();
652
+ }
653
+ },
654
+ getTitle: function getTitle() {
655
+ var _this8 = this;
656
+ var hasTitle = this.$props.title || this.$slots.title || null;
657
+ if (hasTitle) {
658
+ return vue.createVNode(Title.Title, {
659
+ "class": helper.getClassName(this.$props.innerClass, 'ai-title') || null
660
+ }, {
661
+ "default": function _default() {
662
+ return [_this8.$props.title || _this8.$slots.title()];
663
+ }
664
+ });
665
+ }
666
+ return null;
667
+ }
668
+ },
669
+ beforeUnmount: function beforeUnmount() {
670
+ if (this.$props.clearSessionOnDestroy) {
671
+ // cleanup logic
672
+ // final Object to store in local storage cache
673
+ var finalCacheObj = helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {};
674
+ // delete current component's cache
675
+ delete finalCacheObj[this.$props.componentId];
676
+ // update local cache
677
+ helper.setObjectInLocalStorage(constants.AI_LOCAL_CACHE_KEY, finalCacheObj);
678
+ }
679
+ },
680
+ render: function render() {
681
+ var _slot5;
682
+ var _this9 = this;
683
+ var props = this.$props;
684
+ if (!this.shouldShowComponent) {
685
+ return null;
686
+ }
687
+ if (!this.isTriggered) {
688
+ return vue.createVNode(SearchBox.Chatbox, {
689
+ "style": props.style || {}
690
+ }, {
691
+ "default": function _default() {
692
+ return [_this9.getTitle(), vue.createVNode("div", {
693
+ "class": "--trigger-message-wrapper",
694
+ "onClick": _this9.handleTriggerClick,
695
+ "aria-hidden": "true"
696
+ }, [_this9.renderTriggerMessageFunc()])];
697
+ }
698
+ });
699
+ }
700
+ return vue.createVNode(SearchBox.Chatbox, {
701
+ "style": props.style || {}
702
+ }, {
703
+ "default": function _default() {
704
+ return [_this9.getTitle(), vue.createVNode(SearchBox.ChatContainer, {
705
+ "class": "--ai-chat-container",
706
+ "theme": props.theme,
707
+ "showInput": props.showInput
708
+ }, {
709
+ "default": function _default() {
710
+ return [_this9.hasCustomRenderer && vue.createVNode(SearchBox.MessagesContainer, {
711
+ "themePreset": _this9.themePreset,
712
+ "theme": props.theme,
713
+ "ref": _this9.$props.innerRef,
714
+ "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
715
+ }, _isSlot(_slot5 = _this9.getComponent()) ? _slot5 : {
716
+ "default": function _default() {
717
+ return [_slot5];
718
+ }
719
+ }), !_this9.hasCustomRenderer && vue.createVNode(SearchBox.MessagesContainer, {
720
+ "themePreset": _this9.themePreset,
721
+ "theme": props.theme,
722
+ "ref": _this9.$props.innerRef,
723
+ "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
724
+ }, {
725
+ "default": function _default() {
726
+ return [_this9.messages.map(function (message, index) {
727
+ return vue.createVNode(SearchBox.Message, {
728
+ "key": index,
729
+ "isSender": message.role === constants.AI_ROLES.USER,
730
+ "innerHTML": md.render(message.content),
731
+ "themePreset": _this9.themePreset,
732
+ "theme": props.theme,
733
+ "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || '')
734
+ }, null);
735
+ }), _this9.isLoadingState && vue.createVNode(SearchBox.Message, {
736
+ "themePreset": _this9.themePreset,
737
+ "theme": props.theme,
738
+ "isSender": false,
739
+ "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || null)
740
+ }, {
741
+ "default": function _default() {
742
+ return [vue.createVNode(SearchBox.TypingIndicator, null, {
743
+ "default": function _default() {
744
+ return [vue.createVNode(SearchBox.TypingDot, {
745
+ "themePreset": _this9.themePreset
746
+ }, null), vue.createVNode(SearchBox.TypingDot, {
747
+ "themePreset": _this9.themePreset
748
+ }, null), vue.createVNode(SearchBox.TypingDot, {
749
+ "themePreset": _this9.themePreset
750
+ }, null)];
751
+ }
752
+ })];
753
+ }
754
+ })];
755
+ }
756
+ }), _this9.renderErrorComponent(), ' ', props.showFeedback && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode("div", {
757
+ "class": "--ai-answer-feedback-container " + (helper.getClassName(props.innerClass, 'ai-feedback') || '')
758
+ }, [vue.createVNode(SearchBox.AIFeedback, {
759
+ "hideUI": _this9.isLoadingState || !_this9.sessionId,
760
+ "key": _this9.sessionId,
761
+ "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
762
+ _this9.trackUsefullness(_this9.sessionId, {
763
+ useful: useful,
764
+ reason: reason
765
+ });
766
+ }
767
+ }, null)]), ' ', _this9.renderAIScreenFooter(), props.showInput && !_this9.isLoadingState && !_this9.isAITyping && vue.createVNode(SearchBox.MessageInputContainer, {
768
+ "class": "--ai-input-container",
769
+ "onSubmit": _this9.handleSendMessage
770
+ }, {
771
+ "default": function _default() {
772
+ return [vue.createVNode(SearchBox.InputGroup, {
773
+ "enableAI": true,
774
+ "isOpen": false
775
+ }, {
776
+ "default": function _default() {
777
+ return [vue.createVNode(CancelSvg.InputWrapper, {
778
+ "ref": _inputWrapperRef
779
+ }, {
780
+ "default": function _default() {
781
+ return [vue.createVNode(SearchBox.MessageInput, {
782
+ "ref": _inputRef,
783
+ "placeholder": props.placeholder,
784
+ "enterButton": props.enterButton,
785
+ "value": _this9.inputMessage,
786
+ "onInput": _this9.handleMessageInputChange,
787
+ "id": props.componentId + "-ai-input",
788
+ "showIcon": props.showIcon,
789
+ "iconPosition": props.iconPosition,
790
+ "themePreset": _this9.themePreset,
791
+ "disabled": _this9.isLoadingState || !_this9.AISessionId,
792
+ "class": helper.getClassName(props.innerClass, 'ai-input') || null
793
+ }, null), ' ', _this9.renderIcons()];
794
+ }
795
+ })];
796
+ }
797
+ }), _this9.renderEnterButtonElement()];
798
+ }
799
+ }), ' '];
800
+ }
801
+ })];
802
+ }
803
+ });
804
+ }
805
+ });
806
+ AIAnswer.hasInternalComponent = function () {
807
+ return true;
808
+ };
809
+ var mapStateToProps = function mapStateToProps(state, props) {
810
+ var dependencyComponent = Object.values(props.react)[0];
811
+ if (Array.isArray(dependencyComponent)) {
812
+ // eslint-disable-next-line prefer-destructuring
813
+ dependencyComponent = dependencyComponent[0];
814
+ }
815
+ var showComponent = !!(state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value);
816
+ var dependentComponentValue = state.selectedValues[dependencyComponent] && state.selectedValues[dependencyComponent].value || '';
817
+ return {
818
+ showComponent: showComponent,
819
+ dependentComponentValue: dependentComponentValue,
820
+ AIResponse: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response,
821
+ isAIResponseLoading: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].isLoading,
822
+ AIResponseError: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].error,
823
+ rawData: state.rawData[props.componentId],
824
+ themePreset: state.config.themePreset,
825
+ isLoading: state.isLoading[props.componentId] || false,
826
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
827
+ componentError: state.error[props.componentId] || null,
828
+ isAITyping: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.isTyping || false
829
+ };
830
+ };
831
+ var mapDispatchToProps = {
832
+ getAIResponse: function getAIResponse(sessionId, componentId, message, shouldFetchMeta) {
833
+ if (shouldFetchMeta === void 0) {
834
+ shouldFetchMeta = false;
835
+ }
836
+ return query.fetchAIResponse(sessionId, componentId, message, null, shouldFetchMeta);
837
+ },
838
+ trackUsefullness: analytics.recordAISessionUsefulness,
839
+ createAISession: query.createAISession
840
+ };
841
+ var AIConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps, mapDispatchToProps)(AIAnswer), {
842
+ componentType: constants.componentTypes.AIAnswer,
843
+ internalComponent: true
844
+ }));
845
+ AIConnected.name = AIAnswer.name;
846
+ AIConnected.hasInternalComponent = AIAnswer.hasInternalComponent;
847
+ AIConnected.install = function (Vue) {
848
+ Vue.component(AIConnected.name, AIConnected);
849
+ };
850
+ // Add componentType for SSR
851
+ AIConnected.componentType = constants.componentTypes.AIAnswer;
852
+
853
+ var _templateObject, _templateObject2;
854
+ var HierarchicalMenuList = vueEmotion.styled('ul')(_templateObject || (_templateObject = _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"])));
855
+ var HierarchicalMenuListItem = vueEmotion.styled('li')(_templateObject2 || (_templateObject2 = _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) {
856
+ return !props.showLine && "\n\t\t\t\t\tdisplay: none;\n\t\t\t\t";
857
+ });
858
+
859
+ var HierarchicalMenuListItemComponent = {
860
+ name: 'HierarchicalMenuListItemComponent',
861
+ data: function data() {
862
+ return {
863
+ isExpanded: false,
864
+ newParentPath: ''
865
+ };
866
+ },
867
+ created: function created() {
868
+ var listItemLabel = this.listItem.key;
869
+ var newParentPath = listItemLabel;
870
+ if (this.parentPath) {
871
+ newParentPath = "" + this.parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + listItemLabel;
872
+ }
873
+ this.newParentPath = newParentPath;
874
+ this.isExpanded = !!helper.recLookup(this.selectedValues, newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
875
+ },
876
+ watch: {
877
+ listItem: function listItem(newVal) {
878
+ if (newVal.initiallyExpanded) {
879
+ this.isExpanded = newVal.initiallyExpanded;
880
+ }
881
+ },
882
+ selectedValues: function selectedValues(newVal) {
883
+ this.isExpanded = !!helper.recLookup(newVal, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
884
+ }
885
+ },
886
+ props: {
887
+ parentPath: types.string,
888
+ selectedValues: types.rawData,
889
+ mode: types.string,
890
+ searchTerm: types.string,
891
+ listItem: types.rawData,
892
+ showLine: types.bool,
893
+ renderItem: types.func,
894
+ handleListItemClick: types.func,
895
+ renderSwitcherIcon: types.func,
896
+ showCheckbox: VueTypes.bool,
897
+ innerClass: types.style,
898
+ showRadio: VueTypes.bool,
899
+ renderIcon: types.func,
900
+ showCount: VueTypes.bool,
901
+ showSwitcherIcon: types.bool,
902
+ switcherIcon: types.children
903
+ },
904
+ render: function render() {
905
+ var _this = this;
906
+ var _this$$props = this.$props,
907
+ selectedValues = _this$$props.selectedValues,
908
+ mode = _this$$props.mode,
909
+ searchTerm = _this$$props.searchTerm,
910
+ listItem = _this$$props.listItem,
911
+ parentPath = _this$$props.parentPath,
912
+ showLine = _this$$props.showLine,
913
+ renderItem = _this$$props.renderItem,
914
+ handleListItemClick = _this$$props.handleListItemClick,
915
+ showCheckbox = _this$$props.showCheckbox,
916
+ innerClass = _this$$props.innerClass,
917
+ showRadio = _this$$props.showRadio,
918
+ renderIcon = _this$$props.renderIcon,
919
+ showCount = _this$$props.showCount,
920
+ showSwitcherIcon = _this$$props.showSwitcherIcon;
921
+ if (!(listItem instanceof Object) || Object.keys(listItem).length === 0) {
922
+ return null;
923
+ }
924
+ var listItemLabel = listItem.key;
925
+ var listItemCount = listItem.count;
926
+ var isLeafNode = !(Array.isArray(listItem.list) && listItem.list.length > 0);
927
+ var renderSwitcherIcon = function renderSwitcherIcon(isExpandedProp) {
928
+ if (showSwitcherIcon === false) {
929
+ return null;
930
+ }
931
+ var switcherIcon = _this.$props.switcherIcon;
932
+ if (switcherIcon) return switcherIcon(isExpandedProp);
933
+ return (
934
+ /* eslint-disable jsx-a11y/click-events-have-key-events
935
+ , jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-tabindex */
936
+ vue.createVNode("span", {
937
+ "tabIndex": "0",
938
+ "onClick": function onClick(e) {
939
+ e.stopPropagation();
940
+ _this.isExpanded = !_this.isExpanded;
941
+ },
942
+ "class": "--switcher-icon"
943
+ }, [vue.createTextVNode("\u27A4")])
944
+ );
945
+ };
946
+ var isSelected = false;
947
+ if (mode === 'single') {
948
+ if (helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR) === true) {
949
+ isSelected = true;
950
+ }
951
+ } else {
952
+ isSelected = !!helper.recLookup(selectedValues, this.newParentPath, constants.TREELIST_VALUES_PATH_SEPARATOR);
953
+ }
954
+ return vue.createVNode(HierarchicalMenuListItem, {
955
+ "class": (isSelected ? '-selected-item' : '') + " " + (this.isExpanded ? '-expanded-item' : ''),
956
+ "key": this.newParentPath,
957
+ "showLine": showLine
958
+ }, {
959
+ "default": function _default() {
960
+ return [vue.createVNode(ListItem.ListItem, {
961
+ "isTreeListItem": true,
962
+ "onClick": function onClick() {
963
+ handleListItemClick(listItemLabel, parentPath);
964
+ },
965
+ "style": {
966
+ textDecoration: 'none'
967
+ }
968
+ }, {
969
+ "default": function _default() {
970
+ return [renderItem ? renderItem(listItemLabel, listItemCount, isSelected) : vue.createVNode(Flex.Flex, {
971
+ "alignItems": "center",
972
+ "gap": "5px"
973
+ }, {
974
+ "default": function _default() {
975
+ return [!isLeafNode && renderSwitcherIcon(isSelected), mode === 'multiple' && showCheckbox && vue.createVNode(Flex.Flex, {
976
+ "alignItems": "center",
977
+ "gap": "5px"
978
+ }, {
979
+ "default": function _default() {
980
+ return [vue.createVNode(FormControlList.Checkbox, {
981
+ "type": "checkbox",
982
+ "class": helper.getClassName(innerClass, 'checkbox') || null,
983
+ "checked": isSelected,
984
+ "id": listItemLabel + "-checkbox-" + _this.newParentPath,
985
+ "name": listItemLabel + "-checkbox-" + _this.newParentPath,
986
+ "show": true,
987
+ "readOnly": true
988
+ }, null), vue.createVNode("label", {
989
+ "style": {
990
+ width: '26px',
991
+ marginTop: 0,
992
+ marginBottom: 0,
993
+ marginRight: '-9px',
994
+ left: '-3px'
995
+ },
996
+ "htmlFor": listItemLabel + "-checkbox-" + _this.newParentPath,
997
+ "onClick": function onClick(e) {
998
+ e.stopPropagation();
999
+ }
1000
+ }, null)];
1001
+ }
1002
+ }), mode === 'single' && showRadio && vue.createVNode(Flex.Flex, {
1003
+ "alignItems": "center",
1004
+ "gap": "5px"
1005
+ }, {
1006
+ "default": function _default() {
1007
+ return [vue.createVNode(FormControlList.Radio, {
1008
+ "checked": isSelected,
1009
+ "class": helper.getClassName(innerClass, 'radio') || null,
1010
+ "id": listItemLabel + "-radio-" + _this.newParentPath,
1011
+ "name": listItemLabel + "-radio-" + _this.newParentPath,
1012
+ "show": true,
1013
+ "readOnly": true,
1014
+ "type": "radio"
1015
+ }, null), vue.createVNode("label", {
1016
+ "style": {
1017
+ width: '26px',
1018
+ marginTop: 0,
1019
+ marginBottom: 0,
1020
+ marginRight: '-9px',
1021
+ left: '-3px'
1022
+ },
1023
+ "htmlFor": listItemLabel + "-radio-" + _this.newParentPath,
1024
+ "onClick": function onClick(e) {
1025
+ e.stopPropagation();
1026
+ }
1027
+ }, null)];
1028
+ }
1029
+ }), ' ', renderIcon(isLeafNode), vue.createVNode("div", {
1030
+ "class": "--list-item-label-count-wrapper"
1031
+ }, [vue.createVNode("span", {
1032
+ "class": "--list-item-label " + (helper.getClassName(innerClass, 'label') || '')
1033
+ }, [listItemLabel]), showCount && vue.createVNode("span", {
1034
+ "class": "--list-item-count " + (helper.getClassName(innerClass, 'count') || '')
1035
+ }, [listItemCount])])];
1036
+ }
1037
+ })];
1038
+ }
1039
+ }), isLeafNode === false && vue.createVNode("div", {
1040
+ "class": "--list-child " + (showSwitcherIcon ? ' --show-switcher-icon' : '')
1041
+ }, [vue.createVNode(HierarchicalMenuComponent, {
1042
+ "key": _this.newParentPath + "-" + listItemLabel + "-" + listItemCount,
1043
+ "listArray": listItem.list,
1044
+ "parentPath": _this.newParentPath,
1045
+ "isExpanded": _this.isExpanded,
1046
+ "listItemProps": {
1047
+ mode: mode,
1048
+ selectedValues: selectedValues,
1049
+ searchTerm: searchTerm,
1050
+ showLine: showLine,
1051
+ renderItem: renderItem,
1052
+ handleListItemClick: handleListItemClick,
1053
+ renderSwitcherIcon: renderSwitcherIcon,
1054
+ showCheckbox: showCheckbox,
1055
+ innerClass: innerClass,
1056
+ showRadio: showRadio,
1057
+ renderIcon: renderIcon,
1058
+ showCount: showCount,
1059
+ showSwitcherIcon: showSwitcherIcon,
1060
+ switcherIcon: _this.$props.switcherIcon
1061
+ }
1062
+ }, null)])];
1063
+ }
1064
+ });
1065
+ }
1066
+ };
1067
+
1068
+ function _isSlot$1(s) {
1069
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
1070
+ }
1071
+ var HierarchicalMenuComponent = {
1072
+ name: 'HierarchicalMenuComponent',
1073
+ props: {
1074
+ listArray: VueTypes.arrayOf(VueTypes.object),
1075
+ // array of objects
1076
+ parentPath: VueTypes.string.def(''),
1077
+ isExpanded: VueTypes.bool.def(false),
1078
+ listItemProps: types.rawData
1079
+ },
1080
+ render: function render() {
1081
+ var _slot;
1082
+ var _this$$props = this.$props,
1083
+ listArray = _this$$props.listArray,
1084
+ isExpanded = _this$$props.isExpanded,
1085
+ parentPath = _this$$props.parentPath,
1086
+ listItemProps = _this$$props.listItemProps;
1087
+ if (!Array.isArray(listArray) || listArray.length === 0) {
1088
+ return null;
1089
+ }
1090
+ return vue.createVNode(HierarchicalMenuList, {
1091
+ "class": "" + (isExpanded ? '--open' : ''),
1092
+ "isSelected": isExpanded
1093
+ }, _isSlot$1(_slot = listArray.map(function (listItem) {
1094
+ return vue.createVNode(HierarchicalMenuListItemComponent, vue.mergeProps({
1095
+ "key": parentPath + "__" + JSON.stringify(listItem),
1096
+ "parentPath": parentPath,
1097
+ "listItem": listItem
1098
+ }, listItemProps), null);
1099
+ })) ? _slot : {
1100
+ "default": function _default() {
1101
+ return [_slot];
1102
+ }
1103
+ });
1104
+ }
1105
+ };
1106
+
1107
+ function _isSlot$2(s) {
1108
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
1109
+ }
1110
+ var updateQueryAction = reactivecore.Actions.updateQuery,
1111
+ setQueryOptions = reactivecore.Actions.setQueryOptions;
1112
+ var transformValueIntoLocalState = function transformValueIntoLocalState(valueArray) {
1113
+ var valueToSet = {};
1114
+ if (valueArray.length) {
1115
+ var newSelectedValues = {};
1116
+ valueArray.forEach(function (valueItem) {
1117
+ helper.setDeep(newSelectedValues, valueItem.split(' > '), !helper.recLookup(newSelectedValues, valueItem.split(' > '), constants.TREELIST_VALUES_PATH_SEPARATOR), true);
1118
+ });
1119
+ valueToSet = newSelectedValues;
1120
+ }
1121
+ return valueToSet;
1122
+ };
1123
+ var TreeList = {
1124
+ name: 'TreeList',
1125
+ props: {
1126
+ selectedValue: vueTypes.types.selectedValue,
1127
+ error: vueTypes.types.title,
1128
+ rawData: vueTypes.types.rawData,
1129
+ aggregationData: vueTypes.types.rawData,
1130
+ themePreset: vueTypes.types.themePreset,
1131
+ updateQueryAction: vueTypes.types.funcRequired,
1132
+ setQueryOptions: vueTypes.types.funcRequired,
1133
+ // component props
1134
+ componentId: vueTypes.types.string.isRequired,
1135
+ className: vueTypes.types.string,
1136
+ style: vueTypes.types.style,
1137
+ showRadio: VueTypes.bool.def(false),
1138
+ showCheckbox: vueTypes.types.bool.def(false),
1139
+ mode: VueTypes.oneOf(['single', 'multiple']).def('multiple'),
1140
+ showCount: VueTypes.bool.def(false),
1141
+ showSearch: VueTypes.bool.def(false),
1142
+ showIcon: VueTypes.bool.def(false),
1143
+ icon: vueTypes.types.children,
1144
+ showLeafIcon: VueTypes.bool.def(false),
1145
+ leafIcon: vueTypes.types.children,
1146
+ showLine: VueTypes.bool.def(false),
1147
+ switcherIcon: vueTypes.types.func,
1148
+ render: vueTypes.types.func,
1149
+ renderItem: vueTypes.types.func,
1150
+ innerClass: vueTypes.types.style,
1151
+ placeholder: vueTypes.types.string,
1152
+ title: vueTypes.types.title,
1153
+ isLoading: vueTypes.types.bool,
1154
+ dataField: vueTypes.types.stringArray.isRequired,
1155
+ onQueryChange: vueTypes.types.func,
1156
+ defaultValue: vueTypes.types.stringArray,
1157
+ value: vueTypes.types.stringArray,
1158
+ customQuery: vueTypes.types.func,
1159
+ defaultQuery: vueTypes.types.func,
1160
+ enableAppbase: vueTypes.types.bool,
1161
+ index: vueTypes.types.string,
1162
+ showFilter: vueTypes.types.bool,
1163
+ URLParams: vueTypes.types.bool,
1164
+ filterLabel: vueTypes.types.string,
1165
+ onChange: vueTypes.types.func,
1166
+ onValueChange: vueTypes.types.func,
1167
+ beforeValueChange: vueTypes.types.func,
1168
+ sortBy: vueTypes.types.sortByWithCount.def('count'),
1169
+ onError: vueTypes.types.func,
1170
+ showSwitcherIcon: vueTypes.types.bool.def(true),
1171
+ renderError: vueTypes.types.title,
1172
+ renderNoResults: vueTypes.types.func,
1173
+ loader: vueTypes.types.title,
1174
+ aggergationSize: vueTypes.types.number,
1175
+ endpoint: vueTypes.types.endpoint,
1176
+ queryFormat: vueTypes.types.queryFormatSearch.def('or'),
1177
+ size: vueTypes.types.number.def(100),
1178
+ nestedField: vueTypes.types.string,
1179
+ react: vueTypes.types.react,
1180
+ transformData: vueTypes.types.func,
1181
+ selectAllLabel: vueTypes.types.string,
1182
+ showMissing: VueTypes.bool.def(false),
1183
+ missingLabel: VueTypes.string.def('N/A')
1184
+ },
1185
+ data: function data() {
1186
+ var props = this.$props;
1187
+ this.__state = {
1188
+ selectedValues: {},
1189
+ searchTerm: '',
1190
+ aggregationData: []
1191
+ };
1192
+ this.internalComponent = props.componentId + "__internal";
1193
+ return this.__state;
1194
+ },
1195
+ created: function created() {
1196
+ var props = this.$props;
1197
+ var componentId = props.componentId;
1198
+ var defaultValue = this.defaultValue || this.value;
1199
+ var currentValueArray = this.selectedValue || defaultValue || [];
1200
+ // update local state for selected values
1201
+ if (currentValueArray.length) {
1202
+ var newSelectedValues = transformValueIntoLocalState(currentValueArray);
1203
+ this.setValue(newSelectedValues, true);
1204
+ }
1205
+
1206
+ // Set custom and default queries in store
1207
+ helper.updateCustomQuery(componentId, props, currentValueArray);
1208
+ helper.updateDefaultQuery(componentId, props, currentValueArray);
1209
+ this.updateQueryOptions();
1210
+ },
1211
+ mounted: function mounted() {
1212
+ var _this$$props = this.$props,
1213
+ enableAppbase = _this$$props.enableAppbase,
1214
+ index = _this$$props.index;
1215
+ if (!enableAppbase && index) {
1216
+ console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
1217
+ }
1218
+ },
1219
+ watch: {
1220
+ defaultQuery: function defaultQuery() {
1221
+ this.updateDefaultQuery();
1222
+ this.updateQuery([]);
1223
+ },
1224
+ customQuery: function customQuery() {
1225
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
1226
+ this.updateQuery(valueArray);
1227
+ },
1228
+ sortBy: function sortBy() {
1229
+ this.updateQueryOptions();
1230
+ },
1231
+ dataField: function dataField() {
1232
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues) || [];
1233
+ this.updateQueryOptions();
1234
+ this.updateQuery(valueArray);
1235
+ },
1236
+ value: function value(newVal, oldVal) {
1237
+ if (!helper.isEqual(newVal, oldVal)) {
1238
+ this.setValue(newVal);
1239
+ }
1240
+ },
1241
+ selectedValue: function selectedValue(newVal) {
1242
+ if (!helper.isEqual(helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues), newVal)) {
1243
+ var _this$$props2 = this.$props,
1244
+ value = _this$$props2.value,
1245
+ onChange = _this$$props2.onChange;
1246
+ var valueToSet = [];
1247
+ if (Array.isArray(newVal) && newVal.length) {
1248
+ valueToSet = newVal;
1249
+ }
1250
+ if (value === undefined) {
1251
+ this.setValue(valueToSet);
1252
+ } else if (onChange && !helper.isEqual(value, valueToSet)) {
1253
+ onChange(valueToSet);
1254
+ }
1255
+ }
1256
+ },
1257
+ aggregationData: function aggregationData(newVal, oldVal) {
1258
+ if (newVal && !helper.isEqual(newVal, oldVal)) {
1259
+ this.$data.aggregationData = newVal;
1260
+ }
1261
+ }
1262
+ },
1263
+ computed: {
1264
+ hasCustomRenderer: function hasCustomRenderer() {
1265
+ return index.hasCustomRenderer(this);
1266
+ }
1267
+ },
1268
+ methods: {
1269
+ renderIcon: function renderIcon(isLeafNode) {
1270
+ var _this$$props3 = this.$props,
1271
+ showIcon = _this$$props3.showIcon,
1272
+ showLeafIcon = _this$$props3.showLeafIcon,
1273
+ icon = _this$$props3.icon;
1274
+ if (isLeafNode) {
1275
+ if (!showLeafIcon) return null;
1276
+ var _ref = this.$slots || this.$props,
1277
+ leafIcon = _ref.leafIcon;
1278
+ if (leafIcon) return leafIcon();
1279
+ return vue.createVNode("span", {
1280
+ "role": "img",
1281
+ "aria-label": "file",
1282
+ "class": "--leaf-icon"
1283
+ }, [vue.createVNode("svg", {
1284
+ "viewBox": "64 64 896 896",
1285
+ "focusable": "false",
1286
+ "data-icon": "file",
1287
+ "width": "1em",
1288
+ "height": "1em",
1289
+ "fill": "currentColor",
1290
+ "aria-hidden": "true"
1291
+ }, [vue.createVNode("path", {
1292
+ "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"
1293
+ }, null)])]);
1294
+ }
1295
+ if (!showIcon) return null;
1296
+ if (icon) {
1297
+ return icon;
1298
+ }
1299
+ if (this.$slots.icon) {
1300
+ return this.$slots.icon();
1301
+ }
1302
+ return vue.createVNode("span", {
1303
+ "role": "img",
1304
+ "aria-label": "folder-open",
1305
+ "class": "--folder-icon"
1306
+ }, [vue.createVNode("svg", {
1307
+ "viewBox": "64 64 896 896",
1308
+ "focusable": "false",
1309
+ "data-icon": "folder-open",
1310
+ "width": "1em",
1311
+ "height": "1em",
1312
+ "fill": "currentColor",
1313
+ "aria-hidden": "true"
1314
+ }, [vue.createVNode("path", {
1315
+ "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"
1316
+ }, null)])]);
1317
+ },
1318
+ getTransformedData: function getTransformedData() {
1319
+ var _this$$props4 = this.$props,
1320
+ dataField = _this$$props4.dataField,
1321
+ showSearch = _this$$props4.showSearch;
1322
+ var transformedData = helper.transformRawTreeListData(this.$data.aggregationData, dataField);
1323
+ var filteredData = [];
1324
+ if (showSearch && this.searchTerm) {
1325
+ filteredData = this.filterDataBasedOnSearchTerm(transformedData, '');
1326
+ }
1327
+ return filteredData.length ? filteredData : transformedData;
1328
+ },
1329
+ handleInputChange: function handleInputChange(e) {
1330
+ var value = e.target.value;
1331
+ this.searchTerm = value;
1332
+ },
1333
+ renderSearch: function renderSearch() {
1334
+ var _this$$props5 = this.$props,
1335
+ showSearch = _this$$props5.showSearch,
1336
+ innerClass = _this$$props5.innerClass,
1337
+ placeholder = _this$$props5.placeholder,
1338
+ componentId = _this$$props5.componentId,
1339
+ themePreset = _this$$props5.themePreset;
1340
+ if (showSearch) {
1341
+ return vue.createVNode(Input.Input, {
1342
+ "class": helper.getClassName(innerClass, 'input') || null,
1343
+ "onInput": this.handleInputChange,
1344
+ "value": this.searchTerm,
1345
+ "placeholder": placeholder || 'Search',
1346
+ "style": {
1347
+ margin: '0 0 8px'
1348
+ },
1349
+ "aria-label": componentId + "-search",
1350
+ "themePreset": themePreset
1351
+ }, null);
1352
+ }
1353
+ return null;
1354
+ },
1355
+ handleListItemClick: function handleListItemClick(key, parentPath) {
1356
+ var path = key;
1357
+ if (parentPath) {
1358
+ path = "" + parentPath + constants.TREELIST_VALUES_PATH_SEPARATOR + key;
1359
+ }
1360
+ var newSelectedValues = _rollupPluginBabelHelpers._extends({}, this.selectedValues);
1361
+ if (this.$props.mode === 'single') {
1362
+ newSelectedValues = {};
1363
+ helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), true, true);
1364
+ } else {
1365
+ var newValue = !helper.recLookup(newSelectedValues, path, constants.TREELIST_VALUES_PATH_SEPARATOR);
1366
+ helper.setDeep(newSelectedValues, path.split(constants.TREELIST_VALUES_PATH_SEPARATOR), newValue, true);
1367
+ }
1368
+ newSelectedValues = utils.sanitizeObject(_rollupPluginBabelHelpers._extends({}, newSelectedValues));
1369
+ if (this.$props.value === undefined) {
1370
+ this.setValue(newSelectedValues);
1371
+ } else if (this.$props.onChange) {
1372
+ var valueToSet = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(newSelectedValues);
1373
+ this.$props.onChange(valueToSet);
1374
+ }
1375
+ },
1376
+ filterDataBasedOnSearchTerm: function filterDataBasedOnSearchTerm(listArray, parentPath) {
1377
+ var _this = this;
1378
+ if (!(listArray && Array.isArray(listArray) && listArray.length)) {
1379
+ return null;
1380
+ }
1381
+ var result = [];
1382
+ listArray.forEach(function (ele) {
1383
+ var isLeafItem = !ele.list;
1384
+ var newParentPath = ele.key;
1385
+ if (parentPath) {
1386
+ newParentPath = parentPath + "." + ele.key;
1387
+ }
1388
+ 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);
1389
+ if (isLeafItem && keyHasSearchTerm) {
1390
+ result.push(_rollupPluginBabelHelpers._extends({}, ele, {
1391
+ initiallyExpanded: keyHasSearchTerm
1392
+ }));
1393
+ } else if (!isLeafItem) {
1394
+ var filteredChildrenItems = _this.filterDataBasedOnSearchTerm(ele.list, newParentPath);
1395
+ if (keyHasSearchTerm || !!filteredChildrenItems.length) {
1396
+ result.push(_rollupPluginBabelHelpers._extends({}, ele, {
1397
+ initiallyExpanded: keyHasSearchTerm || !!filteredChildrenItems.length,
1398
+ list: filteredChildrenItems
1399
+ }));
1400
+ }
1401
+ }
1402
+ });
1403
+ return result;
1404
+ },
1405
+ getComponent: function getComponent() {
1406
+ var _this$$props6 = this.$props,
1407
+ rawData = _this$$props6.rawData,
1408
+ error = _this$$props6.error,
1409
+ isLoading = _this$$props6.isLoading;
1410
+ var data = {
1411
+ data: this.getTransformedData(),
1412
+ rawData: rawData,
1413
+ error: error,
1414
+ handleClick: this.handleListItemClick,
1415
+ value: this.$data.selectedValues,
1416
+ loading: isLoading,
1417
+ PATH_SEPARATOR: constants.TREELIST_VALUES_PATH_SEPARATOR
1418
+ };
1419
+ return this.$slots.render(data) || helper.getComponent(data, this.$props);
1420
+ },
1421
+ getDefaultQuery: function getDefaultQuery(value) {
1422
+ var _this2 = this;
1423
+ var query = null;
1424
+ var type = 'term';
1425
+ var booleanAggregator = this.$props.queryFormat === 'or' ? 'should' : 'must';
1426
+ if (!Array.isArray(value) || value.length === 0) {
1427
+ return null;
1428
+ }
1429
+ if (value) {
1430
+ var _bool;
1431
+ // adds a sub-query with must as an array of objects for each term/value
1432
+ var queryArray = value.map(function (item) {
1433
+ return {
1434
+ bool: {
1435
+ must: item.split(' > ').map(function (subItem, i) {
1436
+ var _type, _ref2;
1437
+ return _ref2 = {}, _ref2[type] = (_type = {}, _type[_this2.$props.dataField[i]] = subItem, _type), _ref2;
1438
+ })
1439
+ }
1440
+ };
1441
+ });
1442
+ var listQuery = {
1443
+ bool: (_bool = {}, _bool[booleanAggregator] = queryArray, _bool)
1444
+ };
1445
+ query = value.length ? listQuery : null;
1446
+ }
1447
+ if (query && this.$props.nestedField) {
1448
+ return {
1449
+ nested: {
1450
+ path: this.$props.nestedField,
1451
+ query: query
1452
+ }
1453
+ };
1454
+ }
1455
+ return query;
1456
+ },
1457
+ updateQuery: function updateQuery(value) {
1458
+ var customQuery = this.$props.customQuery;
1459
+ var query = this.getDefaultQuery(value);
1460
+ var customQueryOptions;
1461
+ if (customQuery) {
1462
+ var _ref3 = customQuery(value, this.$props) || {};
1463
+ query = _ref3.query;
1464
+ customQueryOptions = helper.getOptionsFromQuery(customQuery(value, this.$props));
1465
+ helper.updateCustomQuery(this.$props.componentId, this.$props, value);
1466
+ }
1467
+ this.setQueryOptions(this.$props.componentId, _rollupPluginBabelHelpers._extends({}, this.generateQueryOptions(), customQueryOptions));
1468
+ this.updateQueryAction({
1469
+ componentId: this.$props.componentId,
1470
+ query: query,
1471
+ value: value,
1472
+ label: this.$props.filterLabel,
1473
+ showFilter: this.$props.showFilter,
1474
+ URLParams: this.$props.URLParams,
1475
+ componentType: constants.componentTypes.treeList
1476
+ });
1477
+ },
1478
+ setValue: function setValue(value, hasMountedParam) {
1479
+ var _this3 = this;
1480
+ if (hasMountedParam === void 0) {
1481
+ hasMountedParam = true;
1482
+ }
1483
+ var finalValues = Array.isArray(value) === false ? helper.transformTreeListLocalStateIntoQueryComptaibleFormat(value) : value;
1484
+ var performUpdate = function performUpdate() {
1485
+ var handleUpdates = function handleUpdates() {
1486
+ _this3.updateQuery(finalValues);
1487
+ if (_this3.$props.onValueChange) _this3.$props.onValueChange(finalValues);
1488
+ };
1489
+ if (hasMountedParam) {
1490
+ _this3.selectedValues = Array.isArray(value) ? transformValueIntoLocalState(value) : value;
1491
+ handleUpdates();
1492
+ } else {
1493
+ handleUpdates();
1494
+ }
1495
+ };
1496
+ helper.checkValueChange(this.$props.componentId, finalValues, this.$props.beforeValueChange, performUpdate);
1497
+ },
1498
+ generateQueryOptions: function generateQueryOptions() {
1499
+ var queryOptions = helper.getQueryOptions(this.$props);
1500
+ var valueArray = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
1501
+ return helper.getAggsQuery(valueArray, queryOptions, this.$props);
1502
+ },
1503
+ updateDefaultQuery: function updateDefaultQuery(queryOptions) {
1504
+ var value = helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.selectedValues);
1505
+ // Update default query for RS API
1506
+ helper.updateDefaultQuery(this.$props.componentId, this.$props, value);
1507
+ helper.updateInternalQuery(transform.getInternalComponentID(this.$props.componentId), queryOptions, value, this.$props, this.generateQueryOptions(), null);
1508
+ },
1509
+ updateQueryOptions: function updateQueryOptions() {
1510
+ // for a new query due to other changes don't append after to get fresh results
1511
+ var queryOptions = this.generateQueryOptions(this.$props, {}, helper.transformTreeListLocalStateIntoQueryComptaibleFormat(this.$data.selectedValues));
1512
+ if (this.$props.defaultQuery) {
1513
+ // eslint-disable-next-line no-use-before-define
1514
+ this.updateDefaultQuery(queryOptions);
1515
+ } else {
1516
+ this.setQueryOptions(transform.getInternalComponentID(this.$props.componentId), queryOptions);
1517
+ }
1518
+ }
1519
+ },
1520
+ render: function render() {
1521
+ var _this4 = this;
1522
+ var props = this.$props;
1523
+ var style = props.style,
1524
+ className = props.className,
1525
+ mode = props.mode,
1526
+ showLine = props.showLine,
1527
+ renderItem = props.renderItem,
1528
+ showCheckbox = props.showCheckbox,
1529
+ innerClass = props.innerClass,
1530
+ showRadio = props.showRadio,
1531
+ showCount = props.showCount,
1532
+ showSwitcherIcon = props.showSwitcherIcon,
1533
+ switcherIcon = props.switcherIcon,
1534
+ title = props.title,
1535
+ loader = props.loader,
1536
+ renderError = props.renderError;
1537
+ if (this.isLoading) {
1538
+ return (this.$slots.loader ? this.$slots.loader() : loader) || null;
1539
+ }
1540
+ if (this.error) {
1541
+ if (this.$slots.renderError) {
1542
+ return this.$slots.renderError(this.error);
1543
+ }
1544
+ return helper.isFunction(renderError) ? renderError(this.error) : renderError;
1545
+ }
1546
+ var transformedData = this.getTransformedData();
1547
+ if (!transformedData || transformedData.length === 0) {
1548
+ return this.$slots.renderNoResults ? this.$slots.renderNoResults() : null;
1549
+ }
1550
+ return vue.createVNode(Container.Container, {
1551
+ "style": style,
1552
+ "class": className
1553
+ }, {
1554
+ "default": function _default() {
1555
+ return [props.title && vue.createVNode(Title.Title, {
1556
+ "class": helper.getClassName(innerClass, 'title') || null
1557
+ }, _isSlot$2(title) ? title : {
1558
+ "default": function _default() {
1559
+ return [title];
1560
+ }
1561
+ }), _this4.renderSearch(), _this4.hasCustomRenderer ? _this4.getComponent() : vue.createVNode(HierarchicalMenuComponent, {
1562
+ "key": "initial-node",
1563
+ "listArray": transformedData,
1564
+ "parentPath": "",
1565
+ "isExpanded": true,
1566
+ "listItemProps": {
1567
+ mode: mode,
1568
+ selectedValues: _this4.selectedValues,
1569
+ searchTerm: _this4.searchTerm,
1570
+ showLine: showLine,
1571
+ renderItem: renderItem != null ? renderItem : _this4.$slots.renderItem,
1572
+ handleListItemClick: _this4.handleListItemClick,
1573
+ showCheckbox: showCheckbox,
1574
+ innerClass: innerClass,
1575
+ showRadio: showRadio,
1576
+ renderIcon: _this4.renderIcon,
1577
+ showCount: showCount,
1578
+ showSwitcherIcon: showSwitcherIcon,
1579
+ switcherIcon: switcherIcon != null ? switcherIcon : _this4.$slots.switcherIcon
1580
+ }
1581
+ }, null)];
1582
+ }
1583
+ });
1584
+ }
1585
+ };
1586
+ var mapStateToProps$1 = function mapStateToProps(state, props) {
1587
+ return {
1588
+ selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
1589
+ rawData: state.rawData[props.componentId] || {},
1590
+ aggregationData: props.nestedField && state.aggregations[props.componentId] ? state.aggregations[props.componentId].reactivesearch_nested : state.aggregations[props.componentId] || {},
1591
+ themePreset: state.config.themePreset,
1592
+ error: state.error[props.componentId],
1593
+ isLoading: state.isLoading[props.componentId],
1594
+ enableAppbase: state.config.enableAppbase
1595
+ };
1596
+ };
1597
+ var mapDispatchtoProps = {
1598
+ setQueryOptions: setQueryOptions,
1599
+ updateQueryAction: updateQueryAction
1600
+ };
1601
+ TreeList.hasInternalComponent = function () {
1602
+ return true;
1603
+ };
1604
+ var TreeListConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchtoProps)(TreeList), {
1605
+ componentType: constants.componentTypes.treeList,
1606
+ internalComponent: TreeList.hasInternalComponent()
1607
+ }));
1608
+ TreeListConnected.name = TreeList.name;
1609
+ TreeListConnected.install = function (Vue) {
1610
+ Vue.component(TreeListConnected.name, TreeListConnected);
1611
+ };
1612
+
1613
+ // Add componentType for SSR
1614
+ TreeListConnected.componentType = constants.componentTypes.treeList;
1615
+
1616
+ var RcConnected = PreferencesConsumer.PreferencesConsumer({
1617
+ name: 'RcConnected',
1618
+ render: function render() {
1619
+ var component = ReactiveComponent.default;
1620
+ switch (this.$attrs.componentType) {
1621
+ case constants.componentTypes.reactiveList:
1622
+ component = ReactiveList.default;
1623
+ break;
1624
+ case constants.componentTypes.searchBox:
1625
+ component = SearchBox.SearchBox;
1626
+ break;
1627
+ // list components
1628
+ case constants.componentTypes.singleList:
1629
+ component = SingleList.default;
1630
+ break;
1631
+ case constants.componentTypes.multiList:
1632
+ component = MultiList.default;
1633
+ break;
1634
+ case constants.componentTypes.singleDropdownList:
1635
+ component = SingleDropdownList.default;
1636
+ break;
1637
+ case constants.componentTypes.multiDropdownList:
1638
+ component = MultiDropdownList.default;
1639
+ break;
1640
+ // basic components
1641
+ case constants.componentTypes.toggleButton:
1642
+ component = ToggleButton.default;
1643
+ break;
1644
+ // range components
1645
+ case constants.componentTypes.dynamicRangeSlider:
1646
+ component = DynamicRangeSlider.default;
1647
+ break;
1648
+ case constants.componentTypes.singleRange:
1649
+ component = SingleRange.default;
1650
+ break;
1651
+ case constants.componentTypes.multiRange:
1652
+ component = MultiRange.default;
1653
+ break;
1654
+ case constants.componentTypes.rangeSlider:
1655
+ component = RangeSlider.default;
1656
+ break;
1657
+ case constants.componentTypes.rangeInput:
1658
+ component = RangeInput.default;
1659
+ break;
1660
+ }
1661
+ return vue.h(component, null, this.$slots);
1662
+ }
1663
+ });
1664
+ RcConnected.name = ReactiveComponent.default.name;
1665
+ RcConnected.hasInternalComponent = ReactiveComponent.default.hasInternalComponent;
1666
+ // Add componentType for SSR
1667
+ RcConnected.componentType = constants.componentTypes.reactiveComponent;
1668
+ RcConnected.install = function (Vue) {
1669
+ Vue.component(RcConnected.name, RcConnected);
1670
+ };
1671
+
1672
+ var components = [ReactiveList.default, ResultCard.default, ResultList.default, ReactiveBase.default, SearchBox.SearchBox, 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];
1673
+ function install (Vue) {
1674
+ components.map(function (component) {
1675
+ Vue.use(component);
1676
+ return null;
1677
+ });
1678
+ }
1679
+
1680
+ exports.AIAnswer = AIConnected;
1681
+ exports.ReactiveComponentPrivate = RcConnected;
1682
+ exports.TreeList = TreeListConnected;
1683
+ exports.install = install;